refactor(e2e): consolidate tests in preview.spec.ts (#63652)

This commit is contained in:
Huyen Nguyen
2025-11-10 05:29:42 -08:00
committed by GitHub
parent dff61e6af7
commit 7616926f3f

View File

@@ -9,7 +9,7 @@ test.beforeEach(async ({ page }) => {
});
test.describe('Challenge Preview Component', () => {
test('should render correct output of default code', async ({
test('should render correct output for default and changed code', async ({
page,
isMobile
}) => {
@@ -18,30 +18,27 @@ test.describe('Challenge Preview Component', () => {
.getByRole('tab', { name: translations.learn['editor-tabs'].preview })
.click();
}
// Check default code output
await expect(
page
.frameLocator('.challenge-preview-frame')
.first()
.getByRole('heading', { name: 'CatPhotoApp' })
).toBeVisible();
});
test('should render correct output of changed code', async ({
page,
isMobile
}) => {
// Change code
await focusEditor({ page, isMobile });
await page.keyboard.insertText('<h1>FreeCodeCamp</h1>');
if (isMobile) {
await page
.getByRole('tab', { name: translations.learn['editor-tabs'].preview })
.click();
}
// Check changed code output
await expect(
page
.frameLocator('.challenge-preview-frame')
.first()
.getByRole('heading', { name: 'FreeCodeCamp' })
).toBeVisible();
});