Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/e2e/src/diff.coverage-blank-line-deletion.ts
Original file line number Diff line number Diff line change
@@ -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('')
}
16 changes: 16 additions & 0 deletions packages/e2e/src/diff.coverage-blank-line-insertion.ts
Original file line number Diff line number Diff line change
@@ -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('')
}
17 changes: 17 additions & 0 deletions packages/e2e/src/diff.coverage-cjk-line-replacement.ts
Original file line number Diff line number Diff line change
@@ -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('状態: 完了')
}
16 changes: 16 additions & 0 deletions packages/e2e/src/diff.coverage-combining-mark-replacement.ts
Original file line number Diff line number Diff line change
@@ -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}')
}
18 changes: 18 additions & 0 deletions packages/e2e/src/diff.coverage-consecutive-lines-deletion.ts
Original file line number Diff line number Diff line change
@@ -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')
}
18 changes: 18 additions & 0 deletions packages/e2e/src/diff.coverage-consecutive-lines-insertion.ts
Original file line number Diff line number Diff line change
@@ -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')
}
17 changes: 17 additions & 0 deletions packages/e2e/src/diff.coverage-cursor-at-document-end.ts
Original file line number Diff line number Diff line change
@@ -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')
}
17 changes: 17 additions & 0 deletions packages/e2e/src/diff.coverage-cursor-at-document-start.ts
Original file line number Diff line number Diff line change
@@ -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')
}
18 changes: 18 additions & 0 deletions packages/e2e/src/diff.coverage-cursor-down-clamps-column.ts
Original file line number Diff line number Diff line change
@@ -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')
}
18 changes: 18 additions & 0 deletions packages/e2e/src/diff.coverage-cursor-down-last-line.ts
Original file line number Diff line number Diff line change
@@ -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')
}
18 changes: 18 additions & 0 deletions packages/e2e/src/diff.coverage-cursor-left-document-start.ts
Original file line number Diff line number Diff line change
@@ -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')
}
18 changes: 18 additions & 0 deletions packages/e2e/src/diff.coverage-cursor-right-document-end.ts
Original file line number Diff line number Diff line change
@@ -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')
}
18 changes: 18 additions & 0 deletions packages/e2e/src/diff.coverage-cursor-up-clamps-column.ts
Original file line number Diff line number Diff line change
@@ -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')
}
18 changes: 18 additions & 0 deletions packages/e2e/src/diff.coverage-cursor-up-first-line.ts
Original file line number Diff line number Diff line change
@@ -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')
}
17 changes: 17 additions & 0 deletions packages/e2e/src/diff.coverage-delete-left-character.ts
Original file line number Diff line number Diff line change
@@ -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')
}
17 changes: 17 additions & 0 deletions packages/e2e/src/diff.coverage-delete-left-document-start.ts
Original file line number Diff line number Diff line change
@@ -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')
}
17 changes: 17 additions & 0 deletions packages/e2e/src/diff.coverage-delete-left-line-break.ts
Original file line number Diff line number Diff line change
@@ -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')
}
17 changes: 17 additions & 0 deletions packages/e2e/src/diff.coverage-delete-right-document-end.ts
Original file line number Diff line number Diff line change
@@ -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')
}
17 changes: 17 additions & 0 deletions packages/e2e/src/diff.coverage-delete-right-empty-document.ts
Original file line number Diff line number Diff line change
@@ -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('')
}
16 changes: 16 additions & 0 deletions packages/e2e/src/diff.coverage-final-line-deletion.ts
Original file line number Diff line number Diff line change
@@ -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')
}
16 changes: 16 additions & 0 deletions packages/e2e/src/diff.coverage-final-line-insertion.ts
Original file line number Diff line number Diff line change
@@ -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')
}
17 changes: 17 additions & 0 deletions packages/e2e/src/diff.coverage-final-line-replacement.ts
Original file line number Diff line number Diff line change
@@ -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')
}
Loading