سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 22:00 UTC
test: diagnose auth hydration and isolate CAS snapshots in browser fixtures
davoodmehraban89 committed
Nov 17, 2026 at 23:55 UTC
d3da74a03c92e295cfea27e8c8eb24caea27608e
5 files changed
+13
-2
scripts/accounting-document-workflow.spec.js
+2
@@ -163,6 +163,8 @@ async function authenticatedMockBrowser(page){
163
throw Error('Unexpected RPC '+name);
164
};
165
await enterApp({id:'FINORA_F0_FIXTURE_ONLY'});
166
+ const authState={display:getComputedStyle(document.getElementById('auth-screen')).display,status:document.getElementById('auth-login-status')?.textContent||'',userId:currentUser?.id||null,startup:window.FinoraStartupStatus};
167
+ if(authState.display!=='none')throw new Error('QA_ENTER_APP_FAILED '+JSON.stringify(authState));
168
document.querySelectorAll('.modal-backdrop.active').forEach(x=>x.classList.remove('active'));
169
switchView('view-invoices');
170
});
scripts/commerce-route-types.spec.js
+2
@@ -12,6 +12,8 @@ async function openCommerce(page,kind='non_formal'){
12
sb.from=()=>({select:()=>({order(){return this},async range(){return {data:rows,error:null}}})});
13
sb.rpc=async(name,args)=>{if(name!=='finora_sync_records_v2')throw Error('Unexpected RPC '+name);return {data:{upserts:(args.p_upserts||[]).map(row=>({collection:row.collection,id:row.id,version:Number(row.expected_version||0)+1})),deletes:(args.p_deletes||[]).map(row=>({collection:row.collection,id:row.id}))},error:null};};
14
await enterApp({id:'COMMERCE_QA'});
15
+ const authState={display:getComputedStyle(document.getElementById('auth-screen')).display,status:document.getElementById('auth-login-status')?.textContent||'',userId:currentUser?.id||null,startup:window.FinoraStartupStatus};
16
+ if(authState.display!=='none')throw new Error('QA_ENTER_APP_FAILED '+JSON.stringify(authState));
17
},kind);
18
await expect(page.locator('#auth-screen')).toBeHidden();
19
await page.locator('.module-tab[data-module="commerce"]').click();
scripts/dom-smoke.spec.js
+4
-1
@@ -193,7 +193,7 @@ test('operational settings persist warehouse, currency and costing with an accur
193
await page.evaluate(()=>{
194
window.alert=()=>{};window.confirm=()=>false;
195
currentUser={id:'QA_OPS_SETTINGS',organizationId:'QA_ORG',role:'admin',modules:['full_suite'],subscription:{type:'lifetime',status:'active',endDate:'2099-01-01'}};
196
- const fresh={};COLLS.forEach(key=>fresh[key]=[]);datastore=fresh;syncSnap.clear();
196
+ const fresh={};COLLS.forEach(key=>fresh[key]=[]);datastore=fresh;syncSnap.clear();syncVersionSnap.clear();
197
datastore.companies=[{id:'QA_OPS_CO',ownerUserId:currentUser.id,name:'Operational Settings Fixture'}];
198
datastore.settings=[{id:'main',ownerUserId:currentUser.id,default_company_id:'QA_OPS_CO',defaultWarehouseId:'QA_WH_A',baseCurrencyCode:'IRR',inventoryCostMethod:'weighted_average'}];
199
datastore.warehouses=[{id:'QA_WH_A',ownerUserId:currentUser.id,companyId:'QA_OPS_CO',name:'Warehouse A',active:true},{id:'QA_WH_B',ownerUserId:currentUser.id,companyId:'QA_OPS_CO',name:'Warehouse B',active:true}];
@@ -206,6 +206,9 @@ test('operational settings persist warehouse, currency and costing with an accur
206
await page.locator('#p5-set-base-cur').selectOption('USD');
207
await page.locator('#p5-set-cost-method').selectOption('weighted_average');
208
await page.locator('#p5-data-root .card').first().getByRole('button',{name:'ذخیره تنظیمات',exact:true}).click();
209
+ await page.waitForTimeout(750);
210
+ const syncDebug=await page.evaluate(()=>({userId:currentUser?.id||null,organizationId:currentUser?.organizationId||null,syncPending,syncRunning,syncFailCount,badge:document.querySelector('#sync-status')?.textContent||'',authDisplay:getComputedStyle(document.getElementById('auth-screen')).display}));
211
+ console.log('OPS_SETTINGS_SYNC_DEBUG '+JSON.stringify(syncDebug));
212
const selected={defaultWarehouseId:'QA_WH_B',baseCurrencyCode:'USD',inventoryCostMethod:'weighted_average'};
213
await expect.poll(()=>{
214
const s=rows.get('settings|main')?.data;
scripts/phase0-invoice-persistence.spec.js
+2
@@ -69,6 +69,8 @@ async function authenticatedMockBrowser(page,companyId='QA_CO',url=BASE){
69
return await window.qaF0Write(args);
70
};
71
await enterApp({id:'FINORA_F0_FIXTURE_ONLY'});
72
+ const authState={display:getComputedStyle(document.getElementById('auth-screen')).display,status:document.getElementById('auth-login-status')?.textContent||'',userId:currentUser?.id||null,startup:window.FinoraStartupStatus};
73
+ if(authState.display!=='none')throw new Error('QA_ENTER_APP_FAILED '+JSON.stringify(authState));
74
switchView('view-invoices');
75
});
76
await expect(page.locator('#auth-screen')).toBeHidden();
scripts/ux-hardening-r2.spec.js
+3
-1
@@ -48,7 +48,9 @@ async function signInSettings(page,user=SETTINGS_USER){
48
sb.from=()=>({select:()=>({order(){return this},async range(from,to){return {data:(await window.qaSettingsRead(currentUser.id)).slice(from,to+1),error:null}}})});
49
sb.rpc=async(name,args)=>{if(name!=='finora_sync_records_v2')throw new Error('Unexpected settings RPC');return window.qaSettingsWrite(currentUser.id,args)};
50
sb.auth.signOut=async()=>{await window.qaSettingsSignOut();return {error:null}};
51
- await enterApp({id});navigateShell('settings','view-settings','experience');
51
+ await enterApp({id});
52
+ const authState={display:getComputedStyle(document.getElementById('auth-screen')).display,status:document.getElementById('auth-login-status')?.textContent||'',userId:currentUser?.id||null,startup:window.FinoraStartupStatus};
53
+ if(authState.display!=='none')throw new Error('QA_ENTER_APP_FAILED '+JSON.stringify(authState));navigateShell('settings','view-settings','experience');
54
},user);
55
await expect(page.locator('#auth-screen')).toBeHidden();
56
await expect(page.locator('#finora-experience-card')).toBeVisible();