Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions apps/e2e/src/tests/admin-policy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,16 @@ import { buildDriver, quitDriver, clickWhen, waitFor, BASE_URL } from '../helper
import { sessionCookie } from '../helpers/app-session.js';
import { saveScreenshot } from '../helpers/screenshot.js';
import { byTestId } from '../helpers/test-ids.js';
import { apiCall } from '../helpers/accounts.js';

const API_URL = process.env.E2E_API_URL ?? 'http://127.0.0.1:3210';
const EMAIL = `e2e-policy-${Date.now().toString(36)}@foxschema.test`;

let admin = '';
let driver: Page;
let userId = '';
let policy: { adminPolicy: 'one' | 'several'; source: string | null; activeAdmins: string[] };

async function api(method: string, path: string, body?: unknown) {
const res = await fetch(`${API_URL}/api${path}`, {
method,
headers: { ...(body ? { 'content-type': 'application/json' } : {}), cookie: admin },
...(body ? { body: JSON.stringify(body) } : {}),
});
return { status: res.status, json: (await res.json().catch(() => null)) as any };
}
const api = (method: string, path: string, body?: unknown) => apiCall(method, path, body, admin);

async function openAppUsers(): Promise<void> {
// A fresh load each time, so every test reads what the server holds now.
Expand Down
11 changes: 2 additions & 9 deletions apps/e2e/src/tests/auth-recovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { randomBytes } from 'node:crypto';
import type { Page } from 'playwright';
import { buildDriver, quitDriver, BASE_URL } from '../helpers/driver.js';
import { sessionCookie } from '../helpers/app-session.js';
import { apiCall } from '../helpers/accounts.js';

const API_URL = process.env.E2E_API_URL ?? 'http://127.0.0.1:3210';
const EMAIL = `e2e-invite-${Date.now()}@foxschema.test`;
const FIRST_PASSWORD = `first-${randomBytes(6).toString('hex')}`;
const SECOND_PASSWORD = `second-${randomBytes(6).toString('hex')}`;
Expand All @@ -22,14 +22,7 @@ let admin = '';
let userId = '';
const pages: Page[] = [];

async function api(method: string, path: string, body?: unknown, cookie = admin) {
const res = await fetch(`${API_URL}/api${path}`, {
method,
headers: { ...(body ? { 'content-type': 'application/json' } : {}), ...(cookie ? { cookie } : {}) },
...(body ? { body: JSON.stringify(body) } : {}),
});
return { status: res.status, json: (await res.json().catch(() => null)) as any };
}
const api = (method: string, path: string, body?: unknown, cookie = admin) => apiCall(method, path, body, cookie);

async function signedOutPage(): Promise<Page> {
const page = await buildDriver({ signedIn: false });
Expand Down
11 changes: 2 additions & 9 deletions apps/e2e/src/tests/git-migrations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { tryCleanup } from '../helpers/sql-exec.js';
import { AppPage } from '../pages/AppPage.js';
import { ConnectionModal } from '../pages/ConnectionModal.js';
import { MigrationPage } from '../pages/MigrationPage.js';
import { apiCall } from '../helpers/accounts.js';

/**
* The real Git server the server's own tests use (packages/server), loaded at
Expand All @@ -40,7 +41,6 @@ async function startTestGitServer(): Promise<TestGitServer> {
return mod.startTestGitServer();
}

const API_URL = process.env.E2E_API_URL ?? 'http://127.0.0.1:3210';

/**
* The whole flow for one engine. The seed gives every engine a `demo_a` and a
Expand All @@ -60,14 +60,7 @@ let app: AppPage;
let modal: ConnectionModal;
let migration: MigrationPage;

async function api(method: string, path: string, body?: unknown) {
const res = await fetch(`${API_URL}/api${path}`, {
method,
headers: { ...(body ? { 'content-type': 'application/json' } : {}), cookie: admin },
...(body ? { body: JSON.stringify(body) } : {}),
});
return { status: res.status, json: (await res.json().catch(() => null)) as any };
}
const api = (method: string, path: string, body?: unknown) => apiCall(method, path, body, admin);

describe.skipIf(!hasConfig(dialect))(`Migrations in Git (${label})`, () => {
beforeAll(async () => {
Expand Down
10 changes: 2 additions & 8 deletions apps/e2e/src/tests/workspaces.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { buildDriver, quitDriver, clickWhen, waitFor, BASE_URL } from '../helper
import { sessionCookie } from '../helpers/app-session.js';
import { saveScreenshot } from '../helpers/screenshot.js';
import { byTestId } from '../helpers/test-ids.js';
import { apiCall } from '../helpers/accounts.js';

const API_URL = process.env.E2E_API_URL ?? 'http://127.0.0.1:3210';
const RUN = Date.now().toString(36);
Expand All @@ -30,14 +31,7 @@ let guestCookie = '';
const WALKER_EMAIL = `e2e-wswalker-${RUN}@foxschema.test`;
let walkerId = '';

async function api(method: string, path: string, body?: unknown, cookie = admin) {
const res = await fetch(`${API_URL}/api${path}`, {
method,
headers: { ...(body !== undefined ? { 'content-type': 'application/json' } : {}), cookie },
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
});
return { status: res.status, json: (await res.json().catch(() => null)) as any };
}
const api = (method: string, path: string, body?: unknown, cookie = admin) => apiCall(method, path, body, cookie);

async function openMenu(page: Page = driver): Promise<void> {
if (page === driver) await page.goto(BASE_URL);
Expand Down
Loading