Skip to content

Commit 6d75052

Browse files
committed
chore: add LC PO and update LC E2E tests
1 parent c66aa3e commit 6d75052

File tree

6 files changed

+72
-70
lines changed

6 files changed

+72
-70
lines changed

packages/client/e2e/fixtures.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
FxAnalyticsPageObject,
99
FxBlotterPageObject,
1010
FxTilesPageObject,
11+
LimitCheckerPageObject,
1112
} from "./pages"
1213
import { isOpenFin } from "./utils"
1314

@@ -32,7 +33,7 @@ type CreditPages = {
3233
interface Fixtures {
3334
fxPages: FxPages
3435
creditPages: CreditPages
35-
limitCheckerPage: Page
36+
limitCheckerPO: LimitCheckerPageObject
3637
}
3738

3839
const creditOpenfinUrlSuffixes: Record<string, keyof CreditPages> = {
@@ -51,8 +52,8 @@ const fxOpenFinUrlSuffixes: Record<string, keyof FxPages> = {
5152
const limitCheckerUrlPath = "limit-checker"
5253

5354
export const test = base.extend<Fixtures>({
54-
browser: async ({}, use, workerInfo) => {
55-
if (isOpenFin(workerInfo)) {
55+
browser: async ({}, use, testInfo) => {
56+
if (isOpenFin(testInfo)) {
5657
const runtimeConnection = await chromium.connectOverCDP(RUNTIME_ADDRESS)
5758
await use(runtimeConnection)
5859
} else {
@@ -117,10 +118,10 @@ export const test = base.extend<Fixtures>({
117118
})
118119
}
119120
},
120-
creditPages: async ({ context }, use, workerInfo) => {
121+
creditPages: async ({ context }, use, testInfo) => {
121122
const contextPages = context.pages()
122123

123-
if (isOpenFin(workerInfo)) {
124+
if (isOpenFin(testInfo)) {
124125
use(
125126
Object.keys(creditOpenfinUrlSuffixes).reduce<CreditPages>(
126127
(rec, urlPath) => {
@@ -133,14 +134,14 @@ export const test = base.extend<Fixtures>({
133134

134135
switch (urlPath) {
135136
case "credit-blotter":
136-
rec.blotterPO = new CreditBlotterPageObject(page, workerInfo)
137+
rec.blotterPO = new CreditBlotterPageObject(page, testInfo)
137138
break
138139
case "credit-new-rfq":
139-
rec.newRfqPO = new CreditNewRfqPageObject(page, workerInfo)
140+
rec.newRfqPO = new CreditNewRfqPageObject(page, testInfo)
140141
break
141142
case "credit-rfqs":
142143
page.setViewportSize({ width: 1280, height: 1024 })
143-
rec.rfqsPO = new CreditRfqTilesPageObject(page, workerInfo)
144+
rec.rfqsPO = new CreditRfqTilesPageObject(page, testInfo)
144145
break
145146
default:
146147
throw Error(`Unknown Openfin page URL - ${urlPath}`)
@@ -155,29 +156,25 @@ export const test = base.extend<Fixtures>({
155156
contextPages.length > 0 ? contextPages[0] : await context.newPage()
156157
await mainPage.goto(`${process.env.E2E_RTC_WEB_ROOT_URL}/credit`)
157158
use({
158-
blotterPO: new CreditBlotterPageObject(mainPage, workerInfo),
159-
newRfqPO: new CreditNewRfqPageObject(mainPage, workerInfo),
160-
rfqsPO: new CreditRfqTilesPageObject(mainPage, workerInfo),
159+
blotterPO: new CreditBlotterPageObject(mainPage, testInfo),
160+
newRfqPO: new CreditNewRfqPageObject(mainPage, testInfo),
161+
rfqsPO: new CreditRfqTilesPageObject(mainPage, testInfo),
161162
})
162163
}
163164
},
164-
limitCheckerPage: async ({ context }, use, workerInfo) => {
165+
limitCheckerPO: async ({ context }, use, testInfo) => {
165166
const contextPages = context.pages()
166167

167-
if (isOpenFin(workerInfo)) {
168+
if (isOpenFin(testInfo)) {
168169
const page = contextPages.find(
169170
(p) =>
170171
p.url() ===
171172
`${process.env.E2E_RTC_WEB_ROOT_URL}/${limitCheckerUrlPath}`,
172173
)
173174
if (!page)
174175
throw Error(`Openfin page at ${limitCheckerUrlPath} was not found`)
175-
use(page)
176-
} else {
177-
const mainPage =
178-
contextPages.length > 0 ? contextPages[0] : await context.newPage()
179176

180-
use(mainPage)
177+
use(new LimitCheckerPageObject(page, testInfo))
181178
}
182179
},
183180
})

packages/client/e2e/fx-blotter.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ test.describe("Trade Blotter", () => {
5656
test("when user clicks on the header of any column, it should sort it (depending on number of clicks, can be ascending or descending)", async ({
5757
fxPages: { blotterPO },
5858
}) => {
59-
const firstRowTradeID = await blotterPO.tradeIDCellContent
59+
const firstRowTradeID = await blotterPO.firstTradeIDCellContent
6060

6161
// filter once (descending)
6262
await blotterPO.tradeIDColHeader.click()
63-
const afterClick1 = await blotterPO.tradeIDCellContent
63+
const afterClick1 = await blotterPO.firstTradeIDCellContent
6464

6565
expect(afterClick1).toBe(firstRowTradeID)
6666

6767
// filter 2nd time (ascending)
6868
await blotterPO.tradeIDColHeader.click()
69-
const afterClick2 = await blotterPO.tradeIDCellContent
69+
const afterClick2 = await blotterPO.firstTradeIDCellContent
7070

7171
expect(afterClick2).toBe("1")
7272

@@ -87,7 +87,7 @@ test.describe("Trade Blotter", () => {
8787
await searchInput.pressSequentially(tradeIDToSearch, { delay: 100 })
8888
const rows = blotterPO.page.locator(`[role="grid"] > div`)
8989
expect(await rows.count()).toBe(2)
90-
const firstRowTradeID = await blotterPO.tradeIDCellContent
90+
const firstRowTradeID = await blotterPO.firstTradeIDCellContent
9191
expect(firstRowTradeID).toBe(tradeIDToSearch)
9292
// cleanup so the next test that runs is not filtered
9393
await searchInput.fill("")
@@ -96,7 +96,7 @@ test.describe("Trade Blotter", () => {
9696
test("when user clicks export button on blotter, should download a csv, and the csv data should match blotter data", async ({
9797
fxPages: { blotterPO },
9898
}) => {
99-
const firstRowTradeID = await blotterPO.tradeIDCellContent
99+
const firstRowTradeID = await blotterPO.firstTradeIDCellContent
100100
const downloadPromise = blotterPO.page.waitForEvent("download")
101101
const downloadButton = blotterPO.exportToCsvButton
102102
await downloadButton.click()

packages/client/e2e/limit-checker.spec.ts

Lines changed: 22 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ export const assertGridRow = async ({
1414
firstCellToAssert?: number
1515
lastCellToAssert?: number
1616
}) => {
17-
let j = 0
1817
for (
19-
let i = firstCellToAssert ? firstCellToAssert : 0;
18+
let i = firstCellToAssert ? firstCellToAssert : 0, j = 0;
2019
i < (lastCellToAssert ? lastCellToAssert : assertions.length);
21-
i++
20+
i++, j++
2221
) {
2322
await expect(row.nth(i)).toHaveText(assertions[j])
24-
j++
2523
}
2624
}
2725

@@ -31,28 +29,16 @@ test.describe("Limit Checker", () => {
3129
})
3230

3331
test("Trade is checked and allowed if notional is under set limit", async ({
34-
limitCheckerPage,
32+
limitCheckerPO,
3533
fxPages: { tilePO, blotterPO },
3634
}) => {
37-
const limitTableFirstRowCells = limitCheckerPage
38-
.locator(`[role="grid"] > div`)
39-
.nth(1)
40-
.locator("div")
35+
const fxBlotterLastTradeId = Number(await blotterPO.firstTradeIDCellContent)
4136

42-
const limitCheckInput = limitCheckerPage
43-
.locator("div", {
44-
has: limitCheckerPage.locator("div", { hasText: /^EUR\/USD$/ }),
45-
})
46-
.last()
47-
.locator("input")
37+
const limitCheckerTradeId = Number(
38+
await limitCheckerPO.firstTradeIDCellContent,
39+
)
4840

49-
const lastTradeIdString = await blotterPO.firstTradeRow.nth(1).innerText()
50-
const lastTradeId = Number(lastTradeIdString)
51-
52-
const limitIdString = await limitTableFirstRowCells.nth(1).innerText()
53-
const limitId = Number(limitIdString)
54-
55-
await limitCheckInput.fill("2000000")
41+
await limitCheckerPO.limitCheckerInput.fill("2000000")
5642

5743
await tilePO.selectFilter("EUR")
5844
await tilePO.notionalInput("EURUSD").fill("1999999")
@@ -61,13 +47,15 @@ test.describe("Limit Checker", () => {
6147
await expect(
6248
blotterPO.firstTradeRow
6349
.nth(1)
64-
.getByText(String(isNaN(lastTradeId) ? 1 : lastTradeId + 1)),
50+
.getByText(
51+
String(isNaN(fxBlotterLastTradeId) ? 1 : fxBlotterLastTradeId + 1),
52+
),
6553
).toBeVisible()
6654

6755
await assertGridRow({
68-
row: limitTableFirstRowCells,
56+
row: limitCheckerPO.firstTradeRow,
6957
assertions: [
70-
String(isNaN(limitId) ? 0 : limitId + 1),
58+
String(isNaN(limitCheckerTradeId) ? 0 : limitCheckerTradeId + 1),
7159
"Success",
7260
"EURUSD",
7361
"1,999,999",
@@ -86,36 +74,25 @@ test.describe("Limit Checker", () => {
8674
})
8775

8876
test("Trade is blocked if notional is above limit", async ({
89-
limitCheckerPage,
77+
limitCheckerPO,
9078
fxPages: { tilePO, blotterPO },
9179
}) => {
92-
const limitTableFirstRowCells = limitCheckerPage
93-
.locator(`[role="grid"] > div`)
94-
.nth(1)
95-
.locator("div")
96-
97-
const tradeId = await blotterPO.firstTradeRow.nth(1).innerText()
98-
99-
const limitCheckInput = limitCheckerPage
100-
.locator("div", {
101-
has: limitCheckerPage.locator("div", { hasText: /^EUR\/USD$/ }),
102-
})
103-
.last()
104-
.locator("input")
80+
const fxBlotterLastTradeId = await blotterPO.firstTradeIDCellContent
10581

106-
const limitIdString = await limitTableFirstRowCells.nth(1).innerText()
107-
const limitId = Number(limitIdString)
82+
const limitCheckerTradeId = Number(
83+
await limitCheckerPO.firstTradeIDCellContent,
84+
)
10885

109-
await limitCheckInput.fill("1000000")
86+
await limitCheckerPO.limitCheckerInput.fill("1000000")
11087

11188
await tilePO.selectFilter("EUR")
11289
await tilePO.notionalInput("EURUSD").fill("1000001")
11390
await tilePO.buy("EURUSD")
11491

11592
await assertGridRow({
116-
row: limitTableFirstRowCells,
93+
row: limitCheckerPO.firstTradeRow,
11794
assertions: [
118-
String(isNaN(limitId) ? 0 : limitId + 1),
95+
String(isNaN(limitCheckerTradeId) ? 0 : limitCheckerTradeId + 1),
11996
"Failure",
12097
"EURUSD",
12198
"1,000,001",
@@ -125,6 +102,6 @@ test.describe("Limit Checker", () => {
125102
lastCellToAssert: 6,
126103
})
127104

128-
await expect(blotterPO.firstTradeRow.nth(1)).toHaveText(tradeId)
105+
expect(await blotterPO.firstTradeIDCellContent).toBe(fxBlotterLastTradeId)
129106
})
130107
})

packages/client/e2e/pages/FxBlotterPageObject.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export class FxBlotterPageObject {
2828
return this.page.locator('[role="grid"] > div').nth(1).locator("div")
2929
}
3030

31-
get tradeIDCellContent() {
32-
return this.firstTradeRow.nth(TRADE_ID_COLUMN_INDEX).textContent()
31+
get firstTradeIDCellContent() {
32+
return this.firstTradeRow.nth(TRADE_ID_COLUMN_INDEX).innerText()
3333
}
3434

3535
get tradeIDColHeader() {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Page, TestInfo } from "@playwright/test"
2+
3+
const TRADE_ID_COLUMN_INDEX = 1 // account for trade state (colour bar) column
4+
5+
export class LimitCheckerPageObject {
6+
constructor(
7+
readonly page: Page,
8+
readonly testInfo: TestInfo,
9+
) {}
10+
11+
get limitCheckerInput() {
12+
return this.page
13+
.locator("div", {
14+
has: this.page.locator("div", { hasText: /^EUR\/USD$/ }),
15+
})
16+
.last()
17+
.locator("input")
18+
}
19+
20+
get firstTradeRow() {
21+
return this.page.locator(`[role="grid"] > div`).nth(1).locator("div")
22+
}
23+
24+
get firstTradeIDCellContent() {
25+
return this.firstTradeRow.nth(TRADE_ID_COLUMN_INDEX).innerText()
26+
}
27+
}

packages/client/e2e/pages/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ export * from "./CreditSellSidePageObject"
55
export * from "./FxAnalyticsPageObject"
66
export * from "./FxBlotterPageObject"
77
export * from "./FxTilesPageObject"
8+
export * from "./LimitCheckerPageObject"

0 commit comments

Comments
 (0)