-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
15 changed files
with
194 additions
and
81 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
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,52 @@ | ||
import { | ||
Page, | ||
PlaywrightTestArgs, | ||
PlaywrightTestOptions, | ||
test as base, | ||
TestFixture, | ||
} from '@playwright/test'; | ||
import { HomePage } from '@/tests/fixtures/pages/home-page'; | ||
import { AboutPage } from '@/tests/fixtures/pages/about-page'; | ||
import { BlogPage } from '@/tests/fixtures/pages/blog-page'; | ||
import { ContactPage } from '@/tests/fixtures/pages/contact-page'; | ||
import { DefinitionPage } from '@/tests/fixtures/pages/definition-page'; | ||
import { FaqPage } from '@/tests/fixtures/pages/faq-page'; | ||
import { MapPage } from '@/tests/fixtures/pages/map-page'; | ||
import { ToolsAndServicesPage } from '@/tests/fixtures/pages/tools-and-services-page'; | ||
import { UseCasesPage } from '@/tests/fixtures/pages/use-cases-page'; | ||
import { RNBPage } from '@/tests/fixtures/pages/_page'; | ||
|
||
type PagesFixtures = { | ||
aboutPage: AboutPage; | ||
blogPage: BlogPage; | ||
contactPage: ContactPage; | ||
definitionPage: DefinitionPage; | ||
faqPage: FaqPage; | ||
homePage: HomePage; | ||
mapPage: MapPage; | ||
toolsAndServicesPage: ToolsAndServicesPage; | ||
useCasesPage: UseCasesPage; | ||
}; | ||
|
||
const createPageFixture = | ||
<T extends RNBPage>(PageClass: new (page: Page) => T) => | ||
async ( | ||
{ page }: PlaywrightTestArgs & PlaywrightTestOptions, | ||
use: (page: T) => Promise<void>, | ||
) => { | ||
const instance = new PageClass(page); | ||
await instance.goto(); | ||
await use(instance); | ||
}; | ||
|
||
export const test = base.extend<PagesFixtures>({ | ||
aboutPage: createPageFixture(AboutPage), | ||
blogPage: createPageFixture(BlogPage), | ||
contactPage: createPageFixture(ContactPage), | ||
definitionPage: createPageFixture(DefinitionPage), | ||
faqPage: createPageFixture(FaqPage), | ||
homePage: createPageFixture(HomePage), | ||
mapPage: createPageFixture(MapPage), | ||
toolsAndServicesPage: createPageFixture(ToolsAndServicesPage), | ||
useCasesPage: createPageFixture(UseCasesPage), | ||
}); |
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,15 @@ | ||
import { type Page } from '@playwright/test'; | ||
|
||
export abstract class RNBPage { | ||
readonly page: Page; | ||
readonly path: string; | ||
|
||
protected constructor(page: Page, path: string) { | ||
this.page = page; | ||
this.path = path; | ||
} | ||
|
||
async goto() { | ||
await this.page.goto(this.path); | ||
} | ||
} |
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,8 @@ | ||
import { RNBPage } from '@/tests/fixtures/pages/_page'; | ||
import { Page } from '@playwright/test'; | ||
|
||
export class AboutPage extends RNBPage { | ||
constructor(page: Page) { | ||
super(page, '/a-propos'); | ||
} | ||
} |
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,8 @@ | ||
import { RNBPage } from '@/tests/fixtures/pages/_page'; | ||
import { Page } from '@playwright/test'; | ||
|
||
export class BlogPage extends RNBPage { | ||
constructor(page: Page) { | ||
super(page, '/blog'); | ||
} | ||
} |
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,8 @@ | ||
import { RNBPage } from '@/tests/fixtures/pages/_page'; | ||
import { Page } from '@playwright/test'; | ||
|
||
export class ContactPage extends RNBPage { | ||
constructor(page: Page) { | ||
super(page, '/contact'); | ||
} | ||
} |
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,8 @@ | ||
import { RNBPage } from '@/tests/fixtures/pages/_page'; | ||
import { Page } from '@playwright/test'; | ||
|
||
export class DefinitionPage extends RNBPage { | ||
constructor(page: Page) { | ||
super(page, '/definition'); | ||
} | ||
} |
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,8 @@ | ||
import { RNBPage } from '@/tests/fixtures/pages/_page'; | ||
import { Page } from '@playwright/test'; | ||
|
||
export class FaqPage extends RNBPage { | ||
constructor(page: Page) { | ||
super(page, '/faq'); | ||
} | ||
} |
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,36 @@ | ||
import { RNBPage } from '@/tests/fixtures/pages/_page'; | ||
import { Locator, Page } from '@playwright/test'; | ||
|
||
export class HomePage extends RNBPage { | ||
readonly mapButton: Locator; | ||
readonly searchMapField: Locator; | ||
readonly searchMapButton: Locator; | ||
readonly searchMapSuggestions: Locator; | ||
readonly dbsTitle: Locator; | ||
readonly toolsTitle: Locator; | ||
readonly useCasesTitle: Locator; | ||
readonly faqButton: Locator; | ||
readonly newsletterField: Locator; | ||
readonly newsletterButton: Locator; | ||
|
||
constructor(page: Page) { | ||
super(page, '/'); | ||
|
||
this.mapButton = page.locator('a', { | ||
hasText: 'Voir la carte des bâtiments', | ||
}); | ||
this.searchMapField = page.getByPlaceholder(/un identifiant RNB/); | ||
this.searchMapButton = page.locator('.fr-search-bar button[type="submit"]'); | ||
this.searchMapSuggestions = page.locator( | ||
'[class*="addressAutocomplete_autocomplete_suggestions"]', | ||
); | ||
this.dbsTitle = page | ||
.locator('h2') | ||
.getByText('Enrichissez vos bases de données bâtimentaires'); | ||
this.toolsTitle = page.locator('h2').getByText('Outils et services'); | ||
this.useCasesTitle = page.locator('h2').getByText("Cas d'usage"); | ||
this.faqButton = page.getByText('Consulter la Foire aux Questions'); | ||
this.newsletterField = page.getByPlaceholder('Votre adresse email'); | ||
this.newsletterButton = page.locator('[value="S\'inscrire"]'); | ||
} | ||
} |
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,8 @@ | ||
import { RNBPage } from '@/tests/fixtures/pages/_page'; | ||
import { Page } from '@playwright/test'; | ||
|
||
export class MapPage extends RNBPage { | ||
constructor(page: Page) { | ||
super(page, '/map'); | ||
} | ||
} |
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,8 @@ | ||
import { RNBPage } from '@/tests/fixtures/pages/_page'; | ||
import { Page } from '@playwright/test'; | ||
|
||
export class ToolsAndServicesPage extends RNBPage { | ||
constructor(page: Page) { | ||
super(page, '/outils-services'); | ||
} | ||
} |
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,8 @@ | ||
import { RNBPage } from '@/tests/fixtures/pages/_page'; | ||
import { Page } from '@playwright/test'; | ||
|
||
export class UseCasesPage extends RNBPage { | ||
constructor(page: Page) { | ||
super(page, '/cas'); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.