From 99cf5fe081548b78a5121e201cd10da55cc07f14 Mon Sep 17 00:00:00 2001 From: KimieTran <34021222+KimieTran@users.noreply.github.com> Date: Tue, 18 Mar 2025 23:54:47 +0700 Subject: [PATCH 1/8] add TC_NITRON_02: Check the colums in the "All Markets" table --- pages/HomePage.page.ts | 7 ++ pages/LendBorrowMintPage.ts | 13 ++++ tests/NitronRevamp/NitronOnKeplrByEK.spec.ts | 78 ++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 pages/LendBorrowMintPage.ts create mode 100644 tests/NitronRevamp/NitronOnKeplrByEK.spec.ts diff --git a/pages/HomePage.page.ts b/pages/HomePage.page.ts index 31220b5..53f8126 100644 --- a/pages/HomePage.page.ts +++ b/pages/HomePage.page.ts @@ -1,4 +1,5 @@ import { expect, type Locator, type Page } from '@playwright/test'; +import { AsyncLocalStorage } from 'async_hooks'; export class HomePage{ readonly page: Page; readonly spotHistory; @@ -12,6 +13,7 @@ export class HomePage{ readonly orderBook; readonly orderPrice; readonly carbonTestnet: Locator + readonly demexTestnet: Locator readonly mantle: Locator readonly addressMetaMaskDropBtn: Locator readonly addressPhantomDropBtn: Locator @@ -23,6 +25,8 @@ export class HomePage{ readonly addressDropBtn: Locator readonly firstCopyClipBoardBtn: Locator readonly withdrawnTab: Locator + readonly earnBtn: Locator + readonly lendBorrowMintItem: Locator constructor (page:Page){ this.page=page; @@ -37,6 +41,7 @@ export class HomePage{ this.orderBook=page.locator('xpath=//p[text()="Order Book"]'); this.orderPrice=page.locator('xpath=//p[text()="Order Price"]'); this.carbonTestnet=this.page.getByRole('paragraph').filter({ hasText: 'Carbon Testnet' }) + this.demexTestnet=this.page.getByRole('paragraph').filter({ hasText: 'Demex Testnet' }) //this.carbonTestnet=this.page.getByRole('paragraph').filter({ hasText: 'Carbon Devnet' }) this.mantle=this.page.getByText('Mantle') this.addressMetaMaskDropBtn = this.page.getByRole('img', { name: 'MetaMask' }) @@ -49,6 +54,8 @@ export class HomePage{ this.addressDropBtn = this.page.locator('svg:nth-child(3)').first() this.firstCopyClipBoardBtn=this.page.locator('div[title="Copy to Clipboard"]').first() this.withdrawnTab=this.page.getByRole('button', { name: 'Withdraw', exact: true }) + this.earnBtn = this.page.getByRole('button', { name: 'Earn' }) + this.lendBorrowMintItem = this.page.getByRole('menuitem', { name: 'Lend, Borrow, Mint Lend and' }) } diff --git a/pages/LendBorrowMintPage.ts b/pages/LendBorrowMintPage.ts new file mode 100644 index 0000000..7bef26f --- /dev/null +++ b/pages/LendBorrowMintPage.ts @@ -0,0 +1,13 @@ +import { type Locator, type Page } from '@playwright/test'; + +export class LendBorrowMintPage{ + readonly page: Page; + readonly headersText: Locator + + constructor (page:Page){ + this.page=page; + this.headersText = this.page.locator('thead th div') + } + + +} \ No newline at end of file diff --git a/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts b/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts new file mode 100644 index 0000000..fbe9e3f --- /dev/null +++ b/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts @@ -0,0 +1,78 @@ +import { test, expect, Page, BrowserContext, chromium } from '@playwright/test' +import { HomePage } from '../../pages/HomePage.page'; +import { TradeTradePage } from '../../pages/TradeTradePage.page'; +import { ConnectWalletPage } from '../../pages/ConnectWalletPage'; +import { EncryptedKeyPage } from '../../pages/EncryptedKeyPage'; +import { LendBorrowMintPage } from '../../pages/LendBorrowMintPage'; + +let page: Page +let browserContext: BrowserContext +const encryptedKeplrKey = "ATkNagk48TArQzAvyB7FfqThoLq2NuXu1naRDqqJCN44hEEKULwJCGj2dHyepgMX1C3yUmknktxw3pJe1Z41zWpbE6SUfHhXvyeptoSgiRBPNpNqgKmmA824QFpP3XURoTDszYYL5MRWs1zoWZnHDjfvWJmTUtxdWBRqTfdiLYcipPKQYzRg1jdqXoAqpt51zydX6TfCTnfxBt61SFxsEgbgbb16w1puk9mGfFiysr9R3PystkTja6sX8AbNW9tMMALKQGHtuCjJCmjuBw9RZTfd4XnSmn1tHYEqTbKaBq6oRLJwyzVnyiqmAcmn2Pg7S2aUvWqwpyYe7KyqAQXVQY7vTjN8JtBBihA4TyWUYGhNimtWYw" +const passworld = 'Abc12345789' + +test.beforeAll('Launch browser context with permission', async () => { + test.setTimeout(120_000) + const browser = await chromium.launch() + browserContext = await browser.newContext() + page = await browserContext.newPage() + + const homePage = new HomePage(page) + await homePage.goToHomePage() + expect(homePage.spotHistory).toBeTruthy(); + await homePage.demexTestnet.click(); + await homePage.mantle.click() + await page.waitForTimeout(10_000) + + const tradePage = new TradeTradePage(page); + await tradePage.headerConnectWallet.click(); + + const connectWalletPage = new ConnectWalletPage(page) + await connectWalletPage.selectWallet.isVisible() + + await connectWalletPage.encryptedKeyBtn.click({ delay: 2000 }) + const encryptedKeyPage = new EncryptedKeyPage(page) + + await encryptedKeyPage.encryptedKeyTextbox.waitFor({ state: 'visible' }) + await encryptedKeyPage.encryptedKeyTextbox.click() + await encryptedKeyPage.encryptedKeyTextbox.fill(encryptedKeplrKey) + await encryptedKeyPage.encryptedKeyTextbox.press('Tab') + await encryptedKeyPage.passwordTextbox.fill(passworld) + await encryptedKeyPage.passwordTextbox.press('Tab') + await encryptedKeyPage.connectBtn.waitFor({ state: 'visible' }) + await encryptedKeyPage.connectBtn.click({ delay: 2000 }) + await encryptedKeyPage.connectBtn.waitFor({ state: 'detached' }) + await homePage.addressDropBtn.waitFor({ state: 'visible' }) + +}) + +test.describe('Nitron on Keplr by Encrypted Key', () => { + test('TC_NITRON_02: Check the colums in the "All Markets" table', async () => { + const homePage = new HomePage(page) + await homePage.earnBtn.click() + await homePage.lendBorrowMintItem.click() + + const lendBorrowMintPage = new LendBorrowMintPage(page) + + const expectedHeaders = [ + 'Asset', + 'Total Lent', + 'Lend APY', + 'Available to Borrow', + 'Borrow APY', + 'In Wallet' + ] + + await page.waitForTimeout(3000) + const headers = await lendBorrowMintPage.headersText.allInnerTexts() + + const actualHeaders: string[] = [] + for (const header of headers) { + if (header.trim() !== '') { + actualHeaders.push(header.trim()) + } + } + expect(actualHeaders).toEqual(expectedHeaders) + + }) + +}) \ No newline at end of file From c88a181c7de5d4456ef56f0a89b96f5a02eafeba Mon Sep 17 00:00:00 2001 From: KimieTran <34021222+KimieTran@users.noreply.github.com> Date: Fri, 21 Mar 2025 07:38:48 +0700 Subject: [PATCH 2/8] add TC_NITRON_02, TC_NITRON_05 for Nitron test cases --- pages/LendBorrowMintPage.ts | 15 +++++++++ tests/NitronRevamp/NitronOnKeplrByEK.spec.ts | 33 ++++++++++++++++++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/pages/LendBorrowMintPage.ts b/pages/LendBorrowMintPage.ts index 7bef26f..ac4c7a9 100644 --- a/pages/LendBorrowMintPage.ts +++ b/pages/LendBorrowMintPage.ts @@ -3,10 +3,25 @@ import { type Locator, type Page } from '@playwright/test'; export class LendBorrowMintPage{ readonly page: Page; readonly headersText: Locator + readonly howItWorkBtn: Locator + readonly step1Logo: Locator + readonly step2Logo: Locator + readonly step3Logo: Locator + readonly step4Logo: Locator + readonly learnMoreLink: Locator + readonly xBtn: Locator constructor (page:Page){ this.page=page; this.headersText = this.page.locator('thead th div') + this.howItWorkBtn = this.page.getByRole('button', { name: 'How it works' }) + this.step1Logo = this.page.getByRole('img', { name: 'step1' }) + this.step1Logo = this.page.getByRole('img', { name: 'step2' }) + this.step1Logo = this.page.getByRole('img', { name: 'step3' }) + this.step1Logo = this.page.getByRole('img', { name: 'step4' }) + this.learnMoreLink = this.page.locator('div').filter({ hasText: /^Learn More$/ }).getByRole('link') + this.xBtn = this.page.locator("div:has-text('How Nitron Works') + button") + } diff --git a/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts b/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts index fbe9e3f..6c84a57 100644 --- a/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts +++ b/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts @@ -19,8 +19,8 @@ test.beforeAll('Launch browser context with permission', async () => { const homePage = new HomePage(page) await homePage.goToHomePage() expect(homePage.spotHistory).toBeTruthy(); - await homePage.demexTestnet.click(); - await homePage.mantle.click() + //await homePage.demexTestnet.click(); + //await homePage.mantle.click() await page.waitForTimeout(10_000) const tradePage = new TradeTradePage(page); @@ -75,4 +75,33 @@ test.describe('Nitron on Keplr by Encrypted Key', () => { }) + test('TC_NITRON_05: Check the link "How it Works"', async () => { + await page.reload() + await page.waitForLoadState() + + const lendBorrowMintPage = new LendBorrowMintPage(page) + await lendBorrowMintPage.howItWorkBtn.click() + await lendBorrowMintPage.xBtn.waitFor({ state: 'visible' }) + await expect(lendBorrowMintPage.xBtn).toBeVisible() + + await lendBorrowMintPage.xBtn.click() + await expect(lendBorrowMintPage.xBtn).toBeDisabled() + + }) + + test('TC_NITRON_06: Chek the components of the "Hown it Works" drop down', async () => { + await page.reload() + await page.waitForLoadState() + + const lendBorrowMintPage = new LendBorrowMintPage(page) + await lendBorrowMintPage.howItWorkBtn.click() + + await expect(lendBorrowMintPage.step1Logo).toBeVisible() + await expect(lendBorrowMintPage.step2Logo).toBeVisible() + await expect(lendBorrowMintPage.step3Logo).toBeVisible() + await expect(lendBorrowMintPage.step4Logo).toBeVisible() + await expect(lendBorrowMintPage.learnMoreLink).toBeVisible() + + }) + }) \ No newline at end of file From 45d04bd3cdea22a7d03c0fce1e197bffb383ecbf Mon Sep 17 00:00:00 2001 From: KimieTran <34021222+KimieTran@users.noreply.github.com> Date: Tue, 25 Mar 2025 00:09:23 +0700 Subject: [PATCH 3/8] add TC_NITRON_15 Verify that the Lending and Borrowing pages are separated into different pages --- .github/workflows/playwright.yml | 4 +- pages/LendBorrowMintPage.ts | 13 +++-- pages/TradeTradePage.page.ts | 3 +- tests/NitronRevamp/NitronOnKeplrByEK.spec.ts | 49 ++++++++++++++++++- tests/TradingToken/TradingOnKeplrByEK.spec.ts | 4 +- tests/TradingToken/TradingOnLeapByEK.spec.ts | 4 +- .../TradingOnMetaMaskByEK.spec.ts | 4 +- tests/TradingToken/TradingOnPhantom.spec.ts | 7 +-- 8 files changed, 71 insertions(+), 17 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index b91bb10..34e7b30 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,9 +1,9 @@ name: Playwright Tests on: push: - branches: [ main, master, feature/trading-v2 ] + branches: [ main, master, feature/nitron-revamp ] pull_request: - branches: [ main, master, feature/trading-v2 ] + branches: [ main, master, feature/nitron-revamp ] jobs: test: timeout-minutes: 60 diff --git a/pages/LendBorrowMintPage.ts b/pages/LendBorrowMintPage.ts index ac4c7a9..602db6a 100644 --- a/pages/LendBorrowMintPage.ts +++ b/pages/LendBorrowMintPage.ts @@ -10,18 +10,23 @@ export class LendBorrowMintPage{ readonly step4Logo: Locator readonly learnMoreLink: Locator readonly xBtn: Locator + readonly yourPositionsItem: Locator + readonly lendingTab: Locator + readonly borrowingTab: Locator constructor (page:Page){ this.page=page; this.headersText = this.page.locator('thead th div') this.howItWorkBtn = this.page.getByRole('button', { name: 'How it works' }) this.step1Logo = this.page.getByRole('img', { name: 'step1' }) - this.step1Logo = this.page.getByRole('img', { name: 'step2' }) - this.step1Logo = this.page.getByRole('img', { name: 'step3' }) - this.step1Logo = this.page.getByRole('img', { name: 'step4' }) + this.step2Logo = this.page.getByRole('img', { name: 'step2' }) + this.step3Logo = this.page.getByRole('img', { name: 'step3' }) + this.step4Logo = this.page.getByRole('img', { name: 'step4' }) this.learnMoreLink = this.page.locator('div').filter({ hasText: /^Learn More$/ }).getByRole('link') this.xBtn = this.page.locator("div:has-text('How Nitron Works') + button") - + this.yourPositionsItem = this.page.locator('div').filter({ hasText: /^Your Positions$/ }).nth(1) + this.lendingTab = this.page.getByRole('button', { name: 'Lending' }) + this.borrowingTab = this.page.getByRole('button', { name: 'Borrowing' }) } diff --git a/pages/TradeTradePage.page.ts b/pages/TradeTradePage.page.ts index 9bd402b..81299df 100644 --- a/pages/TradeTradePage.page.ts +++ b/pages/TradeTradePage.page.ts @@ -43,7 +43,8 @@ export class TradeTradePage{ this.marketBtn = this.page.getByRole('button', { name: 'Market', exact: true }) this.tradeExecutedPopup = this.page.getByText('Trade Executed', { exact: true }) this.priceOrderTextBox = this.page.locator('form div').filter({ hasText: 'MidUSD' }).nth(2) - this.priceForm = this.page.locator('#priceFormField') + //this.priceForm = this.page.locator('#priceFormField') + this.priceForm = this.page.getByRole('spinbutton').first() } async goToTradePage(){ diff --git a/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts b/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts index 6c84a57..5c8a56a 100644 --- a/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts +++ b/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts @@ -42,6 +42,7 @@ test.beforeAll('Launch browser context with permission', async () => { await encryptedKeyPage.connectBtn.click({ delay: 2000 }) await encryptedKeyPage.connectBtn.waitFor({ state: 'detached' }) await homePage.addressDropBtn.waitFor({ state: 'visible' }) + await page.pause() }) @@ -85,7 +86,7 @@ test.describe('Nitron on Keplr by Encrypted Key', () => { await expect(lendBorrowMintPage.xBtn).toBeVisible() await lendBorrowMintPage.xBtn.click() - await expect(lendBorrowMintPage.xBtn).toBeDisabled() + await expect(lendBorrowMintPage.xBtn).not.toBeVisible() }) @@ -104,4 +105,50 @@ test.describe('Nitron on Keplr by Encrypted Key', () => { }) + test('TC_NITRON_15: Verify that the Lending and Borrowing pages are separated into different pages', async () => { + await page.reload() + await page.waitForLoadState() + + const lendBorrowMintPage = new LendBorrowMintPage(page) + await lendBorrowMintPage.yourPositionsItem.click() + await lendBorrowMintPage.lendingTab.click() + + const expectedLendingHeaders = [ + 'Asset', + 'Amount', + 'Collateral', + 'Lend APY' + ] + + await page.waitForTimeout(3000) + const lendingHeaders = await lendBorrowMintPage.headersText.allInnerTexts() + + const actualLendingHeaders: string[] = [] + for (const header of lendingHeaders) { + if (header.trim() !== '') { + actualLendingHeaders.push(header.trim()) + } + } + expect(actualLendingHeaders).toEqual(expectedLendingHeaders) + + await lendBorrowMintPage.borrowingTab.click() + const expectedBorrowingHeaders = [ + 'Asset', + 'Amount', + 'Collateral', + 'Lend APY' + ] + + await page.waitForTimeout(3000) + const borrowingHeaders = await lendBorrowMintPage.headersText.allInnerTexts() + + const actualBorrowingHeaders: string[] = [] + for (const header of borrowingHeaders) { + if (header.trim() !== '') { + actualBorrowingHeaders.push(header.trim()) + } + } + expect(actualBorrowingHeaders).toEqual(expectedBorrowingHeaders) + }) + }) \ No newline at end of file diff --git a/tests/TradingToken/TradingOnKeplrByEK.spec.ts b/tests/TradingToken/TradingOnKeplrByEK.spec.ts index 561a7e2..30082d5 100644 --- a/tests/TradingToken/TradingOnKeplrByEK.spec.ts +++ b/tests/TradingToken/TradingOnKeplrByEK.spec.ts @@ -63,8 +63,8 @@ test.describe('Trading on Keplr by Encrypted Key', () => { const tradePage = new TradeTradePage(page) await tradePage.buyBtn.waitFor({state: 'visible'}) await tradePage.priceForm.clear() - await tradePage.priceForm.fill('0.01') - await tradePage.amountToken.fill('1000') + await tradePage.priceForm.fill('0.1') + await tradePage.amountToken.fill('10000') await tradePage.buyBtn.click() await tradePage.confirmBtn.click() diff --git a/tests/TradingToken/TradingOnLeapByEK.spec.ts b/tests/TradingToken/TradingOnLeapByEK.spec.ts index 5305bb7..dc502db 100644 --- a/tests/TradingToken/TradingOnLeapByEK.spec.ts +++ b/tests/TradingToken/TradingOnLeapByEK.spec.ts @@ -65,8 +65,8 @@ test.describe('Trading on Leap by Encrypted Key', () => { const tradePage = new TradeTradePage(page) await tradePage.buyBtn.waitFor({state: 'visible'}) await tradePage.priceForm.clear() - await tradePage.priceForm.fill('0.01') - await tradePage.amountToken.fill('1000') + await tradePage.priceForm.fill('0.1') + await tradePage.amountToken.fill('10000') await tradePage.buyBtn.click() await tradePage.confirmBtn.click() diff --git a/tests/TradingToken/TradingOnMetaMaskByEK.spec.ts b/tests/TradingToken/TradingOnMetaMaskByEK.spec.ts index 7f5677a..4a188d2 100644 --- a/tests/TradingToken/TradingOnMetaMaskByEK.spec.ts +++ b/tests/TradingToken/TradingOnMetaMaskByEK.spec.ts @@ -63,8 +63,8 @@ test.describe('Trading on MetaMask by Encrypted Key', () => { const tradePage = new TradeTradePage(page) await tradePage.buyBtn.waitFor({state: 'visible'}) await tradePage.priceForm.clear() - await tradePage.priceForm.fill('0.01') - await tradePage.amountToken.fill('1000') + await tradePage.priceForm.fill('0.1') + await tradePage.amountToken.fill('10000') await tradePage.buyBtn.click() await tradePage.confirmBtn.click() diff --git a/tests/TradingToken/TradingOnPhantom.spec.ts b/tests/TradingToken/TradingOnPhantom.spec.ts index 114ab8e..4af1ba9 100644 --- a/tests/TradingToken/TradingOnPhantom.spec.ts +++ b/tests/TradingToken/TradingOnPhantom.spec.ts @@ -99,9 +99,10 @@ test.describe(' Trading Token with Phantom wallet ', () => { await page.waitForLoadState() const tradePage = new TradeTradePage(page) await tradePage.buyBtn.waitFor({state: 'visible'}) + //await page.pause() await tradePage.priceForm.clear() - await tradePage.priceForm.fill('0.01') - await tradePage.amountToken.fill('1000') + await tradePage.priceForm.fill('0.1') + await tradePage.amountToken.fill('10000') await tradePage.buyBtn.click() const [newPage2] = await Promise.all([ @@ -186,7 +187,7 @@ test.describe(' Trading Token with Phantom wallet ', () => { const tradePage = new TradeTradePage(page) await tradePage.marketBtn.click() await tradePage.buyBtn.waitFor({ state: 'visible' }) - await tradePage.amountOnMarket.fill('1000') + await tradePage.amountOnMarket.fill('3000') await tradePage.buyBtn.click() const [newPage2] = await Promise.all([ From 0a74b5d214c60fcb0df92712516d7baf79b4f786 Mon Sep 17 00:00:00 2001 From: KimieTran <34021222+KimieTran@users.noreply.github.com> Date: Wed, 26 Mar 2025 23:50:32 +0700 Subject: [PATCH 4/8] add TC_DEMEX_NITRON_1: Access Nitron; test borrowing and lending with assets --- .github/workflows/playwright.yml | 2 +- pages/LendBorrowMintPage.ts | 17 +++++++++++ tests/NitronRevamp/NitronOnKeplrByEK.spec.ts | 30 +++++++++++++++++--- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 34e7b30..7032a75 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -6,7 +6,7 @@ on: branches: [ main, master, feature/nitron-revamp ] jobs: test: - timeout-minutes: 60 + timeout-minutes: 90 runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/pages/LendBorrowMintPage.ts b/pages/LendBorrowMintPage.ts index 602db6a..f1a935e 100644 --- a/pages/LendBorrowMintPage.ts +++ b/pages/LendBorrowMintPage.ts @@ -13,6 +13,14 @@ export class LendBorrowMintPage{ readonly yourPositionsItem: Locator readonly lendingTab: Locator readonly borrowingTab: Locator + readonly searchTextbox: Locator + readonly usdLendBtn: Locator + readonly usdBorrowBtn: Locator + readonly amountTextbox: Locator + readonly transactionText: Locator + readonly lendBtn: Locator + readonly borrowBtn: Locator + readonly backBtn: Locator constructor (page:Page){ this.page=page; @@ -27,6 +35,15 @@ export class LendBorrowMintPage{ this.yourPositionsItem = this.page.locator('div').filter({ hasText: /^Your Positions$/ }).nth(1) this.lendingTab = this.page.getByRole('button', { name: 'Lending' }) this.borrowingTab = this.page.getByRole('button', { name: 'Borrowing' }) + this.searchTextbox = this.page.getByRole('textbox', { name: 'Search' }) + this.usdLendBtn = this.page.getByRole('button', { name: 'Lend' }).first() + this.usdBorrowBtn = this.page.getByRole('button', { name: 'Borrow' }).first() + this.amountTextbox = this.page.getByRole('spinbutton') + this.transactionText = this.page.getByText('Transaction Broadcasted') + this.lendBtn = this.page.getByRole('button', { name: 'Lend' }) + this.borrowBtn = this.page.getByRole('button', { name: 'Borrow' }) + this.backBtn = this.page.locator('a').filter({ hasText: 'Back' }) + } diff --git a/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts b/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts index 5c8a56a..50fdd08 100644 --- a/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts +++ b/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts @@ -42,7 +42,6 @@ test.beforeAll('Launch browser context with permission', async () => { await encryptedKeyPage.connectBtn.click({ delay: 2000 }) await encryptedKeyPage.connectBtn.waitFor({ state: 'detached' }) await homePage.addressDropBtn.waitFor({ state: 'visible' }) - await page.pause() }) @@ -105,6 +104,29 @@ test.describe('Nitron on Keplr by Encrypted Key', () => { }) + test('TC_DEMEX_NITRON_1: Access Nitron; test borrowing and lending with assets', async () => { + await page.reload() + await page.waitForLoadState() + + const lendBorrowMintPage = new LendBorrowMintPage(page) + await lendBorrowMintPage.searchTextbox.fill('USD') + await lendBorrowMintPage.usdLendBtn.click({delay: 1000}) + await lendBorrowMintPage.amountTextbox.fill('1') + await lendBorrowMintPage.lendBtn.click() + await expect(lendBorrowMintPage.transactionText).toBeVisible() + + await page.reload() + await lendBorrowMintPage.backBtn.click() + await lendBorrowMintPage.searchTextbox.fill('USD') + await lendBorrowMintPage.usdBorrowBtn.click({delay: 1000}) + await lendBorrowMintPage.amountTextbox.fill('1') + await lendBorrowMintPage.borrowBtn.click() + await expect(lendBorrowMintPage.transactionText).toBeVisible() + await page.reload() + await lendBorrowMintPage.backBtn.click() + + }) + test('TC_NITRON_15: Verify that the Lending and Borrowing pages are separated into different pages', async () => { await page.reload() await page.waitForLoadState() @@ -134,9 +156,9 @@ test.describe('Nitron on Keplr by Encrypted Key', () => { await lendBorrowMintPage.borrowingTab.click() const expectedBorrowingHeaders = [ 'Asset', - 'Amount', - 'Collateral', - 'Lend APY' + 'Debt', + 'Borrow APY', + 'Available to Borrow' ] await page.waitForTimeout(3000) From e5d543b88118dc1cbeb35b77fd1502f18fab9289 Mon Sep 17 00:00:00 2001 From: KimieTran <34021222+KimieTran@users.noreply.github.com> Date: Fri, 28 Mar 2025 12:09:58 +0700 Subject: [PATCH 5/8] add TC_NITRON_13: Check the tooltip of the record collaterallizing the asset boosts on E-mode --- pages/LendBorrowMintPage.ts | 18 +++++++++++++++ playwright.config.ts | 2 +- tests/NitronRevamp/NitronOnKeplrByEK.spec.ts | 23 ++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/pages/LendBorrowMintPage.ts b/pages/LendBorrowMintPage.ts index f1a935e..14fcf99 100644 --- a/pages/LendBorrowMintPage.ts +++ b/pages/LendBorrowMintPage.ts @@ -21,6 +21,15 @@ export class LendBorrowMintPage{ readonly lendBtn: Locator readonly borrowBtn: Locator readonly backBtn: Locator + readonly enableModeBtn: Locator + readonly enableBtn: Locator + readonly selectCategoryDropdown: Locator + readonly stablecoinsOption: Locator + readonly thunderIcon: Locator + readonly thunderTooltips: Locator + readonly stableCoinsBtn: Locator + readonly disableEModeBtn: Locator + readonly disableBtn: Locator constructor (page:Page){ this.page=page; @@ -43,6 +52,15 @@ export class LendBorrowMintPage{ this.lendBtn = this.page.getByRole('button', { name: 'Lend' }) this.borrowBtn = this.page.getByRole('button', { name: 'Borrow' }) this.backBtn = this.page.locator('a').filter({ hasText: 'Back' }) + this.enableModeBtn = this.page.getByRole('button', { name: 'Enable', exact: true }) + this.enableBtn = this.page.getByRole('button', { name: 'Enable', exact: true }) + this.selectCategoryDropdown = this.page.getByText('Select Category') + this.stablecoinsOption = this.page.getByRole('cell', { name: 'Stablecoins' }) + this.thunderIcon = this.page.locator('td:nth-child(9)').first() + this.thunderTooltips = this.page.getByText('Collateralizing this asset boosts borrowing power in your current E-Mode category.') + this.stableCoinsBtn = this.page.getByRole('button', { name: 'Stablecoins' }) + this.disableEModeBtn = this.page.getByLabel('', { exact: true }).first() + this.disableBtn = this.page.getByRole('button', { name: 'Disable' }) } diff --git a/playwright.config.ts b/playwright.config.ts index 9ec0643..0227b69 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -12,7 +12,7 @@ import { defineConfig, devices } from '@playwright/test'; * See https://playwright.dev/docs/test-configuration. */ export default defineConfig({ - testDir: './tests', + testDir: './tests/NitronRevamp', testMatch: '**/*.spec.ts', timeout: 60_000, /* Run tests in files in parallel */ diff --git a/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts b/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts index 50fdd08..b6081d1 100644 --- a/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts +++ b/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts @@ -127,6 +127,29 @@ test.describe('Nitron on Keplr by Encrypted Key', () => { }) + test('TC_NITRON_13: Check the tooltip of the record collaterallizing the asset boosts on E-mode', async () => { + await page.reload() + await page.waitForLoadState() + + const lendBorrowMintPage = new LendBorrowMintPage(page) + await lendBorrowMintPage.usdLendBtn.waitFor({state: 'visible'}) + await lendBorrowMintPage.enableModeBtn.click() + await lendBorrowMintPage.selectCategoryDropdown.click() + await lendBorrowMintPage.stablecoinsOption.click() + await lendBorrowMintPage.enableBtn.click() + + await lendBorrowMintPage.backBtn.click() + await lendBorrowMintPage.searchTextbox.fill('USD') + await lendBorrowMintPage.thunderIcon.click() + await expect(lendBorrowMintPage.thunderTooltips).toBeVisible() + + await page.reload() + await lendBorrowMintPage.stableCoinsBtn.click() + await lendBorrowMintPage.disableEModeBtn.check() + await lendBorrowMintPage.disableBtn.click() + await lendBorrowMintPage.backBtn.click() + }) + test('TC_NITRON_15: Verify that the Lending and Borrowing pages are separated into different pages', async () => { await page.reload() await page.waitForLoadState() From 91b1e33f852446fdf534d4a4a0f848aa16ef9582 Mon Sep 17 00:00:00 2001 From: KimieTran <34021222+KimieTran@users.noreply.github.com> Date: Mon, 31 Mar 2025 00:29:09 +0700 Subject: [PATCH 6/8] add TC_NITRON_21, TC_NITRON_26 test cases --- pages/LendBorrowMintPage.ts | 19 +++++++- tests/NitronRevamp/NitronOnKeplrByEK.spec.ts | 50 ++++++++++++++++++-- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/pages/LendBorrowMintPage.ts b/pages/LendBorrowMintPage.ts index 14fcf99..c5c5d9c 100644 --- a/pages/LendBorrowMintPage.ts +++ b/pages/LendBorrowMintPage.ts @@ -30,6 +30,15 @@ export class LendBorrowMintPage{ readonly stableCoinsBtn: Locator readonly disableEModeBtn: Locator readonly disableBtn: Locator + readonly viewDetailsBtn: Locator + readonly popupLiquidRiskParamsText: Locator + readonly contentUnderPopupTitle: Locator + readonly healthFactorArea: Locator + readonly currentLTVArea: Locator + readonly xPopupBtn: Locator + readonly eMode: Locator + readonly eModeTooltips: Locator + readonly learnMoreLinkTooltips: Locator constructor (page:Page){ this.page=page; @@ -61,7 +70,15 @@ export class LendBorrowMintPage{ this.stableCoinsBtn = this.page.getByRole('button', { name: 'Stablecoins' }) this.disableEModeBtn = this.page.getByLabel('', { exact: true }).first() this.disableBtn = this.page.getByRole('button', { name: 'Disable' }) - + this.viewDetailsBtn = this.page.locator('a').filter({ hasText: 'View Details' }) + this.popupLiquidRiskParamsText = this.page.getByText('Liquidation Risk Parameters') + this.contentUnderPopupTitle = this.page.getByText('Your health factor and loan-to-value determines the assurance of your collateral. Add more collateral or return borrowed assets to avoid liquidation.') + this.healthFactorArea = this.page.getByRole('paragraph').filter({ hasText: 'Health Factor' }) + this.currentLTVArea = this.page.getByText('Current LTV') + this.xPopupBtn = this.page.getByRole('button') + this.eMode = this.page.getByText('E-Mode', { exact: true }) + this.eModeTooltips = this.page.getByText('Efficiency Mode (E-Mode) increases your LTV for a selected category of assets.') + this.learnMoreLinkTooltips = this.page.locator('a[href*="introduction/efficiency-mode"]') } diff --git a/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts b/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts index b6081d1..207a1d4 100644 --- a/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts +++ b/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts @@ -43,14 +43,12 @@ test.beforeAll('Launch browser context with permission', async () => { await encryptedKeyPage.connectBtn.waitFor({ state: 'detached' }) await homePage.addressDropBtn.waitFor({ state: 'visible' }) + await homePage.earnBtn.click() + await homePage.lendBorrowMintItem.click() }) test.describe('Nitron on Keplr by Encrypted Key', () => { test('TC_NITRON_02: Check the colums in the "All Markets" table', async () => { - const homePage = new HomePage(page) - await homePage.earnBtn.click() - await homePage.lendBorrowMintItem.click() - const lendBorrowMintPage = new LendBorrowMintPage(page) const expectedHeaders = [ @@ -196,4 +194,48 @@ test.describe('Nitron on Keplr by Encrypted Key', () => { expect(actualBorrowingHeaders).toEqual(expectedBorrowingHeaders) }) + test('TC_NITRON_21: Verify that the Liquidation Risk Parameters pop-up will be displayed when clicking on the "View Details" of the Health Factor', async () => { + await page.reload() + await page.waitForLoadState() + + const lendBorrowMintPage = new LendBorrowMintPage(page) + await lendBorrowMintPage.yourPositionsItem.click() + + await lendBorrowMintPage.viewDetailsBtn.click() + await expect(lendBorrowMintPage.popupLiquidRiskParamsText).toBeVisible() + await expect(lendBorrowMintPage.contentUnderPopupTitle).toBeVisible() + await expect(lendBorrowMintPage.healthFactorArea).toBeVisible() + await expect(lendBorrowMintPage.currentLTVArea).toBeVisible() + await lendBorrowMintPage.xPopupBtn.click() + + }) + + test.only('TC_NITRON_26: Check the tooltip of the E-mode', async () => { + await page.reload() + await page.waitForLoadState() + + const lendBorrowMintPage = new LendBorrowMintPage(page) + await lendBorrowMintPage.usdLendBtn.waitFor({state: 'visible'}) + await lendBorrowMintPage.enableModeBtn.click() + await lendBorrowMintPage.selectCategoryDropdown.click() + await lendBorrowMintPage.stablecoinsOption.click() + await lendBorrowMintPage.enableBtn.click() + await lendBorrowMintPage.backBtn.click() + + await lendBorrowMintPage.yourPositionsItem.click() + await lendBorrowMintPage.borrowingTab.click() + await page.pause() + + await lendBorrowMintPage.eMode.hover() + await expect(lendBorrowMintPage.eModeTooltips).toBeVisible() + await expect(lendBorrowMintPage.learnMoreLinkTooltips).toBeVisible() + + await page.reload() + await lendBorrowMintPage.stableCoinsBtn.click() + await lendBorrowMintPage.disableEModeBtn.check() + await lendBorrowMintPage.disableBtn.click() + await lendBorrowMintPage.backBtn.click() + + }) + }) \ No newline at end of file From 479aa6fe1c4bbf86a7db39196071b9ee091c8465 Mon Sep 17 00:00:00 2001 From: KimieTran <34021222+KimieTran@users.noreply.github.com> Date: Mon, 31 Mar 2025 00:29:41 +0700 Subject: [PATCH 7/8] remove test.only --- tests/NitronRevamp/NitronOnKeplrByEK.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts b/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts index 207a1d4..5d8ff99 100644 --- a/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts +++ b/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts @@ -210,7 +210,7 @@ test.describe('Nitron on Keplr by Encrypted Key', () => { }) - test.only('TC_NITRON_26: Check the tooltip of the E-mode', async () => { + test('TC_NITRON_26: Check the tooltip of the E-mode', async () => { await page.reload() await page.waitForLoadState() From cf3b39479f2fe7db92b39bf4575196db74421e48 Mon Sep 17 00:00:00 2001 From: KimieTran <34021222+KimieTran@users.noreply.github.com> Date: Tue, 1 Apr 2025 00:08:25 +0700 Subject: [PATCH 8/8] add TC_NITRON_12, TC_NITRON_24 test cases --- pages/LendBorrowMintPage.ts | 17 ++++++++- tests/NitronRevamp/NitronOnKeplrByEK.spec.ts | 40 ++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/pages/LendBorrowMintPage.ts b/pages/LendBorrowMintPage.ts index c5c5d9c..3076e92 100644 --- a/pages/LendBorrowMintPage.ts +++ b/pages/LendBorrowMintPage.ts @@ -39,6 +39,7 @@ export class LendBorrowMintPage{ readonly eMode: Locator readonly eModeTooltips: Locator readonly learnMoreLinkTooltips: Locator + readonly eModeThunderIcon: Locator constructor (page:Page){ this.page=page; @@ -79,7 +80,21 @@ export class LendBorrowMintPage{ this.eMode = this.page.getByText('E-Mode', { exact: true }) this.eModeTooltips = this.page.getByText('Efficiency Mode (E-Mode) increases your LTV for a selected category of assets.') this.learnMoreLinkTooltips = this.page.locator('a[href*="introduction/efficiency-mode"]') + this.eModeThunderIcon = this.page.locator('div').filter({ hasText: /^E-Mode$/ }).locator('svg') } - + async getLendApyColumnValues() { + const columnValues = await this.page.$$eval('tbody tr', rows => { + return rows.map(row => { + const lendApyCell = row.querySelectorAll('td')[3] + const value = lendApyCell ? lendApyCell.innerText.trim() : null + if (value) { + const number = parseFloat(value.replace('%', '').trim()) + return !isNaN(number) ? number : null + } + return null + }).filter(value => value !== null) + }) + return columnValues + } } \ No newline at end of file diff --git a/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts b/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts index 5d8ff99..f5d4f1e 100644 --- a/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts +++ b/tests/NitronRevamp/NitronOnKeplrByEK.spec.ts @@ -125,6 +125,21 @@ test.describe('Nitron on Keplr by Encrypted Key', () => { }) + test('TC_NITRON_12: Verify that the filter all E-Mode related assets to top of page sort by Lend APY', async () => { + await page.reload() + await page.waitForLoadState() + const lendBorrowMintPage = new LendBorrowMintPage(page) + await expect(lendBorrowMintPage.eMode).toBeVisible() + + await page.waitForSelector('table') + await lendBorrowMintPage.usdLendBtn.waitFor({state: 'visible'}) + + const lendApyValues = await lendBorrowMintPage.getLendApyColumnValues() + const sortedLendAPYValues = [...lendApyValues].sort((a, b) => b - a) + expect(lendApyValues).toEqual(sortedLendAPYValues) + + }) + test('TC_NITRON_13: Check the tooltip of the record collaterallizing the asset boosts on E-mode', async () => { await page.reload() await page.waitForLoadState() @@ -210,6 +225,31 @@ test.describe('Nitron on Keplr by Encrypted Key', () => { }) + test('TC_NITRON_24: Check that the E-Mode is on the Lending page', async () => { + await page.reload() + await page.waitForLoadState() + + const lendBorrowMintPage = new LendBorrowMintPage(page) + await lendBorrowMintPage.usdLendBtn.waitFor({state: 'visible'}) + await lendBorrowMintPage.enableModeBtn.click() + await lendBorrowMintPage.selectCategoryDropdown.click() + await lendBorrowMintPage.stablecoinsOption.click() + await lendBorrowMintPage.enableBtn.click() + await lendBorrowMintPage.backBtn.click() + + await lendBorrowMintPage.yourPositionsItem.click() + await lendBorrowMintPage.lendingTab.click() + await expect(lendBorrowMintPage.eMode).toBeVisible() + await expect(lendBorrowMintPage.eModeThunderIcon).toBeVisible() + + await page.reload() + await lendBorrowMintPage.stableCoinsBtn.click() + await lendBorrowMintPage.disableEModeBtn.check() + await lendBorrowMintPage.disableBtn.click() + await lendBorrowMintPage.backBtn.click() + + }) + test('TC_NITRON_26: Check the tooltip of the E-mode', async () => { await page.reload() await page.waitForLoadState()