Skip to content

Commit

Permalink
test: use challenge with visible buttons for spec (freeCodeCamp#54566)
Browse files Browse the repository at this point in the history
  • Loading branch information
ojeytonwilliams authored and pull[bot] committed Nov 6, 2024
1 parent 0ee6ba5 commit 04fba1e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 28 deletions.
2 changes: 1 addition & 1 deletion e2e/editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect, test } from '@playwright/test';

test.beforeEach(async ({ page }) => {
await page.goto(
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-2'
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-3'
);
});

Expand Down
2 changes: 1 addition & 1 deletion e2e/lower-jaw.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { test, expect } from '@playwright/test';

test.beforeEach(async ({ page }) => {
await page.goto(
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-2'
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-3'
);
});

Expand Down
2 changes: 1 addition & 1 deletion e2e/preview.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import translations from '../client/i18n/locales/english/translations.json';

test.beforeEach(async ({ page }) => {
await page.goto(
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-2'
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-3'
);
});

Expand Down
31 changes: 9 additions & 22 deletions e2e/progress-bar.spec.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
import { expect, test, type Page } from '@playwright/test';

let page: Page;

test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
await page.goto(
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-2'
);
});
import { expect, test } from '@playwright/test';

test.describe('Progress bar component', () => {
test('Should appear with the correct content after the user has submitted their code', async ({
isMobile,
browserName
page
}) => {
const monacoEditor = page.getByLabel('Editor content');
await page.goto(
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-2'
);

// The editor has an overlay div, which prevents the click event from bubbling up in iOS Safari.
// This is a quirk in this browser-OS combination, and the workaround here is to use `.focus()`
// in place of `.click()` to focus on the editor.
// Ref: https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
if (isMobile && browserName === 'webkit') {
await monacoEditor.focus();
} else {
await monacoEditor.click();
}
const monacoEditor = page.getByLabel('Editor content');

// Using focus instead of click since we're not testing if the editor
// behaves correctly, we're using it to complete the challenge.
await monacoEditor.focus();
await page.keyboard.press('Control+A');
//Meta + A works in webkit
await page.keyboard.press('Meta+A');
Expand Down
6 changes: 3 additions & 3 deletions e2e/reset-modal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import translations from '../client/i18n/locales/english/translations.json';

test('should render the modal content correctly', async ({ page }) => {
await page.goto(
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-2'
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-3'
);

await page.getByRole('button', { name: translations.buttons.reset }).click();
Expand Down Expand Up @@ -48,7 +48,7 @@ test('User can reset challenge', async ({ page }) => {
.getByText(updatedText);

await page.goto(
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-2'
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-3'
);

// Building the preview can take a while
Expand Down Expand Up @@ -137,7 +137,7 @@ test('User can reset classic challenge', async ({ page, isMobile }) => {

test('should close when the user clicks the close button', async ({ page }) => {
await page.goto(
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-2'
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-3'
);

await page.getByRole('button', { name: translations.buttons.reset }).click();
Expand Down

0 comments on commit 04fba1e

Please sign in to comment.