Skip to content
Merged
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
15 changes: 9 additions & 6 deletions packages/e2e/src/diff.ambiguous-duplicated-codeblocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import type { Test } from '@lvce-editor/test-with-playwright'

export const name = 'diff.ambiguous-duplicated-codeblocks'

export const skip = 1

const expectRowsToHaveText = async (expect: any, rows: any, texts: readonly string[]): Promise<void> => {
for (let index = 0; index < texts.length; index += 1) {
await expect(rows.nth(index)).toHaveText(texts[index])
Expand Down Expand Up @@ -62,14 +60,18 @@ const afterAnchor = true`,

const leftRows = Locator('.DiffEditorContentLeft .EditorRow')
const rightRows = Locator('.DiffEditorContentRight .EditorRow')
const rightGutterItems = Locator('.DiffEditorContentRight .DiffEditorGutter > div')
const rightLineNumbers = Locator('.DiffEditorContentRight .DiffEditorLineNumber')
const rightEmptyLineNumbers = Locator('.DiffEditorContentRight .DiffEditorLineNumberEmpty')
const deletedRows = Locator('.DiffEditorContentLeft .EditorRow.Deletion')
const insertedRows = Locator('.DiffEditorContentRight .EditorRow.Insertion')
const blockLines = block.split('\n')

await expect(leftRows).toHaveCount(17)
await expect(rightRows).toHaveCount(17)
await expect(rightLineNumbers).toHaveCount(17)
await expect(rightGutterItems).toHaveCount(13)
await expect(rightLineNumbers).toHaveCount(12)
await expect(rightEmptyLineNumbers).toHaveCount(1)
await expect(deletedRows).toHaveCount(5)
await expect(insertedRows).toHaveCount(0)
await expect(deletedRows.nth(0)).toHaveText('if (enabled) {')
Expand All @@ -87,8 +89,9 @@ const afterAnchor = true`,
expectRowsToHaveText(expect, rightRows, ['const beforeAnchor = true', ...blockLines, ...blockLines, '', '', '', '', '', 'const afterAnchor = true']),
])
await expectOneOf([
(): Promise<void> => expectRowsToHaveText(expect, rightLineNumbers, ['1', '', '', '', '', '', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']),
(): Promise<void> => expectRowsToHaveText(expect, rightLineNumbers, ['1', '2', '3', '4', '5', '6', '', '', '', '', '', '7', '8', '9', '10', '11', '12']),
(): Promise<void> => expectRowsToHaveText(expect, rightLineNumbers, ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '', '', '', '', '', '12']),
(): Promise<void> => expectRowsToHaveText(expect, rightGutterItems, ['1', '', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']),
(): Promise<void> => expectRowsToHaveText(expect, rightGutterItems, ['1', '2', '3', '4', '5', '6', '', '7', '8', '9', '10', '11', '12']),
(): Promise<void> => expectRowsToHaveText(expect, rightGutterItems, ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '', '12']),
])
await expect(rightEmptyLineNumbers.nth(0)).toHaveAttribute('style', 'height: 100px;')
}
Loading