Skip to content

Commit cf7de0e

Browse files
committed
done tc TC_DEMEX_TO_1: Buy order & TC_DEMEX_TO_4: Cancel order with Phantom wallet
1 parent be84076 commit cf7de0e

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed

pages/TradeTradePage.page.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ export class TradeTradePage{
1111
readonly buyBtn: Locator
1212
readonly confirmBtn: Locator
1313
readonly orderedPopup: Locator
14+
readonly orderedCancelledPopup: Locator
15+
readonly cancelBtn: Locator
16+
readonly cancelAllBtn: Locator
1417

1518
constructor(page: Page){
1619
this.page=page;
@@ -24,9 +27,43 @@ export class TradeTradePage{
2427
this.buyBtn = this.page.getByRole('button', { name: 'Buy SWTH', exact: true })
2528
this.confirmBtn = this.page.getByRole('button', { name: 'Confirm' })
2629
this.orderedPopup = this.page.getByText('Order Placed')
30+
this.orderedCancelledPopup = this.page.getByText('Order Cancelled')
31+
this.cancelBtn = this.page.getByRole('button', { name: 'Cancel', exact: true })
32+
this.cancelAllBtn = this.page.getByRole('columnheader', { name: 'Cancel All' })
2733
}
2834

2935
async goToTradePage(){
3036
await this.page.goto('https://beta-app.dem.exchange/trade');
3137
}
38+
39+
async verifyTableData(expectedData: Array<{ [key: string]: string }>) {
40+
const table = this.page.locator('//table[thead//th[contains(text(), "Date")]]');
41+
await expect(table).toBeVisible();
42+
43+
const headers = await table.locator('thead tr th').allInnerTexts();
44+
console.log('Column headers:', headers);
45+
46+
const columnIndexes: { [key: string]: number } = {};
47+
headers.forEach((header, index) => {
48+
columnIndexes[header.trim()] = index + 1;
49+
});
50+
console.log('Column Index:', columnIndexes)
51+
52+
for (let rowIndex = 0; rowIndex < expectedData.length; rowIndex++) {
53+
const row = table.locator(`tbody tr:nth-child(${rowIndex + 1})`);
54+
55+
for (const [columnName, expectedValue] of Object.entries(expectedData[rowIndex])) {
56+
if (columnIndexes[columnName] !== undefined) {
57+
const columnIndex = columnIndexes[columnName];
58+
const cellLocator = row.locator(`td:nth-child(${columnIndex})`);
59+
60+
await expect(cellLocator).toHaveText(expectedValue);
61+
console.log(`Row ${rowIndex + 1}, column "${columnName}" verified: "${expectedValue}"`);
62+
} else {
63+
console.warn(`Column "${columnName}" not found!`);
64+
}
65+
}
66+
}
67+
}
68+
3269
}

tests/ConnectWalletsAndDeposit/ConnectPhantomWallet.spec.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ test.describe.serial(' Phantom wallet ', () => {
130130
await expect(withdrawPage.transactionSuccess).toBeVisible()
131131
})
132132

133-
test('Place a buy order, verify appearance in order book', async () => {
133+
test('TC_DEMEX_TO_1: Place a buy order, verify appearance in order book', async () => {
134134
const tradePage = new TradeTradePage(page)
135135
await tradePage.opTokenOption.click()
136136
await tradePage.spotTab.click()
@@ -146,9 +146,36 @@ test.describe.serial(' Phantom wallet ', () => {
146146
await newPage2.waitForLoadState()
147147

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

151-
await expect(tradePage.orderedPopup).toBeVisible()
152+
await expect(tradePage.orderedPopup).toBeVisible({ timeout: 10_000})
152153

154+
const expectedTableData = [
155+
{
156+
'Market': 'SWTH / USD',
157+
'Type': 'Limit|Buy',
158+
'Size': '1,000 SWTH$1.24',
159+
'Filled': '0 SWTH$0.00',
160+
}
161+
]
162+
await tradePage.verifyTableData(expectedTableData)
163+
164+
})
165+
166+
test('TC_DEMEX_TO_4: Cancel an active order and confirm removal', async () => {
167+
const tradePage = new TradeTradePage(page)
168+
169+
const [newPage3] = await Promise.all([
170+
browserContext.waitForEvent('page'),
171+
await tradePage.cancelBtn.click()
172+
]);
173+
await newPage3.waitForLoadState()
174+
175+
const phantomPage3 = new PhantomPage(newPage3)
176+
await phantomPage3.connectBtn.waitFor({ state: 'visible' })
177+
await phantomPage3.connectBtn.click({ delay: 1000 })
178+
179+
await expect(tradePage.orderedCancelledPopup).toBeVisible({ timeout: 10_000})
153180
})
154181
})

0 commit comments

Comments
 (0)