Skip to content

Commit

Permalink
Refactor Apply Now button in ProjectsPage.tsx and test.ts files
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaiahA21 committed Oct 5, 2024
1 parent 4185db2 commit 80f97c0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
16 changes: 9 additions & 7 deletions src/pages/ProjectsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,15 @@ const ProjectsPage = () => {
bring to life with Tech Start?
</h3>
<S.WrapDiv>
<HoverButton
mode={ButtonMode.GRADIENT}
glowOnHover={true}
link="/apply"
text={"Apply Now"}
linkIsInternal={true}
/>
<div data-testid="apply_now_button">
<HoverButton
mode={ButtonMode.GRADIENT}
glowOnHover={true}
link="/apply"
text={"Apply Now"}
linkIsInternal={true}
/>
</div>
</S.WrapDiv>
</div>
<ProjectKeywordsSection />
Expand Down
9 changes: 5 additions & 4 deletions tests/homePage/HomePage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ test('Should display Logo', async ({ page }) => {

/**
* Test join team button
* sidenote: Oct 4,2024 -> consistently fails on webkit
*/
test('join button should navigate to Apply page', async function ({ page }) {
test('join button should navigate to Apply page', async function ({ page, baseURL }) {
await page.goto("/");

// Wait for the join team button to be visible before clicking
Expand All @@ -34,10 +35,10 @@ test('join button should navigate to Apply page', async function ({ page }) {
*/
await Promise.all([
applyBtn.click(), // Trigger the click
await page.waitForURL(/.*apply/), // Wait for the navigation to /apply
await expect(page).toHaveURL(`${baseURL}/apply`) // Wait for the navigation to /apply
]);
await expect(page).toHaveURL(/.*apply/)

await expect(page).toHaveURL(`${baseURL}/apply`);
await page.close();
});

Expand Down
5 changes: 3 additions & 2 deletions tests/navigationBar/NavBar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ test('Test apply button navigates to the apply page', async ({ page, baseURL })
await page.goto('/');
await page.getByText('Apply', { exact: true }).click();
await expect(page).toHaveURL(`${baseURL}/apply`);
await expect(page.getByRole('heading', { name: 'APPLY' })).toBeVisible();
// ensure there's an application section
await expect(page.getByRole('heading', { name: 'Applications', exact: true })).toBeVisible()
await page.close();

});
Expand All @@ -101,7 +102,7 @@ test('Test merch button navigates to the Merch page and then find the 2 merch',
test('Test gallery button navigates to the Merch page', async function ({ page, baseURL }) {
await page.goto('/');
await page.getByText('Gallery', { exact: true }).click();
await expect(page).toHaveURL(`${ baseURL }/gallery`);
await expect(page).toHaveURL(`${baseURL}/gallery`);
await page.getByRole('heading', { name: 'Gallery' }).click();
await expect(page.getByTestId('photo-gallery-image-0')).toBeVisible();
await expect(page.getByTestId('photo-gallery-image-32')).toBeVisible();
Expand Down
8 changes: 5 additions & 3 deletions tests/project/ProjectPage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import { test, expect } from '@playwright/test';
*/
test('Apply Now btn nagivates to the apply now page', async ({ page, baseURL }) => {
await page.goto(`${baseURL}/projects`);
await page.getByText('Apply Now').click();
await expect(page).toHaveURL(/.*apply/);
await expect(page.getByRole('heading', { name: 'APPLY' })).toBeVisible();
// await page.getByText('Apply Now').click();
const applyButton = page.getByTestId('apply_now_button');
applyButton.click();
await expect(page).toHaveURL(`${baseURL}/apply`);
// await expect(page.getByRole('heading', { name: 'APPLY' })).toBeVisible();
await page.close();

});

0 comments on commit 80f97c0

Please sign in to comment.