-
Notifications
You must be signed in to change notification settings - Fork 21
feat: e2e for gatsby starter #113
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -12,6 +12,8 @@ yarn-error.log | |
| .env.development | ||
| .env.production | ||
|
|
||
| playwright-report/ | ||
|
|
||
| .vercel | ||
|
|
||
| .vscode/ | ||
|
|
||
This file contains hidden or 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 hidden or 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,43 @@ | ||
| # E2E Test Suite | ||
|
|
||
| End-to-end tests for Contentstack Gatsby Starter App using [Playwright](https://playwright.dev/). | ||
|
|
||
| ## Setup | ||
|
|
||
| ```bash | ||
| cd e2e | ||
| npm install | ||
| npx playwright install chromium | ||
| ``` | ||
|
|
||
| ## Run Tests | ||
|
|
||
| ```bash | ||
| # Start Gatsby app first (in another terminal) | ||
| cd contentstack-gatsby-starter-app | ||
| npm run develop | ||
|
|
||
| # Run tests | ||
| cd e2e | ||
| npm test # Headless | ||
| npm run test:headed # With browser | ||
| npm run test:debug # Debug mode | ||
| ``` | ||
|
|
||
| ## Structure | ||
|
|
||
| ``` | ||
| e2e/ | ||
| βββ pages/ # Page Object Models | ||
| βββ tests/ # Test specs | ||
| βββ fixtures/ # Playwright fixtures | ||
| βββ utils/ # Helpers | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| Set `BASE_URL` in `.env.development`: | ||
|
|
||
| ``` | ||
| BASE_URL=http://localhost:8000 | ||
| ``` |
This file contains hidden or 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,2 @@ | ||
| // Base URL for the Gatsby app (development server) | ||
| BASE_URL=http://localhost:8000 |
This file contains hidden or 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 @@ | ||
| export { test, expect, TestFixtures } from './test-fixtures'; |
This file contains hidden or 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,30 @@ | ||
| import { test as base } from '@playwright/test'; | ||
| import { HomePage, AboutPage, BlogPage, BlogPostPage, ContactPage } from '../pages'; | ||
|
|
||
| export interface TestFixtures { | ||
| homePage: HomePage; | ||
| aboutPage: AboutPage; | ||
| blogPage: BlogPage; | ||
| blogPostPage: BlogPostPage; | ||
| contactPage: ContactPage; | ||
| } | ||
|
|
||
| export const test = base.extend<TestFixtures>({ | ||
| homePage: async ({ page }, use) => { | ||
| await use(new HomePage(page)); | ||
| }, | ||
| aboutPage: async ({ page }, use) => { | ||
| await use(new AboutPage(page)); | ||
| }, | ||
| blogPage: async ({ page }, use) => { | ||
| await use(new BlogPage(page)); | ||
| }, | ||
| blogPostPage: async ({ page }, use) => { | ||
| await use(new BlogPostPage(page)); | ||
| }, | ||
| contactPage: async ({ page }, use) => { | ||
| await use(new ContactPage(page)); | ||
| }, | ||
| }); | ||
|
|
||
| export { expect } from '@playwright/test'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 @@ | ||
| { | ||
| "name": "contentstack-gatsby-starter-app-e2e", | ||
| "version": "1.0.0", | ||
| "description": "E2E test suite for Contentstack Gatsby Starter App using Playwright", | ||
| "main": "playwright.config.ts", | ||
| "scripts": { | ||
|
abhishek305 marked this conversation as resolved.
Outdated
|
||
| "test": "playwright test", | ||
| "test:headed": "playwright test --headed", | ||
| "test:headless": "playwright test", | ||
| "test:chromium": "playwright test --project=chromium", | ||
| "test:firefox": "playwright test --project=firefox", | ||
| "test:webkit": "playwright test --project=webkit", | ||
| "test:mobile": "playwright test --project=mobile-chrome --project=mobile-safari", | ||
| "test:debug": "playwright test --debug", | ||
| "test:ui": "playwright test --ui", | ||
| "test:report": "playwright show-report ../playwright-report", | ||
| "test:ci": "CI=true playwright test --project=chromium", | ||
| "install:browsers": "playwright install" | ||
| }, | ||
| "keywords": [ | ||
| "playwright", | ||
| "e2e", | ||
| "testing", | ||
| "contentstack", | ||
| "gatsby", | ||
| "typescript" | ||
| ], | ||
| "author": "Contentstack", | ||
| "license": "MIT", | ||
| "devDependencies": { | ||
| "@playwright/test": "^1.40.0", | ||
| "@types/node": "^20.10.0", | ||
| "dotenv": "^16.3.1", | ||
| "typescript": "^5.3.0" | ||
| } | ||
| } | ||
This file contains hidden or 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,43 @@ | ||
| import { Page } from '@playwright/test'; | ||
| import { BasePage } from './BasePage'; | ||
|
|
||
| interface AboutSelectors { | ||
| heroBanner: string; | ||
| heroTitle: string; | ||
| teamSection: string; | ||
| teamMembers: string; | ||
| } | ||
|
|
||
| export class AboutPage extends BasePage { | ||
| readonly aboutSelectors: AboutSelectors; | ||
|
|
||
| constructor(page: Page) { | ||
| super(page); | ||
| this.aboutSelectors = { | ||
| heroBanner: '.hero-banner', | ||
| heroTitle: '.hero-banner .hero-title', | ||
| teamSection: '.about-team-section', | ||
| teamMembers: '.team-content .team-details', | ||
| }; | ||
| } | ||
|
|
||
| async goto(): Promise<void> { | ||
| await super.goto('/about-us'); | ||
| } | ||
|
|
||
| async isHeroBannerVisible(): Promise<boolean> { | ||
| return await this.page.locator(this.aboutSelectors.heroBanner).isVisible(); | ||
| } | ||
|
|
||
| async getHeroTitle(): Promise<string | null> { | ||
| return await this.page.locator(this.aboutSelectors.heroTitle).textContent(); | ||
| } | ||
|
|
||
| async isTeamSectionVisible(): Promise<boolean> { | ||
| return await this.page.locator(this.aboutSelectors.teamSection).isVisible(); | ||
| } | ||
|
|
||
| async getTeamMembersCount(): Promise<number> { | ||
| return await this.page.locator(this.aboutSelectors.teamMembers).count(); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.