-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set Up Automated Testing with Playwright (#688)
## Description This PR introduces the foundation for our automated end-to-end (E2E) testing suite using `playwright`. We've implemented initial test scenarios covering critical user flows across three key areas of our application. ### Test Scenarios Implemented: 1. **Legal Pages** - Verify page titles - Confirm page existence 2. **Login Page** - Ensure login page loads correctly - Validate successful login functionality 3. **Create Organization Page** - Test creation with mandatory information only - Test creation with mandatory information and description - Validate handling of missing inputs - Verify responses to incorrect inputs ### Technical Details: - Framework: Playwright - Browsers Tested: Chromium, Firefox ## Type of Change - [x] New feature (non-breaking change which adds functionality) - [x] This change requires a documentation update ## Impact This change lays the groundwork for comprehensive automated testing, which will: - Improve code quality and reliability - Accelerate the development process by catching issues early - Enhance confidence in deployments ## Additional Context Documentation on the testing framework, including how to start the tester locally, add new tests and best practices, will be added to the StreamETH Notion. This will serve as a guide for current and future developers to understand and expand our testing suite.
- Loading branch information
Showing
15 changed files
with
903 additions
and
52 deletions.
There are no files selected for viewing
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
name: Playwright Tests with Dependency and Artifact Caching | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [develop, main] | ||
|
||
jobs: | ||
install: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node 20 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20" | ||
|
||
- name: Install yarn and dependencies | ||
run: | | ||
npm install -g yarn | ||
yarn install | ||
- name: Install Playwright browsers | ||
run: yarn playwright install --with-deps | ||
|
||
- name: Build application | ||
run: yarn build | ||
env: | ||
NEXT_PUBLIC_SPACE_STORAGE_URL: ${{ secrets.NEXT_PUBLIC_SPACE_STORAGE_URL }} | ||
NEXT_PUBLIC_STUDIO_API_KEY: ${{ secrets.NEXT_PUBLIC_STUDIO_API_KEY }} | ||
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }} | ||
NEXT_PUBLIC_PRIVY_ID: ${{ secrets.NEXT_PUBLIC_PRIVY_ID }} | ||
SPACES_KEY: ${{ secrets.SPACES_KEY }} | ||
SPACES_SECRET: ${{ secrets.SPACES_SECRET }} | ||
SPACE_STORAGE_PATH: ${{ secrets.SPACE_STORAGE_PATH }} | ||
|
||
- name: Save .next directory | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: next-artifact | ||
if-no-files-found: error | ||
path: packages/app/.next | ||
|
||
chrome-tests: | ||
needs: install | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node 20 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20" | ||
|
||
- name: Install dependencies | ||
run: | | ||
npm install -g yarn | ||
yarn install | ||
- name: Install Playwright browsers | ||
run: yarn playwright install --with-deps chromium | ||
|
||
- name: Download the build folders | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: next-artifact | ||
path: packages/app/.next | ||
|
||
- name: Run Playwright tests on Chrome | ||
run: | | ||
cd packages/app | ||
yarn playwright test --project=chromium | ||
env: | ||
NEXT_PUBLIC_SPACE_STORAGE_URL: ${{ secrets.NEXT_PUBLIC_SPACE_STORAGE_URL }} | ||
NEXT_PUBLIC_STUDIO_API_KEY: ${{ secrets.NEXT_PUBLIC_STUDIO_API_KEY }} | ||
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }} | ||
NEXT_PUBLIC_PRIVY_ID: ${{ secrets.NEXT_PUBLIC_PRIVY_ID }} | ||
SPACES_KEY: ${{ secrets.SPACES_KEY }} | ||
SPACES_SECRET: ${{ secrets.SPACES_SECRET }} | ||
SPACE_STORAGE_PATH: ${{ secrets.SPACE_STORAGE_PATH }} | ||
PRIVY_EMAIL: ${{ secrets.PRIVY_EMAIL }} | ||
PRIVY_OTP: ${{ secrets.PRIVY_OTP }} | ||
ORG_NAME: test_org | ||
|
||
- name: Upload test results | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: playwright-report-chrome | ||
path: packages/app/playwright-report | ||
retention-days: 30 | ||
|
||
firefox-tests: | ||
needs: install | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node 20 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20" | ||
|
||
- name: Install dependencies | ||
run: | | ||
npm install -g yarn | ||
yarn install | ||
- name: Install Playwright browsers | ||
run: yarn playwright install --with-deps | ||
|
||
- name: Download the build folders | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: next-artifact | ||
path: packages/app/.next | ||
|
||
- name: Run Playwright tests on Firefox | ||
run: | | ||
cd packages/app | ||
yarn playwright test --project=firefox | ||
env: | ||
NEXT_PUBLIC_SPACE_STORAGE_URL: ${{ secrets.NEXT_PUBLIC_SPACE_STORAGE_URL }} | ||
NEXT_PUBLIC_STUDIO_API_KEY: ${{ secrets.NEXT_PUBLIC_STUDIO_API_KEY }} | ||
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }} | ||
NEXT_PUBLIC_PRIVY_ID: ${{ secrets.NEXT_PUBLIC_PRIVY_ID }} | ||
SPACES_KEY: ${{ secrets.SPACES_KEY }} | ||
SPACES_SECRET: ${{ secrets.SPACES_SECRET }} | ||
SPACE_STORAGE_PATH: ${{ secrets.SPACE_STORAGE_PATH }} | ||
PRIVY_EMAIL: ${{ secrets.PRIVY_EMAIL }} | ||
PRIVY_OTP: ${{ secrets.PRIVY_OTP }} | ||
ORG_NAME: test_org | ||
|
||
- name: Upload test results | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: playwright-report-firefox | ||
path: packages/app/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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,10 @@ node_modules | |
|
||
.yarn/* | ||
.yarn | ||
|
||
# testing | ||
/coverage | ||
/playwright | ||
|
||
# next.js | ||
/.next/ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
import path from 'path'; | ||
|
||
require('dotenv').config({path: path.resolve(__dirname, 'test.env')}) | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: './tests', | ||
/* Run tests in files in parallel */ | ||
fullyParallel: false, | ||
/* 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 : 1, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : 2, | ||
/* 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: { | ||
baseURL: 'http://localhost:3000', | ||
trace: 'on-first-retry', | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ name: 'setup', testMatch: /.*\.setup\.ts/ }, | ||
{ | ||
name: 'chromium', | ||
use: { | ||
...devices['Desktop Chrome'], storageState: 'packages/app/playwright/.auth/user.json', | ||
}, | ||
dependencies: ['setup'], | ||
|
||
}, | ||
|
||
{ | ||
name: 'firefox', | ||
use: { | ||
...devices['Desktop Firefox'], storageState: 'packages/app/playwright/.auth/user.json', | ||
}, | ||
dependencies: ['setup'], | ||
}, | ||
|
||
//{ | ||
// name: 'webkit', | ||
// use: { ...devices['Desktop Safari'] }, | ||
//}, | ||
|
||
/* Test against mobile viewports. */ | ||
// { | ||
// name: 'Mobile Chrome', | ||
// use: { ...devices['Pixel 5'] }, | ||
// }, | ||
// { | ||
// name: 'Mobile Safari', | ||
// use: { ...devices['iPhone 12'] }, | ||
// }, | ||
|
||
/* Test against branded browsers. */ | ||
// { | ||
// name: 'Microsoft Edge', | ||
// use: { ...devices['Desktop Edge'], channel: 'msedge' }, | ||
// }, | ||
// { | ||
// name: 'Google Chrome', | ||
// use: { ...devices['Desktop Chrome'], channel: 'chrome' }, | ||
// }, | ||
], | ||
|
||
/* Run your local dev server before starting the tests */ | ||
webServer: { | ||
command: 'yarn start', | ||
url: 'http://127.0.0.1:3000', | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
}) |
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,7 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test('has title', async ({ page }) => { | ||
await page.goto('http://localhost:3000/studio'); | ||
|
||
await expect(page).toHaveTitle(/StreamETH/); | ||
}); |
Oops, something went wrong.