Skip to content

chore: adds dynamic locator and element getters in the modal validator #4223

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

ganchoradkov
Copy link
Member

Description

Added locator & element getters that try to get an element from the page every n ms until a timeout is hit rather than once

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Associated Issues

For Linear issues: Closes APKT-xxx
For GH issues: closes #...

Showcase (Optional)

If there is a UI change include the screenshots with before and after state.
If new feature is being introduced, include the link to demo recording.

Checklist

  • Code in this PR is covered by automated tests (Unit tests, E2E tests)
  • My changes generate no new warnings
  • I have reviewed my own code
  • I have filled out all required sections
  • I have tested my changes on the preview link
  • Approver of this PR confirms that the changes are tested on the preview link

Copy link

changeset-bot bot commented Apr 16, 2025

⚠️ No Changeset found

Latest commit: 38f4f60

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Apr 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
appkit-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2025 1:34pm
appkit-laboratory ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2025 1:34pm
11 Skipped Deployments
Name Status Preview Comments Updated (UTC)
appkit-basic-ep ⬜️ Ignored (Inspect) Apr 24, 2025 1:34pm
appkit-basic-example ⬜️ Ignored (Inspect) Apr 24, 2025 1:34pm
appkit-basic-sign-client-example ⬜️ Ignored (Inspect) Apr 24, 2025 1:34pm
appkit-basic-up-example ⬜️ Ignored (Inspect) Apr 24, 2025 1:34pm
appkit-ethers5-bera ⬜️ Ignored (Inspect) Apr 24, 2025 1:34pm
appkit-nansen-demo ⬜️ Ignored (Inspect) Apr 24, 2025 1:34pm
appkit-vue-solana ⬜️ Ignored (Inspect) Apr 24, 2025 1:34pm
appkit-wagmi-cdn-example ⬜️ Ignored (Inspect) Apr 24, 2025 1:34pm
ethereum-provider-wagmi-example ⬜️ Ignored (Inspect) Apr 24, 2025 1:34pm
next-wagmi-solana-bitcoin-example ⬜️ Ignored (Inspect) Apr 24, 2025 1:34pm
vue-wagmi-example ⬜️ Ignored (Inspect) Apr 24, 2025 1:34pm

Copy link
Contributor

github-actions bot commented Apr 16, 2025

Warnings
⚠️ File apps/laboratory/tests/shared/validators/ModalValidator.ts contains a KEY or SECRET
⚠️ File packages/controllers/src/controllers/ModalController.ts contains a KEY or SECRET

Generated by 🚫 dangerJS against 38f4f60

Comment on lines 18 to 42
async getLocator(selector: string, timeout = 5000, interval = 500): Promise<Locator> {
const start = Date.now()
while (Date.now() - start < timeout) {
const element = this.page.locator(selector)
if (element) {
return element
}
// eslint-disable-next-line no-await-in-loop
await this.page.waitForTimeout(interval) // Wait before rechecking
}
throw new Error(`Element ${selector} did not become visible within ${timeout}ms`)
}

async getByTestId(testId: string | RegExp, timeout = 5000, interval = 500): Promise<Locator> {
const start = Date.now()
while (Date.now() - start < timeout) {
const element = this.page.getByTestId(testId)
if (element) {
return element
}
// eslint-disable-next-line no-await-in-loop
await this.page.waitForTimeout(interval) // Wait before rechecking
}
throw new Error(
`Element with data-testid="${testId}" did not become visible within ${timeout}ms`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make a utils like getElement or something that has the timing part of these?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdym? to move these into the shared/utils?

Copy link
Contributor

github-actions bot commented Apr 16, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 74.8% 25362 / 33904
🔵 Statements 74.8% 25362 / 33904
🔵 Functions 66.22% 2141 / 3233
🔵 Branches 83.25% 4912 / 5900
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/controllers/src/controllers/ModalController.ts 93.96% 93.87% 84.61% 93.96% 64-65, 86-90
Generated in workflow #11303 for commit 38f4f60 by the Vitest Coverage Report Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants