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..27a0a06 --- /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', '85px') + await expect(cursor).toHaveCSS('top', '0px') + + await Command.execute('DiffView.moveCursorRight') + await expect(cursor).toHaveCSS('left', '94px') + + await Command.execute('DiffView.moveCursorRight') + await expect(cursor).toHaveCSS('left', '49px') + await expect(cursor).toHaveCSS('top', '20px') + + await Command.execute('DiffView.moveCursorLeft') + 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 new file mode 100644 index 0000000..8cd34eb --- /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', '67px') + await expect(cursor).toHaveCSS('top', '20px') + + await Command.execute('DiffView.moveCursorToStartOfLine') + await expect(cursor).toHaveCSS('left', '49px') + + await Command.execute('DiffView.moveCursorToEndOfLine') + 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 new file mode 100644 index 0000000..2a0088c --- /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', '94px') + await expect(cursor).toHaveCSS('top', '0px') + + await Command.execute('DiffView.moveCursorDown') + await expect(cursor).toHaveCSS('left', '58px') + await expect(cursor).toHaveCSS('top', '20px') + + await Command.execute('DiffView.moveCursorDown') + await expect(cursor).toHaveCSS('left', '58px') + await expect(cursor).toHaveCSS('top', '40px') + + await Command.execute('DiffView.moveCursorUp') + await expect(cursor).toHaveCSS('left', '58px') + 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') +}