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: Assertion with EXCLUDE priority causing test result submit errors #1229

Merged
merged 5 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
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
169 changes: 95 additions & 74 deletions client/tests/e2e/TestRun.e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,24 @@
});

describe('Test Run when signed in as tester', () => {
const assignSelfAndNavigateToRun = async page => {
const modalDialogSectionButtonSelector =
'button#disclosure-btn-modal-dialog-0';
const modalDialogTableSelector =
'table[aria-label="Reports for Modal Dialog Example V24.06.07 in draft phase"]';
const assignSelfAndNavigateToRun = async (
page,
{
testPlanSectionButtonSelector = 'button#disclosure-btn-modal-dialog-0',
testPlanTableSelector = 'table[aria-label="Reports for Modal Dialog Example V24.06.07 in draft phase"]'
} = {}
) => {
const startTestingButtonSelector =
'a[role="button"] ::-p-text(Start Testing)';

// Expand Modal Dialog's V24.06.07 section
await page.waitForSelector(modalDialogSectionButtonSelector);
await page.click(modalDialogSectionButtonSelector);
await page.waitForSelector(testPlanSectionButtonSelector);
await page.click(testPlanSectionButtonSelector);

// Wait for the table to render
await page.waitForSelector(modalDialogTableSelector);
await page.waitForSelector(testPlanTableSelector);

await page.$eval(modalDialogTableSelector, el => {
await page.$eval(testPlanTableSelector, el => {
// First button found on table would be 'Assign Yourself'
el.querySelector('button').click();
});
Expand Down Expand Up @@ -161,6 +163,72 @@
await page.waitForNetworkIdle();
};

const handlePageSubmit = async (page, { expectConflicts = true } = {}) => {
await page.waitForSelector('h1 ::-p-text(Test 1)');

// Confirm that submission cannot happen with empty form
// Specificity with selector because there's a 2nd 'hidden' button coming
// from the harness which is what is actually called for the submit event
const submitResultsButtonSelector =
'button[class="btn btn-primary"] ::-p-text(Submit Results)';
await page.waitForSelector(submitResultsButtonSelector);
await page.click(submitResultsButtonSelector);
await page.waitForNetworkIdle();
await page.waitForSelector('::-p-text((required))');

// Should refocus on topmost output textarea on page
const activeElementAfterEmptySubmit = await page.evaluate(() => {
return {
id: document.activeElement.id,
nodeName: document.activeElement.nodeName.toLowerCase()
};
});

// Input output for valid submission
await page.evaluate(() => {
const yesRadios = document.querySelectorAll(
'input[data-testid^="radio-yes-"]'
);
const noRadios = document.querySelectorAll(
'input[data-testid^="radio-no-"]'
);
const noUndesiredRadios = document.querySelectorAll(
'input[id^="problem-"][id$="-true"]'
);
const noOutputCheckboxes = document.querySelectorAll(
'input[id^="no-output-checkbox"]'
);

yesRadios.forEach((radio, index) => {
if (index % 2 === 0) {
radio.click();
} else {
noRadios[index].click();
}
});

noUndesiredRadios.forEach(radio => {
radio.click();
});

noOutputCheckboxes.forEach(checkbox => {
checkbox.click();
});
});
// Submit valid form
await page.click(submitResultsButtonSelector);
await page.waitForNetworkIdle();
if (expectConflicts)
await page.waitForSelector(
'::-p-text(This test has conflicting results)'
);
await page.waitForSelector('h2 ::-p-text(Test Results)');
await page.waitForSelector('button ::-p-text(Edit Results)');

expect(activeElementAfterEmptySubmit.id).toBe('speechoutput-0');
expect(activeElementAfterEmptySubmit.nodeName).toBe('textarea');
};

it('self assigns tester on Test Queue page and opens test run', async () => {
await getPage({ role: 'tester', url: '/test-queue' }, async page => {
await assignSelfAndNavigateToRun(page);
Expand Down Expand Up @@ -323,76 +391,29 @@
});
});

it('inputs results and successfully submits', async () => {

Check warning on line 394 in client/tests/e2e/TestRun.e2e.test.js

View workflow job for this annotation

GitHub Actions / Using NodeJS and Postgres 12

Test has no assertions

Check warning on line 394 in client/tests/e2e/TestRun.e2e.test.js

View workflow job for this annotation

GitHub Actions / Using NodeJS and Postgres 12

Test has no assertions
await getPage({ role: 'tester', url: '/test-queue' }, async page => {
await assignSelfAndNavigateToRun(page);

await page.waitForSelector('h1 ::-p-text(Test 1)');

// Confirm that submission cannot happen with empty form
// Specificity with selector because there's a 2nd 'hidden' button coming
// from the harness which is what is actually called for the submit event
const submitResultsButtonSelector =
'button[class="btn btn-primary"] ::-p-text(Submit Results)';
await page.waitForSelector(submitResultsButtonSelector);
await page.click(submitResultsButtonSelector);
await page.waitForNetworkIdle();
await page.waitForSelector('::-p-text((required))');

// Should refocus on topmost output textarea on page
const activeElementAfterEmptySubmit = await page.evaluate(() => {
return {
id: document.activeElement.id,
nodeName: document.activeElement.nodeName.toLowerCase()
};
});

// Input output for valid submission
await page.evaluate(() => {
const yesRadios = document.querySelectorAll(
'input[data-testid^="radio-yes-"]'
);
const noRadios = document.querySelectorAll(
'input[data-testid^="radio-no-"]'
);
const noUndesiredRadios = document.querySelectorAll(
'input[id^="problem-"][id$="-true"]'
);
const noOutputCheckboxes = document.querySelectorAll(
'input[id^="no-output-checkbox"]'
);

yesRadios.forEach((radio, index) => {
if (index % 2 === 0) {
radio.click();
} else {
noRadios[index].click();
}
});

noUndesiredRadios.forEach(radio => {
radio.click();
});

noOutputCheckboxes.forEach(checkbox => {
checkbox.click();
await getPage(
{ role: 'tester', url: '/test-queue' },
async (page, { baseUrl }) => {
await assignSelfAndNavigateToRun(page);
await handlePageSubmit(page);

// Do the same for Color Viewer Slider which has specially handled
// exclusions;
// Excluded in tests.csv and re-included in *-commands.csv
await page.goto(`${baseUrl}/test-queue`);
await assignSelfAndNavigateToRun(page, {
testPlanSectionButtonSelector:
'button#disclosure-btn-horizontal-slider-0',
testPlanTableSelector:
'table[aria-label="Reports for Color Viewer Slider V24.06.26 in draft phase"]'
});
});
// Submit valid form
await page.click(submitResultsButtonSelector);
await page.waitForNetworkIdle();
await page.waitForSelector(
'::-p-text(This test has conflicting results)'
);
await page.waitForSelector('h2 ::-p-text(Test Results)');
await page.waitForSelector('button ::-p-text(Edit Results)');

expect(activeElementAfterEmptySubmit.id).toBe('speechoutput-0');
expect(activeElementAfterEmptySubmit.nodeName).toBe('textarea');
});
await handlePageSubmit(page, { expectConflicts: false });
}
);
});

it('opens popup with content after clicking "Open Test Page" button', async () => {

Check warning on line 416 in client/tests/e2e/TestRun.e2e.test.js

View workflow job for this annotation

GitHub Actions / Using NodeJS and Postgres 12

Test has no assertions

Check warning on line 416 in client/tests/e2e/TestRun.e2e.test.js

View workflow job for this annotation

GitHub Actions / Using NodeJS and Postgres 12

Test has no assertions
await getPage({ role: 'tester', url: '/test-queue' }, async page => {
await assignSelfAndNavigateToRun(page);

Expand Down
Loading
Loading