Skip to content

Commit f8babb5

Browse files
authored
bb/fix specs (#1475)
* chore(playwright): fix testID for token balance items and enhance send page navigation logic * fix(types): remove duplicate user field in Fingerprint interface in snaplet-client.d.ts * fix(types): remove duplicate user field in Fingerprint interface in snaplet-client.d.ts
1 parent 5892a7a commit f8babb5

File tree

7 files changed

+56
-15
lines changed

7 files changed

+56
-15
lines changed

packages/app/features/home/InvestmentBalanceList.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const InvestmentsBalanceList = () => {
2626
return investmentCoins.map((coin) => (
2727
<Fragment key={`token-balance-list-${coin.label}`}>
2828
<TokenBalanceItem
29+
testID={`token-balance-list-${coin.label}`}
2930
coin={coin}
3031
jc={'space-between'}
3132
ai={'center'}
@@ -144,7 +145,14 @@ export const AddInvestmentLink = () => {
144145
const hoverStyles = useHoverStyles()
145146

146147
return (
147-
<LinkableButton circular href="/trade" p="$2" size="$5" hoverStyle={hoverStyles}>
148+
<LinkableButton
149+
circular
150+
href="/trade"
151+
p="$2"
152+
size="$5"
153+
hoverStyle={hoverStyles}
154+
title="Add Investment"
155+
>
148156
<LinkableButton.Icon>
149157
<IconPlus size="$5" color="$color10" />
150158
</LinkableButton.Icon>

packages/app/utils/useSearchResultHref.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@ export const useSearchResultHref = (profile?: SearchResultCommonType) => {
1515
return ''
1616
case path === '/activity':
1717
return `${baseMainnet.blockExplorers.default.url}/address/${query}`
18-
case path === '/send' || path === '/':
19-
return `/send?recipient=${query}&idType=address`
18+
case path === '/send' || path === '/': {
19+
const _sendParams = JSON.parse(JSON.stringify(sendParams)) //JSON makes sure we don't pass undefined values
20+
return `/send?${new URLSearchParams({
21+
..._sendParams,
22+
recipient: query,
23+
idType: 'address',
24+
}).toString()}`
25+
}
2026

2127
default:
2228
throw new Error(`Unhandled path: ${path}`)

packages/playwright/tests/fixtures/earn/EarnDepositPage.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export class EarnDepositPage {
2323

2424
async navigate(coin: { symbol: string }) {
2525
await this.page.goto('/')
26-
await this.page.getByRole('link', { name: 'Earn' }).click()
26+
// The Earn link is now inside the SavingsBalanceCard
27+
await this.page.getByText('Savings').click()
2728
await this.page.waitForURL('/earn')
2829
await expect(this.startEarningButton).toBeVisible()
2930
await this.startEarningButton.click()
@@ -63,8 +64,12 @@ export class EarnDepositPage {
6364
}
6465

6566
async submit() {
66-
await expect(this.page.getByRole('button', { name: 'Confirm Deposit' })).toBeVisible()
67-
await expect(this.page.getByRole('button', { name: 'Confirm Deposit' })).toBeEnabled()
67+
await expect(async () => {
68+
await expect(this.page.getByRole('button', { name: 'Confirm Deposit' })).toBeVisible()
69+
await expect(this.page.getByRole('button', { name: 'Confirm Deposit' })).toBeEnabled()
70+
}).toPass({
71+
timeout: 15000,
72+
})
6873
await this.page.getByRole('button', { name: 'Confirm Deposit' }).click()
6974
await expect(this.page.getByText('Deposit Submitted', { exact: true })).toBeVisible({
7075
timeout: 10000,

packages/playwright/tests/fixtures/swap/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,15 @@ export class SwapFormPage {
7777
}
7878

7979
async goto() {
80-
log('goto /trade')
80+
log('goto /?token=investments')
8181
await this.page.goto('/')
82-
await this.page.getByRole('link', { name: 'Trade' }).nth(0).click()
83-
await this.page.waitForURL('/trade')
82+
const investButton = this.page.getByText('Invest', { exact: true })
83+
await expect(investButton).toBeVisible()
84+
await investButton.click()
85+
await this.page.waitForURL('/?token=investments')
86+
const addInvestmentButton = this.page.getByRole('link', { name: 'Add Investment' })
87+
await expect(addInvestmentButton).toBeVisible()
88+
await addInvestmentButton.click()
8489
await this.validatePageVisible()
8590
}
8691

packages/playwright/tests/send.onboarded.spec.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { userOnboarded } from '@my/snaplet/models'
44
import type { Database } from '@my/supabase/database.types'
55
import { mergeTests, type Page } from '@playwright/test'
66
import type { SupabaseClient } from '@supabase/supabase-js'
7-
import { coins, type coin, ethCoin } from 'app/data/coins'
7+
import { coins, type coin, ethCoin, stableCoins } from 'app/data/coins'
88
import { assert } from 'app/utils/assert'
99
import { hexToBytea } from 'app/utils/hexToBytea'
1010
import { shorten } from 'app/utils/strings'
@@ -101,9 +101,25 @@ for (const token of [...coins, ethCoin]) {
101101
// goto send page
102102
await page.goto('/')
103103

104-
//Press send button
105-
await page.locator(`a[href="/?token=${token.token}"]`).click()
106-
await page.getByTestId('send-quick-action').click()
104+
//Press send button - navigate to correct category based on token type
105+
const isStableCoin = stableCoins.some((coin) => coin.symbol === token.symbol)
106+
107+
if (isStableCoin) {
108+
const cashBalButton = page.getByText('Cash Balance')
109+
await expect(cashBalButton).toBeVisible()
110+
await cashBalButton.click()
111+
} else {
112+
const investmentsButton = page.getByText('Invest', { exact: true })
113+
await expect(investmentsButton).toBeVisible()
114+
await investmentsButton.click()
115+
}
116+
117+
const tokenButton = page.getByTestId(`token-balance-list-${token.label}`)
118+
await expect(tokenButton).toBeVisible()
119+
await tokenButton.click()
120+
const sendButton = page.getByTestId('send-quick-action')
121+
await expect(sendButton).toBeVisible()
122+
await sendButton.click()
107123

108124
// fill search input
109125
const searchInput = page.getByRole('search', { name: 'query' })
@@ -134,6 +150,7 @@ for (const token of [...coins, ethCoin]) {
134150
expect(Object.fromEntries(url.searchParams.entries())).toMatchObject({
135151
recipient: query,
136152
idType,
153+
sendToken: token.token,
137154
})
138155
}).toPass({
139156
timeout: 5000,

packages/playwright/tests/swap.onboarded.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ test("can't access form page without accepting risk dialog", async ({ page, swap
171171
await expect(async () => {
172172
const currentUrl = new URL(page.url())
173173
expect(currentUrl.pathname).toBe('/')
174-
expect(currentUrl.searchParams.toString()).toBe('')
174+
expect(currentUrl.searchParams.toString()).toBe('token=investments')
175175
}).toPass({ timeout: 5000 })
176176
})
177177

packages/snaplet/.snaplet/snaplet-client.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,4 +1086,4 @@ export interface Fingerprint {
10861086
deletedAt?: FingerprintDateField;
10871087
user?: FingerprintRelationField;
10881088
sendAccountCredentialsByCredentialId?: FingerprintRelationField;
1089-
}}
1089+
}}

0 commit comments

Comments
 (0)