-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…#250) * feat: add data-testid to About us hero * feat(test): write test for successful render of About us page * fix(test): rename hero section component test case * feat(test): define data-testid for mission section * feat(test): write test case for mission section * feat(test): define data-testid for leadership section * feat(test): write test case for leadership section * feat(test): define data-testid for reports section * feat(test): write test case for reports section * chore: rename test elements for clarity * feat(test): define data-testid for leadership carousel and elements * feat(test): write test case for carousel display * feat(test): define data-testid for partnership btn and modal * feat(test): write test case for partner with us modal in /about
- Loading branch information
Showing
7 changed files
with
136 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import { HelmetProvider } from "react-helmet-async"; | ||
import { BrowserRouter } from "react-router-dom"; | ||
import { describe, expect, it } from "vitest"; | ||
|
||
import placeholder from "../../src/assets/images/sytLogo.png"; | ||
import Caroussel from "../../src/components/Caroussel"; | ||
import AboutUs from "../../src/pages/aboutUs/AboutUs"; | ||
|
||
const LeadershipData = [ | ||
{ | ||
name: "First User", | ||
title: "Founder", | ||
image: placeholder, | ||
linkedin: { | ||
href: "https://www.linkedin.com/", | ||
username: "First User", | ||
}, | ||
twitter: { | ||
href: "https://twitter.com/x", | ||
username: "First User", | ||
}, | ||
}, | ||
{ | ||
name: "Second User", | ||
title: "Dev Relations & Opensource Programs", | ||
image: placeholder, | ||
linkedin: { | ||
href: "https://www.linkedin.com", | ||
username: "Second User", | ||
}, | ||
twitter: { | ||
href: "", | ||
username: "", | ||
}, | ||
}, | ||
{ | ||
name: "Third User", | ||
title: "Community Manager", | ||
image: placeholder, | ||
linkedin: { | ||
href: "https://www.linkedin.com", | ||
username: "Third User", | ||
}, | ||
twitter: { | ||
href: "", | ||
username: "", | ||
}, | ||
}, | ||
]; | ||
|
||
describe("About us page unit tests", () => { | ||
const renderWithRouter = (ui) => | ||
render( | ||
<HelmetProvider> | ||
<BrowserRouter>{ui}</BrowserRouter> | ||
</HelmetProvider> | ||
); | ||
|
||
it("should render Hero Section successfully", () => { | ||
renderWithRouter(<AboutUs />); | ||
const titleElement = screen.getByTestId("title"); | ||
expect(titleElement).toBeTruthy(); | ||
}); | ||
|
||
it("should render Mission/Vision Section successfully", () => { | ||
renderWithRouter(<AboutUs />); | ||
const testElement = screen.getByTestId("mission"); | ||
expect(testElement).toBeTruthy(); | ||
}); | ||
|
||
it("should render Leadership Section successfully", () => { | ||
renderWithRouter(<AboutUs />); | ||
const testElement = screen.getByTestId("leadership"); | ||
expect(testElement).toBeTruthy(); | ||
}); | ||
|
||
it("should render Reports Section successfully", () => { | ||
renderWithRouter(<AboutUs />); | ||
const testElement = screen.getByTestId("reports"); | ||
expect(testElement).toBeTruthy(); | ||
}); | ||
|
||
it("should render leadership carousel successfully", () => { | ||
renderWithRouter(<Caroussel CarousselData={LeadershipData} />); | ||
const carouselElement = screen.getByTestId("carousel"); | ||
expect(carouselElement).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { test, expect } from "@playwright/test"; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto("http://localhost:5173/about-us"); | ||
}); | ||
|
||
test("should render partnership modal when partner with us btn is clicked", async ({ | ||
page, | ||
}) => { | ||
const testId = "partner-with-us"; | ||
// click Partner with us button | ||
await page.click(`button[data-testid="${testId}"]`); | ||
|
||
// Check if the popup is visible | ||
const popupTestId = "partner-popup"; | ||
const popup = await page.locator(`div[data-testid="${popupTestId}"]`); | ||
await expect(popup).toBeVisible(); | ||
}); |