This commit is contained in:
@@ -2,7 +2,7 @@ import { test, expect, type Page } from '@playwright/test';
|
||||
import { createRequire } from 'node:module';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { dirname, resolve, join } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { logout } from './helpers/session';
|
||||
|
||||
// ── Local-auth WORKSPACE-INVITE-LINK E2E ──────────────────────────────────────
|
||||
//
|
||||
@@ -41,7 +41,9 @@ const repoRoot = resolve(__dirname, '..', '..');
|
||||
// builds it identically: <tmpdir>/maestro-e2e-auth/e2e-auth.db). Computing it
|
||||
// independently keeps the spec decoupled from Playwright's config internals while
|
||||
// guaranteeing both open the SAME SQLite file.
|
||||
const DB_PATH = join(tmpdir(), 'maestro-e2e-auth', 'e2e-auth.db');
|
||||
const e2eTmp = process.env.E2E_AUTH_TMP;
|
||||
if (!e2eTmp) throw new Error('E2E_AUTH_TMP must be set by playwright.auth.config.ts');
|
||||
const DB_PATH = join(e2eTmp, 'e2e-auth.db');
|
||||
|
||||
const OWNER = { email: '[email protected]', password: 'OwnerPass123!', name: 'InviteOwner' };
|
||||
const JOINER = { email: '[email protected]', password: 'JoinerPass123!', name: 'InviteJoiner' };
|
||||
@@ -74,11 +76,18 @@ function trackFatalErrors(page: Page): string[] {
|
||||
if (res.status() >= 400) {
|
||||
const { pathname } = new URL(res.url());
|
||||
const expectedInvitePreview404 = res.status() === 404 && INVITE_PREVIEW_RE.test(pathname);
|
||||
// ログアウトした直後、次のログイン画面へ移る一瞬に /api/auth/me が 401 で
|
||||
// 返ることがある。これは「今の利用者は誰か」を尋ねて「誰でもない」と答えられた
|
||||
// だけで、不具合ではない(useAuthState はこの 401 を未ログインの合図として使う)。
|
||||
// 出るかどうかは画面の入れ替わりとの競争で決まる。パスと状態を両方指定している
|
||||
// ので、/api/auth/me が 500 を返せば今までどおり失敗として残る(#1399)。
|
||||
const loggedOutAuthProbe401 = res.status() === 401 && pathname === '/api/auth/me';
|
||||
if (
|
||||
!BENIGN_ASSET.test(pathname) &&
|
||||
!BENIGN_PATHS.has(pathname) &&
|
||||
!BENIGN_PATH_RE.test(pathname) &&
|
||||
!expectedInvitePreview404
|
||||
!expectedInvitePreview404 &&
|
||||
!loggedOutAuthProbe401
|
||||
) {
|
||||
fatalErrors.push(`HTTP ${res.status()} ${res.url()}`);
|
||||
}
|
||||
@@ -100,10 +109,6 @@ async function login(page: Page, email: string, password: string) {
|
||||
expect(page.url(), 'login should not bounce back to /auth/login').not.toContain('/auth/login');
|
||||
}
|
||||
|
||||
async function logout(page: Page) {
|
||||
await page.goto('/auth/logout');
|
||||
}
|
||||
|
||||
/** Mint an invite for the seeded case space via the owner's authed page.request.
|
||||
* Returns the captured token. */
|
||||
async function createInvite(page: Page, role: 'viewer' | 'editor'): Promise<string> {
|
||||
|
||||
Reference in New Issue
Block a user