Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(playwright): ✅ update goto() urls #177

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/playwright/about-me/aboutMe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { expect, test } from '@playwright/test'
test.describe('About Me Page - Tests', () => {
test('Heading + text', async ({ page }) => {
await test.step('Go to page About me', async () => {
await page.goto('http://localhost:3000/about-me')
await page.goto('/about-me')
})

await test.step('Check that the Heading text is correct', async () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/playwright/breadcrumbs/aboutMe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { expect, test } from '@playwright/test'
test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
await test.step('Go to About Me page', async () => {
await page.goto('http://localhost:3000/about-me')
await page.goto('/about-me')
})

const breadcrumbs = page.locator(getDataTestId(DATA_TEST_IDS.breadcrumbs))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { expect, test } from '@playwright/test'
test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
await test.step('Go to Cryptomania subpage', async () => {
await page.goto('http://localhost:3000/personal-projects/cryptomania')
await page.goto('/personal-projects/cryptomania')
})

const breadcrumbs = page.locator(getDataTestId(DATA_TEST_IDS.breadcrumbs))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { expect, test } from '@playwright/test'
test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
await test.step('Go to Portfolio Website subpage', async () => {
await page.goto('http://localhost:3000/personal-projects/krsiak')
await page.goto('/personal-projects/krsiak')
})

const breadcrumbs = page.locator(getDataTestId(DATA_TEST_IDS.breadcrumbs))
Expand Down
2 changes: 1 addition & 1 deletion __tests__/playwright/breadcrumbs/personalProjects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { expect, test } from '@playwright/test'
test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
await test.step('Go to Personal projects page', async () => {
await page.goto('http://localhost:3000/personal-projects')
await page.goto('/personal-projects')
})

const breadcrumbs = page.locator(getDataTestId(DATA_TEST_IDS.breadcrumbs))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { expect, test } from '@playwright/test'
test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
await test.step('Go to Groupon subpage', async () => {
await page.goto('http://localhost:3000/work-experience/groupon')
await page.goto('/work-experience/groupon')
})

const breadcrumbs = page.locator(getDataTestId(DATA_TEST_IDS.breadcrumbs))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { expect, test } from '@playwright/test'
test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
await test.step('Go to Komercni banka subpage', async () => {
await page.goto('http://localhost:3000/work-experience/komercni-banka')
await page.goto('/work-experience/komercni-banka')
})

const breadcrumbs = page.locator(getDataTestId(DATA_TEST_IDS.breadcrumbs))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { expect, test } from '@playwright/test'
test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
await test.step('Go to Moravia subpage', async () => {
await page.goto('http://localhost:3000/work-experience/moravia')
await page.goto('/work-experience/moravia')
})

const breadcrumbs = page.locator(getDataTestId(DATA_TEST_IDS.breadcrumbs))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { expect, test } from '@playwright/test'
test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
await test.step('Go to Smartsupp dashboard subpage', async () => {
await page.goto('http://localhost:3000/work-experience/smartsupp-dashboard')
await page.goto('/work-experience/smartsupp-dashboard')
})

const breadcrumbs = page.locator(getDataTestId(DATA_TEST_IDS.breadcrumbs))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { expect, test } from '@playwright/test'
test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
await test.step('Go to Smartsupp HELP subpage', async () => {
await page.goto('http://localhost:3000/work-experience/smartsupp-help')
await page.goto('/work-experience/smartsupp-help')
})

const breadcrumbs = page.locator(getDataTestId(DATA_TEST_IDS.breadcrumbs))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { expect, test } from '@playwright/test'
test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
await test.step('Go to Smartsupp web subpage', async () => {
await page.goto('http://localhost:3000/work-experience/smartsupp-web')
await page.goto('/work-experience/smartsupp-web')
})

const breadcrumbs = page.locator(getDataTestId(DATA_TEST_IDS.breadcrumbs))
Expand Down
2 changes: 1 addition & 1 deletion __tests__/playwright/breadcrumbs/workExperience.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { expect, test } from '@playwright/test'
test.describe('Links', () => {
test('should navigate correctly', async ({ page }) => {
await test.step('Go to Work experience page', async () => {
await page.goto('http://localhost:3000/work-experience')
await page.goto('/work-experience')
})

const breadcrumbs = page.locator(getDataTestId(DATA_TEST_IDS.breadcrumbs))
Expand Down
4 changes: 1 addition & 3 deletions __tests__/playwright/footer/copyright.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import { ID } from '@/utils/constants'
import { DATA_TEST_IDS } from '@/utils/dataTestIds'
import { expect, test } from '@playwright/test'

const HOME_PAGE_PATH = '/'

test.describe('Footer - Copy', () => {
test('Copyright', async ({ page }) => {
await test.step('Go to home page', async () => {
await page.goto(HOME_PAGE_PATH)
await page.goto('/')
})

await test.step('Check if the footer is present on the page', async () => {
Expand Down
19 changes: 6 additions & 13 deletions __tests__/playwright/header/desktop-menu/linkAboutMe.spec.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
import { getDataTestId } from '@/__tests__/playwright/utils/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/dataTestIds'
import { expect, test } from '@playwright/test'

const Selectors = {
MENU_ABOUT_ME: 'data-testid=desktop-about-me-link',
}

const Paths = {
HOME: '/',
ABOUT_ME: 'http://localhost:3000/about-me',
}

test.describe('Desktop Menu', () => {
test('Link - About Me', async ({ page }) => {
await test.step('Go to home page', async () => {
await page.goto(Paths.HOME)
await page.goto('/')
})

await test.step('Check if the link is visible', async () => {
const isLinkVisible = await page.isVisible(Selectors.MENU_ABOUT_ME)
const isLinkVisible = await page.isVisible(getDataTestId(DATA_TEST_IDS.menu.desktop.links.aboutMe))
expect(isLinkVisible).toBe(true)
})

await test.step('Check if the link redirects to the about me page when clicked', async () => {
await page.click(Selectors.MENU_ABOUT_ME)
await page.click(getDataTestId(DATA_TEST_IDS.menu.desktop.links.aboutMe))
await page.waitForLoadState('networkidle')
expect(page.url()).toBe(Paths.ABOUT_ME)
expect(page.url()).toBe('http://localhost:3000/about-me')
})

await test.step('Check if the H1 heading on the final page has the text "About Me"', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
import { getDataTestId } from '@/__tests__/playwright/utils/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/dataTestIds'
import { expect, test } from '@playwright/test'

const Selectors = {
MENU_PERSONAL_PROJECTS: 'data-testid=desktop-personal-projects-link',
}

const Paths = {
HOME: '/',
PERSONAL_PROJECTS: 'http://localhost:3000/personal-projects',
}

test.describe('Desktop Menu', () => {
test('Link - Personal Projects', async ({ page }) => {
await test.step('Go to home page', async () => {
await page.goto(Paths.HOME)
await page.goto('/')
})

await test.step('Check if the link is visible', async () => {
const isLinkVisible = await page.isVisible(Selectors.MENU_PERSONAL_PROJECTS)
const isLinkVisible = await page.isVisible(getDataTestId(DATA_TEST_IDS.menu.desktop.links.personalProjects))
expect(isLinkVisible).toBe(true)
})

await test.step('Check if the link redirects to the personal projects page when clicked', async () => {
await page.click(Selectors.MENU_PERSONAL_PROJECTS)
await page.click(getDataTestId(DATA_TEST_IDS.menu.desktop.links.personalProjects))
await page.waitForLoadState('networkidle')
expect(page.url()).toBe(Paths.PERSONAL_PROJECTS)
expect(page.url()).toBe('http://localhost:3000/personal-projects')
})

await test.step('Check if the H1 heading on the final page has the text "Personal Projects"', async () => {
Expand Down
19 changes: 6 additions & 13 deletions __tests__/playwright/header/desktop-menu/linkResume.spec.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
import { getDataTestId } from '@/__tests__/playwright/utils/getDataTestId'
import { TEXT } from '@/localization/texts_en'
import { DATA_TEST_IDS } from '@/utils/dataTestIds'
import { expect, test } from '@playwright/test'

const Selectors = {
MENU_RESUME: 'data-testid=desktop-resume-link',
}

const Paths = {
HOME: '/',
RESUME: 'http://localhost:3000/resume',
}

test.describe('Desktop Menu', () => {
test('Link - Resume', async ({ page }) => {
await test.step('Go to home page', async () => {
await page.goto(Paths.HOME)
await page.goto('/')
})

await test.step('Check if the link is visible', async () => {
const isLinkVisible = await page.isVisible(Selectors.MENU_RESUME)
const isLinkVisible = await page.isVisible(getDataTestId(DATA_TEST_IDS.menu.desktop.links.resume))
expect(isLinkVisible).toBe(true)
})

await test.step('Check if the link redirects to the resume page when clicked', async () => {
await page.click(Selectors.MENU_RESUME)
await page.click(getDataTestId(DATA_TEST_IDS.menu.desktop.links.resume))
await page.waitForLoadState('networkidle')
expect(page.url()).toBe(Paths.RESUME)
expect(page.url()).toBe('http://localhost:3000/resume')
})

await test.step('Check if the H1 heading on the final page has the text "Resume"', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
import { getDataTestId } from '@/__tests__/playwright/utils/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/dataTestIds'
import { expect, test } from '@playwright/test'

const Selectors = {
MENU_WORK_EXPERIENCE: 'data-testid=desktop-work-experience-link',
}

const Paths = {
HOME: '/',
WORK_EXPERIENCE: 'http://localhost:3000/work-experience',
}

test.describe('Desktop Menu', () => {
test('Link - Work Experience', async ({ page }) => {
await test.step('Go to home page', async () => {
await page.goto(Paths.HOME)
await page.goto('/')
})

await test.step('Check if the link is visible', async () => {
const isLinkVisible = await page.isVisible(Selectors.MENU_WORK_EXPERIENCE)
const isLinkVisible = await page.isVisible(getDataTestId(DATA_TEST_IDS.menu.desktop.links.workExperience))
expect(isLinkVisible).toBe(true)
})

await test.step('Check if the link redirects to the work experience page when clicked', async () => {
await page.click(Selectors.MENU_WORK_EXPERIENCE)
await page.click(getDataTestId(DATA_TEST_IDS.menu.desktop.links.workExperience))
await page.waitForLoadState('networkidle')
expect(page.url()).toBe(Paths.WORK_EXPERIENCE)
expect(page.url()).toBe('http://localhost:3000/work-experience')
})

await test.step('Check if the H1 heading on the final page has the text "Work Experience"', async () => {
Expand Down
25 changes: 9 additions & 16 deletions __tests__/playwright/header/headerLogo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,32 @@
import { getDataTestId } from '@/__tests__/playwright/utils/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/dataTestIds'
import { expect, test } from '@playwright/test'

const Selectors = {
HEADER_LOGO: 'data-testid=header-logo',
}

const Paths = {
HOME: '/',
HOME_PAGE_URL: 'http://localhost:3000/',
}

test.describe('Header - Logo', () => {
test('Check link and text', async ({ page }) => {
await test.step('Go to home page', async () => {
await page.goto(Paths.HOME)
await page.goto('/')
})

await test.step('Check if the link is visible', async () => {
const isLinkVisible = await page.isVisible(Selectors.HEADER_LOGO)
const isLinkVisible = await page.isVisible(getDataTestId(DATA_TEST_IDS.header))
expect(isLinkVisible).toBe(true)
})

await test.step('Check if the link text is correct', async () => {
const linkText = await page.textContent(Selectors.HEADER_LOGO)
const linkText = await page.textContent(getDataTestId(DATA_TEST_IDS.header))
expect(linkText).toBe('krsiak.cz')
})

await test.step('Check if link is correct', async () => {
const linkUrl = await page.getAttribute(Selectors.HEADER_LOGO, 'href')
expect(linkUrl).toBe(Paths.HOME)
const linkUrl = await page.getAttribute(getDataTestId(DATA_TEST_IDS.header), 'href')
expect(linkUrl).toBe('/')
})

await test.step('Check if the link redirects to the home page when clicked', async () => {
await page.click(Selectors.HEADER_LOGO)
await page.click(getDataTestId(DATA_TEST_IDS.header))
await page.waitForLoadState('networkidle')
expect(page.url()).toBe(Paths.HOME_PAGE_URL)
expect(page.url()).toBe('http://localhost:3000/')
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import { getDataTestId } from '@/__tests__/playwright/utils/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/dataTestIds'
import test, { expect } from '@playwright/test'

const START_URL = 'http://localhost:3000/about-me'

test.describe('Navigation - About Me', () => {
test('navigates to previous page - Homepage', async ({ page }) => {
// Navigate to your app's page
await page.goto(START_URL)
await page.goto('/about-me')

// Click on the NextPageNavigation component to go to the previous page
await page.click(getDataTestId(DATA_TEST_IDS.page.aboutMe.previous))
Expand All @@ -18,7 +16,7 @@ test.describe('Navigation - About Me', () => {

test('navigates to next page - Resume', async ({ page }) => {
// Navigate to your app's page
await page.goto(START_URL)
await page.goto('/about-me')

// Click on the NextPageNavigation component to go to the next page
await page.click(getDataTestId(DATA_TEST_IDS.page.aboutMe.next))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import test, { expect } from '@playwright/test'
test.describe('Navigation - Personal Projects', () => {
test('navigates to previous page - Work Experience', async ({ page }) => {
// Navigate to your app's page
await page.goto('http://localhost:3000/personal-projects')
await page.goto('/personal-projects')

// Click on the NextPageNavigation component to go to the previous page
await page.click(getDataTestId(DATA_TEST_IDS.projects.personal.overview.previous))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import { getDataTestId } from '@/__tests__/playwright/utils/getDataTestId'
import { DATA_TEST_IDS } from '@/utils/dataTestIds'
import test, { expect } from '@playwright/test'

const START_URL = 'http://localhost:3000/work-experience'

test.describe('Navigation - Work Experience', () => {
test('navigates to previous page - Resume', async ({ page }) => {
// Navigate to your app's page
await page.goto(START_URL)
await page.goto('/work-experience')

// Click on the NextPageNavigation component to go to the previous page
await page.click(getDataTestId(DATA_TEST_IDS.projects.work.overview.previous))
Expand All @@ -18,7 +16,7 @@ test.describe('Navigation - Work Experience', () => {

test('navigates to next page - Personal Projects', async ({ page }) => {
// Navigate to your app's page
await page.goto(START_URL)
await page.goto('/work-experience')

// Click on the NextPageNavigation component to go to the next page
await page.click(getDataTestId(DATA_TEST_IDS.projects.work.overview.next))
Expand Down
3 changes: 1 addition & 2 deletions __tests__/playwright/statusPage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { expect, test } from '@playwright/test'

const STATUS_PAGE_URL = 'http://localhost:3000/status-page'
const STATUS_BADGE_SELECTOR = 'img'

test.describe('Status Page', () => {
test('Page title and status badges', async ({ page }) => {
await test.step('Go to status page', async () => {
await page.goto(STATUS_PAGE_URL)
await page.goto('/status-page')
})

await test.step('Check if the page title is correct', async () => {
Expand Down
1 change: 1 addition & 0 deletions utils/dataTestIds.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO: refactor this file to be more readable
const NEXT = 'next'
const PREVIOUS = 'previous'
const PAGE_NAVIGATION = 'page-navigation'
Expand Down
Loading