Skip to content

Commit

Permalink
add support for other browsers to simulation and browser version crea…
Browse files Browse the repository at this point in the history
…tion hooks
  • Loading branch information
gnarf committed Mar 13, 2024
1 parent 2791508 commit b6d2994
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 43 deletions.
14 changes: 9 additions & 5 deletions server/controllers/AutomationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,12 @@ const updateJobResults = async (req, res) => {
testCsvRow,
presentationNumber,
responses,
atVersionName,
browserVersionName
capabilities: {
atName,
atVersion: atVersionName,
browserName,
browserVersion: browserVersionName
}
} = req.body;
const job = await getCollectionJobById(id);
if (!job) {
Expand All @@ -251,9 +255,9 @@ const updateJobResults = async (req, res) => {
);
}

/* TODO: Change this once we support more At + Browser Combos in Automation */
const [at] = await getAts(null, { name: 'NVDA' });
const [browser] = await getBrowsers(null, { name: 'Chrome' });
/* TODO: Change this to use a better key based lookup system after gh-958 */
const [at] = await getAts(atName);
const [browser] = await getBrowsers(browserName);

const [atVersion, browserVersion] = await Promise.all([
findOrCreateAtVersion({
Expand Down
79 changes: 41 additions & 38 deletions server/tests/util/mock-automation-scheduler-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ const setupMockAutomationSchedulerServer = async () => {

const simulateResultCompletion = async (
tests,
atName,
atVersionName,
browserName,
browserVersionName,
jobId,
currentTestIndex,
Expand All @@ -52,8 +54,12 @@ const setupMockAutomationSchedulerServer = async () => {
});

const testResult = {
atVersionName,
browserVersionName,
capabilities: {
atName,
atVersion: atVersionName,
browserName,
browserVersion: browserVersionName
},
responses
};

Expand All @@ -74,7 +80,9 @@ const setupMockAutomationSchedulerServer = async () => {
setTimeout(() => {
simulateResultCompletion(
tests,
atName,
atVersionName,
browserName,
browserVersionName,
jobId,
currentTestIndex + 1,
Expand Down Expand Up @@ -102,59 +110,52 @@ const setupMockAutomationSchedulerServer = async () => {
});
} else {
// Local development must simulate posting results
const { testPlanVersionGitSha, testPlanName, jobId } = req.body;
const { jobId } = req.body;

const { testPlanVersions } = await query(gql`
const { collectionJob } = await query(gql`
query {
testPlanVersions {
id
gitSha
metadata
testPlan {
id
}
testPlanReports {
at {
name
atVersions {
name
collectionJob (id: "${jobId}") {
testPlanRun {
testPlanReport {
testPlanVersion {
metadata
gitSha
}
}
browser {
name
browserVersions {
at {
name
atVersions {
name
}
}
}
runnableTests {
id
rowNumber
scenarios {
id
browser {
name
browserVersions {
name
}
}
assertions {
runnableTests {
id
rowNumber
scenarios {
id
}
assertions {
id
}
}
}
}
}
}
`);
const testPlanVersion = testPlanVersions.find(
testPlanVersion =>
testPlanVersion.gitSha === testPlanVersionGitSha &&
testPlanVersion.testPlan.id === testPlanName
);

const testPlanReport = testPlanVersion.testPlanReports.find(
testPlanReport =>
testPlanReport.at.name === 'NVDA' &&
testPlanReport.browser.name === 'Chrome'
);
const { testPlanReport } = collectionJob.testPlanRun;
const { testPlanVersion } = testPlanReport;

const browserName = testPlanReport.browser.name;
const browserVersionName =
testPlanReport.browser.browserVersions[0].name;

const atName = testPlanReport.at.name;
const atVersionName = testPlanReport.at.atVersions[0].name;
const { runnableTests } = testPlanReport;

Expand All @@ -173,7 +174,9 @@ const setupMockAutomationSchedulerServer = async () => {
() =>
simulateResultCompletion(
runnableTests,
atName,
atVersionName,
browserName,
browserVersionName,
jobId,
0,
Expand Down

0 comments on commit b6d2994

Please sign in to comment.