Skip to content

Commit

Permalink
chore: add integration test for the create fuels template (#2278)
Browse files Browse the repository at this point in the history
Co-authored-by: Peter Smith <[email protected]>
Co-authored-by: Sérgio Torres <[email protected]>
Co-authored-by: Chad Nehemiah <[email protected]>
  • Loading branch information
4 people committed May 28, 2024
1 parent 0b53b85 commit ffc62ba
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 72 deletions.
4 changes: 4 additions & 0 deletions .changeset/great-teachers-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

chore: add integration test for the `create fuels` template
15 changes: 15 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@ jobs:
FUEL_TESTNET_NETWORK_URL: ${{ secrets.FUEL_TESTNET_NETWORK_URL }}
PUBLISHED_NPM_VERSION: ${{ steps.release.outputs.published_version }}

create-fuels-template-integration:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Test Setup
uses: ./.github/actions/test-setup

- name: Run UI tests
run: sh ./scripts/create-fuels-template-integration.sh

test:
if: github.base_ref == 'master' || github.ref_name == 'master'
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,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/
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"@fuel-ts/utils": "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",
Expand Down
27 changes: 27 additions & 0 deletions playwright-tests/create-fuels.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { test, expect } from '@playwright/test';

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);

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();

await page.waitForTimeout(5000);

const incrementButton = page.getByText('Increment Counter');
await incrementButton.click();

await page.waitForTimeout(2000);

const counter = page.getByTestId('counter');
await expect(counter).toBeVisible();
});
30 changes: 30 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { defineConfig, devices } from '@playwright/test';

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
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. */
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: {
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
});
Loading

0 comments on commit ffc62ba

Please sign in to comment.