Skip to content

Commit f6845a4

Browse files
committed
update withdraw flow & done TC_DEMEX_TO_2 Sell order with Phantom wallet
1 parent cf7de0e commit f6845a4

6 files changed

Lines changed: 107 additions & 46 deletions

File tree

pages/TradeTradePage.page.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export class TradeTradePage{
1414
readonly orderedCancelledPopup: Locator
1515
readonly cancelBtn: Locator
1616
readonly cancelAllBtn: Locator
17+
readonly switchingBtn: Locator
18+
readonly sellBtn: Locator
1719

1820
constructor(page: Page){
1921
this.page=page;
@@ -30,6 +32,8 @@ export class TradeTradePage{
3032
this.orderedCancelledPopup = this.page.getByText('Order Cancelled')
3133
this.cancelBtn = this.page.getByRole('button', { name: 'Cancel', exact: true })
3234
this.cancelAllBtn = this.page.getByRole('columnheader', { name: 'Cancel All' })
35+
this.switchingBtn = this.page.locator("button:has(span:has-text('Buy SWTH'))").locator("xpath=following-sibling::button")
36+
this.sellBtn = this.page.getByRole('button', { name: 'Sell SWTH', exact: true })
3337
}
3438

3539
async goToTradePage(){

pages/WithdrawPage.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { type Locator, type Page } from '@playwright/test';
33
export class WithdrawPage{
44
readonly page: Page;
55
readonly carbonGroupUSD: Locator
6+
readonly selectToken: Locator
67
readonly swthTokenOption: Locator
78
readonly recipientAddrTextbox: Locator
89
readonly amountTextbox: Locator
@@ -12,7 +13,8 @@ export class WithdrawPage{
1213

1314
constructor (page:Page){
1415
this.page=page;
15-
this.carbonGroupUSD = this.page.getByRole('button', { name: 'cUSD USD Carbon Grouped USD' })
16+
//this.carbonGroupUSD = this.page.getByRole('button', { name: 'cUSD USD Carbon Grouped USD' })
17+
this.selectToken = this.page.getByRole('button', { name: 'Select Token' })
1618
this.swthTokenOption = this.page.getByRole('cell', { name: 'SWTH SWTH Carbon Token' })
1719
this.recipientAddrTextbox = this.page.getByRole('textbox', { name: 'swth1q...' })
1820
this.amountTextbox = this.page.getByRole('spinbutton').first()

tests/ConnectWalletsAndDeposit/ConnectEncryptedKeyWallet.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ test.describe.serial('Connect Leap wallet by Encrypted Key & Verify deposit', (
7878
test('Verify that the withdraw can be executed with other wallets address', async () => {
7979
const depositPage = new DepositPage(page)
8080
await depositPage.depositBtn.click()
81-
await depositPage.myBrowerWallet.click()
81+
//await depositPage.myBrowerWallet.click()
8282

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

8686
const withdrawPage = new WithdrawPage(page)
87-
await withdrawPage.carbonGroupUSD.click()
87+
await withdrawPage.selectToken.click()
8888
await withdrawPage.swthTokenOption.click()
8989
await withdrawPage.recipientAddrTextbox.fill(phantomSwthAddress)
9090
await withdrawPage.amountTextbox.fill('1')

tests/ConnectWalletsAndDeposit/ConnectLeapWallet.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ test.describe.serial('Leap wallet ', () => {
113113
test('Verify that the withdraw can be executed with other wallets address', async () => {
114114
const depositPage = new DepositPage(page)
115115
await depositPage.depositBtn.click()
116-
await depositPage.myBrowerWallet.click()
116+
//await depositPage.myBrowerWallet.click()
117117

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

121121
const withdrawPage = new WithdrawPage(page)
122-
await withdrawPage.carbonGroupUSD.click()
122+
await withdrawPage.selectToken.click()
123123
await withdrawPage.swthTokenOption.click()
124124
await withdrawPage.recipientAddrTextbox.fill(phantomSwthAddress)
125125
await withdrawPage.amountTextbox.fill('1')

tests/ConnectWalletsAndDeposit/ConnectMetaMaskWallet.spec.ts

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -103,41 +103,41 @@ test.describe.serial('Connect MetaMask wallet & Verify deposit', () => {
103103

104104
})
105105

106-
test.skip('Verify that the validation form is presented when user performed deposit amount = 0', async () => {
107-
const depositPage = new DepositPage(page)
108-
await depositPage.depositBtn.click()
109-
await depositPage.myBrowerWallet.click()
110-
await depositPage.selectNetworkBtn.click()
111-
await depositPage.networkOption('Ethereum').click()
112-
await depositPage.amountTextbox.fill('0')
113-
await depositPage.metaMaskDepositBtn.click()
114-
await expect(depositPage.errorAmountMsg).toBeVisible()
115-
})
116-
117-
test('Verify that the withdraw can be executed with other wallets address', async () => {
118-
const depositPage = new DepositPage(page)
119-
await depositPage.depositBtn.click()
120-
await depositPage.myBrowerWallet.click()
121-
122-
const homePage = new HomePage(page)
123-
await homePage.withdrawnTab.click()
124-
125-
const withdrawPage = new WithdrawPage(page)
126-
await withdrawPage.carbonGroupUSD.click()
127-
await withdrawPage.swthTokenOption.click()
128-
await withdrawPage.recipientAddrTextbox.fill(phantomSwthAddress)
129-
await withdrawPage.amountTextbox.fill('1')
130-
131-
const [popup] = await Promise.all([
132-
browserContext.waitForEvent('page'),
133-
await withdrawPage.withdrawBtn.click()
134-
]);
135-
await popup.waitForLoadState()
136-
137-
const confirmPage = new MetaMaskPage(popup)
138-
await confirmPage.confirmFooterBtn.waitFor({ state: 'visible' })
139-
await confirmPage.confirmFooterBtn.click({ delay: 1000 })
140-
141-
await expect(withdrawPage.transactionSuccess).toBeVisible()
142-
})
106+
test.skip('Verify that the validation form is presented when user performed deposit amount = 0', async () => {
107+
const depositPage = new DepositPage(page)
108+
await depositPage.depositBtn.click()
109+
await depositPage.myBrowerWallet.click()
110+
await depositPage.selectNetworkBtn.click()
111+
await depositPage.networkOption('Ethereum').click()
112+
await depositPage.amountTextbox.fill('0')
113+
await depositPage.metaMaskDepositBtn.click()
114+
await expect(depositPage.errorAmountMsg).toBeVisible()
115+
})
116+
117+
test('Verify that the withdraw can be executed with other wallets address', async () => {
118+
const depositPage = new DepositPage(page)
119+
await depositPage.depositBtn.click()
120+
//await depositPage.myBrowerWallet.click()
121+
122+
const homePage = new HomePage(page)
123+
await homePage.withdrawnTab.click()
124+
125+
const withdrawPage = new WithdrawPage(page)
126+
await withdrawPage.selectToken.click()
127+
await withdrawPage.swthTokenOption.click()
128+
await withdrawPage.recipientAddrTextbox.fill(phantomSwthAddress)
129+
await withdrawPage.amountTextbox.fill('1')
130+
131+
const [popup] = await Promise.all([
132+
browserContext.waitForEvent('page'),
133+
await withdrawPage.withdrawBtn.click()
134+
]);
135+
await popup.waitForLoadState()
136+
137+
const confirmPage = new MetaMaskPage(popup)
138+
await confirmPage.confirmFooterBtn.waitFor({ state: 'visible' })
139+
await confirmPage.confirmFooterBtn.click({ delay: 1000 })
140+
141+
await expect(withdrawPage.transactionSuccess).toBeVisible()
142+
})
143143
})

tests/ConnectWalletsAndDeposit/ConnectPhantomWallet.spec.ts

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ test.describe.serial(' Phantom wallet ', () => {
7676
await newPage2.waitForLoadState()
7777

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

8182
await page.waitForTimeout(10_000)
@@ -103,16 +104,17 @@ test.describe.serial(' Phantom wallet ', () => {
103104
await expect(depositPage.errorAmountMsg).toBeVisible()
104105
})
105106

106-
test.skip('Verify that the withdraw can be executed with other wallets address', async () => {
107+
test('Verify that the withdraw can be executed with other wallets address', async () => {
107108
const depositPage = new DepositPage(page)
108109
await depositPage.depositBtn.click()
109-
await depositPage.myBrowerWallet.click()
110+
//await depositPage.myBrowerWallet.click()
110111

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

114115
const withdrawPage = new WithdrawPage(page)
115-
await withdrawPage.carbonGroupUSD.click()
116+
//await withdrawPage.carbonGroupUSD.click()
117+
await withdrawPage.selectToken.click()
116118
await withdrawPage.swthTokenOption.click()
117119
await withdrawPage.recipientAddrTextbox.fill(leapSwthAddress)
118120
await withdrawPage.amountTextbox.fill('1')
@@ -131,6 +133,8 @@ test.describe.serial(' Phantom wallet ', () => {
131133
})
132134

133135
test('TC_DEMEX_TO_1: Place a buy order, verify appearance in order book', async () => {
136+
const homePage = new HomePage(page)
137+
await homePage.goToHomePage()
134138
const tradePage = new TradeTradePage(page)
135139
await tradePage.opTokenOption.click()
136140
await tradePage.spotTab.click()
@@ -155,7 +159,6 @@ test.describe.serial(' Phantom wallet ', () => {
155159
{
156160
'Market': 'SWTH / USD',
157161
'Type': 'Limit|Buy',
158-
'Size': '1,000 SWTH$1.24',
159162
'Filled': '0 SWTH$0.00',
160163
}
161164
]
@@ -164,6 +167,8 @@ test.describe.serial(' Phantom wallet ', () => {
164167
})
165168

166169
test('TC_DEMEX_TO_4: Cancel an active order and confirm removal', async () => {
170+
await page.reload()
171+
await page.waitForLoadState()
167172
const tradePage = new TradeTradePage(page)
168173

169174
const [newPage3] = await Promise.all([
@@ -178,4 +183,54 @@ test.describe.serial(' Phantom wallet ', () => {
178183

179184
await expect(tradePage.orderedCancelledPopup).toBeVisible({ timeout: 10_000})
180185
})
186+
187+
test('TC_DEMEX_TO_2: Place a sell order, verify appearance in order book', async () => {
188+
await page.reload()
189+
await page.waitForLoadState()
190+
const tradePage = new TradeTradePage(page)
191+
await tradePage.amountToken.fill('1000')
192+
await tradePage.switchingBtn.click()
193+
await tradePage.sellBtn.click()
194+
195+
const [newPage2] = await Promise.all([
196+
browserContext.waitForEvent('page'),
197+
await tradePage.confirmBtn.click()
198+
]);
199+
await newPage2.waitForLoadState()
200+
201+
const phantomPage2 = new PhantomPage(newPage2)
202+
await phantomPage2.connectBtn.waitFor({ state: 'visible' })
203+
await phantomPage2.connectBtn.click({ delay: 1000 })
204+
205+
await expect(tradePage.orderedPopup).toBeVisible({ timeout: 10_000})
206+
207+
const expectedTableData = [
208+
{
209+
'Market': 'SWTH / USD',
210+
'Type': 'Limit|Sell',
211+
'Filled': '0 SWTH$0.00',
212+
}
213+
]
214+
await tradePage.verifyTableData(expectedTableData)
215+
216+
})
217+
})
218+
219+
test.afterAll('Reset data', async () => {
220+
const tradePage = new TradeTradePage(page)
221+
try {
222+
await tradePage.cancelAllBtn.click({timeout: 5000})
223+
} catch (e) {}
224+
225+
const [newPage2] = await Promise.all([
226+
browserContext.waitForEvent('page'),
227+
await tradePage.confirmBtn.click()
228+
]);
229+
await newPage2.waitForLoadState()
230+
231+
const phantomPage2 = new PhantomPage(newPage2)
232+
await phantomPage2.connectBtn.waitFor({ state: 'visible' })
233+
await phantomPage2.connectBtn.click({ delay: 1000 })
234+
235+
await expect(tradePage.orderedCancelledPopup).toBeVisible({ timeout: 10_000})
181236
})

0 commit comments

Comments
 (0)