@syntrologie/adapt-content 2.1.0 → 2.2.0-canary.10
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/cdn.d.ts +1 -1
- package/dist/components/AnchorPicker.d.ts +5 -20
- package/dist/components/AnchorPicker.d.ts.map +1 -1
- package/dist/components/AnchorPicker.js +4 -181
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +51 -27
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/schema.d.ts +28 -28
- package/dist/types.d.ts +5 -15
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/selectorGenerator.d.ts +3 -19
- package/dist/utils/selectorGenerator.d.ts.map +1 -1
- package/dist/utils/selectorGenerator.js +2 -119
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/BeforeAfterToggle.test.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/BeforeAfterToggle.test.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/BeforeAfterToggle.test.js +28 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/DetectionBadge.test.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/DetectionBadge.test.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/DetectionBadge.test.js +18 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/DismissedSection.test.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/DismissedSection.test.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/DismissedSection.test.js +22 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditBackButton.test.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditBackButton.test.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditBackButton.test.js +20 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorBody.test.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorBody.test.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorBody.test.js +12 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorCard.test.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorCard.test.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorCard.test.js +25 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorFooter.test.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorFooter.test.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorFooter.test.js +23 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorHeader.test.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorHeader.test.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorHeader.test.js +24 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorInput.test.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorInput.test.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorInput.test.js +26 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorLayout.test.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorLayout.test.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorLayout.test.js +13 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorSelect.test.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorSelect.test.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorSelect.test.js +22 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorTextarea.test.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorTextarea.test.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EditorTextarea.test.js +20 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/ElementHighlight.test.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/ElementHighlight.test.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/ElementHighlight.test.js +100 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EmptyState.test.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EmptyState.test.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/EmptyState.test.js +10 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/GroupHeader.test.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/GroupHeader.test.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/GroupHeader.test.js +14 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/TriggerJourney.test.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/TriggerJourney.test.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/TriggerJourney.test.js +126 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/cn.test.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/cn.test.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/cn.test.js +16 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/formatConditionLabel.test.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/formatConditionLabel.test.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/formatConditionLabel.test.js +329 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/useElementRect.test.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/useElementRect.test.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/useElementRect.test.js +112 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/cn.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/cn.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/cn.js +3 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPicker.d.ts +31 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPicker.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPicker.js +152 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggle.d.ts +7 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggle.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggle.js +9 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLine.d.ts +23 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLine.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLine.js +40 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadge.d.ts +6 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadge.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadge.js +5 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSection.d.ts +8 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSection.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSection.js +9 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButton.d.ts +7 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButton.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButton.js +4 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBody.d.ts +7 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBody.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBody.js +4 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCard.d.ts +13 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCard.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCard.js +6 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooter.d.ts +7 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooter.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooter.js +4 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeader.d.ts +9 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeader.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeader.js +4 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInput.d.ts +8 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInput.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInput.js +5 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayout.d.ts +7 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayout.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayout.js +4 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShell.d.ts +23 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShell.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShell.js +116 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelect.d.ts +8 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelect.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelect.js +5 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextarea.d.ts +8 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextarea.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextarea.js +15 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlight.d.ts +32 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlight.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlight.js +75 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyState.d.ts +6 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyState.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyState.js +4 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeader.d.ts +8 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeader.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeader.js +5 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourney.d.ts +12 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourney.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourney.js +40 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/formatConditionLabel.d.ts +26 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/formatConditionLabel.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/formatConditionLabel.js +207 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useElementRect.d.ts +8 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useElementRect.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useElementRect.js +46 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useShowWhenStatus.d.ts +24 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useShowWhenStatus.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useShowWhenStatus.js +215 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/index.d.ts +33 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/index.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/index.js +24 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/utils/selectorGenerator.d.ts +22 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/utils/selectorGenerator.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/utils/selectorGenerator.js +143 -0
- package/node_modules/@syntrologie/shared-editor-ui/package.json +45 -0
- package/package.json +17 -12
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
3
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
|
+
import { ElementHighlight } from '../components/ElementHighlight';
|
|
5
|
+
// Mock ResizeObserver for jsdom
|
|
6
|
+
class MockResizeObserver {
|
|
7
|
+
observe() { }
|
|
8
|
+
unobserve() { }
|
|
9
|
+
disconnect() { }
|
|
10
|
+
}
|
|
11
|
+
vi.stubGlobal('ResizeObserver', MockResizeObserver);
|
|
12
|
+
vi.stubGlobal('requestAnimationFrame', (cb) => {
|
|
13
|
+
cb(0);
|
|
14
|
+
return 0;
|
|
15
|
+
});
|
|
16
|
+
vi.stubGlobal('cancelAnimationFrame', () => { });
|
|
17
|
+
describe('ElementHighlight', () => {
|
|
18
|
+
let mockElement;
|
|
19
|
+
let mockRect;
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
mockRect = {
|
|
22
|
+
top: 100,
|
|
23
|
+
left: 200,
|
|
24
|
+
width: 300,
|
|
25
|
+
height: 150,
|
|
26
|
+
bottom: 250,
|
|
27
|
+
right: 500,
|
|
28
|
+
x: 200,
|
|
29
|
+
y: 100,
|
|
30
|
+
toJSON: () => ({}),
|
|
31
|
+
};
|
|
32
|
+
mockElement = document.createElement('div');
|
|
33
|
+
vi.spyOn(mockElement, 'getBoundingClientRect').mockReturnValue(mockRect);
|
|
34
|
+
});
|
|
35
|
+
it('renders portal to document.body', () => {
|
|
36
|
+
render(_jsx(ElementHighlight, { element: mockElement, color: "#3b82f6" }));
|
|
37
|
+
// The highlight is portaled to document.body — check body has the overlay
|
|
38
|
+
const overlay = document.body.querySelector('[data-syntro-highlight]');
|
|
39
|
+
expect(overlay).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
it('positions at element bounding rect', () => {
|
|
42
|
+
render(_jsx(ElementHighlight, { element: mockElement, color: "#3b82f6", padding: 2 }));
|
|
43
|
+
const overlay = document.body.querySelector('[data-syntro-highlight]');
|
|
44
|
+
expect(overlay).toBeTruthy();
|
|
45
|
+
// Fixed positioning with padding
|
|
46
|
+
expect(overlay.style.top).toBe('98px'); // 100 - 2
|
|
47
|
+
expect(overlay.style.left).toBe('198px'); // 200 - 2
|
|
48
|
+
expect(overlay.style.width).toBe('304px'); // 300 + 2*2
|
|
49
|
+
expect(overlay.style.height).toBe('154px'); // 150 + 2*2
|
|
50
|
+
});
|
|
51
|
+
it('shows label text and icon', () => {
|
|
52
|
+
const icon = _jsx("span", { "data-testid": "icon", children: "I" });
|
|
53
|
+
render(_jsx(ElementHighlight, { element: mockElement, color: "#ef4444", label: "Sensitive", labelIcon: icon }));
|
|
54
|
+
const label = document.body.querySelector('[data-syntro-highlight-label]');
|
|
55
|
+
expect(label).toBeTruthy();
|
|
56
|
+
expect(label.textContent).toContain('Sensitive');
|
|
57
|
+
expect(document.body.querySelector('[data-testid="icon"]')).toBeTruthy();
|
|
58
|
+
});
|
|
59
|
+
it('shows remove button when showRemove is true', () => {
|
|
60
|
+
const onRemove = vi.fn();
|
|
61
|
+
render(_jsx(ElementHighlight, { element: mockElement, color: "#ef4444", label: "Test", showRemove: true, onRemove: onRemove }));
|
|
62
|
+
const removeBtn = document.body.querySelector('[data-syntro-highlight-remove]');
|
|
63
|
+
expect(removeBtn).toBeTruthy();
|
|
64
|
+
});
|
|
65
|
+
it('calls onClick when clicked', () => {
|
|
66
|
+
const onClick = vi.fn();
|
|
67
|
+
render(_jsx(ElementHighlight, { element: mockElement, color: "#3b82f6", onClick: onClick }));
|
|
68
|
+
const overlay = document.body.querySelector('[data-syntro-highlight]');
|
|
69
|
+
fireEvent.click(overlay);
|
|
70
|
+
expect(onClick).toHaveBeenCalledTimes(1);
|
|
71
|
+
});
|
|
72
|
+
it('calls onRemove when remove button is clicked', () => {
|
|
73
|
+
const onRemove = vi.fn();
|
|
74
|
+
const onClick = vi.fn();
|
|
75
|
+
render(_jsx(ElementHighlight, { element: mockElement, color: "#ef4444", label: "Test", showRemove: true, onRemove: onRemove, onClick: onClick }));
|
|
76
|
+
const removeBtn = document.body.querySelector('[data-syntro-highlight-remove]');
|
|
77
|
+
fireEvent.click(removeBtn);
|
|
78
|
+
expect(onRemove).toHaveBeenCalledTimes(1);
|
|
79
|
+
// onClick should not fire when clicking remove
|
|
80
|
+
expect(onClick).not.toHaveBeenCalled();
|
|
81
|
+
});
|
|
82
|
+
it('shows dimensions when showDimensions is true', () => {
|
|
83
|
+
mockElement = document.createElement('section');
|
|
84
|
+
mockElement.id = 'hero';
|
|
85
|
+
vi.spyOn(mockElement, 'getBoundingClientRect').mockReturnValue(mockRect);
|
|
86
|
+
render(_jsx(ElementHighlight, { element: mockElement, color: "rgba(99,102,241,0.6)", showDimensions: true }));
|
|
87
|
+
const label = document.body.querySelector('[data-syntro-highlight-label]');
|
|
88
|
+
expect(label).toBeTruthy();
|
|
89
|
+
// Should contain tag name and dimensions
|
|
90
|
+
expect(label.textContent).toContain('section');
|
|
91
|
+
expect(label.textContent).toContain('#hero');
|
|
92
|
+
expect(label.textContent).toContain('300');
|
|
93
|
+
expect(label.textContent).toContain('150');
|
|
94
|
+
});
|
|
95
|
+
it('does not show remove button when showRemove is false', () => {
|
|
96
|
+
render(_jsx(ElementHighlight, { element: mockElement, color: "#3b82f6", label: "Test" }));
|
|
97
|
+
const removeBtn = document.body.querySelector('[data-syntro-highlight-remove]');
|
|
98
|
+
expect(removeBtn).toBeNull();
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmptyState.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/EmptyState.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { EmptyState } from '../components/EmptyState';
|
|
5
|
+
describe('EmptyState', () => {
|
|
6
|
+
it('renders the message text', () => {
|
|
7
|
+
const { getByText } = render(_jsx(EmptyState, { message: "No items found" }));
|
|
8
|
+
expect(getByText('No items found')).toBeTruthy();
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GroupHeader.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/GroupHeader.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { GroupHeader } from '../components/GroupHeader';
|
|
5
|
+
describe('GroupHeader', () => {
|
|
6
|
+
it('renders the label', () => {
|
|
7
|
+
const { getByText } = render(_jsx(GroupHeader, { label: "Active", count: 5 }));
|
|
8
|
+
expect(getByText('Active')).toBeTruthy();
|
|
9
|
+
});
|
|
10
|
+
it('renders the count badge', () => {
|
|
11
|
+
const { getByText } = render(_jsx(GroupHeader, { label: "Items", count: 12 }));
|
|
12
|
+
expect(getByText('12')).toBeTruthy();
|
|
13
|
+
});
|
|
14
|
+
});
|
package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/TriggerJourney.test.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TriggerJourney.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/TriggerJourney.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { describe, it, expect } from 'vitest';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import { TriggerJourney } from '../components/TriggerJourney';
|
|
5
|
+
describe('TriggerJourney', () => {
|
|
6
|
+
it('returns null when status is null', () => {
|
|
7
|
+
const { container } = render(_jsx(TriggerJourney, { status: null }));
|
|
8
|
+
expect(container.innerHTML).toBe('');
|
|
9
|
+
});
|
|
10
|
+
it('returns null when conditions array is empty', () => {
|
|
11
|
+
const status = { visible: true, isFallback: true, conditions: [] };
|
|
12
|
+
const { container } = render(_jsx(TriggerJourney, { status: status }));
|
|
13
|
+
expect(container.innerHTML).toBe('');
|
|
14
|
+
});
|
|
15
|
+
it('renders a single node for one condition', () => {
|
|
16
|
+
const status = {
|
|
17
|
+
visible: true,
|
|
18
|
+
isFallback: false,
|
|
19
|
+
conditions: [{
|
|
20
|
+
type: 'page_url',
|
|
21
|
+
passed: true,
|
|
22
|
+
formatted: { label: '/pricing', instruction: 'Visit /pricing', shortLabel: '/pricing' },
|
|
23
|
+
}],
|
|
24
|
+
};
|
|
25
|
+
render(_jsx(TriggerJourney, { status: status }));
|
|
26
|
+
expect(screen.getByText('/pricing')).toBeTruthy();
|
|
27
|
+
});
|
|
28
|
+
it('renders multiple connected nodes', () => {
|
|
29
|
+
const status = {
|
|
30
|
+
visible: false,
|
|
31
|
+
isFallback: false,
|
|
32
|
+
conditions: [
|
|
33
|
+
{
|
|
34
|
+
type: 'page_url',
|
|
35
|
+
passed: true,
|
|
36
|
+
formatted: { label: '/fine-arts/', instruction: 'Visit a /fine-arts/ page', shortLabel: '/fine-arts/' },
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: 'event_count',
|
|
40
|
+
passed: false,
|
|
41
|
+
formatted: {
|
|
42
|
+
label: 'views >= 2',
|
|
43
|
+
instruction: 'View pages 2+ times',
|
|
44
|
+
shortLabel: 'View 2+ times',
|
|
45
|
+
progress: { current: 1, target: 2, operator: 'gte' },
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
const { container } = render(_jsx(TriggerJourney, { status: status }));
|
|
51
|
+
expect(screen.getByText('/fine-arts/')).toBeTruthy();
|
|
52
|
+
expect(screen.getByText('View 2+ times')).toBeTruthy();
|
|
53
|
+
const lines = container.querySelectorAll('[data-journey-line]');
|
|
54
|
+
expect(lines.length).toBe(1);
|
|
55
|
+
});
|
|
56
|
+
it('shows progress bar for event_count conditions', () => {
|
|
57
|
+
const status = {
|
|
58
|
+
visible: false,
|
|
59
|
+
isFallback: false,
|
|
60
|
+
conditions: [{
|
|
61
|
+
type: 'event_count',
|
|
62
|
+
passed: false,
|
|
63
|
+
formatted: {
|
|
64
|
+
label: 'clicks >= 3',
|
|
65
|
+
instruction: 'Reach 3+ click events',
|
|
66
|
+
shortLabel: '3+ clicks',
|
|
67
|
+
progress: { current: 1, target: 3, operator: 'gte' },
|
|
68
|
+
},
|
|
69
|
+
}],
|
|
70
|
+
};
|
|
71
|
+
render(_jsx(TriggerJourney, { status: status }));
|
|
72
|
+
expect(screen.getByText('1/3')).toBeTruthy();
|
|
73
|
+
});
|
|
74
|
+
it('marks passed nodes with data-passed attribute', () => {
|
|
75
|
+
const status = {
|
|
76
|
+
visible: false,
|
|
77
|
+
isFallback: false,
|
|
78
|
+
conditions: [
|
|
79
|
+
{ type: 'a', passed: true, formatted: { label: 'a', instruction: 'A', shortLabel: 'A' } },
|
|
80
|
+
{ type: 'b', passed: false, formatted: { label: 'b', instruction: 'B', shortLabel: 'B' } },
|
|
81
|
+
],
|
|
82
|
+
};
|
|
83
|
+
const { container } = render(_jsx(TriggerJourney, { status: status }));
|
|
84
|
+
const nodes = container.querySelectorAll('[data-journey-node]');
|
|
85
|
+
expect(nodes.length).toBe(2);
|
|
86
|
+
expect(nodes[0].getAttribute('data-passed')).toBe('true');
|
|
87
|
+
expect(nodes[1].getAttribute('data-passed')).toBe('false');
|
|
88
|
+
});
|
|
89
|
+
it('shows "All conditions met" when all passed and multiple conditions', () => {
|
|
90
|
+
const status = {
|
|
91
|
+
visible: true,
|
|
92
|
+
isFallback: false,
|
|
93
|
+
conditions: [
|
|
94
|
+
{ type: 'a', passed: true, formatted: { label: 'a', instruction: 'A', shortLabel: 'A' } },
|
|
95
|
+
{ type: 'b', passed: true, formatted: { label: 'b', instruction: 'B', shortLabel: 'B' } },
|
|
96
|
+
],
|
|
97
|
+
};
|
|
98
|
+
render(_jsx(TriggerJourney, { status: status }));
|
|
99
|
+
expect(screen.getByText('All conditions met')).toBeTruthy();
|
|
100
|
+
});
|
|
101
|
+
it('does NOT show "All conditions met" for single condition', () => {
|
|
102
|
+
const status = {
|
|
103
|
+
visible: true,
|
|
104
|
+
isFallback: false,
|
|
105
|
+
conditions: [
|
|
106
|
+
{ type: 'a', passed: true, formatted: { label: 'a', instruction: 'A', shortLabel: 'A' } },
|
|
107
|
+
],
|
|
108
|
+
};
|
|
109
|
+
render(_jsx(TriggerJourney, { status: status }));
|
|
110
|
+
expect(screen.queryByText('All conditions met')).toBeNull();
|
|
111
|
+
});
|
|
112
|
+
it('uses instruction as title attribute for tooltip', () => {
|
|
113
|
+
const status = {
|
|
114
|
+
visible: false,
|
|
115
|
+
isFallback: false,
|
|
116
|
+
conditions: [{
|
|
117
|
+
type: 'page_url',
|
|
118
|
+
passed: false,
|
|
119
|
+
formatted: { label: '/p', instruction: 'Visit /pricing page', shortLabel: '/pricing' },
|
|
120
|
+
}],
|
|
121
|
+
};
|
|
122
|
+
render(_jsx(TriggerJourney, { status: status }));
|
|
123
|
+
const label = screen.getByText('/pricing');
|
|
124
|
+
expect(label.getAttribute('title')).toBe('Visit /pricing page');
|
|
125
|
+
});
|
|
126
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cn.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/cn.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { cn } from '../cn';
|
|
3
|
+
describe('cn', () => {
|
|
4
|
+
it('joins multiple classes', () => {
|
|
5
|
+
expect(cn('a', 'b', 'c')).toBe('a b c');
|
|
6
|
+
});
|
|
7
|
+
it('filters out false, null, and undefined values', () => {
|
|
8
|
+
expect(cn('a', false, null, undefined, 'b')).toBe('a b');
|
|
9
|
+
});
|
|
10
|
+
it('returns empty string for no args', () => {
|
|
11
|
+
expect(cn()).toBe('');
|
|
12
|
+
});
|
|
13
|
+
it('handles a single class', () => {
|
|
14
|
+
expect(cn('only')).toBe('only');
|
|
15
|
+
});
|
|
16
|
+
});
|
package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/formatConditionLabel.test.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatConditionLabel.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/formatConditionLabel.test.ts"],"names":[],"mappings":""}
|
package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/formatConditionLabel.test.js
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { formatConditionLabel } from '../formatConditionLabel';
|
|
3
|
+
describe('formatConditionLabel', () => {
|
|
4
|
+
it('event_count: returns label with progress data', () => {
|
|
5
|
+
const result = formatConditionLabel({ type: 'event_count', key: 'click', operator: 'gte', count: 3 }, 1);
|
|
6
|
+
expect(result.label).toBe('click \u2265 3');
|
|
7
|
+
expect(result.progress).toEqual({ current: 1, target: 3, operator: 'gte' });
|
|
8
|
+
// New fields must be present
|
|
9
|
+
expect(result.instruction).toBeDefined();
|
|
10
|
+
expect(result.shortLabel).toBeDefined();
|
|
11
|
+
});
|
|
12
|
+
it('page_url: returns the url as label', () => {
|
|
13
|
+
const result = formatConditionLabel({ type: 'page_url', url: '/pricing' });
|
|
14
|
+
expect(result.label).toBe('/pricing');
|
|
15
|
+
});
|
|
16
|
+
it('viewport: returns width constraints as label', () => {
|
|
17
|
+
const result = formatConditionLabel({ type: 'viewport', maxWidth: 768 });
|
|
18
|
+
expect(result.label).toContain('w');
|
|
19
|
+
expect(result.label).toContain('768px');
|
|
20
|
+
});
|
|
21
|
+
it('viewport: returns "any viewport" when no constraints', () => {
|
|
22
|
+
const result = formatConditionLabel({ type: 'viewport' });
|
|
23
|
+
expect(result.label).toBe('any viewport');
|
|
24
|
+
});
|
|
25
|
+
it('dismissed (inverted): returns "not dismissed"', () => {
|
|
26
|
+
const result = formatConditionLabel({ type: 'dismissed', inverted: true });
|
|
27
|
+
expect(result.label).toBe('not dismissed');
|
|
28
|
+
});
|
|
29
|
+
it('cooldown_active (inverted): returns "cooldown inactive"', () => {
|
|
30
|
+
const result = formatConditionLabel({ type: 'cooldown_active', inverted: true });
|
|
31
|
+
expect(result.label).toBe('cooldown inactive');
|
|
32
|
+
});
|
|
33
|
+
it('unknown type: returns type name as label', () => {
|
|
34
|
+
const result = formatConditionLabel({ type: 'some_custom' });
|
|
35
|
+
expect(result.label).toBe('some_custom');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
describe('instruction + shortLabel fields', () => {
|
|
39
|
+
describe('event_count', () => {
|
|
40
|
+
it('compound key with "page-views" returns instruction with topic and times', () => {
|
|
41
|
+
const result = formatConditionLabel({ type: 'event_count', key: 'fine-arts-page-views', operator: 'gte', count: 2 }, 0);
|
|
42
|
+
expect(result.instruction).toContain('fine arts');
|
|
43
|
+
expect(result.instruction).toContain('2+ times');
|
|
44
|
+
});
|
|
45
|
+
it('compound key shortLabel contains "2+ times"', () => {
|
|
46
|
+
const result = formatConditionLabel({ type: 'event_count', key: 'fine-arts-page-views', operator: 'gte', count: 2 }, 0);
|
|
47
|
+
expect(result.shortLabel).toContain('2+ times');
|
|
48
|
+
});
|
|
49
|
+
it('simple "click" key returns instruction mentioning click', () => {
|
|
50
|
+
const result = formatConditionLabel({ type: 'event_count', key: 'click', operator: 'gte', count: 3 }, 1);
|
|
51
|
+
expect(result.instruction.toLowerCase()).toContain('click');
|
|
52
|
+
});
|
|
53
|
+
it('click key shortLabel contains "clicks"', () => {
|
|
54
|
+
const result = formatConditionLabel({ type: 'event_count', key: 'click', operator: 'gte', count: 3 }, 1);
|
|
55
|
+
expect(result.shortLabel).toContain('click');
|
|
56
|
+
});
|
|
57
|
+
it('generic key returns instruction with "events"', () => {
|
|
58
|
+
const result = formatConditionLabel({ type: 'event_count', key: 'scroll-depth', operator: 'gte', count: 5 }, 0);
|
|
59
|
+
expect(result.instruction.toLowerCase()).toContain('event');
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
describe('page_url', () => {
|
|
63
|
+
it('url with wildcards returns instruction starting with "Visit"', () => {
|
|
64
|
+
const result = formatConditionLabel({
|
|
65
|
+
type: 'page_url',
|
|
66
|
+
url: '/fine-arts/**',
|
|
67
|
+
});
|
|
68
|
+
expect(result.instruction).toMatch(/^Visit/);
|
|
69
|
+
});
|
|
70
|
+
it('url with wildcards cleans up trailing wildcards', () => {
|
|
71
|
+
const result = formatConditionLabel({
|
|
72
|
+
type: 'page_url',
|
|
73
|
+
url: '/fine-arts/**',
|
|
74
|
+
});
|
|
75
|
+
expect(result.instruction).not.toContain('**');
|
|
76
|
+
});
|
|
77
|
+
it('simple url returns instruction starting with "Visit"', () => {
|
|
78
|
+
const result = formatConditionLabel({
|
|
79
|
+
type: 'page_url',
|
|
80
|
+
url: '/pricing',
|
|
81
|
+
});
|
|
82
|
+
expect(result.instruction).toMatch(/^Visit/);
|
|
83
|
+
});
|
|
84
|
+
it('shortLabel contains cleaned url', () => {
|
|
85
|
+
const result = formatConditionLabel({
|
|
86
|
+
type: 'page_url',
|
|
87
|
+
url: '/fine-arts/**',
|
|
88
|
+
});
|
|
89
|
+
expect(result.shortLabel).toContain('/fine-arts/');
|
|
90
|
+
expect(result.shortLabel).not.toContain('**');
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
describe('anchor_visible', () => {
|
|
94
|
+
it('instruction starts with "Scroll"', () => {
|
|
95
|
+
const result = formatConditionLabel({
|
|
96
|
+
type: 'anchor_visible',
|
|
97
|
+
anchorId: 'hero-section',
|
|
98
|
+
state: 'visible',
|
|
99
|
+
});
|
|
100
|
+
expect(result.instruction).toMatch(/^Scroll/);
|
|
101
|
+
});
|
|
102
|
+
it('instruction contains anchorId and state', () => {
|
|
103
|
+
const result = formatConditionLabel({
|
|
104
|
+
type: 'anchor_visible',
|
|
105
|
+
anchorId: 'hero-section',
|
|
106
|
+
state: 'visible',
|
|
107
|
+
});
|
|
108
|
+
expect(result.instruction).toContain('hero-section');
|
|
109
|
+
expect(result.instruction).toContain('visible');
|
|
110
|
+
});
|
|
111
|
+
it('shortLabel contains anchorId', () => {
|
|
112
|
+
const result = formatConditionLabel({
|
|
113
|
+
type: 'anchor_visible',
|
|
114
|
+
anchorId: 'hero-section',
|
|
115
|
+
state: 'visible',
|
|
116
|
+
});
|
|
117
|
+
expect(result.shortLabel).toContain('hero-section');
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
describe('event_occurred', () => {
|
|
121
|
+
it('instruction contains "event"', () => {
|
|
122
|
+
const result = formatConditionLabel({
|
|
123
|
+
type: 'event_occurred',
|
|
124
|
+
eventName: 'signup_complete',
|
|
125
|
+
});
|
|
126
|
+
expect(result.instruction.toLowerCase()).toContain('event');
|
|
127
|
+
});
|
|
128
|
+
it('instruction contains event name', () => {
|
|
129
|
+
const result = formatConditionLabel({
|
|
130
|
+
type: 'event_occurred',
|
|
131
|
+
eventName: 'signup_complete',
|
|
132
|
+
});
|
|
133
|
+
expect(result.instruction).toContain('signup_complete');
|
|
134
|
+
});
|
|
135
|
+
it('shortLabel contains event name', () => {
|
|
136
|
+
const result = formatConditionLabel({
|
|
137
|
+
type: 'event_occurred',
|
|
138
|
+
eventName: 'signup_complete',
|
|
139
|
+
});
|
|
140
|
+
expect(result.shortLabel).toContain('signup_complete');
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
describe('viewport', () => {
|
|
144
|
+
it('viewport with minWidth instruction contains pixel value', () => {
|
|
145
|
+
const result = formatConditionLabel({
|
|
146
|
+
type: 'viewport',
|
|
147
|
+
minWidth: 768,
|
|
148
|
+
});
|
|
149
|
+
expect(result.instruction).toContain('768px');
|
|
150
|
+
});
|
|
151
|
+
it('viewport instruction starts with "Use a viewport"', () => {
|
|
152
|
+
const result = formatConditionLabel({
|
|
153
|
+
type: 'viewport',
|
|
154
|
+
minWidth: 768,
|
|
155
|
+
});
|
|
156
|
+
expect(result.instruction).toMatch(/^Use a viewport/);
|
|
157
|
+
});
|
|
158
|
+
it('viewport with no constraints shortLabel is "Any size"', () => {
|
|
159
|
+
const result = formatConditionLabel({ type: 'viewport' });
|
|
160
|
+
expect(result.shortLabel).toBe('Any size');
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
describe('session_metric', () => {
|
|
164
|
+
it('instruction contains key and threshold', () => {
|
|
165
|
+
const result = formatConditionLabel({
|
|
166
|
+
type: 'session_metric',
|
|
167
|
+
key: 'time_on_page',
|
|
168
|
+
operator: 'gte',
|
|
169
|
+
threshold: 30,
|
|
170
|
+
});
|
|
171
|
+
expect(result.instruction).toContain('time_on_page');
|
|
172
|
+
expect(result.instruction).toContain('30');
|
|
173
|
+
});
|
|
174
|
+
it('shortLabel contains key and threshold', () => {
|
|
175
|
+
const result = formatConditionLabel({
|
|
176
|
+
type: 'session_metric',
|
|
177
|
+
key: 'time_on_page',
|
|
178
|
+
operator: 'gte',
|
|
179
|
+
threshold: 30,
|
|
180
|
+
});
|
|
181
|
+
expect(result.shortLabel).toContain('time_on_page');
|
|
182
|
+
expect(result.shortLabel).toContain('30');
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
describe('dismissed', () => {
|
|
186
|
+
it('inverted instruction contains "Do not dismiss" or "not dismiss"', () => {
|
|
187
|
+
const result = formatConditionLabel({
|
|
188
|
+
type: 'dismissed',
|
|
189
|
+
inverted: true,
|
|
190
|
+
key: 'promo-banner',
|
|
191
|
+
});
|
|
192
|
+
expect(result.instruction.toLowerCase()).toContain('not dismiss');
|
|
193
|
+
});
|
|
194
|
+
it('non-inverted instruction contains "Dismiss"', () => {
|
|
195
|
+
const result = formatConditionLabel({
|
|
196
|
+
type: 'dismissed',
|
|
197
|
+
inverted: false,
|
|
198
|
+
key: 'promo-banner',
|
|
199
|
+
});
|
|
200
|
+
expect(result.instruction).toContain('Dismiss');
|
|
201
|
+
});
|
|
202
|
+
it('inverted shortLabel contains "Not dismissed"', () => {
|
|
203
|
+
const result = formatConditionLabel({
|
|
204
|
+
type: 'dismissed',
|
|
205
|
+
inverted: true,
|
|
206
|
+
key: 'promo-banner',
|
|
207
|
+
});
|
|
208
|
+
expect(result.shortLabel).toBe('Not dismissed');
|
|
209
|
+
});
|
|
210
|
+
it('non-inverted shortLabel contains "Dismissed"', () => {
|
|
211
|
+
const result = formatConditionLabel({
|
|
212
|
+
type: 'dismissed',
|
|
213
|
+
inverted: false,
|
|
214
|
+
key: 'promo-banner',
|
|
215
|
+
});
|
|
216
|
+
expect(result.shortLabel).toBe('Dismissed');
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
describe('cooldown_active', () => {
|
|
220
|
+
it('inverted instruction contains "Wait for cooldown"', () => {
|
|
221
|
+
const result = formatConditionLabel({
|
|
222
|
+
type: 'cooldown_active',
|
|
223
|
+
inverted: true,
|
|
224
|
+
});
|
|
225
|
+
expect(result.instruction).toContain('Wait for cooldown');
|
|
226
|
+
});
|
|
227
|
+
it('non-inverted instruction contains "Cooldown is active"', () => {
|
|
228
|
+
const result = formatConditionLabel({
|
|
229
|
+
type: 'cooldown_active',
|
|
230
|
+
inverted: false,
|
|
231
|
+
});
|
|
232
|
+
expect(result.instruction).toContain('Cooldown is active');
|
|
233
|
+
});
|
|
234
|
+
it('inverted shortLabel is "Cooldown done"', () => {
|
|
235
|
+
const result = formatConditionLabel({
|
|
236
|
+
type: 'cooldown_active',
|
|
237
|
+
inverted: true,
|
|
238
|
+
});
|
|
239
|
+
expect(result.shortLabel).toBe('Cooldown done');
|
|
240
|
+
});
|
|
241
|
+
it('non-inverted shortLabel is "Cooldown active"', () => {
|
|
242
|
+
const result = formatConditionLabel({
|
|
243
|
+
type: 'cooldown_active',
|
|
244
|
+
inverted: false,
|
|
245
|
+
});
|
|
246
|
+
expect(result.shortLabel).toBe('Cooldown active');
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
describe('frequency_limit', () => {
|
|
250
|
+
it('inverted instruction contains "fewer than"', () => {
|
|
251
|
+
const result = formatConditionLabel({
|
|
252
|
+
type: 'frequency_limit',
|
|
253
|
+
inverted: true,
|
|
254
|
+
limit: 5,
|
|
255
|
+
});
|
|
256
|
+
expect(result.instruction).toContain('fewer than');
|
|
257
|
+
});
|
|
258
|
+
it('non-inverted instruction contains "Shown"', () => {
|
|
259
|
+
const result = formatConditionLabel({
|
|
260
|
+
type: 'frequency_limit',
|
|
261
|
+
inverted: false,
|
|
262
|
+
limit: 5,
|
|
263
|
+
});
|
|
264
|
+
expect(result.instruction).toContain('Shown');
|
|
265
|
+
});
|
|
266
|
+
it('inverted shortLabel is "< N views"', () => {
|
|
267
|
+
const result = formatConditionLabel({
|
|
268
|
+
type: 'frequency_limit',
|
|
269
|
+
inverted: true,
|
|
270
|
+
limit: 5,
|
|
271
|
+
});
|
|
272
|
+
expect(result.shortLabel).toBe('< 5 views');
|
|
273
|
+
});
|
|
274
|
+
it('non-inverted shortLabel is "N+ views"', () => {
|
|
275
|
+
const result = formatConditionLabel({
|
|
276
|
+
type: 'frequency_limit',
|
|
277
|
+
inverted: false,
|
|
278
|
+
limit: 5,
|
|
279
|
+
});
|
|
280
|
+
expect(result.shortLabel).toBe('5+ views');
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
describe('route', () => {
|
|
284
|
+
it('instruction contains "Navigate to"', () => {
|
|
285
|
+
const result = formatConditionLabel({
|
|
286
|
+
type: 'route',
|
|
287
|
+
routeId: 'checkout',
|
|
288
|
+
});
|
|
289
|
+
expect(result.instruction).toContain('Navigate to');
|
|
290
|
+
expect(result.instruction).toContain('checkout');
|
|
291
|
+
});
|
|
292
|
+
it('shortLabel is routeId', () => {
|
|
293
|
+
const result = formatConditionLabel({
|
|
294
|
+
type: 'route',
|
|
295
|
+
routeId: 'checkout',
|
|
296
|
+
});
|
|
297
|
+
expect(result.shortLabel).toBe('checkout');
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
describe('state_equals', () => {
|
|
301
|
+
it('instruction contains key and value', () => {
|
|
302
|
+
const result = formatConditionLabel({
|
|
303
|
+
type: 'state_equals',
|
|
304
|
+
key: 'theme',
|
|
305
|
+
value: 'dark',
|
|
306
|
+
});
|
|
307
|
+
expect(result.instruction).toContain('theme');
|
|
308
|
+
expect(result.instruction).toContain('dark');
|
|
309
|
+
});
|
|
310
|
+
it('shortLabel is key', () => {
|
|
311
|
+
const result = formatConditionLabel({
|
|
312
|
+
type: 'state_equals',
|
|
313
|
+
key: 'theme',
|
|
314
|
+
value: 'dark',
|
|
315
|
+
});
|
|
316
|
+
expect(result.shortLabel).toBe('theme');
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
describe('unknown type', () => {
|
|
320
|
+
it('instruction equals the type string', () => {
|
|
321
|
+
const result = formatConditionLabel({ type: 'some_custom' });
|
|
322
|
+
expect(result.instruction).toBe('some_custom');
|
|
323
|
+
});
|
|
324
|
+
it('shortLabel equals the type string', () => {
|
|
325
|
+
const result = formatConditionLabel({ type: 'some_custom' });
|
|
326
|
+
expect(result.shortLabel).toBe('some_custom');
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
});
|
package/node_modules/@syntrologie/shared-editor-ui/dist/__tests__/useElementRect.test.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useElementRect.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/useElementRect.test.ts"],"names":[],"mappings":""}
|