gantt-source_management 3.37.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/.editorconfig +9 -0
- package/.eslintrc.json +39 -0
- package/.prettierrc.cjs +5 -0
- package/README.md +129 -0
- package/cypress/e2e/add-rows-items.test.ts +26 -0
- package/cypress/e2e/basic.test.ts +173 -0
- package/cypress/e2e/calculated-zoom-mode.test.ts +163 -0
- package/cypress/e2e/calendar-dates.test.ts +285 -0
- package/cypress/e2e/dst.test.ts +691 -0
- package/cypress/e2e/grid-cells.test.ts +72 -0
- package/cypress/e2e/items-vertical.test.ts +305 -0
- package/cypress/e2e/items.test.ts +501 -0
- package/cypress/e2e/list-columns-toggle.test.ts +124 -0
- package/cypress/e2e/list-header-resize.test.ts +30 -0
- package/cypress/e2e/locale.test.ts +102 -0
- package/cypress/e2e/move-items-outside.test.ts +437 -0
- package/cypress/e2e/rows.test.ts +50 -0
- package/cypress/e2e/scroll-bar.test.ts +357 -0
- package/cypress/e2e/time-bookmarks.test.ts +92 -0
- package/cypress/e2e/utc-mode.test.ts +51 -0
- package/cypress/fixtures/example.json +5 -0
- package/cypress/helpers.ts +12 -0
- package/cypress/plugins/index.js +22 -0
- package/cypress/support/commands.ts +175 -0
- package/cypress/support/e2e.ts +31 -0
- package/cypress.config.js +24 -0
- package/dist/api/api.d.ts +182 -0
- package/dist/api/helpers.d.ts +9 -0
- package/dist/api/id.d.ts +14 -0
- package/dist/api/locale.d.ts +3 -0
- package/dist/api/main.d.ts +47 -0
- package/dist/api/public.d.ts +32 -0
- package/dist/api/slots.d.ts +22 -0
- package/dist/api/time.d.ts +104 -0
- package/dist/assets/2f1f893a.wasm +0 -0
- package/dist/gstc.d.ts +708 -0
- package/dist/gstc.esm.min.d.ts +708 -0
- package/dist/gstc.esm.min.js +574 -0
- package/dist/gstc.umd.min.d.ts +708 -0
- package/dist/gstc.umd.min.js +701 -0
- package/dist/gstc.wasm.esm.min.d.ts +708 -0
- package/dist/gstc.wasm.esm.min.js +574 -0
- package/dist/gstc.wasm.umd.min.d.ts +708 -0
- package/dist/gstc.wasm.umd.min.js +701 -0
- package/dist/plugins/calendar-scroll.d.ts +15 -0
- package/dist/plugins/calendar-scroll.esm.min.d.ts +15 -0
- package/dist/plugins/calendar-scroll.esm.min.js +13 -0
- package/dist/plugins/calendar-scroll.umd.min.d.ts +15 -0
- package/dist/plugins/calendar-scroll.umd.min.js +13 -0
- package/dist/plugins/dependency-lines.d.ts +47 -0
- package/dist/plugins/dependency-lines.esm.min.d.ts +47 -0
- package/dist/plugins/dependency-lines.esm.min.js +38 -0
- package/dist/plugins/dependency-lines.umd.min.d.ts +47 -0
- package/dist/plugins/dependency-lines.umd.min.js +38 -0
- package/dist/plugins/export-image.d.ts +12 -0
- package/dist/plugins/export-image.esm.min.d.ts +12 -0
- package/dist/plugins/export-image.esm.min.js +28 -0
- package/dist/plugins/export-image.umd.min.d.ts +12 -0
- package/dist/plugins/export-image.umd.min.js +34 -0
- package/dist/plugins/export-pdf.d.ts +12 -0
- package/dist/plugins/export-pdf.esm.min.d.ts +12 -0
- package/dist/plugins/export-pdf.esm.min.js +389 -0
- package/dist/plugins/export-pdf.umd.min.d.ts +12 -0
- package/dist/plugins/export-pdf.umd.min.js +511 -0
- package/dist/plugins/grab-scroll.d.ts +14 -0
- package/dist/plugins/grab-scroll.esm.min.d.ts +14 -0
- package/dist/plugins/grab-scroll.umd.min.d.ts +14 -0
- package/dist/plugins/highlight-weekends.d.ts +12 -0
- package/dist/plugins/highlight-weekends.esm.min.d.ts +12 -0
- package/dist/plugins/highlight-weekends.esm.min.js +14 -0
- package/dist/plugins/highlight-weekends.umd.min.d.ts +12 -0
- package/dist/plugins/highlight-weekends.umd.min.js +14 -0
- package/dist/plugins/item-movement.d.ts +97 -0
- package/dist/plugins/item-movement.esm.min.d.ts +97 -0
- package/dist/plugins/item-movement.esm.min.js +25 -0
- package/dist/plugins/item-movement.umd.min.d.ts +97 -0
- package/dist/plugins/item-movement.umd.min.js +25 -0
- package/dist/plugins/item-resizing.d.ts +102 -0
- package/dist/plugins/item-resizing.esm.min.d.ts +102 -0
- package/dist/plugins/item-resizing.esm.min.js +37 -0
- package/dist/plugins/item-resizing.umd.min.d.ts +102 -0
- package/dist/plugins/item-resizing.umd.min.js +37 -0
- package/dist/plugins/item-types.d.ts +13 -0
- package/dist/plugins/item-types.esm.min.d.ts +13 -0
- package/dist/plugins/item-types.esm.min.js +127 -0
- package/dist/plugins/item-types.umd.min.d.ts +13 -0
- package/dist/plugins/item-types.umd.min.js +127 -0
- package/dist/plugins/progress-bar.d.ts +13 -0
- package/dist/plugins/progress-bar.esm.min.d.ts +13 -0
- package/dist/plugins/progress-bar.esm.min.js +27 -0
- package/dist/plugins/progress-bar.umd.min.d.ts +13 -0
- package/dist/plugins/progress-bar.umd.min.js +27 -0
- package/dist/plugins/selection.d.ts +94 -0
- package/dist/plugins/selection.esm.min.d.ts +94 -0
- package/dist/plugins/selection.esm.min.js +26 -0
- package/dist/plugins/selection.umd.min.d.ts +94 -0
- package/dist/plugins/selection.umd.min.js +26 -0
- package/dist/plugins/time-bookmarks.d.ts +38 -0
- package/dist/plugins/time-bookmarks.esm.min.d.ts +38 -0
- package/dist/plugins/time-bookmarks.esm.min.js +50 -0
- package/dist/plugins/time-bookmarks.umd.min.d.ts +38 -0
- package/dist/plugins/time-bookmarks.umd.min.js +50 -0
- package/dist/plugins/timeline-pointer.d.ts +83 -0
- package/dist/plugins/timeline-pointer.esm.min.d.ts +83 -0
- package/dist/plugins/timeline-pointer.esm.min.js +13 -0
- package/dist/plugins/timeline-pointer.umd.min.d.ts +83 -0
- package/dist/plugins/timeline-pointer.umd.min.js +13 -0
- package/dist/style.css +811 -0
- package/dist/vendor.esm.min.js +128 -0
- package/examples/complex-1/faces/face-1.jpg +0 -0
- package/examples/complex-1/faces/face-10.jpg +0 -0
- package/examples/complex-1/faces/face-11.jpg +0 -0
- package/examples/complex-1/faces/face-12.jpg +0 -0
- package/examples/complex-1/faces/face-13.jpg +0 -0
- package/examples/complex-1/faces/face-14.jpg +0 -0
- package/examples/complex-1/faces/face-15.jpg +0 -0
- package/examples/complex-1/faces/face-16.jpg +0 -0
- package/examples/complex-1/faces/face-17.jpg +0 -0
- package/examples/complex-1/faces/face-18.jpg +0 -0
- package/examples/complex-1/faces/face-19.jpg +0 -0
- package/examples/complex-1/faces/face-2.jpg +0 -0
- package/examples/complex-1/faces/face-20.jpg +0 -0
- package/examples/complex-1/faces/face-21.jpg +0 -0
- package/examples/complex-1/faces/face-22.jpg +0 -0
- package/examples/complex-1/faces/face-23.jpg +0 -0
- package/examples/complex-1/faces/face-24.jpg +0 -0
- package/examples/complex-1/faces/face-25.jpg +0 -0
- package/examples/complex-1/faces/face-26.jpg +0 -0
- package/examples/complex-1/faces/face-27.jpg +0 -0
- package/examples/complex-1/faces/face-28.jpg +0 -0
- package/examples/complex-1/faces/face-29.jpg +0 -0
- package/examples/complex-1/faces/face-3.jpg +0 -0
- package/examples/complex-1/faces/face-30.jpg +0 -0
- package/examples/complex-1/faces/face-31.jpg +0 -0
- package/examples/complex-1/faces/face-32.jpg +0 -0
- package/examples/complex-1/faces/face-33.jpg +0 -0
- package/examples/complex-1/faces/face-34.jpg +0 -0
- package/examples/complex-1/faces/face-35.jpg +0 -0
- package/examples/complex-1/faces/face-36.jpg +0 -0
- package/examples/complex-1/faces/face-37.jpg +0 -0
- package/examples/complex-1/faces/face-38.jpg +0 -0
- package/examples/complex-1/faces/face-39.jpg +0 -0
- package/examples/complex-1/faces/face-4.jpg +0 -0
- package/examples/complex-1/faces/face-40.jpg +0 -0
- package/examples/complex-1/faces/face-41.jpg +0 -0
- package/examples/complex-1/faces/face-42.jpg +0 -0
- package/examples/complex-1/faces/face-43.jpg +0 -0
- package/examples/complex-1/faces/face-44.jpg +0 -0
- package/examples/complex-1/faces/face-45.jpg +0 -0
- package/examples/complex-1/faces/face-46.jpg +0 -0
- package/examples/complex-1/faces/face-47.jpg +0 -0
- package/examples/complex-1/faces/face-48.jpg +0 -0
- package/examples/complex-1/faces/face-49.jpg +0 -0
- package/examples/complex-1/faces/face-5.jpg +0 -0
- package/examples/complex-1/faces/face-50.jpg +0 -0
- package/examples/complex-1/faces/face-6.jpg +0 -0
- package/examples/complex-1/faces/face-7.jpg +0 -0
- package/examples/complex-1/faces/face-8.jpg +0 -0
- package/examples/complex-1/faces/face-9.jpg +0 -0
- package/examples/complex-1/index.html +61 -0
- package/examples/complex-1/index.js +923 -0
- package/examples/index.html +22 -0
- package/examples/reset.css +455 -0
- package/examples/server.js +18 -0
- package/package.json +150 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import DeepState from 'deep-state-observer';
|
|
2
|
+
import { Data, DataChartDimensions, DataChartTime, DataScrollHorizontal } from '../../dist/gstc';
|
|
3
|
+
import { round } from '../helpers';
|
|
4
|
+
|
|
5
|
+
describe('Scroll bar', () => {
|
|
6
|
+
it('Movement (not precise)', () => {
|
|
7
|
+
const horizontalScrollBarSelector = '.gstc__scroll-bar-inner--horizontal';
|
|
8
|
+
const verticalScrollBarSelector = '.gstc__scroll-bar-inner--vertical';
|
|
9
|
+
let state: DeepState;
|
|
10
|
+
let merge;
|
|
11
|
+
|
|
12
|
+
cy.load('/examples/simple/simple.esm.html')
|
|
13
|
+
.get(horizontalScrollBarSelector)
|
|
14
|
+
.should(($el) => {
|
|
15
|
+
expect($el.css('left')).to.eq('0px');
|
|
16
|
+
})
|
|
17
|
+
.window()
|
|
18
|
+
.then((win) => {
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
state = win.state;
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
merge = win.gstc.api.mergeDeep;
|
|
23
|
+
const dimensions: DataChartDimensions = state.get('$data.chart.dimensions');
|
|
24
|
+
cy.log('$data.scroll.horizontal', state.get('$data.scroll.horizontal'));
|
|
25
|
+
cy.log('$data.chart.dimensions', dimensions);
|
|
26
|
+
cy.log('widthWithoutScrollBar', dimensions.widthWithoutScrollBar);
|
|
27
|
+
})
|
|
28
|
+
.then(() => {
|
|
29
|
+
const $data: Data = { ...state.get('$data') };
|
|
30
|
+
expect($data.scroll.horizontal.absolutePosPx).to.eq(0);
|
|
31
|
+
expect($data.scroll.horizontal.maxHandlePosPx).to.be.greaterThan(0);
|
|
32
|
+
expect($data.scroll.vertical.handlePosPx).to.eq(0);
|
|
33
|
+
expect(isNaN($data.scroll.vertical.handlePosPx)).to.eq(false);
|
|
34
|
+
})
|
|
35
|
+
.get('.gstc__list-column-row[data-gstcid="gstcid-1"]')
|
|
36
|
+
.scrollH(800)
|
|
37
|
+
.then(() => {
|
|
38
|
+
const scroll = state.get('$data.scroll');
|
|
39
|
+
cy.log('horizontal', scroll.horizontal);
|
|
40
|
+
expect(scroll.horizontal.absolutePosPx).to.be.greaterThan(0);
|
|
41
|
+
expect(scroll.horizontal.maxHandlePosPx).to.be.greaterThan(0);
|
|
42
|
+
})
|
|
43
|
+
.get(verticalScrollBarSelector)
|
|
44
|
+
.should(($el) => {
|
|
45
|
+
expect($el.css('top')).to.eq('0px');
|
|
46
|
+
})
|
|
47
|
+
.then(() => {
|
|
48
|
+
const scroll = state.get('$data.scroll');
|
|
49
|
+
cy.log('vertical', scroll.vertical);
|
|
50
|
+
expect(scroll.vertical.absolutePosPx).to.eq(0);
|
|
51
|
+
expect(scroll.vertical.maxHandlePosPx).to.be.greaterThan(0);
|
|
52
|
+
expect(isNaN(scroll.vertical.handlePosPx)).to.eq(false);
|
|
53
|
+
})
|
|
54
|
+
.scrollV(400)
|
|
55
|
+
.then(() => {
|
|
56
|
+
const scroll = state.get('$data.scroll');
|
|
57
|
+
cy.log('vertical', scroll.vertical);
|
|
58
|
+
expect(scroll.vertical.absolutePosPx).to.be.greaterThan(0);
|
|
59
|
+
expect(scroll.vertical.maxHandlePosPx).to.be.greaterThan(0);
|
|
60
|
+
expect(isNaN(scroll.vertical.handlePosPx)).to.eq(false);
|
|
61
|
+
})
|
|
62
|
+
.get('.gstc__list-column-row[data-gstcid="gstcid-12"]')
|
|
63
|
+
.then(() => {
|
|
64
|
+
cy.log('state', merge({}, state.get()));
|
|
65
|
+
})
|
|
66
|
+
.then(() => {
|
|
67
|
+
const $vertical = Cypress.$(verticalScrollBarSelector);
|
|
68
|
+
const $horizontal = Cypress.$(horizontalScrollBarSelector);
|
|
69
|
+
const v = merge({}, state.get('$data.scroll.vertical'));
|
|
70
|
+
const h = merge({}, state.get('$data.scroll.horizontal'));
|
|
71
|
+
cy.log('vertical', v);
|
|
72
|
+
cy.log('horizontal', h);
|
|
73
|
+
expect(round(v.handlePosPx)).to.eq(round($vertical.css('top')));
|
|
74
|
+
expect(round(h.handlePosPx)).to.eq(round($horizontal.css('left')));
|
|
75
|
+
expect(round(v.innerHandleSize)).to.eq(round($vertical.height()));
|
|
76
|
+
expect(round(h.innerHandleSize)).to.eq(round($horizontal.width()));
|
|
77
|
+
expect(round(state.get('$data.chart.dimensions.widthWithoutScrollBar'))).to.eq(round(h.scrollSize));
|
|
78
|
+
expect(round(state.get('$data.chart.dimensions.heightWithoutScrollBar'))).to.eq(round(v.scrollSize));
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('Movement (precise)', () => {
|
|
83
|
+
const horizontalScrollBarSelector = '.gstc__scroll-bar-inner--horizontal';
|
|
84
|
+
const verticalScrollBarSelector = '.gstc__scroll-bar-inner--vertical';
|
|
85
|
+
let state: DeepState;
|
|
86
|
+
let merge;
|
|
87
|
+
|
|
88
|
+
cy.load('/examples/simple/simple.esm.html')
|
|
89
|
+
.window()
|
|
90
|
+
.then((win) => {
|
|
91
|
+
// @ts-ignore
|
|
92
|
+
state = win.state;
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
merge = win.gstc.api.mergeDeep;
|
|
95
|
+
state.update('config.scroll.horizontal.precise', true);
|
|
96
|
+
state.update('config.scroll.vertical.precise', true);
|
|
97
|
+
})
|
|
98
|
+
.get(horizontalScrollBarSelector)
|
|
99
|
+
.should(($el) => {
|
|
100
|
+
expect($el.css('left')).to.eq('0px');
|
|
101
|
+
})
|
|
102
|
+
.wait(Cypress.env('wait'))
|
|
103
|
+
.then(() => {
|
|
104
|
+
const scroll = state.get('$data.scroll');
|
|
105
|
+
cy.log('horizontal', scroll.horizontal);
|
|
106
|
+
expect(scroll.horizontal.absolutePosPx).to.eq(0);
|
|
107
|
+
expect(scroll.horizontal.maxHandlePosPx).to.be.greaterThan(0);
|
|
108
|
+
})
|
|
109
|
+
.get('.gstc__list-column-row[data-gstcid="gstcid-1"]')
|
|
110
|
+
.should('be.visible')
|
|
111
|
+
.scrollH(800)
|
|
112
|
+
.then(() => {
|
|
113
|
+
const scroll = state.get('$data.scroll');
|
|
114
|
+
cy.log('horizontal', scroll.horizontal);
|
|
115
|
+
expect(scroll.horizontal.absolutePosPx).to.be.greaterThan(0);
|
|
116
|
+
expect(scroll.horizontal.maxHandlePosPx).to.be.greaterThan(0);
|
|
117
|
+
})
|
|
118
|
+
.get(verticalScrollBarSelector)
|
|
119
|
+
.should(($el) => {
|
|
120
|
+
expect($el.css('top')).to.eq('0px');
|
|
121
|
+
})
|
|
122
|
+
.wait(Cypress.env('wait'))
|
|
123
|
+
.then(() => {
|
|
124
|
+
const scroll = state.get('$data.scroll');
|
|
125
|
+
cy.log('vertical', scroll.vertical);
|
|
126
|
+
expect(scroll.vertical.absolutePosPx).to.eq(0);
|
|
127
|
+
expect(scroll.vertical.maxHandlePosPx).to.be.greaterThan(0);
|
|
128
|
+
expect(isNaN(scroll.vertical.handlePosPx)).to.eq(false);
|
|
129
|
+
})
|
|
130
|
+
.scrollV(400)
|
|
131
|
+
.then(() => {
|
|
132
|
+
const scroll = state.get('$data.scroll');
|
|
133
|
+
cy.log('vertical', scroll.vertical);
|
|
134
|
+
expect(scroll.vertical.absolutePosPx).to.be.greaterThan(0);
|
|
135
|
+
expect(scroll.vertical.maxHandlePosPx).to.be.greaterThan(0);
|
|
136
|
+
expect(isNaN(scroll.vertical.handlePosPx)).to.eq(false);
|
|
137
|
+
})
|
|
138
|
+
.get('.gstc__list-column-row[data-gstcid="gstcid-12"]')
|
|
139
|
+
.then(() => {
|
|
140
|
+
cy.log('state', merge({}, state.get()));
|
|
141
|
+
})
|
|
142
|
+
.then(() => {
|
|
143
|
+
const $vertical = Cypress.$(verticalScrollBarSelector);
|
|
144
|
+
const $horizontal = Cypress.$(horizontalScrollBarSelector);
|
|
145
|
+
const scroll = state.get('$data.scroll');
|
|
146
|
+
const v = scroll.vertical;
|
|
147
|
+
const h = scroll.horizontal;
|
|
148
|
+
cy.log('vertical', v);
|
|
149
|
+
cy.log('horizontal', h);
|
|
150
|
+
expect(round(v.handlePosPx)).to.eq(round($vertical.css('top')));
|
|
151
|
+
expect(round(h.handlePosPx)).to.eq(round($horizontal.css('left')));
|
|
152
|
+
expect(round(v.innerHandleSize)).to.eq(round($vertical.height()));
|
|
153
|
+
expect(round(h.innerHandleSize)).to.eq(round($horizontal.width()));
|
|
154
|
+
expect(round(state.get('$data.chart.dimensions.widthWithoutScrollBar'))).to.eq(round(h.scrollSize));
|
|
155
|
+
expect(round(state.get('$data.chart.dimensions.heightWithoutScrollBar'))).to.eq(round(v.scrollSize));
|
|
156
|
+
})
|
|
157
|
+
//
|
|
158
|
+
// preciseOffset
|
|
159
|
+
//
|
|
160
|
+
.scrollH(-20)
|
|
161
|
+
.then(() => {
|
|
162
|
+
const $scroll = Cypress.$(horizontalScrollBarSelector);
|
|
163
|
+
const scrollData = state.get('$data.scroll.horizontal');
|
|
164
|
+
expect(round(scrollData.handlePosPx)).to.eq(round($scroll.css('left')));
|
|
165
|
+
expect(round(scrollData.innerHandleSize)).to.eq(round($scroll.width()));
|
|
166
|
+
expect(round(state.get('$data.chart.dimensions.widthWithoutScrollBar'))).to.eq(round(scrollData.scrollSize));
|
|
167
|
+
expect(scrollData.preciseOffset).to.be.lessThan(0);
|
|
168
|
+
})
|
|
169
|
+
.scrollV(-20)
|
|
170
|
+
.then(() => {
|
|
171
|
+
const $scroll = Cypress.$(verticalScrollBarSelector);
|
|
172
|
+
const scrollData = state.get('$data.scroll.vertical');
|
|
173
|
+
expect(round(scrollData.handlePosPx)).to.eq(round($scroll.css('top')));
|
|
174
|
+
expect(round(scrollData.innerHandleSize)).to.eq(round($scroll.height()));
|
|
175
|
+
expect(round(state.get('$data.chart.dimensions.heightWithoutScrollBar'))).to.eq(round(scrollData.scrollSize));
|
|
176
|
+
expect(scrollData.preciseOffset).to.be.lessThan(0);
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('should scroll with api', () => {
|
|
181
|
+
let gstc, scrollTo;
|
|
182
|
+
cy.load('/examples/complex-1')
|
|
183
|
+
.window()
|
|
184
|
+
.then((win) => {
|
|
185
|
+
// @ts-ignore
|
|
186
|
+
gstc = win.gstc;
|
|
187
|
+
scrollTo = gstc.api.time.date('2020-02-20');
|
|
188
|
+
gstc.api.scrollToTime(scrollTo.valueOf());
|
|
189
|
+
})
|
|
190
|
+
.wait(Cypress.env('wait'))
|
|
191
|
+
.get('.gstc__chart-timeline-items-row-item[data-gstcid="gstcid-5"]')
|
|
192
|
+
.should('be.visible')
|
|
193
|
+
.then(($el) => {
|
|
194
|
+
const date = gstc.api.time.findDateAtTime(scrollTo.valueOf());
|
|
195
|
+
expect(round($el.position().left)).to.eq(round(date.currentView.leftPx));
|
|
196
|
+
})
|
|
197
|
+
.then(() => {
|
|
198
|
+
gstc.api.scrollToTime(scrollTo.valueOf(), false);
|
|
199
|
+
})
|
|
200
|
+
.wait(Cypress.env('wait'))
|
|
201
|
+
.get('.gstc__chart-timeline-items-row-item[data-gstcid="gstcid-5"]')
|
|
202
|
+
.should('be.visible')
|
|
203
|
+
.then(($el) => {
|
|
204
|
+
const date = gstc.api.time.findDateAtTime(scrollTo.valueOf());
|
|
205
|
+
expect(round($el.position().left)).to.eq(round(date.currentView.leftPx));
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it('should update scroll bar position and size when changing zoom', () => {
|
|
210
|
+
let gstc, state, innerSize, handlePosPx;
|
|
211
|
+
cy.load('/examples/complex-1')
|
|
212
|
+
.window()
|
|
213
|
+
.then((win) => {
|
|
214
|
+
// @ts-ignore
|
|
215
|
+
state = win.state;
|
|
216
|
+
// @ts-ignore
|
|
217
|
+
gstc = win.gstc;
|
|
218
|
+
const horizontal = state.get('$data.scroll.horizontal') as DataScrollHorizontal;
|
|
219
|
+
innerSize = horizontal.innerHandleSize;
|
|
220
|
+
expect(innerSize).to.be.greaterThan(0);
|
|
221
|
+
gstc.api.scrollToTime(gstc.api.time.date('2020-02-20'), false);
|
|
222
|
+
})
|
|
223
|
+
.wait(Cypress.env('wait'))
|
|
224
|
+
.then(() => {
|
|
225
|
+
handlePosPx = state.get('$data.scroll.horizontal.handlePosPx');
|
|
226
|
+
state.update('config.chart.time.zoom', 18);
|
|
227
|
+
})
|
|
228
|
+
.wait(Cypress.env('wait'))
|
|
229
|
+
.get('.gstc__scroll-bar-inner--horizontal')
|
|
230
|
+
.then(($scrollBarInner) => {
|
|
231
|
+
const horizontal = state.get('$data.scroll.horizontal') as DataScrollHorizontal;
|
|
232
|
+
const actualSize = horizontal.innerHandleSize;
|
|
233
|
+
expect(round(actualSize)).not.to.eq(round(innerSize));
|
|
234
|
+
expect(round(horizontal.handlePosPx)).not.to.eq(round(handlePosPx));
|
|
235
|
+
expect($scrollBarInner.get(0).offsetLeft).to.eq(Math.round(horizontal.handlePosPx));
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it('should hide scroll bar when calculatedZooMode is enabled', () => {
|
|
240
|
+
let gstc, state;
|
|
241
|
+
cy.load('/examples/complex-1')
|
|
242
|
+
.window()
|
|
243
|
+
.then((win) => {
|
|
244
|
+
// @ts-ignore
|
|
245
|
+
gstc = win.gstc;
|
|
246
|
+
// @ts-ignore
|
|
247
|
+
state = win.state;
|
|
248
|
+
})
|
|
249
|
+
.then(() => {
|
|
250
|
+
state.update('config.chart.time', (time) => {
|
|
251
|
+
time.calculatedZoomMode = true;
|
|
252
|
+
time.from = gstc.api.time.date('2020-01-01').valueOf();
|
|
253
|
+
time.to = gstc.api.time.date('2020-01-31').valueOf();
|
|
254
|
+
return time;
|
|
255
|
+
});
|
|
256
|
+
})
|
|
257
|
+
.wait(Cypress.env('wait'))
|
|
258
|
+
.get('.gstc__scroll-bar--horizontal')
|
|
259
|
+
.should('not.exist');
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('should hide scroll bar when calculatedZooMode is enabled and switching back and forth', () => {
|
|
263
|
+
let gstc, state;
|
|
264
|
+
cy.load('/examples/complex-1')
|
|
265
|
+
.window()
|
|
266
|
+
.then((win) => {
|
|
267
|
+
// @ts-ignore
|
|
268
|
+
gstc = win.gstc;
|
|
269
|
+
// @ts-ignore
|
|
270
|
+
state = win.state;
|
|
271
|
+
})
|
|
272
|
+
.then(() => {
|
|
273
|
+
state.update('config.chart.time', (time) => {
|
|
274
|
+
time.calculatedZoomMode = true;
|
|
275
|
+
time.from = gstc.api.time.date('2020-01-01').valueOf();
|
|
276
|
+
time.to = gstc.api.time.date('2020-01-31').valueOf();
|
|
277
|
+
time.zoom = 20;
|
|
278
|
+
return time;
|
|
279
|
+
});
|
|
280
|
+
})
|
|
281
|
+
.wait(Cypress.env('wait'))
|
|
282
|
+
.get('.gstc__scroll-bar--horizontal')
|
|
283
|
+
.should('not.exist')
|
|
284
|
+
.then(() => {
|
|
285
|
+
state.update('config.chart.time', (time) => {
|
|
286
|
+
time.calculatedZoomMode = false;
|
|
287
|
+
time.from = gstc.api.time.date('2020-01-01').valueOf();
|
|
288
|
+
time.to = gstc.api.time.date('2020-01-31').valueOf();
|
|
289
|
+
time.zoom = 20;
|
|
290
|
+
return time;
|
|
291
|
+
});
|
|
292
|
+
})
|
|
293
|
+
.wait(Cypress.env('wait'))
|
|
294
|
+
.get('.gstc__scroll-bar--horizontal')
|
|
295
|
+
.should('exist')
|
|
296
|
+
.then(() => {
|
|
297
|
+
state.update('config.chart.time', (time) => {
|
|
298
|
+
time.calculatedZoomMode = false;
|
|
299
|
+
time.from = gstc.api.time.date('2020-01-01').valueOf();
|
|
300
|
+
time.to = gstc.api.time.date('2020-03-31').valueOf();
|
|
301
|
+
time.zoom = 20;
|
|
302
|
+
return time;
|
|
303
|
+
});
|
|
304
|
+
})
|
|
305
|
+
.wait(Cypress.env('wait'))
|
|
306
|
+
.get('.gstc__scroll-bar--horizontal')
|
|
307
|
+
.should('exist')
|
|
308
|
+
.then(() => {
|
|
309
|
+
state.update('config.chart.time', (time) => {
|
|
310
|
+
time.calculatedZoomMode = true;
|
|
311
|
+
time.from = gstc.api.time.date('2020-01-01').valueOf();
|
|
312
|
+
time.to = gstc.api.time.date('2020-01-31').valueOf();
|
|
313
|
+
time.zoom = 20;
|
|
314
|
+
return time;
|
|
315
|
+
});
|
|
316
|
+
})
|
|
317
|
+
.wait(Cypress.env('wait'))
|
|
318
|
+
.get('.gstc__scroll-bar--horizontal')
|
|
319
|
+
.should('not.exist');
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
it('should update right global date when scroll to time centered happened', () => {
|
|
323
|
+
let gstc, state;
|
|
324
|
+
cy.load('/examples/complex-1')
|
|
325
|
+
.window()
|
|
326
|
+
.then((win) => {
|
|
327
|
+
// @ts-ignore
|
|
328
|
+
gstc = win.gstc;
|
|
329
|
+
// @ts-ignore
|
|
330
|
+
state = win.state;
|
|
331
|
+
gstc.api.scrollToTime(gstc.api.time.date('2020-02-05').valueOf());
|
|
332
|
+
})
|
|
333
|
+
.wait(Cypress.env('wait'))
|
|
334
|
+
.then(() => {
|
|
335
|
+
const dataTime: DataChartTime = state.get('$data.chart.time');
|
|
336
|
+
expect(round(dataTime.rightPx)).to.eq(round(dataTime.width));
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
it('should scroll to center', () => {
|
|
341
|
+
let gstc, state;
|
|
342
|
+
cy.load('/examples/complex-1')
|
|
343
|
+
.window()
|
|
344
|
+
.then((win) => {
|
|
345
|
+
// @ts-ignore
|
|
346
|
+
gstc = win.gstc;
|
|
347
|
+
// @ts-ignore
|
|
348
|
+
state = win.state;
|
|
349
|
+
gstc.api.scrollToTime(gstc.api.time.date('2020-02-18 12:00:00').valueOf());
|
|
350
|
+
})
|
|
351
|
+
.wait(Cypress.env('wait'))
|
|
352
|
+
.then(() => {
|
|
353
|
+
const dataTime: DataChartTime = state.get('$data.chart.time');
|
|
354
|
+
expect(dataTime.centerGlobalDate.format('YYYY-MM-DD')).to.eq('2020-02-18');
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Time } from '../../dist/api/time';
|
|
2
|
+
import { DataChartTime } from '../../dist/gstc';
|
|
3
|
+
import { round } from '../helpers';
|
|
4
|
+
|
|
5
|
+
describe('Time bookmarks', () => {
|
|
6
|
+
it('should display the bookmarks at the right positions', () => {
|
|
7
|
+
let gstc, state;
|
|
8
|
+
cy.load('/examples/one-month')
|
|
9
|
+
.window()
|
|
10
|
+
.then((win) => {
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
gstc = win.gstc;
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
state = win.state;
|
|
15
|
+
})
|
|
16
|
+
.then(() => {
|
|
17
|
+
const chartTime: DataChartTime = state.get('$data.chart.time');
|
|
18
|
+
const thirdDateLeft = round(chartTime.levels[1][2].currentView.leftPx);
|
|
19
|
+
let thirdDateFromAll;
|
|
20
|
+
for (const currentDate of chartTime.allDates[1]) {
|
|
21
|
+
if (currentDate.leftGlobalDate.format('YYYY-MM-DD') === '2020-01-03') {
|
|
22
|
+
thirdDateFromAll = currentDate;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const fromAllDates = round(thirdDateFromAll.currentView.leftPx);
|
|
27
|
+
cy.log('thirdDateFromAll', fromAllDates);
|
|
28
|
+
cy.log('thirdDateLeft width', thirdDateLeft);
|
|
29
|
+
expect(fromAllDates).to.eq(thirdDateLeft);
|
|
30
|
+
})
|
|
31
|
+
.get('.gstc__chart-time-bookmark-label-content--1-st')
|
|
32
|
+
.then(($el) => {
|
|
33
|
+
const left = round($el.parent().css('left'));
|
|
34
|
+
const time: Time = gstc.api.time;
|
|
35
|
+
const chartTime: DataChartTime = state.get('$data.chart.time');
|
|
36
|
+
const thirdDateLeft = round(chartTime.levels[1][2].currentView.leftPx);
|
|
37
|
+
const added2Days = chartTime.leftGlobalDate.startOf('day').add(2, 'day').startOf('day');
|
|
38
|
+
expect(added2Days.format('YYYY-MM-DD')).to.eq('2020-01-03');
|
|
39
|
+
const shouldLeft = round(time.getViewOffsetPxFromDates(added2Days, false, chartTime));
|
|
40
|
+
expect(added2Days.format('YYYY-MM-DD')).to.eq('2020-01-03');
|
|
41
|
+
expect(thirdDateLeft).to.eq(shouldLeft);
|
|
42
|
+
expect(chartTime.leftGlobalDate.format('YYYY-MM-DD')).to.eq('2020-01-01');
|
|
43
|
+
expect(left).to.eq(shouldLeft);
|
|
44
|
+
expect($el.text().trim()).to.eq('1-st');
|
|
45
|
+
})
|
|
46
|
+
.get('.gstc__chart-time-bookmark-label-content--bookmark-1')
|
|
47
|
+
.then(($el) => {
|
|
48
|
+
const left = round($el.parent().css('left'));
|
|
49
|
+
const time: Time = gstc.api.time;
|
|
50
|
+
const chartTime: DataChartTime = state.get('$data.chart.time');
|
|
51
|
+
const added4Days = chartTime.leftGlobalDate.startOf('day').add(4, 'day').startOf('day');
|
|
52
|
+
expect(added4Days.format('YYYY-MM-DD')).to.eq('2020-01-05');
|
|
53
|
+
const shouldLeft = round(time.getViewOffsetPxFromDates(added4Days, false, chartTime));
|
|
54
|
+
expect(added4Days.format('YYYY-MM-DD')).to.eq('2020-01-05');
|
|
55
|
+
expect(chartTime.leftGlobalDate.format('YYYY-MM-DD')).to.eq('2020-01-01');
|
|
56
|
+
expect(left).to.eq(shouldLeft);
|
|
57
|
+
expect($el.text().trim()).to.eq('Bookmark 2020-01-05');
|
|
58
|
+
})
|
|
59
|
+
.get('.gstc__chart-time-bookmark-label-content--bookmark-1')
|
|
60
|
+
.should('be.visible')
|
|
61
|
+
.get('.gstc__chart-time-bookmark-label')
|
|
62
|
+
.then(($labels) => {
|
|
63
|
+
expect($labels.length).to.eq(8);
|
|
64
|
+
})
|
|
65
|
+
.get('#btn-next-month')
|
|
66
|
+
.click()
|
|
67
|
+
.wait(300) // because on site there is setTimeout 250 to show the results
|
|
68
|
+
.get('.gstc__chart-time-bookmark-label')
|
|
69
|
+
.then(($labels) => {
|
|
70
|
+
expect($labels.length).to.eq(2);
|
|
71
|
+
})
|
|
72
|
+
.get('.gstc__chart-time-bookmark-label-content--bookmark-8')
|
|
73
|
+
.then(($el) => {
|
|
74
|
+
const left = round($el.parent().css('left'));
|
|
75
|
+
const time: Time = gstc.api.time;
|
|
76
|
+
const chartTime: DataChartTime = state.get('$data.chart.time');
|
|
77
|
+
const added1Day = chartTime.leftGlobalDate.startOf('day').add(1, 'day').startOf('day');
|
|
78
|
+
expect(added1Day.format('YYYY-MM-DD')).to.eq('2020-02-02');
|
|
79
|
+
const shouldLeft = round(time.getViewOffsetPxFromDates(added1Day, false, chartTime));
|
|
80
|
+
expect(added1Day.format('YYYY-MM-DD')).to.eq('2020-02-02');
|
|
81
|
+
expect(chartTime.leftGlobalDate.format('YYYY-MM-DD')).to.eq('2020-02-01');
|
|
82
|
+
expect(left).to.eq(shouldLeft);
|
|
83
|
+
expect($el.text().trim()).to.eq('Bookmark 2020-02-02');
|
|
84
|
+
})
|
|
85
|
+
.get('.gstc__chart-time-bookmark-line-content--bookmark-8')
|
|
86
|
+
.should('be.visible')
|
|
87
|
+
.get('.gstc__chart-time-bookmark-label-content--1-st')
|
|
88
|
+
.should('not.exist')
|
|
89
|
+
.get('.gstc__chart-time-bookmark-label-content--bookmark-1')
|
|
90
|
+
.should('not.exist');
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { DataChartTime } from '../../dist/gstc';
|
|
2
|
+
const date = '2020-01-01';
|
|
3
|
+
describe('UTC mode', () => {
|
|
4
|
+
it('should display dates according to utc mode', () => {
|
|
5
|
+
let GSTC, state;
|
|
6
|
+
cy.load('/examples/one-month')
|
|
7
|
+
.window()
|
|
8
|
+
.then((win) => {
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
GSTC = win.GSTC;
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
state = win.state;
|
|
13
|
+
})
|
|
14
|
+
.then(() => {
|
|
15
|
+
const chartTime: DataChartTime = state.get('$data.chart.time');
|
|
16
|
+
expect(chartTime.fromDate.format('YYYY-MM-DD')).to.eq(
|
|
17
|
+
chartTime.levels[1][0].leftGlobalDate.format('YYYY-MM-DD')
|
|
18
|
+
);
|
|
19
|
+
expect(GSTC.api.date(date, true).valueOf()).not.to.eq(GSTC.api.date(date).valueOf());
|
|
20
|
+
})
|
|
21
|
+
// Invalid time
|
|
22
|
+
.then(() => {
|
|
23
|
+
state.update('config.utcMode', true);
|
|
24
|
+
state.update('config.chart.time', (time) => {
|
|
25
|
+
time.from = GSTC.api.date(date).startOf('month').valueOf();
|
|
26
|
+
time.to = GSTC.api.date(date).endOf('month').valueOf();
|
|
27
|
+
return time;
|
|
28
|
+
});
|
|
29
|
+
})
|
|
30
|
+
.wait(Cypress.env('wait'))
|
|
31
|
+
.then(() => {
|
|
32
|
+
const chartTime: DataChartTime = state.get('$data.chart.time');
|
|
33
|
+
expect(chartTime.fromDate.format('YYYY-MM-DD')).not.to.eq(date);
|
|
34
|
+
})
|
|
35
|
+
// Valid time
|
|
36
|
+
.then(() => {
|
|
37
|
+
state.update('config.chart.time', (time) => {
|
|
38
|
+
time.from = GSTC.api.date(date, true).startOf('month').valueOf();
|
|
39
|
+
time.to = GSTC.api.date(date, true).endOf('month').valueOf();
|
|
40
|
+
return time;
|
|
41
|
+
});
|
|
42
|
+
})
|
|
43
|
+
.wait(Cypress.env('wait'))
|
|
44
|
+
.then(() => {
|
|
45
|
+
const chartTime: DataChartTime = state.get('$data.chart.time');
|
|
46
|
+
expect(chartTime.fromDate.format('YYYY-MM-DD')).to.eq(
|
|
47
|
+
chartTime.levels[1][0].leftGlobalDate.format('YYYY-MM-DD')
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function fixed(nr: string | number) {
|
|
2
|
+
return parseFloat(parseFloat(nr.toString()).toFixed(2));
|
|
3
|
+
}
|
|
4
|
+
export function round(nr: string | number) {
|
|
5
|
+
return Math.round(parseFloat(nr.toString()));
|
|
6
|
+
}
|
|
7
|
+
export const examples = [
|
|
8
|
+
'/examples/complex-1',
|
|
9
|
+
'/examples/item-types-plugin',
|
|
10
|
+
'/examples/add-rows-items',
|
|
11
|
+
'/examples/item-slot-html-content',
|
|
12
|
+
];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
// ***********************************************************
|
|
3
|
+
// This example plugins/index.js can be used to load plugins
|
|
4
|
+
//
|
|
5
|
+
// You can change the location of this file or turn off loading
|
|
6
|
+
// the plugins file with the 'pluginsFile' configuration option.
|
|
7
|
+
//
|
|
8
|
+
// You can read more here:
|
|
9
|
+
// https://on.cypress.io/plugins-guide
|
|
10
|
+
// ***********************************************************
|
|
11
|
+
|
|
12
|
+
// This function is called when a project is opened or re-opened (e.g. due to
|
|
13
|
+
// the project's config changing)
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @type {Cypress.PluginConfig}
|
|
17
|
+
*/
|
|
18
|
+
// eslint-disable-next-line no-unused-vars
|
|
19
|
+
export default (on, config) => {
|
|
20
|
+
// `on` is used to hook into various events Cypress emits
|
|
21
|
+
// `config` is the resolved Cypress config
|
|
22
|
+
};
|