Skip to content

Commit

Permalink
Add Playwright healthchecks
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmyersdev committed Feb 18, 2024
1 parent c1931dc commit 35ac138
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/healthchecks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Production Healthchecks
on:
schedule:
- cron: '*/15 * * * *'
workflow_run:
workflows: [deploy]
types:
- completed
env:
BASE_URL: https://octo.app
jobs:
healthchecks:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: pnpm/action-setup@v2
with:
version: 8
run_install: false
- run: pnpm install --shamefully-hoist
- run: pnpm playwright install --with-deps
- run: pnpm playwright test ./test/e2e/healthchecks
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ test/cypress/videos
!.yarn/releases
!.yarn/sdks
!.yarn/versions
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"@heroicons/vue": "^2.1.1",
"@nuxtjs/tailwindcss": "^6.10.3",
"@pinia/nuxt": "^0.4.11",
"@playwright/test": "^1.41.2",
"@tailwindcss/typography": "^0.5.10",
"@types/culori": "^2.0.4",
"@types/file-saver": "^2.0.7",
Expand Down
77 changes: 77 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { defineConfig, devices } from '@playwright/test'

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './test/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: process.env.BASE_URL,

/* 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,
// },
})
35 changes: 35 additions & 0 deletions pnpm-lock.yaml

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

15 changes: 15 additions & 0 deletions test/e2e/healthchecks/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { expect, test } from '@playwright/test'

test('sets the max-width of the editor to the readability max-width setting', async ({ page }) => {
await page.goto('/docs/new')

await page.waitForLoadState('networkidle')

const inkContainers = await page.locator('.ink-mde-container').all()

expect(inkContainers).toHaveLength(3)

for (const inkContainer of inkContainers) {
await expect(inkContainer).toHaveCSS('max-width', '1000px')
}
})

0 comments on commit 35ac138

Please sign in to comment.