cabloy 5.1.159 → 5.1.160

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.
Files changed (41) hide show
  1. package/.cabloy-version +1 -1
  2. package/CHANGELOG.md +12 -0
  3. package/package.json +1 -1
  4. package/repo-docs/.vitepress/config.mjs +11 -0
  5. package/repo-docs/backend/department-management.md +98 -0
  6. package/repo-docs/backend/menu-authorization.md +124 -0
  7. package/repo-docs/backend/rbac-authorization.md +117 -0
  8. package/repo-docs/backend/resource-field-update.md +2 -2
  9. package/repo-docs/backend/role-management.md +92 -0
  10. package/repo-docs/backend/shared-rbac-architecture.md +339 -0
  11. package/repo-docs/backend/user-management.md +92 -0
  12. package/repo-docs/frontend/model-resource-owner-pattern.md +2 -0
  13. package/repo-docs/frontend/permission-formscene-action-visibility-guide.md +5 -3
  14. package/repo-docs/frontend/table-action-visibility-permission-flow-guide.md +2 -0
  15. package/repo-docs/frontend/table-guide.md +75 -22
  16. package/repo-docs/frontend/table-resource-crud-cookbook.md +25 -4
  17. package/repo-docs/frontend/zova-table-source-reading-map.md +54 -19
  18. package/repo-docs/frontend/zova-table-under-the-hood.md +70 -39
  19. package/test-results/.last-run.json +20 -2
  20. package/test-results/a-commerce-ATP-ADDR-01-aut-11dea-ss-through-Web-self-service/error-context.md +238 -0
  21. package/test-results/a-commerce-ATP-SPC-01-Coup-ef380-mantic-Admin-field-controls/error-context.md +240 -0
  22. package/test-results/a-commerce-ATP-SPC-02-Cate-9f120-on-and-publication-controls/error-context.md +238 -0
  23. package/test-results/a-commerce-ATP-SPC-02-Prod-5f92a-on-and-publication-controls/error-context.md +238 -0
  24. package/test-results/a-commerce-ATP-SPC-02-SKU--2e61e-ency-and-lifecycle-controls/error-context.md +238 -0
  25. package/test-results/a-commerce-ATP-SPC-04-Stoc-fa895--readonly-and-mutation-free/error-context.md +235 -0
  26. package/test-results/a-commerce-ATP-SPC-05-syst-fb406-e-without-mutation-controls/error-context.md +238 -0
  27. package/test-results/a-commerce-Commerce-sessio-4e963-ie-selects-raw-server-theme/error-context.md +226 -0
  28. package/test-results/a-commerce-Commerce-theme--062fe--without-hydration-mismatch/error-context.md +229 -0
  29. package/test-results/a-commerce-PayPal-browser--8672c-t-or-open-an-awaiting-order/error-context.md +238 -0
  30. package/test-results/a-commerce-Payment-callbac-f56c2--reconciles-after-hydration/error-context.md +238 -0
  31. package/test-results/a-commerce-Payment-cancell-3fc74-ified-provider-confirmation/error-context.md +238 -0
  32. package/test-results/a-commerce-Phase-50-60-aut-71d61--observes-operator-shipment/error-context.md +238 -0
  33. package/test-results/a-commerce-Phase-60-custom-407cd-ecutes-a-whole-order-refund/error-context.md +238 -0
  34. package/test-results/cabloy-basic-ATP-BASIC-TAB-e7253-and-pins-configured-columns/error-context.md +240 -0
  35. package/test-results/markdown-ATP-SPC-02-Produc-9d5c2-link-toolbar-edits-Markdown/error-context.md +211 -0
  36. package/test-results/markdown-ATP-SPC-02-Produc-9d6ea-t-editor-and-saves-Markdown/error-context.md +238 -0
  37. package/vona/packages-cli/cli/package.json +1 -1
  38. package/vona/packages-cli/cli-set-api/cli/templates/tools/crudStart/boilerplate/src/entity/{{resourceName}}.tsx_ +1 -1
  39. package/vona/packages-cli/cli-set-api/package.json +1 -1
  40. package/vona/pnpm-lock.yaml +97 -11
  41. package/zova/pnpm-lock.yaml +16 -16
