Skip to content

Commit

Permalink
test: adding playwright chromatic + initial tests
Browse files Browse the repository at this point in the history
  • Loading branch information
canadianpython13 committed Nov 21, 2024
1 parent 17e1454 commit 12b5efe
Show file tree
Hide file tree
Showing 9 changed files with 22,047 additions and 194 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ tmp
.yarn/*
.yarnrc*
.pnp.*
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
11 changes: 11 additions & 0 deletions e2e/introduction.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { test, expect } from '@chromatic-com/playwright'
import { IntroPage } from './pages/IntroductionPage';

test.only('should load intro page', async ({ page }) => {
const introPage = new IntroPage(page)
await introPage.goto()
await expect(introPage.pageTitle).toBeVisible()
await expect(introPage.homePageIcon).toBeVisible()
await expect(introPage.breadcrumbsLabel('Introduction')).toBeVisible()
await expect(introPage.breadcrumbsLabel('Getting Started')).toBeVisible()
})
20 changes: 20 additions & 0 deletions e2e/pages/IntroductionPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Locator, Page } from '@playwright/test'

export class IntroPage {
readonly page: Page
readonly breadcrumbsLabel: (labelName: string) => Locator
readonly homePageIcon: Locator
readonly pageTitle: Locator

constructor(page: Page) {
this.page = page
this.breadcrumbsLabel = (labelname: string) =>
this.page.getByLabel('Breadcrumbs').getByText(labelname)
this.homePageIcon = this.page.getByLabel('Home page')
this.pageTitle = this.page.getByRole('heading', { name: 'Getting Started with Victory' })
}

async goto() {
await this.page.goto('http://localhost:5855/open-source/victory/docs/introduction/')
}
}
13 changes: 13 additions & 0 deletions e2e/pages/components/FooterArea.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Locator, Page } from '@playwright/test'

export class FooterPage {
readonly page: Page
readonly nearformLogo: Locator
readonly copyrightText: Locator

constructor(page: Page) {
this.page = page
this.nearformLogo = this.page.getByRole('link', { name: 'Nearform logo' })
this.copyrightText = this.page.getByText('Copyright © 2013-2024 Nearform')
}
}
17 changes: 17 additions & 0 deletions e2e/pages/components/HeaderArea.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Locator, Page } from '@playwright/test'

export class HeaderPage {
readonly page: Page
readonly leftSideNavLink: (linkName: string) => Locator
readonly rightSideNavLink: (linkName: string) => Locator
readonly searchInput: Locator

constructor(page: Page) {
this.page = page
this.leftSideNavLink = (linkName: string) =>
this.page.getByRole('link', { name: linkName })
this.rightSideNavLink = (linkName: string) =>
this.page.getByLabel(linkName)
this.searchInput = this.page.getByPlaceholder('Search')
}
}
Loading

0 comments on commit 12b5efe

Please sign in to comment.