Merge branch 'development' into feature/beta-release
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
import { test, expect, type TestUser } from '../../fixtures/auth-fixtures';
|
||||
import type { TestDataManager } from '../../utils/TestDataManager';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { ensureAuthenticatedImportFormReady, ensureImportFormReady, resetImportSession } from './import-page-helpers';
|
||||
import { ensureAuthenticatedImportFormReady, ensureImportFormReady, getStoredAuthHeader, resetImportSession } from './import-page-helpers';
|
||||
|
||||
/**
|
||||
* Helper: Generate unique domain with namespace isolation
|
||||
@@ -328,7 +328,7 @@ test.describe('Caddy Import Gap Coverage @caddy-import-gaps', () => {
|
||||
// Gap 3: Overwrite Resolution Flow
|
||||
// =========================================================================
|
||||
test.describe('Overwrite Resolution Flow', () => {
|
||||
test('3.1: should update existing host when selecting Replace with Imported resolution', async ({ page, request, testData, browserName, adminUser }) => {
|
||||
test('3.1: should update existing host when selecting Replace with Imported resolution', async ({ page, testData, browserName, adminUser }) => {
|
||||
// Create existing host with initial config
|
||||
const result = await testData.createProxyHost({
|
||||
domain: 'overwrite-test.example.com',
|
||||
@@ -379,7 +379,7 @@ test.describe('Caddy Import Gap Coverage @caddy-import-gaps', () => {
|
||||
|
||||
await test.step('Verify existing host was updated (not duplicated)', async () => {
|
||||
// Fetch the host via API
|
||||
const response = await request.get(`/api/v1/proxy-hosts/${hostId}`);
|
||||
const response = await page.request.get(`/api/v1/proxy-hosts/${hostId}`, { headers: await getStoredAuthHeader(page) });
|
||||
expect(response.ok()).toBeTruthy();
|
||||
|
||||
const host = await response.json();
|
||||
@@ -389,7 +389,7 @@ test.describe('Caddy Import Gap Coverage @caddy-import-gaps', () => {
|
||||
expect(host.forward_port).toBe(9000);
|
||||
|
||||
// Verify no duplicate was created - fetch all hosts and check count
|
||||
const allHostsResponse = await request.get('/api/v1/proxy-hosts');
|
||||
const allHostsResponse = await page.request.get('/api/v1/proxy-hosts', { headers: await getStoredAuthHeader(page) });
|
||||
expect(allHostsResponse.ok()).toBeTruthy();
|
||||
const allHosts = await allHostsResponse.json();
|
||||
|
||||
@@ -627,7 +627,7 @@ test.describe('Caddy Import Gap Coverage @caddy-import-gaps', () => {
|
||||
// Gap 5: Name Editing in Review
|
||||
// =========================================================================
|
||||
test.describe('Name Editing in Review', () => {
|
||||
test('5.1: should create proxy host with custom name from review table input', async ({ page, request, testData }) => {
|
||||
test('5.1: should create proxy host with custom name from review table input', async ({ page, testData }) => {
|
||||
const domain = generateDomain(testData, 'custom-name-test');
|
||||
const customName = 'My Custom Proxy Name';
|
||||
const caddyfile = `${domain} { reverse_proxy localhost:5000 }`;
|
||||
@@ -669,7 +669,7 @@ test.describe('Caddy Import Gap Coverage @caddy-import-gaps', () => {
|
||||
|
||||
await test.step('Verify created host has custom name', async () => {
|
||||
// Fetch all proxy hosts
|
||||
const response = await request.get('/api/v1/proxy-hosts');
|
||||
const response = await page.request.get('/api/v1/proxy-hosts', { headers: await getStoredAuthHeader(page) });
|
||||
expect(response.ok()).toBeTruthy();
|
||||
|
||||
const hosts = await response.json();
|
||||
|
||||
@@ -22,6 +22,7 @@ import { Page } from '@playwright/test';
|
||||
import {
|
||||
attachImportDiagnostics,
|
||||
ensureImportUiPreconditions,
|
||||
getStoredAuthHeader,
|
||||
logImportFailureContext,
|
||||
resetImportSession,
|
||||
waitForSuccessfulImportResponse,
|
||||
@@ -72,7 +73,7 @@ async function ensureWebkitAuthSession(page: Page): Promise<void> {
|
||||
});
|
||||
}
|
||||
|
||||
const meResponse = await page.request.get('/api/v1/auth/me');
|
||||
const meResponse = await page.request.get('/api/v1/auth/me', { headers: await getStoredAuthHeader(page) });
|
||||
if (!meResponse.ok()) {
|
||||
throw new Error(
|
||||
`WebKit auth bootstrap verification failed: /api/v1/auth/me returned ${meResponse.status()} at ${page.url()}`
|
||||
|
||||
@@ -4,6 +4,11 @@ import { readFileSync } from 'fs';
|
||||
import { STORAGE_STATE } from '../../constants';
|
||||
|
||||
const IMPORT_PAGE_PATH = '/tasks/import/caddyfile';
|
||||
|
||||
export async function getStoredAuthHeader(page: Page): Promise<Record<string, string>> {
|
||||
const token = await page.evaluate(() => localStorage.getItem('charon_auth_token')).catch(() => null);
|
||||
return token ? { Authorization: `Bearer ${token}` } : {};
|
||||
}
|
||||
const SETUP_TEST_EMAIL = process.env.E2E_TEST_EMAIL || 'e2e-test@example.com';
|
||||
const SETUP_TEST_PASSWORD = process.env.E2E_TEST_PASSWORD || 'TestPassword123!';
|
||||
const IMPORT_BLOCKING_STATUS_CODES = new Set([401, 403, 302, 429]);
|
||||
@@ -252,7 +257,7 @@ export async function resetImportSession(page: Page): Promise<void> {
|
||||
|
||||
async function readImportStatus(page: Page): Promise<{ hasPending: boolean; sessionId: string }> {
|
||||
try {
|
||||
const statusResponse = await page.request.get('/api/v1/import/status');
|
||||
const statusResponse = await page.request.get('/api/v1/import/status', { headers: await getStoredAuthHeader(page) });
|
||||
if (!statusResponse.ok()) {
|
||||
return { hasPending: false, sessionId: '' };
|
||||
}
|
||||
@@ -272,16 +277,17 @@ async function readImportStatus(page: Page): Promise<{ hasPending: boolean; sess
|
||||
}
|
||||
|
||||
async function issuePendingSessionCancel(page: Page, sessionId: string): Promise<void> {
|
||||
const authHeader = await getStoredAuthHeader(page);
|
||||
if (sessionId) {
|
||||
await page
|
||||
.request
|
||||
.delete(`/api/v1/import/cancel?session_uuid=${encodeURIComponent(sessionId)}`)
|
||||
.delete(`/api/v1/import/cancel?session_uuid=${encodeURIComponent(sessionId)}`, { headers: authHeader })
|
||||
.catch(() => null);
|
||||
}
|
||||
|
||||
// Keep legacy endpoints for compatibility across backend variants.
|
||||
await page.request.delete('/api/v1/import/cancel').catch(() => null);
|
||||
await page.request.post('/api/v1/import/cancel').catch(() => null);
|
||||
await page.request.delete('/api/v1/import/cancel', { headers: authHeader }).catch(() => null);
|
||||
await page.request.post('/api/v1/import/cancel', { headers: authHeader }).catch(() => null);
|
||||
}
|
||||
|
||||
async function clearPendingImportSession(page: Page): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user