Skip to content

Commit

Permalink
Add tests for online_qa
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Jan 4, 2024
1 parent 46dbe53 commit a22aba4
Show file tree
Hide file tree
Showing 4 changed files with 258 additions and 7 deletions.
16 changes: 13 additions & 3 deletions src/__tests__/backends/penta/PentabarfParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ const prefixConfig: IPrefixConfig = {
},
};

function getFixture(fixtureFile: string) {
return fs.readFileSync(path.join(__dirname, fixtureFile), 'utf8')
}

/*
* A somewhat vague test that just loads in a basic file and checks a few things, comparing against the snapshots in
* __snapshots__.
*/
test('parsing pentabarf XML: overview', () => {
const xml = fs.readFileSync(path.join(__dirname, "pentabarf01_overview.xml"), 'utf8');
const xml = getFixture("pentabarf01_overview.xml");
const p = new PentabarfParser(xml, prefixConfig);

// TODO the auditorium id and slug look dodgy and not id-like or slug-like...
Expand All @@ -49,18 +53,24 @@ test('parsing pentabarf XML: overview', () => {


test('duplicate events lead to errors', () => {
const xml = fs.readFileSync(path.join(__dirname, "pentabarf03_duplicate_talk.xml"), 'utf8');
const xml = getFixture("pentabarf03_duplicate_talk.xml");

expect(() => new PentabarfParser(xml, prefixConfig)).toThrow(
"Auditorium A.01 (Someroom): Talk E001: this talk already exists and is defined a second time."
);
});

test("unrecognised prefixes don't create rooms", () => {
const xml = fs.readFileSync(path.join(__dirname, "pentabarf04_unrecognised_prefix.xml"), 'utf8');
const xml = getFixture("pentabarf04_unrecognised_prefix.xml");
const p = new PentabarfParser(xml, prefixConfig);

expect(p.auditoriums.length).toEqual(0);
expect(p.talks.length).toEqual(0);
expect(p.interestRooms.length).toEqual(0);
});

test("tracks that set a online qa value correctly apply to talks", () => {
const xml = getFixture("pentabarf05_online_qa.xml");
const p = new PentabarfParser(xml, prefixConfig);
expect(p.talks).toMatchSnapshot("talks");
});
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,128 @@ exports[`parsing pentabarf XML: overview: talks 1`] = `
},
]
`;

exports[`tracks that set a online qa value correctly apply to talks: talks 1`] = `
[
{
"auditoriumId": "A.01 (Someroom)",
"dateTs": 1675468800000,
"endTime": 1675502100000,
"id": "E001",
"livestream_endTime": 0,
"prerecorded": true,
"qa_startTime": 0,
"slug": "testcon_opening_remarks",
"speakers": [
{
"email": "",
"id": "9012",
"matrix_id": "",
"name": "John Teststone",
"role": "speaker",
},
{
"email": "",
"id": "90367",
"matrix_id": "",
"name": "Evå 完牲 Exampleson",
"role": "speaker",
},
],
"startTime": 1675501200000,
"subtitle": "",
"title": "Testcon01: Opening Remarks",
"track": "TrackWithQA",
},
{
"auditoriumId": "A.01 (Someroom)",
"dateTs": 1675468800000,
"endTime": 1675503900000,
"id": "E002",
"livestream_endTime": 0,
"prerecorded": true,
"qa_startTime": 0,
"slug": "testcon_opening_remarks",
"speakers": [
{
"email": "",
"id": "9012",
"matrix_id": "",
"name": "John Teststone",
"role": "speaker",
},
{
"email": "",
"id": "90367",
"matrix_id": "",
"name": "Evå 完牲 Exampleson",
"role": "speaker",
},
],
"startTime": 1675502100000,
"subtitle": "",
"title": "Testcon01: Opening Remarks",
"track": "TrackWithoutQA",
},
{
"auditoriumId": "A.01 (Someroom)",
"dateTs": 1675468800000,
"endTime": 1675504800000,
"id": "E003",
"livestream_endTime": 0,
"prerecorded": true,
"qa_startTime": null,
"slug": "testcon_opening_remarks",
"speakers": [
{
"email": "",
"id": "9012",
"matrix_id": "",
"name": "John Teststone",
"role": "speaker",
},
{
"email": "",
"id": "90367",
"matrix_id": "",
"name": "Evå 完牲 Exampleson",
"role": "speaker",
},
],
"startTime": 1675503000000,
"subtitle": "",
"title": "Testcon01: Opening Remarks",
"track": "UnspecifiedTrack",
},
{
"auditoriumId": "AQ.5 (QA Room)",
"dateTs": 1675468800000,
"endTime": 1675505700000,
"id": "E004",
"livestream_endTime": 0,
"prerecorded": true,
"qa_startTime": 0,
"slug": "testcon_opening_remarks",
"speakers": [
{
"email": "",
"id": "9012",
"matrix_id": "",
"name": "John Teststone",
"role": "speaker",
},
{
"email": "",
"id": "90367",
"matrix_id": "",
"name": "Evå 完牲 Exampleson",
"role": "speaker",
},
],
"startTime": 1675503900000,
"subtitle": "",
"title": "Testcon01: Opening Remarks",
"track": "UnspecifiedTrack",
},
]
`;
113 changes: 113 additions & 0 deletions src/__tests__/backends/penta/pentabarf05_online_qa.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<schedule>
<conference>
<title>Testcon01</title>
<subtitle/>
</conference>
<tracks>
<track online_qa="true">TrackWithQA</track>
<track online_qa="false">TrackWithoutQA</track>
</tracks>
<day index="1" date="2023-02-04">
<room name="A.01 (Someroom)">
<event id="E001">
<start>09:00</start>
<duration>00:15</duration>
<room>A.01 (Someroom)</room>
<slug>testcon_opening_remarks</slug>
<title>Testcon01: Opening Remarks</title>
<subtitle/>
<track>TrackWithQA</track>
<type>devroom</type>
<language/>
<abstract>
&lt;p&gt;Opening remarks&lt;/p&gt;
</abstract>
<description></description>
<persons>
<person id="9012">John Teststone</person>
<person id="90367">Evå 完牲 Exampleson</person> <!-- seemed wise to test some Unicode -->
</persons>
<attachments>
</attachments>
<links>
<link href="https://example.org">Submit feedback</link>
</links>
</event>
<event id="E002">
<start>09:15</start>
<duration>00:30</duration>
<room>A.01 (Someroom)</room>
<slug>testcon_opening_remarks</slug>
<title>Testcon01: Opening Remarks</title>
<subtitle/>
<track>TrackWithoutQA</track>
<type>devroom</type>
<language/>
<abstract>
&lt;p&gt;Opening remarks&lt;/p&gt;
</abstract>
<description></description>
<persons>
<person id="9012">John Teststone</person>
<person id="90367">Evå 完牲 Exampleson</person> <!-- seemed wise to test some Unicode -->
</persons>
<attachments>
</attachments>
<links>
<link href="https://example.org">Submit feedback</link>
</links>
</event>
<event id="E003">
<start>09:30</start>
<duration>00:30</duration>
<room>A.01 (Someroom)</room>
<slug>testcon_opening_remarks</slug>
<title>Testcon01: Opening Remarks</title>
<subtitle/>
<track>UnspecifiedTrack</track>
<type>devroom</type>
<language/>
<abstract>
&lt;p&gt;Opening remarks&lt;/p&gt;
</abstract>
<description></description>
<persons>
<person id="9012">John Teststone</person>
<person id="90367">Evå 完牲 Exampleson</person> <!-- seemed wise to test some Unicode -->
</persons>
<attachments>
</attachments>
<links>
<link href="https://example.org">Submit feedback</link>
</links>
</event>
</room>
<room name="AQ.5 (QA Room)">
<event id="E004" >
<start>09:45</start>
<duration>00:30</duration>
<room>AQ.5 (QA Room)</room>
<slug>testcon_opening_remarks</slug>
<title>Testcon01: Opening Remarks</title>
<subtitle/>
<track>UnspecifiedTrack</track>
<type>devroom</type>
<language/>
<abstract>
&lt;p&gt;Opening remarks&lt;/p&gt;
</abstract>
<description></description>
<persons>
<person id="9012">John Teststone</person>
<person id="90367">Evå 完牲 Exampleson</person> <!-- seemed wise to test some Unicode -->
</persons>
<attachments>
</attachments>
<links>
<link href="https://example.org">Submit feedback</link>
</links>
</event>
</room>
</day>
</schedule>
11 changes: 7 additions & 4 deletions src/backends/penta/PentabarfParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,13 @@ export interface IPentabarfSchedule {
day_change: string;
timeslot_duration: string;
};
tracks: {
/**
* This is an extension from FOSDEM.
*/
tracks?: {
track: [{
attr: {
"@online_qa": string;
"@_online_qa": string;
};
"#text": string;
}]
Expand Down Expand Up @@ -156,8 +159,8 @@ export class PentabarfParser {
};
const trackHasOnlineQA = new Map<string, boolean>();

for (const track of this.parsed.schedule.tracks.track) {
trackHasOnlineQA.set(track["#text"], Boolean(track.attr["@online_qa"]));
for (const track of this.parsed.schedule.tracks?.track || []) {
trackHasOnlineQA.set(track["#text"], Boolean(track.attr["@_online_qa"]));
}

for (const day of arrayLike(this.parsed.schedule?.day)) {
Expand Down

0 comments on commit a22aba4

Please sign in to comment.