Skip to content

Commit 79d9798

Browse files
test: confirm that lab project previews can be viewed (freeCodeCamp#59570)
1 parent 3f3b1b4 commit 79d9798

1 file changed

Lines changed: 29 additions & 2 deletions

File tree

e2e/project-preview-modal.spec.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { test, expect } from '@playwright/test';
22

33
import translations from '../client/i18n/locales/english/translations.json';
44

5-
test.describe('When it renders', () => {
5+
test.describe('Should be shown automatically', () => {
66
test.beforeEach(async ({ page }) => {
77
const urlWithProjectPreview =
88
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-1';
@@ -49,7 +49,34 @@ test.describe('When it renders', () => {
4949
});
5050
});
5151

52-
test.describe('It should NOT appear', () => {
52+
test.describe('Should be shown manually', () => {
53+
test.beforeEach(async ({ page }) => {
54+
const urlWithProjectPreview =
55+
'/learn/full-stack-developer/lab-drum-machine/build-drum-machine';
56+
await page.goto(urlWithProjectPreview);
57+
});
58+
59+
test("when the user clicks on 'this example project'", async ({ page }) => {
60+
const dialog = page.getByRole('dialog', {
61+
name: translations.learn['demo-project-title']
62+
});
63+
await expect(dialog).not.toBeVisible();
64+
await page
65+
.getByRole('button', {
66+
name: 'this example project'
67+
})
68+
.click();
69+
await expect(dialog).toBeVisible();
70+
const previewFrame = dialog.frameLocator('#fcc-project-preview-frame');
71+
await expect(
72+
// This is a part of the Drum Machine that we expect to see. Essentially,
73+
// it's a proxy for "not empty"
74+
previewFrame.getByText('Power: On')
75+
).toBeVisible();
76+
});
77+
});
78+
79+
test.describe('Should not render', () => {
5380
test('on the second step of a project', async ({ page }) => {
5481
await page.goto(
5582
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-2'

0 commit comments

Comments
 (0)