diff --git a/.vscode/settings.json b/.vscode/settings.json index 0dae67e..97deafb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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, diff --git a/Backend/src/app/api/data/route.ts b/Backend/src/app/api/data/route.ts index 640a6eb..507194b 100644 --- a/Backend/src/app/api/data/route.ts +++ b/Backend/src/app/api/data/route.ts @@ -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); } diff --git a/Backend/src/app/api/run/create/route.ts b/Backend/src/app/api/run/create/route.ts index 93ee58f..e0536b6 100644 --- a/Backend/src/app/api/run/create/route.ts +++ b/Backend/src/app/api/run/create/route.ts @@ -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 }, ); } diff --git a/Backend/src/utils/handleCSVExport.ts b/Backend/src/utils/handleCSVExport.ts index c6fd17d..32d1ed4 100644 --- a/Backend/src/utils/handleCSVExport.ts +++ b/Backend/src/utils/handleCSVExport.ts @@ -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); }; + diff --git a/Backend/src/utils/toCSV.ts b/Backend/src/utils/toCSV.ts index 51c8322..f786952 100644 --- a/Backend/src/utils/toCSV.ts +++ b/Backend/src/utils/toCSV.ts @@ -17,3 +17,5 @@ export default function toCSV( return [headers.join(","), ...a.map((row) => row.join(","))].join("\n"); } + + diff --git a/Client/cypress.config.js b/Client/cypress.config.js index 463d593..71b99e0 100644 --- a/Client/cypress.config.js +++ b/Client/cypress.config.js @@ -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; }, }, diff --git a/Client/cypress/screenshots/todo2.cy.js/example to-do app -- displays two todo items by default (failed).png b/Client/cypress/screenshots/todo2.cy.js/example to-do app -- displays two todo items by default (failed).png index 1c69f7f..3aa1841 100644 Binary files a/Client/cypress/screenshots/todo2.cy.js/example to-do app -- displays two todo items by default (failed).png and b/Client/cypress/screenshots/todo2.cy.js/example to-do app -- displays two todo items by default (failed).png differ diff --git a/Client/src/index.js b/Client/src/index.js index 287c14b..f77af2b 100644 --- a/Client/src/index.js +++ b/Client/src/index.js @@ -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;