feat(curriculum): add test number enumeration (#55874)

This commit is contained in:
Kevin
2024-08-29 14:56:03 -07:00
committed by GitHub
parent 786a49d55a
commit 4a29f23895
4 changed files with 10 additions and 5 deletions

View File

@@ -43,7 +43,7 @@ function TestSuite({ tests }: TestSuiteProps): JSX.Element {
pass && !err ? t('icons.passed') : t('icons.failed'); pass && !err ? t('icons.passed') : t('icons.failed');
// Remove opening/closing <p> so screen reader will read both // Remove opening/closing <p> so screen reader will read both
// status message and test text as one block. // status message and test text as one block.
text = text.replace(/^<p>|<\/p>$/g, ''); text = `${index + 1}. ${text.replace(/^<p>|<\/p>$/g, '')}`;
return ( return (
<li <li
className='test-result' className='test-result'

View File

@@ -232,6 +232,7 @@ function* executeTests(testRunner, tests, testTimeout = 5000) {
newTest.stack = stack; newTest.stack = stack;
} }
newTest.message = newTest.message.replace(/<p>/, `<p>${i + 1}. `);
yield put(updateConsole(newTest.message)); yield put(updateConsole(newTest.message));
} finally { } finally {
testResults.push(newTest); testResults.push(newTest);

View File

@@ -13,7 +13,7 @@ const outputTexts = {
> 1 | var > 1 | var
| ^`, | ^`,
empty: `// running tests empty: `// running tests
You should declare myName with the var keyword, ending with a semicolon 1. You should declare myName with the var keyword, ending with a semicolon
// tests completed`, // tests completed`,
passed: `// running tests passed: `// running tests
// tests completed` // tests completed`

View File

@@ -25,11 +25,15 @@ test.describe('Challenge Test Suite Component Tests', () => {
await expect(page.getByTestId('test-result')).toHaveCount(3); await expect(page.getByTestId('test-result')).toHaveCount(3);
await expect(page.getByText(translations.icons.initial)).toHaveCount(3); await expect(page.getByText(translations.icons.initial)).toHaveCount(3);
await expect( await expect(
page.getByText('You should not change code above the specified comment.') page.getByText(
'1. You should not change code above the specified comment.'
)
).toBeVisible(); ).toBeVisible();
await expect(page.getByText('b should have a value of 7.')).toBeVisible();
await expect( await expect(
page.getByText('a should be assigned to b with =.') page.getByText('2. b should have a value of 7.')
).toBeVisible();
await expect(
page.getByText('3. a should be assigned to b with =.')
).toBeVisible(); ).toBeVisible();
}); });