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
8 changes: 4 additions & 4 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import config from '@lvce-editor/eslint-config'
import * as config from '@lvce-editor/eslint-config'

export default [
...config,
...config.default,
...config.recommendedRegex,
...config.recommendedActions,
{
files: ['packages/e2e/**/*.ts'],
rules: {
'@cspell/spellchecker': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/prefer-readonly-parameter-types': 'off',
},
},
]
71 changes: 35 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { parseStackLocation } from '../StackLocationRegex/StackLocationRegex.ts'

const trailingOpenParenthesisRegex = /\($/

export const getStackLinePrefix = (stackLine: string): string => {
const match = parseStackLocation(stackLine)
if (!match) {
return stackLine
}
return stackLine.slice(0, stackLine.length - match.text.length).replace(/\($/, '')
return stackLine.slice(0, stackLine.length - match.text.length).replace(trailingOpenParenthesisRegex, '')
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export interface StackLocationMatch {
readonly text: string
}

const whitespaceRegex = /\s/

const isSchemeCharacter = (char: string): boolean => {
return (char >= 'a' && char <= 'z') || (char >= 'A' && char <= 'Z') || (char >= '0' && char <= '9') || char === '+' || char === '.' || char === '-'
}
Expand All @@ -12,7 +14,7 @@ const isSchemeStart = (char: string): boolean => {
}

const isLocationBoundary = (stackLine: string, index: number): boolean => {
return index === 0 || stackLine[index - 1] === '(' || /\s/.test(stackLine[index - 1])
return index === 0 || stackLine[index - 1] === '(' || whitespaceRegex.test(stackLine[index - 1])
}

const getSchemeLocationStart = (stackLine: string, locationEnd: number): number => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ export interface SyntaxLanguageInfo {
readonly tokenizerPath: string
}

const queryOrHashRegex = /[?#]/

const getFileName = (uri: string): string => {
const protocol = getProtocol(uri)
const path = getPath(protocol, uri).split(/[?#]/, 1)[0]
const path = getPath(protocol, uri).split(queryOrHashRegex, 1)[0]
const lastSlashIndex = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\'))
if (lastSlashIndex === -1) {
return path
Expand Down
14 changes: 8 additions & 6 deletions packages/diff-view/test/GetContentRightDom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getContentRightDom } from '../src/parts/GetContentRightDom/GetContentRi
import * as InputName from '../src/parts/InputName/InputName.ts'
import { VisibleLineType } from '../src/parts/VisibleLine/VisibleLine.ts'

test.skip('getContentRightDom renders each right line inside an EditorRow', (): void => {
test('getContentRightDom renders each right line inside an EditorRow', (): void => {
const result = getContentRightDom({
allowedLinkSchemes: defaultAllowedLinkSchemes,
contentRight: 'after-content\nsecond-line',
Expand Down Expand Up @@ -61,7 +61,7 @@ test.skip('getContentRightDom renders each right line inside an EditorRow', ():
])
})

test.skip('getContentRightDom renders cursor for editable right content', (): void => {
test('getContentRightDom renders cursor for editable right content', (): void => {
const result = getContentRightDom({
allowedLinkSchemes: defaultAllowedLinkSchemes,
contentRight: 'after-content',
Expand Down Expand Up @@ -128,13 +128,15 @@ test.skip('getContentRightDom renders cursor for editable right content', (): vo
className: ClassNames.DiffEditorInput,
name: InputName.DiffEditorInput,
onInput: DomEventListenerFunctions.HandleInput,
type: VirtualDomElements.Input,
selectionEnd: 0,
selectionStart: 0,
type: VirtualDomElements.TextArea,
value: '',
},
])
})

test.skip('getContentRightDom renders load errors when available', (): void => {
test('getContentRightDom renders load errors when available', (): void => {
const result = getContentRightDom({
contentRight: '',
errorMessage: 'permission denied',
Expand All @@ -156,7 +158,7 @@ test.skip('getContentRightDom renders load errors when available', (): void => {
])
})

test.skip('getContentRightDom renders paired deletion and insertion on the same row', (): void => {
test('getContentRightDom renders paired deletion and insertion on the same row', (): void => {
const result = getContentRightDom({
allowedLinkSchemes: defaultAllowedLinkSchemes,
contentRight: 'shared-line\nadded-line',
Expand Down Expand Up @@ -215,7 +217,7 @@ test.skip('getContentRightDom renders paired deletion and insertion on the same
])
})

test.skip('getContentRightDom renders syntax-highlighted token spans', (): void => {
test('getContentRightDom renders syntax-highlighted token spans', (): void => {
const result = getContentRightDom({
allowedLinkSchemes: defaultAllowedLinkSchemes,
contentRight: 'const answer = 1',
Expand Down
4 changes: 3 additions & 1 deletion packages/e2e/src/diff.media-fallback-missing-invalid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export const name = 'diff.media-fallback-missing-invalid'

export const skip = 1

const svgDataUriRegex = /^data:image\/svg\+xml;/

export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Workspace }) => {
const tmpDir = await FileSystem.getTmpDir()
await Workspace.setPath(tmpDir)
Expand All @@ -15,7 +17,7 @@ export const test: Test = async ({ DiffView, expect, FileSystem, Locator, Worksp
const afterPane = Locator('.DiffPane--after')
const afterImage = Locator('.DiffPane--after .ImageElement')
await expect(beforePane).toContainText('Failed to load image')
await expect(afterImage).toHaveAttribute('src', /^data:image\/svg\+xml;/ as unknown as string)
await expect(afterImage).toHaveAttribute('src', svgDataUriRegex as unknown as string)

await FileSystem.writeFile(`${tmpDir}/left-invalid.mp4`, 'not a video')
await DiffView.open(`${tmpDir}/left-invalid.mp4`, `${tmpDir}/missing-right.mp4`)
Expand Down
7 changes: 5 additions & 2 deletions packages/e2e/src/diff.video-different-formats-valid-both.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export const name = 'diff.video-different-formats-valid-both'

export const skip = 1

const mp4DataUriRegex = /^data:video\/mp4;base64,/
const webmDataUriRegex = /^data:video\/webm;base64,/

export const test: Test = async ({ DiffView, expect, FileSystem, Locator }) => {
const tmpDir = await FileSystem.getTmpDir()
await FileSystem.writeFile(`${tmpDir}/left.mp4`, 'fixture')
Expand All @@ -15,7 +18,7 @@ export const test: Test = async ({ DiffView, expect, FileSystem, Locator }) => {
const afterVideo = Locator('.DiffPane--after .VideoElement')

await expect(beforeVideo).toHaveAttribute('title', 'left.mp4')
await expect(beforeVideo).toHaveAttribute('src', /^data:video\/mp4;base64,/ as unknown as string)
await expect(beforeVideo).toHaveAttribute('src', mp4DataUriRegex as unknown as string)
await expect(afterVideo).toHaveAttribute('title', 'right.webm')
await expect(afterVideo).toHaveAttribute('src', /^data:video\/webm;base64,/ as unknown as string)
await expect(afterVideo).toHaveAttribute('src', webmDataUriRegex as unknown as string)
}
4 changes: 3 additions & 1 deletion packages/e2e/src/diff.video-invalid-left-valid-right.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export const name = 'diff.video-invalid-left-valid-right'

export const skip = 1

const mp4DataUriRegex = /^data:video\/mp4;base64,/

export const test: Test = async ({ DiffView, expect, FileSystem, Locator }) => {
const tmpDir = await FileSystem.getTmpDir()
await FileSystem.writeFile(`${tmpDir}/left-invalid.mp4`, 'fixture')
Expand All @@ -16,5 +18,5 @@ export const test: Test = async ({ DiffView, expect, FileSystem, Locator }) => {

await expect(beforePane).toContainText('Failed to load video: left-invalid.mp4')
await expect(afterVideo).toHaveAttribute('title', 'right-valid.mp4')
await expect(afterVideo).toHaveAttribute('src', /^data:video\/mp4;base64,/ as unknown as string)
await expect(afterVideo).toHaveAttribute('src', mp4DataUriRegex as unknown as string)
}
6 changes: 4 additions & 2 deletions packages/e2e/src/diff.video-mp4-valid-both.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export const name = 'diff.video-mp4-valid-both'

export const skip = 1

const mp4DataUriRegex = /^data:video\/mp4;base64,/

export const test: Test = async ({ DiffView, expect, FileSystem, Locator }) => {
const tmpDir = await FileSystem.getTmpDir()
await FileSystem.writeFile(`${tmpDir}/left.mp4`, 'fixture')
Expand All @@ -15,7 +17,7 @@ export const test: Test = async ({ DiffView, expect, FileSystem, Locator }) => {
const afterVideo = Locator('.DiffPane--after .VideoElement')

await expect(beforeVideo).toHaveAttribute('title', 'left.mp4')
await expect(beforeVideo).toHaveAttribute('src', /^data:video\/mp4;base64,/ as unknown as string)
await expect(beforeVideo).toHaveAttribute('src', mp4DataUriRegex as unknown as string)
await expect(afterVideo).toHaveAttribute('title', 'right.mp4')
await expect(afterVideo).toHaveAttribute('src', /^data:video\/mp4;base64,/ as unknown as string)
await expect(afterVideo).toHaveAttribute('src', mp4DataUriRegex as unknown as string)
}
4 changes: 3 additions & 1 deletion packages/e2e/src/diff.video-text-left-video-right.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export const name = 'diff.video-text-left-video-right'

export const skip = 1

const mp4DataUriRegex = /^data:video\/mp4;base64,/

export const test: Test = async ({ DiffView, expect, FileSystem, Locator }) => {
const tmpDir = await FileSystem.getTmpDir()
await FileSystem.writeFile(`${tmpDir}/left.txt`, 'fixture')
Expand All @@ -16,5 +18,5 @@ export const test: Test = async ({ DiffView, expect, FileSystem, Locator }) => {

await expect(beforePane).toContainText('const leftValue = 42')
await expect(afterVideo).toHaveAttribute('title', 'right.mp4')
await expect(afterVideo).toHaveAttribute('src', /^data:video\/mp4;base64,/ as unknown as string)
await expect(afterVideo).toHaveAttribute('src', mp4DataUriRegex as unknown as string)
}