-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from SpaceyaTech/feat/hero-section
Feature: Hero Section
- Loading branch information
Showing
12 changed files
with
199 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { test, expect } from "@playwright/test"; | ||
|
||
//Test for the HeroSection component | ||
test.describe("HeroSection Component", () => { | ||
test.beforeEach(async ({ page }) => { | ||
//go to the page containing the HeroSection component | ||
await page.goto("http://localhost:3000"); | ||
}); | ||
|
||
test("should render the HeroSection component", async ({ page }) => { | ||
const heroSection = await page.locator('[data-test="HeroSection"]'); | ||
await expect(heroSection).toBeVisible(); | ||
}); | ||
|
||
test("should display the heading ", async ({ page }) => { | ||
const heading = await page.getByRole("heading", { | ||
name: "Making open-source contribution fun again", | ||
}); | ||
await expect(heading).toBeVisible(); | ||
}); | ||
|
||
test("should display the description correctly", async ({ page }) => { | ||
// Locate the description paragraph within the HeroSection | ||
const description = await page.locator( | ||
'[data-test="HeroSection"] p.font-ff-inconsolata', | ||
); | ||
|
||
// Wait for the paragraph to be visible | ||
await expect(description).toBeVisible(); | ||
|
||
// Verify the description text | ||
await expect(description).toHaveText( | ||
"Open-source is the fastest way to get the job experience you need. Colabs is the platform that makes open-source contribution fun and competitive.", | ||
); | ||
}); | ||
|
||
test("should display the collaborator images correctly", async ({ page }) => { | ||
const collaborators = await page.locator( | ||
'[data-test="HeroSection"] img[alt="Collaborator"]', | ||
); | ||
|
||
//check the number of collaborators image displayed | ||
await expect(collaborators).toHaveCount(4); | ||
|
||
//check that they are all visible | ||
for (let i = 0; i < 4; i++) { | ||
const collaborator = collaborators.nth(i); | ||
await expect(collaborator).toBeVisible(); | ||
await expect(collaborator).toHaveClass(/rounded-full/); | ||
} | ||
}); | ||
|
||
test("should display the contributor text", async ({ page }) => { | ||
const contributorText = await page.locator( | ||
'[data-test="HeroSection"] p.font-text-brand-gray-10', | ||
); | ||
await expect(contributorText).toHaveText("500+ contributors and counting"); | ||
}); | ||
|
||
test("should render the action buttons correctly", async ({ page }) => { | ||
// Verify the "Join Colabs" button | ||
const joinButton = await page.locator( | ||
"data-test=HeroSection >> text=Join Colabs", | ||
); | ||
await expect(joinButton).toBeVisible(); | ||
await expect(joinButton).toHaveAttribute( | ||
"href", | ||
"/auth/signup?returnTo=%2Fdashboard", | ||
); | ||
|
||
// Verify the "Launch a Hackathon" button | ||
const hackathonButton = await page.locator( | ||
"data-test=HeroSection >> text=Launch a Hackathon", | ||
); | ||
await expect(hackathonButton).toBeVisible(); | ||
await expect(hackathonButton).toHaveAttribute( | ||
"href", | ||
"/dashboard/hackathons", | ||
); | ||
}); | ||
|
||
test("should display the astronaut image", async ({ page }) => { | ||
// Verify the astronaut image | ||
const astronautImage = await page.locator( | ||
'[data-test="HeroSection"] img[alt="Standing robot"]', | ||
); | ||
await expect(astronautImage).toBeVisible(); | ||
await expect(astronautImage).toHaveClass(/object-contain/); | ||
}); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,72 @@ | ||
import astronaut from "../../assets/Astronaut-herosection.png"; | ||
import rocketIcon from "../../assets/rocket.png"; | ||
import fred from "../../assets/hero-section/fred.png"; | ||
import ian from "../../assets/hero-section/ian.png"; | ||
import katrina from "../../assets/hero-section/katrina.png"; | ||
import sharon from "../../assets/hero-section/sharon.png"; | ||
import { Link } from "@tanstack/react-router"; | ||
|
||
export const HeroSection = () => { | ||
//array of collaborators | ||
const collaborators = [fred, ian, katrina, sharon]; | ||
return ( | ||
//border border-red-500 | ||
<div | ||
data-test="HeroSection" | ||
className="flex flex-col items-center gap-4 p-4 md:mt-2 md:p-5 lg:mt-4 lg:flex lg:flex-row lg:justify-around" | ||
> | ||
<div className="flex flex-col gap-4 p-4 lg:flex lg:w-1/2 lg:flex-col lg:gap-6"> | ||
<h1 className="pb-2 text-[25px] font-bold text-heading md:text-[30px] lg:text-[55px] lg:leading-[60.5px]"> | ||
Making open-source contribution fun again | ||
</h1> | ||
<p className="font-ff-inconsolata text-lg font-bold leading-6 text-brand-gray-8 lg:text-xl"> | ||
Open-source is the fastest way to get the job experience you need. | ||
Colabs is the platform that makes open-source contribution fun and | ||
competitive. | ||
</p> | ||
|
||
{/* collaborators */} | ||
<div className="mt-2 flex flex-col items-start justify-center gap-2 md:flex-row md:items-center md:justify-center lg:justify-start"> | ||
{/* Loop thru the array of collaborators to display them */} | ||
<div className="relative flex"> | ||
{collaborators.map((collaborator, index) => ( | ||
<img | ||
key={index} | ||
src={collaborator} | ||
alt="Collaborator" | ||
className={`h-12 w-12 rounded-full object-cover ${ | ||
index !== 0 ? "-ml-2" : "" | ||
}`} | ||
/> | ||
))} | ||
</div> | ||
|
||
<p className="font-text-brand-gray-10 text-sm font-medium"> | ||
500+ contributors and counting | ||
</p> | ||
</div> | ||
<div className="mt-5 flex flex-col gap-2 md:flex-row md:justify-around lg:justify-start lg:gap-4"> | ||
<Link | ||
to="/auth/signup" | ||
search={{ returnTo: "/dashboard" }} | ||
className="btn bg-brand-green-6 px-4 py-2 text-white md:w-[40%] lg:w-auto lg:text-lg" | ||
> | ||
Join Colabs | ||
</Link> | ||
<Link | ||
to="/dashboard/hackathons" | ||
className="btn bg-brand-green-8 px-4 py-2 text-brand-green-7 outline outline-1 outline-brand-green-8 md:w-[40%] lg:w-auto lg:text-lg" | ||
> | ||
Launch a Hackathon <img src={rocketIcon} alt="Rocket icon" /> | ||
</Link> | ||
</div> | ||
</div> | ||
|
||
<img | ||
src={astronaut} | ||
alt="Standing robot" | ||
className="mt-4 md:h-auto md:max-w-[50%] lg:max-w-[30%] lg:items-center lg:justify-center lg:object-contain" | ||
/> | ||
</div> | ||
); | ||
}; |
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