Skip to content
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

feat: add e2e tests to CI #243

Merged
merged 42 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5238ea6
feat: add test
LuizAsFight Mar 8, 2024
cf8e93d
chore: right abi
LuizAsFight Mar 8, 2024
93e628b
fix: infra
LuizAsFight Mar 14, 2024
c69bcee
chore: remove trash
LuizAsFight Mar 14, 2024
50ebca8
chore: fix last codes
LuizAsFight Mar 14, 2024
6673116
chore
LuizAsFight Mar 14, 2024
dbf580c
chore: fuels/connectors version
LuizAsFight Mar 14, 2024
4ff2a74
fix: update fuels-ts sdk + typings
LuizAsFight Mar 14, 2024
9854625
Merge branch 'main' of github.com:FuelLabs/fuel-explorer into lf/feat…
LuizAsFight Mar 14, 2024
dd8ed08
feat: tests passing
LuizAsFight Mar 18, 2024
24ab8f9
Merge branch 'main' of github.com:FuelLabs/fuel-explorer into lf/feat…
LuizAsFight Mar 18, 2024
85b0164
fix: typing
LuizAsFight Mar 18, 2024
8a50114
feat: self review
LuizAsFight Mar 18, 2024
f06d3bd
chore
LuizAsFight Mar 18, 2024
0d9c719
fix: metamask package
LuizAsFight Mar 18, 2024
fc70f1e
chore: gitignore
LuizAsFight Mar 18, 2024
cf2a01d
fix: package versions
LuizAsFight Mar 19, 2024
70aa35a
feat: add ci e2e-tests
LuizAsFight Mar 20, 2024
2bcd3fb
fix: create env file
LuizAsFight Mar 20, 2024
e936cb4
chore
LuizAsFight Mar 20, 2024
3c4196e
chore: change link
LuizAsFight Mar 20, 2024
5de36ca
chore
LuizAsFight Mar 20, 2024
866158f
chore: revert
LuizAsFight Mar 20, 2024
f4bacee
chore: test if metamask connection is breaking test
LuizAsFight Mar 20, 2024
1fe09ac
chore: track e2e fail
LuizAsFight Mar 20, 2024
5c81025
fix: env files
LuizAsFight Mar 20, 2024
9888ec3
fix: env
LuizAsFight Mar 20, 2024
40c2142
chore: re-enable all tests
LuizAsFight Mar 20, 2024
631e2ed
chore: close context after test
LuizAsFight Mar 20, 2024
a8e5bdb
chore: track e2e
LuizAsFight Mar 20, 2024
2fb073e
chore
LuizAsFight Mar 20, 2024
3c2eb8d
chore: track e2e
LuizAsFight Mar 21, 2024
594b238
fix: connectbutton
LuizAsFight Mar 21, 2024
a7e01de
chore
LuizAsFight Mar 21, 2024
9c91c56
chore
LuizAsFight Mar 21, 2024
8cf67d1
fix: env
LuizAsFight Mar 21, 2024
33aa852
fix
LuizAsFight Mar 21, 2024
9edcd13
chore
LuizAsFight Mar 21, 2024
263e65c
fix: add build to app-portal
LuizAsFight Mar 21, 2024
f982144
Merge branch 'main' of github.com:FuelLabs/fuel-explorer into lf/feat…
LuizAsFight Mar 21, 2024
7ba23ca
fix: add walletconnect only when have id
LuizAsFight Mar 22, 2024
f6c54a7
Merge branch 'main' into lf/feat/add-e2e-to-ci
LuizAsFight Mar 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Tests

on:
pull_request:
branches: [main, master]
types: [opened, synchronize, reopened]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
tests-e2e:
name: E2E Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Create .env file graphql
run: cp packages/graphql/.env.example packages/graphql/.env

- name: Create .env file explorer
run: cp packages/app-explorer/.env.example packages/app-explorer/.env

- name: Setup Node
uses: FuelLabs/github-actions/setups/node@master
with:
node-version: 18.19.0

- name: Setup Docker
uses: FuelLabs/github-actions/setups/docker@master
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Start Test Node
run: pnpm node:start

# E2E tests running with Playwright
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps chromium

- name: Run E2E Tests
run: xvfb-run --auto-servernum -- pnpm test:e2e

- uses: actions/upload-artifact@v2
if: always()
with:
name: playwright-report
path: packages/e2e-tests/playwright-report/
retention-days: 30

- name: Stop Test Node
run: pnpm node:stop
3 changes: 1 addition & 2 deletions packages/app-commons/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ export const NODE_ENV = process.env.NODE_ENV;
export const BLOCK_EXPLORER_URL = process.env.NEXT_PUBLIC_BLOCK_EXPLORER_URL;

