@jskit-ai/http-web 0.2.15 → 0.2.16
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 +5 -0
- package/fixtures/crud-list-date-filters/App.vue +3 -3
- package/fixtures/crud-list-date-filters/main.js +3 -9
- package/fixtures/crud-screens/App.vue +14 -0
- package/fixtures/crud-screens/index.html +12 -0
- package/fixtures/crud-screens/main.js +114 -0
- package/fixtures/crud-screens/vite.config.mjs +24 -0
- package/fixtures/select-field/main.js +3 -9
- package/locales/en.json +1 -2
- package/package.json +10 -8
- package/patterns/crud-screen-set/PATTERN.md +13 -0
- package/patterns/crud-screen-set/example/books/BookEditPage.vue +2 -0
- package/patterns/crud-screen-set/example/books/BookFormFields.vue +0 -6
- package/patterns/crud-screen-set/example/books/BookListPage.vue +5 -2
- package/patterns/crud-screen-set/example/books/BookNewPage.vue +2 -0
- package/patterns/crud-screen-set/example/books/BookViewPage.vue +5 -9
- package/src/client/components/CrudAddEditScreen.vue +70 -75
- package/src/client/components/CrudDeleteAction.vue +26 -14
- package/src/client/components/CrudListBulkActionSurface.vue +25 -20
- package/src/client/components/CrudListCreateAction.vue +38 -0
- package/src/client/components/CrudListDateFilterControl.vue +0 -1
- package/src/client/components/CrudListFilterControls.vue +0 -11
- package/src/client/components/CrudListFilterSheet.vue +59 -0
- package/src/client/components/CrudListFilterSurface.vue +58 -84
- package/src/client/components/CrudListRecordActionMenu.vue +14 -18
- package/src/client/components/CrudListScreen.vue +305 -245
- package/src/client/components/CrudViewScreen.vue +84 -99
- package/src/client/composables/records/useCrudAddEdit.js +6 -4
- package/src/client/composables/records/useView.js +1 -0
- package/src/client/composables/runtime/useViewCore.js +4 -4
- package/src/client/composables/useCrudDeleteAction.js +4 -3
- package/src/client/types.js +0 -1
- package/test/crudAddEditActions.test.js +19 -2
- package/test/crudListBulkActionSurface.test.js +3 -2
- package/test/crudListDateFilterSurface.browser.test.js +23 -14
- package/test/crudListFilterSurface.test.js +11 -7
- package/test/crudScreenComponents.test.js +89 -16
- package/test/crudScreenPattern.test.js +3 -0
- package/test/crudScreensMaterialBaselines.browser.test.js +170 -0
- package/test/translation.test.js +6 -2
|
@@ -23,9 +23,16 @@ async function readClientFile(...parts) {
|
|
|
23
23
|
|
|
24
24
|
test("every CRUD list create action retains its configured label and destination", async () => {
|
|
25
25
|
const componentUrl = new URL("../src/client/components/CrudListScreen.vue", import.meta.url).href;
|
|
26
|
+
const createActionUrl = new URL("../src/client/components/CrudListCreateAction.vue", import.meta.url).href;
|
|
26
27
|
const hooks = registerHooks({
|
|
27
28
|
load(url, context, nextLoad) {
|
|
28
29
|
if (!url.endsWith(".vue")) return nextLoad(url, context);
|
|
30
|
+
if (url === createActionUrl) {
|
|
31
|
+
return {
|
|
32
|
+
format: "module", shortCircuit: true,
|
|
33
|
+
source: "import { h } from \"vue\"; export default { props: [\"label\", \"to\"], setup: (props) => () => h(\"a\", { href: props.to }, props.label) };"
|
|
34
|
+
};
|
|
35
|
+
}
|
|
29
36
|
if (url !== componentUrl) {
|
|
30
37
|
return { format: "module", shortCircuit: true, source: "export default { render: () => null };" };
|
|
31
38
|
}
|
|
@@ -65,17 +72,66 @@ test("every CRUD list create action retains its configured label and destination
|
|
|
65
72
|
props: { to: { type: [String, Object], default: undefined } },
|
|
66
73
|
setup: (props, { slots }) => () => h("a", { href: props.to }, slots.default?.())
|
|
67
74
|
}));
|
|
68
|
-
for (const name of ["
|
|
75
|
+
for (const name of ["VCard", "VTable", "VTextField", "VSkeletonLoader", "VCheckboxBtn", "VIcon", "VTooltip"]) {
|
|
69
76
|
app.component(name, defineComponent({ setup: (_props, { slots }) => () => h("div", slots.default?.()) }));
|
|
70
77
|
}
|
|
71
78
|
const html = await renderToString(app);
|
|
72
79
|
const labels = [...html.matchAll(/<a[^>]*href="\/books\/new"[^>]*>(.*?)<\/a>/gs)]
|
|
73
80
|
.map((match) => match[1].trim());
|
|
74
|
-
|
|
81
|
+
// The FAB or app bar action, plus the empty state's own button.
|
|
82
|
+
assert.deepEqual(labels, Array(populated ? 1 : 2).fill(createLabel ?? "New record"));
|
|
75
83
|
}
|
|
76
84
|
}
|
|
77
85
|
});
|
|
78
86
|
|
|
87
|
+
test("a CRUD view whose record is not found or forbidden tells the shell, and no other failure does", async () => {
|
|
88
|
+
const componentUrl = new URL("../src/client/components/CrudViewScreen.vue", import.meta.url).href;
|
|
89
|
+
const navigationStub = "export function useShellNavigation() { return { pageUnavailable: () => globalThis.__crudViewUnavailable.push(true) }; }";
|
|
90
|
+
const hooks = registerHooks({
|
|
91
|
+
resolve(specifier, context, nextResolve) {
|
|
92
|
+
if (specifier === "@jskit-ai/shell-web/client/navigation/useShellNavigation" && context.parentURL === componentUrl) {
|
|
93
|
+
return { url: `data:text/javascript,${encodeURIComponent(navigationStub)}`, shortCircuit: true };
|
|
94
|
+
}
|
|
95
|
+
return nextResolve(specifier, context);
|
|
96
|
+
},
|
|
97
|
+
load(url, context, nextLoad) {
|
|
98
|
+
if (!url.endsWith(".vue")) return nextLoad(url, context);
|
|
99
|
+
if (url !== componentUrl) {
|
|
100
|
+
return { format: "module", shortCircuit: true, source: "export default { render: () => null };" };
|
|
101
|
+
}
|
|
102
|
+
const { descriptor } = parse(readFileSync(new URL(url), "utf8"));
|
|
103
|
+
return {
|
|
104
|
+
format: "module", shortCircuit: true,
|
|
105
|
+
source: compileScript(descriptor, { id: "crud-view-unavailable", inlineTemplate: true }).content
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
let CrudViewScreen;
|
|
110
|
+
try {
|
|
111
|
+
({ default: CrudViewScreen } = await import(componentUrl));
|
|
112
|
+
} finally {
|
|
113
|
+
hooks.deregister();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const cases = [
|
|
117
|
+
{ name: "not found", view: { isNotFound: true, errorStatus: 404, loadError: "" }, unavailable: 1 },
|
|
118
|
+
{ name: "forbidden", view: { isNotFound: false, errorStatus: 403, loadError: "No access" }, unavailable: 1 },
|
|
119
|
+
{ name: "server error", view: { isNotFound: false, errorStatus: 500, loadError: "Try again" }, unavailable: 0 },
|
|
120
|
+
{ name: "loaded", view: { isNotFound: false, errorStatus: 0, loadError: "" }, unavailable: 0 }
|
|
121
|
+
];
|
|
122
|
+
for (const { name, view, unavailable } of cases) {
|
|
123
|
+
globalThis.__crudViewUnavailable = [];
|
|
124
|
+
const screen = { view: { ...view, isLoading: false, isFetching: false, refresh() {} }, editLocation: null, recordTitle: "" };
|
|
125
|
+
const app = createSSRApp({ render: () => h(CrudViewScreen, { screen }) });
|
|
126
|
+
for (const component of ["VBtn", "VCard", "VIcon", "VList", "VSkeletonLoader"]) {
|
|
127
|
+
app.component(component, defineComponent({ setup: (_props, { slots }) => () => h("div", slots.default?.()) }));
|
|
128
|
+
}
|
|
129
|
+
await renderToString(app);
|
|
130
|
+
assert.equal(globalThis.__crudViewUnavailable.length, unavailable, name);
|
|
131
|
+
}
|
|
132
|
+
delete globalThis.__crudViewUnavailable;
|
|
133
|
+
});
|
|
134
|
+
|
|
79
135
|
test("CRUD screen components own list/view/form chrome centrally", async () => {
|
|
80
136
|
const listSource = await readComponent("CrudListScreen.vue");
|
|
81
137
|
const viewSource = await readComponent("CrudViewScreen.vue");
|
|
@@ -84,41 +140,55 @@ test("CRUD screen components own list/view/form chrome centrally", async () => {
|
|
|
84
140
|
const bulkActionSource = await readComponent("CrudListBulkActionSurface.vue");
|
|
85
141
|
const rowActionSource = await readComponent("CrudListRecordActionMenu.vue");
|
|
86
142
|
|
|
143
|
+
const createActionSource = await readComponent("CrudListCreateAction.vue");
|
|
144
|
+
|
|
87
145
|
assert.match(listSource, /CrudListBulkActionSurface/);
|
|
88
146
|
assert.match(listSource, /CrudListFilterSurface/);
|
|
89
147
|
assert.match(listSource, /CrudListRecordActionMenu/);
|
|
148
|
+
assert.match(listSource, /<CrudListCreateAction v-if="listPrimaryAction"/);
|
|
149
|
+
assert.match(listSource, /<ShellPageActions>[\s\S]*icon="\$refresh"[\s\S]*<\/ShellPageActions>/);
|
|
90
150
|
assert.match(listSource, /class="crud-list-cards"/);
|
|
91
151
|
assert.match(listSource, /class="crud-list-table"/);
|
|
92
|
-
assert.match(listSource, /class="crud-list-fab"/);
|
|
93
|
-
assert.doesNotMatch(listSource, /crud-list-cards d-md-none/);
|
|
94
|
-
assert.doesNotMatch(listSource, /crud-list-table d-none d-md-block/);
|
|
95
|
-
assert.doesNotMatch(listSource, /class="crud-list-fab d-md-none"/);
|
|
96
152
|
assert.match(listSource, /\.crud-list-table\s*\{\s*display:\s*none;/);
|
|
153
|
+
// The list's own width, not the window's, picks cards or the table.
|
|
154
|
+
assert.match(listSource, /container: crud-list \/ inline-size;/);
|
|
97
155
|
assert.match(
|
|
98
156
|
listSource,
|
|
99
|
-
/@
|
|
157
|
+
/@container crud-list \(min-width: 720px\)[\s\S]*\.crud-list-cards\s*\{\s*display:\s*none;[\s\S]*\.crud-list-table\s*\{\s*display:\s*block;/
|
|
100
158
|
);
|
|
101
|
-
assert.match(listSource,
|
|
159
|
+
assert.match(listSource, /table-layout: fixed;/);
|
|
160
|
+
assert.match(listSource, /text-overflow: ellipsis;/);
|
|
161
|
+
assert.match(listSource, /@click="openRow\(row, \$event\)"/);
|
|
162
|
+
assert.match(listSource, /class="crud-list-card__title crud-list-card__link"/);
|
|
163
|
+
assert.match(listSource, /icon="\$inbox"/);
|
|
164
|
+
assert.match(listSource, /icon="\$cloudOff"/);
|
|
165
|
+
assert.match(listSource, /variant="solo-filled"[\s\S]*rounded="pill"[\s\S]*prepend-inner-icon="\$search"/);
|
|
166
|
+
assert.doesNotMatch(listSource, /@media|<v-sheet|\sborder(?=[\s>])|\bborder\s*:|min-height:\s*48px/u);
|
|
102
167
|
assert.match(listSource, /selectableRows/);
|
|
103
|
-
assert.match(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
);
|
|
168
|
+
assert.match(createActionSource, /<v-fab[\s\S]*v-if="isCompact \|\| isMedium"[\s\S]*\bapp\b[\s\S]*\bextended\b/);
|
|
169
|
+
assert.match(createActionSource, /<ShellPageAction primary icon="\$add"/);
|
|
170
|
+
assert.match(rowActionSource, /icon="\$moreVert"/);
|
|
107
171
|
assert.match(listSource, /<slot[\s\S]*name="card-fields"/);
|
|
108
172
|
assert.match(listSource, /<slot name="table-header"/);
|
|
109
173
|
assert.match(listSource, /<slot[\s\S]*name="table-row"/);
|
|
110
174
|
assert.match(listSource, /:row="row"/);
|
|
111
175
|
|
|
112
|
-
assert.match(viewSource, /crud-screen crud-
|
|
176
|
+
assert.match(viewSource, /class="crud-screen crud-view"/);
|
|
113
177
|
assert.match(viewSource, /crud-view-panel/);
|
|
114
178
|
assert.match(viewSource, /@click="view\.refresh"/);
|
|
115
|
-
assert.match(viewSource, /<slot name="actions" :screen="screen" :view="view" \/>/);
|
|
179
|
+
assert.match(viewSource, /<ShellPageActions>\s*<slot name="actions" :screen="screen" :view="view" \/>/);
|
|
180
|
+
assert.match(viewSource, /pageUnavailable\(\)/);
|
|
181
|
+
assert.match(viewSource, /<v-list class="crud-view-fields" lines="two">/);
|
|
182
|
+
assert.doesNotMatch(viewSource, /backTo|Back to/u);
|
|
116
183
|
assert.match(viewSource, /<slot name="before-fields"/);
|
|
117
184
|
assert.match(viewSource, /<slot name="fields"/);
|
|
118
185
|
assert.match(viewSource, /<slot name="after-fields"/);
|
|
119
186
|
assert.match(viewSource, /supporting-content/);
|
|
120
187
|
|
|
121
|
-
assert.match(addEditSource, /crud-screen crud-
|
|
188
|
+
assert.match(addEditSource, /class="crud-screen crud-add-edit-form"/);
|
|
189
|
+
assert.match(addEditSource, /<ShellPageActions>\s*<slot\s+name="actions"/);
|
|
190
|
+
assert.match(addEditSource, /<ShellPageAction\s+primary/);
|
|
191
|
+
assert.match(addEditSource, /navigation\.finish\(/);
|
|
122
192
|
assert.match(addEditSource, /addEdit\.canRetryLoad/);
|
|
123
193
|
assert.match(addEditSource, /@click="addEdit\.refresh"/);
|
|
124
194
|
assert.match(addEditSource, /<slot[\s\S]*name="fields"/);
|
|
@@ -127,6 +197,7 @@ test("CRUD screen components own list/view/form chrome centrally", async () => {
|
|
|
127
197
|
assert.match(deleteActionSource, /@click="action\.confirm"/);
|
|
128
198
|
assert.match(deleteActionSource, /@click="closeDialog"/);
|
|
129
199
|
assert.doesNotMatch(deleteActionSource, /\bactivator=/);
|
|
200
|
+
assert.match(deleteActionSource, /<ShellPageAction\s+icon="\$delete"/);
|
|
130
201
|
|
|
131
202
|
const sharedSources = [
|
|
132
203
|
listSource,
|
|
@@ -134,10 +205,12 @@ test("CRUD screen components own list/view/form chrome centrally", async () => {
|
|
|
134
205
|
addEditSource,
|
|
135
206
|
deleteActionSource,
|
|
136
207
|
bulkActionSource,
|
|
137
|
-
rowActionSource
|
|
208
|
+
rowActionSource,
|
|
209
|
+
createActionSource
|
|
138
210
|
].join("\n");
|
|
139
211
|
assert.doesNotMatch(sharedSources, /:loading=|v-progress-(?:circular|linear)/u);
|
|
140
212
|
assert.doesNotMatch(sharedSources, /ui-generator|generated-ui/u);
|
|
213
|
+
assert.doesNotMatch(sharedSources, /@mdi\/js|mdi-|!important/u);
|
|
141
214
|
assert.match(listSource, /v-skeleton-loader/u);
|
|
142
215
|
assert.match(viewSource, /v-skeleton-loader/u);
|
|
143
216
|
assert.match(addEditSource, /v-skeleton-loader/u);
|
|
@@ -23,6 +23,9 @@ const patternRoot = path.resolve(
|
|
|
23
23
|
);
|
|
24
24
|
const exampleRoot = path.join(patternRoot, "example", "books");
|
|
25
25
|
|
|
26
|
+
// definePage() is the file-based router's compile-time macro: an application build removes it from page setup.
|
|
27
|
+
globalThis.definePage = () => {};
|
|
28
|
+
|
|
26
29
|
const hooks = registerHooks({
|
|
27
30
|
resolve(specifier, context, nextResolve) {
|
|
28
31
|
if (specifier === "@local/books/shared") {
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import test from "node:test";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { chromium, expect } from "@playwright/test";
|
|
6
|
+
import {
|
|
7
|
+
createChromiumLaunchOptions,
|
|
8
|
+
startViteFixture,
|
|
9
|
+
stopProcess
|
|
10
|
+
} from "../../../tooling/testUtils/browserFixture.mjs";
|
|
11
|
+
import { expectMaterialBaseline } from "../../../tooling/testUtils/visualBaseline.mjs";
|
|
12
|
+
|
|
13
|
+
const TEST_DIRECTORY = path.dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
const FIXTURE_ROOT = path.resolve(TEST_DIRECTORY, "../fixtures/crud-screens");
|
|
15
|
+
// Kept in the repository, outside the published package.
|
|
16
|
+
const BASELINE_DIRECTORY = path.resolve(TEST_DIRECTORY, "../../../tooling/material-baselines/http-web");
|
|
17
|
+
const RUN_BROWSER_TEST = process.env.JSKIT_MATERIAL_BASELINES === "1";
|
|
18
|
+
const VIEWPORTS = Object.freeze([
|
|
19
|
+
{ width: 390, height: 844 },
|
|
20
|
+
{ width: 768, height: 1024 },
|
|
21
|
+
{ width: 1280, height: 900 }
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
const BOOKS = Object.freeze([
|
|
25
|
+
{ id: "1", title: "The Left Hand of Darkness", author: "Ursula K. Le Guin", notes: "Winter, and the envoy Genly Ai." },
|
|
26
|
+
{ id: "2", title: "Kindred", author: "Octavia E. Butler", notes: null },
|
|
27
|
+
{ id: "3", title: "The Dispossessed", author: "Ursula K. Le Guin", notes: "Anarres and Urras." }
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
function bookResource(book) {
|
|
31
|
+
return {
|
|
32
|
+
type: "books",
|
|
33
|
+
id: book.id,
|
|
34
|
+
attributes: {
|
|
35
|
+
title: book.title,
|
|
36
|
+
author: book.author,
|
|
37
|
+
notes: book.notes,
|
|
38
|
+
createdAt: "2026-01-02T10:00:00.000Z",
|
|
39
|
+
updatedAt: "2026-01-02T10:00:00.000Z"
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// What Material 3 fixes on the CRUD screens: the app bar's title, Up arrow and actions, the FAB, the search bar, the
|
|
45
|
+
// cards and the table, the empty and error states, the view's header and value-first details, the form's fields and
|
|
46
|
+
// the delete dialog.
|
|
47
|
+
const CRUD_PROBES = Object.freeze([
|
|
48
|
+
{ name: "application", selector: ".v-application" },
|
|
49
|
+
{ name: "appBar", selector: ".v-app-bar", width: true },
|
|
50
|
+
{ name: "pageTitle", selector: "[data-testid=jskit-shell-page-title]" },
|
|
51
|
+
{ name: "upButton", selector: "[data-testid=jskit-shell-back]", width: true },
|
|
52
|
+
{ name: "primaryAction", selector: ".shell-page-action.v-btn--variant-flat" },
|
|
53
|
+
{ name: "pageAction", selector: ".shell-page-action.v-btn--variant-text" },
|
|
54
|
+
{ name: "navigationBar", selector: "[data-testid=jskit-shell-bottom-nav]", width: true },
|
|
55
|
+
{ name: "rail", selector: "[data-testid=jskit-shell-rail]", width: true },
|
|
56
|
+
{ name: "drawer", selector: "[data-testid=jskit-shell-drawer].v-navigation-drawer--active", width: true },
|
|
57
|
+
{ name: "content", selector: ".shell-layout__content", width: true },
|
|
58
|
+
{ name: "fab", selector: ".crud-list-fab .v-btn" },
|
|
59
|
+
{ name: "search", selector: ".crud-list-search .v-field", width: true },
|
|
60
|
+
{ name: "card", selector: ".crud-list-card", width: true },
|
|
61
|
+
{ name: "cardTitle", selector: ".crud-list-card__title" },
|
|
62
|
+
{ name: "cardMenu", selector: ".crud-list-card .v-btn--icon", width: true },
|
|
63
|
+
{ name: "table", selector: ".crud-list-table", width: true },
|
|
64
|
+
{ name: "tableHeader", selector: ".crud-list-table thead th" },
|
|
65
|
+
{ name: "tableRow", selector: ".crud-list-table tbody tr" },
|
|
66
|
+
{ name: "tableCell", selector: ".crud-list-table tbody td" },
|
|
67
|
+
{ name: "rowAction", selector: ".crud-list-table tbody .v-btn--icon", width: true },
|
|
68
|
+
{ name: "state", selector: ".crud-list-state" },
|
|
69
|
+
{ name: "stateIcon", selector: ".crud-list-state .v-icon", width: true },
|
|
70
|
+
{ name: "stateAction", selector: ".crud-list-state .v-btn" },
|
|
71
|
+
{ name: "viewHeader", selector: ".crud-view-header h2" },
|
|
72
|
+
{ name: "viewPanel", selector: ".crud-view-panel", width: true },
|
|
73
|
+
{ name: "viewItemTitle", selector: ".crud-view-fields .v-list-item-title" },
|
|
74
|
+
{ name: "viewItemSubtitle", selector: ".crud-view-fields .v-list-item-subtitle" },
|
|
75
|
+
{ name: "field", selector: ".crud-add-edit-form__fields .v-field", width: true },
|
|
76
|
+
{ name: "fieldLabel", selector: ".crud-add-edit-form__fields .v-field-label" },
|
|
77
|
+
{ name: "dialog", selector: ".v-overlay--active .v-card", width: true },
|
|
78
|
+
{ name: "dialogTitle", selector: ".v-overlay--active .crud-delete-action__headline" },
|
|
79
|
+
{ name: "dialogAction", selector: ".v-overlay--active .v-card-actions .v-btn" }
|
|
80
|
+
]);
|
|
81
|
+
|
|
82
|
+
const SCREENS = Object.freeze([
|
|
83
|
+
{ name: "list", path: "/books", data: "books", ready: ".crud-list-card, .crud-list-table" },
|
|
84
|
+
{ name: "list-empty", path: "/books", data: "empty", ready: ".crud-list-state" },
|
|
85
|
+
{ name: "list-error", path: "/books", data: "error", ready: ".crud-list-state" },
|
|
86
|
+
{ name: "view", path: "/books/1", data: "books", ready: ".crud-view-header" },
|
|
87
|
+
{ name: "delete-dialog", path: "/books/1", data: "books", ready: ".crud-view-header", openDelete: true },
|
|
88
|
+
{ name: "new", path: "/books/new", data: "books", ready: ".crud-add-edit-form__fields .v-field" },
|
|
89
|
+
{ name: "edit", path: "/books/1/edit", data: "books", ready: ".crud-add-edit-form__fields .v-field--dirty" }
|
|
90
|
+
]);
|
|
91
|
+
|
|
92
|
+
async function serveBooks(page, screen) {
|
|
93
|
+
await page.route("**/api/**", async (route) => {
|
|
94
|
+
const url = new URL(route.request().url());
|
|
95
|
+
const record = /^\/api\/books\/([^/]+)$/u.exec(url.pathname);
|
|
96
|
+
if (screen.data === "error") {
|
|
97
|
+
await route.fulfill({
|
|
98
|
+
status: 500,
|
|
99
|
+
contentType: "application/vnd.api+json",
|
|
100
|
+
body: JSON.stringify({ errors: [{ status: "500", title: "Server error", detail: "Unable to load books." }] })
|
|
101
|
+
});
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (url.pathname === "/api/books") {
|
|
105
|
+
const books = screen.data === "empty" ? [] : BOOKS;
|
|
106
|
+
await route.fulfill({
|
|
107
|
+
contentType: "application/vnd.api+json",
|
|
108
|
+
body: JSON.stringify({ data: books.map(bookResource), meta: { page: { nextCursor: null } } })
|
|
109
|
+
});
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const book = record && BOOKS.find((candidate) => candidate.id === record[1]);
|
|
113
|
+
if (book) {
|
|
114
|
+
await route.fulfill({ contentType: "application/vnd.api+json", body: JSON.stringify({ data: bookResource(book) }) });
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
await route.fulfill({
|
|
118
|
+
status: 404,
|
|
119
|
+
contentType: "application/vnd.api+json",
|
|
120
|
+
body: JSON.stringify({ errors: [{ status: "404", title: "Not found" }] })
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
test("the CRUD screens keep their Material 3 baselines in light and dark at every window size", {
|
|
126
|
+
skip: RUN_BROWSER_TEST ? false : "set JSKIT_MATERIAL_BASELINES=1 to check the Material 3 baselines",
|
|
127
|
+
timeout: 300_000
|
|
128
|
+
}, async () => {
|
|
129
|
+
const vite = await startViteFixture({ fixtureRoot: FIXTURE_ROOT });
|
|
130
|
+
let browser = null;
|
|
131
|
+
try {
|
|
132
|
+
browser = await chromium.launch(createChromiumLaunchOptions());
|
|
133
|
+
for (const viewport of VIEWPORTS) {
|
|
134
|
+
// The app follows the system's light or dark setting, Material 3's default.
|
|
135
|
+
for (const colorScheme of ["light", "dark"]) {
|
|
136
|
+
const context = await browser.newContext({
|
|
137
|
+
baseURL: vite.baseURL,
|
|
138
|
+
colorScheme,
|
|
139
|
+
locale: "en-US",
|
|
140
|
+
reducedMotion: "reduce",
|
|
141
|
+
timezoneId: "UTC",
|
|
142
|
+
viewport
|
|
143
|
+
});
|
|
144
|
+
try {
|
|
145
|
+
for (const screen of SCREENS) {
|
|
146
|
+
const page = await context.newPage();
|
|
147
|
+
await serveBooks(page, screen);
|
|
148
|
+
await page.goto(screen.path);
|
|
149
|
+
await expect(page.locator(screen.ready).filter({ visible: true }).first()).toBeVisible();
|
|
150
|
+
if (screen.openDelete) {
|
|
151
|
+
await page.getByRole("button", { name: /^Delete/u }).first().click();
|
|
152
|
+
await expect(page.locator(".v-overlay--active .crud-delete-action__headline")).toBeVisible();
|
|
153
|
+
}
|
|
154
|
+
await expectMaterialBaseline(page, {
|
|
155
|
+
directory: BASELINE_DIRECTORY,
|
|
156
|
+
name: `crud-${screen.name}-${viewport.width}-${colorScheme}`,
|
|
157
|
+
probes: CRUD_PROBES
|
|
158
|
+
});
|
|
159
|
+
await page.close();
|
|
160
|
+
}
|
|
161
|
+
} finally {
|
|
162
|
+
await context.close();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
} finally {
|
|
167
|
+
await browser?.close();
|
|
168
|
+
await stopProcess(vite);
|
|
169
|
+
}
|
|
170
|
+
});
|
package/test/translation.test.js
CHANGED
|
@@ -62,7 +62,11 @@ async function importCrudListScreen() {
|
|
|
62
62
|
load(url, context, nextLoad) {
|
|
63
63
|
if (!url.endsWith(".vue")) return nextLoad(url, context);
|
|
64
64
|
if (url !== componentUrl) {
|
|
65
|
-
|
|
65
|
+
// Child components show the label they are given (the app bar's actions), or else their content.
|
|
66
|
+
return {
|
|
67
|
+
format: "module", shortCircuit: true,
|
|
68
|
+
source: "import { h } from \"vue\"; export default { props: [\"label\"], setup: (props, { slots }) => () => props.label ? h(\"span\", props.label) : h(\"div\", slots.default?.()) };"
|
|
69
|
+
};
|
|
66
70
|
}
|
|
67
71
|
const { descriptor } = parse(readFileSync(new URL(url), "utf8"));
|
|
68
72
|
return {
|
|
@@ -86,7 +90,7 @@ async function renderCrudListScreen(props) {
|
|
|
86
90
|
});
|
|
87
91
|
await router.push("/books");
|
|
88
92
|
app.use(router);
|
|
89
|
-
for (const name of ["VBtn", "
|
|
93
|
+
for (const name of ["VBtn", "VCard", "VTable", "VTextField", "VSkeletonLoader", "VCheckboxBtn", "VIcon", "VTooltip"]) {
|
|
90
94
|
app.component(name, defineComponent({ setup: (_props, { slots }) => () => h("div", slots.default?.()) }));
|
|
91
95
|
}
|
|
92
96
|
return renderToString(app);
|