mirror of
https://github.com/ramvignesh-b/pi-ku.git
synced 2026-05-04 15:56:56 +00:00
3c9c72d25f
* feat: update E2E testing configuration to use ssl * fix: add IPv6 loopback support to mkcert generation command in CI workflow * feat: centralize SSL certificate generation into a reusable workflow job * fix: use static ip in mkcert command * fix: correct mkcert command args * feat: implement certificate caching in CI workflow to persist SSL files across jobs * refactor: optimize CI workflow caching * ci: implement certificate caching in workflow * fix: correct certificate caching keys and fix environment file paths in CI workflows * fix: correct environment file paths and parallelize frontend dependency installation in CI workflow * test: set TZ environment variable to Asia/Kolkata in vitest configuration * fix: force en-US locale in Intl formatters to ensure consistent date and time output * fix: update MAILPIT_API_URL protocol from https to http in e2e environment example * chore: set test timezone to Asia/Kolkata * ci: add sll support and enhance e2e workflow * ci: improve compatibility for docker-compose execution * refactor: improve container orchestration detection and fallback logic in e2e test script * feat: add container runtime validation and force docker usage in CI environment * feat: add caching for Playwright dependencies in CI workflow * chore: update restart policy to unless-stopped for postgres and mailpit services in e2e docker-compose --------- Co-authored-by: ramvignesh-b <ramvignesh-b@github.com>
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { request } from "@playwright/test";
|
|
|
|
export interface MailpitMessage {
|
|
ID: string;
|
|
Subject: string;
|
|
Snippet: string;
|
|
To: { Address: string }[];
|
|
}
|
|
|
|
const MAILPIT_API_URL = `http://${process.env.EMAIL_HOST}:${process.env.EMAIL_API_PORT}/api/v1`;
|
|
|
|
export const MailpitHelper = {
|
|
getActivationLink: async (
|
|
email: string,
|
|
timeout = 10000,
|
|
): Promise<string> => {
|
|
const startTime = Date.now();
|
|
const requestContext = await request.newContext();
|
|
|
|
while (Date.now() - startTime < timeout) {
|
|
const response = await requestContext.get(`${MAILPIT_API_URL}/search`, {
|
|
params: { query: `to:${email}`, limit: 1 },
|
|
});
|
|
|
|
if (response.ok()) {
|
|
const data = await response.json();
|
|
if (data.messages?.length > 0) {
|
|
const msgId = data.messages[0].ID;
|
|
const detailRes = await requestContext.get(
|
|
`${MAILPIT_API_URL}/message/${msgId}`,
|
|
);
|
|
const details = await detailRes.json();
|
|
|
|
const body = details.HTML || details.Text || "";
|
|
const match = body.match(/https?:\/\/\S+activate\/\S+/);
|
|
|
|
if (match) return match[0];
|
|
}
|
|
}
|
|
await new Promise((r) => setTimeout(r, 1000));
|
|
}
|
|
|
|
throw new Error(`Timeout: Could not find activation link for ${email}`);
|
|
},
|
|
};
|