copy
Some checks failed
Test Environment Setup / setup-test-environment (push) Has been cancelled

This commit is contained in:
Lio 2025-06-26 13:38:01 +02:00
parent 26375a13b1
commit 2ea8c6d791
8 changed files with 15 additions and 43 deletions

View file

@ -16,8 +16,6 @@
"**/.env*": true,
"**/.next": true,
"**/.pnpm-store": true,
"**/.vscode": true,
"**/*.config*": true,
"**/biome.jsonc": true,
"**/next-env.d.ts": true,
"**/node_modules": true,

View file

@ -19,7 +19,7 @@ export async function GET() {
duration: number;
success?: boolean;
pending: boolean;
created_at: Date;
created_at: Date;
}>(`select * from test_runs;`)
.then((r) => r.rows);
@ -31,7 +31,6 @@ export async function GET() {
(n, child) => n + Number(child.duration),
0
);
return {
run_id: run.id,
run_name: run.name,
@ -45,6 +44,5 @@ export async function GET() {
})),
};
});
return NextResponse.json(formatted);
}

View file

@ -4,44 +4,26 @@ import pool from "@/utils/db";
export async function POST(request: Request) {
let runId;
try {
let {
runName,
testId,
testName,
path,
duration,
success,
runId: passedRunId,
} = await request.json();
let {runName, testId, testName, path,duration, success, runId: passedRunId} = await request.json();
if (!passedRunId) {
const res = await pool
.query(
`WITH new_run AS (
INSERT INTO runs (name)
VALUES ($1)
RETURNING id
)
SELECT id FROM new_run;`,
`WITH new_run AS ( INSERT INTO runs (name) VALUES ($1) RETURNING id)
SELECT id FROM new_run;`,
[runName],
)
.then((r) => r.rows[0].id);
return NextResponse.json({ runId: res });
}
if (!testId) {
const res = await pool.query(
`INSERT INTO test_runs (run_id, test_name, path)
const res = await pool.query(`INSERT INTO test_runs (run_id, test_name, path)
VALUES ($1, $2, $3) returning id`,
[passedRunId, testName, path],
);
return NextResponse.json({
testId: res.rows[0].id,
});
}
if (testId) {
if (duration) {
await pool.query(
@ -55,13 +37,8 @@ export async function POST(request: Request) {
} catch (error) {
console.error("Error creating run:", error);
return NextResponse.json(
{
error: "Failed to create run",
// @ts-ignore
message: error.message,
// @ts-ignore
detail: error.detail,
},
// @ts-ignore
{error: "Failed to create run", message: error.message, detail: error.detail},
{ status: 500 },
);
}

View file

@ -11,10 +11,6 @@ export const handleExportCSV = (dateGroup: any) => {
"Success",
"Duration (s)"
];
console.log(dateGroup);
console.log(toCSV(headers, dateGroup));
// Create and trigger download
const blob = new Blob([...toCSV(headers, dateGroup)], {
type: "text/csv;charset=utf-8;",
@ -32,3 +28,4 @@ export const handleExportCSV = (dateGroup: any) => {
link.click();
document.body.removeChild(link);
};

View file

@ -17,3 +17,5 @@ export default function toCSV(
return [headers.join(","), ...a.map((row) => row.join(","))].join("\n");
}

View file

@ -1,12 +1,12 @@
const { defineConfig } = require("cypress");
const apiRequestPlugin = require("./src/index");
const setupAnalyticsPlugin = require("./src/index");
module.exports = defineConfig({
historyTrackerURL: "http://localhost:3001",
e2e: {
setupNodeEvents(on, config) {
// Set up the API request plugin
apiRequestPlugin(on, config);
// Set up the analytics plugin
setupAnalyticsPlugin(on, config);
return config;
},
},

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 190 KiB

View file

@ -55,7 +55,7 @@ const apiRequests = {
// Track if event handlers have been registered to prevent duplicate registrations
let eventHandlersRegistered = false;
function setupApiRequestPlugin(on, config) {
function setupAnalyticsPlugin(on, config) {
// If event handlers are already registered, don't register them again
if (eventHandlersRegistered) {
console.log("API plugin event handlers already registered, skipping...");
@ -142,4 +142,4 @@ function setupApiRequestPlugin(on, config) {
console.log("API plugin event handlers registered successfully");
}
module.exports = setupApiRequestPlugin;
module.exports = setupAnalyticsPlugin;