@davoodmehraban89 / Factor-easy / commits / bead02f
Fork 0

سامانه صدور فاکتور و حسابداری

fix(phase0): expose bootstrap timeout stage and diagnose PostgREST availability (#114)

* docs(state): record owner-confirmed post-auth login timeout and staged diagnostic scope * fix(login): report only fixed pending bootstrap stages on real account timeout * fix(login): distinguish organization membership from seven authorization queries * fix(login): independently probe read-only PostgREST gateway without credentials * fix(cache): enable new bootstrap stage and PostgREST diagnostics * test(login): enforce REST reachability and privacy-safe bootstrap progress diagnostics * test(login): verify public PostgREST outage independent of reachable GoTrue Auth * test(login): distinguish account identity from tenant hydration timeout without PII * fix(login): bound entire account-context promise even if underlying helper does not settle on abort

davoodmehraban89 committed Oct 12, 2026 at 23:45 UTC bead02fbc48f04e12de8b1565d99d2a3c4af761d
8 files changed +146 -27
PROJECT_STATE.md
+6
@@ -96,6 +96,12 @@ The latest user message is the sole source of new instructions. Read AGENTS.md t
96 - **Operational blocker:** authorized Windows Desktop Commander is paired/ONLINE but tool explicitly said MONTHLY USAGE EXCEEDED and instructed not to retry or reconnect; no tool quota bypass attempted. Independent external `factoreasy.ir` HTTP fetch also inaccessible through web tool. Thus live same-ISP critical-JS/manifest/Auth HTTP outcomes, browser load latency, and authenticated company data read are **NOT VERIFIED**. The CI-gated deploy is proof of publishing but not a user-network acceptance. Owner should hard-refresh Chrome, click built-in diagnostic without entering credentials, report `SITE_JS_*`, `MANIFEST_*`, `AUTH_*` code; compare once using independent mobile hotspot if available. No username/password/private email/tokens. [Issue #106](https://github.com/davoodmehraban89/Factor-easy/issues/106) and F0-01 / Phase 0 remain OPEN.
97 - **Rollback:** revert #112 through protected gated Pages release; no financial DB rollback necessary.
98
99 +### 2026-10-12 Owner confirmed post-authentication login still times out — F0-01 P0 ACTIVE
100 +- **New real user result:** on the affected Chrome/ISP, initial diagnostic `SITE_JS_OK | MANIFEST_OK | AUTH_OK` but password sign-in **does not reach the workspace** and ends with `دریافت اطلاعات حساب بیش از حد طول کشید`. This is a **25-second `enterApp()` bootstrap timeout**, not evidence of incorrect credentials; `AUTH_OK` only probes public GoTrue health. Avoid sharing/storing the owner's screenshot email/password; no live credentials collected.
101 +- **Inspected source:** `enterApp()` concurrently waits `fetchCurrentUser()` (profile + membership + 7 authorization/license organization reads) and `FinoraAppAssetsReady`; it then performs paginated, tenant-scoped `pullAll()` with full atomic snapshot. All are under one 25s cancel signal, but the existing UI gives the same timeout message regardless of which step stalled. Supabase project is ACTIVE_HEALTHY, and read-only pg_indexes shows scoped `records` indexes and membership indexes; database service health does **not** demonstrate reliable owner-ISP PostgREST connectivity.
102 +- **This bounded step:** instrument stages with **strictly fixed, privacy-safe identifiers** for account/profile, organization membership, access/license, optional startup assets, and company record hydration; show exact pending stages on timeout and add a *separate read-only PostgREST reachability check* to existing site/manifest/Auth diagnostic. Add synthetic Chromium network-failure tests, keep tenant-scoped atomic data and RLS/auth paths entirely unchanged. No user DB read, schema/RLS/Auth changes, no credential/URL logging. Rollback this UI-only PR.
103 +- **Acceptance:** full Chromium/Golden/three disposable PostgreSQL/Security checks, gated main Publish and affected-browser retest showing `REST_*` + safe `BOOT_*` stage code; actual root cause cannot be claimed fixed before owner network trace. Keep [Issue #106](https://github.com/davoodmehraban89/Factor-easy/issues/106) / F0-01 / Phase 0 OPEN. Desktop Commander reported monthly usage quota exhausted; no attempts to bypass limitation or modify stale 2189 untracked files in `C:\Temp\Factor-easy`.
104 +
105 ## Current change ledger
106 | 2026-10-07 | Owner requested accounting/product usability refinement from live screenshots: automatic non-user-entered floating-detail codes, contextual in-product guides (especially accounting/chart/dimensions), remove duplicate product internal tax ID and use product code as internal item ID, strengthen in-control product/person search, introduce hierarchical product group/subgroup coding with deterministic 6-digit product codes, and keep sale/purchase commercial-document workspace layout stable while only semantic fields change. | **IMPLEMENTED / LOCAL VERIFICATION PASSED / CI PENDING** | Baseline main = `7e58c75f7d754f378d94ca3f356c1ae580aa7ee3`. Automatic dimension type/value codes, contextual guides, product-code-as-internal-ID, normalized multi-token search, and additive six-digit product coding implemented. Existing historical codes preserved. Commercial sale/purchase workspaces now share a stable `صدور سند تجاری` header/actions layout; duplicate purchase sidebar injection removed; the public selector is the single document-type selector and the legacy internal invoice-kind control is hidden. Local syntax/static/commerce/UX/accounting phases 2–6/Golden checks passed; protected-branch CI remains pending. |
107
index.html
+4 -4
@@ -13,8 +13,8 @@
13 <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; font-src 'self' https://cdn.jsdelivr.net data:; img-src 'self' data: blob:; connect-src 'self' https://hcsixhqbyuhpshfwqpjx.supabase.co; object-src 'none'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests" />
14 <meta name="apple-mobile-web-app-capable" content="yes" />
15 <meta name="theme-color" content="#071a48" />
16 -<link rel="preload" as="script" href="js/core.js?v=20261012-login-wiring-v3" />
17 -<link rel="preload" as="script" href="js/login-connectivity.js?v=20261012-site-probe-v2" />
16 +<link rel="preload" as="script" href="js/core.js?v=20261012-bootstrap-stages-v4" />
17 +<link rel="preload" as="script" href="js/login-connectivity.js?v=20261012-data-probe-v3" />
18 <script src="vendor/supabase.js"></script>
19 <script async src="https://cdn.jsdelivr.net/npm/xlsx@0.18.5/dist/xlsx.full.min.js"></script>
20 <link id="finora-optional-font" rel="stylesheet" media="print" href="https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/misc/Farsi-Digits/Vazirmatn-FD-font-face.css" />
@@ -892,8 +892,8 @@ body{background:#f6f9fc}
892
893 <!-- The credential-free connectivity action must be loaded before core declares
894 login actions interactive. Hardened Pages binds static handlers just before core. -->
895 -<script src="js/login-connectivity.js?v=20261012-site-probe-v2"></script>
896 -<script src="js/core.js?v=20261012-login-wiring-v3"></script>
895 +<script src="js/login-connectivity.js?v=20261012-data-probe-v3"></script>
896 +<script src="js/core.js?v=20261012-bootstrap-stages-v4"></script>
897 <script src="js/admin.js?v=20261012-provision-error-v1"></script>
898 <script src="js/sync.js?v=20261012-login-read-cancel-v1"></script>
899 <script src="js/ui.js?v=20261002-shell-scroll-ownership-v2"></script>
js/core.js
+41 -6
@@ -67,6 +67,35 @@ function setAuthLoginStatus(message,state){
67 const el=document.getElementById('auth-login-status');
68 if(el){el.textContent=message;el.dataset.state=state||'ready';}
69 }
70 +// Fixed, credential-free bootstrap steps only. Do not collect URLs, user
71 +// identities, payloads, bearer tokens or third-party response bodies.
72 +const FINORA_LOGIN_STEP_LABELS=Object.freeze({
73 + ACCOUNT_CONTEXT:'مشخصات و دسترسی حساب',
74 + PROFILE:'مشخصات کاربر',
75 + ORG_MEMBERSHIP:'عضویت سازمانی',
76 + ORG_ACCESS:'مجوزها و اشتراک سازمان',
77 + APP_ASSETS:'اجزای نرم‌افزار',
78 + TENANT_RECORDS:'اطلاعات شرکت'
79 +});
80 +const finoraPendingLoginReads=new Map();
81 +function finoraPendingLoginStages(){
82 + return [...finoraPendingLoginReads.keys()].sort();
83 +}
84 +function finoraTrackLoginRead(stage,promise){
85 + if(!Object.prototype.hasOwnProperty.call(FINORA_LOGIN_STEP_LABELS,stage))
86 + return Promise.resolve(promise);
87 + finoraPendingLoginReads.set(stage,(finoraPendingLoginReads.get(stage)||0)+1);
88 + return Promise.resolve(promise).finally(()=>{
89 + const count=finoraPendingLoginReads.get(stage)||0;
90 + if(count<=1)finoraPendingLoginReads.delete(stage);
91 + else finoraPendingLoginReads.set(stage,count-1);
92 + });
93 +}
94 +function finoraLoginStageDescription(codes){
95 + const valid=codes.filter(code=>Object.prototype.hasOwnProperty.call(FINORA_LOGIN_STEP_LABELS,code));
96 + return valid.length?valid.map(code=>FINORA_LOGIN_STEP_LABELS[code]).join('، '):'پاسخ درخواست نامشخص';
97 +}
98 +
99 // Abort a stuck read or optional startup barrier without claiming a half-loaded
100 // financial workspace is usable. Only the login hydration path uses this.
101 function finoraAbortableRead(promise,signal){
@@ -101,7 +130,7 @@ function buildUserFromRows(profile,lic){
130 async function fetchCurrentUser(authUser,{signal}={}){
131 let query=sb.from('profiles').select('id,email,username,full_name,role').eq('id',authUser.id);
132 if(signal&&typeof query.abortSignal==='function')query=query.abortSignal(signal);
104 - const p=await finoraAbortableRead(query.single(),signal);
133 + const p=await finoraTrackLoginRead('PROFILE',finoraAbortableRead(query.single(),signal));
134 if(p.error)throw p.error;
135 return buildUserFromRows(p.data,null);
136 }
@@ -273,17 +302,21 @@ async function skipSetPassword(){
302 }
303 async function enterApp(authUser,{timeoutMs=25000}={}){
304 const controller=new AbortController();
276 - const timer=setTimeout(()=>controller.abort(),timeoutMs);
305 + let timeoutStageCodes=[];
306 + const timer=setTimeout(()=>{
307 + timeoutStageCodes=finoraPendingLoginStages(); // capture before aborted promises clear
308 + controller.abort();
309 + },timeoutMs);
310 try{
311 setAuthLoginStatus('در حال بازیابی نشست و آماده‌سازی محیط کار...','loading');
312 const [profile]=await Promise.all([
280 - fetchCurrentUser(authUser,{signal:controller.signal}),
281 - finoraAbortableRead(window.FinoraAppAssetsReady,controller.signal)
313 + finoraTrackLoginRead('ACCOUNT_CONTEXT',finoraAbortableRead(fetchCurrentUser(authUser,{signal:controller.signal}),controller.signal)),
314 + finoraTrackLoginRead('APP_ASSETS',finoraAbortableRead(window.FinoraAppAssetsReady,controller.signal))
315 ]);
316 if(controller.signal.aborted)throw new Error('FINORA_LOGIN_READ_TIMEOUT');
317 currentUser=profile;
318 setAuthLoginStatus('در حال دریافت اطلاعات شرکت...','loading');
286 - await finoraAbortableRead(pullAll({signal:controller.signal}),controller.signal);
319 + await finoraTrackLoginRead('TENANT_RECORDS',finoraAbortableRead(pullAll({signal:controller.signal}),controller.signal));
320 if(controller.signal.aborted)throw new Error('FINORA_LOGIN_READ_TIMEOUT');
321 const prefs=typeof getMySettings==='function'?getMySettings():null;if(prefs?.user_display_name&&!currentUser.fullName)currentUser.fullName=prefs.user_display_name;if(prefs?.professional_role)currentUser.professionalRole=prefs.professional_role;
322 }catch(err){
@@ -291,7 +324,9 @@ async function enterApp(authUser,{timeoutMs=25000}={}){
324 const timedOut=controller.signal.aborted||err?.message==='FINORA_LOGIN_READ_TIMEOUT';
325 if(timedOut){
326 console.warn('Finora login read timed out (no identity or private data logged).');
294 - setAuthLoginStatus('دریافت اطلاعات حساب بیش از حد طول کشید. اتصال سرور را بررسی کنید و ورود را دوباره انجام دهید.','error');
327 + const stages=timeoutStageCodes.length?timeoutStageCodes:finoraPendingLoginStages();
328 + const safeCodes=stages.length?stages.join(','):'UNKNOWN';
329 + setAuthLoginStatus('دریافت اطلاعات حساب بیش از حد طول کشید. مرحله معطل: '+finoraLoginStageDescription(stages)+' (BOOT_'+safeCodes+'). اتصال را بررسی کنید و دوباره تلاش کنید.','error');
330 }else{
331 console.error('Finora account hydration failed',err);
332 setAuthLoginStatus('دریافت اطلاعات حساب ناموفق بود؛ اتصال را بررسی و دوباره تلاش کنید.','error');
js/login-connectivity.js
+17 -10
@@ -1,5 +1,5 @@
1 -// Read-only, credential-free diagnostics. A missing manifest is NOT proof
2 -// that core JS or the Supabase Auth service is unreachable.
1 +// Credential-free diagnostics. GoTrue health does not check PostgREST.
2 +// A missing manifest is NOT proof that core JS or data reads are unavailable.
3 async function checkAuthConnectivity(){
4 const out=document.getElementById('auth-connectivity-result');
5 const button=document.getElementById('auth-connectivity-check');
@@ -15,15 +15,15 @@ async function checkAuthConnectivity(){
15 out.dataset.status='offline';
16 return;
17 }
18 - // Execute three independent checks so a failed PWA manifest cannot mask
19 - // a healthy executable file or a healthy GoTrue endpoint. Both are GET;
20 - // neither accesses user identity, session, password or private records.
18 + // Execute four independent GET checks. The REST root only returns
19 + // gateway/OpenAPI status: never call a table, use a user JWT or read records.
20 const requests=[
22 - fetch(new URL('js/login-connectivity.js?v=20261012-site-probe-v2',document.baseURI).href,{cache:'no-store',signal:controller.signal}),
21 + fetch(new URL('js/login-connectivity.js?v=20261012-data-probe-v3',document.baseURI).href,{cache:'no-store',signal:controller.signal}),
22 fetch(new URL('manifest.json',document.baseURI).href,{cache:'no-store',signal:controller.signal}),
24 - fetch(SUPABASE_URL+'/auth/v1/health',{method:'GET',headers:{apikey:SUPABASE_KEY},cache:'no-store',signal:controller.signal})
23 + fetch(SUPABASE_URL+'/auth/v1/health',{method:'GET',headers:{apikey:SUPABASE_KEY},cache:'no-store',signal:controller.signal}),
24 + fetch(SUPABASE_URL+'/rest/v1/',{method:'GET',headers:{apikey:SUPABASE_KEY},cache:'no-store',signal:controller.signal})
25 ];
26 - const [script,manifest,auth]=await Promise.allSettled(requests);
26 + const [script,manifest,auth,rest]=await Promise.allSettled(requests);
27 const describe=(r,name)=>{
28 if(r.status==='rejected')return name+(controller.signal.aborted?'_TIMEOUT':'_NETWORK_ERROR');
29 return name+(r.value.ok?'_OK':'_HTTP_'+r.value.status);
@@ -35,7 +35,11 @@ async function checkAuthConnectivity(){
35 const manifestCode=describe(manifest,'MANIFEST');
36 const authCode=auth.status==='rejected'?(controller.signal.aborted?'AUTH_TIMEOUT':'AUTH_UNREACHABLE'):
37 (auth.value.status===200?'AUTH_OK':'AUTH_HTTP_'+auth.value.status);
38 - const codes=[siteCode,manifestCode,authCode].join(' | ');
38 + // A 401/403/404 from REST still proves the gateway responded; 5xx does not.
39 + // It does NOT prove authenticated tenant reads or RLS authorization.
40 + const restCode=rest.status==='rejected'?(controller.signal.aborted?'REST_TIMEOUT':'REST_UNREACHABLE'):'REST_HTTP_'+rest.value.status;
41 + const restHealthy=rest.status==='fulfilled'&&rest.value.status<500;
42 + const codes=[siteCode,manifestCode,authCode,restCode].join(' | ');
43 if(!scriptOk&&!manifestOk){
44 out.dataset.status='site-error';
45 out.textContent='دو فایل بررسی‌شده از این شبکه دریافت نشدند ('+codes+'). با اینترنت دیگری امتحان کنید؛ این آزمون علت قطعی مشکل ورود را مشخص نمی‌کند.';
@@ -45,12 +49,15 @@ async function checkAuthConnectivity(){
49 }else if(!authOk){
50 out.dataset.status=auth.status==='rejected'?'auth-unreachable':'auth-http';
51 out.textContent='فایل اصلی سایت دریافت می‌شود، اما بررسی سرور ورود موفق نبود ('+codes+'). نتیجه را بدون اطلاعات حساب برای پشتیبانی بفرستید.';
52 + }else if(!restHealthy){
53 + out.dataset.status='rest-unreachable';
54 + out.textContent='فایل ورود و سرور Auth پاسخ می‌دهند، اما مسیر دریافت اطلاعات شرکت (REST) پاسخ سالم نداده است ('+codes+'). این مورد می‌تواند باعث توقف ورود شود.';
55 }else if(!manifestOk){
56 out.dataset.status='site-warning';
57 out.textContent='فایل اجرایی و سرور ورود در دسترس‌اند، اما فایل تنظیمات سایت دریافت نشد ('+codes+'). این مورد به‌تنهایی مانع ورود را ثابت نمی‌کند.';
58 }else{
59 out.dataset.status='ok';
53 - out.textContent='فایل اصلی و سرور ورود پاسخ داده‌اند ('+codes+'). این نتیجه موفقیت رمز عبور یا بارگذاری اطلاعات شرکت را تأیید نمی‌کند.';
60 + out.textContent='فایل‌های سایت و درگاه‌های Auth و REST پاسخ داده‌اند ('+codes+'). این نتیجه ورود موفق یا صحت مجوزها و دریافت اطلاعات شرکت را تأیید نمی‌کند.';
61 }
62 }catch{
63 out.textContent='بررسی مستقل اتصال کامل نشد (DIAGNOSTIC_FAILED). بدون ارسال رمز یا اطلاعات حساب دوباره امتحان کنید.';
js/organization-rbac.js
+4 -3
@@ -2,14 +2,15 @@
2 (function(){
3 const baseFetchCurrentUser=fetchCurrentUser;
4 // Forward read-only timeout through the actual membership/license lookups.
5 -async function finoraOrganizationRead(query,signal){
5 +async function finoraOrganizationRead(query,signal,stage='ORG_ACCESS'){
6 if(signal&&typeof query.abortSignal==='function')query=query.abortSignal(signal);
7 - const result=await finoraAbortableRead(query,signal);
7 + const request=finoraAbortableRead(query,signal);
8 + const result=await finoraTrackLoginRead(stage,request);
9 if(signal?.aborted)throw new Error('FINORA_LOGIN_READ_TIMEOUT');
10 return result;
11 }
12 async function loadOrganizationContext(user,{signal}={}){
12 - const {data:members,error:memberError}=await finoraOrganizationRead(sb.from('organization_members').select('id,organization_id,unit_id,position_title,status,is_owner').eq('user_id',user.id).eq('status','active'),signal);
13 + const {data:members,error:memberError}=await finoraOrganizationRead(sb.from('organization_members').select('id,organization_id,unit_id,position_title,status,is_owner').eq('user_id',user.id).eq('status','active'),signal,'ORG_MEMBERSHIP');
14 if(memberError)throw memberError;
15 const orgIds=(members||[]).map(x=>x.organization_id);
16 if(!orgIds.length)throw new Error('عضویت سازمانی برای این کاربر تعریف نشده است.');
scripts/login-connectivity-check.mjs
+7 -4
@@ -6,9 +6,9 @@ const diagnostic=fs.readFileSync('js/login-connectivity.js','utf8');
6 assert(html.includes('id="auth-connectivity-check"'),'Missing diagnostic action');
7 assert(html.includes('id="auth-connectivity-result"'),'Missing accessible result');
8 assert(html.includes('id="auth-connectivity-result" aria-live="polite"'),'Diagnostic must announce updates without adding a conflicting global role=status');
9 -assert(html.includes('js/login-connectivity.js?v=20261012-site-probe-v2'),'Missing versioned script');
10 -assert(html.includes('js/core.js?v=20261012-login-wiring-v3'),'Production login controls must use new cache version');
11 -assert(html.indexOf('<script src="js/login-connectivity.js?v=20261012-site-probe-v2"')<html.indexOf('<script src="js/core.js?v=20261012-login-wiring-v3"'),'Connectivity handler script must execute before core (not just preload)');
9 +assert(html.includes('js/login-connectivity.js?v=20261012-data-probe-v3'),'Missing versioned script');
10 +assert(html.includes('js/core.js?v=20261012-bootstrap-stages-v4'),'Production login controls must use new cache version');
11 +assert(html.indexOf('<script src="js/login-connectivity.js?v=20261012-data-probe-v3"')<html.indexOf('<script src="js/core.js?v=20261012-bootstrap-stages-v4"'),'Connectivity handler script must execute before core (not just preload)');
12 assert(html.includes('js/bootstrap.js?v=20261012-login-ready-v2'),'Parallel bootstrap must also be cache-busted');
13 assert(html.includes('id="auth-login-button"')&&html.includes('id="auth-login-status"'),'Login control requires real readiness/progress feedback');
14 assert(core.includes('window.FinoraAppAssetsReady'),'Authenticated workspace must remain gated until all module scripts settle');
@@ -19,8 +19,11 @@ assert(!core.includes('اتصال اینترنت/VPN را بررسی کنید'),
19 assert(diagnostic.includes("'/auth/v1/health'"),'Must test the real GoTrue health path');
20 assert(diagnostic.includes('apikey:SUPABASE_KEY'),'Health check requires public API key');
21 assert(diagnostic.includes("new URL('manifest.json',document.baseURI)"),'Missing same-origin site baseline');
22 -assert(diagnostic.includes("new URL('js/login-connectivity.js?v=20261012-site-probe-v2',document.baseURI)"),'Missing same-origin executable asset probe');
22 +assert(diagnostic.includes("new URL('js/login-connectivity.js?v=20261012-data-probe-v3',document.baseURI)"),'Missing same-origin executable asset probe');
23 assert(diagnostic.includes("SITE_JS")&&diagnostic.includes("MANIFEST"),'Must diagnose executable asset and manifest independently');
24 +assert(diagnostic.includes("'/rest/v1/'"),'PostgREST gateway probe required to distinguish data endpoint from Auth health');
25 +assert(diagnostic.includes('REST_UNREACHABLE')&&diagnostic.includes('rest-unreachable'),'PostgREST network failure must surface separately');
26 +assert(core.includes('FINORA_LOGIN_STEP_LABELS')&&core.includes('finoraPendingLoginStages'),'Timeout must identify fixed pending bootstrapping stages');
27 assert(diagnostic.includes("site-warning"),'Manifest-only error must not be misreported as total site failure');
28 assert(!diagnostic.includes("if(!siteOk)"),'Legacy manifest-only SITE_UNREACHABLE classifier must be removed');
29 assert(!diagnostic.includes('signInWithPassword')&&!diagnostic.includes('auth-password'),'Diagnostic must not touch credentials');
scripts/login-connectivity.spec.js
+40
@@ -1,5 +1,14 @@
1 const { test, expect } = require('@playwright/test');
2 const base=process.env.FINORA_TEST_BASE||'http://127.0.0.1:4173/index.html';
3 +test.beforeEach(async({page})=>{
4 + // Gateway response confirms transport only; no private data or user token.
5 + await page.route('**/rest/v1/',route=>route.fulfill({
6 + status:200,
7 + contentType:'application/json',
8 + headers:{'access-control-allow-origin':'*'},
9 + body:'{}'
10 + }));
11 +});
12 test('Login diagnostics distinguish a reachable auth service from password errors', async ({page})=>{
13 await page.route('**/auth/v1/health', route=>route.fulfill({
14 status:200, contentType:'application/json',
@@ -75,3 +84,34 @@ test('Both site resources and Auth unreachable: report independent failures with
84 await expect(output).toContainText('AUTH_UNREACHABLE');
85 expect(await output.textContent()).not.toMatch(/Bearer |password|access_token|apiKey/i);
86 });
87 +
88 +test('Auth and static files can work while Supabase PostgREST data endpoint is unreachable',async({page})=>{
89 + await page.route('**/rest/v1/',route=>route.abort('failed'));
90 + await page.route('**/auth/v1/health',route=>route.fulfill({
91 + status:200,contentType:'application/json',
92 + headers:{'access-control-allow-origin':'*'},body:'{"name":"GoTrue"}'
93 + }));
94 + await page.goto(base,{waitUntil:'domcontentloaded'});
95 + await page.locator('#auth-connectivity-check').click();
96 + const output=page.locator('#auth-connectivity-result');
97 + await expect(output).toHaveAttribute('data-status','rest-unreachable',{timeout:15000});
98 + await expect(output).toContainText('SITE_JS_OK');
99 + await expect(output).toContainText('AUTH_OK');
100 + await expect(output).toContainText('REST_UNREACHABLE');
101 +});
102 +test('A 503 data gateway response remains distinct from good Auth service',async({page})=>{
103 + await page.route('**/rest/v1/',route=>route.fulfill({
104 + status:503,contentType:'application/json',
105 + headers:{'access-control-allow-origin':'*'},body:'{}'
106 + }));
107 + await page.route('**/auth/v1/health',route=>route.fulfill({
108 + status:200,contentType:'application/json',
109 + headers:{'access-control-allow-origin':'*'},body:'{"name":"GoTrue"}'
110 + }));
111 + await page.goto(base,{waitUntil:'domcontentloaded'});
112 + await page.locator('#auth-connectivity-check').click();
113 + const output=page.locator('#auth-connectivity-result');
114 + await expect(output).toHaveAttribute('data-status','rest-unreachable',{timeout:15000});
115 + await expect(output).toContainText('AUTH_OK');
116 + await expect(output).toContainText('REST_HTTP_503');
117 +});
scripts/phase0-startup-performance.spec.js
+27
@@ -199,3 +199,30 @@ test('F0 organization-scoped record hydration respects abort and tenant boundary
199 });
200 expect(observed).toEqual({selectedTenant:'org-fixture',preserved:true,noLeakedDummy:true,noStaleSnapshot:true});
201 });
202 +
203 +test('F0 bootstrap timeout reports ACCOUNT_CONTEXT without email, token or private profile',async({page})=>{
204 + await page.goto(BASE,{waitUntil:'domcontentloaded'});
205 + await expect.poll(()=>page.evaluate(()=>window.FinoraStartupStatus?.authChecked),{timeout:15000}).toBe(true);
206 + const output=await page.evaluate(async()=>{
207 + window.fetchCurrentUser=()=>new Promise(()=>{});
208 + await enterApp({id:'synthetic-account'}, {timeoutMs:65});
209 + return document.getElementById('auth-login-status').textContent;
210 + });
211 + expect(output).toContain('BOOT_ACCOUNT_CONTEXT');
212 + expect(output).toContain('بیش از حد');
213 + expect(output).not.toMatch(/synthetic-account|@|Bearer |password|access_token/i);
214 +});
215 +
216 +test('F0 bootstrap timeout reports TENANT_RECORDS when profile has already resolved',async({page})=>{
217 + await page.goto(BASE,{waitUntil:'domcontentloaded'});
218 + await expect.poll(()=>page.evaluate(()=>window.FinoraStartupStatus?.authChecked),{timeout:15000}).toBe(true);
219 + const output=await page.evaluate(async()=>{
220 + window.fetchCurrentUser=async()=>({id:'synthetic-tenant',role:'accountant',fullName:'Not Public'});
221 + window.pullAll=()=>new Promise(()=>{});
222 + await enterApp({id:'synthetic-tenant'}, {timeoutMs:65});
223 + return document.getElementById('auth-login-status').textContent;
224 + });
225 + expect(output).toContain('BOOT_TENANT_RECORDS');
226 + expect(output).toContain('بیش از حد');
227 + expect(output).not.toMatch(/synthetic-tenant|Not Public|Bearer |password|access_token/i);
228 +});