سامانه صدور فاکتور و حسابداری
test(login): delayed static script and duplicate slow sign-in browser regressions
davoodmehraban89 committed
Oct 12, 2026 at 19:39 UTC
a4b15f8ac915fa4c4f8f16531231e8acee2974c3
1 file changed
+43
scripts/phase0-startup-performance.spec.js
+43
@@ -43,3 +43,46 @@ test('F0 startup is independent of optional spreadsheet CDN and keeps on-demand
43
expect(await page.evaluate(()=>typeof window.finoraDownloadConfiguredTemplate)).toBe('function');
44
expect(await page.evaluate(()=>typeof window.XLSX)).toBe('undefined');
45
});
46
+
47
+test('F0 login controls are actionable before a delayed non-auth deferred script completes',async({page})=>{
48
+ const late='phase6-reporting.js';
49
+ let lateFinished=false;
50
+ await page.route('**/js/'+late+'*',async route=>{
51
+ await new Promise(resolve=>setTimeout(resolve,3500));
52
+ lateFinished=true;
53
+ await route.continue();
54
+ });
55
+ const start=Date.now();
56
+ await page.goto(BASE,{waitUntil:'commit'});
57
+ await expect(page.locator('#auth-login-button')).toBeEnabled({timeout:3000});
58
+ const readyMs=Date.now()-start;
59
+ console.info('F0 login form enabled before late ERP script, elapsed ms:',readyMs);
60
+ expect(lateFinished,'Login should not wait on optional ERP source file').toBe(false);
61
+ await page.locator('#auth-email').fill('nobody@example.test');
62
+ await page.locator('#auth-password').fill('qa-fixture-only');
63
+ await expect(page.locator('#auth-email')).toHaveValue('nobody@example.test');
64
+ await expect(page.locator('#auth-login-status')).toHaveAttribute('data-state','ready');
65
+ // Never submit this fake identity to a real server in a startup smoke.
66
+});
67
+
68
+test('F0 login visibly reports a pending mocked sign-in and suppresses duplicate requests',async({page})=>{
69
+ await page.goto(BASE,{waitUntil:'domcontentloaded'});
70
+ await expect.poll(()=>page.evaluate(()=>window.FinoraStartupStatus?.authChecked),{timeout:15000}).toBe(true);
71
+ await page.evaluate(()=>{
72
+ window.finoraFixtureLoginCalls=0;
73
+ sb.auth.signInWithPassword=async()=>{
74
+ window.finoraFixtureLoginCalls+=1;
75
+ return {data:{user:{id:'fixture-nonreal'}},error:null};
76
+ };
77
+ window.fetchCurrentUser=async()=>({id:'fixture-nonreal',email:'fixture@example.test',role:'accountant'});
78
+ window.pullAll=()=>new Promise(()=>{}); // intentionally stalled fixture, zero DB activity
79
+ });
80
+ await page.locator('#auth-email').fill('fixture@example.test');
81
+ await page.locator('#auth-password').fill('synthetic-fixture-only');
82
+ await page.locator('#auth-login-button').click();
83
+ await expect(page.locator('#auth-login-status')).toHaveAttribute('data-state','loading');
84
+ await page.locator('#auth-login-button').click();
85
+ await expect(page.locator('#auth-login-status')).toHaveAttribute('data-state','busy');
86
+ expect(await page.evaluate(()=>window.finoraFixtureLoginCalls)).toBe(1);
87
+ await expect(page.locator('#auth-screen')).toBeVisible();
88
+});