@operato/data-grist 10.29.77 → 10.29.79
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 +26 -0
- package/dist/src/data-card/record-card.d.ts +4 -0
- package/dist/src/data-card/record-card.js +62 -20
- package/dist/src/data-card/record-card.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-date.d.ts +2 -0
- package/dist/src/editors/ox-grist-editor-date.js +3 -8
- package/dist/src/editors/ox-grist-editor-date.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-month.d.ts +2 -0
- package/dist/src/editors/ox-grist-editor-month.js +3 -1
- package/dist/src/editors/ox-grist-editor-month.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-week.d.ts +2 -0
- package/dist/src/editors/ox-grist-editor-week.js +3 -1
- package/dist/src/editors/ox-grist-editor-week.js.map +1 -1
- package/dist/src/editors/ox-grist-editor.js +2 -1
- package/dist/src/editors/ox-grist-editor.js.map +1 -1
- package/dist/src/filters/filter-input.d.ts +1 -0
- package/dist/src/filters/filter-input.js +20 -0
- package/dist/src/filters/filter-input.js.map +1 -1
- package/dist/src/filters/filter-range-date.d.ts +7 -0
- package/dist/src/filters/filter-range-date.js +53 -0
- package/dist/src/filters/filter-range-date.js.map +1 -1
- package/dist/src/filters/filter-select-buttons.js +7 -0
- package/dist/src/filters/filter-select-buttons.js.map +1 -1
- package/dist/src/filters/filter-styles.js +8 -2
- package/dist/src/filters/filter-styles.js.map +1 -1
- package/dist/src/filters/filters-form.js +38 -14
- package/dist/src/filters/filters-form.js.map +1 -1
- package/dist/src/filters/pill-choice.d.ts +24 -0
- package/dist/src/filters/pill-choice.js +63 -0
- package/dist/src/filters/pill-choice.js.map +1 -0
- package/dist/test/accessible-name.test.js +324 -0
- package/dist/test/accessible-name.test.js.map +1 -0
- package/dist/test/accumulator-labels.test.d.ts +1 -0
- package/dist/test/accumulator-labels.test.js +32 -0
- package/dist/test/accumulator-labels.test.js.map +1 -0
- package/dist/test/address-intents.test.js +201 -0
- package/dist/test/address-intents.test.js.map +1 -0
- package/dist/test/card-selector.test.js +71 -0
- package/dist/test/card-selector.test.js.map +1 -0
- package/dist/test/card-thumb.test.d.ts +1 -0
- package/dist/test/card-thumb.test.js +44 -0
- package/dist/test/card-thumb.test.js.map +1 -0
- package/dist/test/card-totals-narrow.test.js +103 -0
- package/dist/test/card-totals-narrow.test.js.map +1 -0
- package/dist/test/cell-button-row-height.test.js +53 -0
- package/dist/test/cell-button-row-height.test.js.map +1 -0
- package/dist/test/column-resize.test.js +153 -0
- package/dist/test/column-resize.test.js.map +1 -0
- package/dist/test/control-heights.test.js +25 -0
- package/dist/test/control-heights.test.js.map +1 -0
- package/dist/test/count-handler.test.js +56 -0
- package/dist/test/count-handler.test.js.map +1 -0
- package/dist/test/create-paste-policy.test.js +159 -0
- package/dist/test/create-paste-policy.test.js.map +1 -0
- package/dist/test/data-integrity.test.js +145 -0
- package/dist/test/data-integrity.test.js.map +1 -0
- package/dist/test/date-fields.test.d.ts +2 -0
- package/dist/test/date-fields.test.js +138 -0
- package/dist/test/date-fields.test.js.map +1 -0
- package/dist/test/destructive-actions.test.js +147 -0
- package/dist/test/destructive-actions.test.js.map +1 -0
- package/dist/test/edit-lifecycle.test.js +270 -0
- package/dist/test/edit-lifecycle.test.js.map +1 -0
- package/dist/test/edit-rebase.test.js +185 -0
- package/dist/test/edit-rebase.test.js.map +1 -0
- package/dist/test/editor-commit.test.js +68 -0
- package/dist/test/editor-commit.test.js.map +1 -0
- package/dist/test/fetch-failure-state.test.js +129 -0
- package/dist/test/fetch-failure-state.test.js.map +1 -0
- package/dist/test/field-contains-content.test.js +101 -0
- package/dist/test/field-contains-content.test.js.map +1 -0
- package/dist/test/field-hint.test.js +54 -0
- package/dist/test/field-hint.test.js.map +1 -0
- package/dist/test/filter-labels.test.js +140 -0
- package/dist/test/filter-labels.test.js.map +1 -0
- package/dist/test/filter-ownership.test.js +83 -0
- package/dist/test/filter-ownership.test.js.map +1 -0
- package/dist/test/filter-select-buttons-count.test.js +36 -0
- package/dist/test/filter-select-buttons-count.test.js.map +1 -0
- package/dist/test/filter-typing.test.js +66 -0
- package/dist/test/filter-typing.test.js.map +1 -0
- package/dist/test/filters-phone-width.test.d.ts +1 -0
- package/dist/test/filters-phone-width.test.js +33 -0
- package/dist/test/filters-phone-width.test.js.map +1 -0
- package/dist/test/filters-phone-wrap.test.js +17 -0
- package/dist/test/filters-phone-wrap.test.js.map +1 -0
- package/dist/test/filters-pills.test.d.ts +2 -0
- package/dist/test/filters-pills.test.js +149 -0
- package/dist/test/filters-pills.test.js.map +1 -0
- package/dist/test/first-click-stays.test.js +77 -0
- package/dist/test/first-click-stays.test.js.map +1 -0
- package/dist/test/fixed-column-opaque.test.js +134 -0
- package/dist/test/fixed-column-opaque.test.js.map +1 -0
- package/dist/test/flexible-columns.test.js +134 -0
- package/dist/test/flexible-columns.test.js.map +1 -0
- package/dist/test/grid-single-scroller.test.js +107 -0
- package/dist/test/grid-single-scroller.test.js.map +1 -0
- package/dist/test/group-heading.test.js +208 -0
- package/dist/test/group-heading.test.js.map +1 -0
- package/dist/test/latest-fetch-wins.test.js +91 -0
- package/dist/test/latest-fetch-wins.test.js.map +1 -0
- package/dist/test/list-defaults.test.js +146 -0
- package/dist/test/list-defaults.test.js.map +1 -0
- package/dist/test/list-records.test.js +46 -0
- package/dist/test/list-records.test.js.map +1 -0
- package/dist/test/office-density.test.js +52 -0
- package/dist/test/office-density.test.js.map +1 -0
- package/dist/test/page-errors.d.ts +1 -0
- package/dist/test/page-errors.js +44 -0
- package/dist/test/page-errors.js.map +1 -0
- package/dist/test/paste-integrity.test.js +163 -0
- package/dist/test/paste-integrity.test.js.map +1 -0
- package/dist/test/record-card-height.test.js +15 -0
- package/dist/test/record-card-height.test.js.map +1 -0
- package/dist/test/record-view-popup-editor.test.js +71 -0
- package/dist/test/record-view-popup-editor.test.js.map +1 -0
- package/dist/test/renderer-date-calendar-day.test.js +48 -0
- package/dist/test/renderer-date-calendar-day.test.js.map +1 -0
- package/dist/test/request-generation.test.js +153 -0
- package/dist/test/request-generation.test.js.map +1 -0
- package/dist/test/resubmit.test.js +83 -0
- package/dist/test/resubmit.test.js.map +1 -0
- package/dist/test/row-hover-visible.test.js +139 -0
- package/dist/test/row-hover-visible.test.js.map +1 -0
- package/dist/test/search-term.test.js +108 -0
- package/dist/test/search-term.test.js.map +1 -0
- package/dist/test/searchable-select.test.js +65 -0
- package/dist/test/searchable-select.test.js.map +1 -0
- package/dist/test/select-empty-value.test.js +61 -0
- package/dist/test/select-empty-value.test.js.map +1 -0
- package/dist/test/shift-range-select.test.js +100 -0
- package/dist/test/shift-range-select.test.js.map +1 -0
- package/dist/test/sparkline-renderer.test.js +36 -0
- package/dist/test/sparkline-renderer.test.js.map +1 -0
- package/dist/test/wheel-one-scroller.test.js +275 -0
- package/dist/test/wheel-one-scroller.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/test/card-selector.test.ts +18 -4
- package/test/date-fields.test.ts +163 -0
- package/test/filter-select-buttons-count.test.ts +2 -1
- package/test/filters-phone-width.test.ts +35 -0
- package/test/filters-pills.test.ts +162 -0
- package/test/list-defaults.test.ts +2 -1
- package/translations/en.json +8 -1
- package/translations/es.json +8 -1
- package/translations/ja.json +8 -1
- package/translations/ko.json +8 -1
- package/translations/ms.json +8 -1
- package/translations/zh.json +8 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-records.test.js","sourceRoot":"","sources":["../../test/list-records.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,OA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E,GAAG,MAAM,OAAO,CACtB,IAAI,CAAA,wCAAwC,IAAI,YAAY,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,EAAE,cAAc,CAC/G,CAAA;YACD,MAAM,IAAI,CAAC,EAAE,CAAC,CAAA;YACd,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;QAC1C,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,sDAAsD,EAAE,KAAK,IAAI,EAAE;YACpE,MAAM,EAAE,GAAG,MAAM,OAAO,CACtB,IAAI,CAAA,wCAAwC,IAAI,YAAY,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,EAAE,cAAc,CAC/G,CAAA;YACD,MAAM,IAAI,CAAC,EAAE,CAAC,CAAA;YACd,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;YAC7B,MAAM,IAAI,CAAC,EAAE,CAAC,CAAA;YACd,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;QAC1C,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC","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 list or card shows the records of its data, whenever its config arrives. The grist hands the data over at once\n * and the compiled config a render later - and a personal config loads later still - so a list that emptied itself\n * on a config change showed nothing until the next fetch (2026-10-26).\n */\n\nconst records = [\n { id: '1', title: 'one' },\n { id: '2', title: 'two' }\n]\nconst config = (header: string) => ({\n columns: [{ type: 'string', name: 'title', header, record: { editable: true } }],\n rows: { appendable: false },\n list: { fields: ['title'] }\n})\n\n/* `updateComplete` resolves false while an update set another one going. */\nconst idle = async (el: DataGrist) => {\n while (!((await el.updateComplete) && (await el.grist.updateComplete)));\n}\n\nfor (const [mode, tag] of [\n ['LIST', 'ox-record-partial'],\n ['CARD', 'ox-record-card']\n] as const) {\n describe(`a ${mode} and its config`, () => {\n failOnPageErrors()\n\n const shown = (el: DataGrist) =>\n Array.from(el.grist.renderRoot.querySelectorAll(tag) as NodeListOf<any>).map(item => item.record.title)\n\n it('shows the records it was given with its config', async () => {\n const el = await fixture<DataGrist>(\n html`<ox-grist style=\"height:300px\" .mode=${mode} .config=${config('title')} .data=${{ records }}></ox-grist>`\n )\n await idle(el)\n expect(shown(el)).to.eql(['one', 'two'])\n })\n\n it('keeps its records when the config changes after them', async () => {\n const el = await fixture<DataGrist>(\n html`<ox-grist style=\"height:300px\" .mode=${mode} .config=${config('title')} .data=${{ records }}></ox-grist>`\n )\n await idle(el)\n el.config = config('renamed')\n await idle(el)\n expect(shown(el)).to.eql(['one', 'two'])\n })\n })\n}\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { expect, fixture, html } from '@open-wc/testing';
|
|
2
|
+
import { setViewport } from '@web/test-runner-commands';
|
|
3
|
+
import '../src/data-grist.js';
|
|
4
|
+
const idle = async (el) => {
|
|
5
|
+
while (!((await el.updateComplete) && (await el.grist.updateComplete)))
|
|
6
|
+
;
|
|
7
|
+
await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
8
|
+
};
|
|
9
|
+
const rows = [{ id: 'one', title: '첫 업무', description: '긴 업무 설명을 충분한 너비로 읽을 수 있어야 합니다.' }];
|
|
10
|
+
const config = (button) => ({
|
|
11
|
+
columns: [
|
|
12
|
+
...(button ? [{ type: 'gutter', gutterName: 'button', icon: 'edit', title: '상세', forList: true }] : []),
|
|
13
|
+
{ type: 'string', name: 'title', header: '제목', width: 'minmax(220px, 1fr)' },
|
|
14
|
+
{ type: 'string', name: 'description', header: '설명', width: 220 },
|
|
15
|
+
...(button ? [{ type: 'string', name: 'action', header: '', width: 40, record: { renderer: () => html `<button class="icon" aria-label="열기">↗</button>` } }] : [])
|
|
16
|
+
],
|
|
17
|
+
rows: { appendable: false, editable: false, selectable: false },
|
|
18
|
+
list: { fields: ['title'], details: ['description'] }
|
|
19
|
+
});
|
|
20
|
+
async function make(mode, button) {
|
|
21
|
+
const el = await fixture(html `<ox-grist style="width:100%;height:240px;--grid-record-padding:4px 8px;--spacing-medium:8px;--spacing-small:4px;--spacing-tiny:2px;--cell-action-height:26px" .mode=${mode} .config=${config(button)} .data=${{ records: rows }}></ox-grist>`);
|
|
22
|
+
await idle(el);
|
|
23
|
+
return el;
|
|
24
|
+
}
|
|
25
|
+
describe('Office density regression', () => {
|
|
26
|
+
afterEach(async () => setViewport({ width: 800, height: 600 }));
|
|
27
|
+
it('an action gutter does not enlarge the grid row on desktop or phone', async () => {
|
|
28
|
+
for (const width of [1440, 375]) {
|
|
29
|
+
await setViewport({ width, height: 812 });
|
|
30
|
+
const plain = await make('GRID', false);
|
|
31
|
+
const action = await make('GRID', true);
|
|
32
|
+
const field = (el) => el.grist.renderRoot.querySelector('ox-grid-body').renderRoot.querySelector('ox-grid-field');
|
|
33
|
+
expect(field(action).getBoundingClientRect().height).to.equal(field(plain).getBoundingClientRect().height);
|
|
34
|
+
expect(field(action).getBoundingClientRect().height).to.be.at.most(32);
|
|
35
|
+
const body = action.grist.renderRoot.querySelector('ox-grid-body');
|
|
36
|
+
const buttonCell = Array.from(body.renderRoot.querySelectorAll('ox-grid-field')).find((cell) => cell.renderRoot.querySelector('button.icon'));
|
|
37
|
+
expect(buttonCell.renderRoot.querySelector('button.icon').getBoundingClientRect().height).to.equal(26);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
it('a phone list gives its text a full line and puts actions below it', async () => {
|
|
41
|
+
await setViewport({ width: 375, height: 812 });
|
|
42
|
+
const el = await make('LIST', true);
|
|
43
|
+
const row = el.grist.renderRoot.querySelector('ox-record-partial');
|
|
44
|
+
await row.updateComplete;
|
|
45
|
+
const content = row.renderRoot.querySelector('[content]');
|
|
46
|
+
const action = row.renderRoot.querySelector('ox-list-gutter');
|
|
47
|
+
expect(content.getBoundingClientRect().width).to.be.above(320);
|
|
48
|
+
expect(action.getBoundingClientRect().top).to.be.at.least(content.getBoundingClientRect().bottom);
|
|
49
|
+
expect(row.scrollWidth).to.be.at.most(row.clientWidth);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=office-density.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"office-density.test.js","sourceRoot":"","sources":["../../test/office-density.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,sBAAsB,CAAA;AAG7B,MAAM,IAAI,GAAG,KAAK,EAAE,EAAa,EAAE,EAAE;IACnC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAAC,CAAC;IACxE,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,qBAAqB,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAC3F,CAAC,CAAA;AAED,MAAM,IAAI,GAAG,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC,CAAA;AAC1F,MAAM,MAAM,GAAG,CAAC,MAAe,EAAE,EAAE,CAAC,CAAC;IACnC,OAAO,EAAE;QACP,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ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,CAAC,UAAU,CAAC,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,qBAAqB,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QACxG,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,mEAAmE,EAAE,KAAK,IAAI,EAAE;QACjF,MAAM,WAAW,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;QAC9C,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QACnC,MAAM,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,mBAAmB,CAAQ,CAAA;QACzE,MAAM,GAAG,CAAC,cAAc,CAAA;QACxB,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAgB,CAAA;QACxE,MAAM,MAAM,GAAG,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,gBAAgB,CAAgB,CAAA;QAC5E,MAAM,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAC9D,MAAM,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,MAAM,CAAC,CAAA;QACjG,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;IACxD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { expect, fixture, html } from '@open-wc/testing'\nimport { setViewport } from '@web/test-runner-commands'\nimport '../src/data-grist.js'\nimport type { DataGrist } from '../src/data-grist.js'\n\nconst idle = async (el: DataGrist) => {\n while (!((await el.updateComplete) && (await el.grist.updateComplete)));\n await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))\n}\n\nconst rows = [{ id: 'one', title: '첫 업무', description: '긴 업무 설명을 충분한 너비로 읽을 수 있어야 합니다.' }]\nconst config = (button: boolean) => ({\n columns: [\n ...(button ? [{ type: 'gutter', gutterName: 'button', icon: 'edit', title: '상세', forList: true }] : []),\n { type: 'string', name: 'title', header: '제목', width: 'minmax(220px, 1fr)' },\n { type: 'string', name: 'description', header: '설명', width: 220 },\n ...(button ? [{ type: 'string', name: 'action', header: '', width: 40, record: { renderer: () => html`<button class=\"icon\" aria-label=\"열기\">↗</button>` } }] : [])\n ],\n rows: { appendable: false, editable: false, selectable: false },\n list: { fields: ['title'], details: ['description'] }\n})\n\nasync function make(mode: string, button: boolean) {\n const el = await fixture<DataGrist>(html`<ox-grist style=\"width:100%;height:240px;--grid-record-padding:4px 8px;--spacing-medium:8px;--spacing-small:4px;--spacing-tiny:2px;--cell-action-height:26px\" .mode=${mode} .config=${config(button)} .data=${{records: rows}}></ox-grist>`)\n await idle(el)\n return el\n}\n\ndescribe('Office density regression', () => {\n afterEach(async () => setViewport({ width: 800, height: 600 }))\n\n it('an action gutter does not enlarge the grid row on desktop or phone', async () => {\n for (const width of [1440, 375]) {\n await setViewport({ width, height: 812 })\n const plain = await make('GRID', false)\n const action = await make('GRID', true)\n const field = (el: DataGrist) => (el.grist.renderRoot.querySelector('ox-grid-body') as any).renderRoot.querySelector('ox-grid-field') as HTMLElement\n expect(field(action).getBoundingClientRect().height).to.equal(field(plain).getBoundingClientRect().height)\n expect(field(action).getBoundingClientRect().height).to.be.at.most(32)\n const body = action.grist.renderRoot.querySelector('ox-grid-body') as any\n const buttonCell = Array.from(body.renderRoot.querySelectorAll('ox-grid-field')).find((cell: any) => cell.renderRoot.querySelector('button.icon')) as any\n expect(buttonCell.renderRoot.querySelector('button.icon').getBoundingClientRect().height).to.equal(26)\n }\n })\n\n it('a phone list gives its text a full line and puts actions below it', async () => {\n await setViewport({ width: 375, height: 812 })\n const el = await make('LIST', true)\n const row = el.grist.renderRoot.querySelector('ox-record-partial') as any\n await row.updateComplete\n const content = row.renderRoot.querySelector('[content]') as HTMLElement\n const action = row.renderRoot.querySelector('ox-list-gutter') as HTMLElement\n expect(content.getBoundingClientRect().width).to.be.above(320)\n expect(action.getBoundingClientRect().top).to.be.at.least(content.getBoundingClientRect().bottom)\n expect(row.scrollWidth).to.be.at.most(row.clientWidth)\n })\n})\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function failOnPageErrors(): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Fail a test when the page throws while it runs - a render exception or a rejected promise nobody awaited. The
|
|
3
|
+
* runner only logs those as 「thrown outside a test」 and the test still passes. The browser's ResizeObserver loop
|
|
4
|
+
* notice is not an error of the page.
|
|
5
|
+
*/
|
|
6
|
+
export function failOnPageErrors() {
|
|
7
|
+
const errors = [];
|
|
8
|
+
const benign = (message) => message.includes('ResizeObserver loop');
|
|
9
|
+
const onError = (e) => {
|
|
10
|
+
var _a;
|
|
11
|
+
if (benign(String(e.message))) {
|
|
12
|
+
e.stopImmediatePropagation();
|
|
13
|
+
e.preventDefault();
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
errors.push(String(((_a = e.error) === null || _a === void 0 ? void 0 : _a.stack) || e.message));
|
|
17
|
+
};
|
|
18
|
+
const onRejection = (e) => {
|
|
19
|
+
var _a;
|
|
20
|
+
errors.push(String(((_a = e.reason) === null || _a === void 0 ? void 0 : _a.stack) || e.reason));
|
|
21
|
+
};
|
|
22
|
+
let previousOnError = null;
|
|
23
|
+
before(() => {
|
|
24
|
+
window.addEventListener('error', onError, true);
|
|
25
|
+
window.addEventListener('unhandledrejection', onRejection);
|
|
26
|
+
previousOnError = window.onerror;
|
|
27
|
+
window.onerror = (message, ...rest) => benign(String(message)) ? true : previousOnError === null || previousOnError === void 0 ? void 0 : previousOnError.call(window, message, ...rest);
|
|
28
|
+
});
|
|
29
|
+
after(() => {
|
|
30
|
+
window.removeEventListener('error', onError, true);
|
|
31
|
+
window.removeEventListener('unhandledrejection', onRejection);
|
|
32
|
+
window.onerror = previousOnError;
|
|
33
|
+
});
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
errors.length = 0;
|
|
36
|
+
});
|
|
37
|
+
afterEach(async () => {
|
|
38
|
+
/* Let renders the test started finish, so their errors land in this test. */
|
|
39
|
+
await new Promise(resolve => setTimeout(resolve, 50));
|
|
40
|
+
if (errors.length)
|
|
41
|
+
throw new Error(`the page threw while the test ran:\n${errors.join('\n')}`);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=page-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-errors.js","sourceRoot":"","sources":["../../test/page-errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,MAAM,MAAM,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAA;IAE3E,MAAM,OAAO,GAAG,CAAC,CAAa,EAAE,EAAE;;QAChC,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;YAC9B,CAAC,CAAC,wBAAwB,EAAE,CAAA;YAC5B,CAAC,CAAC,cAAc,EAAE,CAAA;YAClB,OAAM;QACR,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,MAAA,CAAC,CAAC,KAAK,0CAAE,KAAK,KAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;IAClD,CAAC,CAAA;IACD,MAAM,WAAW,GAAG,CAAC,CAAwB,EAAE,EAA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C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAChG,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["/*\n * Fail a test when the page throws while it runs - a render exception or a rejected promise nobody awaited. The\n * runner only logs those as 「thrown outside a test」 and the test still passes. The browser's ResizeObserver loop\n * notice is not an error of the page.\n */\nexport function failOnPageErrors() {\n const errors: string[] = []\n const benign = (message: string) => message.includes('ResizeObserver loop')\n\n const onError = (e: ErrorEvent) => {\n if (benign(String(e.message))) {\n e.stopImmediatePropagation()\n e.preventDefault()\n return\n }\n errors.push(String(e.error?.stack || e.message))\n }\n const onRejection = (e: PromiseRejectionEvent) => {\n errors.push(String(e.reason?.stack || e.reason))\n }\n let previousOnError: OnErrorEventHandler = null\n\n before(() => {\n window.addEventListener('error', onError, true)\n window.addEventListener('unhandledrejection', onRejection)\n previousOnError = window.onerror\n window.onerror = (message, ...rest) =>\n benign(String(message)) ? true : previousOnError?.call(window, message, ...rest)\n })\n after(() => {\n window.removeEventListener('error', onError, true)\n window.removeEventListener('unhandledrejection', onRejection)\n window.onerror = previousOnError\n })\n beforeEach(() => {\n errors.length = 0\n })\n afterEach(async () => {\n /* Let renders the test started finish, so their errors land in this test. */\n await new Promise(resolve => setTimeout(resolve, 50))\n if (errors.length) throw new Error(`the page threw while the test ran:\\n${errors.join('\\n')}`)\n })\n}\n"]}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { expect, fixture } from '@open-wc/testing';
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import '../src/data-grist.js';
|
|
4
|
+
import { DataGridBody } from '../src/data-grid/data-grid-body.js';
|
|
5
|
+
import { OxGristEditorNumber } from '../src/editors/ox-grist-editor-number.js';
|
|
6
|
+
import { failOnPageErrors } from './page-errors.js';
|
|
7
|
+
/* The clipboard holds `text` as `mime` while `run` reads it. */
|
|
8
|
+
async function withClipboard(mime, text, run) {
|
|
9
|
+
const previous = Object.getOwnPropertyDescriptor(navigator, 'clipboard');
|
|
10
|
+
Object.defineProperty(navigator, 'clipboard', { configurable: true, value: {
|
|
11
|
+
read: async () => [{ getType: async (requested) => {
|
|
12
|
+
if (requested !== mime)
|
|
13
|
+
throw Error('no type');
|
|
14
|
+
return new Blob([text], { type: mime });
|
|
15
|
+
} }]
|
|
16
|
+
} });
|
|
17
|
+
try {
|
|
18
|
+
return await run();
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
if (previous)
|
|
22
|
+
Object.defineProperty(navigator, 'clipboard', previous);
|
|
23
|
+
else
|
|
24
|
+
delete navigator.clipboard;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/* What a paste sends, read off a body that only records its field changes. */
|
|
28
|
+
async function paste(mime, text, type = 'number', options = {}) {
|
|
29
|
+
var _a, _b, _d;
|
|
30
|
+
const changes = [];
|
|
31
|
+
const body = {
|
|
32
|
+
focused: { row: (_a = options.row) !== null && _a !== void 0 ? _a : 0, column: 0 }, data: { records: options.records || [{ id: 'a', value: 1 }] },
|
|
33
|
+
columns: [{ name: 'value', type, record: { editable: (_b = options.editable) !== null && _b !== void 0 ? _b : true } }],
|
|
34
|
+
config: { rows: { appendable: (_d = options.appendable) !== null && _d !== void 0 ? _d : false } }, appendRecord: { __dirty__: '+' },
|
|
35
|
+
pasteTargets: DataGridBody.prototype.pasteTargets,
|
|
36
|
+
resetEdit() { }, focus() { }, dispatchEvent(e) { changes.push(e.detail); }
|
|
37
|
+
};
|
|
38
|
+
await withClipboard(mime, text, () => DataGridBody.prototype.paste.call(body));
|
|
39
|
+
return { body, changes };
|
|
40
|
+
}
|
|
41
|
+
const source = (mime, values) => mime === 'text/html'
|
|
42
|
+
? `<table>${values.map(value => `<tr><td>${value}</td></tr>`).join('')}</table>`
|
|
43
|
+
: values.join('\n');
|
|
44
|
+
describe('paste and input data contracts', () => {
|
|
45
|
+
for (const mime of ['text/html', 'text/plain']) {
|
|
46
|
+
for (const [type, input, expected] of [
|
|
47
|
+
['number', 'abc', 'abc'], ['number', '1,200', '1,200'],
|
|
48
|
+
['number', ' ', null], ['number', 'Infinity', 'Infinity'],
|
|
49
|
+
['number', '12.5', 12.5], ['integer', '12.5', 12], ['integer', '-1.5', -2],
|
|
50
|
+
['boolean', 'false', false], ['checkbox', 'true', true], ['number', '0', 0]
|
|
51
|
+
]) {
|
|
52
|
+
it(`${mime} parses ${type} ${input}`, async () => {
|
|
53
|
+
const { changes } = await paste(mime, source(mime, [input]), type);
|
|
54
|
+
expect(changes[0].after).to.equal(expected);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/* A blank cell clears an existing row's field and leaves a new row's to its default; id 0 is an existing row. */
|
|
58
|
+
for (const [type, input, records, row, expected] of [
|
|
59
|
+
['number', ' ', [{ id: 0, value: 1 }], 0, null],
|
|
60
|
+
['string', ' ', [{ id: 'a', value: 'x' }], 1, undefined],
|
|
61
|
+
['number', ' ', [{ id: 'a', value: 1 }], 1, undefined],
|
|
62
|
+
['select', ' ', [{ id: 'a', value: 1 }], 1, undefined]
|
|
63
|
+
]) {
|
|
64
|
+
it(`${mime} pastes a blank ${type} into ${row ? 'a new' : 'an existing'} row as ${expected}`, async () => {
|
|
65
|
+
const { changes } = await paste(mime, source(mime, [input]), type, { records, row, appendable: true });
|
|
66
|
+
expect(changes).to.have.length(1);
|
|
67
|
+
expect(changes[0].after).to.equal(expected);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
it(`${mime} passes the destination row to editable`, async () => {
|
|
71
|
+
const seen = [];
|
|
72
|
+
await paste(mime, source(mime, ['1', '2']), 'number', {
|
|
73
|
+
records: [{ id: 'a' }, { id: 'b' }],
|
|
74
|
+
editable: (_v, _c, _r, row) => { seen.push(row); return true; }
|
|
75
|
+
});
|
|
76
|
+
expect(seen).to.eql([0, 1]);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
it('integer IME input uses the same conversion as the number editor', () => {
|
|
80
|
+
let after;
|
|
81
|
+
const column = { name: 'value', type: 'integer', record: { editable: true } };
|
|
82
|
+
const body = { _imeBuffer: { value: '12.5' }, _resetIMEBuffer() { }, columns: [column],
|
|
83
|
+
data: { records: [{ value: 1 }] }, dispatchEvent(e) { after = e.detail.after; } };
|
|
84
|
+
DataGridBody.prototype._commitIMEBuffer.call(body, 0, 0);
|
|
85
|
+
const expected = OxGristEditorNumber.prototype.formatFromEditor.call({ column }, '12.5');
|
|
86
|
+
expect(after).to.equal(expected);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
/* Pasting into a rendered grid: the rows that end up in the grid, through its own field-change handling. */
|
|
90
|
+
describe('paste into a grid', () => {
|
|
91
|
+
failOnPageErrors();
|
|
92
|
+
const mount = async (options) => {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
const el = await fixture(html `<ox-grist
|
|
95
|
+
style="height:300px"
|
|
96
|
+
.config=${{
|
|
97
|
+
columns: [
|
|
98
|
+
{ name: 'amount', type: 'number', header: 'amount', record: { editable: (_a = options.editable) !== null && _a !== void 0 ? _a : true }, validation: options.validation },
|
|
99
|
+
{ name: 'memo', type: 'string', header: 'memo', record: { editable: (_b = options.editable) !== null && _b !== void 0 ? _b : true } }
|
|
100
|
+
],
|
|
101
|
+
rows: { appendable: options.appendable }
|
|
102
|
+
}}
|
|
103
|
+
.data=${{ records: [{ id: 'a', amount: 1, memo: 'kept' }] }}
|
|
104
|
+
></ox-grist>`);
|
|
105
|
+
await el.updateComplete;
|
|
106
|
+
await el.grist.updateComplete;
|
|
107
|
+
return el;
|
|
108
|
+
};
|
|
109
|
+
const bodyOf = (el) => el.grist.renderRoot.querySelector('ox-grid-body');
|
|
110
|
+
const pasteAt = async (el, row, mime, text, column = 0) => {
|
|
111
|
+
const body = bodyOf(el);
|
|
112
|
+
body.focused = { row, column };
|
|
113
|
+
await withClipboard(mime, text, () => body.paste());
|
|
114
|
+
await el.updateComplete;
|
|
115
|
+
};
|
|
116
|
+
const table = (mime, rows) => mime === 'text/html'
|
|
117
|
+
? `<table>${rows.map(cells => `<tr>${cells.map(cell => `<td>${cell}</td>`).join('')}</tr>`).join('')}</table>`
|
|
118
|
+
: rows.map(cells => cells.join('\t')).join('\n');
|
|
119
|
+
const rows = (el) => el.grist.data.records.map(({ amount, memo }) => ({ amount, memo }));
|
|
120
|
+
for (const mime of ['text/html', 'text/plain']) {
|
|
121
|
+
it(`${mime} stops at the last row when rows cannot be appended`, async () => {
|
|
122
|
+
const el = await mount({ appendable: false });
|
|
123
|
+
await pasteAt(el, 0, mime, table(mime, [['2', 'x'], ['3', 'y']]));
|
|
124
|
+
expect(rows(el)).to.eql([{ amount: 2, memo: 'x' }]);
|
|
125
|
+
});
|
|
126
|
+
it(`${mime} appends new rows in order`, async () => {
|
|
127
|
+
const el = await mount({ appendable: true });
|
|
128
|
+
await pasteAt(el, 1, mime, table(mime, [['2', 'x'], ['3', 'y']]));
|
|
129
|
+
expect(rows(el)).to.eql([{ amount: 1, memo: 'kept' }, { amount: 2, memo: 'x' }, { amount: 3, memo: 'y' }]);
|
|
130
|
+
});
|
|
131
|
+
it(`${mime} adds no row for read-only cells`, async () => {
|
|
132
|
+
const el = await mount({ appendable: true, editable: false });
|
|
133
|
+
await pasteAt(el, 1, mime, table(mime, [['2', 'x']]));
|
|
134
|
+
expect(el.grist.data.records).to.have.length(1);
|
|
135
|
+
});
|
|
136
|
+
it(`${mime} adds no row for a blank new row`, async () => {
|
|
137
|
+
const el = await mount({ appendable: true });
|
|
138
|
+
await pasteAt(el, 1, mime, table(mime, [[' ', ' '], ['4', 'z']]));
|
|
139
|
+
expect(rows(el)).to.eql([{ amount: 1, memo: 'kept' }, { amount: 4, memo: 'z' }]);
|
|
140
|
+
expect(el.dirtyRecords).to.have.length(1);
|
|
141
|
+
});
|
|
142
|
+
it(`${mime} keeps a new row's cells together while one is being validated`, async () => {
|
|
143
|
+
let resolve;
|
|
144
|
+
const el = await mount({ appendable: true, validation: () => new Promise(done => (resolve = done)) });
|
|
145
|
+
await pasteAt(el, 1, mime, table(mime, [['5', 'w']]));
|
|
146
|
+
resolve(true);
|
|
147
|
+
await new Promise(done => setTimeout(done));
|
|
148
|
+
expect(rows(el)).to.eql([{ amount: 1, memo: 'kept' }, { amount: 5, memo: 'w' }]);
|
|
149
|
+
});
|
|
150
|
+
it(`${mime} into the append row and a key typed into it while the paste is validated make one row`, async () => {
|
|
151
|
+
let resolve;
|
|
152
|
+
const el = await mount({ appendable: true, validation: () => new Promise(done => (resolve = done)) });
|
|
153
|
+
await pasteAt(el, 1, mime, table(mime, [['5']]));
|
|
154
|
+
const body = bodyOf(el);
|
|
155
|
+
body._imeBuffer.value = 'typed';
|
|
156
|
+
body._commitIMEBuffer(1, 1);
|
|
157
|
+
resolve(true);
|
|
158
|
+
await new Promise(done => setTimeout(done));
|
|
159
|
+
expect(rows(el)).to.eql([{ amount: 1, memo: 'kept' }, { amount: 5, memo: 'typed' }]);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
//# sourceMappingURL=paste-integrity.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paste-integrity.test.js","sourceRoot":"","sources":["../../test/paste-integrity.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAE1B,OAAO,sBAAsB,CAAA;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAA;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEnD,gEAAgE;AAChE,KAAK,UAAU,aAAa,CAAI,IAAY,EAAE,IAAY,EAAE,GAAqB;IAC/E,MAAM,QAAQ,GAAG,MAAM,CAAC,wBAAwB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;IACxE,MAAM,CAAC,cAAc,CAAC,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,CAAA;QAClF,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,GAAG,IAAI,wFAAwF,EAAE,KAAK,IAAI,EAAE;YAC7G,IAAI,OAAkC,CAAA;YACtC,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAA;YACrG,MAAM,OAAO,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;YAChD,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,CAAA;YACvB,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,OAAO,CAAA;YAC/B,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YAC3B,OAAO,CAAC,IAAI,CAAC,CAAA;YACb,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAA;YAC3C,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;QACtF,CAAC,CAAC,CAAA;IACJ,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["import { expect, fixture } from '@open-wc/testing'\nimport { html } from 'lit'\n\nimport '../src/data-grist.js'\nimport { DataGrist } from '../src/data-grist.js'\nimport { DataGridBody } from '../src/data-grid/data-grid-body.js'\nimport { OxGristEditorNumber } from '../src/editors/ox-grist-editor-number.js'\nimport { failOnPageErrors } from './page-errors.js'\n\n/* The clipboard holds `text` as `mime` while `run` reads it. */\nasync function withClipboard<T>(mime: string, text: string, run: () => Promise<T>): Promise<T> {\n const previous = Object.getOwnPropertyDescriptor(navigator, 'clipboard')\n Object.defineProperty(navigator, 'clipboard', { configurable: true, value: {\n read: async () => [{ getType: async (requested: string) => {\n if (requested !== mime) throw Error('no type')\n return new Blob([text], { type: mime })\n } }]\n } })\n try { return await run() }\n finally {\n if (previous) Object.defineProperty(navigator, 'clipboard', previous)\n else delete (navigator as any).clipboard\n }\n}\n\n/* What a paste sends, read off a body that only records its field changes. */\nasync function paste(mime: string, text: string, type = 'number', options: any = {}) {\n const changes: any[] = []\n const body: any = {\n focused: { row: options.row ?? 0, column: 0 }, data: { records: options.records || [{ id: 'a', value: 1 }] },\n columns: [{ name: 'value', type, record: { editable: options.editable ?? true } }],\n config: { rows: { appendable: options.appendable ?? false } }, appendRecord: { __dirty__: '+' },\n pasteTargets: (DataGridBody.prototype as any).pasteTargets,\n resetEdit() {}, focus() {}, dispatchEvent(e: CustomEvent) { changes.push(e.detail) }\n }\n await withClipboard(mime, text, () => DataGridBody.prototype.paste.call(body))\n return { body, changes }\n}\nconst source = (mime: string, values: string[]) => mime === 'text/html'\n ? `<table>${values.map(value => `<tr><td>${value}</td></tr>`).join('')}</table>`\n : values.join('\\n')\n\ndescribe('paste and input data contracts', () => {\n for (const mime of ['text/html', 'text/plain']) {\n for (const [type, input, expected] of [\n ['number', 'abc', 'abc'], ['number', '1,200', '1,200'],\n ['number', ' ', null], ['number', 'Infinity', 'Infinity'],\n ['number', '12.5', 12.5], ['integer', '12.5', 12], ['integer', '-1.5', -2],\n ['boolean', 'false', false], ['checkbox', 'true', true], ['number', '0', 0]\n ] as const) {\n it(`${mime} parses ${type} ${input}`, async () => {\n const { changes } = await paste(mime, source(mime, [input]), type)\n expect(changes[0].after).to.equal(expected)\n })\n }\n /* A blank cell clears an existing row's field and leaves a new row's to its default; id 0 is an existing row. */\n for (const [type, input, records, row, expected] of [\n ['number', ' ', [{ id: 0, value: 1 }], 0, null],\n ['string', ' ', [{ id: 'a', value: 'x' }], 1, undefined],\n ['number', ' ', [{ id: 'a', value: 1 }], 1, undefined],\n ['select', ' ', [{ id: 'a', value: 1 }], 1, undefined]\n ] as const) {\n it(`${mime} pastes a blank ${type} into ${row ? 'a new' : 'an existing'} row as ${expected}`, async () => {\n const { changes } = await paste(mime, source(mime, [input]), type, { records, row, appendable: true })\n expect(changes).to.have.length(1)\n expect(changes[0].after).to.equal(expected)\n })\n }\n it(`${mime} passes the destination row to editable`, async () => {\n const seen: number[] = []\n await paste(mime, source(mime, ['1', '2']), 'number', {\n records: [{ id: 'a' }, { id: 'b' }],\n editable: (_v: any, _c: any, _r: any, row: number) => { seen.push(row); return true }\n })\n expect(seen).to.eql([0, 1])\n })\n }\n it('integer IME input uses the same conversion as the number editor', () => {\n let after: any\n const column: any = { name: 'value', type: 'integer', record: { editable: true } }\n const body: any = { _imeBuffer: { value: '12.5' }, _resetIMEBuffer() {}, columns: [column],\n data: { records: [{ value: 1 }] }, dispatchEvent(e: CustomEvent) { after = e.detail.after } }\n DataGridBody.prototype._commitIMEBuffer.call(body, 0, 0)\n const expected = OxGristEditorNumber.prototype.formatFromEditor.call({ column } as any, '12.5')\n expect(after).to.equal(expected)\n })\n})\n\n/* Pasting into a rendered grid: the rows that end up in the grid, through its own field-change handling. */\ndescribe('paste into a grid', () => {\n failOnPageErrors()\n\n const mount = async (options: { appendable: boolean; editable?: boolean; validation?: () => Promise<boolean> }) => {\n const el = await fixture<DataGrist>(html`<ox-grist\n style=\"height:300px\"\n .config=${{\n columns: [\n { name: 'amount', type: 'number', header: 'amount', record: { editable: options.editable ?? true }, validation: options.validation },\n { name: 'memo', type: 'string', header: 'memo', record: { editable: options.editable ?? true } }\n ],\n rows: { appendable: options.appendable }\n }}\n .data=${{ records: [{ id: 'a', amount: 1, memo: 'kept' }] }}\n ></ox-grist>`)\n await el.updateComplete\n await el.grist.updateComplete\n return el\n }\n const bodyOf = (el: DataGrist) => el.grist.renderRoot.querySelector('ox-grid-body') as any\n const pasteAt = async (el: DataGrist, row: number, mime: string, text: string, column = 0) => {\n const body = bodyOf(el)\n body.focused = { row, column }\n await withClipboard(mime, text, () => body.paste())\n await el.updateComplete\n }\n const table = (mime: string, rows: string[][]) => mime === 'text/html'\n ? `<table>${rows.map(cells => `<tr>${cells.map(cell => `<td>${cell}</td>`).join('')}</tr>`).join('')}</table>`\n : rows.map(cells => cells.join('\\t')).join('\\n')\n const rows = (el: DataGrist) => el.grist.data.records.map(({ amount, memo }) => ({ amount, memo }))\n\n for (const mime of ['text/html', 'text/plain']) {\n it(`${mime} stops at the last row when rows cannot be appended`, async () => {\n const el = await mount({ appendable: false })\n await pasteAt(el, 0, mime, table(mime, [['2', 'x'], ['3', 'y']]))\n expect(rows(el)).to.eql([{ amount: 2, memo: 'x' }])\n })\n\n it(`${mime} appends new rows in order`, async () => {\n const el = await mount({ appendable: true })\n await pasteAt(el, 1, mime, table(mime, [['2', 'x'], ['3', 'y']]))\n expect(rows(el)).to.eql([{ amount: 1, memo: 'kept' }, { amount: 2, memo: 'x' }, { amount: 3, memo: 'y' }])\n })\n\n it(`${mime} adds no row for read-only cells`, async () => {\n const el = await mount({ appendable: true, editable: false })\n await pasteAt(el, 1, mime, table(mime, [['2', 'x']]))\n expect(el.grist.data.records).to.have.length(1)\n })\n\n it(`${mime} adds no row for a blank new row`, async () => {\n const el = await mount({ appendable: true })\n await pasteAt(el, 1, mime, table(mime, [[' ', ' '], ['4', 'z']]))\n expect(rows(el)).to.eql([{ amount: 1, memo: 'kept' }, { amount: 4, memo: 'z' }])\n expect(el.dirtyRecords).to.have.length(1)\n })\n\n it(`${mime} keeps a new row's cells together while one is being validated`, async () => {\n let resolve!: (valid: boolean) => void\n const el = await mount({ appendable: true, validation: () => new Promise(done => (resolve = done)) })\n await pasteAt(el, 1, mime, table(mime, [['5', 'w']]))\n resolve(true)\n await new Promise(done => setTimeout(done))\n expect(rows(el)).to.eql([{ amount: 1, memo: 'kept' }, { amount: 5, memo: 'w' }])\n })\n\n it(`${mime} into the append row and a key typed into it while the paste is validated make one row`, async () => {\n let resolve!: (valid: boolean) => void\n const el = await mount({ appendable: true, validation: () => new Promise(done => (resolve = done)) })\n await pasteAt(el, 1, mime, table(mime, [['5']]))\n const body = bodyOf(el)\n body._imeBuffer.value = 'typed'\n body._commitIMEBuffer(1, 1)\n resolve(true)\n await new Promise(done => setTimeout(done))\n expect(rows(el)).to.eql([{ amount: 1, memo: 'kept' }, { amount: 5, memo: 'typed' }])\n })\n }\n})\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { RecordCard } from '../src/data-card/record-card.js';
|
|
3
|
+
/**
|
|
4
|
+
* A card is as tall as its content by default. A list whose cards carry different numbers of lines (a fact row that
|
|
5
|
+
* only some records have) stretches the cards of a row to one height through --data-card-record-card-height.
|
|
6
|
+
*/
|
|
7
|
+
const text = (styles) => (Array.isArray(styles) ? styles : [styles]).map(s => { var _a; return String((_a = s.cssText) !== null && _a !== void 0 ? _a : s); }).join('\n');
|
|
8
|
+
describe('record card height', () => {
|
|
9
|
+
it('reads --data-card-record-card-height, min-content when not set', () => {
|
|
10
|
+
const css = text(RecordCard.styles);
|
|
11
|
+
const host = css.slice(css.indexOf(':host {'), css.indexOf('}', css.indexOf(':host {')));
|
|
12
|
+
expect(host).to.contain('height: var(--data-card-record-card-height, min-content);');
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=record-card-height.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-card-height.test.js","sourceRoot":"","sources":["../../test/record-card-height.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAE5D;;;GAGG;AAEH,MAAM,IAAI,GAAG,CAAC,MAAe,EAAE,EAAE,CAC/B,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,WAAC,OAAA,MAAM,CAAC,MAAC,CAA0B,CAAC,OAAO,mCAAI,CAAC,CAAC,CAAA,EAAA,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAEnH,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;QACxE,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;QACnC,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QACxF,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,2DAA2D,CAAC,CAAA;IACtF,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { expect } from '@open-wc/testing'\n\nimport { RecordCard } from '../src/data-card/record-card.js'\n\n/**\n * A card is as tall as its content by default. A list whose cards carry different numbers of lines (a fact row that\n * only some records have) stretches the cards of a row to one height through --data-card-record-card-height.\n */\n\nconst text = (styles: unknown) =>\n (Array.isArray(styles) ? styles : [styles]).map(s => String((s as { cssText?: string }).cssText ?? s)).join('\\n')\n\ndescribe('record card height', () => {\n it('reads --data-card-record-card-height, min-content when not set', () => {\n const css = text(RecordCard.styles)\n const host = css.slice(css.indexOf(':host {'), css.indexOf('}', css.indexOf(':host {')))\n expect(host).to.contain('height: var(--data-card-record-card-height, min-content);')\n })\n})\n"]}
|
|
@@ -0,0 +1,71 @@
|
|
|
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/record-view/record-view.js';
|
|
5
|
+
import { buildColumn } from '../src/configure/column-builder.js';
|
|
6
|
+
import { OxGristEditor } from '../src/editors/ox-grist-editor.js';
|
|
7
|
+
import { registerEditor } from '../src/editors/registry.js';
|
|
8
|
+
/*
|
|
9
|
+
* In a form (ox-record-view - the 「만들기」 dialog of a grid) a field is pressed to be edited. A field whose editor
|
|
10
|
+
* opens a popup used to become 「editing」 on the first press but open nothing until its editor was pressed again,
|
|
11
|
+
* so what was typed after the first press went nowhere (pdf template 「만들기」, body HTML, 2026-10-10).
|
|
12
|
+
*/
|
|
13
|
+
let opened = 0;
|
|
14
|
+
class ProbePopupEditor extends OxGristEditor {
|
|
15
|
+
_onclick(e) {
|
|
16
|
+
e.stopPropagation();
|
|
17
|
+
opened++;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
ProbePopupEditor.opensPopup = true;
|
|
21
|
+
customElements.define('probe-popup-editor', ProbePopupEditor);
|
|
22
|
+
registerEditor('probe-popup', ProbePopupEditor);
|
|
23
|
+
const settle = (ms = 100) => new Promise(resolve => setTimeout(resolve, ms));
|
|
24
|
+
describe('a popup field in a form', () => {
|
|
25
|
+
it('does not emit the old inline value after a popup has confirmed a different value', async () => {
|
|
26
|
+
const record = { body: 'old' };
|
|
27
|
+
const editor = await fixture(html `<probe-popup-editor
|
|
28
|
+
.column=${buildColumn({ type: 'probe-popup', name: 'body', record: { editable: true } })}
|
|
29
|
+
.record=${record}
|
|
30
|
+
></probe-popup-editor>`);
|
|
31
|
+
let changes = 0;
|
|
32
|
+
editor.addEventListener('field-change', () => changes++);
|
|
33
|
+
record.body = 'confirmed';
|
|
34
|
+
editor._onfocusout();
|
|
35
|
+
expect(changes).to.equal(0);
|
|
36
|
+
expect(record.body).to.equal('confirmed');
|
|
37
|
+
});
|
|
38
|
+
it('opens its popup on the first press', async () => {
|
|
39
|
+
opened = 0;
|
|
40
|
+
const columns = [
|
|
41
|
+
buildColumn({ type: 'string', name: 'name', header: 'name', record: { editable: true } }),
|
|
42
|
+
buildColumn({ type: 'probe-popup', name: 'body', header: 'body', record: { editable: true } })
|
|
43
|
+
];
|
|
44
|
+
const view = (await fixture(html `<ox-record-view .columns=${columns} .record=${{}}></ox-record-view>`));
|
|
45
|
+
await view.updateComplete;
|
|
46
|
+
await settle();
|
|
47
|
+
const body = view.renderRoot.querySelector('ox-record-view-body');
|
|
48
|
+
await body.updateComplete;
|
|
49
|
+
const field = Array.from(body.renderRoot.querySelectorAll('ox-grid-field')).find(one => { var _a; return ((_a = one.column) === null || _a === void 0 ? void 0 : _a.name) === 'body'; });
|
|
50
|
+
expect(!!field, 'the body field is drawn').to.equal(true);
|
|
51
|
+
field.click();
|
|
52
|
+
await settle(200);
|
|
53
|
+
expect(field.getAttribute('editing'), 'the field is being edited').to.equal('true');
|
|
54
|
+
expect(opened, 'the popup editor was opened once').to.equal(1);
|
|
55
|
+
});
|
|
56
|
+
it('leaves a field edited in place as it was - nothing extra is pressed', async () => {
|
|
57
|
+
opened = 0;
|
|
58
|
+
const columns = [buildColumn({ type: 'string', name: 'name', header: 'name', record: { editable: true } })];
|
|
59
|
+
const view = (await fixture(html `<ox-record-view .columns=${columns} .record=${{}}></ox-record-view>`));
|
|
60
|
+
await view.updateComplete;
|
|
61
|
+
await settle();
|
|
62
|
+
const body = view.renderRoot.querySelector('ox-record-view-body');
|
|
63
|
+
await body.updateComplete;
|
|
64
|
+
const field = body.renderRoot.querySelector('ox-grid-field');
|
|
65
|
+
field.click();
|
|
66
|
+
await settle(200);
|
|
67
|
+
expect(field.getAttribute('editing')).to.equal('true');
|
|
68
|
+
expect(opened).to.equal(0);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=record-view-popup-editor.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|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K,EAAE,CAAA;QACb,MAAM,MAAM,CAAC,GAAG,CAAC,CAAA;QACjB,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QACtD,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC5B,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/record-view/record-view.js'\nimport { buildColumn } from '../src/configure/column-builder.js'\nimport { OxGristEditor } from '../src/editors/ox-grist-editor.js'\nimport { registerEditor } from '../src/editors/registry.js'\n\n/*\n * In a form (ox-record-view - the 「만들기」 dialog of a grid) a field is pressed to be edited. A field whose editor\n * opens a popup used to become 「editing」 on the first press but open nothing until its editor was pressed again,\n * so what was typed after the first press went nowhere (pdf template 「만들기」, body HTML, 2026-10-10).\n */\n\nlet opened = 0\n\nclass ProbePopupEditor extends OxGristEditor {\n static opensPopup = true\n\n _onclick(e: Event): void {\n e.stopPropagation()\n opened++\n }\n}\ncustomElements.define('probe-popup-editor', ProbePopupEditor)\nregisterEditor('probe-popup', ProbePopupEditor)\n\nconst settle = (ms = 100) => new Promise(resolve => setTimeout(resolve, ms))\n\ndescribe('a popup field in a form', () => {\n it('does not emit the old inline value after a popup has confirmed a different value', async () => {\n const record = { body: 'old' }\n const editor = await fixture<ProbePopupEditor>(\n html`<probe-popup-editor\n .column=${buildColumn({ type: 'probe-popup', name: 'body', record: { editable: true } } as any)}\n .record=${record}\n ></probe-popup-editor>`\n )\n let changes = 0\n editor.addEventListener('field-change', () => changes++)\n record.body = 'confirmed'\n editor._onfocusout()\n expect(changes).to.equal(0)\n expect(record.body).to.equal('confirmed')\n })\n\n it('opens its popup on the first press', async () => {\n opened = 0\n const columns = [\n buildColumn({ type: 'string', name: 'name', header: 'name', record: { editable: true } } as any),\n buildColumn({ type: 'probe-popup', name: 'body', header: 'body', record: { editable: true } } as any)\n ]\n const view = (await fixture(html`<ox-record-view .columns=${columns} .record=${{}}></ox-record-view>`)) as any\n await view.updateComplete\n await settle()\n\n const body = view.renderRoot.querySelector('ox-record-view-body') as any\n await body.updateComplete\n const field = Array.from(body.renderRoot.querySelectorAll('ox-grid-field') as NodeListOf<any>).find(one => one.column?.name === 'body')\n expect(!!field, 'the body field is drawn').to.equal(true)\n\n field.click()\n await settle(200)\n\n expect(field.getAttribute('editing'), 'the field is being edited').to.equal('true')\n expect(opened, 'the popup editor was opened once').to.equal(1)\n })\n\n it('leaves a field edited in place as it was - nothing extra is pressed', async () => {\n opened = 0\n const columns = [buildColumn({ type: 'string', name: 'name', header: 'name', record: { editable: true } } as any)]\n const view = (await fixture(html`<ox-record-view .columns=${columns} .record=${{}}></ox-record-view>`)) as any\n await view.updateComplete\n await settle()\n const body = view.renderRoot.querySelector('ox-record-view-body') as any\n await body.updateComplete\n const field = body.renderRoot.querySelector('ox-grid-field') as any\n field.click()\n await settle(200)\n expect(field.getAttribute('editing')).to.equal('true')\n expect(opened).to.equal(0)\n })\n})\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { render } from 'lit';
|
|
3
|
+
import { OxGristRendererDate } from '../src/renderers/ox-grist-renderer-date.js';
|
|
4
|
+
/**
|
|
5
|
+
* 'YYYY-MM-DD' 는 달력의 날이다. 브라우저가 UTC 서쪽에 있어도 그 날 그대로 나와야 한다.
|
|
6
|
+
*
|
|
7
|
+
* 시험 브라우저의 시간대는 고를 수 없으므로, 시간대를 적지 않은 Intl.DateTimeFormat 을 America/Tijuana
|
|
8
|
+
* 로 돌린다 — 그 시간대의 브라우저가 날짜를 적는 길과 같다.
|
|
9
|
+
*/
|
|
10
|
+
const WEST = 'America/Tijuana';
|
|
11
|
+
function renderText(value, type) {
|
|
12
|
+
const column = { type, record: {} };
|
|
13
|
+
const host = document.createElement('div');
|
|
14
|
+
render(OxGristRendererDate(value, column, {}, 0, undefined), host);
|
|
15
|
+
return host.textContent.trim();
|
|
16
|
+
}
|
|
17
|
+
describe('OxGristRendererDate — calendar day', () => {
|
|
18
|
+
const Original = Intl.DateTimeFormat;
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
;
|
|
21
|
+
Intl.DateTimeFormat = function (locales, options = {}) {
|
|
22
|
+
return new Original(locales, { timeZone: WEST, ...options });
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
;
|
|
27
|
+
Intl.DateTimeFormat = Original;
|
|
28
|
+
});
|
|
29
|
+
it("renders '2025-12-31' as Dec 31 west of UTC", () => {
|
|
30
|
+
const expected = new Original(undefined, { year: 'numeric', month: 'numeric', day: 'numeric', timeZone: 'UTC' }).format(Date.UTC(2025, 11, 31));
|
|
31
|
+
expect(renderText('2025-12-31', 'date')).to.equal(expected);
|
|
32
|
+
});
|
|
33
|
+
it('still renders a datetime instant in the browser time zone', () => {
|
|
34
|
+
// 2025-12-31T03:00Z is Dec 30 evening in Tijuana.
|
|
35
|
+
const text = renderText('2025-12-31T03:00:00Z', 'datetime');
|
|
36
|
+
const expected = new Original(undefined, {
|
|
37
|
+
year: 'numeric',
|
|
38
|
+
month: 'numeric',
|
|
39
|
+
day: 'numeric',
|
|
40
|
+
hour: 'numeric',
|
|
41
|
+
minute: '2-digit',
|
|
42
|
+
hour12: false,
|
|
43
|
+
timeZone: WEST
|
|
44
|
+
}).format(new Date('2025-12-31T03:00:00Z'));
|
|
45
|
+
expect(text).to.equal(expected);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=renderer-date-calendar-day.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer-date-calendar-day.test.js","sourceRoot":"","sources":["../../test/renderer-date-calendar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AE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CACrH,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,CACvB,CAAA;QACD,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAC7D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,kDAAkD;QAClD,MAAM,IAAI,GAAG,UAAU,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAA;QAC3D,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,SAAS,EAAE;YACvC,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,SAAS;YAChB,GAAG,EAAE,SAAS;YACd,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,KAAK;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAA;QAC3C,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IACjC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { expect } from '@open-wc/testing'\nimport { render } from 'lit'\n\nimport { OxGristRendererDate } from '../src/renderers/ox-grist-renderer-date.js'\n\n/**\n * 'YYYY-MM-DD' 는 달력의 날이다. 브라우저가 UTC 서쪽에 있어도 그 날 그대로 나와야 한다.\n *\n * 시험 브라우저의 시간대는 고를 수 없으므로, 시간대를 적지 않은 Intl.DateTimeFormat 을 America/Tijuana\n * 로 돌린다 — 그 시간대의 브라우저가 날짜를 적는 길과 같다.\n */\nconst WEST = 'America/Tijuana'\n\nfunction renderText(value: any, type: string): string {\n const column = { type, record: {} } as any\n const host = document.createElement('div')\n render(OxGristRendererDate(value, column, {}, 0, undefined as any) as any, host)\n return host.textContent!.trim()\n}\n\ndescribe('OxGristRendererDate — calendar day', () => {\n const Original = Intl.DateTimeFormat\n\n beforeEach(() => {\n ;(Intl as any).DateTimeFormat = function (locales?: any, options: any = {}) {\n return new Original(locales, { timeZone: WEST, ...options })\n }\n })\n\n afterEach(() => {\n ;(Intl as any).DateTimeFormat = Original\n })\n\n it(\"renders '2025-12-31' as Dec 31 west of UTC\", () => {\n const expected = new Original(undefined, { year: 'numeric', month: 'numeric', day: 'numeric', timeZone: 'UTC' }).format(\n Date.UTC(2025, 11, 31)\n )\n expect(renderText('2025-12-31', 'date')).to.equal(expected)\n })\n\n it('still renders a datetime instant in the browser time zone', () => {\n // 2025-12-31T03:00Z is Dec 30 evening in Tijuana.\n const text = renderText('2025-12-31T03:00:00Z', 'datetime')\n const expected = new Original(undefined, {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: '2-digit',\n hour12: false,\n timeZone: WEST\n }).format(new Date('2025-12-31T03:00:00Z'))\n expect(text).to.equal(expected)\n })\n})\n"]}
|