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

chore: add initial user stories #603

Closed
wants to merge 1 commit into from
Closed
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
27 changes: 27 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Playwright Tests
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ apps/stock-price-checker-proxy/cache/
apps/twitch-proxy/.data/
apps/twitch-proxy/.logs/
Caddyfile
.eslintcache
.eslintcache
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
56 changes: 56 additions & 0 deletions e2e/25-5-clock.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const { test, expect } = require('@playwright/test');
const fs = require('fs');
const path = require('path');

const portMap = require('../port-map.json');

const name = fs
.readdirSync(path.join(__dirname, '../apps'))
.filter(name => name === '25--5--clock')[0];

const portNum = portMap[name];

test.beforeAll(async ({ browser }) => {
const context = await browser.newContext();
const page = await context.newPage();
await page.goto(`http://localhost:${portNum}`);
global.document = await page.evaluate(() => document);
// Do something before any test suites start
});

test.describe('#Content', () => {
test('I can see an element with id="break-label" that contains a string (e.g. "Break Length").', async ({
page
}) => {
const breakTitle = await page.$('#break-label');
expect((await breakTitle?.innerText())?.length).toBeGreaterThan(0);
});

test('I can see an element with id="session-label" that contains a string (e.g. "Session Length").', async ({
page
}) => {
const sessionTitle = await page.$('#session-label');
expect((await sessionTitle?.innerText())?.length).toBeGreaterThan(0);
});

test('I can see two clickable elements with corresponding IDs: id="break-decrement" and id="session-decrement".', async ({
page
}) => {
expect(await page.$('#break-decrement')).toBeDefined();
expect(await page.$('#session-decrement')).toBeDefined();
});

test('I can see two clickable elements with corresponding IDs: id="break-increment" and id="session-increment".', async ({
page
}) => {
expect(await page.$('#break-increment')).toBeDefined();
expect(await page.$('#session-increment')).toBeDefined();
});

test('I can see an element with a corresponding id="timer-label", that contains a string indicating a session is initialized (e.g. "Session")', async ({
page
}) => {
const timerLabel = await page.$('#timer-label');
expect((await timerLabel?.innerText())?.length).toBeGreaterThan(0);
});
});
78 changes: 74 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
"start": "docker compose up -d",
"stop": "docker compose down",
"prepare": "husky install",
"test": "jest"
"test": "jest",
"playwright:run": "playwright test",
"playwright:watch": "playwright test --ui"
},
"devDependencies": {
"@playwright/test": "^1.45.1",
"@types/jest": "^29.5.10",
"@types/node": "^20.14.10",
"axios": "1.6.0",
"eslint-config-prettier": "8.7.0",
"eslint-plugin-react": "7.34.0",
Expand Down
78 changes: 78 additions & 0 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// @ts-check
const { defineConfig, devices } = require('@playwright/test');

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config({ path: path.resolve(__dirname, '.env') });

/**
* @see https://playwright.dev/docs/test-configuration
*/
module.exports = defineConfig({
testDir: './e2e',
/* Run tests in files in parallel */
fullyParallel: true,
/* 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 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* 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: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry'
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] }
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] }
},

{
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: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});
Loading