-
Notifications
You must be signed in to change notification settings - Fork 0
Test suite #51
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
Test suite #51
Changes from 94 commits
Commits
Show all changes
107 commits
Select commit
Hold shift + click to select a range
c40b00c
build(deps): add Playwright
coopbri 317427e
build(deps,scripts): add Happy DOM, Bun types, RTL, unit and E2E test…
coopbri bd7e4ce
feature: add bunfig.toml, test setup
coopbri d792e1f
chore(knip): add test config
coopbri 7ac87ad
build(deps,scripts): add 'ms', dedicated Next.js dev script
coopbri 91df514
build(deps): add msw, msw graphql codegen plugin
coopbri 4d486f8
feature(graphql): add MSW plugin
coopbri f2182f8
docs(readme): update instructions for test env vars
coopbri 33cb127
feature: add Playwright config
coopbri 25ffa0e
ci: add test workflow
coopbri 263e9f3
ci(test): set artifact name with shard ID
coopbri c9778d1
ci(test): set artifact path with shard ID
coopbri 71bfc0f
ci(test): correct shard artifacts (use proper job)
coopbri de51ef2
ci(test): resolve invalid character error
coopbri 5018629
ci(test): resolve invalid character error
coopbri 07c76d1
ci(test): iterate over uploaded blob reports for merge
coopbri 2ee3bcd
ci(test): fix merge iteration
coopbri 514bc60
ci(test): fix merge iteration
coopbri 42872ec
ci(test): disable merge job, add discussion TODO
coopbri 57e926e
ci(test): update TODO
coopbri 37ee1b1
test(e2e,auth): add basic auth (sign in) test
coopbri 2d8bed1
ci(test): add test credential env vars
coopbri 3d690a6
chore(test,auth): remove brackets
coopbri e412820
ci(test): add debug flag
coopbri acb5000
docs(env): improve comment
coopbri dce3b6b
ci(test): set Bun setup action version from v1 to v2, remove latest flag
coopbri 747cdbc
test(e2e): add CI test tests
coopbri 363dc13
test(e2e): implement page object model pattern with fixtures
coopbri dd6e488
ci(test): fix Playwright shard execution
coopbri 443c994
test(e2e,auth): remove example tests
coopbri 4c1e514
ci(test): add env vars
coopbri 82e8ee8
ci(test): fix env var access typo
coopbri bf49ef8
ci(test): inject '.env.test' to E2E job
coopbri 5cb89ee
feature(env): add test env var file
coopbri 5564662
build(deps,scripts): create proxy unit test script, add GraphQL Codeg…
coopbri 7e24d30
feature(scripts): add unit test execution script
coopbri a5c1dde
chore(test,playwright): add TODO
coopbri cfc3c7d
test: add mocks
coopbri e215e10
chore(test,e2e,auth): add TODO
coopbri fed8367
docs: add JSDoc
coopbri fc07e13
test(e2e,msw): inject MSW Node.js server instance
coopbri 3145050
chore(knip): update config
coopbri 615ea46
refactor(env): update exports, knip ignores
coopbri 4241b17
docs(graphql): fix typo
coopbri bbea32e
style(feature-card): center content
coopbri 4362235
chore(graphql): update generated artifacts
coopbri ac79f38
Merge branch 'master' into test/suite
coopbri 715cc8f
fix: track graphql.mock.ts artifact
coopbri 8ffbead
ci(test): add debug step
coopbri fa9c9be
refactor(scripts,test): 'zsh' -> 'sh'
coopbri 0b0a32d
test: use zsh
coopbri b0e001d
fix: fix glob expansion for non-zsh shells
coopbri c9aec7a
fix: fix glob expansion for non-zsh shells
coopbri 8c21957
fix: fix glob expansion for non-zsh shells
coopbri c3903b2
test: replace test shell script with package.json script
coopbri e4bbaf8
feature: add MSW browser service worker and config
coopbri 0ec2942
test(mocks): add HIDRA and WalletConnect handlers
coopbri d159b44
chore(e2e,auth): add warning about app router support
coopbri 0c79707
ci(test): remove Playwright debug flag
coopbri 552d7b7
ci(test): conditionally upload test result artifacts
coopbri 6311cd7
ci(test): disable sharding
coopbri 1134cc9
build(deps,scripts): add RTL extensions, fix Bun test pattern match
coopbri fa3191a
test: enhance unit test setup file
coopbri 2f59a98
test: add custom render implementation
coopbri 5ed9f97
test: add theme toggle tests
coopbri b84da4a
ci(test): inject WalletConnect project ID env var to unit test job
coopbri ed1301a
test(theme-toggle): add TODO
coopbri 6eaae4b
test(unit): add more providers to custom 'render'
coopbri 00f0b74
test(msw): initialize MSW fixtures on app start behind feature flag
coopbri 88caf6f
test: add home page (todo), landing page tests
coopbri 37e6c1d
test(mocks): add and inject Next.js app router mocks
coopbri c281384
docs: add JSDoc to test files
coopbri c7a650c
test: add skipped dashboard page test
coopbri 63cc341
docs: add MSW unit test integration reference article
coopbri 9e5e323
docs(handlers,walletconnect): remove trailing slash
coopbri cc12ff7
build(deps): upgrade web3 dependencies
coopbri 43be2ff
chore(graphql): enable shared add plugin in mock artifacts
coopbri 69f3cc0
chore: format
coopbri b16e735
docs(tests,theme-toggle): update TODO
coopbri 891111f
docs(tests,theme-toggle): update TODO
coopbri cb22e26
ci: trigger build
coopbri c6a3e26
chore(knip): update test patterns
coopbri 1ac3e70
docs(readme): remove instructions for test env vars
coopbri 6f443eb
build(scripts): explicitly inject env var files into test scripts
coopbri 9820d01
chore(package): move msw config so it doesn't get lost in the sauce
coopbri 5866668
build(deps): upgrade dependencies
coopbri 3322c7d
Merge branch 'master' into test/suite
coopbri 2a1cc3e
chore: format
coopbri 15550e7
ci(test): remove E2E test artifact upload job
coopbri fae2a2c
chore: update mock user ID env var name
coopbri 615b335
build(deps): add ms DT types
coopbri c770f58
fix(docker): fix build
coopbri 06383c0
build(deps): upgrade knip, typescript
coopbri 563b588
chore(ts): set bun module types explicitly for language server support
coopbri a70788e
chore: remove instances of `BlockchainProvider` in test files
coopbri 296953c
build(deps): remove '@types/bun'
coopbri 1cf2d61
Merge branch 'master' into test/suite
coopbri 0d44e49
Merge branch 'master' into test/suite
coopbri 03dd288
chore: format
coopbri 23624d0
Merge branch 'master' into test/suite
coopbri 0795d27
build(deps): upgrade dependencies
coopbri b7759cf
chore: format
coopbri 04dc5d8
fix: fix build issues
coopbri a68322e
ci: trigger build
coopbri d606562
chore: remove WalletConnect content
coopbri 6b57f4e
chore(playwright): remove unused import
coopbri 014d8ab
ci(test): pin Bun 1.1.42
coopbri 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
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,4 @@ | ||
# https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#test-environment-variables | ||
AUTH_KEYCLOAK_ISSUER="https://hidra.omni.dev/realms/test" | ||
NEXT_PUBLIC_API_BASE_URL="http://127.0.0.1:4000/graphql" | ||
APP_ENV="test" |
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,60 @@ | ||
name: Test 🧪 | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
|
||
jobs: | ||
test_unit: | ||
name: Run unit tests 🃏 | ||
timeout-minutes: 1 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: oven-sh/setup-bun@v2 | ||
# - uses: ArtiomTr/jest-coverage-report-action@v2 | ||
# with: | ||
# package-manager: bun | ||
# test-script: bun test:coverage | ||
# annotations: failed-tests | ||
# TODO replace below with commented job above, blocked by Bun not yet supporting a JSON coverage reporter for the action to consume nor generate (similar: https://github.com/oven-sh/bun/issues/4099) | ||
- name: Install dependencies | ||
run: bun install | ||
- name: Run unit tests | ||
run: bun run test | ||
env: | ||
WALLETCONNECT_PROJECT_ID: ${{ vars.WALLETCONNECT_PROJECT_ID }} | ||
|
||
test_e2e: | ||
name: Run E2E tests 🗺️ | ||
timeout-minutes: 3 | ||
runs-on: ubuntu-latest | ||
# TODO enable, disabled for now while E2E tests are simple. No need to shard early | ||
# strategy: | ||
# fail-fast: false | ||
# shard tests across 4 nodes (https://playwright.dev/docs/test-sharding) | ||
# matrix: | ||
# shard: [1/4, 2/4, 3/4, 4/4] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: oven-sh/setup-bun@v2 | ||
- name: Install dependencies | ||
run: bun install | ||
- name: Install Playwright | ||
run: bunx playwright install --with-deps | ||
- name: Load test environment variables | ||
uses: falti/[email protected] | ||
with: | ||
path: .env.test | ||
- name: Run E2E tests | ||
# TODO enable, disabled for now while E2E tests are simple. No need to shard early | ||
# run: bun test:e2e --shard ${{ matrix.shard }} | ||
run: bun test:e2e | ||
env: | ||
TEST_USERNAME: ${{ secrets.TEST_USERNAME }} | ||
TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }} | ||
WALLETCONNECT_PROJECT_ID: ${{ vars.WALLETCONNECT_PROJECT_ID }} | ||
AUTH_SECRET: ${{ secrets.AUTH_SECRET }} | ||
AUTH_KEYCLOAK_SECRET: ${{ secrets.AUTH_KEYCLOAK_SECRET }} |
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
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
Large diffs are not rendered by default.
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,5 @@ | ||
telemetry = false | ||
|
||
# https://bun.sh/docs/runtime/bunfig#test-runner | ||
[test] | ||
preload = "test/test.setup.ts" |
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
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,115 @@ | ||
import { loadEnvConfig } from "@next/env"; | ||
import { defineConfig, devices } from "@playwright/test"; | ||
import ms from "ms"; | ||
|
||
// import type { | ||
// PlaywrightTestOptions, | ||
// PlaywrightWorkerOptions, | ||
// Project, | ||
// } from "@playwright/test"; | ||
|
||
// TODO use Bun runtime instead of Node.js (pending https://github.com/oven-sh/bun/issues/8222). After this is resolved, consider using Playwright for running all tests including unit tests (see https://pkerschbaum.com/blog/using-playwright-to-run-unit-tests) | ||
|
||
// type PlaywrightDevices = Project< | ||
// PlaywrightTestOptions, | ||
// PlaywrightWorkerOptions | ||
// >; | ||
|
||
// load environment variables (see https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#loading-environment-variables-with-nextenv) | ||
loadEnvConfig(process.cwd()); | ||
|
||
/** | ||
* Desktop devices/viewports. | ||
*/ | ||
// TODO enable desktop viewports (https://linear.app/omnidev/issue/OMNI-156/enable-more-playwright-devices) | ||
// const desktopDevices: PlaywrightDevices[] = [ | ||
// { | ||
// name: "🖥️ Chromium", | ||
// use: { | ||
// ...devices["Desktop Chrome"], | ||
// }, | ||
// }, | ||
// { | ||
// name: "🖥️ Firefox", | ||
// use: { | ||
// ...devices["Desktop Firefox"], | ||
// }, | ||
// }, | ||
|
||
// { | ||
// name: "🖥️ Safari (Webkit)", | ||
// use: { | ||
// ...devices["Desktop Safari"], | ||
// }, | ||
// }, | ||
// { | ||
// name: "🖥️ Microsoft Edge", | ||
// use: { | ||
// channel: "msedge", | ||
// }, | ||
// }, | ||
// ]; | ||
|
||
/** | ||
* Mobile devices/viewports. | ||
*/ | ||
// TODO enable mobile viewports (https://linear.app/omnidev/issue/OMNI-156/enable-more-playwright-devices) | ||
// const mobileDevices: PlaywrightDevices[] = [ | ||
// { | ||
// name: "📱 Chrome", | ||
// use: { | ||
// ...devices["Pixel 5"], | ||
// }, | ||
// }, | ||
// { | ||
// name: "📱 Safari", | ||
// use: devices["iPhone 12"], | ||
// }, | ||
// ]; | ||
|
||
/** | ||
* Playwright configuration. | ||
* @see https://playwright.dev/docs/test-configuration | ||
*/ | ||
const playwrightConfig = defineConfig({ | ||
testDir: "src/__tests__", | ||
// maximum single-test timeout | ||
timeout: ms("3m"), | ||
expect: { | ||
timeout: ms("5s"), | ||
}, | ||
// run tests within the same file in parallel | ||
fullyParallel: true, | ||
// TODO enable more devices than default (https://linear.app/omnidev/issue/OMNI-156/enable-more-playwright-devices) | ||
// projects: [...desktopDevices, ...mobileDevices], | ||
// test output reporter | ||
reporter: process.env.CI | ||
? // blob is used in CI to merge sharded test results (https://playwright.dev/docs/test-reporters#blob-reporter) | ||
"blob" | ||
: [["html", { outputFolder: "src/test/generated/report" }]], | ||
// fail build in CI if `test.only` is left in source code | ||
forbidOnly: !!process.env.CI, | ||
// number of retry attempts on test failure | ||
retries: process.env.CI ? 2 : undefined, | ||
// use single worker to mitigate flakiness from parallel tests. Note that this effectively disables parallelization across test files. See https://playwright.dev/docs/test-parallel#worker-processes | ||
workers: 1, | ||
// artifact output location (screenshots, videos, traces) | ||
outputDir: "src/generated/test-artifacts", | ||
// run dev server before starting the tests | ||
webServer: { | ||
// NB: no need to run GraphQL code generation, so just the Next.js server is started here | ||
command: "bun dev:next", | ||
port: (process.env.PORT as unknown as number) || 3000, | ||
timeout: ms("2m"), | ||
// do not use an existing server on CI | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
use: { | ||
headless: true, | ||
baseURL: process.env.PLAYWRIGHT_TEST_BASE_URL || "http://localhost:3000", | ||
// retry a test with tracing if it is failing (allows analysis of DOM, console logs, network traffic, etc.) | ||
trace: "retry-with-trace", | ||
}, | ||
}); | ||
|
||
export default playwrightConfig; |
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.