Skip to content

Commit 5aa1502

Browse files
Merge pull request #375 from multiversx/rm/update/add-test-for-template-actions
Added tests for template actions
2 parents 17becd3 + 1694b52 commit 5aa1502

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1938
-14394
lines changed

.github/workflows/night-e2e-workern.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/playwright.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/workflows/pre-merge-e2e-tests.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Playwright E2E Tests
2+
on:
3+
pull_request:
4+
branches: [main]
5+
workflow_dispatch:
6+
jobs:
7+
Slack-Notification:
8+
runs-on: runner-dapp
9+
steps:
10+
- name: Slack Notification
11+
uses: rtCamp/action-slack-notify@master
12+
env:
13+
if: always()
14+
SLACK_ICON_EMOJI: ':robot_face:'
15+
SLACK_USERNAME: Playwright Bot
16+
SLACK_MESSAGE: E2E merge tests are now running. A new notification will be sent when completed.
17+
SLACK_TITLE : 'Playwright E2E Template RUN'
18+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
19+
E2E-RUN:
20+
runs-on: runner-dapp
21+
needs: Slack-Notification
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 22
29+
- name: Setup pnpm
30+
run: npm install -g pnpm
31+
- name: Install Dependencies
32+
uses: nick-fields/retry@v3
33+
with:
34+
timeout_minutes: 120
35+
retry_on: error
36+
max_attempts: 2
37+
command: pnpm install
38+
- name: Install Playwright Browsers
39+
run: pnpm exec playwright install --with-deps
40+
- name: Run Playwright E2E Tests
41+
run: pnpm run run-playwright-test
42+
- name: Upload Playwright test report
43+
uses: actions/upload-artifact@v4
44+
if: ${{ !cancelled() }}
45+
with:
46+
name: playwright-report
47+
path: playwright-report/
48+
retention-days: 1
49+
- name: Slack Success Notification
50+
uses: rtCamp/action-slack-notify@master
51+
if: success()
52+
env:
53+
SLACK_ICON_EMOJI: ':white_check_mark:'
54+
SLACK_USERNAME: Playwright Bot
55+
SLACK_MESSAGE: 'E2E merge Tests completed successfully! All tests passed. 📊 Test Report: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
56+
SLACK_TITLE: 'Playwright E2E Tests - SUCCESS'
57+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
58+
- name: Slack Failure Notification
59+
uses: rtCamp/action-slack-notify@master
60+
if: failure()
61+
env:
62+
SLACK_ICON_EMOJI: ':red_circle:'
63+
SLACK_USERNAME: Playwright Bot
64+
SLACK_MESSAGE: 'E2E merge Tests failed. Please check the logs for details. 📊 Test Report: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
65+
SLACK_TITLE: 'Playwright E2E Tests - FAILED'
66+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
67+
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Playwright E2E Tests
2+
on:
3+
schedule:
4+
- cron: '0 20 * * *'
5+
workflow_dispatch:
6+
jobs:
7+
Slack-Notification:
8+
runs-on: runner-dapp
9+
steps:
10+
- name: Slack Notification
11+
uses: rtCamp/action-slack-notify@master
12+
env:
13+
if: always()
14+
SLACK_ICON_EMOJI: ':robot_face:'
15+
SLACK_USERNAME: Playwright Bot
16+
SLACK_MESSAGE: E2E night tests are now running. A new notification will be sent when completed.
17+
SLACK_TITLE : 'Playwright E2E Template RUN'
18+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
19+
E2E-RUN:
20+
runs-on: runner-dapp
21+
needs: Slack-Notification
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 22
29+
- name: Setup pnpm
30+
run: npm install -g pnpm
31+
- name: Install Dependencies
32+
uses: nick-fields/retry@v3
33+
with:
34+
timeout_minutes: 120
35+
retry_on: error
36+
max_attempts: 2
37+
command: pnpm install
38+
- name: Install Playwright Browsers
39+
run: pnpm exec playwright install --with-deps
40+
- name: Run Playwright E2E Tests
41+
run: pnpm run run-playwright-test
42+
- name: Upload Playwright test report
43+
uses: actions/upload-artifact@v4
44+
if: ${{ !cancelled() }}
45+
with:
46+
name: playwright-report
47+
path: playwright-report/
48+
retention-days: 1
49+
- name: Slack Success Notification
50+
uses: rtCamp/action-slack-notify@master
51+
if: success()
52+
env:
53+
SLACK_ICON_EMOJI: ':white_check_mark:'
54+
SLACK_USERNAME: Playwright Bot
55+
SLACK_MESSAGE: 'E2E Night Tests completed successfully! All tests passed. 📊 Test Report: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
56+
SLACK_TITLE: 'Playwright E2E Tests - SUCCESS'
57+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
58+
- name: Slack Failure Notification
59+
uses: rtCamp/action-slack-notify@master
60+
if: failure()
61+
env:
62+
SLACK_ICON_EMOJI: ':x:'
63+
SLACK_USERNAME: Playwright Bot
64+
SLACK_MESSAGE: 'E2E Night Tests failed. Please check the logs for details. 📊 Test Report: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
65+
SLACK_TITLE: 'Playwright E2E Tests - FAILED'
66+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ node_modules/
3535
/playwright-report/
3636
/blob-report/
3737
/playwright/.cache/
38-
/certificates/
38+
/certificates/
39+
/temps/

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
"copy-devnet-config": "cp ./src/config/config.devnet.ts ./src/config/index.ts",
4040
"copy-testnet-config": "cp ./src/config/config.testnet.ts ./src/config/index.ts",
4141
"copy-mainnet-config": "cp ./src/config/config.mainnet.ts ./src/config/index.ts",
42-
"test": "jest"
42+
"test": "jest",
43+
"run-playwright-test": "playwright test",
44+
"run-playwright-test-ui": "playwright test --ui"
4345
},
4446
"browserslist": [
4547
">0.2%",

playwright.config.ts

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,67 @@
11
import { defineConfig, devices } from '@playwright/test';
22

3+
import { TEST_CONFIG } from './tests/config';
4+
5+
/**
6+
* Read environment variables from file.
7+
* https://github.com/motdotla/dotenv
8+
*/
9+
10+
/**
11+
* See https://playwright.dev/docs/test-configuration.
12+
*/
313
export default defineConfig({
14+
/* timeout for each test */
15+
timeout: TEST_CONFIG.timeout,
16+
/* timeout for locators */
17+
expect: { timeout: TEST_CONFIG.expectTimeout },
18+
/* directory where the tests are located */
419
testDir: './tests',
5-
fullyParallel: true,
20+
/* pattern to match the tests */
21+
testMatch: '**/*.spec.ts',
22+
23+
/* Run tests in files in parallel */
24+
fullyParallel: TEST_CONFIG.fullyParallel,
25+
/* Fail the build on CI if you accidentally left test.only in the source code. */
626
forbidOnly: !!process.env.CI,
7-
timeout: 95000,
8-
retries: process.env.CI ? 5 : 5,
9-
workers: process.env.CI ? 1 : undefined,
27+
/* Retry on CI only */
28+
retries: TEST_CONFIG.retries,
29+
/* Parallel tests on CI only. */
30+
workers: TEST_CONFIG.workers,
31+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
1032
reporter: 'html',
33+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
1134
use: {
35+
/* Base URL to use in actions like `await page.goto('/')`. */
1236
baseURL: 'https://localhost:3000',
1337
ignoreHTTPSErrors: true,
14-
trace: 'on-first-retry'
38+
39+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
40+
trace: 'on-first-retry',
41+
// Default to headless mode; will be overridden by the environment variable
42+
headless: true,
43+
44+
/* Capture screenshot on test failure */
45+
screenshot: 'only-on-failure',
46+
47+
/* Record video on any failure */
48+
video: 'retain-on-failure'
1549
},
1650

51+
/* Configure projects for major browsers */
1752
projects: [
1853
{
19-
name: 'chromium',
20-
use: { ...devices['Desktop Chrome'] }
54+
use: {
55+
...devices['Desktop Chrome'],
56+
launchOptions: {
57+
args: ['--start-maximized']
58+
}
59+
}
2160
}
2261
],
2362
webServer: {
24-
command: 'npm run start-devnet',
63+
command: 'pnpm run start-devnet',
2564
timeout: 120 * 1000,
26-
reuseExistingServer: true
65+
reuseExistingServer: !process.env.CI
2766
}
2867
});

0 commit comments

Comments
 (0)