Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davikstone2 committed Nov 30, 2023
1 parent 69da793 commit 1066fbb
Show file tree
Hide file tree
Showing 11 changed files with 770 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"reset": " ./compile reset",
"compile": " ./compile recompile",
"old": " webpack --config ./webpack/old/.config.js",
"test": "jest",
"test": "cd tests && npm run test",
"analyze": " --config ./webpack/old/webpack.analyze.js",
"jsdoc": "jsdoc --destination saitolitedocs lib/templates/abstractcryptomodule.js lib/templates/substratebasedcrypto.js lib/saito/wallet.js README.md",
"pretty": "npx prettier --write .",
Expand Down
33 changes: 33 additions & 0 deletions tests/.github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Playwright Tests
on:
push:
branches: [ main, master, feature/e2e-testing ]
pull_request:
branches: [ main, master, feature/e2e-testing]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Install packages
- run: npm install
- name: Deploy node
- run: npm run go
- name: Install Playwright Browsers
run: npx playwright install --with-deps
working-directory: tests
- name: Run Playwright tests
run: npx playwright test
working-directory: tests
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
91 changes: 91 additions & 0 deletions tests/package-lock.json

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

18 changes: 18 additions & 0 deletions tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "saito-e2e",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "npx playwright test",
"show-report": "npx playwright show-report",
"ui": "npx playwright test --ui"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.39.0",
"@types/node": "^20.8.8"
}
}
77 changes: 77 additions & 0 deletions tests/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: './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 : 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:12101',

/* 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' },
// },
],
timeout: 30000,
/* 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,
// },
});
26 changes: 26 additions & 0 deletions tests/src/mods/arcade/arcade_page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {type Page, type Locator, expect} from '@playwright/test'
import ModulePage from "../module_page";

export default class ArcadePage extends ModulePage {

constructor(page: Page) {
super(page, "/arcade");
}

async openChat() {

}

async createChessGame() {
let chessMenuItem = this.page.locator("#Chess");
await chessMenuItem.waitFor();
expect(chessMenuItem).toBeTruthy();
await chessMenuItem.click();

let createGameButton = this.page.locator(".saito-multi-select_btn_options", {hasText: "create public invite"});
await chessMenuItem.waitFor();
expect(createGameButton).toBeTruthy();
await createGameButton.click();
}
}

20 changes: 20 additions & 0 deletions tests/src/mods/module_page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {type Page, type Locator} from '@playwright/test'

export default class ModulePage {
readonly page: Page;
readonly url: string;

constructor(page: Page, url: string) {
this.page = page;
this.url = url;
}

async goto() {
await this.page.goto(this.url);
// TODO : check if this timeout can be removed and start testing when the page is loaded
await this.page.waitForTimeout(1000);

// await this.page.waitForLoadState();
}

}
Loading

0 comments on commit 1066fbb

Please sign in to comment.