diff --git a/cypress/integration/header.spec.ts b/cypress/integration/header.spec.ts deleted file mode 100644 index 8d88220da..000000000 --- a/cypress/integration/header.spec.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { completeOnboarding } from "./landing-page.spec"; - -describe("Header component", () => { - before(() => { - completeOnboarding(); - }); - - it("should display the title correctly", () => { - cy.visit("/MyGoals"); - cy.get(".header h6").should("have.text", "My goals"); - }); - - it("should show search input when search icon is clicked", () => { - cy.get(".header-items").find(".header-icon[alt='zinzen search']").click(); - - cy.get(".header-search").should("be.visible"); - cy.go("back"); - }); - - it("should open settings dropdown when settings icon is clicked", () => { - cy.get(".header-items").find(".header-icon[alt='Settings']").click(); - - cy.get(".header-dropdown").should("be.visible"); - }); - - it("should close settings dropdown when clicked outside", () => { - cy.get(".header-items").find(".header-icon[alt='Settings']").click(); - - cy.get("body").click("bottom"); // Click outside the dropdown - - cy.get(".header-dropdown").should("not.be.visible"); - }); - - it("should toggle dark mode when Switch Mode button is clicked", () => { - cy.get(".header-items").find(".header-icon[alt='Settings']").click(); - - cy.contains("Dark mode").click(); - - // Assert that dark mode is enabled - cy.get(".App-dark").should("be.visible"); - cy.get(".App-light").should("not.exist"); - - cy.get(".header-items").find(".header-icon[alt='Settings']").click(); - - cy.contains("Dark mode").click(); - - // Assert that dark mode is disabled and light mode is enabled - cy.get(".App-dark").should("not.exist"); - cy.get(".App-light").should("be.visible"); - }); - - it("should only display Zinzen settings on MyJournal or My Time page", () => { - const checkHeaderItems = () => { - cy.get(".header-items .header-icon[alt='Settings']").should("be.visible"); - cy.get(".header-items .header-icon[alt='zinzen inbox']").should("not.exist"); - cy.get(".header-items .header-icon[alt='zinzen search']").should("not.exist"); - }; - - cy.contains("Journal").click(); - checkHeaderItems(); - - cy.contains("Schedule").click(); - checkHeaderItems(); - }); -}); diff --git a/playwright/tests/header-ui.spec.ts b/playwright/tests/header-ui.spec.ts new file mode 100644 index 000000000..7718af255 --- /dev/null +++ b/playwright/tests/header-ui.spec.ts @@ -0,0 +1,72 @@ +import { test, expect } from "@playwright/test"; +import { STORAGE_STATE } from "playwright/config/constants"; + +test.describe("Header component", () => { + test.use({ storageState: STORAGE_STATE }); + + test.beforeEach(async ({ page }) => { + await page.goto("http://127.0.0.1:3000/"); + }); + + test("should display the title correctly", async ({ page }) => { + await page.getByRole("button", { name: "Goals" }).click(); + const heading = page.getByRole("heading"); + await expect(heading).toHaveText("My goals"); + }); + + test("should show search input when search icon is clicked", async ({ page }) => { + await page.getByRole("button", { name: "Goals" }).click(); + const searchIcon = page.getByRole("img", { name: "zinzen search" }); + await searchIcon.click(); + const searchInput = page.getByPlaceholder("Search"); + await expect(searchInput).toBeVisible(); + }); + + test("should open settings dropdown when settings icon is clicked", async ({ page }) => { + const settingsIcon = page.getByRole("img", { name: "Settings" }); + await settingsIcon.click(); + const settingsDropdown = page.locator(".ant-dropdown"); + await expect(settingsDropdown).toHaveCSS("display", "block"); + }); + + test("should close settings dropdown when clicked outside", async ({ page }) => { + const settingsIcon = page.getByRole("img", { name: "Settings" }); + await settingsIcon.click(); + await page.locator("body").click({ position: { x: 0, y: 0 } }); + const settingsDropdown = page.locator(".ant-dropdown"); + await expect(settingsDropdown).toHaveCSS("display", "none"); + }); + + test("should toggle dark mode when Switch Mode button is clicked", async ({ page }) => { + const settingsIcon = page.getByRole("img", { name: "Settings" }); + await settingsIcon.click(); + + const darkModeSwitch = page.locator("div").filter({ hasText: /^Dark mode$/ }); + await darkModeSwitch.click(); + await expect(page.locator(".App-light")).toBeVisible(); + await expect(page.locator(".App-dark")).not.toBeVisible(); + + await settingsIcon.click(); + await darkModeSwitch.click(); + await expect(page.locator(".App-light")).not.toBeVisible(); + await expect(page.locator(".App-dark")).toBeVisible(); + }); + + test("verify header icons visibility on specific pages", async ({ page }) => { + const checkHeaderItems = async () => { + const settingsIcon = page.getByRole("img", { name: "Settings" }); + const lightModeIcon = page.getByRole("img", { name: "light mode" }); + const searchIcon = page.getByRole("img", { name: "zinzen search" }); + + await expect(settingsIcon).toBeVisible(); + await expect(lightModeIcon).toBeVisible(); + await expect(searchIcon).not.toBeVisible(); + }; + + await page.getByRole("button", { name: "Journal" }).click(); + await checkHeaderItems(); + + await page.getByRole("button", { name: "Schedule" }).click(); + await checkHeaderItems(); + }); +}); diff --git a/playwright/userOnboarding.json b/playwright/userOnboarding.json index 1ceab7cd7..a9eee1a57 100644 --- a/playwright/userOnboarding.json +++ b/playwright/userOnboarding.json @@ -18,7 +18,7 @@ }, { "name": "darkMode", - "value": "off" + "value": "on" } ] } diff --git a/src/components/GoalsComponents/GoalSublist/GoalSublist.scss b/src/components/GoalsComponents/GoalSublist/GoalSublist.scss index e05414f64..1665a2fe0 100644 --- a/src/components/GoalsComponents/GoalSublist/GoalSublist.scss +++ b/src/components/GoalsComponents/GoalSublist/GoalSublist.scss @@ -29,6 +29,12 @@ flex-direction: column; justify-content: center; + .goal-item-summary-wrapper { + margin: 10px auto; + text-align: center; + padding: 0 24px; + } + .mygoalsbutton-dark, .mygoalsbutton-light { display: none; diff --git a/src/components/GoalsComponents/GoalSublist/GoalSublist.tsx b/src/components/GoalsComponents/GoalSublist/GoalSublist.tsx index 321165308..775da899d 100755 --- a/src/components/GoalsComponents/GoalSublist/GoalSublist.tsx +++ b/src/components/GoalsComponents/GoalSublist/GoalSublist.tsx @@ -25,6 +25,7 @@ import GoalHistory from "./GoalHistory"; import GoalsAccordion from "../GoalsAccordion"; import "./GoalSublist.scss"; +import GoalItemSummary from "../MyGoal/GoalItemSummary/GoalItemSummary"; export const GoalSublist = () => { const { t } = useTranslation(); @@ -86,6 +87,7 @@ export const GoalSublist = () => {
{parentGoal && t(parentGoal?.title)}
+ {parentGoal &&
-
{t(`${goal.title}`)}
+