diff --git a/.github/workflows/allTests.yml b/.github/workflows/allTests.yml index da82ded..b605a30 100644 --- a/.github/workflows/allTests.yml +++ b/.github/workflows/allTests.yml @@ -103,7 +103,7 @@ jobs: name: playwright-report-with-wallet-aave-other path: playwright-reports/with-wallet-aave-other retention-days: 30 - with-wallet-ajna-tests: + with-wallet-ajna-and-morphoblue-tests: name: 'With wallet - Ajna' runs-on: ubuntu-latest env: @@ -130,12 +130,12 @@ jobs: TENDERLY_ACCESS_KEY=${{ secrets.TENDERLY_ACCESS_KEY }} \ BASE_URL=${{ inputs.base_url }} \ FLAGS=${{ inputs.flags}} \ - yarn nightly:with-wallet:ajna + yarn nightly:with-wallet:ajna-and-morphoblue - uses: actions/upload-artifact@v3 if: always() with: - name: playwright-report-with-wallet-ajna - path: playwright-reports/with-wallet-ajna + name: playwright-report-with-wallet-ajna-and-morphoblue + path: playwright-reports/with-wallet-ajna-and-morphoblue retention-days: 30 with-wallet-maker-and-spark-tests: name: 'With wallet - Maker & Spark' diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 31f5816..862035f 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -89,7 +89,7 @@ jobs: name: playwright-report-with-wallet-aave-other path: playwright-reports/with-wallet-aave-other retention-days: 30 - with-wallet-ajna-tests: + with-wallet-ajna-and-morphoblue-tests: name: 'With wallet - Ajna' runs-on: ubuntu-latest env: @@ -114,12 +114,13 @@ jobs: TENDERLY_PROJECT=${{ secrets.TENDERLY_PROJECT }} \ TENDERLY_USER=${{ secrets.TENDERLY_USER }} \ TENDERLY_ACCESS_KEY=${{ secrets.TENDERLY_ACCESS_KEY }} \ - yarn nightly:with-wallet:ajna + FLAGS='MorphoBlue:true' \ + yarn nightly:with-wallet:ajna-and-morphoblue - uses: actions/upload-artifact@v3 if: always() with: - name: playwright-report-with-wallet-ajna - path: playwright-reports/with-wallet-ajna + name: playwright-report-with-wallet-ajna-and-morphoblue + path: playwright-reports/with-wallet-ajna-and-morphoblue retention-days: 30 with-wallet-maker-and-spark-tests: name: 'With wallet - Maker & Spark' diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 027b51b..81fed6f 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -103,7 +103,7 @@ jobs: name: playwright-report-with-wallet-aave-other path: playwright-reports/with-wallet-aave-other retention-days: 30 - with-wallet-ajna-tests: + with-wallet-ajna-and-morphoblue-tests: name: 'With wallet - Ajna' runs-on: ubuntu-latest env: @@ -130,12 +130,12 @@ jobs: TENDERLY_ACCESS_KEY=${{ secrets.TENDERLY_ACCESS_KEY }} \ BASE_URL=${{ inputs.base_url }} \ FLAGS=${{ inputs.flags}} \ - yarn ci:with-wallet:ajna:regression + yarn ci:with-wallet:ajna-and-morphoblue:regression - uses: actions/upload-artifact@v3 if: always() with: - name: playwright-report-with-wallet-ajna - path: playwright-reports/with-wallet-ajna + name: playwright-report-with-wallet-ajna-and-morphoblue + path: playwright-reports/with-wallet-ajna-and-morphoblue retention-days: 30 with-wallet-maker-and-spark-tests: diff --git a/package.json b/package.json index 28121fb..c75c00a 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,9 @@ "no-wallet": "REPORT_FOLDER=no-wallet npx playwright test --project=no-wallet", "with-wallet:aave:ethereum": "REPORT_FOLDER=with-wallet-aave-ethereum npx playwright test --project=with-wallet-aave-ethereum --workers=1", "with-wallet:aave:other": "REPORT_FOLDER=with-wallet-aave-other npx playwright test --project=with-wallet-aave-other --workers=1", - "with-wallet:ajna": "REPORT_FOLDER=with-wallet-ajna npx playwright test --project=with-wallet-ajna --workers=1", + "with-wallet:ajna-and-morphoblue": "REPORT_FOLDER=with-wallet-ajna-and-morphoblue npx playwright test --project=with-wallet-ajna-and-morphoblue --workers=1", "with-wallet:maker-and-spark": "REPORT_FOLDER=with-wallet-maker-and-spark npx playwright test --project=with-wallet-maker-and-spark --workers=1", - "with-wallet:all": "yarn with-wallet:aave:ethereum & yarn with-wallet:aave:other & yarn with-wallet:ajna & yarn with-wallet:maker-and-spark", + "with-wallet:all": "yarn with-wallet:aave:ethereum & yarn with-wallet:aave:other & yarn with-wallet:ajna-and-morphoblue & yarn with-wallet:maker-and-spark", "test:e2e": "yarn no-wallet & yarn with-wallet:all", "//-1a": "---------------------------------------------------------------", "//-1b": "---------------------- REGRESSION TESTS -----------------------", @@ -28,9 +28,9 @@ "no-wallet:regression": "REPORT_FOLDER=no-wallet npx playwright test --grep @regression --project=no-wallet", "with-wallet:aave:ethereum:regression": "REPORT_FOLDER=with-wallet-aave-ethereum npx playwright test --grep @regression --project=with-wallet-aave-ethereum --workers=1", "with-wallet:aave:other:regression": "REPORT_FOLDER=with-wallet-aave-other npx playwright test --grep @regression --project=with-wallet-aave-other --workers=1", - "with-wallet:ajna:regression": "REPORT_FOLDER=with-wallet-ajna npx playwright test --grep @regression --project=with-wallet-ajna --workers=1", + "with-wallet:ajna-and-morphoblue:regression": "REPORT_FOLDER=with-wallet-ajna-and-morphoblue npx playwright test --grep @regression --project=with-wallet-ajna-and-morphoblue --workers=1", "with-wallet:maker-and-spark:regression": "REPORT_FOLDER=with-wallet-maker-and-spark npx playwright test --grep @regression --project=with-wallet-maker-and-spark --workers=1", - "with-wallet:all:regression": "yarn with-wallet:aave:ethereum:regression & yarn with-wallet:aave:other:regression & yarn with-wallet:ajna:regression & yarn with-wallet:maker-and-spark:regression", + "with-wallet:all:regression": "yarn with-wallet:aave:ethereum:regression & yarn with-wallet:aave:other:regression & yarn with-wallet:ajna-and-morphoblue:regression & yarn with-wallet:maker-and-spark:regression", "test:e2e:regression": "yarn no-wallet:regression & yarn with-wallet:all:regression", "//-2a": "---------------------------------------------------------------", "//-2b": "---------------------- CI REGRESSION TESTS -----------------------", @@ -38,7 +38,7 @@ "ci:no-wallet:regression": "WORKERS='2' FULLY_PARALLEL='true' RETRIES='2' yarn no-wallet:regression", "ci:with-wallet:aave:ethereum:regression": "xvfb-run yarn with-wallet:aave:ethereum:regression", "ci:with-wallet:aave:other:regression": "xvfb-run yarn with-wallet:aave:other:regression", - "ci:with-wallet:ajna:regression": "xvfb-run yarn with-wallet:ajna:regression", + "ci:with-wallet:ajna-and-morphoblue:regression": "xvfb-run yarn with-wallet:ajna-and-morphoblue:regression", "ci:with-wallet:maker-and-spark:regression": "xvfb-run yarn with-wallet:maker-and-spark:regression", "//-3a": "---------------------------------------------------------------", "//-3b": "---------------------- NIGHTLY TESTS -----------------------", @@ -46,7 +46,7 @@ "nightly:no-wallet": "WORKERS='2' FULLY_PARALLEL='true' RETRIES='2' yarn no-wallet", "nightly:with-wallet:aave:ethereum": "RETRIES='2' xvfb-run yarn with-wallet:aave:ethereum", "nightly:with-wallet:aave:other": "RETRIES='2' xvfb-run yarn with-wallet:aave:other", - "nightly:with-wallet:ajna": "RETRIES='2' xvfb-run yarn with-wallet:ajna", + "nightly:with-wallet:ajna-and-morphoblue": "RETRIES='2' xvfb-run yarn with-wallet:ajna-and-morphoblue", "nightly:with-wallet:maker-and-spark": "RETRIES='2' xvfb-run yarn with-wallet:maker-and-spark", "//-9a": "---------------------------------------------------------------", "//-9b": "---------------------- REPORTS --------------------------------", @@ -54,7 +54,7 @@ "test:report:no-wallet": "npx playwright show-report playwright-reports/no-wallet", "test:report:with-wallet:aave:ethereum": "npx playwright show-report playwright-reports/with-wallet-aave-ethereum", "test:report:with-wallet:aave:other": "npx playwright show-report playwright-reports/with-wallet-aave-other", - "test:report:with-wallet:ajna": "npx playwright show-report playwright-reports/with-wallet-ajna", + "test:report:with-wallet:ajna-and-morphoblue": "npx playwright show-report playwright-reports/with-wallet-ajna-and-morphoblue", "test:report:with-wallet:maker-and-spark": "npx playwright show-report playwright-reports/with-wallet-maker-and-spark", "//-10a": "---------------------------------------------------------------", "//-10b": "---------------------- MANUAL TESTING UTILS --------------------------------", diff --git a/playwright.config.ts b/playwright.config.ts index 8e611ee..09cc21e 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -54,8 +54,8 @@ const defaultConfig: PlaywrightTestConfig = { }, { - name: 'with-wallet-ajna', - testMatch: ['withWallet/ajna/**'], + name: 'with-wallet-ajna-and-morphoblue', + testMatch: ['withWallet/ajna/**', 'withWallet/morphoBlue/**'], use: { ...devices['Desktop Chrome'] }, }, diff --git a/src/pages/position/orderInformation.ts b/src/pages/position/orderInformation.ts index b40e8b7..a2b327e 100644 --- a/src/pages/position/orderInformation.ts +++ b/src/pages/position/orderInformation.ts @@ -153,7 +153,7 @@ export class OrderInformation { }: { current: string; future: string; - protocol?: 'Ajna'; + protocol?: 'Ajna' | 'Morpho Blue'; }) { const regExp = new RegExp(`${current}%${protocol ? '' : ' '}${future}%`); diff --git a/tests/withWallet/morphoBlue/morphoBlueBorrow.spec.ts b/tests/withWallet/morphoBlue/morphoBlueBorrow.spec.ts new file mode 100644 index 0000000..5aa39de --- /dev/null +++ b/tests/withWallet/morphoBlue/morphoBlueBorrow.spec.ts @@ -0,0 +1,192 @@ +import { BrowserContext, test } from '@playwright/test'; +import { expect, metamaskSetUp } from 'utils/setup'; +import { resetState } from '@synthetixio/synpress/commands/synpress'; +import * as metamask from '@synthetixio/synpress/commands/metamask'; +import * as tenderly from 'utils/tenderly'; +import { setup } from 'utils/setup'; +import { extremelyLongTestTimeout, longTestTimeout } from 'utils/config'; +import { App } from 'src/app'; + +let context: BrowserContext; +let app: App; +let forkId: string; +let walletAddress: string; + +test.describe.configure({ mode: 'serial' }); + +test.describe('Morpho Blue Borrow - Wallet connected', async () => { + test.afterAll(async () => { + await tenderly.deleteFork(forkId); + + await app.page.close(); + + await context.close(); + + await resetState(); + }); + + test('It should allow to simulate a Morpho Blue Borrow position before opening it @regression', async () => { + test.info().annotations.push({ + type: 'Test case', + description: 'xxxxxx', + }); + + test.setTimeout(extremelyLongTestTimeout); + + await test.step('Test setup', async () => { + ({ 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: '10', + }); + }); + + await app.page.goto('/ethereum/morphoblue/borrow/WSTETH-ETH#setup'); + + await app.position.setup.deposit({ token: 'WSTETH', amount: '10.12345' }); + + await app.position.overview.shouldHaveCollateralDepositedAfterPill('10.12 WSTETH'); + await app.position.overview.shouldHaveNetValueAfterPill('\\$[0-9]{1,2},[0-9]{3}.[0-9]{2}'); + // !!! BUG: vailableToWithdrawAfterPill showing 0.00 at the moment + // await app.position.overview.shouldHaveAvailableToWithdrawAfterPill({ + // amount: '10.12', + // token: 'WSTETH', + // }); + await app.position.overview.shouldHaveAvailableToBorrowAfterPill({ + amount: '[0-9]{1,2}.[0-9]{2}', + token: 'ETH', + }); + + await app.position.setup.shouldHaveMaxBorrowingAmount({ + token: 'ETH', + amount: '[0-9]{1,2}.[0-9]{2}', + }); + await app.position.setup.orderInformation.shouldHaveCollateralLocked({ + token: 'WSTETH', + current: '0.00', + future: '10.12', + }); + await app.position.setup.orderInformation.shouldHaveMaxLTV({ + current: '[0-9]{2,3}.[0-9]{2}', + future: '[0-9]{2,3}.[0-9]{2}', + }); + // !!! BUG: vailableToWithdrawAfterPill showing 0.00 at the moment + // await app.position.setup.orderInformation.shouldHaveAvailableToWithdraw({ + // token: 'WSTETH', + // current: '0.00', + // future: '10.12', + // }); + await app.position.setup.orderInformation.shouldHaveAvailableToBorrow({ + token: 'ETH', + current: '0.00', + future: '[0-9]{1,2}.[0-9]{2}', + }); + + await app.position.setup.borrow({ token: 'ETH', amount: '8.12345' }); + + await app.position.overview.shouldHaveLiquidationPriceAfterPill('[0-1].[0-9]{3,4} WSTETH/ETH'); + await app.position.overview.shouldHaveLoanToValueAfterPill('[4-9][0-9].[0-9]{1,2}%'); + await app.position.overview.shouldHaveDebtAfterPill({ + amount: '8.1234', + token: 'ETH', + }); + await app.position.overview.shouldHaveNetValueAfterPill('\\$[0-9]{1,2},[0-9]{3}.[0-9]{2}'); + await app.position.overview.shouldHaveAvailableToWithdrawAfterPill({ + amount: '[0-1].[0-9]{3,4}', + token: 'WSTETH', + }); + await app.position.overview.shouldHaveAvailableToBorrowAfterPill({ + amount: '[0-4].[0-9]{3,4}', + token: 'ETH', + }); + + await app.position.orderInformation.shouldHaveLiquidationPrice({ + pair: 'WSTETH/ETH', + current: '0.00', + future: '[0-2].[0-9]{3,4}', + }); + await app.position.orderInformation.shouldHaveLTV({ + protocol: 'Morpho Blue', + current: '0.00', + future: '[1-9][0-9].[0-9]{2}', + }); + await app.position.setup.orderInformation.shouldHaveMaxLTV({ + current: '[0-9]{2,3}.[0-9]{2}', + future: '[0-9]{2,3}.[0-9]{2}', + }); + await app.position.setup.orderInformation.shouldHaveDebt({ + token: 'ETH', + current: '0.00', + future: '8.[0-9]{3,4}', + }); + await app.position.setup.orderInformation.shouldHaveAvailableToWithdraw({ + token: 'WSTETH', + current: '0.00', + future: '[0-5].[0-9]{3,4}', + }); + await app.position.setup.orderInformation.shouldHaveAvailableToBorrow({ + token: 'ETH', + current: '0.00', + future: '[0-5].[0-9]{3,4}', + }); + }); + + test('It should open a Morpho Blue Borrow position @regression', async () => { + test.info().annotations.push({ + type: 'Test case', + description: 'xxx', + }); + + test.setTimeout(extremelyLongTestTimeout); + + await app.page.goto('ethereum/morphoblue/borrow/WSTETH-USDC#setup'); + await app.position.setup.deposit({ token: 'WSTETH', amount: '10' }); + await app.position.setup.borrow({ token: 'USDC', amount: '8000.12' }); + + await app.position.setup.createSmartDeFiAccount(); + + // Smart DeFi Acount creation randomly fails - Retry until it's created. + await expect(async () => { + await app.position.setup.createSmartDeFiAccount(); + await test.step('Metamask: ConfirmAddToken', async () => { + await metamask.confirmAddToken(); + }); + await app.position.setup.continueShouldBeVisible(); + }).toPass({ timeout: longTestTimeout }); + + await app.position.setup.continue(); + + // Setting up allowance randomly fails - Retry until it's set. + await expect(async () => { + await app.position.setup.approveAllowance(); + await test.step('Metamask: ConfirmAddToken', async () => { + await metamask.confirmAddToken(); + }); + await app.position.setup.continueShouldBeVisible(); + }).toPass({ timeout: longTestTimeout }); + + await app.position.setup.continue(); + + // Position creation randomly fails - Retry until it's created. + await expect(async () => { + await app.position.setup.confirmOrRetry(); + await test.step('Metamask: ConfirmPermissionToSpend', async () => { + await metamask.confirmPermissionToSpend(); + }); + await app.position.setup.goToPositionShouldBeVisible(); + }).toPass({ timeout: longTestTimeout }); + + // !!!! BUG: Position is created but UI gets stuck + // await app.position.setup.goToPosition(); + // await app.position.setup.continue(); + // await app.position.manage.shouldBeVisible('Manage your XXX Borrow Position'); + }); +});