Skip to content

Commit

Permalink
Add e2e test for registration tracking event on registerName
Browse files Browse the repository at this point in the history
  • Loading branch information
nhohb committed Sep 6, 2024
1 parent 5a7ceca commit 95adbe7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions e2e/specs/stateless/registerName.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import {
* get stuck looking for the complete button
*/

const chain = 'localhost'
const trackEventPrefix = 'Event triggered on local development'

test.describe.serial('normal registration', () => {
const name = `registration-normal-${Date.now()}.eth`

Expand All @@ -36,6 +39,16 @@ test.describe.serial('normal registration', () => {
account: createAccounts().getAddress('user') as `0x${string}`,
})

const events: string[] = []

page.on('console', (msg) => {
const message = msg.text()

if (message.includes(trackEventPrefix)) {
events.push(message.replace(trackEventPrefix, '').trim())
}
})

const homePage = makePageObject('HomePage')
const registrationPage = makePageObject('RegistrationPage')
const transactionModal = makePageObject('TransactionModal')
Expand All @@ -44,11 +57,18 @@ test.describe.serial('normal registration', () => {

await homePage.goto()
await login.connect()
await expect(events).toContain(JSON.stringify({ type: 'home_page', chain }))

// should redirect to registration page
await homePage.searchInput.fill(name)
await homePage.searchInput.press('Enter')
await expect(events).toContain(
JSON.stringify({ type: 'start_searching', chain, props: { keyword: name } }),
)
await expect(page.getByRole('heading', { name: `Register ${name}` })).toBeVisible()
await expect(events).toContain(
JSON.stringify({ type: 'search_selected', chain, props: { keyword: name } }),
)

// should have payment choice ethereum checked and show primary name setting as checked
await expect(page.getByTestId('payment-choice-ethereum')).toBeChecked()
Expand Down

0 comments on commit 95adbe7

Please sign in to comment.