سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 15:45 UTC
test(pages): verify one bundled request and fail-closed unavailable financial workspace
davoodmehraban89 committed
Oct 13, 2026 at 01:04 UTC
e1156aab97bff385d65cee1fa3bb073d30b3b098
1 file changed
+44
scripts/pages-artifact.spec.js
+44
@@ -55,3 +55,47 @@ test('Production CSP login and connectivity actions work while later ERP JS is s
55
await Promise.all([page.locator('#auth-login-button').click(),alertHandled]);
56
expect(delayedModuleFinished).toBe(false);
57
});
58
+
59
+test('Built Pages uses exactly one SHA-pinned local bundle for all 14 ERP extensions',async({page})=>{
60
+ const requested=[];
61
+ page.on('request',req=>{
62
+ const path=new URL(req.url()).pathname;
63
+ if(path.includes('finora-extension-bundle.js')||/\/(organization-rbac|request-workflow-d2|office-workflow|taxpayer-print)\.js$/.test(path))
64
+ requested.push(path);
65
+ });
66
+ await page.goto(base,{waitUntil:'domcontentloaded'});
67
+ await expect.poll(()=>page.evaluate(()=>window.FinoraStartupStatus?.extensionsReady),{timeout:15000}).toBe(true);
68
+ const state=await page.evaluate(()=>({
69
+ ...window.FinoraStartupStatus,
70
+ bundle:document.querySelector('script[src*="finora-extension-bundle.js"]')?.src||'',
71
+ loaded:typeof window.FINORA_OFFICE_WORKFLOW_C8_UI_VERSION
72
+ }));
73
+ expect(state.extensionBundle).toBe(true);
74
+ expect(state.extensionCount).toBe(14);
75
+ expect(state.failedExtensionCount).toBe(0);
76
+ expect(state.bundle).toMatch(/finora-extension-bundle\.js\?v=[0-9a-f]{16}$/);
77
+ expect(state.loaded).toBe('string');
78
+ expect(requested.filter(x=>x.endsWith('/finora-extension-bundle.js')).length).toBe(1);
79
+ expect(requested.filter(x=>/\/(organization-rbac|request-workflow-d2|office-workflow|taxpayer-print)\.js$/.test(x))).toEqual([]);
80
+});
81
+
82
+test('A blocked production bundle fails closed and never exposes a partial financial workspace',async({page})=>{
83
+ await page.route('**/js/finora-extension-bundle.js*',route=>route.abort('failed'));
84
+ await page.goto(base,{waitUntil:'domcontentloaded'});
85
+ await expect.poll(()=>page.evaluate(()=>window.FinoraStartupStatus?.extensionsReady),{timeout:15000}).toBe(true);
86
+ const output=await page.evaluate(async()=>{
87
+ window.fetchCurrentUser=async()=>({id:'fixture-no-account',role:'accountant'});
88
+ await enterApp({id:'fixture-no-account'}, {timeoutMs:500});
89
+ return {
90
+ status:document.getElementById('auth-login-status').textContent,
91
+ loginVisible:getComputedStyle(document.getElementById('auth-screen')).display!=='none',
92
+ currentUser:currentUser,
93
+ failures:window.FinoraStartupStatus.failedExtensionCount
94
+ };
95
+ });
96
+ expect(output.failures).toBe(14);
97
+ expect(output.status).toContain('BOOT_APP_ASSETS_FAILED');
98
+ expect(output.status).not.toContain('fixture-no-account');
99
+ expect(output.loginVisible).toBe(true);
100
+ expect(output.currentUser).toBe(null);
101
+});