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
28 changes: 28 additions & 0 deletions packages/e2e/src/diff.cursor-navigation-horizontal.ts
Original file line number Diff line number Diff line change
@@ -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')
}
23 changes: 23 additions & 0 deletions packages/e2e/src/diff.cursor-navigation-line-boundaries.ts
Original file line number Diff line number Diff line change
@@ -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')
}
29 changes: 29 additions & 0 deletions packages/e2e/src/diff.cursor-navigation-vertical.ts
Original file line number Diff line number Diff line change
@@ -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')
}
18 changes: 18 additions & 0 deletions packages/e2e/src/diff.delete-right-character.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.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')
}
18 changes: 18 additions & 0 deletions packages/e2e/src/diff.delete-right-line-break.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.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')
}
Loading