Skip to content

Commit

Permalink
fixed frontend tests
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerkoser committed Dec 13, 2024
1 parent 2373018 commit bba16b3
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 114 deletions.
82 changes: 20 additions & 62 deletions .pnp.cjs

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

Binary file not shown.
Binary file not shown.
Binary file not shown.
21 changes: 10 additions & 11 deletions frontend/__tests__/composables/useCodemirror.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,33 +317,32 @@ describe('composables', () => {
setupSpy()
shootEditorCompletions.editorEnter(editorView)
expect(spy).toHaveBeenCalledTimes(1)
expect(spy).toHaveBeenCalledWith(expect.objectContaining({
expect(spy.mock.calls[0]).toEqual([{
changes: { from: 0, to: 0, insert: '\n' },
selection: { anchor: 1 },
effects: expect.any(StateEffect),
}))

}])
setEditorContentAndCursor('test', 1, 0)
spy.mockReset()
shootEditorCompletions.editorEnter(editorView)
expect(spy).toHaveBeenCalledTimes(1)
expect(spy).toHaveBeenCalledWith(expect.objectContaining({
expect(spy.mock.calls[0]).toEqual([{
changes: { from: 0, to: 0, insert: '\n' },
selection: { anchor: 1 },
effects: expect.any(StateEffect),
}))
}])
})

it('should preserve indent after a regular line', () => {
setEditorContentAndCursor('spec:\n foo:bar', 2, 9)
setupSpy()
shootEditorCompletions.editorEnter(editorView)
expect(spy).toHaveBeenCalledTimes(1)
expect(spy).toHaveBeenCalledWith(expect.objectContaining({
expect(spy.mock.calls[0]).toEqual([{
changes: { from: 15, to: 15, insert: '\n ' },
selection: { anchor: 18 },
effects: expect.any(StateEffect),
}))
}])
})

