@operato/data-grist 10.29.74 → 10.29.76
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/CHANGELOG.md +15 -0
- package/dist/src/data-card/record-card.js +1 -1
- package/dist/src/data-card/record-card.js.map +1 -1
- package/dist/src/data-grid/data-grid-field.js +18 -0
- package/dist/src/data-grid/data-grid-field.js.map +1 -1
- package/dist/src/data-list/data-list-field.js +4 -1
- package/dist/src/data-list/data-list-field.js.map +1 -1
- package/dist/src/data-list/record-partial.js +15 -1
- package/dist/src/data-list/record-partial.js.map +1 -1
- package/dist/src/filters/filter-checkbox.js +1 -1
- package/dist/src/filters/filter-checkbox.js.map +1 -1
- package/dist/src/filters/filter-input-barcode.js +1 -1
- package/dist/src/filters/filter-input-barcode.js.map +1 -1
- package/dist/src/filters/filter-input.js +1 -1
- package/dist/src/filters/filter-input.js.map +1 -1
- package/dist/src/filters/filter-range-date.js +1 -1
- package/dist/src/filters/filter-range-date.js.map +1 -1
- package/dist/src/filters/filter-range-number.js +1 -1
- package/dist/src/filters/filter-range-number.js.map +1 -1
- package/dist/src/filters/filter-select-buttons.js +1 -1
- package/dist/src/filters/filter-select-buttons.js.map +1 -1
- package/dist/src/types.d.ts +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/test/cell-button-row-height.test.ts +63 -0
- package/test/office-density.test.ts +57 -0
- package/dist/test/accessible-name.test.d.ts +0 -2
- package/dist/test/accessible-name.test.js +0 -324
- package/dist/test/accessible-name.test.js.map +0 -1
- package/dist/test/accumulator-labels.test.d.ts +0 -1
- package/dist/test/accumulator-labels.test.js +0 -32
- package/dist/test/accumulator-labels.test.js.map +0 -1
- package/dist/test/address-intents.test.d.ts +0 -1
- package/dist/test/address-intents.test.js +0 -201
- package/dist/test/address-intents.test.js.map +0 -1
- package/dist/test/card-selector.test.d.ts +0 -1
- package/dist/test/card-selector.test.js +0 -58
- package/dist/test/card-selector.test.js.map +0 -1
- package/dist/test/card-thumb.test.d.ts +0 -1
- package/dist/test/card-thumb.test.js +0 -44
- package/dist/test/card-thumb.test.js.map +0 -1
- package/dist/test/card-totals-narrow.test.d.ts +0 -1
- package/dist/test/card-totals-narrow.test.js +0 -103
- package/dist/test/card-totals-narrow.test.js.map +0 -1
- package/dist/test/column-resize.test.d.ts +0 -1
- package/dist/test/column-resize.test.js +0 -153
- package/dist/test/column-resize.test.js.map +0 -1
- package/dist/test/control-heights.test.d.ts +0 -1
- package/dist/test/control-heights.test.js +0 -25
- package/dist/test/control-heights.test.js.map +0 -1
- package/dist/test/count-handler.test.d.ts +0 -1
- package/dist/test/count-handler.test.js +0 -56
- package/dist/test/count-handler.test.js.map +0 -1
- package/dist/test/create-paste-policy.test.d.ts +0 -1
- package/dist/test/create-paste-policy.test.js +0 -159
- package/dist/test/create-paste-policy.test.js.map +0 -1
- package/dist/test/data-integrity.test.d.ts +0 -1
- package/dist/test/data-integrity.test.js +0 -145
- package/dist/test/data-integrity.test.js.map +0 -1
- package/dist/test/destructive-actions.test.d.ts +0 -11
- package/dist/test/destructive-actions.test.js +0 -147
- package/dist/test/destructive-actions.test.js.map +0 -1
- package/dist/test/edit-lifecycle.test.d.ts +0 -2
- package/dist/test/edit-lifecycle.test.js +0 -270
- package/dist/test/edit-lifecycle.test.js.map +0 -1
- package/dist/test/edit-rebase.test.d.ts +0 -1
- package/dist/test/edit-rebase.test.js +0 -185
- package/dist/test/edit-rebase.test.js.map +0 -1
- package/dist/test/editor-commit.test.d.ts +0 -2
- package/dist/test/editor-commit.test.js +0 -68
- package/dist/test/editor-commit.test.js.map +0 -1
- package/dist/test/fetch-failure-state.test.d.ts +0 -1
- package/dist/test/fetch-failure-state.test.js +0 -129
- package/dist/test/fetch-failure-state.test.js.map +0 -1
- package/dist/test/field-contains-content.test.d.ts +0 -1
- package/dist/test/field-contains-content.test.js +0 -101
- package/dist/test/field-contains-content.test.js.map +0 -1
- package/dist/test/field-hint.test.d.ts +0 -2
- package/dist/test/field-hint.test.js +0 -54
- package/dist/test/field-hint.test.js.map +0 -1
- package/dist/test/filter-labels.test.d.ts +0 -2
- package/dist/test/filter-labels.test.js +0 -140
- package/dist/test/filter-labels.test.js.map +0 -1
- package/dist/test/filter-ownership.test.d.ts +0 -1
- package/dist/test/filter-ownership.test.js +0 -83
- package/dist/test/filter-ownership.test.js.map +0 -1
- package/dist/test/filter-select-buttons-count.test.d.ts +0 -1
- package/dist/test/filter-select-buttons-count.test.js +0 -35
- package/dist/test/filter-select-buttons-count.test.js.map +0 -1
- package/dist/test/filter-typing.test.d.ts +0 -2
- package/dist/test/filter-typing.test.js +0 -66
- package/dist/test/filter-typing.test.js.map +0 -1
- package/dist/test/filters-phone-wrap.test.d.ts +0 -1
- package/dist/test/filters-phone-wrap.test.js +0 -17
- package/dist/test/filters-phone-wrap.test.js.map +0 -1
- package/dist/test/first-click-stays.test.d.ts +0 -1
- package/dist/test/first-click-stays.test.js +0 -77
- package/dist/test/first-click-stays.test.js.map +0 -1
- package/dist/test/fixed-column-opaque.test.d.ts +0 -1
- package/dist/test/fixed-column-opaque.test.js +0 -134
- package/dist/test/fixed-column-opaque.test.js.map +0 -1
- package/dist/test/flexible-columns.test.d.ts +0 -1
- package/dist/test/flexible-columns.test.js +0 -134
- package/dist/test/flexible-columns.test.js.map +0 -1
- package/dist/test/grid-single-scroller.test.d.ts +0 -1
- package/dist/test/grid-single-scroller.test.js +0 -107
- package/dist/test/grid-single-scroller.test.js.map +0 -1
- package/dist/test/group-heading.test.d.ts +0 -1
- package/dist/test/group-heading.test.js +0 -208
- package/dist/test/group-heading.test.js.map +0 -1
- package/dist/test/latest-fetch-wins.test.d.ts +0 -1
- package/dist/test/latest-fetch-wins.test.js +0 -91
- package/dist/test/latest-fetch-wins.test.js.map +0 -1
- package/dist/test/list-defaults.test.d.ts +0 -2
- package/dist/test/list-defaults.test.js +0 -145
- package/dist/test/list-defaults.test.js.map +0 -1
- package/dist/test/list-records.test.d.ts +0 -1
- package/dist/test/list-records.test.js +0 -46
- package/dist/test/list-records.test.js.map +0 -1
- package/dist/test/page-errors.d.ts +0 -1
- package/dist/test/page-errors.js +0 -44
- package/dist/test/page-errors.js.map +0 -1
- package/dist/test/paste-integrity.test.d.ts +0 -1
- package/dist/test/paste-integrity.test.js +0 -163
- package/dist/test/paste-integrity.test.js.map +0 -1
- package/dist/test/record-card-height.test.d.ts +0 -1
- package/dist/test/record-card-height.test.js +0 -15
- package/dist/test/record-card-height.test.js.map +0 -1
- package/dist/test/record-view-popup-editor.test.d.ts +0 -1
- package/dist/test/record-view-popup-editor.test.js +0 -71
- package/dist/test/record-view-popup-editor.test.js.map +0 -1
- package/dist/test/renderer-date-calendar-day.test.d.ts +0 -1
- package/dist/test/renderer-date-calendar-day.test.js +0 -48
- package/dist/test/renderer-date-calendar-day.test.js.map +0 -1
- package/dist/test/request-generation.test.d.ts +0 -1
- package/dist/test/request-generation.test.js +0 -153
- package/dist/test/request-generation.test.js.map +0 -1
- package/dist/test/resubmit.test.d.ts +0 -1
- package/dist/test/resubmit.test.js +0 -83
- package/dist/test/resubmit.test.js.map +0 -1
- package/dist/test/row-hover-visible.test.d.ts +0 -1
- package/dist/test/row-hover-visible.test.js +0 -139
- package/dist/test/row-hover-visible.test.js.map +0 -1
- package/dist/test/search-term.test.d.ts +0 -1
- package/dist/test/search-term.test.js +0 -108
- package/dist/test/search-term.test.js.map +0 -1
- package/dist/test/searchable-select.test.d.ts +0 -1
- package/dist/test/searchable-select.test.js +0 -65
- package/dist/test/searchable-select.test.js.map +0 -1
- package/dist/test/select-empty-value.test.d.ts +0 -1
- package/dist/test/select-empty-value.test.js +0 -61
- package/dist/test/select-empty-value.test.js.map +0 -1
- package/dist/test/shift-range-select.test.d.ts +0 -1
- package/dist/test/shift-range-select.test.js +0 -100
- package/dist/test/shift-range-select.test.js.map +0 -1
- package/dist/test/sparkline-renderer.test.d.ts +0 -1
- package/dist/test/sparkline-renderer.test.js +0 -36
- package/dist/test/sparkline-renderer.test.js.map +0 -1
- package/dist/test/wheel-one-scroller.test.d.ts +0 -2
- package/dist/test/wheel-one-scroller.test.js +0 -275
- package/dist/test/wheel-one-scroller.test.js.map +0 -1
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { expect, fixture } from '@open-wc/testing';
|
|
2
|
-
import { html } from 'lit';
|
|
3
|
-
import { addressController, writeAddress } from '@operato/utils/address.js';
|
|
4
|
-
import { decodeListQuery, encodeListQuery } from '@operato/utils/list-query.js';
|
|
5
|
-
import '../src/data-grist.js';
|
|
6
|
-
const turn = () => new Promise(resolve => setTimeout(resolve, 0));
|
|
7
|
-
const native = () => window.navigation;
|
|
8
|
-
const filters = (month) => [{ name: 'month', operator: 'eq', value: month }];
|
|
9
|
-
const address = (month) => `?${encodeListQuery({ filters: filters(month) })}`;
|
|
10
|
-
async function until(check) {
|
|
11
|
-
for (let i = 0; i < 200; i++) {
|
|
12
|
-
if (check())
|
|
13
|
-
return;
|
|
14
|
-
await new Promise(resolve => setTimeout(resolve, 5));
|
|
15
|
-
}
|
|
16
|
-
throw new Error('intent sequence did not settle');
|
|
17
|
-
}
|
|
18
|
-
/** Product oracle: only the latest accepted intent changes the query, records, edits or history. */
|
|
19
|
-
class Intended {
|
|
20
|
-
constructor() {
|
|
21
|
-
this.entries = [10];
|
|
22
|
-
this.cursor = 0;
|
|
23
|
-
this.edited = false;
|
|
24
|
-
this.reads = [10];
|
|
25
|
-
}
|
|
26
|
-
get month() {
|
|
27
|
-
return this.entries[this.cursor];
|
|
28
|
-
}
|
|
29
|
-
accept(month) {
|
|
30
|
-
if (month === this.month)
|
|
31
|
-
return;
|
|
32
|
-
this.entries.splice(++this.cursor);
|
|
33
|
-
this.entries.push(month);
|
|
34
|
-
this.edited = false;
|
|
35
|
-
this.reads.push(month);
|
|
36
|
-
}
|
|
37
|
-
back() {
|
|
38
|
-
this.cursor--;
|
|
39
|
-
this.edited = false;
|
|
40
|
-
this.reads.push(this.month);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
describe('overlapping user intents against query and displayed state', () => {
|
|
44
|
-
let previousOnError;
|
|
45
|
-
const resizeNotice = (event) => {
|
|
46
|
-
if (event.message.includes('ResizeObserver loop')) {
|
|
47
|
-
event.preventDefault();
|
|
48
|
-
event.stopImmediatePropagation();
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
before(() => {
|
|
52
|
-
window.addEventListener('error', resizeNotice, true);
|
|
53
|
-
previousOnError = window.onerror;
|
|
54
|
-
window.onerror = (message, ...rest) => String(message).includes('ResizeObserver loop') ? true : previousOnError === null || previousOnError === void 0 ? void 0 : previousOnError.call(window, message, ...rest);
|
|
55
|
-
});
|
|
56
|
-
after(() => {
|
|
57
|
-
window.removeEventListener('error', resizeNotice, true);
|
|
58
|
-
window.onerror = previousOnError;
|
|
59
|
-
});
|
|
60
|
-
it('checks every edit, question, refusal, supersession, adoption and browser traversal', async () => {
|
|
61
|
-
const controller = addressController();
|
|
62
|
-
controller.registerQuery();
|
|
63
|
-
const coverage = new Set();
|
|
64
|
-
for (let seed = 1; seed <= 12; seed++) {
|
|
65
|
-
await writeAddress(address(10));
|
|
66
|
-
const floorKey = native().currentEntry.key;
|
|
67
|
-
const reads = [];
|
|
68
|
-
let shown = [];
|
|
69
|
-
const grist = await fixture(html `<ox-grist
|
|
70
|
-
style="display:block;width:800px;height:400px"
|
|
71
|
-
.urlParamsSensitive=${true}
|
|
72
|
-
.config=${{ columns: [{ name: 'month', header: 'month' }], pagination: { limit: 20 } }}
|
|
73
|
-
.fetchHandler=${async ({ filters: list }) => {
|
|
74
|
-
const month = Number(list.find((filter) => filter.name === 'month').value);
|
|
75
|
-
reads.push(month);
|
|
76
|
-
return { records: [{ id: String(month), month }], total: 1 };
|
|
77
|
-
}}
|
|
78
|
-
@list-adopted=${(event) => {
|
|
79
|
-
shown = event.detail.records.map((row) => row.month);
|
|
80
|
-
}}
|
|
81
|
-
></ox-grist>`);
|
|
82
|
-
await until(() => { var _a, _b, _c; return ((_c = (_b = (_a = grist.data) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.month) === 10; });
|
|
83
|
-
const expected = new Intended();
|
|
84
|
-
// Initial configuration may make the initial read once or more; subsequent intent reads must match exactly.
|
|
85
|
-
reads.splice(0, reads.length, 10);
|
|
86
|
-
let decision;
|
|
87
|
-
let gated = false;
|
|
88
|
-
const stopGuard = controller.guard({
|
|
89
|
-
discards: () => grist.dirtyRecords.length > 0,
|
|
90
|
-
approve: change => {
|
|
91
|
-
if (!grist.dirtyRecords.length)
|
|
92
|
-
return true;
|
|
93
|
-
return new Promise(resolve => {
|
|
94
|
-
const endQuestion = gated ? controller.beginQuestion() : () => { };
|
|
95
|
-
const finish = (answer) => {
|
|
96
|
-
endQuestion();
|
|
97
|
-
resolve(answer);
|
|
98
|
-
};
|
|
99
|
-
decision = finish;
|
|
100
|
-
change.signal.addEventListener('abort', () => finish(false), { once: true });
|
|
101
|
-
});
|
|
102
|
-
},
|
|
103
|
-
committed: () => grist.reset()
|
|
104
|
-
});
|
|
105
|
-
const verify = async (step) => {
|
|
106
|
-
await turn();
|
|
107
|
-
await grist.updateComplete;
|
|
108
|
-
expect(grist.filters, step).to.deep.equal(filters(expected.month));
|
|
109
|
-
expect(grist.data.records.map(row => row.month), step).to.deep.equal([expected.month]);
|
|
110
|
-
expect(shown, step).to.deep.equal([expected.month]);
|
|
111
|
-
expect(grist.dirtyRecords.length > 0, step).to.equal(expected.edited);
|
|
112
|
-
expect(reads, step).to.deep.equal(expected.reads);
|
|
113
|
-
const entries = native().entries();
|
|
114
|
-
const floor = entries.findIndex((entry) => entry.key === floorKey);
|
|
115
|
-
expect(floor, step).to.be.at.least(0);
|
|
116
|
-
expect(entries
|
|
117
|
-
.slice(floor)
|
|
118
|
-
.map((entry) => decodeListQuery(new URL(entry.url).search).filters[0].value), step).to.deep.equal(expected.entries);
|
|
119
|
-
expect(native().currentEntry.index - floor, step).to.equal(expected.cursor);
|
|
120
|
-
};
|
|
121
|
-
let random = seed;
|
|
122
|
-
try {
|
|
123
|
-
for (let step = 0; step < 18; step++) {
|
|
124
|
-
random = (Math.imul(random, 1664525) + 1013904223) >>> 0;
|
|
125
|
-
const action = random % 5;
|
|
126
|
-
coverage.add(action);
|
|
127
|
-
const label = `seed ${seed}, step ${step}, action ${action}`;
|
|
128
|
-
const next = 20 + seed * 100 + step;
|
|
129
|
-
// Real grid edit, independent of the oracle's edit flag.
|
|
130
|
-
grist.dirtyData.records[0].__dirty__ = 'M';
|
|
131
|
-
grist.dirtyData.records[0].memo = label;
|
|
132
|
-
grist.refresh();
|
|
133
|
-
expected.edited = true;
|
|
134
|
-
await verify(label + ' edited');
|
|
135
|
-
decision = undefined;
|
|
136
|
-
gated = action !== 2 && action !== 4;
|
|
137
|
-
const first = writeAddress(address(next));
|
|
138
|
-
await turn();
|
|
139
|
-
await verify(label + ' before decision');
|
|
140
|
-
await until(() => !!decision);
|
|
141
|
-
const answerFirst = decision;
|
|
142
|
-
await verify(label + ' question pending');
|
|
143
|
-
if (action === 0) {
|
|
144
|
-
answerFirst(false);
|
|
145
|
-
expect(await first, label).to.equal(false);
|
|
146
|
-
}
|
|
147
|
-
else if (action === 1) {
|
|
148
|
-
// Requests made under a real modal question are rejected without fetching or changing the view.
|
|
149
|
-
expect(await writeAddress(address(next + 10000)), label).to.equal(false);
|
|
150
|
-
await verify(label + ' outside request refused');
|
|
151
|
-
answerFirst(true);
|
|
152
|
-
expect(await first, label).to.equal(true);
|
|
153
|
-
expected.accept(next);
|
|
154
|
-
}
|
|
155
|
-
else if (action === 2) {
|
|
156
|
-
// An asynchronous owner decision can be superseded before a dialog is installed.
|
|
157
|
-
decision = undefined;
|
|
158
|
-
const second = writeAddress(address(next + 10000));
|
|
159
|
-
await until(() => !!decision);
|
|
160
|
-
decision(true);
|
|
161
|
-
expect(await second, label).to.equal(true);
|
|
162
|
-
expected.accept(next + 10000);
|
|
163
|
-
answerFirst(true);
|
|
164
|
-
expect(await first, label).to.equal(false);
|
|
165
|
-
}
|
|
166
|
-
else if (action === 3) {
|
|
167
|
-
answerFirst(true);
|
|
168
|
-
expect(await first, label).to.equal(true);
|
|
169
|
-
expected.accept(next);
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
if (expected.cursor > 0) {
|
|
173
|
-
// Browser navigation aborts the outstanding application approval; an old yes cannot revive it.
|
|
174
|
-
decision = undefined;
|
|
175
|
-
const movement = native().back();
|
|
176
|
-
movement.finished.catch(() => { });
|
|
177
|
-
await until(() => !!decision);
|
|
178
|
-
decision(true);
|
|
179
|
-
await movement.finished;
|
|
180
|
-
expected.back();
|
|
181
|
-
answerFirst(true);
|
|
182
|
-
expect(await first, label).to.equal(false);
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
answerFirst(false);
|
|
186
|
-
expect(await first, label).to.equal(false);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
await until(() => { var _a; return ((_a = grist.data.records[0]) === null || _a === void 0 ? void 0 : _a.month) === expected.month; });
|
|
190
|
-
await verify(label + ' completed');
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
finally {
|
|
194
|
-
stopGuard();
|
|
195
|
-
grist.remove();
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
expect([...coverage].sort()).to.deep.equal([0, 1, 2, 3, 4]);
|
|
199
|
-
}).timeout(45000);
|
|
200
|
-
});
|
|
201
|
-
//# sourceMappingURL=address-intents.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"address-intents.test.js","sourceRoot":"","sources":["../../test/address-intents.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,M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C,MAAM,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;4BAC7B,QAAS,CAAC,IAAI,CAAC,CAAA;4BACf,MAAM,QAAQ,CAAC,QAAQ,CAAA;4BACvB,QAAQ,CAAC,IAAI,EAAE,CAAA;4BACf,WAAW,CAAC,IAAI,CAAC,CAAA;4BACjB,MAAM,CAAC,MAAM,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;wBAC5C,CAAC;6BAAM,CAAC;4BACN,WAAW,CAAC,KAAK,CAAC,CAAA;4BAClB,MAAM,CAAC,MAAM,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;wBAC5C,CAAC;oBACH,CAAC;oBACD,MAAM,KAAK,CAAC,GAAG,EAAE,WAAC,OAAA,CAAA,MAAA,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,0CAAE,KAAK,MAAK,QAAQ,CAAC,KAAK,CAAA,EAAA,CAAC,CAAA;oBAClE,MAAM,MAAM,CAAC,KAAK,GAAG,YAAY,CAAC,CAAA;gBACpC,CAAC;YACH,CAAC;oBAAS,CAAC;gBACT,SAAS,EAAE,CAAA;gBACX,KAAK,CAAC,MAAM,EAAE,CAAA;YAChB,CAAC;QACH,CAAC;QACD,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC7D,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AACnB,CAAC,CAAC,CAAA","sourcesContent":["import { expect, fixture } from '@open-wc/testing'\nimport { html } from 'lit'\nimport { addressController, writeAddress } from '@operato/utils/address.js'\nimport { decodeListQuery, encodeListQuery } from '@operato/utils/list-query.js'\nimport type { DataGrist } from '../src/data-grist.js'\nimport '../src/data-grist.js'\n\nconst turn = () => new Promise(resolve => setTimeout(resolve, 0))\nconst native = () => (window as any).navigation\nconst filters = (month: number) => [{ name: 'month', operator: 'eq', value: month }]\nconst address = (month: number) => `?${encodeListQuery({ filters: filters(month) })}`\nasync function until(check: () => boolean) {\n for (let i = 0; i < 200; i++) {\n if (check()) return\n await new Promise(resolve => setTimeout(resolve, 5))\n }\n throw new Error('intent sequence did not settle')\n}\n\n/** Product oracle: only the latest accepted intent changes the query, records, edits or history. */\nclass Intended {\n entries: number[] = [10]\n cursor = 0\n edited = false\n reads = [10]\n get month() {\n return this.entries[this.cursor]\n }\n accept(month: number) {\n if (month === this.month) return\n this.entries.splice(++this.cursor)\n this.entries.push(month)\n this.edited = false\n this.reads.push(month)\n }\n back() {\n this.cursor--\n this.edited = false\n this.reads.push(this.month)\n }\n}\n\ndescribe('overlapping user intents against query and displayed state', () => {\n let previousOnError: typeof window.onerror\n const resizeNotice = (event: ErrorEvent) => {\n if (event.message.includes('ResizeObserver loop')) {\n event.preventDefault()\n event.stopImmediatePropagation()\n }\n }\n before(() => {\n window.addEventListener('error', resizeNotice, true)\n previousOnError = window.onerror\n window.onerror = (message, ...rest) =>\n String(message).includes('ResizeObserver loop') ? true : previousOnError?.call(window, message, ...rest)\n })\n after(() => {\n window.removeEventListener('error', resizeNotice, true)\n window.onerror = previousOnError\n })\n it('checks every edit, question, refusal, supersession, adoption and browser traversal', async () => {\n const controller = addressController()\n controller.registerQuery()\n const coverage = new Set<number>()\n for (let seed = 1; seed <= 12; seed++) {\n await writeAddress(address(10))\n const floorKey = native().currentEntry.key\n const reads: number[] = []\n let shown: number[] = []\n const grist = await fixture<DataGrist>(\n html`<ox-grist\n style=\"display:block;width:800px;height:400px\"\n .urlParamsSensitive=${true}\n .config=${{ columns: [{ name: 'month', header: 'month' }], pagination: { limit: 20 } }}\n .fetchHandler=${async ({ filters: list }: any) => {\n const month = Number(list.find((filter: any) => filter.name === 'month').value)\n reads.push(month)\n return { records: [{ id: String(month), month }], total: 1 }\n }}\n @list-adopted=${(event: CustomEvent) => {\n shown = event.detail.records.map((row: any) => row.month)\n }}\n ></ox-grist>`\n )\n await until(() => grist.data?.records?.[0]?.month === 10)\n const expected = new Intended()\n // Initial configuration may make the initial read once or more; subsequent intent reads must match exactly.\n reads.splice(0, reads.length, 10)\n let decision: ((answer: boolean) => void) | undefined\n let gated = false\n const stopGuard = controller.guard({\n discards: () => grist.dirtyRecords.length > 0,\n approve: change => {\n if (!grist.dirtyRecords.length) return true\n return new Promise<boolean>(resolve => {\n const endQuestion = gated ? controller.beginQuestion() : () => {}\n const finish = (answer: boolean) => {\n endQuestion()\n resolve(answer)\n }\n decision = finish\n change.signal.addEventListener('abort', () => finish(false), { once: true })\n })\n },\n committed: () => grist.reset()\n })\n const verify = async (step: string) => {\n await turn()\n await grist.updateComplete\n expect(grist.filters, step).to.deep.equal(filters(expected.month))\n expect(\n grist.data.records.map(row => row.month),\n step\n ).to.deep.equal([expected.month])\n expect(shown, step).to.deep.equal([expected.month])\n expect(grist.dirtyRecords.length > 0, step).to.equal(expected.edited)\n expect(reads, step).to.deep.equal(expected.reads)\n const entries = native().entries()\n const floor = entries.findIndex((entry: any) => entry.key === floorKey)\n expect(floor, step).to.be.at.least(0)\n expect(\n entries\n .slice(floor)\n .map((entry: any) => (decodeListQuery(new URL(entry.url).search).filters as any[])[0].value),\n step\n ).to.deep.equal(expected.entries)\n expect(native().currentEntry.index - floor, step).to.equal(expected.cursor)\n }\n let random = seed\n try {\n for (let step = 0; step < 18; step++) {\n random = (Math.imul(random, 1664525) + 1013904223) >>> 0\n const action = random % 5\n coverage.add(action)\n const label = `seed ${seed}, step ${step}, action ${action}`\n const next = 20 + seed * 100 + step\n // Real grid edit, independent of the oracle's edit flag.\n grist.dirtyData.records[0].__dirty__ = 'M'\n grist.dirtyData.records[0].memo = label\n grist.refresh()\n expected.edited = true\n await verify(label + ' edited')\n decision = undefined\n gated = action !== 2 && action !== 4\n const first = writeAddress(address(next))\n await turn()\n await verify(label + ' before decision')\n await until(() => !!decision)\n const answerFirst = decision!\n await verify(label + ' question pending')\n if (action === 0) {\n answerFirst(false)\n expect(await first, label).to.equal(false)\n } else if (action === 1) {\n // Requests made under a real modal question are rejected without fetching or changing the view.\n expect(await writeAddress(address(next + 10000)), label).to.equal(false)\n await verify(label + ' outside request refused')\n answerFirst(true)\n expect(await first, label).to.equal(true)\n expected.accept(next)\n } else if (action === 2) {\n // An asynchronous owner decision can be superseded before a dialog is installed.\n decision = undefined\n const second = writeAddress(address(next + 10000))\n await until(() => !!decision)\n decision!(true)\n expect(await second, label).to.equal(true)\n expected.accept(next + 10000)\n answerFirst(true)\n expect(await first, label).to.equal(false)\n } else if (action === 3) {\n answerFirst(true)\n expect(await first, label).to.equal(true)\n expected.accept(next)\n } else {\n if (expected.cursor > 0) {\n // Browser navigation aborts the outstanding application approval; an old yes cannot revive it.\n decision = undefined\n const movement = native().back()\n movement.finished.catch(() => {})\n await until(() => !!decision)\n decision!(true)\n await movement.finished\n expected.back()\n answerFirst(true)\n expect(await first, label).to.equal(false)\n } else {\n answerFirst(false)\n expect(await first, label).to.equal(false)\n }\n }\n await until(() => grist.data.records[0]?.month === expected.month)\n await verify(label + ' completed')\n }\n } finally {\n stopGuard()\n grist.remove()\n }\n }\n expect([...coverage].sort()).to.deep.equal([0, 1, 2, 3, 4])\n }).timeout(45000)\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '../src/data-grist.js';
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/* Elements are compared by presence, not by value: a failing element comparison makes chai render the DOM and hang the runner. */
|
|
2
|
-
import { expect, fixture } from '@open-wc/testing';
|
|
3
|
-
import { html } from 'lit';
|
|
4
|
-
import '../src/data-grist.js';
|
|
5
|
-
import { failOnPageErrors } from './page-errors.js';
|
|
6
|
-
/*
|
|
7
|
-
* A card's checkbox stands beside the title. It sat in the action row under the text, a line of its own far from
|
|
8
|
-
* what it selects (Office ledgers on a phone, 2026-11-05).
|
|
9
|
-
*/
|
|
10
|
-
const records = [{ id: '1', title: 'one', amount: 990000 }];
|
|
11
|
-
const config = (gutters) => ({
|
|
12
|
-
columns: [
|
|
13
|
-
...gutters,
|
|
14
|
-
{ type: 'string', name: 'title', header: 'title' },
|
|
15
|
-
{ type: 'integer', name: 'amount', header: 'amount' }
|
|
16
|
-
],
|
|
17
|
-
rows: { appendable: false, selectable: { multiple: true } },
|
|
18
|
-
list: { fields: ['title'], details: ['amount'] }
|
|
19
|
-
});
|
|
20
|
-
const idle = async (el) => {
|
|
21
|
-
while (!((await el.updateComplete) && (await el.grist.updateComplete)))
|
|
22
|
-
;
|
|
23
|
-
};
|
|
24
|
-
const cardOf = async (gutters) => {
|
|
25
|
-
const el = await fixture(html `<ox-grist style="width:340px;height:300px" mode="CARD" .config=${config(gutters)} .data=${{ records }}></ox-grist>`);
|
|
26
|
-
await idle(el);
|
|
27
|
-
const card = el.grist.renderRoot.querySelector('ox-record-card');
|
|
28
|
-
await card.updateComplete;
|
|
29
|
-
return card;
|
|
30
|
-
};
|
|
31
|
-
describe('a card and its checkbox', () => {
|
|
32
|
-
failOnPageErrors();
|
|
33
|
-
it('stands in the top-right corner, on the title line, and takes no row of its own', async () => {
|
|
34
|
-
const card = await cardOf([{ type: 'gutter', gutterName: 'row-selector', multiple: true, forList: true }]);
|
|
35
|
-
const box = card.renderRoot.querySelector('ox-card-gutter');
|
|
36
|
-
const title = card.renderRoot.querySelector('ox-card-field[name]');
|
|
37
|
-
const detail = card.renderRoot.querySelector('[detail]');
|
|
38
|
-
expect(box, 'no checkbox').to.exist;
|
|
39
|
-
const cardBox = card.getBoundingClientRect();
|
|
40
|
-
const boxRect = box.getBoundingClientRect();
|
|
41
|
-
const titleRect = title.getBoundingClientRect();
|
|
42
|
-
expect(boxRect.top, 'the checkbox is not on the title line').to.be.below(titleRect.bottom);
|
|
43
|
-
expect(cardBox.right - boxRect.right, 'the checkbox is not at the right edge').to.be.below(16);
|
|
44
|
-
expect(titleRect.right, 'the title runs under the checkbox').to.be.at.most(boxRect.left);
|
|
45
|
-
expect(cardBox.bottom - detail.getBoundingClientRect().bottom, 'the card keeps a row under its text').to.be.below(16);
|
|
46
|
-
expect(card.renderRoot.querySelector('[gutters]'), 'an empty action row').to.equal(null);
|
|
47
|
-
});
|
|
48
|
-
it('leaves the other gutters in the action row', async () => {
|
|
49
|
-
const card = await cardOf([
|
|
50
|
-
{ type: 'gutter', gutterName: 'row-selector', multiple: true, forList: true },
|
|
51
|
-
{ type: 'gutter', gutterName: 'button', icon: 'edit', forList: true }
|
|
52
|
-
]);
|
|
53
|
-
const row = card.renderRoot.querySelector('[gutters]');
|
|
54
|
-
expect(row, 'no action row').to.exist;
|
|
55
|
-
expect(row.querySelectorAll('ox-card-gutter').length).to.equal(1);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
//# sourceMappingURL=card-selector.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"card-selector.test.js","sourceRoot":"","sources":["../../test/card-selector.test.ts"],"names":[],"mappings":"AAAA,kIAAkI;AAClI,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAE1B,OAAO,sBAAsB,CAAA;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEnD;;;GAGG;AAEH,MAAM,OAAO,GAAG,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;AAC3D,MAAM,MAAM,GAAG,CAAC,OAAc,EAAE,EAAE,CAAC,CAAC;IAClC,OAAO,EAAE;QACP,GAAG,OAAO;QACV,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAA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C,EAAE,KAAK,IAAI,EAAE;QAC1D,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC;YACxB,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;YAC7E,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE;SACtE,CAAC,CAAA;QACF,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAgB,CAAA;QACrE,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,KAAK,CAAA;QACrC,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACnE,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["/* Elements are compared by presence, not by value: a failing element comparison makes chai render the DOM and hang the runner. */\nimport { expect, fixture } from '@open-wc/testing'\nimport { html } from 'lit'\n\nimport '../src/data-grist.js'\nimport { DataGrist } from '../src/data-grist.js'\nimport { failOnPageErrors } from './page-errors.js'\n\n/*\n * A card's checkbox stands beside the title. It sat in the action row under the text, a line of its own far from\n * what it selects (Office ledgers on a phone, 2026-11-05).\n */\n\nconst records = [{ id: '1', title: 'one', amount: 990000 }]\nconst config = (gutters: any[]) => ({\n columns: [\n ...gutters,\n { type: 'string', name: 'title', header: 'title' },\n { type: 'integer', name: 'amount', header: 'amount' }\n ],\n rows: { appendable: false, selectable: { multiple: true } },\n list: { fields: ['title'], details: ['amount'] }\n})\n\nconst idle = async (el: DataGrist) => {\n while (!((await el.updateComplete) && (await el.grist.updateComplete)));\n}\n\nconst cardOf = async (gutters: any[]) => {\n const el = await fixture<DataGrist>(\n html`<ox-grist style=\"width:340px;height:300px\" mode=\"CARD\" .config=${config(gutters)} .data=${{ records }}></ox-grist>`\n )\n await idle(el)\n const card = el.grist.renderRoot.querySelector('ox-record-card') as any\n await card.updateComplete\n return card as HTMLElement & { renderRoot: ShadowRoot }\n}\n\ndescribe('a card and its checkbox', () => {\n failOnPageErrors()\n\n it('stands in the top-right corner, on the title line, and takes no row of its own', async () => {\n const card = await cardOf([{ type: 'gutter', gutterName: 'row-selector', multiple: true, forList: true }])\n const box = card.renderRoot.querySelector('ox-card-gutter') as HTMLElement\n const title = card.renderRoot.querySelector('ox-card-field[name]') as HTMLElement\n const detail = card.renderRoot.querySelector('[detail]') as HTMLElement\n expect(box, 'no checkbox').to.exist\n\n const cardBox = card.getBoundingClientRect()\n const boxRect = box.getBoundingClientRect()\n const titleRect = title.getBoundingClientRect()\n expect(boxRect.top, 'the checkbox is not on the title line').to.be.below(titleRect.bottom)\n expect(cardBox.right - boxRect.right, 'the checkbox is not at the right edge').to.be.below(16)\n expect(titleRect.right, 'the title runs under the checkbox').to.be.at.most(boxRect.left)\n expect(cardBox.bottom - detail.getBoundingClientRect().bottom, 'the card keeps a row under its text').to.be.below(16)\n expect(card.renderRoot.querySelector('[gutters]'), 'an empty action row').to.equal(null)\n })\n\n it('leaves the other gutters in the action row', async () => {\n const card = await cardOf([\n { type: 'gutter', gutterName: 'row-selector', multiple: true, forList: true },\n { type: 'gutter', gutterName: 'button', icon: 'edit', forList: true }\n ])\n const row = card.renderRoot.querySelector('[gutters]') as HTMLElement\n expect(row, 'no action row').to.exist\n expect(row.querySelectorAll('ox-card-gutter').length).to.equal(1)\n })\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '../src/data-card/ox-card-thumb.js';
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { expect, fixture, html } from '@open-wc/testing';
|
|
2
|
-
import '../src/data-card/ox-card-thumb.js';
|
|
3
|
-
/*
|
|
4
|
-
* The one picture cell of a catalog card (ADR-0117 amendment 2026-10-13): the picture whole, an icon when there is
|
|
5
|
-
* none, at most one marker in the top-left corner, and a seam under it.
|
|
6
|
-
*/
|
|
7
|
-
describe('ox-card-thumb', () => {
|
|
8
|
-
it('★ shows the picture whole, never cropped, with a seam under it', async () => {
|
|
9
|
-
const thumb = await fixture(html `<ox-card-thumb
|
|
10
|
-
style="--md-sys-color-outline-variant: rgb(200, 200, 200)"
|
|
11
|
-
src="data:image/gif;base64,R0lGODlhAQABAAAAACw="
|
|
12
|
-
alt="a board"
|
|
13
|
-
></ox-card-thumb>`);
|
|
14
|
-
const img = thumb.shadowRoot.querySelector('img');
|
|
15
|
-
expect(img.getAttribute('alt')).to.equal('a board');
|
|
16
|
-
expect(getComputedStyle(img).objectFit).to.equal('contain');
|
|
17
|
-
expect(getComputedStyle(thumb).borderBottomStyle).to.equal('solid');
|
|
18
|
-
expect(thumb.shadowRoot.querySelector('[empty]')).to.equal(null);
|
|
19
|
-
});
|
|
20
|
-
it('★ draws its icon when there is no picture, or the empty slot when one is given', async () => {
|
|
21
|
-
const bare = await fixture(html `<ox-card-thumb icon="dashboard"></ox-card-thumb>`);
|
|
22
|
-
expect(bare.shadowRoot.querySelector('[empty] md-icon').textContent).to.equal('dashboard');
|
|
23
|
-
const marked = await fixture(html `<ox-card-thumb><span slot="empty" id="mark">no picture</span></ox-card-thumb>`);
|
|
24
|
-
const slot = marked.shadowRoot.querySelector('slot[name="empty"]');
|
|
25
|
-
expect(slot.assignedElements().map(e => e.id)).to.deep.equal(['mark']);
|
|
26
|
-
});
|
|
27
|
-
it('★ says one thing in the corner, in its tone, and nothing when there is nothing to say', async () => {
|
|
28
|
-
const quiet = await fixture(html `<ox-card-thumb></ox-card-thumb>`);
|
|
29
|
-
expect(quiet.shadowRoot.querySelector('[badge]')).to.equal(null);
|
|
30
|
-
const warned = await fixture(html `<ox-card-thumb badge="not latest" tone="warn"></ox-card-thumb>`);
|
|
31
|
-
const badge = warned.shadowRoot.querySelector('[badge]');
|
|
32
|
-
expect(badge.textContent).to.equal('not latest');
|
|
33
|
-
expect(badge.getAttribute('tone')).to.equal('warn');
|
|
34
|
-
expect(getComputedStyle(badge).position).to.equal('absolute');
|
|
35
|
-
expect(getComputedStyle(badge).top).to.equal('6px');
|
|
36
|
-
expect(getComputedStyle(badge).left).to.equal('6px');
|
|
37
|
-
});
|
|
38
|
-
it('lays the default slot over the picture for an action that belongs to it', async () => {
|
|
39
|
-
const thumb = await fixture(html `<ox-card-thumb><button id="del">x</button></ox-card-thumb>`);
|
|
40
|
-
const slot = thumb.shadowRoot.querySelector('slot:not([name])');
|
|
41
|
-
expect(slot.assignedElements().map(e => e.id)).to.deep.equal(['del']);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
//# sourceMappingURL=card-thumb.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"card-thumb.test.js","sourceRoot":"","sources":["../../test/card-thumb.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAExD,OAAO,mCAAmC,CAAA;AAG1C;;;GAGG;AACH,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,gEAAgE,EAAE,KAAK,IAAI,EAAE;QAC9E,MAAM,KAAK,GAAG,MAAM,OAAO,CAAc,IAAI,CAAA;;;;wBAIzB,CAAC,CAAA;QACrB,MAAM,GAAG,GAAG,KAAK,CAAC,UAAW,CAAC,aAAa,CAAC,KAAK,CAAE,CAAA;QACnD,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;QACnD,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;QAC3D,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,iBAAiB,CAAC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ACxE,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;QAChD,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QACnD,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;QAC7D,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACnD,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACtD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,yEAAyE,EAAE,KAAK,IAAI,EAAE;QACvF,MAAM,KAAK,GAAG,MAAM,OAAO,CAAc,IAAI,CAAA,4DAA4D,CAAC,CAAA;QAC1G,MAAM,IAAI,GAAG,KAAK,CAAC,UAAW,CAAC,aAAa,CAAC,kBAAkB,CAAoB,CAAA;QACnF,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;IACvE,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { expect, fixture, html } from '@open-wc/testing'\n\nimport '../src/data-card/ox-card-thumb.js'\nimport type { OxCardThumb } from '../src/data-card/ox-card-thumb.js'\n\n/*\n * The one picture cell of a catalog card (ADR-0117 amendment 2026-10-13): the picture whole, an icon when there is\n * none, at most one marker in the top-left corner, and a seam under it.\n */\ndescribe('ox-card-thumb', () => {\n it('★ shows the picture whole, never cropped, with a seam under it', async () => {\n const thumb = await fixture<OxCardThumb>(html`<ox-card-thumb\n style=\"--md-sys-color-outline-variant: rgb(200, 200, 200)\"\n src=\"data:image/gif;base64,R0lGODlhAQABAAAAACw=\"\n alt=\"a board\"\n ></ox-card-thumb>`)\n const img = thumb.shadowRoot!.querySelector('img')!\n expect(img.getAttribute('alt')).to.equal('a board')\n expect(getComputedStyle(img).objectFit).to.equal('contain')\n expect(getComputedStyle(thumb).borderBottomStyle).to.equal('solid')\n expect(thumb.shadowRoot!.querySelector('[empty]')).to.equal(null)\n })\n\n it('★ draws its icon when there is no picture, or the empty slot when one is given', async () => {\n const bare = await fixture<OxCardThumb>(html`<ox-card-thumb icon=\"dashboard\"></ox-card-thumb>`)\n expect(bare.shadowRoot!.querySelector('[empty] md-icon')!.textContent).to.equal('dashboard')\n\n const marked = await fixture<OxCardThumb>(html`<ox-card-thumb><span slot=\"empty\" id=\"mark\">no picture</span></ox-card-thumb>`)\n const slot = marked.shadowRoot!.querySelector('slot[name=\"empty\"]') as HTMLSlotElement\n expect(slot.assignedElements().map(e => e.id)).to.deep.equal(['mark'])\n })\n\n it('★ says one thing in the corner, in its tone, and nothing when there is nothing to say', async () => {\n const quiet = await fixture<OxCardThumb>(html`<ox-card-thumb></ox-card-thumb>`)\n expect(quiet.shadowRoot!.querySelector('[badge]')).to.equal(null)\n\n const warned = await fixture<OxCardThumb>(html`<ox-card-thumb badge=\"not latest\" tone=\"warn\"></ox-card-thumb>`)\n const badge = warned.shadowRoot!.querySelector('[badge]') as HTMLElement\n expect(badge.textContent).to.equal('not latest')\n expect(badge.getAttribute('tone')).to.equal('warn')\n expect(getComputedStyle(badge).position).to.equal('absolute')\n expect(getComputedStyle(badge).top).to.equal('6px')\n expect(getComputedStyle(badge).left).to.equal('6px')\n })\n\n it('lays the default slot over the picture for an action that belongs to it', async () => {\n const thumb = await fixture<OxCardThumb>(html`<ox-card-thumb><button id=\"del\">x</button></ox-card-thumb>`)\n const slot = thumb.shadowRoot!.querySelector('slot:not([name])') as HTMLSlotElement\n expect(slot.assignedElements().map(e => e.id)).to.deep.equal(['del'])\n })\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '../src/data-grist.js';
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/* Elements are compared by presence, not by value: a failing element comparison makes chai render the DOM and hang the runner. */
|
|
2
|
-
import { expect, fixture } from '@open-wc/testing';
|
|
3
|
-
import { html } from 'lit';
|
|
4
|
-
import '../src/data-grist.js';
|
|
5
|
-
import { failOnPageErrors } from './page-errors.js';
|
|
6
|
-
/*
|
|
7
|
-
* A report read on a phone (2026-11-06). The grid's totals row is drawn as a totals card after the cards, and a
|
|
8
|
-
* grist with a narrow mode draws it while its own width is under narrowWidth - a table on a wide screen, cards on a
|
|
9
|
-
* phone, from one config.
|
|
10
|
-
*/
|
|
11
|
-
const records = [
|
|
12
|
-
{ id: '1', name: 'one', shares: 15250, since: '2020-01-01' },
|
|
13
|
-
{ id: '2', name: 'two', shares: 5600, since: '2026-03-17' }
|
|
14
|
-
];
|
|
15
|
-
const config = (accumulator) => ({
|
|
16
|
-
columns: [
|
|
17
|
-
{ type: 'string', name: 'name', header: 'Name' },
|
|
18
|
-
{ type: 'integer', name: 'shares', header: 'Shares', accumulator: 'sum' }
|
|
19
|
-
],
|
|
20
|
-
rows: { appendable: false, editable: false, selectable: false, accumulator },
|
|
21
|
-
list: { fields: ['name'], details: ['shares'] }
|
|
22
|
-
});
|
|
23
|
-
const idle = async (el) => {
|
|
24
|
-
while (!((await el.updateComplete) && (await el.grist.updateComplete)))
|
|
25
|
-
;
|
|
26
|
-
};
|
|
27
|
-
const frame = (width) => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
28
|
-
describe('a card list and its totals', () => {
|
|
29
|
-
failOnPageErrors();
|
|
30
|
-
it('draws the totals card after the cards, each total naming its column', async () => {
|
|
31
|
-
const el = await fixture(html `<ox-grist style="width:340px;height:400px" mode="CARD" .config=${config(true)} .data=${{ records }}></ox-grist>`);
|
|
32
|
-
await idle(el);
|
|
33
|
-
const totals = el.grist.renderRoot.querySelector('[totals]');
|
|
34
|
-
expect(totals, 'no totals card').to.exist;
|
|
35
|
-
const shares = totals.querySelector('[total="shares"]');
|
|
36
|
-
expect(shares.querySelector('label').textContent).to.equal('Shares');
|
|
37
|
-
expect(shares.textContent).to.contain('20850');
|
|
38
|
-
expect(totals.querySelector('[total="name"]'), 'a column with no accumulator is totalled').to.equal(null);
|
|
39
|
-
const cards = el.grist.renderRoot.querySelectorAll('ox-record-card');
|
|
40
|
-
expect(totals.getBoundingClientRect().top, 'the totals stand above a card').to.be.at.least(cards[cards.length - 1].getBoundingClientRect().bottom);
|
|
41
|
-
});
|
|
42
|
-
it('draws no totals card when the rows do not accumulate', async () => {
|
|
43
|
-
const el = await fixture(html `<ox-grist style="width:340px;height:400px" mode="CARD" .config=${config(false)} .data=${{ records }}></ox-grist>`);
|
|
44
|
-
await idle(el);
|
|
45
|
-
expect(el.grist.renderRoot.querySelector('[totals]')).to.equal(null);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
describe('a grist with a narrow mode', () => {
|
|
49
|
-
failOnPageErrors();
|
|
50
|
-
it('draws its mode when wide and its narrow mode when narrow, by its own width', async () => {
|
|
51
|
-
const el = await fixture(html `<ox-grist style="display:flex;width:900px;height:400px" mode="GRID" narrow-mode="CARD" .config=${config(true)} .data=${{ records }}></ox-grist>`);
|
|
52
|
-
await frame(0);
|
|
53
|
-
await idle(el);
|
|
54
|
-
expect(el.shownMode).to.equal('GRID');
|
|
55
|
-
expect(el.renderRoot.querySelector('ox-grid'), 'not a grid while wide').to.exist;
|
|
56
|
-
el.style.width = '340px';
|
|
57
|
-
await frame(0);
|
|
58
|
-
await idle(el);
|
|
59
|
-
expect(el.shownMode).to.equal('CARD');
|
|
60
|
-
expect(el.renderRoot.querySelector('ox-card'), 'not cards while narrow').to.exist;
|
|
61
|
-
expect(el.mode, 'the requested mode was overwritten').to.equal('GRID');
|
|
62
|
-
el.style.width = '900px';
|
|
63
|
-
await frame(0);
|
|
64
|
-
await idle(el);
|
|
65
|
-
expect(el.renderRoot.querySelector('ox-grid'), 'not a grid again once wide').to.exist;
|
|
66
|
-
});
|
|
67
|
-
it('keeps its mode at every width when no narrow mode is set', async () => {
|
|
68
|
-
const el = await fixture(html `<ox-grist style="display:flex;width:340px;height:400px" mode="GRID" .config=${config(true)} .data=${{ records }}></ox-grist>`);
|
|
69
|
-
await frame(0);
|
|
70
|
-
await idle(el);
|
|
71
|
-
expect(el.renderRoot.querySelector('ox-grid')).to.exist;
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
describe('a card detail with a label', () => {
|
|
75
|
-
failOnPageErrors();
|
|
76
|
-
it('keeps the label whole when details stand in a row', async () => {
|
|
77
|
-
const labelled = {
|
|
78
|
-
...config(false),
|
|
79
|
-
columns: [
|
|
80
|
-
{ type: 'string', name: 'name', header: 'Name' },
|
|
81
|
-
{ type: 'string', name: 'since', header: 'Since', label: { renderer: () => '취득일' } }
|
|
82
|
-
],
|
|
83
|
-
list: { fields: ['name'], details: ['since'] }
|
|
84
|
-
};
|
|
85
|
-
const el = await fixture(html `<ox-grist style="width:340px;height:400px;font-size:13px;--data-card-detail-direction:row;--data-card-item-etc-label-font:400 11.5px sans-serif" mode="CARD" .config=${labelled} .data=${{ records }}></ox-grist>`);
|
|
86
|
-
await idle(el);
|
|
87
|
-
const card = el.grist.renderRoot.querySelector('ox-record-card');
|
|
88
|
-
const field = card.renderRoot.querySelector('[detail] ox-card-field');
|
|
89
|
-
const label = field.renderRoot.querySelector('label');
|
|
90
|
-
expect(label.scrollWidth, 'the label is cut').to.be.at.most(label.clientWidth);
|
|
91
|
-
const range = document.createRange();
|
|
92
|
-
range.setStartAfter(label);
|
|
93
|
-
range.setEnd(field.renderRoot, field.renderRoot.childNodes.length);
|
|
94
|
-
const words = document.createRange();
|
|
95
|
-
words.selectNodeContents(label);
|
|
96
|
-
expect(range.getBoundingClientRect().left - words.getBoundingClientRect().right, 'the label touches its value').to.be.at.least(4);
|
|
97
|
-
const value = Array.from(field.renderRoot.children).find(child => child !== label && child.tagName !== 'STYLE');
|
|
98
|
-
const text = document.createRange();
|
|
99
|
-
text.selectNodeContents(value);
|
|
100
|
-
expect(value.getBoundingClientRect().width, 'the value is cut').to.be.at.least(text.getBoundingClientRect().width - 0.01);
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
//# sourceMappingURL=card-totals-narrow.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"card-totals-narrow.test.js","sourceRoot":"","sources":["../../test/card-totals-narrow.test.ts"],"names":[],"mappings":"AAAA,kIAAkI;AAClI,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAE1B,OAAO,sBAAsB,CAAA;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEnD;;;;GAIG;AAEH,MAAM,OAAO,GAAG;IACd,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE;IAC5D,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE;CAC5D,CAAA;AACD,MAAM,MAAM,GAAG,CAAC,WAAoB,EAAE,EAAE,CAAC,CAAC;IACxC,OAAO,EAAE;QACP,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;QAChD,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE;KAC1E;IACD,IAAI,EAA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,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;QAC9E,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAA;QACpC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;QAC1B,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;QAClE,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAA;QACpC,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAA;QAC/B,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,IAAI,GAAG,KAAK,CAAC,qBAAqB,EAAE,CAAC,KAAK,EAAE,6BAA6B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QACjI,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,KAAK,IAAI,KAAK,CAAC,OAAO,KAAK,OAAO,CAAgB,CAAA;QAC9H,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAA;QACnC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAA;QAC9B,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,CAAA;IAC3H,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["/* Elements are compared by presence, not by value: a failing element comparison makes chai render the DOM and hang the runner. */\nimport { expect, fixture } from '@open-wc/testing'\nimport { html } from 'lit'\n\nimport '../src/data-grist.js'\nimport { DataGrist } from '../src/data-grist.js'\nimport { failOnPageErrors } from './page-errors.js'\n\n/*\n * A report read on a phone (2026-11-06). The grid's totals row is drawn as a totals card after the cards, and a\n * grist with a narrow mode draws it while its own width is under narrowWidth - a table on a wide screen, cards on a\n * phone, from one config.\n */\n\nconst records = [\n { id: '1', name: 'one', shares: 15250, since: '2020-01-01' },\n { id: '2', name: 'two', shares: 5600, since: '2026-03-17' }\n]\nconst config = (accumulator: boolean) => ({\n columns: [\n { type: 'string', name: 'name', header: 'Name' },\n { type: 'integer', name: 'shares', header: 'Shares', accumulator: 'sum' }\n ],\n rows: { appendable: false, editable: false, selectable: false, accumulator },\n list: { fields: ['name'], details: ['shares'] }\n})\n\nconst idle = async (el: DataGrist) => {\n while (!((await el.updateComplete) && (await el.grist.updateComplete)));\n}\n\nconst frame = (width: number) => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))\n\ndescribe('a card list and its totals', () => {\n failOnPageErrors()\n\n it('draws the totals card after the cards, each total naming its column', async () => {\n const el = await fixture<DataGrist>(\n html`<ox-grist style=\"width:340px;height:400px\" mode=\"CARD\" .config=${config(true)} .data=${{ records }}></ox-grist>`\n )\n await idle(el)\n const totals = el.grist.renderRoot.querySelector('[totals]') as HTMLElement\n expect(totals, 'no totals card').to.exist\n const shares = totals.querySelector('[total=\"shares\"]') as HTMLElement\n expect(shares.querySelector('label')!.textContent).to.equal('Shares')\n expect(shares.textContent).to.contain('20850')\n expect(totals.querySelector('[total=\"name\"]'), 'a column with no accumulator is totalled').to.equal(null)\n\n const cards = el.grist.renderRoot.querySelectorAll('ox-record-card')\n expect(totals.getBoundingClientRect().top, 'the totals stand above a card').to.be.at.least(cards[cards.length - 1].getBoundingClientRect().bottom)\n })\n\n it('draws no totals card when the rows do not accumulate', async () => {\n const el = await fixture<DataGrist>(\n html`<ox-grist style=\"width:340px;height:400px\" mode=\"CARD\" .config=${config(false)} .data=${{ records }}></ox-grist>`\n )\n await idle(el)\n expect(el.grist.renderRoot.querySelector('[totals]')).to.equal(null)\n })\n})\n\ndescribe('a grist with a narrow mode', () => {\n failOnPageErrors()\n\n it('draws its mode when wide and its narrow mode when narrow, by its own width', async () => {\n const el = await fixture<DataGrist>(\n html`<ox-grist style=\"display:flex;width:900px;height:400px\" mode=\"GRID\" narrow-mode=\"CARD\" .config=${config(true)} .data=${{ records }}></ox-grist>`\n )\n await frame(0)\n await idle(el)\n expect(el.shownMode).to.equal('GRID')\n expect(el.renderRoot.querySelector('ox-grid'), 'not a grid while wide').to.exist\n\n el.style.width = '340px'\n await frame(0)\n await idle(el)\n expect(el.shownMode).to.equal('CARD')\n expect(el.renderRoot.querySelector('ox-card'), 'not cards while narrow').to.exist\n expect(el.mode, 'the requested mode was overwritten').to.equal('GRID')\n\n el.style.width = '900px'\n await frame(0)\n await idle(el)\n expect(el.renderRoot.querySelector('ox-grid'), 'not a grid again once wide').to.exist\n })\n\n it('keeps its mode at every width when no narrow mode is set', async () => {\n const el = await fixture<DataGrist>(\n html`<ox-grist style=\"display:flex;width:340px;height:400px\" mode=\"GRID\" .config=${config(true)} .data=${{ records }}></ox-grist>`\n )\n await frame(0)\n await idle(el)\n expect(el.renderRoot.querySelector('ox-grid')).to.exist\n })\n})\n\ndescribe('a card detail with a label', () => {\n failOnPageErrors()\n\n it('keeps the label whole when details stand in a row', async () => {\n const labelled = {\n ...config(false),\n columns: [\n { type: 'string', name: 'name', header: 'Name' },\n { type: 'string', name: 'since', header: 'Since', label: { renderer: () => '취득일' } }\n ],\n list: { fields: ['name'], details: ['since'] }\n }\n const el = await fixture<DataGrist>(\n html`<ox-grist style=\"width:340px;height:400px;font-size:13px;--data-card-detail-direction:row;--data-card-item-etc-label-font:400 11.5px sans-serif\" mode=\"CARD\" .config=${labelled} .data=${{ records }}></ox-grist>`\n )\n await idle(el)\n const card = el.grist.renderRoot.querySelector('ox-record-card') as any\n const field = card.renderRoot.querySelector('[detail] ox-card-field') as HTMLElement & { renderRoot: ShadowRoot }\n const label = field.renderRoot.querySelector('label') as HTMLElement\n expect(label.scrollWidth, 'the label is cut').to.be.at.most(label.clientWidth)\n const range = document.createRange()\n range.setStartAfter(label)\n range.setEnd(field.renderRoot, field.renderRoot.childNodes.length)\n const words = document.createRange()\n words.selectNodeContents(label)\n expect(range.getBoundingClientRect().left - words.getBoundingClientRect().right, 'the label touches its value').to.be.at.least(4)\n const value = Array.from(field.renderRoot.children).find(child => child !== label && child.tagName !== 'STYLE') as HTMLElement\n const text = document.createRange()\n text.selectNodeContents(value)\n expect(value.getBoundingClientRect().width, 'the value is cut').to.be.at.least(text.getBoundingClientRect().width - 0.01)\n })\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '../src/data-grist.js';
|