Skip to content

Commit

Permalink
Add test for proper room assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesPHoughton committed Oct 19, 2023
1 parent e6e2cae commit 86409b1
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions cypress/e2e/06_Many_Games.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ describe("Many Games", { retries: { runMode: 2, openMode: 0 } }, () => {
cy.stepConsent(playerKey);
});

cy.window().then((win) => {
cy.wrap(win.batchLabel).as("batchLabel");
});

playerKeys.slice(0, 8).forEach((playerKey) => {
cy.stepVideoCheck(playerKey, { headphonesRequired: true });
});
Expand Down Expand Up @@ -100,6 +104,34 @@ describe("Many Games", { retries: { runMode: 2, openMode: 0 } }, () => {
cy.waitForGameLoad(playerKey);
});

// end the batch
cy.empiricaClearBatches();
cy.wait(3000);

// get science data
cy.get("@batchLabel").then((batchLabel) => {
cy.readFile(`../data/scienceData/batch_${batchLabel}.jsonl`)
.then((txt) => {
const lines = txt.split("\n").filter((line) => line.length > 0);
const objs = lines.map((line) => JSON.parse(line));
return objs;
})
.as("dataObjects");
});

const valueCounts = (a) =>
new Map([...new Set(a)].map((x) => [x, a.filter((y) => y === x).length]));

// check that player 1's data is exported even though player 2 is not finished
cy.get("@dataObjects").then((dataObjects) => {
const recordingsFolders = dataObjects.map((obj) => obj.recordingsFolder);
const counts = valueCounts(recordingsFolders);
expect(counts.size).to.equal(8);
expect(Array.from(counts.values())).to.deep.equal([
2, 2, 2, 2, 2, 2, 2, 2,
]);
});

// check for server-side errors
cy.readFile(`../data/empirica.log`).as("empiricaLogs");
cy.get("@empiricaLogs").then((txt) => {
Expand Down

0 comments on commit 86409b1

Please sign in to comment.