Capture Paddle sandbox inline network logs
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import type { Page } from '@playwright/test';
|
import type { Page } from '@playwright/test';
|
||||||
|
import fs from 'node:fs/promises';
|
||||||
|
|
||||||
import { dismissConsentBanner, expectFixture as expect, test } from '../helpers/test-fixtures';
|
import { dismissConsentBanner, expectFixture as expect, test } from '../helpers/test-fixtures';
|
||||||
|
|
||||||
@@ -30,13 +31,40 @@ test.describe('Paddle sandbox full flow (staging)', () => {
|
|||||||
test.skip(!shouldRun, 'Set E2E_PADDLE_SANDBOX=1 to run live sandbox checkout on staging.');
|
test.skip(!shouldRun, 'Set E2E_PADDLE_SANDBOX=1 to run live sandbox checkout on staging.');
|
||||||
test.skip(!tenantEmail || !tenantPassword, 'Set E2E_TENANT_EMAIL and E2E_TENANT_PASSWORD for sandbox flow.');
|
test.skip(!tenantEmail || !tenantPassword, 'Set E2E_TENANT_EMAIL and E2E_TENANT_PASSWORD for sandbox flow.');
|
||||||
|
|
||||||
test('register, pay via Paddle sandbox, and login to event admin', async ({ page, request }) => {
|
test('register, pay via Paddle sandbox, and login to event admin', async ({ page, request }, testInfo) => {
|
||||||
|
const paddleNetworkLog: string[] = [];
|
||||||
|
|
||||||
|
page.on('response', async (response) => {
|
||||||
|
const url = response.url();
|
||||||
|
if (!/paddle/i.test(url)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const status = response.status();
|
||||||
|
let bodySnippet = '';
|
||||||
|
if (status >= 400 || /checkout|error/i.test(url)) {
|
||||||
|
try {
|
||||||
|
const text = await response.text();
|
||||||
|
bodySnippet = text.trim().slice(0, 2000);
|
||||||
|
} catch {
|
||||||
|
bodySnippet = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const entry = [`[${status}] ${url}`, bodySnippet].filter(Boolean).join('\n');
|
||||||
|
paddleNetworkLog.push(entry);
|
||||||
|
if (paddleNetworkLog.length > 40) {
|
||||||
|
paddleNetworkLog.shift();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
await page.addInitScript(() => {
|
await page.addInitScript(() => {
|
||||||
Object.defineProperty(navigator, 'webdriver', {
|
Object.defineProperty(navigator, 'webdriver', {
|
||||||
get: () => undefined,
|
get: () => undefined,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
// Jump directly into wizard for Standard package (2)
|
// Jump directly into wizard for Standard package (2)
|
||||||
await page.goto(`${baseUrl}/${locale}/${checkoutSlug}/2`);
|
await page.goto(`${baseUrl}/${locale}/${checkoutSlug}/2`);
|
||||||
|
|
||||||
@@ -117,6 +145,16 @@ test.describe('Paddle sandbox full flow (staging)', () => {
|
|||||||
|
|
||||||
await expect(page).toHaveURL(/\/event-admin\/mobile\/(dashboard|welcome)/i, { timeout: 30_000 });
|
await expect(page).toHaveURL(/\/event-admin\/mobile\/(dashboard|welcome)/i, { timeout: 30_000 });
|
||||||
await expect(page.getByText(/Dashboard|Willkommen/i)).toBeVisible();
|
await expect(page.getByText(/Dashboard|Willkommen/i)).toBeVisible();
|
||||||
|
} finally {
|
||||||
|
if (paddleNetworkLog.length > 0) {
|
||||||
|
const logPath = testInfo.outputPath('paddle-network-log.txt');
|
||||||
|
await fs.writeFile(logPath, paddleNetworkLog.join('\n\n'), 'utf8');
|
||||||
|
await testInfo.attach('paddle-network-log', {
|
||||||
|
path: logPath,
|
||||||
|
contentType: 'text/plain',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user