Skip to content

Commit

Permalink
feat: convert "editor spec" to Playwright (freeCodeCamp#54970)
Browse files Browse the repository at this point in the history
Co-authored-by: Huyen Nguyen <[email protected]>
  • Loading branch information
Sembauke and huyenltnguyen authored May 29, 2024
1 parent 07bef7a commit 98d85ed
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 29 deletions.
29 changes: 0 additions & 29 deletions cypress/e2e/default/learn/common-components/editor.ts

This file was deleted.

36 changes: 36 additions & 0 deletions e2e/legacy-editor.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { test, expect } from '@playwright/test';
import { focusEditor } from './utils/editor';

test.describe('Editor Shortcuts', () => {
test('Should add a new line if the user presses Alt+Enter', async ({
page,
isMobile
}) => {
await page.goto(
'learn/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements'
);
await focusEditor({ page, isMobile });

await page.keyboard.press('Alt+Enter');
await expect(
page
.getByTestId('editor-container-indexhtml')
.getByText('<h1>Hello</h1>\n')
).toBeVisible();
});

test('Should not add a new line if the user presses Ctrl+Enter', async ({
page,
isMobile
}) => {
await page.goto(
'learn/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements'
);
await focusEditor({ page, isMobile });

await page.keyboard.press('Control+Enter');
await expect(
page.getByTestId('editor-container-indexhtml').getByText('<h1>Hello</h1>')
).toBeVisible();
});
});

0 comments on commit 98d85ed

Please sign in to comment.