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-SPC-05: systemAdmin inspects readonly Address Resource without mutation controls
10
+ - Location: repo-e2e/specs/a-commerce.spec.ts:1371: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,226 @@
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 >> Commerce session SSR: theme cookie selects raw server theme
10
+ - Location: repo-e2e/specs/a-commerce.spec.ts:397:1
11
+
12
+ # Error details
13
+
14
+ ```
15
+ Error: expect(received).toBe(expected) // Object.is equality
16
+
17
+ Expected: "private, no-store"
18
+ Received: "no-cache, no-store, must-revalidate"
19
+ ```
20
+
21
+ # Test source
22
+
23
+ ```ts
24
+ 333 | expect(publicPageErrors).toEqual([]);
25
+ 334 | expect(publicConsoleErrors).toEqual([]);
26
+ 335 | } finally {
27
+ 336 | await publicContext.close();
28
+ 337 | }
29
+ 338 | } finally {
30
+ 339 | await context.close();
31
+ 340 | }
32
+ 341 | },
33
+ 342 | );
34
+ 343 |
35
+ 344 | test(
36
+ 345 | 'Commerce theme: public auto preference mirrors resolved media value without hydration mismatch',
37
+ 346 | { tag: ['@web', '@ssr', '@theme'] },
38
+ 347 | async ({ browser }) => {
39
+ 348 | const context = await browser.newContext();
40
+ 349 | await context.addInitScript(() => localStorage.setItem('themedark', JSON.stringify('auto')));
41
+ 350 | const page = await context.newPage();
42
+ 351 | await page.emulateMedia({ colorScheme: 'dark' });
43
+ 352 | const pageErrors = collectPageErrors(page);
44
+ 353 | const consoleErrors = collectConsoleErrors(page);
45
+ 354 | try {
46
+ 355 | await page.goto('/commerce', { waitUntil: 'load' });
47
+ 356 | await expect(page.locator('html')).toHaveAttribute('data-zova-hydrated', 'commerce');
48
+ 357 | await expect(page.locator('body')).toHaveAttribute('data-theme', 'dark');
49
+ 358 | await expect
50
+ 359 | .poll(() => page.evaluate(() => localStorage.getItem('themedark')))
51
+ 360 | .toBe('"auto"');
52
+ 361 | expect((await context.cookies()).find(cookie => cookie.name === 'themedark')?.value).toBe(
53
+ 362 | 'true',
54
+ 363 | );
55
+ 364 | expect(pageErrors).toEqual([]);
56
+ 365 | expect(consoleErrors).toEqual([]);
57
+ 366 | } finally {
58
+ 367 | await context.close();
59
+ 368 | }
60
+ 369 | },
61
+ 370 | );
62
+ 371 |
63
+ 372 | test(
64
+ 373 | 'Commerce public SSR: theme cookie does not change SSR HTML',
65
+ 374 | { tag: ['@web', '@ssr', '@theme'] },
66
+ 375 | async ({ request }) => {
67
+ 376 | const responses = await Promise.all([
68
+ 377 | request.get('/commerce'),
69
+ 378 | request.get('/commerce', { headers: { Cookie: 'themedark=true' } }),
70
+ 379 | request.get('/commerce', { headers: { Cookie: 'themedark=false' } }),
71
+ 380 | ]);
72
+ 381 | const html = await Promise.all(responses.map(response => response.text()));
73
+ 382 | for (const [index, response] of responses.entries()) {
74
+ 383 | expect(response.status(), `public response ${index}`).toBe(200);
75
+ 384 | expect(response.headers()['cache-control'], `public response ${index}`).toBe(
76
+ 385 | 'no-cache, no-store, must-revalidate',
77
+ 386 | );
78
+ 387 | expect(html[index].toLowerCase()).not.toContain('data-zova-hydrated');
79
+ 388 | expect(html[index]).toContain('data-ssr-theme-dark-false="light"');
80
+ 389 | expect(html[index]).toContain('data-ssr-theme-dark-true="dark"');
81
+ 390 | expect(html[index]).not.toContain('ssr_cookie_themedark');
82
+ 391 | expect(html[index]).toContain("window.matchMedia('(prefers-color-scheme: dark)')");
83
+ 392 | expect(html[index]).not.toMatch(/<body[^>]*data-theme="(?:dark|light)"/);
84
+ 393 | }
85
+ 394 | },
86
+ 395 | );
87
+ 396 |
88
+ 397 | test(
89
+ 398 | 'Commerce session SSR: theme cookie selects raw server theme',
90
+ 399 | { tag: ['@web', '@ssr', '@theme'] },
91
+ 400 | async ({ browser, request }, testInfo) => {
92
+ 401 | const customer = await registerCustomer(request, testInfo);
93
+ 402 | const context = await browser.newContext();
94
+ 403 | const page = await context.newPage();
95
+ 404 | try {
96
+ 405 | await login(
97
+ 406 | page,
98
+ 407 | '/commerce/commerce/member/address',
99
+ 408 | customer.username,
100
+ 409 | customer.password,
101
+ 410 | 'commerce',
102
+ 411 | );
103
+ 412 | const origin = new URL(page.url()).origin;
104
+ 413 | const authCookies = (await context.cookies()).filter(cookie => cookie.name !== 'themedark');
105
+ 414 | const getSessionHtml = async (value: string) => {
106
+ 415 | const sessionContext = await browser.newContext();
107
+ 416 | try {
108
+ 417 | await sessionContext.addCookies([
109
+ 418 | ...authCookies.map(({ domain, path, ...cookie }) => ({ ...cookie, url: origin })),
110
+ 419 | { name: 'themedark', value, url: origin },
111
+ 420 | ]);
112
+ 421 | const response = await sessionContext.request.get('/commerce/commerce/member/address');
113
+ 422 | return { response, html: await response.text() };
114
+ 423 | } finally {
115
+ 424 | await sessionContext.close();
116
+ 425 | }
117
+ 426 | };
118
+ 427 | for (const [value, theme] of [
119
+ 428 | ['true', 'dark'],
120
+ 429 | ['false', 'light'],
121
+ 430 | ] as const) {
122
+ 431 | const { response, html } = await getSessionHtml(value);
123
+ 432 | expect(response.status()).toBe(200);
124
+ > 433 | expect(response.headers()['cache-control']).toBe('private, no-store');
125
+ | ^ Error: expect(received).toBe(expected) // Object.is equality
126
+ 434 | expect(html).toContain(`data-theme="${theme}"`);
127
+ 435 | expect(html).not.toContain('data-ssr-theme-dark-false');
128
+ 436 | expect(html).not.toContain('data-ssr-theme-dark-true');
129
+ 437 | expect(html).not.toContain("window.matchMedia('(prefers-color-scheme: dark)')");
130
+ 438 | expect(html).toContain('Addresses');
131
+ 439 | }
132
+ 440 | } finally {
133
+ 441 | await context.close();
134
+ 442 | }
135
+ 443 | },
136
+ 444 | );
137
+ 445 |
138
+ 446 | test(
139
+ 447 | 'Commerce catalogue: public sellable inventory renders after hydration',
140
+ 448 | { tag: ['@web', '@flow'] },
141
+ 449 | async ({ page }) => {
142
+ 450 | const pageErrors = collectPageErrors(page);
143
+ 451 | const response = await page.goto('/commerce', { waitUntil: 'load' });
144
+ 452 | expect(response?.ok()).toBeTruthy();
145
+ 453 | await expect(page.locator('html')).toHaveAttribute('data-zova-hydrated', 'commerce');
146
+ 454 | await expect(page.getByRole('heading', { name: 'Commerce catalogue' })).toBeVisible();
147
+ 455 | await expect(page.getByRole('link', { name: 'Wireless Headphones' })).toBeVisible();
148
+ 456 | await expect(page.getByText('24 available')).toBeVisible();
149
+ 457 | await page.getByRole('link', { name: 'Wireless Headphones' }).click();
150
+ 458 | await expect(page).toHaveURL(/\/commerce\/product\/\d+(?:\/|$)/);
151
+ 459 | await expect(page.getByRole('heading', { name: 'Wireless Headphones' })).toBeVisible();
152
+ 460 | await expect(page.getByText('HPH-BLK')).toBeVisible();
153
+ 461 | expect(pageErrors).toEqual([]);
154
+ 462 | },
155
+ 463 | );
156
+ 464 |
157
+ 465 | test(
158
+ 466 | 'Commerce catalogue: localized Product navigation preserves locale',
159
+ 467 | { tag: ['@web', '@flow'] },
160
+ 468 | async ({ page, request }) => {
161
+ 469 | const localizedPath = '/commerce/zh-cn';
162
+ 470 | const response = await request.get(localizedPath);
163
+ 471 | expect(response.ok()).toBeTruthy();
164
+ 472 | const html = await response.text();
165
+ 473 | expect(html.toLowerCase()).not.toContain('data-zova-hydrated');
166
+ 474 | expect(html).toContain('商品目录');
167
+ 475 | expect(html).toContain('当前价格和库存以结算时确认为准。');
168
+ 476 |
169
+ 477 | const pageErrors = collectPageErrors(page);
170
+ 478 | const documentResponse = await page.goto(localizedPath, { waitUntil: 'load' });
171
+ 479 | expect(documentResponse?.ok()).toBeTruthy();
172
+ 480 | await expect(page).toHaveURL(/\/commerce\/zh-cn(?:\/|$)/);
173
+ 481 | await expect(page.locator('html')).toHaveAttribute('data-zova-hydrated', 'commerce');
174
+ 482 | await expect(page.getByRole('heading', { name: '商品目录' })).toBeVisible();
175
+ 483 | await expect(page.getByText('当前价格和库存以结算时确认为准。')).toBeVisible();
176
+ 484 | await expect(page.getByText('库存 24 件')).toBeVisible();
177
+ 485 |
178
+ 486 | const productLink = page.getByRole('link', { name: 'Wireless Headphones' });
179
+ 487 | await expect(productLink).toHaveAttribute('href', /\/commerce\/zh-cn\/product\/\d+$/);
180
+ 488 | const productPath = await productLink.getAttribute('href');
181
+ 489 | const productResponse = await request.get(productPath!);
182
+ 490 | expect(productResponse.ok()).toBeTruthy();
183
+ 491 | expect((await productResponse.text()).toLowerCase()).not.toContain('data-zova-hydrated');
184
+ 492 | await productLink.click();
185
+ 493 | await expect(page).toHaveURL(/\/commerce\/zh-cn\/product\/\d+(?:\/|$)/);
186
+ 494 | await expect(page.getByRole('heading', { name: 'Wireless Headphones' })).toBeVisible();
187
+ 495 | await expect(page.getByText('HPH-BLK')).toBeVisible();
188
+ 496 | await expect(page.getByText('库存 24 件')).toBeVisible();
189
+ 497 | await expect(page.getByRole('link', { name: '购物车' })).toHaveAttribute(
190
+ 498 | 'href',
191
+ 499 | '/commerce/commerce/trade/cart',
192
+ 500 | );
193
+ 501 | expect(pageErrors).toEqual([]);
194
+ 502 | },
195
+ 503 | );
196
+ 504 |
197
+ 505 | test(
198
+ 506 | 'Commerce Product: Cart badge keeps SSR initial render neutral',
199
+ 507 | { tag: ['@web', '@cart'] },
200
+ 508 | async ({ page, request }) => {
201
+ 509 | const productPath = '/commerce/product/1';
202
+ 510 | const productResponse = await request.get(productPath);
203
+ 511 | expect(productResponse.ok()).toBeTruthy();
204
+ 512 | const productHtml = await productResponse.text();
205
+ 513 | expect(productHtml.toLowerCase()).not.toContain('data-zova-hydrated');
206
+ 514 | expect(productHtml).toContain('>Cart<!----></a>');
207
+ 515 |
208
+ 516 | const pageErrors = collectPageErrors(page);
209
+ 517 | const documentResponse = await page.goto(productPath, { waitUntil: 'load' });
210
+ 518 | expect(documentResponse?.ok()).toBeTruthy();
211
+ 519 | await expect(page.locator('html')).toHaveAttribute('data-zova-hydrated', 'commerce');
212
+ 520 | await expect(page).toHaveURL(productPath);
213
+ 521 | await expect(page.getByRole('heading', { name: 'Wireless Headphones' })).toBeVisible();
214
+ 522 |
215
+ 523 | const cartLink = page.locator('a[href="/commerce/commerce/trade/cart"]');
216
+ 524 | await expect(cartLink).toHaveCount(1);
217
+ 525 | await expect(cartLink.locator('.badge')).toHaveCount(0);
218
+ 526 | expect(pageErrors).toEqual([]);
219
+ 527 | },
220
+ 528 | );
221
+ 529 |
222
+ 530 | test(
223
+ 531 | 'Commerce Address: session SSR protects an anonymous document request',
224
+ 532 | { tag: ['@web', '@cart'] },
225
+ 533 | async ({ page, request }) => {
226
+ ```