export const IS_PREVIEW = process.env.NEXT_PUBLIC_IS_PUBLIC_PREVIEW === 'true';
export const IS_DEVELOPMENT = process.env.DEV;
export const IS_TEST = process.env.MODE === 'test';
export const IS_DEVELOPMENT = process.env.NODE_ENV === 'development';

const ethChainName = ETH_CHAIN_NAME?.toLowerCase();
export const IS_ETH_DEV_CHAIN = ethChainName && ethChainName === 'foundry';
Expand Down
4 changes: 2 additions & 2 deletions packages/app-explorer/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
NEXT_PUBLIC_ALCHEMY_ID=
NEXT_PUBLIC_INFURA_ID=
NEXT_PUBLIC_WALLETCONNECT_ID=
NEXT_PUBLIC_ETH_CHAIN_NAME=sepolia # options: foundry, sepolia
NEXT_PUBLIC_FUEL_CHAIN_NAME=fuelBeta5 # options: fuelDev, fuelBeta5Dev, fuelBeta5
NEXT_PUBLIC_ETH_CHAIN_NAME=foundry # options: foundry, sepolia
NEXT_PUBLIC_FUEL_CHAIN_NAME=fuelDev # options: fuelDev, fuelBeta5Dev, fuelBeta5
NEXT_PUBLIC_FUEL_VERSION=0.22.0
NEXT_PUBLIC_IS_PUBLIC_PREVIEW=true
NEXT_PUBLIC_WALLET_INSTALL=https://chrome.google.com/webstore/detail/fuel-wallet/dldjpboieedgcmpkchcjcbijingjcgok
Expand Down
1 change: 1 addition & 0 deletions packages/app-portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"types": "./src/index.ts",
"scripts": {
"ts:check": "pnpm xstate:typegen && tsc --noEmit",
"build": "pnpm ts:check",
"xstate:typegen": "xstate typegen 'src/**/*.ts?(x)'"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,25 @@ const transports = {
),
};

export const config = createConfig({
chains: chainsToConnect as any,
connectors: [
injected({
shimDisconnect: true,
target: 'metaMask',
}),
coinbaseWallet({ appName: app.name, headlessMode: true }),
const connectors: any = [
injected({
shimDisconnect: true,
target: 'metaMask',
}),
coinbaseWallet({ appName: app.name, headlessMode: true }),
];
if (WALLETCONNECT_ID) {
connectors.push(
walletConnect({
projectId: WALLETCONNECT_ID,
showQrModal: false,
}),
],
);
}

export const config = createConfig({
chains: chainsToConnect as any,
connectors,
transports,
ssr: true,
});
Expand Down
5 changes: 3 additions & 2 deletions packages/e2e-tests/bridge/AssetList.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ import { connectToMetamask } from './utils/wallets';
test.describe('Asset List', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/bridge');

await connectToMetamask(page);
});

test('e2e asset list', async ({ page }) => {
test('e2e asset list', async ({ page, context }) => {
await test.step('Check if ETH is in the dropdown', async () => {
await hasDropdownSymbol(page, 'ETH');
});
Expand Down Expand Up @@ -99,5 +98,7 @@ test.describe('Asset List', () => {

await hasDropdownSymbol(page, 'TKN');
});

await context.close();
});
});
1 change: 0 additions & 1 deletion packages/e2e-tests/bridge/fixtures/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export const test = base.extend<{
});
// Set context to playwright
await use(context);
//await context.close();
},
extensionId: async ({ context }, use) => {
let [background] = context.serviceWorkers();
Expand Down
1 change: 0 additions & 1 deletion packages/e2e-tests/bridge/utils/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const PROVIDER_URL = 'http://localhost:4000/graphql';

export const connectToMetamask = async (page: Page) => {
await page.bringToFront();

const connectKitButton = getByAriaLabel(page, 'Connect Ethereum Wallet');
await connectKitButton.click();
const metamaskConnect = getButtonByText(page, 'Metamask');
Expand Down
7 changes: 4 additions & 3 deletions packages/e2e-tests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ const config: PlaywrightTestConfig = defineConfig({
// Fail the build on CI if left test.only in the source code
forbidOnly: !!process.env.CI,
// Retry tests on CI if they fail
retries: IS_CI ? 2 : 0,
retries: IS_CI ? 0 : 0,
// retries: IS_CI ? 2 : 0,
webServer: {
command: 'pnpm dev',
url: `http://localhost:${PORT}`,
port: Number(PORT),
reuseExistingServer: true,
cwd: join(__dirname, '../../'),
},
use: {
baseURL: `http://localhost:${PORT}/`,
baseURL: `http://127.0.0.1:${PORT}/`,
permissions: ['clipboard-read', 'clipboard-write'],
trace: 'on-first-retry',
headless: false,
Expand Down
Loading
Loading