From 1ba71c6624a8728f6db88cc8a060a160a56af347 Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Thu, 9 May 2024 20:48:23 +0530 Subject: [PATCH 01/22] setup playwright --- .github/workflows/playwright.yml | 27 +++++++ .gitignore | 4 + e2e-tests/example.spec.ts | 18 +++++ package.json | 1 + playwright.config.ts | 77 +++++++++++++++++++ pnpm-lock.yaml | 128 ++++++++++++++----------------- 6 files changed, 184 insertions(+), 71 deletions(-) create mode 100644 .github/workflows/playwright.yml create mode 100644 e2e-tests/example.spec.ts create mode 100644 playwright.config.ts diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 00000000000..9662b54e97f --- /dev/null +++ b/.github/workflows/playwright.yml @@ -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 install -g pnpm && pnpm install + - name: Install Playwright Browsers + run: pnpm exec playwright install --with-deps + - name: Run Playwright tests + run: pnpm exec playwright test + - uses: actions/upload-artifact@v4 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/.gitignore b/.gitignore index 6feaf48cacb..1fc029f450d 100644 --- a/.gitignore +++ b/.gitignore @@ -157,3 +157,7 @@ Forc.lock .fuel-core/configs/chainConfig.json .fuel-core/configs/metadata.json .fuel-core/configs/stateConfig.json +/test-results/ +/playwright-report/ +/blob-report/ +/playwright/.cache/ diff --git a/e2e-tests/example.spec.ts b/e2e-tests/example.spec.ts new file mode 100644 index 00000000000..54a906a4e84 --- /dev/null +++ b/e2e-tests/example.spec.ts @@ -0,0 +1,18 @@ +import { test, expect } from '@playwright/test'; + +test('has title', async ({ page }) => { + await page.goto('https://playwright.dev/'); + + // Expect a title "to contain" a substring. + await expect(page).toHaveTitle(/Playwright/); +}); + +test('get started link', async ({ page }) => { + await page.goto('https://playwright.dev/'); + + // Click the get started link. + await page.getByRole('link', { name: 'Get started' }).click(); + + // Expects page to have a heading with the name of Installation. + await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); +}); diff --git a/package.json b/package.json index 15e8fd08c88..0f4893c6934 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "@fuel-ts/versions": "workspace:^", "@internal/tsup": "workspace:*", "@istanbuljs/nyc-config-typescript": "^1.0.2", + "@playwright/test": "^1.44.0", "@types/node": "18.15.3", "@types/node-fetch": "^2.6.2", "@types/web": "^0.0.65", diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 00000000000..24d902a8d5a --- /dev/null +++ b/playwright.config.ts @@ -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: './e2e-tests', + /* 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, + // }, +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7db304181df..8afbe42e83d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -47,6 +47,9 @@ importers: '@istanbuljs/nyc-config-typescript': specifier: ^1.0.2 version: 1.0.2(nyc@15.1.0) + '@playwright/test': + specifier: ^1.44.0 + version: 1.44.0 '@types/node': specifier: 18.15.3 version: 18.15.3 @@ -64,7 +67,7 @@ importers: version: 6.9.1(eslint@8.52.0)(typescript@5.2.2) '@vitest/browser': specifier: ^1.6.0 - version: 1.6.0(vitest@1.6.0)(webdriverio@8.36.1(typescript@5.2.2)) + version: 1.6.0(playwright@1.44.0)(vitest@1.6.0)(webdriverio@8.36.1(typescript@5.2.2)) '@vitest/coverage-istanbul': specifier: ^1.6.0 version: 1.6.0(vitest@1.6.0(@types/node@18.15.3)(@vitest/browser@1.6.0)(jsdom@16.7.0)(terser@5.18.2)) @@ -193,7 +196,7 @@ importers: version: link:../../packages/fuels next: specifier: 14.2.2 - version: 14.2.2(@babel/core@7.23.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + version: 14.2.2(@babel/core@7.23.3)(@playwright/test@1.44.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) react: specifier: ^18.2 version: 18.2.0 @@ -266,7 +269,7 @@ importers: version: link:../../packages/fuels next: specifier: 14.2.2 - version: 14.2.2(@babel/core@7.23.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + version: 14.2.2(@babel/core@7.23.3)(@playwright/test@1.44.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) react: specifier: 18.2.0 version: 18.2.0 @@ -404,7 +407,7 @@ importers: version: link:../../packages/fuels next: specifier: 14.2.2 - version: 14.2.2(@babel/core@7.23.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + version: 14.2.2(@babel/core@7.23.3)(@playwright/test@1.44.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) react: specifier: ^18 version: 18.2.0 @@ -1133,7 +1136,7 @@ importers: version: link:../../packages/fuels next: specifier: 14.2.2 - version: 14.2.2(@babel/core@7.23.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + version: 14.2.2(@babel/core@7.23.3)(@playwright/test@1.44.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) react: specifier: ^18.2 version: 18.2.0 @@ -3580,6 +3583,11 @@ packages: resolution: {integrity: sha512-POgTXhjrTfbTV63DiFXav4lBHiICLKKwDeaKn9Nphwj7WH6m0hMMCaJkMyRWjgtPFyRKRVoMXXjczsTQRDEhYw==} engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} + '@playwright/test@1.44.0': + resolution: {integrity: sha512-rNX5lbNidamSUorBhB4XZ9SQTjAqfe5M+p37Z8ic0jPFBMo5iCtQz1kRWkEMg+rYOKSlVycpQmpqjSFq7LXOfg==} + engines: {node: '>=16'} + hasBin: true + '@pmmmwh/react-refresh-webpack-plugin@0.5.10': resolution: {integrity: sha512-j0Ya0hCFZPd4x40qLzbhGsh9TMtdb+CJQiso+WxLOPNasohq9cc5SNUcwsZaRH6++Xh91Xkm/xHCkuIiIu0LUA==} engines: {node: '>= 10.13'} @@ -4810,6 +4818,7 @@ packages: abab@2.0.6: resolution: {integrity: sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==} + deprecated: Use your platform's native atob() and btoa() methods instead abbrev@1.1.1: resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==} @@ -6216,6 +6225,7 @@ packages: domexception@2.0.1: resolution: {integrity: sha512-yxJ2mFy/sibVQlu5qHjOkf9J3K6zgmCxgJ94u2EdvDOV09H+32LtRswEcUsmUWN72pVLOEnTSRaIVVzVQgS0dg==} engines: {node: '>=8'} + deprecated: Use your platform's native DOMException instead domhandler@4.3.1: resolution: {integrity: sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ==} @@ -6415,11 +6425,6 @@ packages: resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} engines: {node: '>=10'} - escodegen@2.0.0: - resolution: {integrity: sha512-mmHKys/C8BFUGI+MAWNcSYoORYLMdPzjrknd2Vc+bUsjN5bXcr8EhrNB+UTqfL1y3I9c4fw2ihgtMPQLBRiQxw==} - engines: {node: '>=6.0'} - hasBin: true - escodegen@2.1.0: resolution: {integrity: sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==} engines: {node: '>=6.0'} @@ -7035,6 +7040,11 @@ packages: fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} + fsevents@2.3.2: + resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -8263,10 +8273,6 @@ packages: resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==} engines: {node: '>=6'} - levn@0.3.0: - resolution: {integrity: sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==} - engines: {node: '>= 0.8.0'} - levn@0.4.1: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} @@ -9085,10 +9091,6 @@ packages: resolution: {integrity: sha512-OS+QTnw1/4vrf+9hh1jc1jnYjzSG4ttTBB8UxOwAnInG3Uo4ssetzC1ihqaIHjLJnA5GGlRl6QlZXOTQhRBUvg==} engines: {node: '>=14.16'} - optionator@0.8.3: - resolution: {integrity: sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==} - engines: {node: '>= 0.8.0'} - optionator@0.9.3: resolution: {integrity: sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==} engines: {node: '>= 0.8.0'} @@ -9402,6 +9404,16 @@ packages: resolution: {integrity: sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA==} engines: {node: '>=8'} + playwright-core@1.44.0: + resolution: {integrity: sha512-ZTbkNpFfYcGWohvTTl+xewITm7EOuqIqex0c7dNZ+aXsbrLj0qI8XlGKfPpipjm0Wny/4Lt4CJsWJk1stVS5qQ==} + engines: {node: '>=16'} + hasBin: true + + playwright@1.44.0: + resolution: {integrity: sha512-F9b3GUCLQ3Nffrfb6dunPOkE5Mh68tR7zN32L4jCk4FjQamgesGay7/dAAe1WaMEGV04DkdJfcJzjoCKygUaRQ==} + engines: {node: '>=16'} + hasBin: true + pluralize@2.0.0: resolution: {integrity: sha512-TqNZzQCD4S42De9IfnnBvILN7HAW7riLqsCyp8lgjXeysyPlX5HhqKAcJHHHb9XskE4/a+7VGC9zzx8Ls0jOAw==} @@ -9866,10 +9878,6 @@ packages: resolution: {integrity: sha512-+wZgbxNES/KlJs9q40F/1sfOd/j7f1O9JaHcW5Dsn3aUUOZg3L2bjpVUcKV2jvtElYfoTuQiNeMfQJ4kwUAhCQ==} engines: {node: '>=10'} - prelude-ls@1.1.2: - resolution: {integrity: sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==} - engines: {node: '>= 0.8.0'} - prelude-ls@1.2.1: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} @@ -11403,10 +11411,6 @@ packages: resolution: {integrity: sha512-qYJ5NjoTX+591/x09KgsDOPVDUJfU9GoS+6jszQQlLp1AHrf1wRFA3Yps8U+/HTG03q0M4qouOfOLtRQP4QypA==} hasBin: true - type-check@0.3.2: - resolution: {integrity: sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==} - engines: {node: '>= 0.8.0'} - type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} @@ -12029,10 +12033,6 @@ packages: engines: {node: '>=8'} hasBin: true - word-wrap@1.2.3: - resolution: {integrity: sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==} - engines: {node: '>=0.10.0'} - wordwrap@1.0.0: resolution: {integrity: sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==} @@ -15007,8 +15007,8 @@ snapshots: '@jridgewell/source-map@0.3.3': dependencies: - '@jridgewell/gen-mapping': 0.3.3 - '@jridgewell/trace-mapping': 0.3.18 + '@jridgewell/gen-mapping': 0.3.5 + '@jridgewell/trace-mapping': 0.3.25 '@jridgewell/sourcemap-codec@1.4.14': {} @@ -15307,6 +15307,10 @@ snapshots: picocolors: 1.0.0 tslib: 2.6.0 + '@playwright/test@1.44.0': + dependencies: + playwright: 1.44.0 + '@pmmmwh/react-refresh-webpack-plugin@0.5.10(react-refresh@0.11.0)(type-fest@3.1.0)(webpack-dev-server@4.15.1(webpack@5.88.0(esbuild@0.17.19)))(webpack@5.88.0(esbuild@0.17.19))': dependencies: ansi-html-community: 0.0.8 @@ -16015,7 +16019,7 @@ snapshots: '@types/eslint@8.40.2': dependencies: - '@types/estree': 1.0.1 + '@types/estree': 1.0.5 '@types/json-schema': 7.0.12 '@types/estree@0.0.39': {} @@ -16560,13 +16564,14 @@ snapshots: vite: 5.2.10(@types/node@20.11.13)(terser@5.18.2) vue: 3.4.15(typescript@5.2.2) - '@vitest/browser@1.6.0(vitest@1.6.0)(webdriverio@8.36.1(typescript@5.2.2))': + '@vitest/browser@1.6.0(playwright@1.44.0)(vitest@1.6.0)(webdriverio@8.36.1(typescript@5.2.2))': dependencies: '@vitest/utils': 1.6.0 magic-string: 0.30.5 sirv: 2.0.4 - vitest: 1.6.0(@types/node@20.11.13)(@vitest/browser@1.6.0)(jsdom@16.7.0)(terser@5.18.2) + vitest: 1.6.0(@types/node@18.15.3)(@vitest/browser@1.6.0)(jsdom@16.7.0)(terser@5.18.2) optionalDependencies: + playwright: 1.44.0 webdriverio: 8.36.1(typescript@5.2.2) '@vitest/coverage-istanbul@1.6.0(vitest@1.6.0(@types/node@18.15.3)(@vitest/browser@1.6.0)(jsdom@16.7.0)(terser@5.18.2))': @@ -18907,15 +18912,6 @@ snapshots: escape-string-regexp@4.0.0: {} - escodegen@2.0.0: - dependencies: - esprima: 4.0.1 - estraverse: 5.3.0 - esutils: 2.0.3 - optionator: 0.8.3 - optionalDependencies: - source-map: 0.6.1 - escodegen@2.1.0: dependencies: esprima: 4.0.1 @@ -19951,6 +19947,9 @@ snapshots: fs.realpath@1.0.0: {} + fsevents@2.3.2: + optional: true + fsevents@2.3.3: optional: true @@ -21389,7 +21388,7 @@ snapshots: data-urls: 2.0.0 decimal.js: 10.4.3 domexception: 2.0.1 - escodegen: 2.0.0 + escodegen: 2.1.0 form-data: 3.0.1 html-encoding-sniffer: 2.0.1 http-proxy-agent: 4.0.1 @@ -21537,11 +21536,6 @@ snapshots: leven@3.1.0: {} - levn@0.3.0: - dependencies: - prelude-ls: 1.1.2 - type-check: 0.3.2 - levn@0.4.1: dependencies: prelude-ls: 1.2.1 @@ -22138,7 +22132,7 @@ snapshots: netmask@2.0.2: {} - next@14.2.2(@babel/core@7.23.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0): + next@14.2.2(@babel/core@7.23.3)(@playwright/test@1.44.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0): dependencies: '@next/env': 14.2.2 '@swc/helpers': 0.5.5 @@ -22159,6 +22153,7 @@ snapshots: '@next/swc-win32-arm64-msvc': 14.2.2 '@next/swc-win32-ia32-msvc': 14.2.2 '@next/swc-win32-x64-msvc': 14.2.2 + '@playwright/test': 1.44.0 transitivePeerDependencies: - '@babel/core' - babel-plugin-macros @@ -22473,15 +22468,6 @@ snapshots: is-inside-container: 1.0.0 is-wsl: 2.2.0 - optionator@0.8.3: - dependencies: - deep-is: 0.1.4 - fast-levenshtein: 2.0.6 - levn: 0.3.0 - prelude-ls: 1.1.2 - type-check: 0.3.2 - word-wrap: 1.2.3 - optionator@0.9.3: dependencies: '@aashutoshrathi/word-wrap': 1.2.6 @@ -22792,6 +22778,14 @@ snapshots: dependencies: find-up: 3.0.0 + playwright-core@1.44.0: {} + + playwright@1.44.0: + dependencies: + playwright-core: 1.44.0 + optionalDependencies: + fsevents: 2.3.2 + pluralize@2.0.0: {} portfinder@1.0.32: @@ -23278,8 +23272,6 @@ snapshots: path-exists: 4.0.0 which-pm: 2.0.0 - prelude-ls@1.1.2: {} - prelude-ls@1.2.1: {} prettier-linter-helpers@1.0.0: @@ -24868,7 +24860,7 @@ snapshots: terser@5.18.2: dependencies: '@jridgewell/source-map': 0.3.3 - acorn: 8.9.0 + acorn: 8.11.3 commander: 2.20.3 source-map-support: 0.5.21 @@ -25227,10 +25219,6 @@ snapshots: turbo-windows-64: 1.8.8 turbo-windows-arm64: 1.8.8 - type-check@0.3.2: - dependencies: - prelude-ls: 1.1.2 - type-check@0.4.0: dependencies: prelude-ls: 1.2.1 @@ -25702,7 +25690,7 @@ snapshots: why-is-node-running: 2.2.2 optionalDependencies: '@types/node': 18.15.3 - '@vitest/browser': 1.6.0(vitest@1.6.0)(webdriverio@8.36.1(typescript@5.2.2)) + '@vitest/browser': 1.6.0(playwright@1.44.0)(vitest@1.6.0)(webdriverio@8.36.1(typescript@5.2.2)) jsdom: 16.7.0 transitivePeerDependencies: - less @@ -25737,7 +25725,7 @@ snapshots: why-is-node-running: 2.2.2 optionalDependencies: '@types/node': 20.11.13 - '@vitest/browser': 1.6.0(vitest@1.6.0)(webdriverio@8.36.1(typescript@5.2.2)) + '@vitest/browser': 1.6.0(playwright@1.44.0)(vitest@1.6.0)(webdriverio@8.36.1(typescript@5.2.2)) jsdom: 16.7.0 transitivePeerDependencies: - less @@ -26078,8 +26066,6 @@ snapshots: siginfo: 2.0.0 stackback: 0.0.2 - word-wrap@1.2.3: {} - wordwrap@1.0.0: {} workbox-background-sync@6.6.0: From 57bb3c644e63bfd24353e4c619aac69b51352ad3 Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Thu, 9 May 2024 21:01:38 +0530 Subject: [PATCH 02/22] modify tests --- .github/workflows/playwright.yml | 39 +++++++++++++++++--------------- e2e-tests/example.spec.ts | 18 +++++++-------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 9662b54e97f..f5faa2fa6e5 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,27 +1,30 @@ name: Playwright Tests on: push: - branches: [ main, master ] + branches: [main, master] pull_request: - branches: [ main, master ] + 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 install -g pnpm && pnpm install - - name: Install Playwright Browsers - run: pnpm exec playwright install --with-deps - - name: Run Playwright tests - run: pnpm exec playwright test - - uses: actions/upload-artifact@v4 - if: always() - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 + - uses: actions/checkout@v4 + - name: CI Setup + uses: ./.github/actions/ci-setup + with: + node-version: ${{ matrix.env.version || 20 }} + - name: Run Fuel Node + run: (cd templates/nextjs && pnpm run fuels:dev) & + - name: Run Next.js server + run: (cd templates/nextjs && pnpm run dev) & + - name: Install Playwright Browsers + run: pnpm exec playwright install --with-deps + - name: Run Playwright tests + run: pnpm exec playwright test + - uses: actions/upload-artifact@v4 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/e2e-tests/example.spec.ts b/e2e-tests/example.spec.ts index 54a906a4e84..c768d4fd110 100644 --- a/e2e-tests/example.spec.ts +++ b/e2e-tests/example.spec.ts @@ -1,18 +1,18 @@ import { test, expect } from '@playwright/test'; test('has title', async ({ page }) => { - await page.goto('https://playwright.dev/'); + await page.goto('http://localhost:3000/'); // Expect a title "to contain" a substring. - await expect(page).toHaveTitle(/Playwright/); + await expect(page).toHaveTitle(/Fuel/); }); -test('get started link', async ({ page }) => { - await page.goto('https://playwright.dev/'); +// test('get started link', async ({ page }) => { +// await page.goto('https://playwright.dev/'); - // Click the get started link. - await page.getByRole('link', { name: 'Get started' }).click(); +// // Click the get started link. +// await page.getByRole('link', { name: 'Get started' }).click(); - // Expects page to have a heading with the name of Installation. - await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); -}); +// // Expects page to have a heading with the name of Installation. +// await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); +// }); From 0f8cfcf35399cf74bce770a3f5b7e28d13f42da6 Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Thu, 9 May 2024 21:12:13 +0530 Subject: [PATCH 03/22] Update example.spec.ts --- e2e-tests/example.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-tests/example.spec.ts b/e2e-tests/example.spec.ts index c768d4fd110..b92ddb4627f 100644 --- a/e2e-tests/example.spec.ts +++ b/e2e-tests/example.spec.ts @@ -3,8 +3,8 @@ import { test, expect } from '@playwright/test'; test('has title', async ({ page }) => { await page.goto('http://localhost:3000/'); - // Expect a title "to contain" a substring. - await expect(page).toHaveTitle(/Fuel/); + const title = page.getByRole('heading', { name: 'Welcome to Fuel' }); + expect(title).toBeVisible(); }); // test('get started link', async ({ page }) => { From 284d1d3946b9d7c8a0b678a962390424fbacaab1 Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Wed, 15 May 2024 04:20:41 +0530 Subject: [PATCH 04/22] update test logic --- e2e-tests/example.spec.ts | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/e2e-tests/example.spec.ts b/e2e-tests/example.spec.ts index b92ddb4627f..ddc2e142ce3 100644 --- a/e2e-tests/example.spec.ts +++ b/e2e-tests/example.spec.ts @@ -1,18 +1,21 @@ import { test, expect } from '@playwright/test'; test('has title', async ({ page }) => { - await page.goto('http://localhost:3000/'); + await page.goto('http://localhost:3000/', { waitUntil: 'networkidle' }); - const title = page.getByRole('heading', { name: 'Welcome to Fuel' }); - expect(title).toBeVisible(); -}); + await page.waitForTimeout(2000); + + const topUpWalletButton = page.getByText('Top-up Wallet'); + await topUpWalletButton.click(); -// test('get started link', async ({ page }) => { -// await page.goto('https://playwright.dev/'); + await page.reload(); -// // Click the get started link. -// await page.getByRole('link', { name: 'Get started' }).click(); + await page.waitForTimeout(2000); -// // Expects page to have a heading with the name of Installation. -// await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); -// }); + const incrementButton = page.getByText('Increment Counter'); + await incrementButton.click(); + + // the counter should be incremented + const counter = page.getByText('1'); + await expect(counter).toBeVisible(); +}); From dda70adecfe5fe3a631ab7b1ef9d99cc5483b198 Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Thu, 16 May 2024 18:14:29 +0530 Subject: [PATCH 05/22] use test-setup instead of ci-setup --- .github/workflows/playwright.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index f5faa2fa6e5..f39f2cb9307 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -10,8 +10,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: CI Setup - uses: ./.github/actions/ci-setup + - name: Build + uses: ./.github/actions/test-setup with: node-version: ${{ matrix.env.version || 20 }} - name: Run Fuel Node From 6b610a537dbaf3fa7a355b0f8c8faa1f13e8469d Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Sun, 19 May 2024 17:08:11 -0700 Subject: [PATCH 06/22] fix test logic --- e2e-tests/example.spec.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/e2e-tests/example.spec.ts b/e2e-tests/example.spec.ts index ddc2e142ce3..a4052958e39 100644 --- a/e2e-tests/example.spec.ts +++ b/e2e-tests/example.spec.ts @@ -1,13 +1,15 @@ import { test, expect } from '@playwright/test'; -test('has title', async ({ page }) => { - await page.goto('http://localhost:3000/', { waitUntil: 'networkidle' }); +test('increment functionality works properly', async ({ page }) => { + await page.goto('http://127.0.0.1:3000/', { waitUntil: 'networkidle' }); await page.waitForTimeout(2000); const topUpWalletButton = page.getByText('Top-up Wallet'); await topUpWalletButton.click(); + await page.waitForTimeout(2000); + await page.reload(); await page.waitForTimeout(2000); @@ -15,7 +17,8 @@ test('has title', async ({ page }) => { const incrementButton = page.getByText('Increment Counter'); await incrementButton.click(); - // the counter should be incremented - const counter = page.getByText('1'); + await page.waitForTimeout(2000); + + const counter = page.getByText('1', { exact: true }); await expect(counter).toBeVisible(); }); From dc0023f2f76661f1595cf7abb38aa538ed1413ce Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Sun, 19 May 2024 17:29:52 -0700 Subject: [PATCH 07/22] add debug html --- e2e-tests/example.spec.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/e2e-tests/example.spec.ts b/e2e-tests/example.spec.ts index a4052958e39..cd44c21973b 100644 --- a/e2e-tests/example.spec.ts +++ b/e2e-tests/example.spec.ts @@ -14,6 +14,9 @@ test('increment functionality works properly', async ({ page }) => { await page.waitForTimeout(2000); + const html = await page.content(); + console.log(html); + const incrementButton = page.getByText('Increment Counter'); await incrementButton.click(); From 16866368a3c88393abaae9f48c0cd57a11ffa9af Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Sun, 19 May 2024 17:37:22 -0700 Subject: [PATCH 08/22] more debug --- e2e-tests/example.spec.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/e2e-tests/example.spec.ts b/e2e-tests/example.spec.ts index cd44c21973b..466f6b800f9 100644 --- a/e2e-tests/example.spec.ts +++ b/e2e-tests/example.spec.ts @@ -14,8 +14,10 @@ test('increment functionality works properly', async ({ page }) => { await page.waitForTimeout(2000); - const html = await page.content(); - console.log(html); + // Fetch the inner HTML of the body tag + const bodyHTML = await page.innerHTML('body'); + // Log the HTML content of the body + console.log(bodyHTML); const incrementButton = page.getByText('Increment Counter'); await incrementButton.click(); From 7f62430f3a3b38899a02943ea11671184819a1d5 Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Sun, 19 May 2024 18:05:07 -0700 Subject: [PATCH 09/22] Update example.spec.ts --- e2e-tests/example.spec.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/e2e-tests/example.spec.ts b/e2e-tests/example.spec.ts index 466f6b800f9..f3fdb8babf0 100644 --- a/e2e-tests/example.spec.ts +++ b/e2e-tests/example.spec.ts @@ -8,6 +8,9 @@ test('increment functionality works properly', async ({ page }) => { const topUpWalletButton = page.getByText('Top-up Wallet'); await topUpWalletButton.click(); + const welcomeToFuelText = page.getByText('Welcome to Fuel'); + await expect(welcomeToFuelText).toBeVisible(); + await page.waitForTimeout(2000); await page.reload(); From 2d439bf4c24c1cc76e1f4f12ec242e553678ff50 Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Mon, 20 May 2024 12:58:11 -0700 Subject: [PATCH 10/22] create .env.local --- .github/workflows/playwright.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index f39f2cb9307..dbefdaa5f0e 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -16,6 +16,8 @@ jobs: node-version: ${{ matrix.env.version || 20 }} - name: Run Fuel Node run: (cd templates/nextjs && pnpm run fuels:dev) & + - name: Copy .env.example and create .env.local off it + run: cp templates/nextjs/.env.example templates/nextjs/.env.local - name: Run Next.js server run: (cd templates/nextjs && pnpm run dev) & - name: Install Playwright Browsers From 5d4ea4913753faa727dfb524dbb1641c1e5e7f80 Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Mon, 20 May 2024 13:05:26 -0700 Subject: [PATCH 11/22] cleanup and changeset --- .changeset/great-teachers-yell.md | 4 ++ .../{example.spec.ts => create-fuels.test.ts} | 5 -- playwright.config.ts | 47 ------------------- 3 files changed, 4 insertions(+), 52 deletions(-) create mode 100644 .changeset/great-teachers-yell.md rename e2e-tests/{example.spec.ts => create-fuels.test.ts} (83%) diff --git a/.changeset/great-teachers-yell.md b/.changeset/great-teachers-yell.md new file mode 100644 index 00000000000..9bdb8c4b2f1 --- /dev/null +++ b/.changeset/great-teachers-yell.md @@ -0,0 +1,4 @@ +--- +--- + +test: add e2e test for the `create fuels` template diff --git a/e2e-tests/example.spec.ts b/e2e-tests/create-fuels.test.ts similarity index 83% rename from e2e-tests/example.spec.ts rename to e2e-tests/create-fuels.test.ts index f3fdb8babf0..b1d8effdc1a 100644 --- a/e2e-tests/example.spec.ts +++ b/e2e-tests/create-fuels.test.ts @@ -17,11 +17,6 @@ test('increment functionality works properly', async ({ page }) => { await page.waitForTimeout(2000); - // Fetch the inner HTML of the body tag - const bodyHTML = await page.innerHTML('body'); - // Log the HTML content of the body - console.log(bodyHTML); - const incrementButton = page.getByText('Increment Counter'); await incrementButton.click(); diff --git a/playwright.config.ts b/playwright.config.ts index 24d902a8d5a..34043fb1089 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,11 +1,5 @@ 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. */ @@ -23,55 +17,14 @@ export default defineConfig({ 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, - // }, }); From c06fa51e789b58adbf5b057d13cebae84fa736f5 Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Mon, 20 May 2024 13:07:14 -0700 Subject: [PATCH 12/22] update changeset --- .changeset/great-teachers-yell.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/great-teachers-yell.md b/.changeset/great-teachers-yell.md index 9bdb8c4b2f1..6792b5d5174 100644 --- a/.changeset/great-teachers-yell.md +++ b/.changeset/great-teachers-yell.md @@ -1,4 +1,4 @@ --- --- -test: add e2e test for the `create fuels` template +feat: add e2e test for the `create fuels` template From 115989587c29b54dc8430a2497a6fc48c385e8fd Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Mon, 20 May 2024 13:17:52 -0700 Subject: [PATCH 13/22] cleanup --- .github/workflows/playwright.yml | 2 +- e2e-tests/create-fuels.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index dbefdaa5f0e..03aa8fe3d60 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,4 +1,4 @@ -name: Playwright Tests +name: create-fuels e2e tests on: push: branches: [main, master] diff --git a/e2e-tests/create-fuels.test.ts b/e2e-tests/create-fuels.test.ts index b1d8effdc1a..2f0844a1f90 100644 --- a/e2e-tests/create-fuels.test.ts +++ b/e2e-tests/create-fuels.test.ts @@ -1,6 +1,6 @@ import { test, expect } from '@playwright/test'; -test('increment functionality works properly', async ({ page }) => { +test('counter contract - increment function call works properly', async ({ page }) => { await page.goto('http://127.0.0.1:3000/', { waitUntil: 'networkidle' }); await page.waitForTimeout(2000); From a2beb721e8dc13e3df6212efa2f46ee4c34fa633 Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Tue, 21 May 2024 21:19:57 +0530 Subject: [PATCH 14/22] remove `main` from branches list Co-authored-by: Peter Smith --- .github/workflows/playwright.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 03aa8fe3d60..02238d5ec30 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,9 +1,9 @@ name: create-fuels e2e tests on: push: - branches: [main, master] + branches: [master] pull_request: - branches: [main, master] + branches: [master] jobs: test: timeout-minutes: 60 From 7b555d17c9f6ba9abbf972a37bf3a28a5553bd76 Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Tue, 21 May 2024 09:18:09 -0700 Subject: [PATCH 15/22] refactor into shell script & rename worflow file --- .github/workflows/create-fuels-e2e.yml | 18 +++++++++++++++ .github/workflows/playwright.yml | 32 -------------------------- scripts/create-fuels-e2e.sh | 5 ++++ 3 files changed, 23 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/create-fuels-e2e.yml delete mode 100644 .github/workflows/playwright.yml create mode 100644 scripts/create-fuels-e2e.sh diff --git a/.github/workflows/create-fuels-e2e.yml b/.github/workflows/create-fuels-e2e.yml new file mode 100644 index 00000000000..e3569568e2c --- /dev/null +++ b/.github/workflows/create-fuels-e2e.yml @@ -0,0 +1,18 @@ +name: create-fuels e2e tests +on: + push: + branches: [master] + pull_request: + branches: [master] +jobs: + test: + timeout-minutes: 10 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build + uses: ./.github/actions/test-setup + with: + node-version: ${{ matrix.env.version || 20 }} + - name: Run e2e tests + run: sh ./scripts/create-fuels-e2e.sh diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml deleted file mode 100644 index 02238d5ec30..00000000000 --- a/.github/workflows/playwright.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: create-fuels e2e tests -on: - push: - branches: [master] - pull_request: - branches: [master] -jobs: - test: - timeout-minutes: 60 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Build - uses: ./.github/actions/test-setup - with: - node-version: ${{ matrix.env.version || 20 }} - - name: Run Fuel Node - run: (cd templates/nextjs && pnpm run fuels:dev) & - - name: Copy .env.example and create .env.local off it - run: cp templates/nextjs/.env.example templates/nextjs/.env.local - - name: Run Next.js server - run: (cd templates/nextjs && pnpm run dev) & - - name: Install Playwright Browsers - run: pnpm exec playwright install --with-deps - - name: Run Playwright tests - run: pnpm exec playwright test - - uses: actions/upload-artifact@v4 - if: always() - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 diff --git a/scripts/create-fuels-e2e.sh b/scripts/create-fuels-e2e.sh new file mode 100644 index 00000000000..7d800fa4966 --- /dev/null +++ b/scripts/create-fuels-e2e.sh @@ -0,0 +1,5 @@ +(cd templates/nextjs && pnpm run fuels:dev) & +cp templates/nextjs/.env.example templates/nextjs/.env.local +(cd templates/nextjs && pnpm run dev) & +pnpm exec playwright install --with-deps +pnpm exec playwright test \ No newline at end of file From 3752cf9c754b51e8aa5ce5919c40189bc66c318a Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Tue, 21 May 2024 09:42:25 -0700 Subject: [PATCH 16/22] move e2e test to `test.yml` file --- .github/workflows/create-fuels-e2e.yml | 18 ------------------ .github/workflows/test.yaml | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 18 deletions(-) delete mode 100644 .github/workflows/create-fuels-e2e.yml diff --git a/.github/workflows/create-fuels-e2e.yml b/.github/workflows/create-fuels-e2e.yml deleted file mode 100644 index e3569568e2c..00000000000 --- a/.github/workflows/create-fuels-e2e.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: create-fuels e2e tests -on: - push: - branches: [master] - pull_request: - branches: [master] -jobs: - test: - timeout-minutes: 10 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Build - uses: ./.github/actions/test-setup - with: - node-version: ${{ matrix.env.version || 20 }} - - name: Run e2e tests - run: sh ./scripts/create-fuels-e2e.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 742b47ea8bd..030ab87d6b7 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -72,6 +72,22 @@ jobs: TEST_WALLET_ADDRESS: ${{ secrets.TEST_WALLET_ADDRESS }} FUEL_TESTNET_NETWORK_URL: ${{ secrets.FUEL_TESTNET_NETWORK_URL }} + create-fuels-e2e: + timeout-minutes: 10 + runs-on: ubuntu-latest + needs: [environments] + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Test Setup + uses: ./.github/actions/test-setup + + - name: Run e2e tests + run: sh ./scripts/create-fuels-e2e.sh + test: if: github.base_ref == 'master' || github.ref_name == 'master' runs-on: ubuntu-latest From c71c4da6635679e24efd90e785b6a8c0a45d0840 Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Tue, 21 May 2024 09:47:53 -0700 Subject: [PATCH 17/22] remove unnecessary `needs` --- .github/workflows/test.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 030ab87d6b7..21d4f62b810 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -75,7 +75,6 @@ jobs: create-fuels-e2e: timeout-minutes: 10 runs-on: ubuntu-latest - needs: [environments] steps: - name: Checkout uses: actions/checkout@v4 From f04a9b1a16cacb36755da4060e2d1bf132206a53 Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Wed, 22 May 2024 00:52:22 +0530 Subject: [PATCH 18/22] change changeset to chore Co-authored-by: Chad Nehemiah --- .changeset/great-teachers-yell.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/great-teachers-yell.md b/.changeset/great-teachers-yell.md index 6792b5d5174..4b0890165ec 100644 --- a/.changeset/great-teachers-yell.md +++ b/.changeset/great-teachers-yell.md @@ -1,4 +1,4 @@ --- --- -feat: add e2e test for the `create fuels` template +chore: add e2e test for the `create fuels` template From ffe34337dafbcbabaa18fdea897e56855e7659e2 Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Wed, 22 May 2024 21:41:01 +0530 Subject: [PATCH 19/22] add #!/bin/bash to sh script Co-authored-by: Peter Smith --- scripts/create-fuels-e2e.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/create-fuels-e2e.sh b/scripts/create-fuels-e2e.sh index 7d800fa4966..5f9fd52e6b5 100644 --- a/scripts/create-fuels-e2e.sh +++ b/scripts/create-fuels-e2e.sh @@ -1,3 +1,5 @@ +#!/bin/bash + (cd templates/nextjs && pnpm run fuels:dev) & cp templates/nextjs/.env.example templates/nextjs/.env.local (cd templates/nextjs && pnpm run dev) & From 0a2fbed676e06784df2f8a8040096c9168d3de14 Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Fri, 24 May 2024 12:05:52 -0700 Subject: [PATCH 20/22] rename e2e -> integration --- .changeset/great-teachers-yell.md | 2 +- .github/workflows/test.yaml | 6 +++--- {e2e-tests => playwright-tests}/create-fuels.test.ts | 0 playwright.config.ts | 2 +- ...te-fuels-e2e.sh => create-fuels-template-integration.sh} | 0 5 files changed, 5 insertions(+), 5 deletions(-) rename {e2e-tests => playwright-tests}/create-fuels.test.ts (100%) rename scripts/{create-fuels-e2e.sh => create-fuels-template-integration.sh} (100%) diff --git a/.changeset/great-teachers-yell.md b/.changeset/great-teachers-yell.md index 4b0890165ec..216ee4239e1 100644 --- a/.changeset/great-teachers-yell.md +++ b/.changeset/great-teachers-yell.md @@ -1,4 +1,4 @@ --- --- -chore: add e2e test for the `create fuels` template +chore: add integration test for the `create fuels` template diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 21d4f62b810..0c9a2400dce 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -72,7 +72,7 @@ jobs: TEST_WALLET_ADDRESS: ${{ secrets.TEST_WALLET_ADDRESS }} FUEL_TESTNET_NETWORK_URL: ${{ secrets.FUEL_TESTNET_NETWORK_URL }} - create-fuels-e2e: + create-fuels-template-integration: timeout-minutes: 10 runs-on: ubuntu-latest steps: @@ -84,8 +84,8 @@ jobs: - name: Test Setup uses: ./.github/actions/test-setup - - name: Run e2e tests - run: sh ./scripts/create-fuels-e2e.sh + - name: Run UI tests + run: sh ./scripts/create-fuels-template-integration.sh test: if: github.base_ref == 'master' || github.ref_name == 'master' diff --git a/e2e-tests/create-fuels.test.ts b/playwright-tests/create-fuels.test.ts similarity index 100% rename from e2e-tests/create-fuels.test.ts rename to playwright-tests/create-fuels.test.ts diff --git a/playwright.config.ts b/playwright.config.ts index 34043fb1089..a5ce6fb9b99 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -4,7 +4,7 @@ import { defineConfig, devices } from '@playwright/test'; * See https://playwright.dev/docs/test-configuration. */ export default defineConfig({ - testDir: './e2e-tests', + testDir: './playwright-tests', /* Run tests in files in parallel */ fullyParallel: true, /* Fail the build on CI if you accidentally left test.only in the source code. */ diff --git a/scripts/create-fuels-e2e.sh b/scripts/create-fuels-template-integration.sh similarity index 100% rename from scripts/create-fuels-e2e.sh rename to scripts/create-fuels-template-integration.sh From 298f82d5bffebd43d72f33aff422771da7adf08a Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Mon, 27 May 2024 11:52:20 -0500 Subject: [PATCH 21/22] increase timeout --- playwright-tests/create-fuels.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playwright-tests/create-fuels.test.ts b/playwright-tests/create-fuels.test.ts index 2f0844a1f90..c3a15847c47 100644 --- a/playwright-tests/create-fuels.test.ts +++ b/playwright-tests/create-fuels.test.ts @@ -15,7 +15,7 @@ test('counter contract - increment function call works properly', async ({ page await page.reload(); - await page.waitForTimeout(2000); + await page.waitForTimeout(5000); const incrementButton = page.getByText('Increment Counter'); await incrementButton.click(); From cf3d6df55563d23b35068a57079efd8b1eafb800 Mon Sep 17 00:00:00 2001 From: Dhaiwat Date: Mon, 27 May 2024 12:12:02 -0500 Subject: [PATCH 22/22] use test-id to locate counter --- playwright-tests/create-fuels.test.ts | 2 +- templates/nextjs/src/pages/index.tsx | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/playwright-tests/create-fuels.test.ts b/playwright-tests/create-fuels.test.ts index c3a15847c47..147c30dfa05 100644 --- a/playwright-tests/create-fuels.test.ts +++ b/playwright-tests/create-fuels.test.ts @@ -22,6 +22,6 @@ test('counter contract - increment function call works properly', async ({ page await page.waitForTimeout(2000); - const counter = page.getByText('1', { exact: true }); + const counter = page.getByTestId('counter'); await expect(counter).toBeVisible(); }); diff --git a/templates/nextjs/src/pages/index.tsx b/templates/nextjs/src/pages/index.tsx index 1a26a38e8a4..75505c0ded7 100644 --- a/templates/nextjs/src/pages/index.tsx +++ b/templates/nextjs/src/pages/index.tsx @@ -82,7 +82,9 @@ export default function Home() { <>

Counter

- {counter} + + {counter} +