Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions pages/TradeTradePage.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export class TradeTradePage{
readonly marketBtn: Locator
readonly amountOnMarket: Locator
readonly tradeExecutedPopup: Locator
readonly priceOrderTextBox: Locator
readonly priceForm: Locator

constructor(page: Page){
this.page=page;
Expand All @@ -40,6 +42,8 @@ export class TradeTradePage{
this.sellBtn = this.page.getByRole('button', { name: 'Sell SWTH', exact: true })
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')
}

async goToTradePage(){
Expand Down
7 changes: 7 additions & 0 deletions tests/TradingToken/TradingOnKeplrByEK.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const encryptedKeplrKey = "ATkNagk48TArQzAvyB7FfqThoLq2NuXu1naRDqqJCN44hEEKULwJC
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()
Expand Down Expand Up @@ -60,6 +61,9 @@ test.describe('Trading on Keplr by Encrypted Key', () => {
await page.waitForLoadState()

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.buyBtn.click()
await tradePage.confirmBtn.click()
Expand Down Expand Up @@ -90,6 +94,9 @@ test.describe('Trading on Keplr by Encrypted Key', () => {
await page.reload()
await page.waitForLoadState()
const tradePage = new TradeTradePage(page)
await tradePage.buyBtn.waitFor({state: 'visible'})
await tradePage.priceForm.clear()
await tradePage.priceForm.fill('10')
await tradePage.amountToken.fill('1000')
await tradePage.switchingBtn.click()
await tradePage.sellBtn.click()
Expand Down
7 changes: 7 additions & 0 deletions tests/TradingToken/TradingOnLeapByEK.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const encryptedLeapKey = "2SrrmLXhu2W3rX4jcELNY4GLoo6wGRVB2U7bG7uN58vokMEw8xugKW
const passworld = 'Abc123456789'

test.beforeAll('Launch browser context with permission', async () => {
test.setTimeout(120_000)
const browser = await chromium.launch()
browserContext = await browser.newContext({
permissions: ['clipboard-read', 'clipboard-write']
Expand Down Expand Up @@ -62,6 +63,9 @@ test.describe('Trading on Leap by Encrypted Key', () => {
await page.waitForLoadState()

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.buyBtn.click()
await tradePage.confirmBtn.click()
Expand Down Expand Up @@ -92,6 +96,9 @@ test.describe('Trading on Leap by Encrypted Key', () => {
await page.reload()
await page.waitForLoadState()
const tradePage = new TradeTradePage(page)
await tradePage.buyBtn.waitFor({state: 'visible'})
await tradePage.priceForm.clear()
await tradePage.priceForm.fill('10')
await tradePage.amountToken.fill('1000')
await tradePage.switchingBtn.click()
await tradePage.sellBtn.click()
Expand Down
147 changes: 147 additions & 0 deletions tests/TradingToken/TradingOnMetaMaskByEK.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
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';

let page: Page
let browserContext: BrowserContext
const encryptedMetaMaskKey = "3uQMeX7XfUJGGxC5J3deTBPDemwZYsaziyEXPJMpTqLEwztgb5kQtf3ChJ5Lq6HGGs9oKNsTuWw2VdC3m8uLsy6WKSYx5eosXBa8Sxq17kUqSNrFiav5kyTmD9QCLNvxY1Nj9tZ9UBq3hJ5xZifZY4QUeQyWJxZeZw8BH8nLaw1zhEsEjBrBEpHGQHdHdX8mfCjrZKHs1Z4gJDjALQFRkCVRws7Dogaw3VZWXRSy6zDDEPpDDKorKztvc2mwnV5vvaXsEcxVpTbwxTPGnKdWxvYJ6gha95DMt96oLvSdsUjatiyDXtdmSmvW8k668Sa6pJcDjhiFZfFJzMxv1jmnHFQZk6RmZQD39G2ThS"
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.carbonTestnet.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(encryptedMetaMaskKey)
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' })

await tradePage.opTokenOption.click()
await tradePage.spotTab.click()
await tradePage.searchToken.fill('SWTH / USD')
await tradePage.swthUSDOption.click()

try {
await tradePage.cancelAllBtn.click({ timeout: 10_000 })
await tradePage.confirmBtn.click()
await expect(tradePage.orderedCancelledPopup).toBeVisible({ timeout: 10_000 })
} catch (e) { }

})

test.describe('Trading on MetaMask by Encrypted Key', () => {
test('TC_DEMEX_TO_1: Place a buy order, verify appearance in order book', async () => {
await page.reload()
await page.waitForLoadState()

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.buyBtn.click()
await tradePage.confirmBtn.click()

await expect(tradePage.orderPlacedPopup).toBeVisible({ timeout: 10_000 })

const expectedTableData = [
{
'Market': 'SWTH / USD',
'Type': 'Limit|Buy',
'Filled': '0 SWTH$0.00',
}
]
await tradePage.verifyTableData(expectedTableData)

})

test('TC_DEMEX_TO_4: Cancel an active order and confirm removal', async () => {
await page.reload()
await page.waitForLoadState()
const tradePage = new TradeTradePage(page)
await tradePage.cancelBtn.click()

await expect(tradePage.orderedCancelledPopup).toBeVisible({ timeout: 10_000 })
})

test('TC_DEMEX_TO_2: Place a sell order, verify appearance in order book', async () => {
await page.reload()
await page.waitForLoadState()
const tradePage = new TradeTradePage(page)
await tradePage.buyBtn.waitFor({state: 'visible'})
await tradePage.priceForm.clear()
await tradePage.priceForm.fill('10')
await tradePage.amountToken.fill('1000')
await tradePage.switchingBtn.click()
await tradePage.sellBtn.click()
await tradePage.confirmBtn.click()

await expect(tradePage.orderPlacedPopup).toBeVisible({ timeout: 10_000 })

const expectedTableData = [
{
'Market': 'SWTH / USD',
'Type': 'Limit|Sell',
'Filled': '0 SWTH$0.00',
}
]
await tradePage.verifyTableData(expectedTableData)

await tradePage.cancelBtn.click()
await expect(tradePage.orderedCancelledPopup).toBeVisible({ timeout: 10_000 })

})

test('TC_DEMEX_TO_3: Test limit and market orders for a range of assets', async () => {
await page.reload()
await page.waitForLoadState()
const tradePage = new TradeTradePage(page)
await tradePage.marketBtn.click()
await tradePage.buyBtn.waitFor({ state: 'visible' })
await tradePage.amountOnMarket.fill('1000')
await tradePage.buyBtn.click()
await tradePage.confirmBtn.click()

await expect(tradePage.tradeExecutedPopup).toBeVisible({ timeout: 10_000 })

})
})

test.afterAll('Reset data', async () => {
await page.reload()
await page.waitForLoadState()

const tradePage = new TradeTradePage(page)
try {
await tradePage.cancelAllBtn.click({ timeout: 10_000 })
await tradePage.confirmBtn.click()
await expect(tradePage.orderedCancelledPopup).toBeVisible({ timeout: 10_000 })
} catch (e) { }

})
6 changes: 6 additions & 0 deletions tests/TradingToken/TradingOnPhantom.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ test.describe(' Trading Token with Phantom wallet ', () => {
await page.reload()
await page.waitForLoadState()
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.buyBtn.click()

Expand Down Expand Up @@ -147,6 +150,9 @@ test.describe(' Trading Token with Phantom wallet ', () => {
await page.reload()
await page.waitForLoadState()
const tradePage = new TradeTradePage(page)
await tradePage.buyBtn.waitFor({state: 'visible'})
await tradePage.priceForm.clear()
await tradePage.priceForm.fill('10')
await tradePage.amountToken.fill('1000')
await tradePage.switchingBtn.click()
await tradePage.sellBtn.click()
Expand Down
87 changes: 87 additions & 0 deletions tests/WithdrawToken/WithdrawOnKeplr.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
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 { PhantomPage } from '../../pages/PhantomPage';
import { DepositPage } from '../../pages/DepositPage';
import { WithdrawPage } from '../../pages/WithdrawPage';
import { EncryptedKeyPage } from '../../pages/EncryptedKeyPage';

let page: Page
let browserContext: BrowserContext
const encryptedKeplrKey = "ATkNagk48TArQzAvyB7FfqThoLq2NuXu1naRDqqJCN44hEEKULwJCGj2dHyepgMX1C3yUmknktxw3pJe1Z41zWpbE6SUfHhXvyeptoSgiRBPNpNqgKmmA824QFpP3XURoTDszYYL5MRWs1zoWZnHDjfvWJmTUtxdWBRqTfdiLYcipPKQYzRg1jdqXoAqpt51zydX6TfCTnfxBt61SFxsEgbgbb16w1puk9mGfFiysr9R3PystkTja6sX8AbNW9tMMALKQGHtuCjJCmjuBw9RZTfd4XnSmn1tHYEqTbKaBq6oRLJwyzVnyiqmAcmn2Pg7S2aUvWqwpyYe7KyqAQXVQY7vTjN8JtBBihA4TyWUYGhNimtWYw"
const passworld = 'Abc12345789'
const phantomSwthAddress = 'tswth1r5kh40kknhw7e02qyzyz50zsfj8xyvfsq9lvxp'

test.beforeAll('Connect Keplr wallet by Encrypted Key', 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.carbonTestnet.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(' Withdraw Token with Keplr wallet ', () => {
test('DEPOSIT_UI_V2_08: Check the active Withdraw button on the Deposit page', async () => {
await page.reload()
await page.waitForLoadState()
const depositPage = new DepositPage(page)
await depositPage.depositBtn.click()

const homePage = new HomePage(page)
await homePage.withdrawnTab.click()

const withdrawPage = new WithdrawPage(page)
await withdrawPage.selectToken.click()
await withdrawPage.swthTokenOption.click()
await withdrawPage.withdrawBtn.click()
await expect(withdrawPage.invalidAddressErrorMsg).toBeVisible()
await expect(withdrawPage.invalidAmountErrorMsg).toBeVisible()

})

test('TC_WTD_MW_001: Verify that the withdraw can be executed with other wallets address', async () => {
await page.reload()
await page.waitForLoadState()
const depositPage = new DepositPage(page)
await depositPage.depositBtn.click()

const homePage = new HomePage(page)
await homePage.withdrawnTab.click()

const withdrawPage = new WithdrawPage(page)
await withdrawPage.selectToken.click()
await withdrawPage.swthTokenOption.click()
await withdrawPage.recipientAddrTextbox.fill(phantomSwthAddress)
await withdrawPage.amountTextbox.fill('1')

await expect(withdrawPage.transactionSuccess).toBeVisible()
})

})
Loading