-
Notifications
You must be signed in to change notification settings - Fork 0
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 #22 from brunomachadors/21-automated-playwright-te…
…sts-for-portfolio-homepage-and-footer feat: Initialize locators in HomePage constructor for improved reusab…
- Loading branch information
Showing
12 changed files
with
251 additions
and
48 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,13 +1,20 @@ | ||
export default function Footer() { | ||
return ( | ||
<footer className="w-full flex flex-col items-center justify-start gap-6 p-4 border-t border-white/20 "> | ||
<div className="flex flex-wrap justify-center gap-6"> | ||
<footer | ||
className="w-full flex flex-col items-center justify-start gap-6 p-4 border-t border-white/20" | ||
data-test-id="footer-container" | ||
> | ||
<div | ||
className="flex flex-wrap justify-center gap-6" | ||
data-test-id="footer-links" | ||
> | ||
<a | ||
href="https://www.instagram.com/brunomachadors/" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
aria-label="INSTAGRAM" | ||
className="hover:text-yellow-500 transition transform hover:scale-110 uppercase" | ||
data-test-id="footer-link-instagram" | ||
> | ||
<span className="material-icons text-sm sm:text-xl">instagram</span> | ||
</a> | ||
|
@@ -17,6 +24,7 @@ export default function Footer() { | |
rel="noopener noreferrer" | ||
aria-label="LINKEDIN" | ||
className="hover:text-yellow-500 transition transform hover:scale-110 uppercase" | ||
data-test-id="footer-link-linkedin" | ||
> | ||
<span className="material-icons text-sm sm:text-xl">linkedin</span> | ||
</a> | ||
|
@@ -26,6 +34,7 @@ export default function Footer() { | |
rel="noopener noreferrer" | ||
aria-label="GITHUB" | ||
className="hover:text-yellow-500 transition transform hover:scale-110 uppercase" | ||
data-test-id="footer-link-github" | ||
> | ||
<span className="material-icons text-sm sm:text-xl">github</span> | ||
</a> | ||
|
@@ -35,19 +44,24 @@ export default function Footer() { | |
rel="noopener noreferrer" | ||
aria-label="MEDIUM" | ||
className="hover:text-yellow-500 transition transform hover:scale-110 uppercase" | ||
data-test-id="footer-link-medium" | ||
> | ||
<span className="material-icons text-sm sm:text-xl">Medium</span> | ||
</a> | ||
<a | ||
href="mailto:[email protected]" | ||
aria-label="EMAIL" | ||
className="hover:text-yellow-500 transition transform hover:scale-110 uppercase" | ||
data-test-id="footer-link-email" | ||
> | ||
<span className="material-icons text-sm sm:text-xl">Email</span> | ||
</a> | ||
</div> | ||
|
||
<p className="text-sm uppercase text-center px-4"> | ||
<p | ||
className="text-sm uppercase text-center px-4" | ||
data-test-id="footer-copyright" | ||
> | ||
© 2024 Bruno Machado. | ||
</p> | ||
</footer> | ||
|
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,24 @@ | ||
// Home Page Data | ||
export const HOME_DATA = { | ||
title: 'Welcome to my Portfolio', | ||
subtitle: 'Explore my skills, experience, and projects as a QA Engineer.', | ||
startButtonText: 'Start here', | ||
}; | ||
|
||
// Footer Data | ||
export const FOOTER_DATA = { | ||
links: ['instagram', 'linkedin', 'github', 'medium', 'email'], | ||
}; | ||
|
||
// Header Data | ||
export const HEADER_DATA = { | ||
menuOptions: [ | ||
'home', | ||
'about', | ||
'resume', | ||
'skills', | ||
'projects', | ||
'posts', | ||
'contacts', | ||
], | ||
}; |
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,27 @@ | ||
import { test } from '@playwright/test'; | ||
import { FooterPage } from './pages/FooterPage'; | ||
import { FOOTER_DATA } from './data'; | ||
|
||
test.describe('Footer', () => { | ||
test('Links and Visibility', async ({ page }) => { | ||
const footerPage = new FooterPage(page); | ||
|
||
await test.step('Go Home', async () => { | ||
await page.goto('/'); | ||
}); | ||
|
||
await test.step('Footer Visible', async () => { | ||
await footerPage.validateFooterVisible(); | ||
}); | ||
|
||
for (const link of FOOTER_DATA.links) { | ||
await test.step(`Check ${link}`, async () => { | ||
await footerPage.validateLinkVisible(link); | ||
}); | ||
} | ||
|
||
await test.step('Copyright', async () => { | ||
await footerPage.validateCopyrightText('© 2024 Bruno Machado.'); | ||
}); | ||
}); | ||
}); |
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,24 @@ | ||
import { test } from '@playwright/test'; | ||
import { HomePage } from './pages/HomePage'; | ||
|
||
test.describe('Home', () => { | ||
test('Content Validation', async ({ page }) => { | ||
const homePage = new HomePage(page); | ||
|
||
await test.step('Go Home', async () => { | ||
await homePage.navigateToHome(); | ||
}); | ||
|
||
await test.step('Check Title', async () => { | ||
await homePage.validateTitleVisible(); | ||
}); | ||
|
||
await test.step('Check Subtitle', async () => { | ||
await homePage.validateSubtitleVisible(); | ||
}); | ||
|
||
await test.step('Check Start Button', async () => { | ||
await homePage.validateStartButtonVisible(); | ||
}); | ||
}); | ||
}); |
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,32 @@ | ||
import { Page, Locator, expect } from '@playwright/test'; | ||
|
||
export class FooterPage { | ||
readonly page: Page; | ||
readonly footerContainer: Locator; | ||
readonly footerLinks: Locator; | ||
readonly copyrightText: Locator; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
this.footerContainer = page.locator('[data-test-id="footer-container"]'); | ||
this.footerLinks = page.locator('[data-test-id="footer-links"] a'); | ||
this.copyrightText = page.locator('[data-test-id="footer-copyright"]'); | ||
} | ||
|
||
async validateFooterVisible() { | ||
await expect(this.footerContainer).toBeVisible(); | ||
} | ||
|
||
async validateLinkVisible(linkTestId: string) { | ||
const link = this.page.locator( | ||
`[data-test-id="footer-link-${linkTestId}"]` | ||
); | ||
await expect(link).toBeVisible(); | ||
await expect(link).toHaveAttribute('href', expect.stringContaining('http')); | ||
} | ||
|
||
async validateCopyrightText(expectedText: string) { | ||
await expect(this.copyrightText).toBeVisible(); | ||
await expect(this.copyrightText).toHaveText(expectedText); | ||
} | ||
} |
Oops, something went wrong.