@@ -0,0 +1,238 @@
1
+ # Instructions
2
+
3
+ - Following Playwright test failed.
4
+ - Explain why, be concise, respect Playwright best practices.
5
+ - Provide a snippet of code with the fix, if possible.
6
+
7
+ # Test info
8
+
9
+ - Name: a-commerce.spec.ts >> ATP-ADDR-01: authenticated customer manages Address through Web self-service
10
+ - Location: repo-e2e/specs/a-commerce.spec.ts:556:1
11
+
12
+ # Error details
13
+
14
+ ```
15
+ Error: expect(page).toHaveURL(expected) failed
16
+
17
+ Expected pattern: /\/commerce\/commerce\/member\/address(?:\?|$)/
18
+ Received string: "http://127.0.0.1:7102/commerce/home/base/errorAccessDenied"
19
+ Timeout: 5000ms
20
+
21
+ Call log:
22
+ - Expect "toHaveURL" with timeout 5000ms
23
+ 14 × locator resolved to <html lang="en-us" data-zova-hydrated="commerce">…</html>
24
+ - unexpected value "http://127.0.0.1:7102/commerce/home/base/errorAccessDenied"
25
+
26
+ ```
27
+
28
+ ```yaml
29
+ - text: 403 Access denied.
30
+ - button "Go Home"
31
+ ```
32
+
33
+ # Test source
34
+
35
+ ```ts
36
+ 89 | await expect(passwordInput).toHaveValue(password);
37
+ 90 | await expect(page.getByPlaceholder('Please input captcha')).not.toHaveValue('');
38
+ 91 | const loginResponse = waitForApiResponse(page, 'POST', '/api/home/user/passport/login');
39
+ 92 | await page.getByRole('button', { name: 'Login', exact: true }).click();
40
+ 93 | const loginResponseValue = await loginResponse;
41
+ 94 | if (!loginResponseValue.ok()) {
42
+ 95 | throw new Error(
43
+ 96 | `login failed: ${loginResponseValue.status()} ${await loginResponseValue.text()}`,
44
+ 97 | );
45
+ 98 | }
46
+ 99 | await expect(page).not.toHaveURL(/\/login(?:\?|$)/);
47
+ 100 | }
48
+ 101 | }
49
+ 102 |
50
+ 103 | async function registerCustomer(
51
+ 104 | request: APIRequestContext,
52
+ 105 | testInfo: TestInfo,
53
+ 106 | ): Promise<{ password: string; username: string }> {
54
+ 107 | const id = `${testInfo.workerIndex}-${testInfo.parallelIndex ?? testInfo.retry}-${Date.now()}`;
55
+ 108 | const username = `e2e-address-${id}`;
56
+ 109 | const password = 'address-e2e-password';
57
+ 110 | const captchaResponse = await request.post('/api/captcha/create', {
58
+ 111 | data: { scene: 'captcha-simple:simple' },
59
+ 112 | });
60
+ 113 | expect(captchaResponse.ok()).toBeTruthy();
61
+ 114 | const captcha = (await captchaResponse.json()).data;
62
+ 115 | expect(captcha?.id).toEqual(expect.any(String));
63
+ 116 | expect(captcha?.token).toEqual(expect.any(String));
64
+ 117 |
65
+ 118 | const baseURL = testInfo.project.use.baseURL;
66
+ 119 | if (!baseURL) throw new Error('commerce E2E base URL is unavailable');
67
+ 120 | const consumerUrl = new URL('/home/user/activation', baseURL).toString();
68
+ 121 | const registerResponse = await request.post('/api/home/user/passport/register', {
69
+ 122 | data: {
70
+ 123 | username,
71
+ 124 | email: `${username}@example.test`,
72
+ 125 | password,
73
+ 126 | passwordConfirm: password,
74
+ 127 | consumerUrl,
75
+ 128 | captcha: { id: captcha.id, token: captcha.token },
76
+ 129 | },
77
+ 130 | });
78
+ 131 | expect(registerResponse.ok()).toBeTruthy();
79
+ 132 | const registration = (await registerResponse.json()).data;
80
+ 133 | expect(registration?.jwt?.accessToken).toEqual(expect.any(String));
81
+ 134 | const activateResponse = await request.post(passportTestActivateCurrentPath, {
82
+ 135 | headers: { Authorization: `Bearer ${registration.jwt.accessToken}` },
83
+ 136 | });
84
+ 137 | expect(activateResponse.ok()).toBeTruthy();
85
+ 138 | return { username, password };
86
+ 139 | }
87
+ 140 |
88
+ 141 | function createAddressFixture(testInfo: TestInfo): IAddressFixture {
89
+ 142 | const id = `${testInfo.workerIndex}-${testInfo.parallelIndex ?? testInfo.retry}-${Date.now()}`;
90
+ 143 | return {
91
+ 144 | recipientName: `E2E Address ${id}`,
92
+ 145 | phone: '15555550123',
93
+ 146 | countryCode: 'US',
94
+ 147 | region: 'California',
95
+ 148 | city: `Original City ${id}`,
96
+ 149 | postalCode: '94105',
97
+ 150 | addressLine1: `1 Test Street ${id}`,
98
+ 151 | addressLine2: 'Suite E2E',
99
+ 152 | updatedCity: `Updated City ${id}`,
100
+ 153 | };
101
+ 154 | }
102
+ 155 |
103
+ 156 | function getAddressTextbox(page: Page, name: string): Locator {
104
+ 157 | return page.getByRole('group', { name, exact: true }).getByRole('textbox');
105
+ 158 | }
106
+ 159 |
107
+ 160 | async function fillAddressForm(page: Page, fixture: IAddressFixture) {
108
+ 161 | await getAddressTextbox(page, 'Recipient Name *').fill(fixture.recipientName);
109
+ 162 | await getAddressTextbox(page, 'Phone *').fill(fixture.phone);
110
+ 163 | await getAddressTextbox(page, 'Country Code *').fill(fixture.countryCode);
111
+ 164 | await getAddressTextbox(page, 'Region *').fill(fixture.region);
112
+ 165 | await getAddressTextbox(page, 'City *').fill(fixture.city);
113
+ 166 | await getAddressTextbox(page, 'Postal Code *').fill(fixture.postalCode);
114
+ 167 | await getAddressTextbox(page, 'Address Line 1 *').fill(fixture.addressLine1);
115
+ 168 | await getAddressTextbox(page, 'Address Line 2').fill(fixture.addressLine2);
116
+ 169 | }
117
+ 170 |
118
+ 171 | async function createAddressThroughCustomerPage(
119
+ 172 | browser: Browser,
120
+ 173 | request: APIRequestContext,
121
+ 174 | testInfo: TestInfo,
122
+ 175 | ) {
123
+ 176 | const customer = await registerCustomer(request, testInfo);
124
+ 177 | const fixture = createAddressFixture(testInfo);
125
+ 178 | const context = await browser.newContext();
126
+ 179 | const page = await context.newPage();
127
+ 180 | const pageErrors = collectPageErrors(page);
128
+ 181 |
129
+ 182 | await login(
130
+ 183 | page,
131
+ 184 | '/commerce/commerce/member/address',
132
+ 185 | customer.username,
133
+ 186 | customer.password,
134
+ 187 | 'commerce',
135
+ 188 | );
136
+ > 189 | await expect(page).toHaveURL(/\/commerce\/commerce\/member\/address(?:\?|$)/);
137
+ | ^ Error: expect(page).toHaveURL(expected) failed
138
+ 190 | await expect(page.getByRole('heading', { name: 'Addresses' })).toBeVisible();
139
+ 191 | await expect(page.getByText('No addresses yet.')).toBeVisible();
140
+ 192 |
141
+ 193 | await fillAddressForm(page, fixture);
142
+ 194 | const createResponse = waitForAddressResponse(page, 'POST', `${addressActionPath}/createMine`);
143
+ 195 | const mineResponse = waitForAddressMine(page);
144
+ 196 | await page.getByRole('button', { name: 'Save address', exact: true }).click();
145
+ 197 | await createResponse;
146
+ 198 | await mineResponse;
147
+ 199 | await expect(page.getByRole('heading', { name: fixture.recipientName })).toBeVisible();
148
+ 200 |
149
+ 201 | return { context, fixture, page, pageErrors };
150
+ 202 | }
151
+ 203 |
152
+ 204 | async function deleteAddressThroughCustomerPage(page: Page, fixture: IAddressFixture) {
153
+ 205 | const card = page
154
+ 206 | .locator('article')
155
+ 207 | .filter({ has: page.getByRole('heading', { name: fixture.recipientName }) });
156
+ 208 | const deleteResponse = waitForAddressResponse(page, 'DELETE', /\/deleteMine\/[^/]+$/);
157
+ 209 | const mineResponse = waitForAddressMine(page);
158
+ 210 | await card.getByRole('button', { name: 'Delete', exact: true }).click();
159
+ 211 | await deleteResponse;
160
+ 212 | await mineResponse;
161
+ 213 | await expect(page.getByRole('heading', { name: fixture.recipientName })).toHaveCount(0);
162
+ 214 | await expect(page.getByText('No addresses yet.')).toBeVisible();
163
+ 215 | }
164
+ 216 |
165
+ 217 | test(
166
+ 218 | 'ATP-SSR-01: anonymous Commerce HTML is public and hydration completes',
167
+ 219 | { tag: ['@web', '@smoke'] },
168
+ 220 | async ({ page, request }) => {
169
+ 221 | const response = await request.get('/commerce');
170
+ 222 | expect(response.ok()).toBeTruthy();
171
+ 223 | expect(response.headers()['cache-control']).toBe('no-cache, no-store, must-revalidate');
172
+ 224 | const html = await response.text();
173
+ 225 | const normalizedHtml = html.toLowerCase();
174
+ 226 | expect(normalizedHtml).not.toContain('data-zova-hydrated');
175
+ 227 |
176
+ 228 | for (const marker of privateMarkers) {
177
+ 229 | expect(normalizedHtml).not.toContain(`"${marker}"`);
178
+ 230 | }
179
+ 231 |
180
+ 232 | const pageErrors = collectPageErrors(page);
181
+ 233 | const documentResponse = await page.goto('/commerce', { waitUntil: 'load' });
182
+ 234 | expect(documentResponse?.ok()).toBeTruthy();
183
+ 235 | await expect(page).toHaveURL(/\/commerce(?:\/|$)/);
184
+ 236 | await expect(page.locator('html')).toHaveAttribute('data-zova-hydrated', 'commerce');
185
+ 237 | await expect(page.getByRole('heading', { name: 'Commerce catalogue' })).toBeVisible();
186
+ 238 | await expect(page.getByText('Dashboard')).toHaveCount(0);
187
+ 239 | await expect(page.locator('body')).toBeVisible();
188
+ 240 | await expect(page).not.toHaveTitle(/error/i);
189
+ 241 | expect(pageErrors).toEqual([]);
190
+ 242 | },
191
+ 243 | );
192
+ 244 |
193
+ 245 | test(
194
+ 246 | 'Commerce theme: public local preference mirrors session cookie without hydration mismatch',
195
+ 247 | { tag: ['@web', '@ssr', '@theme'] },
196
+ 248 | async ({ browser, request }, testInfo) => {
197
+ 249 | const customer = await registerCustomer(request, testInfo);
198
+ 250 | const context = await browser.newContext();
199
+ 251 | await context.addInitScript(() => localStorage.setItem('themedark', 'true'));
200
+ 252 | const page = await context.newPage();
201
+ 253 | const pageErrors = collectPageErrors(page);
202
+ 254 | const consoleErrors: string[] = [];
203
+ 255 | page.on('console', message => {
204
+ 256 | if (message.type() === 'error' || /hydration mismatch/i.test(message.text())) {
205
+ 257 | consoleErrors.push(message.text());
206
+ 258 | }
207
+ 259 | });
208
+ 260 | try {
209
+ 261 | await page.goto('/commerce', { waitUntil: 'load' });
210
+ 262 | await page.evaluate(() => localStorage.setItem('themedark', 'true'));
211
+ 263 | await page.reload({ waitUntil: 'load' });
212
+ 264 | await expect(page.locator('html')).toHaveAttribute('data-zova-hydrated', 'commerce');
213
+ 265 | await expect(page.locator('body')).toHaveAttribute('data-theme', 'dark');
214
+ 266 | expect((await context.cookies()).find(cookie => cookie.name === 'themedark')?.value).toBe(
215
+ 267 | 'true',
216
+ 268 | );
217
+ 269 |
218
+ 270 | await login(
219
+ 271 | page,
220
+ 272 | '/commerce/commerce/member/address',
221
+ 273 | customer.username,
222
+ 274 | customer.password,
223
+ 275 | 'commerce',
224
+ 276 | );
225
+ 277 | await expect(page.locator('html')).toHaveAttribute('data-zova-hydrated', 'commerce');
226
+ 278 | await expect(page.locator('body')).toHaveAttribute('data-theme', 'dark');
227
+ 279 | expect(pageErrors).toEqual([]);
228
+ 280 | expect(consoleErrors).toEqual([]);
229
+ 281 | } finally {
230
+ 282 | await context.close();
231
+ 283 | }
232
+ 284 | },
233
+ 285 | );
234
+ 286 |
235
+ 287 | test(
236
+ 288 | 'Commerce theme: session cookie mirrors public local preference without hydration mismatch',
237
+ 289 | { tag: ['@web', '@ssr', '@theme'] },
238
+ ```
@@ -0,0 +1,240 @@
1
+ # Instructions
2
+
3
+ - Following Playwright test failed.
4
+ - Explain why, be concise, respect Playwright best practices.
5
+ - Provide a snippet of code with the fix, if possible.
6
+
7
+ # Test info
8
+
9
+ - Name: a-commerce.spec.ts >> ATP-SPC-01: Coupon Template renders semantic Admin field controls
10
+ - Location: repo-e2e/specs/a-commerce.spec.ts:1443:1
11
+
12
+ # Error details
13
+
14
+ ```
15
+ Error: expect(page).toHaveURL(expected) failed
16
+
17
+ Expected pattern: /\/commerce-admin\/rest\/resource\/commerce-promotion(?:%3A|:|%253A)couponTemplate\/create(?:[/?#]|$)/
18
+ Received string: "http://127.0.0.1:7102/commerce-admin/home/base/errorAccessDenied"
19
+ Timeout: 5000ms
20
+
21
+ Call log:
22
+ - Expect "toHaveURL" with timeout 5000ms
23
+ 2 × locator resolved to <html lang="en-us">…</html>
24
+ - unexpected value "http://127.0.0.1:7102/commerce-admin/home/base/errorAccessDenied"
25
+ 12 × locator resolved to <html lang="en-us" data-zova-hydrated="commerceAdmin">…</html>
26
+ - unexpected value "http://127.0.0.1:7102/commerce-admin/home/base/errorAccessDenied"
27
+
28
+ ```
29
+
30
+ ```yaml
31
+ - text: 403 Access denied.
32
+ - button "Go Home"
33
+ ```
34
+
35
+ # Test source
36
+
37
+ ```ts
38
+ 1360 | await expect(page.getByText('refunded · $45.99')).toBeVisible();
39
+ 1361 | await expect(page.getByText('1 × $45.99 = $45.99')).toBeVisible();
40
+ 1362 | await expect(page.getByRole('heading', { name: 'Shipment' })).toHaveCount(0);
41
+ 1363 | await expect(page.getByRole('alert')).toHaveCount(0);
42
+ 1364 | expect(pageErrors).toEqual([]);
43
+ 1365 | } finally {
44
+ 1366 | await context.close().catch(() => {});
45
+ 1367 | }
46
+ 1368 | },
47
+ 1369 | );
48
+ 1370 |
49
+ 1371 | test(
50
+ 1372 | 'ATP-SPC-05: systemAdmin inspects readonly Address Resource without mutation controls',
51
+ 1373 | { tag: ['@admin', '@flow', '@address'] },
52
+ 1374 | async ({ browser, request }, testInfo) => {
53
+ 1375 | test.setTimeout(60_000);
54
+ 1376 | const customer = await createAddressThroughCustomerPage(browser, request, testInfo);
55
+ 1377 | const adminContext = await browser.newContext();
56
+ 1378 | const adminPage = await adminContext.newPage();
57
+ 1379 | const adminPageErrors = collectPageErrors(adminPage);
58
+ 1380 | const addressMutationMethods: string[] = [];
59
+ 1381 | adminPage.on('request', request => {
60
+ 1382 | const url = new URL(request.url());
61
+ 1383 | if (
62
+ 1384 | url.pathname.startsWith(addressActionPath) &&
63
+ 1385 | ['POST', 'PATCH', 'PUT', 'DELETE'].includes(request.method())
64
+ 1386 | ) {
65
+ 1387 | addressMutationMethods.push(request.method());
66
+ 1388 | }
67
+ 1389 | });
68
+ 1390 |
69
+ 1391 | try {
70
+ 1392 | await adminPage.setViewportSize({ width: 1440, height: 900 });
71
+ 1393 | await login(adminPage, '/commerce-admin/', 'admin', '123456', 'commerceAdmin');
72
+ 1394 | await adminPage.goto('/commerce-admin/rest/resource/commerce-member%3Aaddress', {
73
+ 1395 | waitUntil: 'load',
74
+ 1396 | });
75
+ 1397 | await expect(adminPage).toHaveURL(addressResourceUrl);
76
+ 1398 | const fixtureRow = adminPage.getByRole('row', { name: customer.fixture.recipientName });
77
+ 1399 | await expect(fixtureRow).toBeVisible();
78
+ 1400 | await expect(fixtureRow).toContainText(customer.fixture.recipientName);
79
+ 1401 | await expect(fixtureRow).toContainText(customer.fixture.phone);
80
+ 1402 | await expect(fixtureRow).toContainText(customer.fixture.countryCode);
81
+ 1403 | await expect(fixtureRow).toContainText(customer.fixture.city);
82
+ 1404 | await expect(fixtureRow).not.toContainText(customer.fixture.region);
83
+ 1405 | await expect(fixtureRow).not.toContainText(customer.fixture.postalCode);
84
+ 1406 | await expect(fixtureRow).not.toContainText(customer.fixture.addressLine1);
85
+ 1407 | await expect(fixtureRow).not.toContainText(customer.fixture.addressLine2);
86
+ 1408 | await expect(adminPage.getByRole('button', { name: 'Create', exact: true })).toHaveCount(0);
87
+ 1409 | await expect(
88
+ 1410 | adminPage.locator('a[href*="/rest/resource/"]').filter({ hasText: 'Create' }),
89
+ 1411 | ).toHaveCount(0);
90
+ 1412 |
91
+ 1413 | const addressId = await fixtureRow.getByRole('cell').first().textContent();
92
+ 1414 | expect(addressId).toMatch(/^\d+$/);
93
+ 1415 | await expect(fixtureRow.getByRole('link', { name: addressId! })).toHaveCount(1);
94
+ 1416 | await adminPage.goto(`/commerce-admin/rest/resource/commerce-member%3Aaddress/${addressId}`, {
95
+ 1417 | waitUntil: 'load',
96
+ 1418 | });
97
+ 1419 | await expect(adminPage).toHaveURL(
98
+ 1420 | /\/commerce-admin\/rest\/resource\/commerce-member(?:%3A|:|%253A)address\/\d+(?:[/?#]|$)/,
99
+ 1421 | );
100
+ 1422 | await expect(
101
+ 1423 | adminPage.getByRole('group', { name: 'Address Line 1 *' }).getByRole('textbox'),
102
+ 1424 | ).toHaveValue(customer.fixture.addressLine1);
103
+ 1425 | await expect(
104
+ 1426 | adminPage.getByRole('group', { name: 'City *' }).getByRole('textbox'),
105
+ 1427 | ).toHaveValue(customer.fixture.city);
106
+ 1428 | await expect(adminPage.getByRole('button', { name: 'Back', exact: true })).toBeVisible();
107
+ 1429 | await expect(adminPage.getByRole('button', { name: 'Submit', exact: true })).toHaveCount(0);
108
+ 1430 | expect(addressMutationMethods).toEqual([]);
109
+ 1431 | expect(adminPageErrors).toEqual([]);
110
+ 1432 |
111
+ 1433 | await deleteAddressThroughCustomerPage(customer.page, customer.fixture);
112
+ 1434 | await expect(customer.page.getByRole('alert')).toHaveCount(0);
113
+ 1435 | expect(customer.pageErrors).toEqual([]);
114
+ 1436 | } finally {
115
+ 1437 | await adminContext.close().catch(() => {});
116
+ 1438 | await customer.context.close().catch(() => {});
117
+ 1439 | }
118
+ 1440 | },
119
+ 1441 | );
120
+ 1442 |
121
+ 1443 | test(
122
+ 1444 | 'ATP-SPC-01: Coupon Template renders semantic Admin field controls',
123
+ 1445 | { tag: ['@admin', '@flow', '@fia'] },
124
+ 1446 | async ({ browser }) => {
125
+ 1447 | test.setTimeout(60_000);
126
+ 1448 | const adminContext = await browser.newContext();
127
+ 1449 | const adminPage = await adminContext.newPage();
128
+ 1450 | const adminPageErrors = collectPageErrors(adminPage);
129
+ 1451 | try {
130
+ 1452 | await adminPage.setViewportSize({ width: 1440, height: 900 });
131
+ 1453 | await login(adminPage, '/commerce-admin/', 'admin', '123456', 'commerceAdmin');
132
+ 1454 | await adminPage.goto(
133
+ 1455 | '/commerce-admin/rest/resource/commerce-promotion%3AcouponTemplate/create',
134
+ 1456 | {
135
+ 1457 | waitUntil: 'load',
136
+ 1458 | },
137
+ 1459 | );
138
+ > 1460 | await expect(adminPage).toHaveURL(
139
+ | ^ Error: expect(page).toHaveURL(expected) failed
140
+ 1461 | /\/commerce-admin\/rest\/resource\/commerce-promotion(?:%3A|:|%253A)couponTemplate\/create(?:[/?#]|$)/,
141
+ 1462 | );
142
+ 1463 |
143
+ 1464 | for (const groupName of [
144
+ 1465 | 'Basic Information',
145
+ 1466 | 'Discount Policy',
146
+ 1467 | 'Validity Window',
147
+ 1468 | 'Usage Limits',
148
+ 1469 | ]) {
149
+ 1470 | await expect(adminPage.getByRole('group', { name: groupName })).toBeVisible();
150
+ 1471 | }
151
+ 1472 |
152
+ 1473 | const state = adminPage
153
+ 1474 | .getByRole('group', { name: 'Template State *' })
154
+ 1475 | .getByRole('combobox');
155
+ 1476 | await expect(state).toBeVisible();
156
+ 1477 | await state.selectOption({ label: 'Active' });
157
+ 1478 | await expect(state).toHaveValue('active');
158
+ 1479 |
159
+ 1480 | const discountInput = adminPage
160
+ 1481 | .getByRole('group', { name: 'Fixed Discount *' })
161
+ 1482 | .getByRole('textbox');
162
+ 1483 | const minSpendInput = adminPage
163
+ 1484 | .getByRole('group', { name: 'Minimum Spend *' })
164
+ 1485 | .getByRole('textbox');
165
+ 1486 | await discountInput.fill('12.34');
166
+ 1487 | await minSpendInput.fill('45.67');
167
+ 1488 | await expect(discountInput).toHaveValue('12.34');
168
+ 1489 | await expect(minSpendInput).toHaveValue('45.67');
169
+ 1490 | await expect(
170
+ 1491 | adminPage.getByRole('group', { name: 'Valid From *' }).locator('input[type="date"]'),
171
+ 1492 | ).toBeVisible();
172
+ 1493 | await expect(
173
+ 1494 | adminPage.getByRole('group', { name: 'Valid Until *' }).locator('input[type="date"]'),
174
+ 1495 | ).toBeVisible();
175
+ 1496 |
176
+ 1497 | await adminPage
177
+ 1498 | .getByRole('group', { name: 'Name *' })
178
+ 1499 | .getByRole('textbox')
179
+ 1500 | .fill('E2E Coupon Template');
180
+ 1501 | await adminPage.getByRole('group', { name: 'Currency *' }).getByRole('textbox').fill('USD');
181
+ 1502 | await adminPage
182
+ 1503 | .getByRole('group', { name: 'Valid From *' })
183
+ 1504 | .getByRole('textbox')
184
+ 1505 | .fill('2026-08-04');
185
+ 1506 | await adminPage
186
+ 1507 | .getByRole('group', { name: 'Valid Until *' })
187
+ 1508 | .getByRole('textbox')
188
+ 1509 | .fill('2026-12-31');
189
+ 1510 | await adminPage
190
+ 1511 | .getByRole('group', { name: 'Total Issue Limit' })
191
+ 1512 | .getByRole('textbox')
192
+ 1513 | .fill('10');
193
+ 1514 | await adminPage
194
+ 1515 | .getByRole('group', { name: 'Total Usage Limit' })
195
+ 1516 | .getByRole('textbox')
196
+ 1517 | .fill('10');
197
+ 1518 | await adminPage
198
+ 1519 | .getByRole('group', { name: 'Per-customer Issue Limit' })
199
+ 1520 | .getByRole('textbox')
200
+ 1521 | .fill('1');
201
+ 1522 |
202
+ 1523 | await expect(adminPage.getByRole('button', { name: 'Submit', exact: true })).toBeVisible();
203
+ 1524 | await expect(adminPage.getByRole('button', { name: 'Back', exact: true })).toBeVisible();
204
+ 1525 | expect(adminPageErrors).toEqual([]);
205
+ 1526 | } finally {
206
+ 1527 | await adminContext.close().catch(() => {});
207
+ 1528 | }
208
+ 1529 | },
209
+ 1530 | );
210
+ 1531 |
211
+ 1532 | test(
212
+ 1533 | 'ATP-SPC-02: Category renders semantic Admin relation and publication controls',
213
+ 1534 | { tag: ['@admin', '@flow', '@category'] },
214
+ 1535 | async ({ browser }, testInfo) => {
215
+ 1536 | test.setTimeout(60_000);
216
+ 1537 | const suffix = `${testInfo.workerIndex}-${testInfo.parallelIndex ?? testInfo.retry}-${Date.now()}`;
217
+ 1538 | const parentName = `E2E Category Parent ${suffix}`;
218
+ 1539 | const childName = `E2E Category Child ${suffix}`;
219
+ 1540 | const adminContext = await browser.newContext();
220
+ 1541 | const adminPage = await adminContext.newPage();
221
+ 1542 | const adminPageErrors = collectPageErrors(adminPage);
222
+ 1543 | const categoryCreatePath = '/commerce-admin/rest/resource/commerce-catalog%3Acategory/create';
223
+ 1544 | const categoryListPath = '/commerce-admin/rest/resource/commerce-catalog%3Acategory';
224
+ 1545 | const categoryActionPath = '/api/commerce/catalog/category';
225
+ 1546 | let parentId: number | string | undefined;
226
+ 1547 | let childId: number | string | undefined;
227
+ 1548 | let headers: { Authorization: string } | undefined;
228
+ 1549 | try {
229
+ 1550 | await adminPage.setViewportSize({ width: 1440, height: 900 });
230
+ 1551 | await login(adminPage, '/commerce-admin/', 'admin', '123456', 'commerceAdmin');
231
+ 1552 | const accessToken = (await adminContext.cookies()).find(
232
+ 1553 | cookie => cookie.name === 'token',
233
+ 1554 | )?.value;
234
+ 1555 | expect(accessToken).toBeTruthy();
235
+ 1556 | headers = { Authorization: `Bearer ${accessToken}` };
236
+ 1557 |
237
+ 1558 | const parentCreateResponse = await adminPage.request.post(categoryActionPath, {
238
+ 1559 | data: { name: parentName, published: false },
239
+ 1560 | headers,
240
+ ```