سامانه صدور فاکتور و حسابداری
test(login): verify public PostgREST outage independent of reachable GoTrue Auth
davoodmehraban89 committed
Oct 12, 2026 at 23:37 UTC
db1804dde0e4a37779388603db88ed6478d14270
1 file changed
+40
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
+});