From 1082d33209e35f095c45aecf9a87d3a39b3f6fb8 Mon Sep 17 00:00:00 2001 From: Mats <64415243+mnyflot@users.noreply.github.com> Date: Mon, 22 Apr 2024 03:45:22 +0200 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20:white=5Fcheck=5Fmark:=20updat?= =?UTF-8?q?e=20fullBlogCard=20to=20test=20img=20src=E2=80=A6=20(#352)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(frontend): :white_check_mark: update fullBlogCard to test img src instead of visibility * fix(frontend): :bug: fix import bug, retries for component testing and run prettier --------- Co-authored-by: Lucas Tran --- frontend/playwright-ct.config.ts | 2 +- frontend/src/lib/convertSatrec.ts | 2 +- frontend/tests/componentTests/fullblogcard.spec.tsx | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend/playwright-ct.config.ts b/frontend/playwright-ct.config.ts index bfa5c8f..5345b7e 100644 --- a/frontend/playwright-ct.config.ts +++ b/frontend/playwright-ct.config.ts @@ -18,7 +18,7 @@ export default defineConfig({ /* Fail the build on CI if you accidentally left test.only in the source code. */ forbidOnly: !!process.env.CI, /* Retry on CI only */ - retries: process.env.CI ? 2 : 0, + retries: 2, /* Opt out of parallel tests on CI. */ workers: process.env.CI ? 1 : undefined, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ diff --git a/frontend/src/lib/convertSatrec.ts b/frontend/src/lib/convertSatrec.ts index d27a51f..211f22a 100644 --- a/frontend/src/lib/convertSatrec.ts +++ b/frontend/src/lib/convertSatrec.ts @@ -1,6 +1,6 @@ import * as satellite from "satellite.js"; import { SatRec } from "satellite.js"; -import globeData from "@components/homeComponents/files/globe-data.json"; +import globeData from "@/components/homeComponents/files/globe-data.json"; // turf needs ts ignore to work with typescript // @ts-ignore diff --git a/frontend/tests/componentTests/fullblogcard.spec.tsx b/frontend/tests/componentTests/fullblogcard.spec.tsx index 001e7b7..16b2ebf 100644 --- a/frontend/tests/componentTests/fullblogcard.spec.tsx +++ b/frontend/tests/componentTests/fullblogcard.spec.tsx @@ -39,8 +39,11 @@ test("FullBlogCard renders correctly", async ({ mount }) => { component.getByText("Mock article content preview text..."), ).toBeVisible(); - //Check if the image is visible - await expect(component.getByRole("img")).toBeVisible(); + //Wait for the image to actually have its src attribute set with the real image URL + await expect(component.getByRole("img")).toHaveAttribute( + "src", + /mock-cover-image\.jpg/, + ); //Check if datePublished is visible await expect(component.getByText("April 13, 2024")).toBeVisible();