@yh-ui/flow 1.0.1 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/bpmn-engine.test.cjs +357 -0
- package/dist/__tests__/bpmn-engine.test.d.ts +1 -0
- package/dist/__tests__/bpmn-engine.test.mjs +406 -0
- package/dist/__tests__/bpmn-utils.test.cjs +268 -0
- package/dist/__tests__/bpmn-utils.test.d.ts +1 -0
- package/dist/__tests__/bpmn-utils.test.mjs +227 -0
- package/dist/__tests__/bpmn-xml.test.cjs +150 -0
- package/dist/__tests__/bpmn-xml.test.d.ts +1 -0
- package/dist/__tests__/bpmn-xml.test.mjs +112 -0
- package/dist/__tests__/collaboration.test.cjs +487 -0
- package/dist/__tests__/collaboration.test.d.ts +1 -0
- package/dist/__tests__/collaboration.test.mjs +424 -0
- package/dist/__tests__/edge-types.test.cjs +275 -0
- package/dist/__tests__/edge-types.test.d.ts +1 -0
- package/dist/__tests__/edge-types.test.mjs +234 -0
- package/dist/__tests__/edge-utils.test.cjs +375 -0
- package/dist/__tests__/edge-utils.test.d.ts +1 -0
- package/dist/__tests__/edge-utils.test.mjs +376 -0
- package/dist/__tests__/events-types.test.cjs +184 -0
- package/dist/__tests__/events-types.test.d.ts +1 -0
- package/dist/__tests__/events-types.test.mjs +184 -0
- package/dist/__tests__/export-image-plugin.test.cjs +142 -0
- package/dist/__tests__/export-image-plugin.test.d.ts +1 -0
- package/dist/__tests__/export-image-plugin.test.mjs +118 -0
- package/dist/__tests__/export.test.cjs +237 -0
- package/dist/__tests__/export.test.d.ts +1 -0
- package/dist/__tests__/export.test.mjs +171 -0
- package/dist/__tests__/flow-context.test.cjs +16 -0
- package/dist/__tests__/flow-context.test.d.ts +1 -0
- package/dist/__tests__/flow-context.test.mjs +16 -0
- package/dist/__tests__/flow-props.test.cjs +94 -0
- package/dist/__tests__/flow-props.test.d.ts +1 -0
- package/dist/__tests__/flow-props.test.mjs +92 -0
- package/dist/__tests__/layout-plugin.test.cjs +233 -0
- package/dist/__tests__/layout-plugin.test.d.ts +1 -0
- package/dist/__tests__/layout-plugin.test.mjs +215 -0
- package/dist/__tests__/node-types.test.cjs +368 -0
- package/dist/__tests__/node-types.test.d.ts +1 -0
- package/dist/__tests__/node-types.test.mjs +292 -0
- package/dist/__tests__/performance.test.cjs +313 -0
- package/dist/__tests__/performance.test.d.ts +1 -0
- package/dist/__tests__/performance.test.mjs +218 -0
- package/dist/__tests__/plugin-advanced.test.cjs +301 -0
- package/dist/__tests__/plugin-advanced.test.d.ts +1 -0
- package/dist/__tests__/plugin-advanced.test.mjs +225 -0
- package/dist/__tests__/plugins.test.cjs +412 -0
- package/dist/__tests__/plugins.test.d.ts +1 -0
- package/dist/__tests__/plugins.test.mjs +402 -0
- package/dist/__tests__/screenshot-capture.test.cjs +183 -0
- package/dist/__tests__/screenshot-capture.test.d.ts +1 -0
- package/dist/__tests__/screenshot-capture.test.mjs +124 -0
- package/dist/__tests__/screenshot.test.cjs +74 -0
- package/dist/__tests__/screenshot.test.d.ts +1 -0
- package/dist/__tests__/screenshot.test.mjs +69 -0
- package/dist/__tests__/theme.test.cjs +185 -0
- package/dist/__tests__/theme.test.d.ts +1 -0
- package/dist/__tests__/theme.test.mjs +191 -0
- package/dist/__tests__/transform.test.cjs +376 -50
- package/dist/__tests__/transform.test.mjs +229 -28
- package/dist/__tests__/useAlignment.test.cjs +37 -0
- package/dist/__tests__/useAlignment.test.mjs +20 -0
- package/dist/__tests__/useNodeDistribution.test.cjs +643 -0
- package/dist/__tests__/useNodeDistribution.test.d.ts +1 -0
- package/dist/__tests__/useNodeDistribution.test.mjs +297 -0
- package/dist/__tests__/viewport-types.test.cjs +324 -0
- package/dist/__tests__/viewport-types.test.d.ts +1 -0
- package/dist/__tests__/viewport-types.test.mjs +207 -0
- package/dist/utils/bpmn.cjs +27 -16
- package/dist/utils/bpmn.mjs +27 -19
- package/package.json +3 -3
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
+
import { captureElement } from "../utils/screenshot.mjs";
|
|
3
|
+
describe("flow/utils/screenshot - captureElement", () => {
|
|
4
|
+
let mockToPng;
|
|
5
|
+
let mockToJpeg;
|
|
6
|
+
let mockToWebp;
|
|
7
|
+
let mockFetch;
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
vi.stubGlobal(
|
|
10
|
+
"fetch",
|
|
11
|
+
mockFetch = vi.fn().mockResolvedValue(
|
|
12
|
+
new Response(new Blob(["test"], { type: "image/png" }))
|
|
13
|
+
)
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
vi.restoreAllMocks();
|
|
18
|
+
});
|
|
19
|
+
const createMockHtmlToImage = () => {
|
|
20
|
+
mockToPng = vi.fn().mockResolvedValue("data:image/png;base64,test");
|
|
21
|
+
mockToJpeg = vi.fn().mockResolvedValue("data:image/jpeg;base64,test");
|
|
22
|
+
mockToWebp = vi.fn().mockResolvedValue("data:image/webp;base64,test");
|
|
23
|
+
return { toPng: mockToPng, toJpeg: mockToJpeg, toWebp: mockToWebp };
|
|
24
|
+
};
|
|
25
|
+
const createMockElement = () => {
|
|
26
|
+
const el = document.createElement("div");
|
|
27
|
+
Object.defineProperty(el, "offsetWidth", { value: 100, configurable: true });
|
|
28
|
+
Object.defineProperty(el, "offsetHeight", { value: 200, configurable: true });
|
|
29
|
+
return el;
|
|
30
|
+
};
|
|
31
|
+
const defaultOptions = {
|
|
32
|
+
imageType: "png",
|
|
33
|
+
imageQuality: 1,
|
|
34
|
+
pixelRatio: 2,
|
|
35
|
+
backgroundColor: "#ffffff"
|
|
36
|
+
};
|
|
37
|
+
describe("png capture", () => {
|
|
38
|
+
it("should capture as png", async () => {
|
|
39
|
+
vi.doMock("html-to-image", () => createMockHtmlToImage(), { virtual: true });
|
|
40
|
+
const mod = await import("html-to-image");
|
|
41
|
+
const htmlToImage = mod.toPng ? mod : mod.default;
|
|
42
|
+
const el = createMockElement();
|
|
43
|
+
const result = await captureElement(el, { ...defaultOptions, imageType: "png" });
|
|
44
|
+
expect(result.extension).toBe("png");
|
|
45
|
+
expect(result.mimeType).toBe("image/png");
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
describe("jpeg capture", () => {
|
|
49
|
+
it("should capture as jpeg", async () => {
|
|
50
|
+
const htmlToImage = createMockHtmlToImage();
|
|
51
|
+
vi.doMock("html-to-image", () => htmlToImage, { virtual: true });
|
|
52
|
+
const el = createMockElement();
|
|
53
|
+
const result = await captureElement(el, { ...defaultOptions, imageType: "jpeg" });
|
|
54
|
+
expect(result.extension).toBe("jpeg");
|
|
55
|
+
expect(result.mimeType).toBe("image/jpeg");
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
describe("webp capture", () => {
|
|
59
|
+
it("should capture as webp when supported", async () => {
|
|
60
|
+
const htmlToImage = createMockHtmlToImage();
|
|
61
|
+
vi.doMock("html-to-image", () => htmlToImage, { virtual: true });
|
|
62
|
+
const el = createMockElement();
|
|
63
|
+
const result = await captureElement(el, { ...defaultOptions, imageType: "webp" });
|
|
64
|
+
expect(result.extension).toBe("webp");
|
|
65
|
+
expect(result.mimeType).toBe("image/webp");
|
|
66
|
+
});
|
|
67
|
+
it("should fall back to png when webp not supported", async () => {
|
|
68
|
+
const htmlToImage = {
|
|
69
|
+
toPng: vi.fn().mockResolvedValue("data:image/png;base64,test"),
|
|
70
|
+
toJpeg: vi.fn().mockResolvedValue("data:image/jpeg;base64,test"),
|
|
71
|
+
toWebp: void 0
|
|
72
|
+
};
|
|
73
|
+
vi.doMock("html-to-image", () => htmlToImage, { virtual: true });
|
|
74
|
+
const el = createMockElement();
|
|
75
|
+
const result = await captureElement(el, { ...defaultOptions, imageType: "webp" });
|
|
76
|
+
expect(result.extension).toBe("png");
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
describe("dimensions", () => {
|
|
80
|
+
it("should calculate dimensions with pixel ratio", async () => {
|
|
81
|
+
const htmlToImage = createMockHtmlToImage();
|
|
82
|
+
vi.doMock("html-to-image", () => htmlToImage, { virtual: true });
|
|
83
|
+
const el = createMockElement();
|
|
84
|
+
const result = await captureElement(el, { ...defaultOptions, pixelRatio: 3 });
|
|
85
|
+
expect(result.width).toBe(300);
|
|
86
|
+
expect(result.height).toBe(600);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
describe("image quality", () => {
|
|
90
|
+
it("should pass quality option for jpeg", async () => {
|
|
91
|
+
const htmlToImage = createMockHtmlToImage();
|
|
92
|
+
vi.doMock("html-to-image", () => htmlToImage, { virtual: true });
|
|
93
|
+
const el = createMockElement();
|
|
94
|
+
await captureElement(el, { ...defaultOptions, imageType: "jpeg", imageQuality: 0.8 });
|
|
95
|
+
expect(mockToJpeg).toHaveBeenCalledWith(el, expect.objectContaining({ quality: 0.8 }));
|
|
96
|
+
});
|
|
97
|
+
it("should pass quality option for webp", async () => {
|
|
98
|
+
const htmlToImage = createMockHtmlToImage();
|
|
99
|
+
vi.doMock("html-to-image", () => htmlToImage, { virtual: true });
|
|
100
|
+
const el = createMockElement();
|
|
101
|
+
await captureElement(el, { ...defaultOptions, imageType: "webp", imageQuality: 0.9 });
|
|
102
|
+
expect(mockToWebp).toHaveBeenCalledWith(el, expect.objectContaining({ quality: 0.9 }));
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
describe("background color", () => {
|
|
106
|
+
it("should pass background color option", async () => {
|
|
107
|
+
const htmlToImage = createMockHtmlToImage();
|
|
108
|
+
vi.doMock("html-to-image", () => htmlToImage, { virtual: true });
|
|
109
|
+
const el = createMockElement();
|
|
110
|
+
await captureElement(el, { ...defaultOptions, backgroundColor: "#ff0000" });
|
|
111
|
+
expect(mockToPng).toHaveBeenCalledWith(el, expect.objectContaining({ backgroundColor: "#ff0000" }));
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
describe("data URL to blob conversion", () => {
|
|
115
|
+
it("should convert data URL to blob", async () => {
|
|
116
|
+
const htmlToImage = createMockHtmlToImage();
|
|
117
|
+
vi.doMock("html-to-image", () => htmlToImage, { virtual: true });
|
|
118
|
+
const el = createMockElement();
|
|
119
|
+
const result = await captureElement(el, defaultOptions);
|
|
120
|
+
expect(result.blob).toBeInstanceOf(Blob);
|
|
121
|
+
expect(mockFetch).toHaveBeenCalled();
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _vitest = require("vitest");
|
|
4
|
+
var _screenshot = require("../utils/screenshot.cjs");
|
|
5
|
+
(0, _vitest.describe)("flow/utils/screenshot", () => {
|
|
6
|
+
let clickSpy;
|
|
7
|
+
(0, _vitest.beforeEach)(() => {
|
|
8
|
+
clickSpy = _vitest.vi.spyOn(HTMLAnchorElement.prototype, "click").mockImplementation(() => {});
|
|
9
|
+
});
|
|
10
|
+
(0, _vitest.afterEach)(() => {
|
|
11
|
+
clickSpy.mockRestore();
|
|
12
|
+
});
|
|
13
|
+
(0, _vitest.describe)("triggerDownload", () => {
|
|
14
|
+
(0, _vitest.it)("should create download link and click it", () => {
|
|
15
|
+
const dataUrl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==";
|
|
16
|
+
(0, _screenshot.triggerDownload)(dataUrl, "test-flow", "png");
|
|
17
|
+
(0, _vitest.expect)(clickSpy).toHaveBeenCalled();
|
|
18
|
+
});
|
|
19
|
+
(0, _vitest.it)("should set correct filename with extension", () => {
|
|
20
|
+
const dataUrl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==";
|
|
21
|
+
(0, _screenshot.triggerDownload)(dataUrl, "my-flow-chart", "jpeg");
|
|
22
|
+
(0, _vitest.expect)(clickSpy).toHaveBeenCalled();
|
|
23
|
+
});
|
|
24
|
+
(0, _vitest.it)("should handle webp extension", () => {
|
|
25
|
+
const dataUrl = "data:image/webp;base64,UklGRlYAAABXRUJQVlA4IEoAAADQAQCdASoQABAAAgA0JZQCdAEO/hAAA=";
|
|
26
|
+
(0, _screenshot.triggerDownload)(dataUrl, "webp-flow", "webp");
|
|
27
|
+
(0, _vitest.expect)(clickSpy).toHaveBeenCalled();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
(0, _vitest.describe)("copyBlobToClipboard", () => {
|
|
31
|
+
(0, _vitest.it)("should throw when clipboard API is not available", async () => {
|
|
32
|
+
const blob = new Blob(["test"], {
|
|
33
|
+
type: "image/png"
|
|
34
|
+
});
|
|
35
|
+
_vitest.vi.stubGlobal("navigator", {
|
|
36
|
+
clipboard: {
|
|
37
|
+
write: void 0
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
await (0, _vitest.expect)((0, _screenshot.copyBlobToClipboard)(blob)).rejects.toThrow("[Flow Screenshot] Clipboard API not available");
|
|
41
|
+
});
|
|
42
|
+
(0, _vitest.it)("should call clipboard write when available", async () => {
|
|
43
|
+
const blob = new Blob(["test"], {
|
|
44
|
+
type: "image/png"
|
|
45
|
+
});
|
|
46
|
+
const writeMock = _vitest.vi.fn().mockResolvedValue(void 0);
|
|
47
|
+
_vitest.vi.stubGlobal("navigator", {
|
|
48
|
+
clipboard: {
|
|
49
|
+
write: writeMock
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
await (0, _screenshot.copyBlobToClipboard)(blob);
|
|
53
|
+
(0, _vitest.expect)(writeMock).toHaveBeenCalled();
|
|
54
|
+
});
|
|
55
|
+
(0, _vitest.it)("should include correct blob type in clipboard item", async () => {
|
|
56
|
+
const blob = new Blob(["test"], {
|
|
57
|
+
type: "image/png"
|
|
58
|
+
});
|
|
59
|
+
let capturedItems = [];
|
|
60
|
+
const writeMock = _vitest.vi.fn().mockImplementation(items => {
|
|
61
|
+
capturedItems = items;
|
|
62
|
+
return Promise.resolve();
|
|
63
|
+
});
|
|
64
|
+
_vitest.vi.stubGlobal("navigator", {
|
|
65
|
+
clipboard: {
|
|
66
|
+
write: writeMock
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
await (0, _screenshot.copyBlobToClipboard)(blob);
|
|
70
|
+
(0, _vitest.expect)(writeMock).toHaveBeenCalled();
|
|
71
|
+
(0, _vitest.expect)(capturedItems.length).toBe(1);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
+
import { triggerDownload, copyBlobToClipboard } from "../utils/screenshot.mjs";
|
|
3
|
+
describe("flow/utils/screenshot", () => {
|
|
4
|
+
let clickSpy;
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
clickSpy = vi.spyOn(HTMLAnchorElement.prototype, "click").mockImplementation(() => {
|
|
7
|
+
});
|
|
8
|
+
});
|
|
9
|
+
afterEach(() => {
|
|
10
|
+
clickSpy.mockRestore();
|
|
11
|
+
});
|
|
12
|
+
describe("triggerDownload", () => {
|
|
13
|
+
it("should create download link and click it", () => {
|
|
14
|
+
const dataUrl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==";
|
|
15
|
+
triggerDownload(dataUrl, "test-flow", "png");
|
|
16
|
+
expect(clickSpy).toHaveBeenCalled();
|
|
17
|
+
});
|
|
18
|
+
it("should set correct filename with extension", () => {
|
|
19
|
+
const dataUrl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==";
|
|
20
|
+
triggerDownload(dataUrl, "my-flow-chart", "jpeg");
|
|
21
|
+
expect(clickSpy).toHaveBeenCalled();
|
|
22
|
+
});
|
|
23
|
+
it("should handle webp extension", () => {
|
|
24
|
+
const dataUrl = "data:image/webp;base64,UklGRlYAAABXRUJQVlA4IEoAAADQAQCdASoQABAAAgA0JZQCdAEO/hAAA=";
|
|
25
|
+
triggerDownload(dataUrl, "webp-flow", "webp");
|
|
26
|
+
expect(clickSpy).toHaveBeenCalled();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
describe("copyBlobToClipboard", () => {
|
|
30
|
+
it("should throw when clipboard API is not available", async () => {
|
|
31
|
+
const blob = new Blob(["test"], { type: "image/png" });
|
|
32
|
+
vi.stubGlobal("navigator", {
|
|
33
|
+
clipboard: {
|
|
34
|
+
write: void 0
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
await expect(copyBlobToClipboard(blob)).rejects.toThrow(
|
|
38
|
+
"[Flow Screenshot] Clipboard API not available"
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
it("should call clipboard write when available", async () => {
|
|
42
|
+
const blob = new Blob(["test"], { type: "image/png" });
|
|
43
|
+
const writeMock = vi.fn().mockResolvedValue(void 0);
|
|
44
|
+
vi.stubGlobal("navigator", {
|
|
45
|
+
clipboard: {
|
|
46
|
+
write: writeMock
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
await copyBlobToClipboard(blob);
|
|
50
|
+
expect(writeMock).toHaveBeenCalled();
|
|
51
|
+
});
|
|
52
|
+
it("should include correct blob type in clipboard item", async () => {
|
|
53
|
+
const blob = new Blob(["test"], { type: "image/png" });
|
|
54
|
+
let capturedItems = [];
|
|
55
|
+
const writeMock = vi.fn().mockImplementation((items) => {
|
|
56
|
+
capturedItems = items;
|
|
57
|
+
return Promise.resolve();
|
|
58
|
+
});
|
|
59
|
+
vi.stubGlobal("navigator", {
|
|
60
|
+
clipboard: {
|
|
61
|
+
write: writeMock
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
await copyBlobToClipboard(blob);
|
|
65
|
+
expect(writeMock).toHaveBeenCalled();
|
|
66
|
+
expect(capturedItems.length).toBe(1);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _vitest = require("vitest");
|
|
4
|
+
var _theme = require("../utils/theme.cjs");
|
|
5
|
+
(0, _vitest.describe)("flow/utils/theme", () => {
|
|
6
|
+
(0, _vitest.beforeEach)(() => {
|
|
7
|
+
_vitest.vi.restoreAllMocks();
|
|
8
|
+
});
|
|
9
|
+
(0, _vitest.describe)("flowTheme", () => {
|
|
10
|
+
(0, _vitest.it)("should have all required theme properties", () => {
|
|
11
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-node-background"]).toBe("#ffffff");
|
|
12
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-node-border"]).toBe("#dcdfe6");
|
|
13
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-node-border-radius"]).toBe("8px");
|
|
14
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-node-padding"]).toBe("10px");
|
|
15
|
+
});
|
|
16
|
+
(0, _vitest.it)("should have node label styles", () => {
|
|
17
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-node-label-color"]).toBe("#303133");
|
|
18
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-node-label-font-size"]).toBe("14px");
|
|
19
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-node-label-font-weight"]).toBe("500");
|
|
20
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-node-description-color"]).toBe("#909399");
|
|
21
|
+
});
|
|
22
|
+
(0, _vitest.it)("should have handle styles", () => {
|
|
23
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-handle-background"]).toBe("#ffffff");
|
|
24
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-handle-border"]).toBe("#409eff");
|
|
25
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-handle-size"]).toBe("12px");
|
|
26
|
+
});
|
|
27
|
+
(0, _vitest.it)("should have edge styles", () => {
|
|
28
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-edge-stroke"]).toBe("#b1b3b8");
|
|
29
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-edge-stroke-width"]).toBe("2");
|
|
30
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-edge-selected-stroke"]).toBe("#409eff");
|
|
31
|
+
});
|
|
32
|
+
(0, _vitest.it)("should have BPMN styles", () => {
|
|
33
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-bpmn-start-fill"]).toBe("#e6f7ed");
|
|
34
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-bpmn-start-stroke"]).toBe("#67c23a");
|
|
35
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-bpmn-end-fill"]).toBe("#fef0f0");
|
|
36
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-bpmn-end-stroke"]).toBe("#f56c6c");
|
|
37
|
+
});
|
|
38
|
+
(0, _vitest.it)("should have AI node styles", () => {
|
|
39
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-ai-node-background"]).toBe("#f0f9ff");
|
|
40
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-ai-node-border"]).toBe("#0ea5e9");
|
|
41
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-ai-node-accent"]).toBe("#0284c7");
|
|
42
|
+
});
|
|
43
|
+
(0, _vitest.it)("should have background styles", () => {
|
|
44
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-background-color"]).toBe("#fafafa");
|
|
45
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-grid-color"]).toBe("#e4e7ed");
|
|
46
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-grid-size"]).toBe("20");
|
|
47
|
+
});
|
|
48
|
+
(0, _vitest.it)("should have alignment line styles", () => {
|
|
49
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-alignment-line-color"]).toBe("#c0c4cc");
|
|
50
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-alignment-line-active-color"]).toBe("#409eff");
|
|
51
|
+
});
|
|
52
|
+
(0, _vitest.it)("should have selection box styles", () => {
|
|
53
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-selection-box-border"]).toBe("#409eff");
|
|
54
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-selection-box-background"]).toBe("rgba(64, 158, 255, 0.1)");
|
|
55
|
+
});
|
|
56
|
+
(0, _vitest.it)("should have control button styles", () => {
|
|
57
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-control-background"]).toBe("#ffffff");
|
|
58
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-control-border"]).toBe("#dcdfe6");
|
|
59
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-control-icon-color"]).toBe("#606266");
|
|
60
|
+
});
|
|
61
|
+
(0, _vitest.it)("should have minimap styles", () => {
|
|
62
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-minimap-background"]).toBe("#f5f7fa");
|
|
63
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-minimap-mask-background"]).toBe("rgba(255, 255, 255, 0.8)");
|
|
64
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-minimap-node-color"]).toBe("#c0c4cc");
|
|
65
|
+
});
|
|
66
|
+
(0, _vitest.it)("should have panel styles", () => {
|
|
67
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-panel-background"]).toBe("#ffffff");
|
|
68
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-panel-border"]).toBe("#e4e7ed");
|
|
69
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-panel-shadow"]).toBe("0 4px 12px rgba(0, 0, 0, 0.15)");
|
|
70
|
+
});
|
|
71
|
+
(0, _vitest.it)("should have toolbar styles", () => {
|
|
72
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-toolbar-background"]).toBe("#ffffff");
|
|
73
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-toolbar-border"]).toBe("#e4e7ed");
|
|
74
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-toolbar-icon-color"]).toBe("#606266");
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
(0, _vitest.describe)("flowThemeDark", () => {
|
|
78
|
+
(0, _vitest.it)("should have dark mode colors", () => {
|
|
79
|
+
(0, _vitest.expect)(_theme.flowThemeDark["flow-node-background"]).toBe("#1f1f1f");
|
|
80
|
+
(0, _vitest.expect)(_theme.flowThemeDark["flow-node-border"]).toBe("#3a3a3a");
|
|
81
|
+
(0, _vitest.expect)(_theme.flowThemeDark["flow-node-label-color"]).toBe("#e5e5e5");
|
|
82
|
+
});
|
|
83
|
+
(0, _vitest.it)("should have dark mode handle colors", () => {
|
|
84
|
+
(0, _vitest.expect)(_theme.flowThemeDark["flow-handle-background"]).toBe("#262626");
|
|
85
|
+
});
|
|
86
|
+
(0, _vitest.it)("should have dark mode edge colors", () => {
|
|
87
|
+
(0, _vitest.expect)(_theme.flowThemeDark["flow-edge-stroke"]).toBe("#5c5c5c");
|
|
88
|
+
});
|
|
89
|
+
(0, _vitest.it)("should have dark mode background", () => {
|
|
90
|
+
(0, _vitest.expect)(_theme.flowThemeDark["flow-background-color"]).toBe("#141414");
|
|
91
|
+
(0, _vitest.expect)(_theme.flowThemeDark["flow-grid-color"]).toBe("#2a2a2a");
|
|
92
|
+
});
|
|
93
|
+
(0, _vitest.it)("should have dark mode minimap colors", () => {
|
|
94
|
+
(0, _vitest.expect)(_theme.flowThemeDark["flow-minimap-background"]).toBe("#1a1a1a");
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
(0, _vitest.describe)("createCustomTheme", () => {
|
|
98
|
+
(0, _vitest.it)("should create theme with overrides", () => {
|
|
99
|
+
const customTheme = (0, _theme.createCustomTheme)({
|
|
100
|
+
"flow-node-background": "#ff0000",
|
|
101
|
+
"flow-node-border": "#00ff00"
|
|
102
|
+
});
|
|
103
|
+
(0, _vitest.expect)(customTheme["flow-node-background"]).toBe("#ff0000");
|
|
104
|
+
(0, _vitest.expect)(customTheme["flow-node-border"]).toBe("#00ff00");
|
|
105
|
+
(0, _vitest.expect)(customTheme["flow-node-label-color"]).toBe(_theme.flowTheme["flow-node-label-color"]);
|
|
106
|
+
});
|
|
107
|
+
(0, _vitest.it)("should merge with base theme", () => {
|
|
108
|
+
const customTheme = (0, _theme.createCustomTheme)({});
|
|
109
|
+
(0, _vitest.expect)(customTheme["flow-node-background"]).toBe(_theme.flowTheme["flow-node-background"]);
|
|
110
|
+
});
|
|
111
|
+
(0, _vitest.it)("should allow multiple overrides", () => {
|
|
112
|
+
const customTheme = (0, _theme.createCustomTheme)({
|
|
113
|
+
"flow-edge-stroke": "#ff00ff",
|
|
114
|
+
"flow-background-color": "#0000ff",
|
|
115
|
+
"flow-grid-size": "25"
|
|
116
|
+
});
|
|
117
|
+
(0, _vitest.expect)(customTheme["flow-edge-stroke"]).toBe("#ff00ff");
|
|
118
|
+
(0, _vitest.expect)(customTheme["flow-background-color"]).toBe("#0000ff");
|
|
119
|
+
(0, _vitest.expect)(customTheme["flow-grid-size"]).toBe("25");
|
|
120
|
+
});
|
|
121
|
+
(0, _vitest.it)("should not mutate original theme", () => {
|
|
122
|
+
const originalBg = _theme.flowTheme["flow-node-background"];
|
|
123
|
+
(0, _theme.createCustomTheme)({
|
|
124
|
+
"flow-node-background": "#ff0000"
|
|
125
|
+
});
|
|
126
|
+
(0, _vitest.expect)(_theme.flowTheme["flow-node-background"]).toBe(originalBg);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
(0, _vitest.describe)("applyFlowTheme", () => {
|
|
130
|
+
(0, _vitest.it)("should apply theme to HTMLElement", () => {
|
|
131
|
+
const setPropertyMock = _vitest.vi.fn();
|
|
132
|
+
const mockElement = {
|
|
133
|
+
style: {
|
|
134
|
+
setProperty: setPropertyMock
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
(0, _theme.applyFlowTheme)(_theme.flowTheme, mockElement);
|
|
138
|
+
(0, _vitest.expect)(setPropertyMock).toHaveBeenCalled();
|
|
139
|
+
(0, _vitest.expect)(setPropertyMock).toHaveBeenCalledWith("--flow-node-background", "#ffffff");
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
(0, _vitest.describe)("flowThemePresets", () => {
|
|
143
|
+
(0, _vitest.it)("should have default preset", () => {
|
|
144
|
+
(0, _vitest.expect)(_theme.flowThemePresets.default).toBe(_theme.flowTheme);
|
|
145
|
+
});
|
|
146
|
+
(0, _vitest.it)("should have dark preset", () => {
|
|
147
|
+
(0, _vitest.expect)(_theme.flowThemePresets.dark).toBe(_theme.flowThemeDark);
|
|
148
|
+
});
|
|
149
|
+
(0, _vitest.it)("should have blue preset with custom colors", () => {
|
|
150
|
+
(0, _vitest.expect)(_theme.flowThemePresets.blue["flow-node-background"]).toBe("#e6f7ff");
|
|
151
|
+
(0, _vitest.expect)(_theme.flowThemePresets.blue["flow-node-border"]).toBe("#91d5ff");
|
|
152
|
+
(0, _vitest.expect)(_theme.flowThemePresets.blue["flow-node-selected-border"]).toBe("#1890ff");
|
|
153
|
+
});
|
|
154
|
+
(0, _vitest.it)("should have green preset with custom colors", () => {
|
|
155
|
+
(0, _vitest.expect)(_theme.flowThemePresets.green["flow-node-background"]).toBe("#f6ffed");
|
|
156
|
+
(0, _vitest.expect)(_theme.flowThemePresets.green["flow-node-border"]).toBe("#b7eb8f");
|
|
157
|
+
(0, _vitest.expect)(_theme.flowThemePresets.green["flow-node-selected-border"]).toBe("#52c41a");
|
|
158
|
+
});
|
|
159
|
+
(0, _vitest.it)("should have purple preset with custom colors", () => {
|
|
160
|
+
(0, _vitest.expect)(_theme.flowThemePresets.purple["flow-node-background"]).toBe("#f9f0ff");
|
|
161
|
+
(0, _vitest.expect)(_theme.flowThemePresets.purple["flow-node-border"]).toBe("#d3adf7");
|
|
162
|
+
(0, _vitest.expect)(_theme.flowThemePresets.purple["flow-node-selected-border"]).toBe("#722ed1");
|
|
163
|
+
});
|
|
164
|
+
(0, _vitest.it)("should inherit base theme values in presets", () => {
|
|
165
|
+
(0, _vitest.expect)(_theme.flowThemePresets.blue["flow-node-label-color"]).toBe(_theme.flowTheme["flow-node-label-color"]);
|
|
166
|
+
(0, _vitest.expect)(_theme.flowThemePresets.green["flow-node-label-color"]).toBe(_theme.flowTheme["flow-node-label-color"]);
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
(0, _vitest.describe)("Theme consistency", () => {
|
|
170
|
+
(0, _vitest.it)("light and dark themes should have same keys", () => {
|
|
171
|
+
const lightKeys = Object.keys(_theme.flowTheme).sort();
|
|
172
|
+
const darkKeys = Object.keys(_theme.flowThemeDark).sort();
|
|
173
|
+
(0, _vitest.expect)(lightKeys).toEqual(darkKeys);
|
|
174
|
+
});
|
|
175
|
+
(0, _vitest.it)("all presets should have same keys as base theme", () => {
|
|
176
|
+
const baseKeys = Object.keys(_theme.flowTheme);
|
|
177
|
+
Object.values(_theme.flowThemePresets).forEach(preset => {
|
|
178
|
+
const presetKeys = Object.keys(preset);
|
|
179
|
+
baseKeys.forEach(key => {
|
|
180
|
+
(0, _vitest.expect)(presetKeys).toContain(key);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
flowTheme,
|
|
4
|
+
flowThemeDark,
|
|
5
|
+
createCustomTheme,
|
|
6
|
+
applyFlowTheme,
|
|
7
|
+
flowThemePresets
|
|
8
|
+
} from "../utils/theme.mjs";
|
|
9
|
+
describe("flow/utils/theme", () => {
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
vi.restoreAllMocks();
|
|
12
|
+
});
|
|
13
|
+
describe("flowTheme", () => {
|
|
14
|
+
it("should have all required theme properties", () => {
|
|
15
|
+
expect(flowTheme["flow-node-background"]).toBe("#ffffff");
|
|
16
|
+
expect(flowTheme["flow-node-border"]).toBe("#dcdfe6");
|
|
17
|
+
expect(flowTheme["flow-node-border-radius"]).toBe("8px");
|
|
18
|
+
expect(flowTheme["flow-node-padding"]).toBe("10px");
|
|
19
|
+
});
|
|
20
|
+
it("should have node label styles", () => {
|
|
21
|
+
expect(flowTheme["flow-node-label-color"]).toBe("#303133");
|
|
22
|
+
expect(flowTheme["flow-node-label-font-size"]).toBe("14px");
|
|
23
|
+
expect(flowTheme["flow-node-label-font-weight"]).toBe("500");
|
|
24
|
+
expect(flowTheme["flow-node-description-color"]).toBe("#909399");
|
|
25
|
+
});
|
|
26
|
+
it("should have handle styles", () => {
|
|
27
|
+
expect(flowTheme["flow-handle-background"]).toBe("#ffffff");
|
|
28
|
+
expect(flowTheme["flow-handle-border"]).toBe("#409eff");
|
|
29
|
+
expect(flowTheme["flow-handle-size"]).toBe("12px");
|
|
30
|
+
});
|
|
31
|
+
it("should have edge styles", () => {
|
|
32
|
+
expect(flowTheme["flow-edge-stroke"]).toBe("#b1b3b8");
|
|
33
|
+
expect(flowTheme["flow-edge-stroke-width"]).toBe("2");
|
|
34
|
+
expect(flowTheme["flow-edge-selected-stroke"]).toBe("#409eff");
|
|
35
|
+
});
|
|
36
|
+
it("should have BPMN styles", () => {
|
|
37
|
+
expect(flowTheme["flow-bpmn-start-fill"]).toBe("#e6f7ed");
|
|
38
|
+
expect(flowTheme["flow-bpmn-start-stroke"]).toBe("#67c23a");
|
|
39
|
+
expect(flowTheme["flow-bpmn-end-fill"]).toBe("#fef0f0");
|
|
40
|
+
expect(flowTheme["flow-bpmn-end-stroke"]).toBe("#f56c6c");
|
|
41
|
+
});
|
|
42
|
+
it("should have AI node styles", () => {
|
|
43
|
+
expect(flowTheme["flow-ai-node-background"]).toBe("#f0f9ff");
|
|
44
|
+
expect(flowTheme["flow-ai-node-border"]).toBe("#0ea5e9");
|
|
45
|
+
expect(flowTheme["flow-ai-node-accent"]).toBe("#0284c7");
|
|
46
|
+
});
|
|
47
|
+
it("should have background styles", () => {
|
|
48
|
+
expect(flowTheme["flow-background-color"]).toBe("#fafafa");
|
|
49
|
+
expect(flowTheme["flow-grid-color"]).toBe("#e4e7ed");
|
|
50
|
+
expect(flowTheme["flow-grid-size"]).toBe("20");
|
|
51
|
+
});
|
|
52
|
+
it("should have alignment line styles", () => {
|
|
53
|
+
expect(flowTheme["flow-alignment-line-color"]).toBe("#c0c4cc");
|
|
54
|
+
expect(flowTheme["flow-alignment-line-active-color"]).toBe("#409eff");
|
|
55
|
+
});
|
|
56
|
+
it("should have selection box styles", () => {
|
|
57
|
+
expect(flowTheme["flow-selection-box-border"]).toBe("#409eff");
|
|
58
|
+
expect(flowTheme["flow-selection-box-background"]).toBe("rgba(64, 158, 255, 0.1)");
|
|
59
|
+
});
|
|
60
|
+
it("should have control button styles", () => {
|
|
61
|
+
expect(flowTheme["flow-control-background"]).toBe("#ffffff");
|
|
62
|
+
expect(flowTheme["flow-control-border"]).toBe("#dcdfe6");
|
|
63
|
+
expect(flowTheme["flow-control-icon-color"]).toBe("#606266");
|
|
64
|
+
});
|
|
65
|
+
it("should have minimap styles", () => {
|
|
66
|
+
expect(flowTheme["flow-minimap-background"]).toBe("#f5f7fa");
|
|
67
|
+
expect(flowTheme["flow-minimap-mask-background"]).toBe("rgba(255, 255, 255, 0.8)");
|
|
68
|
+
expect(flowTheme["flow-minimap-node-color"]).toBe("#c0c4cc");
|
|
69
|
+
});
|
|
70
|
+
it("should have panel styles", () => {
|
|
71
|
+
expect(flowTheme["flow-panel-background"]).toBe("#ffffff");
|
|
72
|
+
expect(flowTheme["flow-panel-border"]).toBe("#e4e7ed");
|
|
73
|
+
expect(flowTheme["flow-panel-shadow"]).toBe("0 4px 12px rgba(0, 0, 0, 0.15)");
|
|
74
|
+
});
|
|
75
|
+
it("should have toolbar styles", () => {
|
|
76
|
+
expect(flowTheme["flow-toolbar-background"]).toBe("#ffffff");
|
|
77
|
+
expect(flowTheme["flow-toolbar-border"]).toBe("#e4e7ed");
|
|
78
|
+
expect(flowTheme["flow-toolbar-icon-color"]).toBe("#606266");
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
describe("flowThemeDark", () => {
|
|
82
|
+
it("should have dark mode colors", () => {
|
|
83
|
+
expect(flowThemeDark["flow-node-background"]).toBe("#1f1f1f");
|
|
84
|
+
expect(flowThemeDark["flow-node-border"]).toBe("#3a3a3a");
|
|
85
|
+
expect(flowThemeDark["flow-node-label-color"]).toBe("#e5e5e5");
|
|
86
|
+
});
|
|
87
|
+
it("should have dark mode handle colors", () => {
|
|
88
|
+
expect(flowThemeDark["flow-handle-background"]).toBe("#262626");
|
|
89
|
+
});
|
|
90
|
+
it("should have dark mode edge colors", () => {
|
|
91
|
+
expect(flowThemeDark["flow-edge-stroke"]).toBe("#5c5c5c");
|
|
92
|
+
});
|
|
93
|
+
it("should have dark mode background", () => {
|
|
94
|
+
expect(flowThemeDark["flow-background-color"]).toBe("#141414");
|
|
95
|
+
expect(flowThemeDark["flow-grid-color"]).toBe("#2a2a2a");
|
|
96
|
+
});
|
|
97
|
+
it("should have dark mode minimap colors", () => {
|
|
98
|
+
expect(flowThemeDark["flow-minimap-background"]).toBe("#1a1a1a");
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
describe("createCustomTheme", () => {
|
|
102
|
+
it("should create theme with overrides", () => {
|
|
103
|
+
const customTheme = createCustomTheme({
|
|
104
|
+
"flow-node-background": "#ff0000",
|
|
105
|
+
"flow-node-border": "#00ff00"
|
|
106
|
+
});
|
|
107
|
+
expect(customTheme["flow-node-background"]).toBe("#ff0000");
|
|
108
|
+
expect(customTheme["flow-node-border"]).toBe("#00ff00");
|
|
109
|
+
expect(customTheme["flow-node-label-color"]).toBe(flowTheme["flow-node-label-color"]);
|
|
110
|
+
});
|
|
111
|
+
it("should merge with base theme", () => {
|
|
112
|
+
const customTheme = createCustomTheme({});
|
|
113
|
+
expect(customTheme["flow-node-background"]).toBe(flowTheme["flow-node-background"]);
|
|
114
|
+
});
|
|
115
|
+
it("should allow multiple overrides", () => {
|
|
116
|
+
const customTheme = createCustomTheme({
|
|
117
|
+
"flow-edge-stroke": "#ff00ff",
|
|
118
|
+
"flow-background-color": "#0000ff",
|
|
119
|
+
"flow-grid-size": "25"
|
|
120
|
+
});
|
|
121
|
+
expect(customTheme["flow-edge-stroke"]).toBe("#ff00ff");
|
|
122
|
+
expect(customTheme["flow-background-color"]).toBe("#0000ff");
|
|
123
|
+
expect(customTheme["flow-grid-size"]).toBe("25");
|
|
124
|
+
});
|
|
125
|
+
it("should not mutate original theme", () => {
|
|
126
|
+
const originalBg = flowTheme["flow-node-background"];
|
|
127
|
+
createCustomTheme({ "flow-node-background": "#ff0000" });
|
|
128
|
+
expect(flowTheme["flow-node-background"]).toBe(originalBg);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
describe("applyFlowTheme", () => {
|
|
132
|
+
it("should apply theme to HTMLElement", () => {
|
|
133
|
+
const setPropertyMock = vi.fn();
|
|
134
|
+
const mockElement = {
|
|
135
|
+
style: {
|
|
136
|
+
setProperty: setPropertyMock
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
applyFlowTheme(flowTheme, mockElement);
|
|
140
|
+
expect(setPropertyMock).toHaveBeenCalled();
|
|
141
|
+
expect(setPropertyMock).toHaveBeenCalledWith("--flow-node-background", "#ffffff");
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
describe("flowThemePresets", () => {
|
|
145
|
+
it("should have default preset", () => {
|
|
146
|
+
expect(flowThemePresets.default).toBe(flowTheme);
|
|
147
|
+
});
|
|
148
|
+
it("should have dark preset", () => {
|
|
149
|
+
expect(flowThemePresets.dark).toBe(flowThemeDark);
|
|
150
|
+
});
|
|
151
|
+
it("should have blue preset with custom colors", () => {
|
|
152
|
+
expect(flowThemePresets.blue["flow-node-background"]).toBe("#e6f7ff");
|
|
153
|
+
expect(flowThemePresets.blue["flow-node-border"]).toBe("#91d5ff");
|
|
154
|
+
expect(flowThemePresets.blue["flow-node-selected-border"]).toBe("#1890ff");
|
|
155
|
+
});
|
|
156
|
+
it("should have green preset with custom colors", () => {
|
|
157
|
+
expect(flowThemePresets.green["flow-node-background"]).toBe("#f6ffed");
|
|
158
|
+
expect(flowThemePresets.green["flow-node-border"]).toBe("#b7eb8f");
|
|
159
|
+
expect(flowThemePresets.green["flow-node-selected-border"]).toBe("#52c41a");
|
|
160
|
+
});
|
|
161
|
+
it("should have purple preset with custom colors", () => {
|
|
162
|
+
expect(flowThemePresets.purple["flow-node-background"]).toBe("#f9f0ff");
|
|
163
|
+
expect(flowThemePresets.purple["flow-node-border"]).toBe("#d3adf7");
|
|
164
|
+
expect(flowThemePresets.purple["flow-node-selected-border"]).toBe("#722ed1");
|
|
165
|
+
});
|
|
166
|
+
it("should inherit base theme values in presets", () => {
|
|
167
|
+
expect(flowThemePresets.blue["flow-node-label-color"]).toBe(
|
|
168
|
+
flowTheme["flow-node-label-color"]
|
|
169
|
+
);
|
|
170
|
+
expect(flowThemePresets.green["flow-node-label-color"]).toBe(
|
|
171
|
+
flowTheme["flow-node-label-color"]
|
|
172
|
+
);
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
describe("Theme consistency", () => {
|
|
176
|
+
it("light and dark themes should have same keys", () => {
|
|
177
|
+
const lightKeys = Object.keys(flowTheme).sort();
|
|
178
|
+
const darkKeys = Object.keys(flowThemeDark).sort();
|
|
179
|
+
expect(lightKeys).toEqual(darkKeys);
|
|
180
|
+
});
|
|
181
|
+
it("all presets should have same keys as base theme", () => {
|
|
182
|
+
const baseKeys = Object.keys(flowTheme);
|
|
183
|
+
Object.values(flowThemePresets).forEach((preset) => {
|
|
184
|
+
const presetKeys = Object.keys(preset);
|
|
185
|
+
baseKeys.forEach((key) => {
|
|
186
|
+
expect(presetKeys).toContain(key);
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
});
|