سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 23:15 UTC
test(phase0): assert concurrent ordered startup and unaffected login when CDN fails
davoodmehraban89 committed
Oct 12, 2026 at 12:40 UTC
4e55bd99422b6aa40233adb08bc131411efcb993
1 file changed
+45
scripts/phase0-startup-performance.spec.js
new
+45
@@ -0,0 +1,45 @@
1
+// Phase 0 startup performance: never load a real owner session or read customer data.
2
+const {test,expect}=require('@playwright/test');
3
+const BASE=process.env.FINORA_TEST_BASE_URL||'http://127.0.0.1:4173/index.html';
4
+const EXTENSIONS=[
5
+ 'organization-rbac.js','organization-invitations.js','organization-enterprise-ux.js',
6
+ 'platform-modules.js','office-automation.js','request-workflow-d2.js',
7
+ 'request-workflow-d3b.js','request-workflow-d3c.js','request-workflow-d4a.js',
8
+ 'office-rbac.js','office-mature.js','office-workflow.js',
9
+ 'organization-shell.js','taxpayer-print.js'
10
+];
11
+
12
+test('F0 startup downloads ordered extension scripts concurrently and still initializes login',async({page})=>{
13
+ const started=[];
14
+ // Simulate an affected ISP where each file has its own network round trip.
15
+ await page.route('**/js/**',async route=>{
16
+ const name=new URL(route.request().url()).pathname.split('/').pop();
17
+ if(!EXTENSIONS.includes(name)){await route.continue();return;}
18
+ started.push({name,ms:Date.now()});
19
+ await new Promise(resolve=>setTimeout(resolve,170));
20
+ await route.continue();
21
+ });
22
+ // A failed optional third-party spreadsheet/font CDN must not hold up login.
23
+ await page.route('https://cdn.jsdelivr.net/**',route=>route.abort());
24
+ await page.goto(BASE,{waitUntil:'domcontentloaded'});
25
+ await expect.poll(()=>page.evaluate(()=>window.FinoraStartupStatus?.extensionCount),{timeout:15000}).toBe(14);
26
+ const state=await page.evaluate(()=>window.FinoraStartupStatus);
27
+ expect(state.failedExtensionCount,'No local extension should fail to load').toBe(0);
28
+ expect(started.map(x=>x.name).sort()).toEqual(EXTENSIONS.slice().sort());
29
+ const arrivalWindow=Math.max(...started.map(x=>x.ms))-Math.min(...started.map(x=>x.ms));
30
+ console.info('F0 startup extension dispatch spread browser ms:',arrivalWindow);
31
+ // Old waterfall loads 14 x 170ms sequentially; parallel dispatch is bounded.
32
+ expect(arrivalWindow,'extension network requests should overlap').toBeLessThan(1200);
33
+ await expect(page.locator('#auth-screen')).toBeVisible();
34
+ expect(await page.evaluate(()=>typeof window.finoraLoadScript)).toBe('function');
35
+ expect(await page.evaluate(()=>typeof XLSX)).toBe('undefined');
36
+});
37
+
38
+test('F0 startup is independent of optional spreadsheet CDN and keeps on-demand Excel guard',async({page})=>{
39
+ await page.route('https://cdn.jsdelivr.net/**',route=>route.abort());
40
+ await page.goto(BASE,{waitUntil:'domcontentloaded'});
41
+ await expect.poll(()=>page.evaluate(()=>window.FinoraStartupStatus?.extensionCount),{timeout:15000}).toBe(14);
42
+ await expect(page.locator('#auth-screen')).toBeVisible();
43
+ expect(await page.evaluate(()=>typeof window.finoraDownloadConfiguredTemplate)).toBe('function');
44
+ expect(await page.evaluate(()=>typeof window.XLSX)).toBe('undefined');
45
+});