-
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.
- Loading branch information
1 parent
087f805
commit 7fa9e8f
Showing
17 changed files
with
258 additions
and
15 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,33 @@ | ||
name: Playwright Tests | ||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: [main, master] | ||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
|
||
- name: Install dependencies | ||
run: npm install -g pnpm && pnpm install | ||
|
||
- name: Install Playwright Browsers | ||
run: pnpm exec playwright install --with-deps | ||
|
||
- name: Run Playwright tests | ||
run: pnpm e2e:test | ||
|
||
- uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 30 |
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,66 @@ | ||
import { expect, test } from '@playwright/test'; | ||
|
||
test.describe('Landing Page Tests', () => { | ||
test.beforeEach(async ({ page }) => { | ||
// Navigate to the base URL before each test | ||
await page.goto('/'); | ||
}); | ||
|
||
test('Should have the appropriate page title', async ({ page }) => { | ||
await expect(page).toHaveTitle(/Eduardo Couto/); | ||
}); | ||
|
||
test('Should check content on hero section', async ({ page }) => { | ||
await expect(page.getByTestId('hero-message')).toContainText( | ||
"Hello, I'm Eduardo. I'm a full-stack developer with 2 years of experience. I enjoy buildingwebsites & applications. My main focus is with Java and React (Next.js).", | ||
); | ||
}); | ||
|
||
test('Should navigate to the Projects section', async ({ page }) => { | ||
// Click on the Projects link | ||
await page.goto('/#projects'); | ||
|
||
// Verify the Projects section is displayed by checking for a specific element | ||
const projectsHeading = page.getByTestId('projects-heading'); | ||
|
||
await expect(projectsHeading).toBeTruthy(); | ||
await expect(projectsHeading).toContainText('My projects'); | ||
await expect(projectsHeading).toBeVisible(); | ||
}); | ||
|
||
test('Should submit the Contact form successfully', async ({ page }) => { | ||
// Navigate to the Contact section | ||
await page.goto('/#contact'); | ||
// Fill the form | ||
await page.fill('input[name="name"]', 'John Doe'); | ||
await page.fill('input[name="email"]', 'john.doe@example.com'); | ||
await page.fill('textarea[name="message"]', 'Hello, This is a test message.'); | ||
// Click the submit button | ||
await page.click('text=Submit'); | ||
// Verify submission success message or redirection | ||
await expect(page.getByTestId('toast-container')).toBeVisible(); | ||
await expect(page.getByTestId('toast-container')).toContainText('Email sent successfully!'); | ||
}); | ||
|
||
test('Should show the contact form errors', async ({ page }) => { | ||
// Navigate to the Contact section | ||
await page.goto('/#contact'); | ||
// Fill the form | ||
await page.fill('input[name="name"]', 'J'); | ||
await page.fill('input[name="email"]', 'john.doe@example.com'); | ||
await page.fill('textarea[name="message"]', ''); | ||
// Click the submit button | ||
await page.click('text=Submit'); | ||
|
||
// Verify the error messages | ||
await expect(page.getByTestId('invalid-name-warning')).toHaveText( | ||
'Name must be at least 2 characters long', | ||
); | ||
|
||
await expect(page.getByTestId('invalid-email-warning')).toBeHidden(); | ||
|
||
await expect(page.getByTestId('invalid-message-warning')).toHaveText( | ||
'Message must be at least 10 characters long', | ||
); | ||
}); | ||
}); |
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 { expect, test } from '@playwright/test'; | ||
|
||
test.describe('404 Page Tests', () => { | ||
test.beforeEach(async ({ page }) => { | ||
// Navigate to the base URL before each test | ||
await page.goto('/non-existent-page'); | ||
}); | ||
|
||
test('Should display a 404 message for non-existent routes', async ({ page }) => { | ||
// Navigate to a non-existent route | ||
await page.goto('/non-existent-page'); | ||
// Check if the 404 text is present | ||
await expect(page.locator('h1')).toContainText('404'); | ||
await expect(page.locator('h2')).toContainText('Page not found - Seems you look lost'); | ||
|
||
const redirectLink = page.getByTestId('redirect-home-link'); | ||
expect(redirectLink).toBeTruthy(); | ||
expect(redirectLink).toContainText('Click here to go back home'); | ||
expect(redirectLink).toHaveAttribute('href', '/'); | ||
}); | ||
|
||
test('Should redirect to landing page on click', async ({ page }) => { | ||
// Navigate to a non-existent route | ||
await page.goto('/non-existent-page'); | ||
// Check if the 404 text is present | ||
|
||
const redirectLink = page.getByTestId('redirect-home-link'); | ||
await redirectLink.click(); | ||
|
||
await expect(page).toHaveURL('/'); | ||
}); | ||
}); |
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,57 @@ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// require('dotenv').config(); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: './e2e', | ||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: 'html', | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
baseURL: 'http://127.0.0.1:3000', | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
|
||
{ | ||
name: 'firefox', | ||
use: { ...devices['Desktop Firefox'] }, | ||
}, | ||
|
||
{ | ||
name: 'webkit', | ||
use: { ...devices['Desktop Safari'] }, | ||
}, | ||
], | ||
|
||
/* Run your local dev server before starting the tests */ | ||
webServer: { | ||
command: 'pnpm start', | ||
url: 'http://127.0.0.1:3000', | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
}); |
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
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
Oops, something went wrong.