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
2 changes: 1 addition & 1 deletion pages/WithdrawPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class WithdrawPage{
this.page=page;
//this.carbonGroupUSD = this.page.getByRole('button', { name: 'cUSD USD Carbon Grouped USD' })
this.selectToken = this.page.getByRole('button', { name: 'Select Token' })
this.swthTokenOption = this.page.getByRole('cell', { name: 'SWTH SWTH Carbon Token' })
this.swthTokenOption = this.page.getByRole('cell', { name: 'SWTH SWTH Demex Token' })
this.recipientAddrTextbox = this.page.getByRole('textbox', { name: 'swth1q...' })
this.amountTextbox = this.page.getByRole('spinbutton').first()
this.memoTextbox = this.page.getByRole('textbox', { name: 'Enter message' })
Expand Down
140 changes: 140 additions & 0 deletions tests/TradingToken/TradingOnKeplrByEK.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
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 encryptedKeplrKey = "ATkNagk48TArQzAvyB7FfqThoLq2NuXu1naRDqqJCN44hEEKULwJCGj2dHyepgMX1C3yUmknktxw3pJe1Z41zWpbE6SUfHhXvyeptoSgiRBPNpNqgKmmA824QFpP3XURoTDszYYL5MRWs1zoWZnHDjfvWJmTUtxdWBRqTfdiLYcipPKQYzRg1jdqXoAqpt51zydX6TfCTnfxBt61SFxsEgbgbb16w1puk9mGfFiysr9R3PystkTja6sX8AbNW9tMMALKQGHtuCjJCmjuBw9RZTfd4XnSmn1tHYEqTbKaBq6oRLJwyzVnyiqmAcmn2Pg7S2aUvWqwpyYe7KyqAQXVQY7vTjN8JtBBihA4TyWUYGhNimtWYw"
const passworld = 'Abc12345789'

test.beforeAll('Launch browser context with permission', async () => {
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' })

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 Keplr 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.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.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) { }

})
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,27 @@ test.beforeAll('Launch browser context with permission', async () => {
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 Token by Encrypted Key', () => {
test.describe('Trading on Leap by Encrypted Key', () => {
test('TC_DEMEX_TO_1: Place a buy order, verify appearance in order book', async () => {
const homePage = new HomePage(page)
await homePage.goToHomePage()
await page.reload()
await page.waitForLoadState()

const tradePage = new TradeTradePage(page)
await tradePage.opTokenOption.click()
await tradePage.spotTab.click()
await tradePage.searchToken.fill('SWTH / USD')
await tradePage.swthUSDOption.click()
await tradePage.amountToken.fill('1000')
await tradePage.buyBtn.click()
await tradePage.confirmBtn.click()
Expand Down Expand Up @@ -124,8 +129,7 @@ test.describe('Trading Token by Encrypted Key', () => {
})

test.afterAll('Reset data', async () => {
const homePage = new HomePage(page)
await homePage.goToHomePage()
await page.reload()
await page.waitForLoadState()

const tradePage = new TradeTradePage(page)
Expand Down
32 changes: 24 additions & 8 deletions tests/TradingToken/TradingOnPhantom.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const password = 'Abc123456789'
const extensionName = "phantom"

test.beforeAll('Add extension: Phantom', async () => {
test.setTimeout(120_000)
test.setTimeout(150_000)
browserContext = await createBrowserContext(extensionName)
page = await browserContext.newPage()

Expand Down Expand Up @@ -71,18 +71,33 @@ test.beforeAll('Add extension: Phantom', async () => {
await phantomPage2.connectBtn.click({ delay: 1000 })
await homePage.addressPhantomDropBtn.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 })

const [newPage2] = await Promise.all([
browserContext.waitForEvent('page'),
await tradePage.confirmBtn.click()
]);
await newPage2.waitForLoadState()

const phantomPage2 = new PhantomPage(newPage2)
await phantomPage2.connectBtn.waitFor({ state: 'visible' })
await phantomPage2.connectBtn.click({ delay: 1000 })

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

})
test.describe(' Trading Token with Phantom wallet ', () => {
test('TC_DEMEX_TO_1: Place a buy order, verify appearance in order book', async () => {
const homePage = new HomePage(page)
await homePage.goToHomePage()
await page.reload()
await page.waitForLoadState()

const tradePage = new TradeTradePage(page)
await tradePage.opTokenOption.click()
await tradePage.spotTab.click()
await tradePage.searchToken.fill('SWTH / USD')
await tradePage.swthUSDOption.click()
await tradePage.amountToken.fill('1000')
await tradePage.buyBtn.click()

Expand Down Expand Up @@ -113,6 +128,7 @@ test.describe(' Trading Token with Phantom wallet ', () => {
await page.reload()
await page.waitForLoadState()
const tradePage = new TradeTradePage(page)
await tradePage.cancelBtn.waitFor({state: 'visible'})

const [newPage3] = await Promise.all([
browserContext.waitForEvent('page'),
Expand Down
91 changes: 46 additions & 45 deletions tests/WithdrawToken/WithdrawOnLeap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,50 +92,51 @@ test.beforeAll('Add extension: Leap', async () => {

})
test.describe(' Withdraw Token with Leap 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')

const [popup] = await Promise.all([
browserContext.waitForEvent('page'),
await withdrawPage.withdrawBtn.click()
]);
await popup.waitForLoadState()

const approvalPage = new LeapPage(popup)
await approvalPage.approveBtn.waitFor({ state: 'visible' })
await approvalPage.approveBtn.click({ delay: 1000 })

await expect(withdrawPage.transactionSuccess).toBeVisible()
})
test('DEPOSIT_UI_V2_08: Check the active Withdraw button on the Deposit page', async () => {
test.setTimeout(90_000)
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')

const [popup] = await Promise.all([
browserContext.waitForEvent('page'),
await withdrawPage.withdrawBtn.click()
]);
await popup.waitForLoadState()

const approvalPage = new LeapPage(popup)
await approvalPage.approveBtn.waitFor({ state: 'visible' })
await approvalPage.approveBtn.click({ delay: 1000 })

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

})
Loading
Loading