mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-18 07:03:01 -04:00
test(e2e,playwright): hotkeys (#52158)
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
51
e2e/hotkeys.spec.ts
Normal file
51
e2e/hotkeys.spec.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
import translations from '../client/i18n/locales/english/translations.json';
|
||||
|
||||
const course =
|
||||
'/learn/javascript-algorithms-and-data-structures/basic-javascript/comment-your-javascript-code';
|
||||
const editorPaneLabel =
|
||||
'Editor content;Press Alt+F1 for Accessibility Options.';
|
||||
|
||||
test.use({ storageState: 'playwright/.auth/certified-user.json' });
|
||||
|
||||
test('User can interact with the app using the keyboard', async ({
|
||||
page,
|
||||
browserName
|
||||
}) => {
|
||||
test.skip(
|
||||
browserName === 'webkit',
|
||||
'Failing on webkit for no apparent reason. Can not reproduce locally.'
|
||||
);
|
||||
|
||||
// Enable keyboard shortcuts
|
||||
await page.goto('/settings');
|
||||
const keyboardShortcutGroup = page.getByRole('group', {
|
||||
name: translations.settings.labels['keyboard-shortcuts']
|
||||
});
|
||||
await keyboardShortcutGroup
|
||||
.getByRole('button', { name: translations.buttons.on, exact: true })
|
||||
.click();
|
||||
|
||||
await page.goto(course);
|
||||
|
||||
await expect(page.getByLabel(editorPaneLabel)).toBeFocused();
|
||||
await page.getByLabel(editorPaneLabel).press('Escape');
|
||||
await expect(page.getByLabel(editorPaneLabel)).not.toBeFocused();
|
||||
|
||||
await page.keyboard.press('n');
|
||||
const nextCourse = '**/declare-javascript-variables';
|
||||
await page.waitForURL(nextCourse);
|
||||
|
||||
await page.keyboard.press('p');
|
||||
const previousCourse = '**/comment-your-javascript-code';
|
||||
await page.waitForURL(previousCourse);
|
||||
|
||||
await page.keyboard.press('e');
|
||||
await expect(page.getByLabel(editorPaneLabel)).toBeFocused();
|
||||
|
||||
await page.keyboard.press('Control+Enter');
|
||||
await expect(page.getByText('running test')).toBeVisible();
|
||||
|
||||
// Show shortcuts (shift+/) is covered by the shortcuts-modal tests
|
||||
});
|
||||
Reference in New Issue
Block a user