mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49:41 +02:00
feat(editor): provide yaml validation for docker compose in the portainer web editor [BE-11697] (#526)
This commit is contained in:
parent
0ebfe047d1
commit
81c5f4acc3
27 changed files with 2046 additions and 36 deletions
42
app/setup-tests/setup-codemirror.ts
Normal file
42
app/setup-tests/setup-codemirror.ts
Normal file
|
@ -0,0 +1,42 @@
|
|||
import 'vitest-dom/extend-expect';
|
||||
|
||||
// Mock Range APIs that CodeMirror needs but JSDOM doesn't provide
|
||||
Range.prototype.getBoundingClientRect = () => ({
|
||||
bottom: 0,
|
||||
height: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
width: 0,
|
||||
x: 0,
|
||||
y: 0,
|
||||
toJSON: vi.fn(),
|
||||
});
|
||||
|
||||
Range.prototype.getClientRects = () => ({
|
||||
item: () => null,
|
||||
length: 0,
|
||||
[Symbol.iterator]: vi.fn(),
|
||||
});
|
||||
|
||||
// Mock createRange
|
||||
document.createRange = () => {
|
||||
const range = new Range();
|
||||
range.getBoundingClientRect = vi.fn();
|
||||
range.getClientRects = () => ({
|
||||
item: () => null,
|
||||
length: 0,
|
||||
[Symbol.iterator]: vi.fn(),
|
||||
});
|
||||
return range;
|
||||
};
|
||||
|
||||
// Mock selection APIs
|
||||
const mockSelection = {
|
||||
rangeCount: 0,
|
||||
addRange: vi.fn(),
|
||||
getRangeAt: vi.fn(),
|
||||
removeAllRanges: vi.fn(),
|
||||
};
|
||||
|
||||
window.getSelection = () => mockSelection as unknown as Selection;
|
Loading…
Add table
Add a link
Reference in a new issue