Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve account name selection flow #3068

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .changeset/hot-shoes-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@reown/appkit-scaffold-ui': patch
'@apps/laboratory': patch
'@apps/demo': patch
'@apps/gallery': patch
'@reown/appkit-adapter-ethers': patch
'@reown/appkit-adapter-ethers5': patch
'@reown/appkit-adapter-polkadot': patch
'@reown/appkit-adapter-solana': patch
'@reown/appkit-adapter-wagmi': patch
'@reown/appkit': patch
'@reown/appkit-utils': patch
'@reown/appkit-cdn': patch
'@reown/appkit-common': patch
'@reown/appkit-core': patch
'@reown/appkit-experimental': patch
'@reown/appkit-polyfills': patch
'@reown/appkit-siwe': patch
'@reown/appkit-ui': patch
'@reown/appkit-wallet': patch
---

Improved account name selection flow
6 changes: 6 additions & 0 deletions apps/laboratory/tests/shared/pages/ModalWalletPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ export class ModalWalletPage extends ModalPage {
await this.page.getByRole('button', { name: 'Choose Name' }).click()
}

async clickAccountName(name: string) {
const suggestion = this.page.getByTestId('account-name-suggestion').getByText(name)
await expect(suggestion).toBeVisible()
await suggestion.click()
}

async typeName(name: string) {
await this.page.getByTestId('wui-ens-input').getByTestId('wui-input-text').fill(name)
}
Expand Down
22 changes: 22 additions & 0 deletions apps/laboratory/tests/shared/validators/ModalValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,28 @@ export class ModalValidator {
await expect(suggestion).toBeVisible()
}

async expectHeaderText(text: string) {
const headerText = this.page.getByTestId('w3m-header-text')
await expect(headerText).toHaveText(text)
}

async expectSignatureRequestFrameByText(headerText: string) {
await expect(
this.page.frameLocator('#w3m-iframe').getByText(headerText),
'AppKit iframe should be visible'
).toBeVisible({
timeout: 10000
})
await this.page.waitForTimeout(500)
}

async expectAccountNameApproveTransaction(name: string) {
await this.expectSignatureRequestFrameByText('requests a signature')
const iframe = this.page.frameLocator('#w3m-iframe')
const textContent = await iframe.locator('.textContent').textContent()
expect(textContent).toContain(`{"name":"${name}","attributes":{},"timestamp":`)
}

async expectCallStatusSuccessOrRetry(sendCallsId: string, allowedRetry: boolean) {
const callStatusReceipt = this.page.getByText('"status": "CONFIRMED"')
const isConfirmed = await callStatusReceipt.isVisible({
Expand Down
3 changes: 3 additions & 0 deletions apps/laboratory/tests/wallet-features.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,8 @@ walletFeaturesTest('it should find account name as expected', async () => {
await page.openChooseName()
await page.typeName('test-ens-check')
await validator.expectAccountNameFound('test-ens-check')
await page.clickAccountName('test-ens-check')
await validator.expectHeaderText('Approve Transaction')
await validator.expectAccountNameApproveTransaction('test-ens-check.reown.id')
await page.closeModal()
})
4 changes: 3 additions & 1 deletion packages/scaffold-ui/src/partials/w3m-header/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ export class W3mHeader extends LitElement {
alignItems="center"
gap="xs"
>
<wui-text variant="paragraph-700" color="fg-100">${this.headerText}</wui-text>
<wui-text variant="paragraph-700" color="fg-100" data-testid="w3m-header-text"
>${this.headerText}</wui-text
>
${isBeta ? html`<wui-tag variant="main">Beta</wui-tag>` : null}
</wui-flex>
`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export class W3mRegisterAccountNameView extends LitElement {
.padding=${['m', 'm', 'm', 'm'] as const}
justifyContent="space-between"
class="suggestion"
@click=${this.onSubmitName.bind(this)}
>
<wui-text color="fg-100" variant="paragraph-400" class="suggested-name">
${this.name}</wui-text
Expand Down
Loading