diff --git a/packages/e2e/src/diff.coverage-blank-line-deletion.ts b/packages/e2e/src/diff.coverage-blank-line-deletion.ts new file mode 100644 index 0000000..819cd6f --- /dev/null +++ b/packages/e2e/src/diff.coverage-blank-line-deletion.ts @@ -0,0 +1,16 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-blank-line-deletion' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'one\n\ntwo') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'one\ntwo') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const deletedRows = Locator('.DiffEditorContentLeft .EditorRow.Deletion') + await expect(deletedRows).toHaveCount(1) + await expect(deletedRows).toHaveText('') +} diff --git a/packages/e2e/src/diff.coverage-blank-line-insertion.ts b/packages/e2e/src/diff.coverage-blank-line-insertion.ts new file mode 100644 index 0000000..da27878 --- /dev/null +++ b/packages/e2e/src/diff.coverage-blank-line-insertion.ts @@ -0,0 +1,16 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-blank-line-insertion' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'one\ntwo') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'one\n\ntwo') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const insertedRows = Locator('.DiffEditorContentRight .EditorRow.Insertion') + await expect(insertedRows).toHaveCount(1) + await expect(insertedRows).toHaveText('') +} diff --git a/packages/e2e/src/diff.coverage-cjk-line-replacement.ts b/packages/e2e/src/diff.coverage-cjk-line-replacement.ts new file mode 100644 index 0000000..c2abcce --- /dev/null +++ b/packages/e2e/src/diff.coverage-cjk-line-replacement.ts @@ -0,0 +1,17 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-cjk-line-replacement' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, '状態: 保留') + await FileSystem.writeFile(`${tmpDir}/after.txt`, '状態: 完了') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const leftRows = Locator('.DiffEditorContentLeft .DiffEditorRows') + const rightRows = Locator('.DiffEditorContentRight .DiffEditorRows') + await expect(leftRows).toHaveText('状態: 保留') + await expect(rightRows).toHaveText('状態: 完了') +} diff --git a/packages/e2e/src/diff.coverage-combining-mark-replacement.ts b/packages/e2e/src/diff.coverage-combining-mark-replacement.ts new file mode 100644 index 0000000..0ca0c34 --- /dev/null +++ b/packages/e2e/src/diff.coverage-combining-mark-replacement.ts @@ -0,0 +1,16 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-combining-mark-replacement' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'Cafe\u{301}') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'Cafe') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const changedTokens = Locator('.DiffToken--changed') + await expect(changedTokens).toHaveCount(1) + await expect(changedTokens).toHaveText('\u{301}') +} diff --git a/packages/e2e/src/diff.coverage-consecutive-lines-deletion.ts b/packages/e2e/src/diff.coverage-consecutive-lines-deletion.ts new file mode 100644 index 0000000..cee559c --- /dev/null +++ b/packages/e2e/src/diff.coverage-consecutive-lines-deletion.ts @@ -0,0 +1,18 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-consecutive-lines-deletion' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'start\nremoved one\nremoved two\nend') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'start\nend') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const deletedRows = Locator('.DiffEditorContentLeft .EditorRow.Deletion') + const secondDeletedRow = deletedRows.nth(1) + await expect(deletedRows).toHaveCount(2) + await expect(deletedRows.first()).toHaveText('removed one') + await expect(secondDeletedRow).toHaveText('removed two') +} diff --git a/packages/e2e/src/diff.coverage-consecutive-lines-insertion.ts b/packages/e2e/src/diff.coverage-consecutive-lines-insertion.ts new file mode 100644 index 0000000..ef68fda --- /dev/null +++ b/packages/e2e/src/diff.coverage-consecutive-lines-insertion.ts @@ -0,0 +1,18 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-consecutive-lines-insertion' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'start\nend') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'start\nadded one\nadded two\nend') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const insertedRows = Locator('.DiffEditorContentRight .EditorRow.Insertion') + const secondInsertedRow = insertedRows.nth(1) + await expect(insertedRows).toHaveCount(2) + await expect(insertedRows.first()).toHaveText('added one') + await expect(secondInsertedRow).toHaveText('added two') +} diff --git a/packages/e2e/src/diff.coverage-cursor-at-document-end.ts b/packages/e2e/src/diff.coverage-cursor-at-document-end.ts new file mode 100644 index 0000000..e57ef0b --- /dev/null +++ b/packages/e2e/src/diff.coverage-cursor-at-document-end.ts @@ -0,0 +1,17 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-cursor-at-document-end' + +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`) + await Command.execute('DiffView.setCursorPosition', 4, 1) + + const cursor = Locator('.EditorCursorRight') + await expect(cursor).toHaveCSS('left', '85px') + await expect(cursor).toHaveCSS('top', '20px') +} diff --git a/packages/e2e/src/diff.coverage-cursor-at-document-start.ts b/packages/e2e/src/diff.coverage-cursor-at-document-start.ts new file mode 100644 index 0000000..d8a45e4 --- /dev/null +++ b/packages/e2e/src/diff.coverage-cursor-at-document-start.ts @@ -0,0 +1,17 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-cursor-at-document-start' + +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`) + await Command.execute('DiffView.setCursorPosition', 0, 0) + + const cursor = Locator('.EditorCursorRight') + await expect(cursor).toHaveCSS('left', '49px') + await expect(cursor).toHaveCSS('top', '0px') +} diff --git a/packages/e2e/src/diff.coverage-cursor-down-clamps-column.ts b/packages/e2e/src/diff.coverage-cursor-down-clamps-column.ts new file mode 100644 index 0000000..1ec7759 --- /dev/null +++ b/packages/e2e/src/diff.coverage-cursor-down-clamps-column.ts @@ -0,0 +1,18 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-cursor-down-clamps-column' + +export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'alpha\nb') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'alpha\nb') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + await Command.execute('DiffView.setCursorPosition', 5, 0) + await Command.execute('DiffView.moveCursorDown') + + const cursor = Locator('.EditorCursorRight') + await expect(cursor).toHaveCSS('left', '58px') + await expect(cursor).toHaveCSS('top', '20px') +} diff --git a/packages/e2e/src/diff.coverage-cursor-down-last-line.ts b/packages/e2e/src/diff.coverage-cursor-down-last-line.ts new file mode 100644 index 0000000..7f54ec4 --- /dev/null +++ b/packages/e2e/src/diff.coverage-cursor-down-last-line.ts @@ -0,0 +1,18 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-cursor-down-last-line' + +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`) + await Command.execute('DiffView.setCursorPosition', 2, 1) + await Command.execute('DiffView.moveCursorDown') + + const cursor = Locator('.EditorCursorRight') + await expect(cursor).toHaveCSS('left', '67px') + await expect(cursor).toHaveCSS('top', '20px') +} diff --git a/packages/e2e/src/diff.coverage-cursor-left-document-start.ts b/packages/e2e/src/diff.coverage-cursor-left-document-start.ts new file mode 100644 index 0000000..e17cae2 --- /dev/null +++ b/packages/e2e/src/diff.coverage-cursor-left-document-start.ts @@ -0,0 +1,18 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-cursor-left-document-start' + +export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'alpha') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'alpha') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + await Command.execute('DiffView.setCursorPosition', 0, 0) + await Command.execute('DiffView.moveCursorLeft') + + const cursor = Locator('.EditorCursorRight') + await expect(cursor).toHaveCSS('left', '49px') + await expect(cursor).toHaveCSS('top', '0px') +} diff --git a/packages/e2e/src/diff.coverage-cursor-right-document-end.ts b/packages/e2e/src/diff.coverage-cursor-right-document-end.ts new file mode 100644 index 0000000..fa4e5d5 --- /dev/null +++ b/packages/e2e/src/diff.coverage-cursor-right-document-end.ts @@ -0,0 +1,18 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-cursor-right-document-end' + +export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'alpha') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'alpha') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + await Command.execute('DiffView.setCursorPosition', 5, 0) + await Command.execute('DiffView.moveCursorRight') + + const cursor = Locator('.EditorCursorRight') + await expect(cursor).toHaveCSS('left', '94px') + await expect(cursor).toHaveCSS('top', '0px') +} diff --git a/packages/e2e/src/diff.coverage-cursor-up-clamps-column.ts b/packages/e2e/src/diff.coverage-cursor-up-clamps-column.ts new file mode 100644 index 0000000..d0b0c8a --- /dev/null +++ b/packages/e2e/src/diff.coverage-cursor-up-clamps-column.ts @@ -0,0 +1,18 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-cursor-up-clamps-column' + +export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'a\ngamma') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'a\ngamma') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + await Command.execute('DiffView.setCursorPosition', 5, 1) + await Command.execute('DiffView.moveCursorUp') + + const cursor = Locator('.EditorCursorRight') + await expect(cursor).toHaveCSS('left', '58px') + await expect(cursor).toHaveCSS('top', '0px') +} diff --git a/packages/e2e/src/diff.coverage-cursor-up-first-line.ts b/packages/e2e/src/diff.coverage-cursor-up-first-line.ts new file mode 100644 index 0000000..a439e15 --- /dev/null +++ b/packages/e2e/src/diff.coverage-cursor-up-first-line.ts @@ -0,0 +1,18 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-cursor-up-first-line' + +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`) + await Command.execute('DiffView.setCursorPosition', 2, 0) + await Command.execute('DiffView.moveCursorUp') + + const cursor = Locator('.EditorCursorRight') + await expect(cursor).toHaveCSS('left', '67px') + await expect(cursor).toHaveCSS('top', '0px') +} diff --git a/packages/e2e/src/diff.coverage-delete-left-character.ts b/packages/e2e/src/diff.coverage-delete-left-character.ts new file mode 100644 index 0000000..9aaad18 --- /dev/null +++ b/packages/e2e/src/diff.coverage-delete-left-character.ts @@ -0,0 +1,17 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-delete-left-character' + +export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'pear') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'pear') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + await Command.execute('DiffView.setCursorPosition', 2, 0) + await Command.execute('DiffView.deleteLeft') + + const afterRows = Locator('.DiffEditorContentRight .DiffEditorRows') + await expect(afterRows).toHaveText('par') +} diff --git a/packages/e2e/src/diff.coverage-delete-left-document-start.ts b/packages/e2e/src/diff.coverage-delete-left-document-start.ts new file mode 100644 index 0000000..d4373b8 --- /dev/null +++ b/packages/e2e/src/diff.coverage-delete-left-document-start.ts @@ -0,0 +1,17 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-delete-left-document-start' + +export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'alpha') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'alpha') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + await Command.execute('DiffView.setCursorPosition', 0, 0) + await Command.execute('DiffView.deleteLeft') + + const afterRows = Locator('.DiffEditorContentRight .DiffEditorRows') + await expect(afterRows).toHaveText('alpha') +} diff --git a/packages/e2e/src/diff.coverage-delete-left-line-break.ts b/packages/e2e/src/diff.coverage-delete-left-line-break.ts new file mode 100644 index 0000000..b5e3596 --- /dev/null +++ b/packages/e2e/src/diff.coverage-delete-left-line-break.ts @@ -0,0 +1,17 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-delete-left-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`) + await Command.execute('DiffView.setCursorPosition', 0, 1) + await Command.execute('DiffView.deleteLeft') + + const afterRows = Locator('.DiffEditorContentRight .DiffEditorRows') + await expect(afterRows).toHaveText('alphabeta') +} diff --git a/packages/e2e/src/diff.coverage-delete-right-document-end.ts b/packages/e2e/src/diff.coverage-delete-right-document-end.ts new file mode 100644 index 0000000..1a4380f --- /dev/null +++ b/packages/e2e/src/diff.coverage-delete-right-document-end.ts @@ -0,0 +1,17 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-delete-right-document-end' + +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`) + await Command.execute('DiffView.setCursorPosition', 4, 1) + await Command.execute('DiffView.deleteRight') + + const afterRows = Locator('.DiffEditorContentRight .DiffEditorRows') + await expect(afterRows).toHaveText('alphabeta') +} diff --git a/packages/e2e/src/diff.coverage-delete-right-empty-document.ts b/packages/e2e/src/diff.coverage-delete-right-empty-document.ts new file mode 100644 index 0000000..e789abc --- /dev/null +++ b/packages/e2e/src/diff.coverage-delete-right-empty-document.ts @@ -0,0 +1,17 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-delete-right-empty-document' + +export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, '') + await FileSystem.writeFile(`${tmpDir}/after.txt`, '') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + await Command.execute('DiffView.setCursorPosition', 0, 0) + await Command.execute('DiffView.deleteRight') + + const afterRows = Locator('.DiffEditorContentRight .DiffEditorRows') + await expect(afterRows).toHaveText('') +} diff --git a/packages/e2e/src/diff.coverage-final-line-deletion.ts b/packages/e2e/src/diff.coverage-final-line-deletion.ts new file mode 100644 index 0000000..f4bb4bc --- /dev/null +++ b/packages/e2e/src/diff.coverage-final-line-deletion.ts @@ -0,0 +1,16 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-final-line-deletion' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'shared one\nshared two\nold final') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'shared one\nshared two') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const deletedRows = Locator('.DiffEditorContentLeft .EditorRow.Deletion') + await expect(deletedRows).toHaveCount(1) + await expect(deletedRows).toHaveText('old final') +} diff --git a/packages/e2e/src/diff.coverage-final-line-insertion.ts b/packages/e2e/src/diff.coverage-final-line-insertion.ts new file mode 100644 index 0000000..2b30fdd --- /dev/null +++ b/packages/e2e/src/diff.coverage-final-line-insertion.ts @@ -0,0 +1,16 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-final-line-insertion' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'shared one\nshared two') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'shared one\nshared two\nnew final') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const insertedRows = Locator('.DiffEditorContentRight .EditorRow.Insertion') + await expect(insertedRows).toHaveCount(1) + await expect(insertedRows).toHaveText('new final') +} diff --git a/packages/e2e/src/diff.coverage-final-line-replacement.ts b/packages/e2e/src/diff.coverage-final-line-replacement.ts new file mode 100644 index 0000000..f5d24a5 --- /dev/null +++ b/packages/e2e/src/diff.coverage-final-line-replacement.ts @@ -0,0 +1,17 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-final-line-replacement' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'shared\nbefore final') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'shared\nafter final') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const deletedRows = Locator('.DiffEditorContentLeft .EditorRow.Deletion') + const insertedRows = Locator('.DiffEditorContentRight .EditorRow.Insertion') + await expect(deletedRows).toHaveText('before final') + await expect(insertedRows).toHaveText('after final') +} diff --git a/packages/e2e/src/diff.coverage-first-line-deletion.ts b/packages/e2e/src/diff.coverage-first-line-deletion.ts new file mode 100644 index 0000000..cd70818 --- /dev/null +++ b/packages/e2e/src/diff.coverage-first-line-deletion.ts @@ -0,0 +1,16 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-first-line-deletion' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'old first\nshared one\nshared two') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'shared one\nshared two') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const deletedRows = Locator('.DiffEditorContentLeft .EditorRow.Deletion') + await expect(deletedRows).toHaveCount(1) + await expect(deletedRows).toHaveText('old first') +} diff --git a/packages/e2e/src/diff.coverage-first-line-insertion.ts b/packages/e2e/src/diff.coverage-first-line-insertion.ts new file mode 100644 index 0000000..e994181 --- /dev/null +++ b/packages/e2e/src/diff.coverage-first-line-insertion.ts @@ -0,0 +1,16 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-first-line-insertion' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'shared one\nshared two') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'new first\nshared one\nshared two') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const insertedRows = Locator('.DiffEditorContentRight .EditorRow.Insertion') + await expect(insertedRows).toHaveCount(1) + await expect(insertedRows).toHaveText('new first') +} diff --git a/packages/e2e/src/diff.coverage-first-line-replacement.ts b/packages/e2e/src/diff.coverage-first-line-replacement.ts new file mode 100644 index 0000000..ab5ba40 --- /dev/null +++ b/packages/e2e/src/diff.coverage-first-line-replacement.ts @@ -0,0 +1,17 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-first-line-replacement' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'before first\nshared') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'after first\nshared') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const deletedRows = Locator('.DiffEditorContentLeft .EditorRow.Deletion') + const insertedRows = Locator('.DiffEditorContentRight .EditorRow.Insertion') + await expect(deletedRows).toHaveText('before first') + await expect(insertedRows).toHaveText('after first') +} diff --git a/packages/e2e/src/diff.coverage-inline-empty-after.ts b/packages/e2e/src/diff.coverage-inline-empty-after.ts new file mode 100644 index 0000000..0b79adb --- /dev/null +++ b/packages/e2e/src/diff.coverage-inline-empty-after.ts @@ -0,0 +1,16 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-inline-empty-after' + +export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'removed') + await FileSystem.writeFile(`${tmpDir}/after.txt`, '') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + await Command.execute('DiffView.setDiffMode', 'inline') + + const inlineRows = Locator('.InlineDiffEditor .DiffEditorRows') + await expect(inlineRows).toContainText('- removed') +} diff --git a/packages/e2e/src/diff.coverage-inline-empty-before.ts b/packages/e2e/src/diff.coverage-inline-empty-before.ts new file mode 100644 index 0000000..bc966a4 --- /dev/null +++ b/packages/e2e/src/diff.coverage-inline-empty-before.ts @@ -0,0 +1,16 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-inline-empty-before' + +export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, '') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'added') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + await Command.execute('DiffView.setDiffMode', 'inline') + + const inlineRows = Locator('.InlineDiffEditor .DiffEditorRows') + await expect(inlineRows).toContainText('+ added') +} diff --git a/packages/e2e/src/diff.coverage-inline-identical-content.ts b/packages/e2e/src/diff.coverage-inline-identical-content.ts new file mode 100644 index 0000000..438fed4 --- /dev/null +++ b/packages/e2e/src/diff.coverage-inline-identical-content.ts @@ -0,0 +1,19 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-inline-identical-content' + +export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'shared one\nshared two') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'shared one\nshared two') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + await Command.execute('DiffView.setDiffMode', 'inline') + + const inlineRows = Locator('.InlineDiffEditor .DiffEditorRows') + const changedRows = Locator('.InlineDiffEditor .EditorRow.Insertion, .InlineDiffEditor .EditorRow.Deletion') + await expect(inlineRows).toContainText('shared one') + await expect(inlineRows).toContainText('shared two') + await expect(changedRows).toHaveCount(0) +} diff --git a/packages/e2e/src/diff.coverage-middle-line-deletion.ts b/packages/e2e/src/diff.coverage-middle-line-deletion.ts new file mode 100644 index 0000000..11d0543 --- /dev/null +++ b/packages/e2e/src/diff.coverage-middle-line-deletion.ts @@ -0,0 +1,16 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-middle-line-deletion' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'shared one\nold middle\nshared two') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'shared one\nshared two') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const deletedRows = Locator('.DiffEditorContentLeft .EditorRow.Deletion') + await expect(deletedRows).toHaveCount(1) + await expect(deletedRows).toHaveText('old middle') +} diff --git a/packages/e2e/src/diff.coverage-middle-line-insertion.ts b/packages/e2e/src/diff.coverage-middle-line-insertion.ts new file mode 100644 index 0000000..38e6822 --- /dev/null +++ b/packages/e2e/src/diff.coverage-middle-line-insertion.ts @@ -0,0 +1,16 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-middle-line-insertion' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'shared one\nshared two') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'shared one\nnew middle\nshared two') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const insertedRows = Locator('.DiffEditorContentRight .EditorRow.Insertion') + await expect(insertedRows).toHaveCount(1) + await expect(insertedRows).toHaveText('new middle') +} diff --git a/packages/e2e/src/diff.coverage-middle-line-replacement.ts b/packages/e2e/src/diff.coverage-middle-line-replacement.ts new file mode 100644 index 0000000..c515013 --- /dev/null +++ b/packages/e2e/src/diff.coverage-middle-line-replacement.ts @@ -0,0 +1,17 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-middle-line-replacement' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'shared one\nbefore middle\nshared two') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'shared one\nafter middle\nshared two') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const deletedRows = Locator('.DiffEditorContentLeft .EditorRow.Deletion') + const insertedRows = Locator('.DiffEditorContentRight .EditorRow.Insertion') + await expect(deletedRows).toHaveText('before middle') + await expect(insertedRows).toHaveText('after middle') +} diff --git a/packages/e2e/src/diff.coverage-mode-toggle-empty-after-roundtrip.ts b/packages/e2e/src/diff.coverage-mode-toggle-empty-after-roundtrip.ts new file mode 100644 index 0000000..6b5cad0 --- /dev/null +++ b/packages/e2e/src/diff.coverage-mode-toggle-empty-after-roundtrip.ts @@ -0,0 +1,20 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-mode-toggle-empty-after-roundtrip' + +export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'removed') + await FileSystem.writeFile(`${tmpDir}/after.txt`, '') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + await Command.execute('DiffView.toggleDiffMode') + + const inlineRows = Locator('.InlineDiffEditor .DiffEditorRows') + await expect(inlineRows).toContainText('- removed') + + await Command.execute('DiffView.toggleDiffMode') + const leftRows = Locator('.DiffEditorContentLeft .DiffEditorRows') + await expect(leftRows).toHaveText('removed') +} diff --git a/packages/e2e/src/diff.coverage-mode-toggle-empty-before-roundtrip.ts b/packages/e2e/src/diff.coverage-mode-toggle-empty-before-roundtrip.ts new file mode 100644 index 0000000..0155369 --- /dev/null +++ b/packages/e2e/src/diff.coverage-mode-toggle-empty-before-roundtrip.ts @@ -0,0 +1,20 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-mode-toggle-empty-before-roundtrip' + +export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, '') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'added') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + await Command.execute('DiffView.toggleDiffMode') + + const inlineRows = Locator('.InlineDiffEditor .DiffEditorRows') + await expect(inlineRows).toContainText('+ added') + + await Command.execute('DiffView.toggleDiffMode') + const rightRows = Locator('.DiffEditorContentRight .DiffEditorRows') + await expect(rightRows).toHaveText('added') +} diff --git a/packages/e2e/src/diff.coverage-rtl-line-replacement.ts b/packages/e2e/src/diff.coverage-rtl-line-replacement.ts new file mode 100644 index 0000000..4ef0d24 --- /dev/null +++ b/packages/e2e/src/diff.coverage-rtl-line-replacement.ts @@ -0,0 +1,17 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-rtl-line-replacement' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'الحالة: قديم') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'الحالة: جديد') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const leftRows = Locator('.DiffEditorContentLeft .DiffEditorRows') + const rightRows = Locator('.DiffEditorContentRight .DiffEditorRows') + await expect(leftRows).toHaveText('الحالة: قديم') + await expect(rightRows).toHaveText('الحالة: جديد') +} diff --git a/packages/e2e/src/diff.coverage-scroll-roundtrip.ts b/packages/e2e/src/diff.coverage-scroll-roundtrip.ts new file mode 100644 index 0000000..c9ebde9 --- /dev/null +++ b/packages/e2e/src/diff.coverage-scroll-roundtrip.ts @@ -0,0 +1,24 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-scroll-roundtrip' + +const getContent = (): string => { + return Array.from({ length: 80 }, (_, index) => `line ${index + 1}`).join('\n') +} + +export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + const content = getContent() + await FileSystem.writeFile(`${tmpDir}/before.txt`, content) + await FileSystem.writeFile(`${tmpDir}/after.txt`, content) + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const rightRows = Locator('.DiffEditorContentRight .DiffEditorRows') + await expect(rightRows).toContainText('line 1') + await Command.execute('DiffView.handleWheel', 0, 9999) + await expect(rightRows).toContainText('line 80') + await Command.execute('DiffView.handleWheel', 0, -9999) + await expect(rightRows).toContainText('line 1') +} diff --git a/packages/e2e/src/diff.coverage-separated-line-deletions.ts b/packages/e2e/src/diff.coverage-separated-line-deletions.ts new file mode 100644 index 0000000..b984c10 --- /dev/null +++ b/packages/e2e/src/diff.coverage-separated-line-deletions.ts @@ -0,0 +1,18 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-separated-line-deletions' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'removed first\none\ntwo\nremoved second\nthree') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'one\ntwo\nthree') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const deletedRows = Locator('.DiffEditorContentLeft .EditorRow.Deletion') + const secondDeletedRow = deletedRows.nth(1) + await expect(deletedRows).toHaveCount(2) + await expect(deletedRows.first()).toHaveText('removed first') + await expect(secondDeletedRow).toHaveText('removed second') +} diff --git a/packages/e2e/src/diff.coverage-separated-line-insertions.ts b/packages/e2e/src/diff.coverage-separated-line-insertions.ts new file mode 100644 index 0000000..65f1ba2 --- /dev/null +++ b/packages/e2e/src/diff.coverage-separated-line-insertions.ts @@ -0,0 +1,18 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-separated-line-insertions' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'one\ntwo\nthree') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'added first\none\ntwo\nadded second\nthree') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const insertedRows = Locator('.DiffEditorContentRight .EditorRow.Insertion') + const secondInsertedRow = insertedRows.nth(1) + await expect(insertedRows).toHaveCount(2) + await expect(insertedRows.first()).toHaveText('added first') + await expect(secondInsertedRow).toHaveText('added second') +} diff --git a/packages/e2e/src/diff.coverage-single-line-deletion.ts b/packages/e2e/src/diff.coverage-single-line-deletion.ts new file mode 100644 index 0000000..30d6d10 --- /dev/null +++ b/packages/e2e/src/diff.coverage-single-line-deletion.ts @@ -0,0 +1,16 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-single-line-deletion' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'removed') + await FileSystem.writeFile(`${tmpDir}/after.txt`, '') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const deletedRows = Locator('.DiffEditorContentLeft .EditorRow.Deletion') + await expect(deletedRows).toHaveCount(1) + await expect(deletedRows).toHaveText('removed') +} diff --git a/packages/e2e/src/diff.coverage-single-line-insertion.ts b/packages/e2e/src/diff.coverage-single-line-insertion.ts new file mode 100644 index 0000000..dc948ba --- /dev/null +++ b/packages/e2e/src/diff.coverage-single-line-insertion.ts @@ -0,0 +1,16 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-single-line-insertion' + +export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, '') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'added') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const insertedRows = Locator('.DiffEditorContentRight .EditorRow.Insertion') + await expect(insertedRows).toHaveCount(1) + await expect(insertedRows).toHaveText('added') +} diff --git a/packages/e2e/src/diff.coverage-whitespace-toggle-roundtrip.ts b/packages/e2e/src/diff.coverage-whitespace-toggle-roundtrip.ts new file mode 100644 index 0000000..ed87fed --- /dev/null +++ b/packages/e2e/src/diff.coverage-whitespace-toggle-roundtrip.ts @@ -0,0 +1,19 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'diff.coverage-whitespace-toggle-roundtrip' + +export const test: Test = async ({ Command, DiffView, expect, FileSystem, Locator, Workspace }) => { + const tmpDir = await FileSystem.getTmpDir() + await FileSystem.writeFile(`${tmpDir}/before.txt`, 'before value') + await FileSystem.writeFile(`${tmpDir}/after.txt`, 'after value') + await Workspace.setPath(tmpDir) + + await DiffView.open(`${tmpDir}/before.txt`, `${tmpDir}/after.txt`) + + const activeToggle = Locator('.DiffEditorWhitespaceToggleActive') + await expect(activeToggle).toHaveCount(0) + await Command.execute('DiffView.toggleWhitespace') + await expect(activeToggle).toHaveCount(1) + await Command.execute('DiffView.toggleWhitespace') + await expect(activeToggle).toHaveCount(0) +}