Skip to content

Commit

Permalink
chore: wait for button to be enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaisailovic committed Feb 14, 2024
1 parent 90f26c0 commit 37d150f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions apps/laboratory/tests/shared/pages/WalletPage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-await-in-loop */
import type { Locator, Page } from '@playwright/test'
import { expect, type Locator, type Page } from '@playwright/test'
import { WALLET_URL } from '../constants'
import type { SessionParams } from '../types'

Expand Down Expand Up @@ -40,16 +40,20 @@ export class WalletPage {
async handleSessionProposal(opts: SessionParams) {
const variant = opts.accept ? `approve` : `reject`
// `.click` doesn't work here, so we use `.focus` and `Space`
await this.page.getByTestId(`session-${variant}-button`).isEnabled()
await this.page.getByTestId(`session-${variant}-button`).focus()
const btn = this.page.getByTestId(`session-${variant}-button`)
await btn.waitFor()
await expect(btn).toBeEnabled()
await btn.focus()
await this.page.keyboard.press('Space')
}

async handleRequest({ accept }: { accept: boolean }) {
const variant = accept ? `approve` : `reject`
// `.click` doesn't work here, so we use `.focus` and `Space`
await this.page.getByTestId(`session-${variant}-button`).isEnabled()
await this.page.getByTestId(`session-${variant}-button`).focus()
const btn = this.page.getByTestId(`session-${variant}-button`)
await btn.waitFor()
await expect(btn).toBeEnabled()
await btn.focus()
await this.page.keyboard.press('Space')
}
}

0 comments on commit 37d150f

Please sign in to comment.