سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 4, 04:15 UTC
test(pages): enforce three core bundles, keep early login responsive and fail closed on core asset error
davoodmehraban89 committed
Oct 13, 2026 at 01:29 UTC
ee418d79afa41766116d9fb63c4a80a2154d9eb4
1 file changed
+44
-1
scripts/pages-artifact.spec.js
+44
-1
@@ -29,7 +29,7 @@ test('hardened Pages artifact loads without script/CSP console errors',async({pa
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=>{
32
+ await page.route('**/js/finora-pages-accounting.js*',async route=>{
33
await new Promise(resolve=>setTimeout(resolve,5000));
34
delayedModuleFinished=true;
35
await route.continue();
@@ -99,3 +99,46 @@ test('A blocked production bundle fails closed and never exposes a partial finan
99
expect(output.loginVisible).toBe(true);
100
expect(output.currentUser).toBe(null);
101
});
102
+
103
+test('Built Pages loads exactly three ordered core groups instead of 38 blocking requests',async({page})=>{
104
+ const names=['foundation','business','accounting'];
105
+ const requests=[];
106
+ page.on('request',r=>{if(new URL(r.url()).pathname.includes('/js/finora-pages-'))requests.push(new URL(r.url()).pathname);});
107
+ await page.goto(base,{waitUntil:'domcontentloaded'});
108
+ await expect.poll(()=>page.evaluate(()=>window.FinoraStartupStatus?.extensionsReady),{timeout:15000}).toBe(true);
109
+ const info=await page.evaluate(()=>({
110
+ scripts:[...document.querySelectorAll('script[src*="finora-pages-"]')].map(el=>new URL(el.src).pathname.split('/').at(-1)),
111
+ blockingFailed:window.FinoraStartupStatus.blockingPagesAssetFailed===true,
112
+ loadedCore:typeof handleLogin,
113
+ loadedAccounting:typeof window.finoraParseMoney==='function'||typeof window.parseFormattedNumber==='function'
114
+ }));
115
+ expect(info.scripts).toEqual(names.map(x=>'finora-pages-'+x+'.js'));
116
+ expect(info.blockingFailed).toBe(false);
117
+ expect(info.loadedCore).toBe('function');
118
+ expect(info.loadedAccounting).toBe(true);
119
+ expect(requests).toEqual(names.map(x=>'/js/finora-pages-'+x+'.js'));
120
+ const html=await page.content();
121
+ for(const legacy of ['js/admin.js','js/patches.js','js/accounting-foundation.js']){
122
+ expect(html).not.toContain('<script src="'+legacy);
123
+ }
124
+});
125
+
126
+test('A blocked required core Pages group prevents opening partial financial workspace',async({page})=>{
127
+ await page.route('**/js/finora-pages-accounting.js*',route=>route.abort('failed'));
128
+ await page.goto(base,{waitUntil:'domcontentloaded'});
129
+ const output=await page.evaluate(async()=>{
130
+ window.fetchCurrentUser=async()=>({id:'fixture-person'});
131
+ await enterApp({id:'fixture-person'},{timeoutMs:300});
132
+ return {
133
+ status:document.getElementById('auth-login-status').textContent,
134
+ visible:getComputedStyle(document.getElementById('auth-screen')).display,
135
+ user:currentUser,
136
+ missing:window.FinoraStartupStatus.blockingPagesAssetFailed
137
+ };
138
+ });
139
+ expect(output.missing).toBe(true);
140
+ expect(output.status).toContain('BOOT_APP_ASSETS_FAILED');
141
+ expect(output.status).not.toContain('fixture-person');
142
+ expect(output.visible).toBe('flex');
143
+ expect(output.user).toBe(null);
144
+});