Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add test for decimal rowNumber test automation (See #1106) #1114

Merged
merged 1 commit into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 111 additions & 2 deletions server/tests/integration/automation-scheduler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,14 @@ const getTestCollectionJob = async (jobId, { transaction }) =>
{ transaction }
);

const scheduleCollectionJobByMutation = async ({ transaction }) =>
const scheduleCollectionJobByMutation = async ({
transaction,
reportId = testPlanReportId
}) =>
await mutate(
`
mutation {
scheduleCollectionJob(testPlanReportId: "${testPlanReportId}") {
scheduleCollectionJob(testPlanReportId: "${reportId}") {
id
status
testPlanRun {
Expand Down Expand Up @@ -564,6 +567,112 @@ describe('Automation controller', () => {
});
});

it('should update job results with decimal presentationNumber', async () => {
await apiServer.sessionAgentDbCleaner(async transaction => {
const { scheduleCollectionJob: job } =
await scheduleCollectionJobByMutation({
transaction,
reportId: '19'
});
const collectionJob = await getCollectionJobById({
id: job.id,
transaction
});
await sessionAgent
.post(`/api/jobs/${job.id}`)
.send({ status: 'RUNNING' })
.set(
'x-automation-secret',
process.env.AUTOMATION_SCHEDULER_SECRET
)
.set('x-transaction-id', transaction.id);
const automatedTestResponse = 'AUTOMATED TEST RESPONSE';
const ats = await AtLoader().getAll({ transaction });
const browsers = await BrowserLoader().getAll({ transaction });
const at = ats.find(
at => at.id === collectionJob.testPlanRun.testPlanReport.at.id
);
const browser = browsers.find(
browser =>
browser.id ===
collectionJob.testPlanRun.testPlanReport.browser.id
);
const { tests } =
collectionJob.testPlanRun.testPlanReport.testPlanVersion;
const testResultsNumber =
collectionJob.testPlanRun.testResults.length;
const selectedTest = tests.find(
test => test.rowNumber === 14.1 && test.at.key === 'nvda'
);
expect(selectedTest).toBeDefined();

const numberOfScenarios = selectedTest.scenarios.filter(
scenario => scenario.atId === at.id
).length;

const response = await sessionAgent
.post(`/api/jobs/${job.id}/test/${selectedTest.rowNumber}`)
.send({
capabilities: {
atName: at.name,
atVersion: at.atVersions[0].name,
browserName: browser.name,
browserVersion: browser.browserVersions[0].name
},
responses: new Array(numberOfScenarios).fill(
automatedTestResponse
)
})
.set(
'x-automation-secret',
process.env.AUTOMATION_SCHEDULER_SECRET
)
.set('x-transaction-id', transaction.id);
expect(response.statusCode).toBe(200);
const storedTestPlanRun = await getTestPlanRun(
collectionJob.testPlanRun.id,
{ transaction }
);
const { testResults } = storedTestPlanRun.testPlanRun;
expect(testResults.length).toEqual(testResultsNumber + 1);
testResults.forEach(testResult => {
expect(testResult.test.id).toEqual(selectedTest.id);
expect(testResult.atVersion.name).toEqual(
at.atVersions[0].name
);
expect(testResult.browserVersion.name).toEqual(
browser.browserVersions[0].name
);
testResult.scenarioResults.forEach(scenarioResult => {
expect(scenarioResult.output).toEqual(
automatedTestResponse
);
scenarioResult.assertionResults.forEach(assertionResult => {
expect(assertionResult.passed).toEqual(false);
expect(assertionResult.failedReason).toEqual(
'AUTOMATED_OUTPUT'
);
});
scenarioResult.unexpectedBehaviors?.forEach(
unexpectedBehavior => {
expect(unexpectedBehavior.id).toEqual('OTHER');
expect(unexpectedBehavior.details).toEqual(null);
}
);
});
});
// also marks status for test as COMPLETED
const { collectionJob: storedCollectionJob } =
await getTestCollectionJob(job.id, { transaction });
expect(storedCollectionJob.id).toEqual(job.id);
expect(storedCollectionJob.status).toEqual('RUNNING');
const testStatus = storedCollectionJob.testStatus.find(
status => status.test.id === selectedTest.id
);
expect(testStatus.status).toEqual(COLLECTION_JOB_STATUS.COMPLETED);
});
});

it('should properly handle per-test status updates without capabilities present', async () => {
await apiServer.sessionAgentDbCleaner(async transaction => {
const { scheduleCollectionJob: job } =
Expand Down
Loading