it('should increase indent after an object or array', () => {
Expand All @@ -352,23 +351,23 @@ describe('composables', () => {
shootEditorCompletions.editorEnter(editorView)
const indent = editorView.state.facet(indentUnit).length
expect(spy).toHaveBeenCalledTimes(1)
expect(spy).toHaveBeenCalledWith(expect.objectContaining({
expect(spy.mock.calls[0]).toEqual([{
changes: { from: 12, to: 12, insert: `\n ${repeat(' ', indent)}` },
selection: { anchor: 18 },
effects: expect.any(StateEffect),
}))
}])
})

it('should increase indent after first item of an array', () => {
setEditorContentAndCursor('spec:\n foo:\n - foo:bar', 3, 13)
setupSpy()
shootEditorCompletions.editorEnter(editorView)
expect(spy).toHaveBeenCalledTimes(1)
expect(spy).toHaveBeenCalledWith(expect.objectContaining({
expect(spy.mock.calls[0]).toEqual([{
changes: { from: 26, to: 26, insert: '\n ' },
selection: { anchor: 33 },
effects: expect.any(StateEffect),
}))
}])
})
})
})
Expand Down
12 changes: 6 additions & 6 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
"test": "vitest run"
},
"dependencies": {
"@codemirror/autocomplete": "^6.18.0",
"@codemirror/commands": "^6.6.0",
"@codemirror/lang-yaml": "^6.1.1",
"@codemirror/language": "^6.10.2",
"@codemirror/search": "^6.5.6",
"@codemirror/state": "^6.4.1",
"@codemirror/autocomplete": "^6.18.3",
"@codemirror/commands": "^6.7.1",
"@codemirror/lang-yaml": "^6.1.2",
"@codemirror/language": "^6.10.6",
"@codemirror/search": "^6.5.8",
"@codemirror/state": "^6.5.0",
"@codemirror/theme-one-dark": "^6.1.2",
"@codemirror/view": "^6.35.3",
"@fontsource/roboto": "^5.0.12",
Expand Down
53 changes: 18 additions & 35 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ __metadata:
languageName: node
linkType: hard

"@codemirror/autocomplete@npm:^6.0.0, @codemirror/autocomplete@npm:^6.18.0":
"@codemirror/autocomplete@npm:^6.0.0, @codemirror/autocomplete@npm:^6.18.3":
version: 6.18.3
resolution: "@codemirror/autocomplete@npm:6.18.3"
dependencies:
Expand All @@ -479,7 +479,7 @@ __metadata:
languageName: node
linkType: hard

"@codemirror/commands@npm:^6.6.0":
"@codemirror/commands@npm:^6.7.1":
version: 6.7.1
resolution: "@codemirror/commands@npm:6.7.1"
dependencies:
Expand All @@ -491,21 +491,22 @@ __metadata:
languageName: node
linkType: hard

"@codemirror/lang-yaml@npm:^6.1.1":
version: 6.1.1
resolution: "@codemirror/lang-yaml@npm:6.1.1"
"@codemirror/lang-yaml@npm:^6.1.2":
version: 6.1.2
resolution: "@codemirror/lang-yaml@npm:6.1.2"
dependencies:
"@codemirror/autocomplete": "npm:^6.0.0"
"@codemirror/language": "npm:^6.0.0"
"@codemirror/state": "npm:^6.0.0"
"@lezer/common": "npm:^1.2.0"
"@lezer/highlight": "npm:^1.2.0"
"@lezer/lr": "npm:^1.0.0"
"@lezer/yaml": "npm:^1.0.0"
checksum: 10c0/a6952affceacaa0e9ce699683f167eb356df487fa2254889d0067a30a7effe2d358607182da11bd7bc8d885e42fdd0235100a408f57be5a396b2e08179025246
checksum: 10c0/fc993c5e24baee0212d587c652ee7633792533c1b1e5b708d5e4f6c29e6164a3563958fd6a3bb402a64f565f7bab7edbda6c8b8cd8bfecfd0b7294f0dcf998a8
languageName: node
linkType: hard

"@codemirror/language@npm:^6.0.0, @codemirror/language@npm:^6.10.2":
"@codemirror/language@npm:^6.0.0, @codemirror/language@npm:^6.10.6":
version: 6.10.6
resolution: "@codemirror/language@npm:6.10.6"
dependencies:
Expand All @@ -519,7 +520,7 @@ __metadata:
languageName: node
linkType: hard

"@codemirror/search@npm:^6.5.6":
"@codemirror/search@npm:^6.5.8":
version: 6.5.8
resolution: "@codemirror/search@npm:6.5.8"
dependencies:
Expand All @@ -530,14 +531,7 @@ __metadata:
languageName: node
linkType: hard

"@codemirror/state@npm:^6.0.0, @codemirror/state@npm:^6.4.0, @codemirror/state@npm:^6.4.1":
version: 6.4.1
resolution: "@codemirror/state@npm:6.4.1"
checksum: 10c0/cdab74d0ca4e262531a257ac419c9c44124f3ace8b0ca1262598a9218fbb6fd8f0afeb4b5ed2f64552a9573a0fc5d55481d4b9b05e9505ef729f9bd0f9469423
languageName: node
linkType: hard

"@codemirror/state@npm:^6.5.0":
"@codemirror/state@npm:^6.0.0, @codemirror/state@npm:^6.4.0, @codemirror/state@npm:^6.5.0":
version: 6.5.0
resolution: "@codemirror/state@npm:6.5.0"
dependencies:
Expand All @@ -558,18 +552,7 @@ __metadata:
languageName: node
linkType: hard

"@codemirror/view@npm:^6.0.0, @codemirror/view@npm:^6.17.0, @codemirror/view@npm:^6.23.0, @codemirror/view@npm:^6.27.0":
version: 6.35.2
resolution: "@codemirror/view@npm:6.35.2"
dependencies:
"@codemirror/state": "npm:^6.4.0"
style-mod: "npm:^4.1.0"
w3c-keyname: "npm:^2.2.4"
checksum: 10c0/2f129a65ceb946d77981eaa230e859aa3f989b6d51c2a491f88953e32a91c59a2d5d2676f1944c9f50241eb3bbd301f786d047571834900c676edc981263fdf5
languageName: node
linkType: hard

"@codemirror/view@npm:^6.35.3":
"@codemirror/view@npm:^6.0.0, @codemirror/view@npm:^6.17.0, @codemirror/view@npm:^6.23.0, @codemirror/view@npm:^6.27.0, @codemirror/view@npm:^6.35.3":
version: 6.35.3
resolution: "@codemirror/view@npm:6.35.3"
dependencies:
Expand Down Expand Up @@ -1124,12 +1107,12 @@ __metadata:
version: 0.0.0-use.local
resolution: "@gardener-dashboard/frontend@workspace:frontend"
dependencies:
"@codemirror/autocomplete": "npm:^6.18.0"
"@codemirror/commands": "npm:^6.6.0"
"@codemirror/lang-yaml": "npm:^6.1.1"
"@codemirror/language": "npm:^6.10.2"
"@codemirror/search": "npm:^6.5.6"
"@codemirror/state": "npm:^6.4.1"
"@codemirror/autocomplete": "npm:^6.18.3"
"@codemirror/commands": "npm:^6.7.1"
"@codemirror/lang-yaml": "npm:^6.1.2"
"@codemirror/language": "npm:^6.10.6"
"@codemirror/search": "npm:^6.5.8"
"@codemirror/state": "npm:^6.5.0"
"@codemirror/theme-one-dark": "npm:^6.1.2"
"@codemirror/view": "npm:^6.35.3"
"@fontsource/roboto": "npm:^5.0.12"
Expand Down Expand Up @@ -1746,7 +1729,7 @@ __metadata:
languageName: node
linkType: hard

"@lezer/lr@npm:*, @lezer/lr@npm:^1.0.0, @lezer/lr@npm:^1.4.0":
"@lezer/lr@npm:^1.0.0, @lezer/lr@npm:^1.4.0":
version: 1.4.2
resolution: "@lezer/lr@npm:1.4.2"
dependencies:
Expand Down

0 comments on commit bba16b3

Please sign in to comment.