سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 17:00 UTC
test(login): independent manifest, critical JS, Auth outage regressions
davoodmehraban89 committed
Oct 12, 2026 at 23:12 UTC
b13b7273efac47961404a7196e7ced5217e0bfdf
1 file changed
+47
scripts/login-connectivity.spec.js
+47
@@ -28,3 +28,50 @@ test('Login diagnostics label HTTP server failures, not bad passwords', async ({
28
await expect(page.locator('#auth-connectivity-result')).toHaveAttribute('data-status','auth-http',{timeout:15000});
29
await expect(page.locator('#auth-connectivity-result')).toContainText('AUTH_HTTP_503');
30
});
31
+
32
+test('A failing manifest cannot falsely classify working login JS and Auth as SITE_UNREACHABLE',async({page})=>{
33
+ await page.goto(base,{waitUntil:'domcontentloaded'});
34
+ await page.route('**/manifest.json*',route=>route.fulfill({status:404,body:'missing'}));
35
+ await page.route('**/auth/v1/health',route=>route.fulfill({
36
+ status:200,contentType:'application/json',
37
+ headers:{'access-control-allow-origin':'*'},
38
+ body:'{"name":"GoTrue"}'
39
+ }));
40
+ await page.locator('#auth-connectivity-check').click();
41
+ const output=page.locator('#auth-connectivity-result');
42
+ await expect(output).toHaveAttribute('data-status','site-warning',{timeout:15000});
43
+ await expect(output).toContainText('SITE_JS_OK');
44
+ await expect(output).toContainText('MANIFEST_HTTP_404');
45
+ await expect(output).toContainText('AUTH_OK');
46
+ await expect(output).not.toContainText('SITE_UNREACHABLE');
47
+});
48
+
49
+test('Critical JS read fails but manifest and Auth are healthy: report failed asset precisely',async({page})=>{
50
+ await page.goto(base,{waitUntil:'domcontentloaded'});
51
+ await page.route('**/js/login-connectivity.js*',route=>route.abort('failed'));
52
+ await page.route('**/auth/v1/health',route=>route.fulfill({
53
+ status:200,contentType:'application/json',
54
+ headers:{'access-control-allow-origin':'*'},
55
+ body:'{"name":"GoTrue"}'
56
+ }));
57
+ await page.locator('#auth-connectivity-check').click();
58
+ const output=page.locator('#auth-connectivity-result');
59
+ await expect(output).toHaveAttribute('data-status','site-error',{timeout:15000});
60
+ await expect(output).toContainText('SITE_JS_NETWORK_ERROR');
61
+ await expect(output).toContainText('MANIFEST_OK');
62
+ await expect(output).toContainText('AUTH_OK');
63
+});
64
+
65
+test('Both site resources and Auth unreachable: report independent failures without exposing user data',async({page})=>{
66
+ await page.goto(base,{waitUntil:'domcontentloaded'});
67
+ await page.route('**/js/login-connectivity.js*',route=>route.abort('failed'));
68
+ await page.route('**/manifest.json*',route=>route.abort('failed'));
69
+ await page.route('**/auth/v1/health',route=>route.abort('failed'));
70
+ await page.locator('#auth-connectivity-check').click();
71
+ const output=page.locator('#auth-connectivity-result');
72
+ await expect(output).toHaveAttribute('data-status','site-error',{timeout:15000});
73
+ await expect(output).toContainText('SITE_JS_NETWORK_ERROR');
74
+ await expect(output).toContainText('MANIFEST_NETWORK_ERROR');
75
+ await expect(output).toContainText('AUTH_UNREACHABLE');
76
+ expect(await output.textContent()).not.toMatch(/Bearer |password|access_token|apiKey/i);
77
+});