Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
BrtqKr committed Apr 28, 2024
1 parent ac548f7 commit 1dd1977
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions WebExample/tests/input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ test.describe('standard input behaviour', () => {

expect(await inputLocator.innerText()).toBe(EXAMPLE_LONG_CONTENT);

const cursorPosition = await page.evaluate((selector) => {
const editableDiv = document.querySelector(selector) as HTMLElement;
const cursorPosition = await page.evaluate(() => {
const editableDiv = document.querySelector('div[contenteditable="true"]') as HTMLElement;
const range = window.getSelection()?.getRangeAt(0);
if (!range || !editableDiv) return null;
const preCaretRange = range.cloneRange();
preCaretRange.selectNodeContents(editableDiv);
preCaretRange.setEnd(range.endContainer, range.endOffset);
return preCaretRange.toString().length;
}, 'div[contenteditable="true"]');
});

expect(cursorPosition).toBe(EXAMPLE_LONG_CONTENT.length);
});
Expand Down
2 changes: 2 additions & 0 deletions WebExample/tests/textManipulation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ test.describe('paste content', () => {
test('select', async ({page}) => {
const inputLocator = await setupInput(page, 'reset');
await inputLocator.focus();
await inputLocator.press(`${OPERATION_MODIFIER}+a`);

const cursorPosition = await page.evaluate(() => {
const editableDiv = document.querySelector('div[contenteditable="true"]');
Expand All @@ -105,6 +106,7 @@ test('select', async ({page}) => {
const preCaretRange = range.cloneRange();
preCaretRange.selectNodeContents(editableDiv);
preCaretRange.setEnd(range.endContainer, range.endOffset);

return preCaretRange.toString().length;
});

Expand Down

0 comments on commit 1dd1977

Please sign in to comment.