From 3ded3a090412445e94d3c095df3a2d03191b3634 Mon Sep 17 00:00:00 2001 From: Le Vivilet Date: Thu, 16 Jul 2026 06:25:35 +0000 Subject: [PATCH 1/2] feature: add diff view e2e coverage --- .../src/diff.cursor-navigation-horizontal.ts | 28 ++++++++++++++++++ .../diff.cursor-navigation-line-boundaries.ts | 23 +++++++++++++++ .../src/diff.cursor-navigation-vertical.ts | 29 +++++++++++++++++++ .../e2e/src/diff.delete-right-character.ts | 18 ++++++++++++ .../e2e/src/diff.delete-right-line-break.ts | 18 ++++++++++++ 5 files changed, 116 insertions(+) create mode 100644 packages/e2e/src/diff.cursor-navigation-horizontal.ts create mode 100644 packages/e2e/src/diff.cursor-navigation-line-boundaries.ts create mode 100644 packages/e2e/src/diff.cursor-navigation-vertical.ts create mode 100644 packages/e2e/src/diff.delete-right-character.ts create mode 100644 packages/e2e/src/diff.delete-right-line-break.ts diff --git a/packages/e2e/src/diff.cursor-navigation-horizontal.ts b/packages/e2e/src/diff.cursor-navigation-horizontal.ts new file mode 100644 index 0000000..e3803a8 --- /dev/null +++ b/packages/e2e/src/diff.cursor-navigation-horizontal.ts @@ -0,0 +1,28 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.cursor-navigation-horizontal' + +export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'alpha\nbeta') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'alpha\nbeta') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const cursor = Locator('.EditorCursorRight') + await Command.execute('DiffView.setCursorPosition', 4, 0) + await expect(cursor).toHaveCSS('left', '84px') + await expect(cursor).toHaveCSS('top', '0px') + + await Command.execute('DiffView.moveCursorRight') + await expect(cursor).toHaveCSS('left', '92px') + + await Command.execute('DiffView.moveCursorRight') + await expect(cursor).toHaveCSS('left', '52px') + await expect(cursor).toHaveCSS('top', '20px') + + await Command.execute('DiffView.moveCursorLeft') + await expect(cursor).toHaveCSS('left', '92px') + await expect(cursor).toHaveCSS('top', '0px') +} diff --git a/packages/e2e/src/diff.cursor-navigation-line-boundaries.ts b/packages/e2e/src/diff.cursor-navigation-line-boundaries.ts new file mode 100644 index 0000000..bce9a16 --- /dev/null +++ b/packages/e2e/src/diff.cursor-navigation-line-boundaries.ts @@ -0,0 +1,23 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.cursor-navigation-line-boundaries' + +export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'alpha\nbeta') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'alpha\nbeta') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const cursor = Locator('.EditorCursorRight') + await Command.execute('DiffView.setCursorPosition', 2, 1) + await expect(cursor).toHaveCSS('left', '68px') + await expect(cursor).toHaveCSS('top', '20px') + + await Command.execute('DiffView.moveCursorToStartOfLine') + await expect(cursor).toHaveCSS('left', '52px') + + await Command.execute('DiffView.moveCursorToEndOfLine') + await expect(cursor).toHaveCSS('left', '84px') +} diff --git a/packages/e2e/src/diff.cursor-navigation-vertical.ts b/packages/e2e/src/diff.cursor-navigation-vertical.ts new file mode 100644 index 0000000..2caad45 --- /dev/null +++ b/packages/e2e/src/diff.cursor-navigation-vertical.ts @@ -0,0 +1,29 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.cursor-navigation-vertical' + +export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'alpha\nb\ngamma') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'alpha\nb\ngamma') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const cursor = Locator('.EditorCursorRight') + await Command.execute('DiffView.setCursorPosition', 5, 0) + await expect(cursor).toHaveCSS('left', '92px') + await expect(cursor).toHaveCSS('top', '0px') + + await Command.execute('DiffView.moveCursorDown') + await expect(cursor).toHaveCSS('left', '60px') + await expect(cursor).toHaveCSS('top', '20px') + + await Command.execute('DiffView.moveCursorDown') + await expect(cursor).toHaveCSS('left', '60px') + await expect(cursor).toHaveCSS('top', '40px') + + await Command.execute('DiffView.moveCursorUp') + await expect(cursor).toHaveCSS('left', '60px') + await expect(cursor).toHaveCSS('top', '20px') +} diff --git a/packages/e2e/src/diff.delete-right-character.ts b/packages/e2e/src/diff.delete-right-character.ts new file mode 100644 index 0000000..b7c024b --- /dev/null +++ b/packages/e2e/src/diff.delete-right-character.ts @@ -0,0 +1,18 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.delete-right-character' + +export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'pear world') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'pear world') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const afterRows = Locator('.DiffEditorContentRight .DiffEditorRows') + await Command.execute('DiffView.setCursorPosition', 1, 0) + await Command.execute('DiffView.deleteRight') + + await expect(afterRows).toHaveText('par world') +} diff --git a/packages/e2e/src/diff.delete-right-line-break.ts b/packages/e2e/src/diff.delete-right-line-break.ts new file mode 100644 index 0000000..414fac6 --- /dev/null +++ b/packages/e2e/src/diff.delete-right-line-break.ts @@ -0,0 +1,18 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.delete-right-line-break' + +export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'alpha\nbeta') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'alpha\nbeta') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const afterRows = Locator('.DiffEditorContentRight .DiffEditorRows') + await Command.execute('DiffView.setCursorPosition', 5, 0) + await Command.execute('DiffView.deleteRight') + + await expect(afterRows).toHaveText('alphabeta') +} From 5fed422ee6417e0a881666382bdeb98448f5dc91 Mon Sep 17 00:00:00 2001 From: Le Vivilet Date: Thu, 16 Jul 2026 06:32:55 +0000 Subject: [PATCH 2/2] fix: correct cursor e2e expectations --- packages/e2e/src/diff.cursor-navigation-horizontal.ts | 8 ++++---- .../e2e/src/diff.cursor-navigation-line-boundaries.ts | 6 +++--- packages/e2e/src/diff.cursor-navigation-vertical.ts | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/e2e/src/diff.cursor-navigation-horizontal.ts b/packages/e2e/src/diff.cursor-navigation-horizontal.ts index e3803a8..27a0a06 100644 --- a/packages/e2e/src/diff.cursor-navigation-horizontal.ts +++ b/packages/e2e/src/diff.cursor-navigation-horizontal.ts @@ -12,17 +12,17 @@ export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locato const cursor = Locator('.EditorCursorRight') await Command.execute('DiffView.setCursorPosition', 4, 0) - await expect(cursor).toHaveCSS('left', '84px') + await expect(cursor).toHaveCSS('left', '85px') await expect(cursor).toHaveCSS('top', '0px') await Command.execute('DiffView.moveCursorRight') - await expect(cursor).toHaveCSS('left', '92px') + await expect(cursor).toHaveCSS('left', '94px') await Command.execute('DiffView.moveCursorRight') - await expect(cursor).toHaveCSS('left', '52px') + await expect(cursor).toHaveCSS('left', '49px') await expect(cursor).toHaveCSS('top', '20px') await Command.execute('DiffView.moveCursorLeft') - await expect(cursor).toHaveCSS('left', '92px') + await expect(cursor).toHaveCSS('left', '94px') await expect(cursor).toHaveCSS('top', '0px') } diff --git a/packages/e2e/src/diff.cursor-navigation-line-boundaries.ts b/packages/e2e/src/diff.cursor-navigation-line-boundaries.ts index bce9a16..8cd34eb 100644 --- a/packages/e2e/src/diff.cursor-navigation-line-boundaries.ts +++ b/packages/e2e/src/diff.cursor-navigation-line-boundaries.ts @@ -12,12 +12,12 @@ export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locato const cursor = Locator('.EditorCursorRight') await Command.execute('DiffView.setCursorPosition', 2, 1) - await expect(cursor).toHaveCSS('left', '68px') + await expect(cursor).toHaveCSS('left', '67px') await expect(cursor).toHaveCSS('top', '20px') await Command.execute('DiffView.moveCursorToStartOfLine') - await expect(cursor).toHaveCSS('left', '52px') + await expect(cursor).toHaveCSS('left', '49px') await Command.execute('DiffView.moveCursorToEndOfLine') - await expect(cursor).toHaveCSS('left', '84px') + await expect(cursor).toHaveCSS('left', '85px') } diff --git a/packages/e2e/src/diff.cursor-navigation-vertical.ts b/packages/e2e/src/diff.cursor-navigation-vertical.ts index 2caad45..2a0088c 100644 --- a/packages/e2e/src/diff.cursor-navigation-vertical.ts +++ b/packages/e2e/src/diff.cursor-navigation-vertical.ts @@ -12,18 +12,18 @@ export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locato const cursor = Locator('.EditorCursorRight') await Command.execute('DiffView.setCursorPosition', 5, 0) - await expect(cursor).toHaveCSS('left', '92px') + await expect(cursor).toHaveCSS('left', '94px') await expect(cursor).toHaveCSS('top', '0px') await Command.execute('DiffView.moveCursorDown') - await expect(cursor).toHaveCSS('left', '60px') + await expect(cursor).toHaveCSS('left', '58px') await expect(cursor).toHaveCSS('top', '20px') await Command.execute('DiffView.moveCursorDown') - await expect(cursor).toHaveCSS('left', '60px') + await expect(cursor).toHaveCSS('left', '58px') await expect(cursor).toHaveCSS('top', '40px') await Command.execute('DiffView.moveCursorUp') - await expect(cursor).toHaveCSS('left', '60px') + await expect(cursor).toHaveCSS('left', '58px') await expect(cursor).toHaveCSS('top', '20px') }