Skip to content

Commit d7cc1fd

Browse files
authored
fix: Assertion with EXCLUDE priority causing test result submit errors (#1229)
* Add new test data sample using failing example with color viewer slider * Update snapshot * Push fix for build error * Update snapshots
1 parent 141c208 commit d7cc1fd

File tree

6 files changed

+410
-144
lines changed

6 files changed

+410
-144
lines changed

client/tests/e2e/TestRun.e2e.test.js

+95-74
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,24 @@ describe('Test Run when not signed in', () => {
108108
});
109109

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

119121
// Expand Modal Dialog's V24.06.07 section
120-
await page.waitForSelector(modalDialogSectionButtonSelector);
121-
await page.click(modalDialogSectionButtonSelector);
122+
await page.waitForSelector(testPlanSectionButtonSelector);
123+
await page.click(testPlanSectionButtonSelector);
122124

123125
// Wait for the table to render
124-
await page.waitForSelector(modalDialogTableSelector);
126+
await page.waitForSelector(testPlanTableSelector);
125127

126-
await page.$eval(modalDialogTableSelector, el => {
128+
await page.$eval(testPlanTableSelector, el => {
127129
// First button found on table would be 'Assign Yourself'
128130
el.querySelector('button').click();
129131
});
@@ -161,6 +163,72 @@ describe('Test Run when signed in as tester', () => {
161163
await page.waitForNetworkIdle();
162164
};
163165

166+
const handlePageSubmit = async (page, { expectConflicts = true } = {}) => {
167+
await page.waitForSelector('h1 ::-p-text(Test 1)');
168+
169+
// Confirm that submission cannot happen with empty form
170+
// Specificity with selector because there's a 2nd 'hidden' button coming
171+
// from the harness which is what is actually called for the submit event
172+
const submitResultsButtonSelector =
173+
'button[class="btn btn-primary"] ::-p-text(Submit Results)';
174+
await page.waitForSelector(submitResultsButtonSelector);
175+
await page.click(submitResultsButtonSelector);
176+
await page.waitForNetworkIdle();
177+
await page.waitForSelector('::-p-text((required))');
178+
179+
// Should refocus on topmost output textarea on page
180+
const activeElementAfterEmptySubmit = await page.evaluate(() => {
181+
return {
182+
id: document.activeElement.id,
183+
nodeName: document.activeElement.nodeName.toLowerCase()
184+
};
185+
});
186+
187+
// Input output for valid submission
188+
await page.evaluate(() => {
189+
const yesRadios = document.querySelectorAll(
190+
'input[data-testid^="radio-yes-"]'
191+
);
192+
const noRadios = document.querySelectorAll(
193+
'input[data-testid^="radio-no-"]'
194+
);
195+
const noUndesiredRadios = document.querySelectorAll(
196+
'input[id^="problem-"][id$="-true"]'
197+
);
198+
const noOutputCheckboxes = document.querySelectorAll(
199+
'input[id^="no-output-checkbox"]'
200+
);
201+
202+
yesRadios.forEach((radio, index) => {
203+
if (index % 2 === 0) {
204+
radio.click();
205+
} else {
206+
noRadios[index].click();
207+
}
208+
});
209+
210+
noUndesiredRadios.forEach(radio => {
211+
radio.click();
212+
});
213+
214+
noOutputCheckboxes.forEach(checkbox => {
215+
checkbox.click();
216+
});
217+
});
218+
// Submit valid form
219+
await page.click(submitResultsButtonSelector);
220+
await page.waitForNetworkIdle();
221+
if (expectConflicts)
222+
await page.waitForSelector(
223+
'::-p-text(This test has conflicting results)'
224+
);
225+
await page.waitForSelector('h2 ::-p-text(Test Results)');
226+
await page.waitForSelector('button ::-p-text(Edit Results)');
227+
228+
expect(activeElementAfterEmptySubmit.id).toBe('speechoutput-0');
229+
expect(activeElementAfterEmptySubmit.nodeName).toBe('textarea');
230+
};
231+
164232
it('self assigns tester on Test Queue page and opens test run', async () => {
165233
await getPage({ role: 'tester', url: '/test-queue' }, async page => {
166234
await assignSelfAndNavigateToRun(page);
@@ -324,72 +392,25 @@ describe('Test Run when signed in as tester', () => {
324392
});
325393

326394
it('inputs results and successfully submits', async () => {
327-
await getPage({ role: 'tester', url: '/test-queue' }, async page => {
328-
await assignSelfAndNavigateToRun(page);
329-
330-
await page.waitForSelector('h1 ::-p-text(Test 1)');
331-
332-
// Confirm that submission cannot happen with empty form
333-
// Specificity with selector because there's a 2nd 'hidden' button coming
334-
// from the harness which is what is actually called for the submit event
335-
const submitResultsButtonSelector =
336-
'button[class="btn btn-primary"] ::-p-text(Submit Results)';
337-
await page.waitForSelector(submitResultsButtonSelector);
338-
await page.click(submitResultsButtonSelector);
339-
await page.waitForNetworkIdle();
340-
await page.waitForSelector('::-p-text((required))');
341-
342-
// Should refocus on topmost output textarea on page
343-
const activeElementAfterEmptySubmit = await page.evaluate(() => {
344-
return {
345-
id: document.activeElement.id,
346-
nodeName: document.activeElement.nodeName.toLowerCase()
347-
};
348-
});
349-
350-
// Input output for valid submission
351-
await page.evaluate(() => {
352-
const yesRadios = document.querySelectorAll(
353-
'input[data-testid^="radio-yes-"]'
354-
);
355-
const noRadios = document.querySelectorAll(
356-
'input[data-testid^="radio-no-"]'
357-
);
358-
const noUndesiredRadios = document.querySelectorAll(
359-
'input[id^="problem-"][id$="-true"]'
360-
);
361-
const noOutputCheckboxes = document.querySelectorAll(
362-
'input[id^="no-output-checkbox"]'
363-
);
364-
365-
yesRadios.forEach((radio, index) => {
366-
if (index % 2 === 0) {
367-
radio.click();
368-
} else {
369-
noRadios[index].click();
370-
}
371-
});
372-
373-
noUndesiredRadios.forEach(radio => {
374-
radio.click();
375-
});
376-
377-
noOutputCheckboxes.forEach(checkbox => {
378-
checkbox.click();
395+
await getPage(
396+
{ role: 'tester', url: '/test-queue' },
397+
async (page, { baseUrl }) => {
398+
await assignSelfAndNavigateToRun(page);
399+
await handlePageSubmit(page);
400+
401+
// Do the same for Color Viewer Slider which has specially handled
402+
// exclusions;
403+
// Excluded in tests.csv and re-included in *-commands.csv
404+
await page.goto(`${baseUrl}/test-queue`);
405+
await assignSelfAndNavigateToRun(page, {
406+
testPlanSectionButtonSelector:
407+
'button#disclosure-btn-horizontal-slider-0',
408+
testPlanTableSelector:
409+
'table[aria-label="Reports for Color Viewer Slider V24.06.26 in draft phase"]'
379410
});
380-
});
381-
// Submit valid form
382-
await page.click(submitResultsButtonSelector);
383-
await page.waitForNetworkIdle();
384-
await page.waitForSelector(
385-
'::-p-text(This test has conflicting results)'
386-
);
387-
await page.waitForSelector('h2 ::-p-text(Test Results)');
388-
await page.waitForSelector('button ::-p-text(Edit Results)');
389-
390-
expect(activeElementAfterEmptySubmit.id).toBe('speechoutput-0');
391-
expect(activeElementAfterEmptySubmit.nodeName).toBe('textarea');
392-
});
411+
await handlePageSubmit(page, { expectConflicts: false });
412+
}
413+
);
393414
});
394415

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

0 commit comments

Comments
 (0)