Skip to content

Commit

Permalink
Add tests for navigating with arrow keys
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Sep 30, 2023
1 parent 2b775df commit 8f5e971
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 55 deletions.
23 changes: 23 additions & 0 deletions e2e/list.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { expect } from '@playwright/test';
import { test } from './fixtures';
import { isMac } from './utils';

test.describe('list', () => {
test.beforeEach(async ({ editorPage }) => {
await editorPage.open();
});

test('navigating with shortcuts', async ({ page, editorPage }) => {
await editorPage.setContents([
{ insert: 'item 1' },
{ insert: '\n', attributes: { list: 'bullet' } },
]);

await editorPage.moveCursorAfterText('item 1');
await page.keyboard.press(isMac ? `Meta+ArrowLeft` : 'Home');
expect(await editorPage.getSelection()).toEqual({ index: 0, length: 0 });

await page.keyboard.press(isMac ? `Meta+ArrowRight` : 'End');
expect(await editorPage.getSelection()).toEqual({ index: 6, length: 0 });
});
});
3 changes: 2 additions & 1 deletion e2e/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const SHORTKEY = process.platform === 'darwin' ? 'Meta' : 'Control';
export const isMac = process.platform === 'darwin';
export const SHORTKEY = isMac ? 'Meta' : 'Control';

export function getSelectionInTextNode() {
const selection = document.getSelection();
Expand Down
80 changes: 28 additions & 52 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@babel/core": "^7.22.5",
"@babel/preset-env": "^7.22.5",
"@babel/preset-typescript": "^7.22.5",
"@playwright/test": "^1.34.3",
"@playwright/test": "^1.38.1",
"@types/lodash.clonedeep": "^4.5.7",
"@types/lodash.isequal": "^4.5.6",
"@types/lodash.merge": "^4.6.7",
Expand All @@ -51,7 +51,6 @@
"lodash": "^4.17.15",
"mini-css-extract-plugin": "^2.7.6",
"npm-run-all": "^4.1.5",
"playwright": "^1.36.0",
"prettier": "^3.0.1",
"style-loader": "^3.3.3",
"stylus": "^0.59.0",
Expand Down

0 comments on commit 8f5e971

Please sign in to comment.