سامانه صدور فاکتور و حسابداری
test(pages): reproduce original inert CSP login clicks under a stalled ERP script
davoodmehraban89 committed
Oct 12, 2026 at 20:32 UTC
52d00ea0bb9120cda407190d5145c859737002c8
1 file changed
+30
scripts/pages-artifact.spec.js
+30
@@ -25,3 +25,33 @@ test('hardened Pages artifact loads without script/CSP console errors',async({pa
25
expect(diag.status()).toBe(404);
26
expect(errors).toEqual([]);
27
});
28
+
29
+
30
+test('Production CSP login and connectivity actions work while later ERP JS is still downloading',async({page})=>{
31
+ let delayedModuleFinished=false;
32
+ await page.route('**/js/phase6-reporting.js*',async route=>{
33
+ await new Promise(resolve=>setTimeout(resolve,5000));
34
+ delayedModuleFinished=true;
35
+ await route.continue();
36
+ });
37
+ await page.route('**/auth/v1/health',route=>route.fulfill({
38
+ status:200,
39
+ contentType:'application/json',
40
+ headers:{'access-control-allow-origin':'*'},
41
+ body:'{"status":"ok"}'
42
+ }));
43
+ // The actual hardened Pages output removes inline onclick attributes.
44
+ await page.goto(base,{waitUntil:'commit'});
45
+ await expect(page.locator('#auth-connectivity-check')).toBeEnabled({timeout:4000});
46
+ expect(await page.evaluate(()=>window.FinoraLoginActionsBound)).toBe(true);
47
+ expect(delayedModuleFinished,'Login actions must be wired before slow ERP scripts').toBe(false);
48
+ await page.locator('#auth-connectivity-check').click();
49
+ await expect(page.locator('#auth-connectivity-result')).toContainText('AUTH_OK',{timeout:2500});
50
+ expect(delayedModuleFinished,'Connectivity check must not await unrelated modules').toBe(false);
51
+ const alertHandled=page.waitForEvent('dialog').then(async d=>{
52
+ expect(d.message()).toContain('ایمیل');
53
+ await d.dismiss();
54
+ });
55
+ await Promise.all([page.locator('#auth-login-button').click(),alertHandled]);
56
+ expect(delayedModuleFinished).toBe(false);
57
+});