Skip to content

Commit

Permalink
Synpress v4 upgrade - Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-langa committed Nov 4, 2024
1 parent baa4044 commit d783355
Show file tree
Hide file tree
Showing 28 changed files with 703 additions and 361 deletions.
128 changes: 64 additions & 64 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,71 +25,71 @@ jobs:
flags_features: ${{ inputs.flags_features}}
secrets: inherit

# with-wallet-aave-ethereum-tests:
# name: 'With wallet - Aave - Ethereum'
# runs-on: ubuntu-latest
# env:
# TENDERLY_PROJECT: ${{ secrets.TENDERLY_PROJECT }}
# TENDERLY_USER: ${{ secrets.TENDERLY_USER }}
# TENDERLY_ACCESS_KEY: ${{ secrets.TENDERLY_ACCESS_KEY }}
# container:
# image: synthetixio/docker-node:18.16-ubuntu
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version: 18
# - name: Install dependencies
# run: yarn
# - name: Install playwright
# run: npx playwright install && npx playwright install-deps
# - name: Install xvfb
# run: apt-get update -y && apt-get -y install xvfb && rm -rf /var/lib/apt/lists/* /var/cache/apt/*
# - name: Run With wallet Aave Ethereum tests
# run: |
# TENDERLY_PROJECT=${{ secrets.TENDERLY_PROJECT }} \
# TENDERLY_USER=${{ secrets.TENDERLY_USER }} \
# TENDERLY_ACCESS_KEY=${{ secrets.TENDERLY_ACCESS_KEY }} \
# yarn nightly:with-wallet:aave:ethereum
# - uses: actions/upload-artifact@v3
# if: always()
# with:
# name: playwright-report-with-wallet-aave-ethereum
# path: playwright-reports/with-wallet-aave-ethereum
# retention-days: 30
with-wallet-aave-ethereum-tests:
name: 'With wallet - Aave - Ethereum'
runs-on: ubuntu-latest
env:
TENDERLY_PROJECT: ${{ secrets.TENDERLY_PROJECT }}
TENDERLY_USER: ${{ secrets.TENDERLY_USER }}
TENDERLY_ACCESS_KEY: ${{ secrets.TENDERLY_ACCESS_KEY }}
container:
image: synthetixio/docker-node:18.16-ubuntu
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: yarn
- name: Install playwright
run: npx playwright install && npx playwright install-deps
- name: Install xvfb
run: apt-get update -y && apt-get -y install xvfb && rm -rf /var/lib/apt/lists/* /var/cache/apt/*
- name: Run With wallet Aave Ethereum tests
run: |
TENDERLY_PROJECT=${{ secrets.TENDERLY_PROJECT }} \
TENDERLY_USER=${{ secrets.TENDERLY_USER }} \
TENDERLY_ACCESS_KEY=${{ secrets.TENDERLY_ACCESS_KEY }} \
yarn nightly:with-wallet:aave:ethereum
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report-with-wallet-aave-ethereum
path: playwright-reports/with-wallet-aave-ethereum
retention-days: 30

# with-wallet-aave-other-tests:
# name: 'With wallet - Aave - Arbitrum, Optimism & Base'
# runs-on: ubuntu-latest
# env:
# TENDERLY_PROJECT: ${{ secrets.TENDERLY_PROJECT }}
# TENDERLY_USER: ${{ secrets.TENDERLY_USER }}
# TENDERLY_ACCESS_KEY: ${{ secrets.TENDERLY_ACCESS_KEY }}
# container:
# image: synthetixio/docker-node:18.16-ubuntu
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version: 18
# - name: Install dependencies
# run: yarn
# - name: Install playwright
# run: npx playwright install && npx playwright install-deps
# - name: Install xvfb
# run: apt-get update -y && apt-get -y install xvfb && rm -rf /var/lib/apt/lists/* /var/cache/apt/*
# - name: Run With wallet Aave Arbitrum, Optimism and Base tests
# run: |
# TENDERLY_PROJECT=${{ secrets.TENDERLY_PROJECT }} \
# TENDERLY_USER=${{ secrets.TENDERLY_USER }} \
# TENDERLY_ACCESS_KEY=${{ secrets.TENDERLY_ACCESS_KEY }} \
# yarn nightly:with-wallet:aave:other
# - uses: actions/upload-artifact@v3
# if: always()
# with:
# name: playwright-report-with-wallet-aave-other
# path: playwright-reports/with-wallet-aave-other
# retention-days: 30
with-wallet-aave-other-tests:
name: 'With wallet - Aave - Arbitrum, Optimism & Base'
runs-on: ubuntu-latest
env:
TENDERLY_PROJECT: ${{ secrets.TENDERLY_PROJECT }}
TENDERLY_USER: ${{ secrets.TENDERLY_USER }}
TENDERLY_ACCESS_KEY: ${{ secrets.TENDERLY_ACCESS_KEY }}
container:
image: synthetixio/docker-node:18.16-ubuntu
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: yarn
- name: Install playwright
run: npx playwright install && npx playwright install-deps
- name: Install xvfb
run: apt-get update -y && apt-get -y install xvfb && rm -rf /var/lib/apt/lists/* /var/cache/apt/*
- name: Run With wallet Aave Arbitrum, Optimism and Base tests
run: |
TENDERLY_PROJECT=${{ secrets.TENDERLY_PROJECT }} \
TENDERLY_USER=${{ secrets.TENDERLY_USER }} \
TENDERLY_ACCESS_KEY=${{ secrets.TENDERLY_ACCESS_KEY }} \
yarn nightly:with-wallet:aave:other
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report-with-wallet-aave-other
path: playwright-reports/with-wallet-aave-other
retention-days: 30

# with-wallet-ajna-and-morphoblue-tests:
# name: 'With wallet - Ajna & Morpho Blue'
Expand Down
8 changes: 5 additions & 3 deletions tests/sharedTestSteps/positionManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export const openPosition = async ({
if (buttonLabel === `Set ${deposit.token} allowance` || ajnaExistingDpm) {
await app.position.setup.setTokenAllowance(deposit.token);
}

// Setting up allowance randomly fails - Retry until it's set.
await expect(async () => {
await app.position.setup.approveAllowanceOrRetry();
Expand All @@ -108,7 +107,6 @@ export const openPosition = async ({
});
await app.position.setup.continueShouldBeVisible();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.continue();
}

Expand Down Expand Up @@ -458,7 +456,11 @@ export const manageDebtOrCollateral = async ({

// =================
// Recently added for Arbitrum Borrow ETH/USDC
await app.position.setup.confirm();
const manageHeader = app.page.getByText('Manage your ');
const confirmButton = app.page.getByRole('button', { name: 'Confirm' });
if ((await manageHeader.isVisible()) && (await confirmButton.isVisible())) {
await app.position.setup.confirm();
}
// =================

// Position creation randomly fails - Retry until it's created.
Expand Down
189 changes: 189 additions & 0 deletions tests/withWallet/aaveV3/ethereum-old/aaveV3BorrowEthereum.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
import { BrowserContext, test } from '@playwright/test';
import { metamaskSetUp } from 'utils/setup';
import { resetState } from '@synthetixio/synpress/commands/synpress';
import * as tenderly from 'utils/tenderly';
import { setup } from 'utils/setup';
import { extremelyLongTestTimeout, longTestTimeout } from 'utils/config';
import { App } from 'src/app';
import {
close,
manageDebtOrCollateral,
openPosition,
} from 'tests/sharedTestSteps/positionManagement';

let context: BrowserContext;
let app: App;
let forkId: string;
let walletAddress: string;

test.describe.configure({ mode: 'serial' });

test.describe('Aave V3 Borrow - Ethereum - Wallet connected', async () => {
test.afterAll(async () => {
await tenderly.deleteFork(forkId);

await app.page.close();

await context.close();

await resetState();
});

test('It should open an Aave V3 Borrow Ethereum position - WSTETH/USDT @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: '11682',
});

test.setTimeout(extremelyLongTestTimeout);

({ context } = await metamaskSetUp({ network: 'mainnet' }));
let page = await context.newPage();
app = new App(page);

({ forkId, walletAddress } = await setup({ app, network: 'mainnet' }));

await tenderly.setTokenBalance({
forkId,
network: 'mainnet',
walletAddress,
token: 'WSTETH',
balance: '50',
});

await app.page.goto('/ethereum/aave/v3/borrow/WSTETH-USDT#setup');

await openPosition({
app,
forkId,
deposit: { token: 'WSTETH', amount: '7.5' },
borrow: { token: 'USDT', amount: '3000' },
});
});

test('It should Deposit and Borrow in a single tx from an existing Aave V3 Ethereum Borrow position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: 'xxxxx',
});

test.setTimeout(longTestTimeout);

await manageDebtOrCollateral({
app,
forkId,
allowanceNotNeeded: true,
deposit: { token: 'WSTETH', amount: '1.5' },
borrow: { token: 'USDT', amount: '1000' },
expectedCollateralDeposited: {
amount: '9.00',
token: 'WSTETH',
},
expectedDebt: { amount: '4,[0-9]{3}.[0-9]{2}([0-9]{1,2})?', token: 'USDT' },
protocol: 'Aave V3',
});
});

test('It should Withdraw and Pay back in a single tx from an existing Aave V3 Ethereum Borrow position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: 'xxxxx',
});

test.setTimeout(longTestTimeout);

await app.position.manage.withdrawCollateral();

await manageDebtOrCollateral({
app,
forkId,
withdraw: { token: 'WSTETH', amount: '2' },
payBack: { token: 'USDT', amount: '2000' },
expectedCollateralDeposited: {
amount: '7.00',
token: 'WSTETH',
},
expectedDebt: { amount: '2,[0-9]{3}.[0-9]{2}([0-9]{1,2})?', token: 'USDT' },
protocol: 'Aave V3',
});
});

test('It should Borrow and Deposit in a single tx on an existing Aave V3 Ethereum Borrow position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: 'xxxx',
});

test.setTimeout(longTestTimeout);

await app.position.manage.openManageOptions({ currentLabel: 'WSTETH' });
await app.position.manage.select('Manage debt');

await manageDebtOrCollateral({
app,
forkId,
allowanceNotNeeded: true,
borrow: { token: 'USDT', amount: '3000' },
deposit: { token: 'WSTETH', amount: '3' },
expectedCollateralDeposited: {
amount: '10.00',
token: 'WSTETH',
},
expectedDebt: { amount: '5,[0-9]{3}.[0-9]{2}([0-9]{1,2})?', token: 'USDT' },
protocol: 'Aave V3',
});
});

test('It should Pay back and Withdraw in a single tx on an existing Aave V3 Ethereum Borrow position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: 'xxxx',
});

test.setTimeout(longTestTimeout);

// Reload page to avoid random fails
await app.page.reload();

await app.position.manage.openManageOptions({ currentLabel: 'WSTETH' });
await app.position.manage.select('Manage debt');
await app.position.manage.payBackDebt();

await manageDebtOrCollateral({
app,
forkId,
payBack: { token: 'USDT', amount: '4000' },
withdraw: { token: 'WSTETH', amount: '1.5' },
expectedCollateralDeposited: {
amount: '8.50',
token: 'WSTETH',
},
expectedDebt: { amount: '1,[0-9]{3}.[0-9]{2}([0-9]{1,2})?', token: 'USDT' },
protocol: 'Aave V3',
allowanceNotNeeded: true,
});
});

test('It should close an existent Aave V3 Borrow Ethereum position - Close to collateral token (WSTETH)', async () => {
test.info().annotations.push({
type: 'Test case',
description: '12060',
});

test.setTimeout(longTestTimeout);

// Pause and relaod to avoid random fails
await app.page.waitForTimeout(1000);
await app.page.reload();

await close({
forkId,
app,
positionType: 'Borrow',
closeTo: 'collateral',
collateralToken: 'WSTETH',
debtToken: 'USDT',
tokenAmountAfterClosing: '[4-8].[0-9]{3,4}',
});
});
});
Loading

0 comments on commit d783355

Please sign in to comment.