@burojs/test-helpers 0.2.0 → 0.4.0
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/README.md +13 -1
- package/dist/index.cjs +159 -302
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +413 -170
- package/dist/index.d.ts +413 -170
- package/dist/index.js +158 -299
- package/dist/index.js.map +1 -1
- package/dist/provider-contract.cjs +273 -0
- package/dist/provider-contract.cjs.map +1 -0
- package/dist/provider-contract.d.cts +60 -0
- package/dist/provider-contract.d.ts +60 -0
- package/dist/provider-contract.js +272 -0
- package/dist/provider-contract.js.map +1 -0
- package/package.json +23 -7
package/dist/index.js
CHANGED
|
@@ -1,311 +1,170 @@
|
|
|
1
|
-
|
|
2
|
-
import { describe, it, expect } from 'vitest';
|
|
3
|
-
|
|
4
|
-
// src/form-view.ts
|
|
1
|
+
//#region src/form-view.ts
|
|
5
2
|
function createFormView(page, resource, view) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
3
|
+
return {
|
|
4
|
+
field: (fieldName) => {
|
|
5
|
+
page.getByTestId(`form-field:${resource}:${view}:${fieldName}`);
|
|
6
|
+
return {
|
|
7
|
+
input: () => page.getByTestId(`form-field-input:${resource}:${view}:${fieldName}`),
|
|
8
|
+
error: () => page.getByTestId(`form-field-error:${resource}:${view}:${fieldName}`),
|
|
9
|
+
help: () => page.getByTestId(`form-field-help:${resource}:${view}:${fieldName}`)
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
group: (groupKey) => page.getByTestId(`form-group:${resource}:${view}:${groupKey}`),
|
|
13
|
+
submit: () => page.getByTestId(`form-submit:${resource}:${view}`),
|
|
14
|
+
cancel: () => page.getByTestId(`form-cancel:${resource}:${view}`),
|
|
15
|
+
action: (actionName) => page.getByTestId(`form-action:${resource}:${view}:${actionName}`)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/list-view.ts
|
|
23
20
|
function pathStr(path) {
|
|
24
|
-
|
|
21
|
+
return path.join("-");
|
|
25
22
|
}
|
|
26
23
|
function createListView(page, resource, options = {}) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
24
|
+
const path = options.basePath ?? `/${resource}`;
|
|
25
|
+
const filterBase = `list-filter:${resource}`;
|
|
26
|
+
const sortBase = (field) => `list-sort:${resource}:${field}`;
|
|
27
|
+
const rowBase = (rowPath) => `${filterBase}:row:${pathStr(rowPath)}`;
|
|
28
|
+
const groupBase = (groupPath) => `${filterBase}:group:${pathStr(groupPath)}`;
|
|
29
|
+
return {
|
|
30
|
+
goto: async () => {
|
|
31
|
+
await page.goto(path);
|
|
32
|
+
},
|
|
33
|
+
row: (recordId) => createRowObject(page, resource, recordId),
|
|
34
|
+
rows: () => page.locator(`[data-testid^="list-row:${resource}:"]`),
|
|
35
|
+
column: (fieldName) => page.locator(`[data-testid^="list-cell:${resource}:"][data-testid$=":${fieldName}"]`),
|
|
36
|
+
columnMenu: (fieldName) => page.getByTestId(sortBase(fieldName)),
|
|
37
|
+
columnSort: (fieldName, direction) => page.getByTestId(`${sortBase(fieldName)}:sort-${direction}`),
|
|
38
|
+
columnMove: (fieldName, direction) => page.getByTestId(`${sortBase(fieldName)}:move-${direction}`),
|
|
39
|
+
columnsToggle: () => page.getByTestId(`list-columns:${resource}`),
|
|
40
|
+
columnsOption: (columnId) => page.getByTestId(`list-columns-option:${resource}:${columnId}`),
|
|
41
|
+
pageSize: () => page.getByTestId(`list-page-size:${resource}`),
|
|
42
|
+
search: () => page.getByTestId(`list-search:${resource}`),
|
|
43
|
+
filtersContainer: () => page.getByTestId(`list-filters:${resource}`),
|
|
44
|
+
filterButton: () => page.getByTestId(`${filterBase}:button`),
|
|
45
|
+
filterPanel: () => page.getByTestId(`${filterBase}:panel`),
|
|
46
|
+
filterAddRow: (groupPath = []) => page.getByTestId(`${groupBase(groupPath)}:add-row`),
|
|
47
|
+
filterRowField: (rowPath) => page.getByTestId(`${rowBase(rowPath)}:field`),
|
|
48
|
+
filterRowFieldOption: (rowPath, field) => page.getByTestId(`${rowBase(rowPath)}:field:option:${field}`),
|
|
49
|
+
filterRowOp: (rowPath) => page.getByTestId(`${rowBase(rowPath)}:op`),
|
|
50
|
+
filterRowOpOption: (rowPath, op) => page.getByTestId(`${rowBase(rowPath)}:op:option:${op}`),
|
|
51
|
+
filterRowValue: (rowPath) => page.getByTestId(`${rowBase(rowPath)}:value`),
|
|
52
|
+
filterRowRemove: (rowPath) => page.getByTestId(`${rowBase(rowPath)}:remove`),
|
|
53
|
+
filterApply: () => page.getByTestId(`${filterBase}:apply`),
|
|
54
|
+
filterReset: () => page.getByTestId(`${filterBase}:reset`),
|
|
55
|
+
filterBadge: (index) => page.getByTestId(`${filterBase}:badge:${index}`),
|
|
56
|
+
filterBadgeRemove: (index) => page.getByTestId(`${filterBase}:badge:${index}:remove`),
|
|
57
|
+
filterClearAll: () => page.getByTestId(`${filterBase}:clear-all`),
|
|
58
|
+
filterPinned: (field) => page.getByTestId(`${filterBase}:pinned:${field}`),
|
|
59
|
+
bulkBar: () => page.getByTestId(`list-bulk-bar:${resource}`),
|
|
60
|
+
bulkAction: (actionName) => page.getByTestId(`bulk-action:${resource}:${actionName}`),
|
|
61
|
+
paginationPrev: () => page.getByTestId(`list-pagination-prev:${resource}`),
|
|
62
|
+
paginationNext: () => page.getByTestId(`list-pagination-next:${resource}`),
|
|
63
|
+
loadMore: () => page.getByTestId("cursor-load-more"),
|
|
64
|
+
empty: () => page.getByTestId(`list-empty:${resource}`),
|
|
65
|
+
toolbar: () => page.getByTestId(`list-toolbar:${resource}`),
|
|
66
|
+
table: () => page.getByTestId(`list-table:${resource}`),
|
|
67
|
+
savedViews: () => page.getByTestId(`list-saved-views:${resource}`),
|
|
68
|
+
savedViewsMenu: () => page.getByTestId(`list-saved-views-menu:${resource}`),
|
|
69
|
+
savedViewEntries: () => page.locator(`[data-testid^="list-saved-view:${resource}:"]`),
|
|
70
|
+
savedView: (viewId) => page.getByTestId(`list-saved-view:${resource}:${viewId}`),
|
|
71
|
+
savedViewSave: () => page.getByTestId(`list-saved-view-save:${resource}`),
|
|
72
|
+
savedViewSaveInput: () => page.getByTestId(`list-saved-view-save-input:${resource}`),
|
|
73
|
+
savedViewSaveConfirm: () => page.getByTestId(`list-saved-view-save-confirm:${resource}`),
|
|
74
|
+
savedViewManage: () => page.getByTestId(`list-saved-view-manage:${resource}`),
|
|
75
|
+
savedViewManageDelete: (viewId) => page.getByTestId(`list-saved-view-manage-delete:${resource}:${viewId}`)
|
|
76
|
+
};
|
|
59
77
|
}
|
|
60
78
|
function createRowObject(page, resource, recordId) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
79
|
+
const rowId = `list-row:${resource}:${recordId}`;
|
|
80
|
+
return {
|
|
81
|
+
root: () => page.getByTestId(rowId),
|
|
82
|
+
cell: (fieldName) => page.getByTestId(`list-cell:${resource}:${recordId}:${fieldName}`),
|
|
83
|
+
action: (actionName) => page.getByTestId(`list-row-action:${resource}:${recordId}:${actionName}`),
|
|
84
|
+
checkbox: () => page.getByTestId(`list-row-checkbox:${resource}:${recordId}`),
|
|
85
|
+
open: async () => {
|
|
86
|
+
await page.getByTestId(rowId).click();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/picker-object.ts
|
|
73
92
|
function createPickerObject(page, targetResource) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
93
|
+
const prefix = `relation-picker:${targetResource}`;
|
|
94
|
+
return {
|
|
95
|
+
trigger: () => page.getByTestId(prefix),
|
|
96
|
+
search: () => page.getByTestId(`${prefix}:search`),
|
|
97
|
+
list: () => page.getByTestId(`${prefix}:list`),
|
|
98
|
+
option: (value) => page.getByTestId(`${prefix}:option:${value}`),
|
|
99
|
+
empty: () => page.getByTestId(`${prefix}:empty`),
|
|
100
|
+
clear: () => page.getByTestId(`${prefix}:clear`),
|
|
101
|
+
advanced: () => page.getByTestId(`${prefix}:advanced`),
|
|
102
|
+
viewAll: () => page.getByTestId(`${prefix}:view-all`),
|
|
103
|
+
dialog: () => page.getByTestId(`relation-picker-dialog:${targetResource}`),
|
|
104
|
+
dialogSearch: () => page.getByTestId(`relation-picker-dialog:${targetResource}:search`),
|
|
105
|
+
unregistered: () => page.getByTestId(`${prefix}:unregistered`)
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/show-view.ts
|
|
110
|
+
function createShowView(page, resource, recordId) {
|
|
111
|
+
return {
|
|
112
|
+
...createFormView(page, resource, "show"),
|
|
113
|
+
root: () => page.getByTestId(`page-show:${resource}:${recordId}`)
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/resource-object.ts
|
|
90
118
|
function createResourceObject(page, name) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
119
|
+
return {
|
|
120
|
+
name,
|
|
121
|
+
list: (options) => createListView(page, name, options),
|
|
122
|
+
edit: (_recordId) => createFormView(page, name, "edit"),
|
|
123
|
+
show: (recordId) => createShowView(page, name, recordId),
|
|
124
|
+
create: () => createFormView(page, name, "create"),
|
|
125
|
+
picker: () => createPickerObject(page, name)
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/buro-page.ts
|
|
102
130
|
function createBuroPage(page) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
131
|
+
return {
|
|
132
|
+
resource: (name) => createResourceObject(page, name),
|
|
133
|
+
navMenuItem: (resource) => page.getByTestId(`nav-menu-item:${resource}`),
|
|
134
|
+
sidebarCustomPage: (pageKey) => page.getByTestId(`sidebar-custompage:${pageKey}`),
|
|
135
|
+
contextPicker: (sliceName) => page.getByTestId(`context-picker:${sliceName}`),
|
|
136
|
+
contextPickerOption: (sliceName, value) => page.getByTestId(`context-picker-option:${sliceName}:${value}`),
|
|
137
|
+
languageSwitch: () => page.getByTestId("language-switch"),
|
|
138
|
+
languageSwitchOption: (localeCode) => page.getByTestId(`language-switch:${localeCode}`),
|
|
139
|
+
login: () => ({
|
|
140
|
+
email: () => page.getByTestId("login-email"),
|
|
141
|
+
password: () => page.getByTestId("login-password"),
|
|
142
|
+
submit: () => page.getByTestId("login-submit")
|
|
143
|
+
}),
|
|
144
|
+
taskRun: (name) => ({
|
|
145
|
+
root: () => page.getByTestId(`task-run:${name}`),
|
|
146
|
+
progress: () => page.getByTestId(`task-run-progress:${name}`),
|
|
147
|
+
failure: (subject) => page.getByTestId(`task-run-failure:${name}:${subject}`)
|
|
148
|
+
}),
|
|
149
|
+
notification: (type) => page.getByTestId(`notification:${type}`),
|
|
150
|
+
actionConfirm: (resource, scope, actionName) => page.getByTestId(`action-confirm-dialog:${resource}:${scope}:${actionName}`),
|
|
151
|
+
page
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/confirm-dialog.ts
|
|
113
156
|
function createConfirmDialog(page, resource, scope, actionName) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
function context(signal) {
|
|
127
|
-
return Object.freeze({
|
|
128
|
-
signal,
|
|
129
|
-
requestContext: REQUEST_CONTEXT,
|
|
130
|
-
session: SESSION,
|
|
131
|
-
providerServiceKey: "contract-provider"
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
function queryShape(kind, value) {
|
|
135
|
-
if (kind === "custom") return;
|
|
136
|
-
expect(value).toBeTypeOf("object");
|
|
137
|
-
if (kind === "list" || kind === "many")
|
|
138
|
-
expect(value.data).toBeInstanceOf(Array);
|
|
139
|
-
if (kind === "one") expect(value).toHaveProperty("data");
|
|
140
|
-
if (kind === "count")
|
|
141
|
-
expect([null, "number"]).toContain(typeof value.total);
|
|
142
|
-
}
|
|
143
|
-
function observed(fixture, expected, signal) {
|
|
144
|
-
expect(fixture.observeCalls()).toContainEqual(expect.objectContaining({ ...expected, signal }));
|
|
145
|
-
}
|
|
146
|
-
async function assertBatch(provider, fixture, operations, expected) {
|
|
147
|
-
expect(provider.batch?.queries).toBeTypeOf("function");
|
|
148
|
-
const controller = new AbortController();
|
|
149
|
-
const result = await provider.batch.queries(operations, context(controller.signal));
|
|
150
|
-
validateBatchResult(operations, result);
|
|
151
|
-
if (expected !== void 0) expect(result).toEqual(expected);
|
|
152
|
-
for (const entry of result.results) if (entry.status === "error") dataError(entry.error);
|
|
153
|
-
observed(
|
|
154
|
-
fixture,
|
|
155
|
-
{ lifecycle: "batch", descriptors: operations.map((operation) => operation.descriptor) },
|
|
156
|
-
controller.signal
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
function dataError(value) {
|
|
160
|
-
expect(isDataError(value)).toBe(true);
|
|
161
|
-
}
|
|
162
|
-
function livePlan(value) {
|
|
163
|
-
expect(value, "descriptors.live was supplied, so live.open must return a plan").not.toBeNull();
|
|
164
|
-
expect(value).toBeTypeOf("object");
|
|
165
|
-
expect(value?.subscribe).toBeTypeOf("function");
|
|
166
|
-
}
|
|
167
|
-
function liveDescriptorRequired(hasLiveSlot, descriptor) {
|
|
168
|
-
if (!hasLiveSlot) return;
|
|
169
|
-
expect(
|
|
170
|
-
descriptor,
|
|
171
|
-
"the provider exposes a `live` slot, so the fixture must supply `descriptors.live` \u2014 omitting it silently skips the whole live cell"
|
|
172
|
-
).toBeDefined();
|
|
173
|
-
}
|
|
174
|
-
function dataProviderContract(name, fixture) {
|
|
175
|
-
describe(`${name} data provider contract`, () => {
|
|
176
|
-
for (const kind of ["list", "one", "many", "count", "custom"]) {
|
|
177
|
-
it(`preserves the ${kind} query descriptor and AbortSignal`, async () => {
|
|
178
|
-
const provider = await fixture.create();
|
|
179
|
-
const descriptor = fixture.descriptors.queries?.[kind];
|
|
180
|
-
const handler = provider.queries?.[kind];
|
|
181
|
-
if (descriptor === void 0 || handler === void 0) return;
|
|
182
|
-
const controller = new AbortController();
|
|
183
|
-
const result = await handler(descriptor, context(controller.signal));
|
|
184
|
-
queryShape(kind, result);
|
|
185
|
-
const expected = fixture.descriptors.expected?.queries?.[kind];
|
|
186
|
-
if (expected !== void 0) expect(result).toEqual(expected);
|
|
187
|
-
observed(fixture, { lifecycle: "query", kind, descriptor }, controller.signal);
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
for (const kind of [
|
|
191
|
-
"createOne",
|
|
192
|
-
"createMany",
|
|
193
|
-
"updateOne",
|
|
194
|
-
"updateMany",
|
|
195
|
-
"deleteOne",
|
|
196
|
-
"deleteMany",
|
|
197
|
-
"custom"
|
|
198
|
-
]) {
|
|
199
|
-
it(`validates ${kind} mutation output and preserves its request`, async () => {
|
|
200
|
-
const provider = await fixture.create();
|
|
201
|
-
const descriptor = fixture.descriptors.mutations?.[kind];
|
|
202
|
-
const handler = provider.mutations?.[kind];
|
|
203
|
-
if (descriptor === void 0 || handler === void 0) return;
|
|
204
|
-
const controller = new AbortController();
|
|
205
|
-
const result = await handler(descriptor, context(controller.signal));
|
|
206
|
-
validateMutationResult(descriptor, result);
|
|
207
|
-
const expected = fixture.descriptors.expected?.mutations?.[kind];
|
|
208
|
-
if (expected !== void 0) expect(result).toEqual(expected);
|
|
209
|
-
observed(fixture, { lifecycle: "mutation", kind, descriptor }, controller.signal);
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
for (const specimen of fixture.descriptors.errors ?? []) {
|
|
213
|
-
it(`returns a structured error for the ${specimen.lifecycle}.${specimen.kind} error specimen`, async () => {
|
|
214
|
-
const provider = await fixture.create();
|
|
215
|
-
const controller = new AbortController();
|
|
216
|
-
const handler = specimen.lifecycle === "query" ? provider.queries?.[specimen.kind] : provider.mutations?.[specimen.kind];
|
|
217
|
-
expect(handler).toBeTypeOf("function");
|
|
218
|
-
try {
|
|
219
|
-
await handler(specimen.descriptor, context(controller.signal));
|
|
220
|
-
throw new Error("Provider error specimen resolved instead of rejecting.");
|
|
221
|
-
} catch (error) {
|
|
222
|
-
dataError(error);
|
|
223
|
-
}
|
|
224
|
-
observed(
|
|
225
|
-
fixture,
|
|
226
|
-
{ lifecycle: specimen.lifecycle, kind: specimen.kind, descriptor: specimen.descriptor },
|
|
227
|
-
controller.signal
|
|
228
|
-
);
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
it("reports absent optional capabilities without invoking fallback handlers", async () => {
|
|
232
|
-
const provider = await fixture.create();
|
|
233
|
-
const before = fixture.observeCalls().length;
|
|
234
|
-
for (const kind of ["list", "one", "many", "count", "custom"]) {
|
|
235
|
-
if (provider.queries?.[kind] === void 0) {
|
|
236
|
-
const capability = resolveDataCapability(provider, { lifecycle: "query", kind });
|
|
237
|
-
expect(capability).toMatchObject({ kind: "capability", code: "missing-data-capability" });
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
for (const kind of [
|
|
241
|
-
"createOne",
|
|
242
|
-
"createMany",
|
|
243
|
-
"updateOne",
|
|
244
|
-
"updateMany",
|
|
245
|
-
"deleteOne",
|
|
246
|
-
"deleteMany",
|
|
247
|
-
"custom"
|
|
248
|
-
]) {
|
|
249
|
-
if (provider.mutations?.[kind] === void 0) {
|
|
250
|
-
const capability = resolveDataCapability(provider, { lifecycle: "mutation", kind });
|
|
251
|
-
expect(capability).toMatchObject({ kind: "capability", code: "missing-data-capability" });
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
expect(fixture.observeCalls()).toHaveLength(before);
|
|
255
|
-
});
|
|
256
|
-
it("validates batch IDs, kinds, partial errors, and the shared AbortSignal", async () => {
|
|
257
|
-
const provider = await fixture.create();
|
|
258
|
-
const operations = fixture.descriptors.batch;
|
|
259
|
-
if (provider.batch?.queries === void 0 || operations === void 0) return;
|
|
260
|
-
await assertBatch(provider, fixture, operations, fixture.descriptors.expected?.batch);
|
|
261
|
-
});
|
|
262
|
-
for (const [index, operations] of (fixture.descriptors.batchGroups ?? []).entries()) {
|
|
263
|
-
it(`keeps batch group ${index + 1} isolated and validates its partial results`, async () => {
|
|
264
|
-
const provider = await fixture.create();
|
|
265
|
-
await assertBatch(provider, fixture, operations, void 0);
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
for (const kind of ["offset", "cursor"]) {
|
|
269
|
-
it(`preserves ${kind} pagination and its mapped total/page shape`, async () => {
|
|
270
|
-
const provider = await fixture.create();
|
|
271
|
-
const descriptor = fixture.descriptors.pagination?.[kind];
|
|
272
|
-
if (descriptor === void 0 || provider.queries?.list === void 0) return;
|
|
273
|
-
const controller = new AbortController();
|
|
274
|
-
const result = await provider.queries.list(descriptor, context(controller.signal));
|
|
275
|
-
queryShape("list", result);
|
|
276
|
-
const expected = fixture.descriptors.expected?.pagination?.[kind];
|
|
277
|
-
if (expected !== void 0) expect(result).toEqual(expected);
|
|
278
|
-
observed(fixture, { lifecycle: "query", kind: "list", descriptor }, controller.signal);
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
it("opens live plans with the complete descriptor and subscribes with an AbortSignal", async () => {
|
|
282
|
-
const provider = await fixture.create();
|
|
283
|
-
const descriptor = fixture.descriptors.live;
|
|
284
|
-
liveDescriptorRequired(provider.live !== void 0, descriptor);
|
|
285
|
-
if (provider.live === void 0 || descriptor === void 0) return;
|
|
286
|
-
const openController = new AbortController();
|
|
287
|
-
const plan = await provider.live.open(descriptor, context(openController.signal));
|
|
288
|
-
observed(fixture, { lifecycle: "live-open", descriptor }, openController.signal);
|
|
289
|
-
livePlan(plan);
|
|
290
|
-
if (plan === null) return;
|
|
291
|
-
const subscribeController = new AbortController();
|
|
292
|
-
const observer = {
|
|
293
|
-
next: () => void 0,
|
|
294
|
-
status: () => void 0,
|
|
295
|
-
error: () => void 0,
|
|
296
|
-
complete: () => void 0
|
|
297
|
-
};
|
|
298
|
-
const unsubscribe = await plan.subscribe(observer, { signal: subscribeController.signal });
|
|
299
|
-
observed(fixture, { lifecycle: "live-subscribe" }, subscribeController.signal);
|
|
300
|
-
await unsubscribe();
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// src/index.ts
|
|
306
|
-
var PACKAGE_NAME = "@burojs/test-helpers";
|
|
307
|
-
var PACKAGE_VERSION = "0.0.0";
|
|
157
|
+
return {
|
|
158
|
+
dialog: () => page.getByTestId(`action-confirm-dialog:${resource}:${scope}:${actionName}`),
|
|
159
|
+
yes: () => page.getByTestId(`action-confirm-yes:${resource}:${scope}:${actionName}`),
|
|
160
|
+
no: () => page.getByTestId(`action-confirm-no:${resource}:${scope}:${actionName}`)
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/index.ts
|
|
165
|
+
const PACKAGE_NAME = "@burojs/test-helpers";
|
|
166
|
+
const PACKAGE_VERSION = "0.0.0";
|
|
167
|
+
//#endregion
|
|
168
|
+
export { PACKAGE_NAME, PACKAGE_VERSION, createBuroPage, createConfirmDialog, createFormView, createListView, createPickerObject, createResourceObject, createShowView };
|
|
308
169
|
|
|
309
|
-
export { PACKAGE_NAME, PACKAGE_VERSION, createBuroPage, createConfirmDialog, createFormView, createListView, createPickerObject, createResourceObject, createShowView, dataProviderContract };
|
|
310
|
-
//# sourceMappingURL=index.js.map
|
|
311
170
|
//# sourceMappingURL=index.js.map
|