Skip to content

added tests to check username availability#642

Open
roseb89 wants to merge 2 commits intomainfrom
SWIS-408/a11y-test-check-username
Open

added tests to check username availability#642
roseb89 wants to merge 2 commits intomainfrom
SWIS-408/a11y-test-check-username

Conversation

@roseb89
Copy link
Copy Markdown
Collaborator

@roseb89 roseb89 commented Apr 1, 2026

Description

Tickets:

  • SWIS-408
  • Added two accessibility tests to check username availability. One test to test against a used username and one test to check against an available username

Motivation and Context

How Has This Been Tested?

Checklist:

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nypl-library-card-app Ready Ready Preview, Comment Apr 1, 2026 5:22pm

Request Review

@roseb89 roseb89 requested review from Toxiapo, clarissarichard, milliesavalia and russellcullen and removed request for clarissarichard April 1, 2026 18:02
@roseb89 roseb89 marked this pull request as ready for review April 1, 2026 18:03
await page.keyboard.press("Tab");
await expect(accountPage.availableUsernameButton).toBeFocused();
await accountPage.availableUsernameButton.press("Enter");
await expect(accountPage.availableUsernameMessage).toBeVisible();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Where is the focus expected to be after the "username is available" message is displayed?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The focus should jump back to the input field. We should also add this behavior to the unavailable test.

await page.keyboard.press("Tab");
await expect(accountPage.availableUsernameButton).toBeFocused();
await accountPage.availableUsernameButton.press("Enter");
await expect(accountPage.unavailableUsernameMessage).toBeVisible();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would it make sense to mock the username availability like we have in account.spec.ts and just confirm the focus is correct in this test?

/* Tests existing username rejection.
Account is temporary; username availability reset expected in 30 days. */
export const USED_USER_NAME = "tester";
export const AVAILABLE_USER_NAME = "testuser";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

How do we know this username is available?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'd setup this username yesterday. I’m considering deleting it and re-registering via the NYC flow to test its longevity beyond 30 days, though I'm unsure of Sierra’s database flush frequency. The AVAILABLE_USER_NAME is available because this is not a full end-to-end with application submission. It's only the account's page.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think mocking the username would eliminate the need for this process. Thoughts on trying that?

Copy link
Copy Markdown
Collaborator Author

@roseb89 roseb89 Apr 2, 2026

Choose a reason for hiding this comment

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

I think mocking the username would eliminate the need for this process. Thoughts on trying that?

The first approach of having the real check username endpoint enabled is preferred but I will defer to the mock approach since the user name changes will cause this test to be brittle.

Copy link
Copy Markdown
Collaborator

@russellcullen russellcullen Apr 2, 2026

Choose a reason for hiding this comment

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

The first approach of having the real check username endpoint enabled is preferred

I'm curious, why is that approach preferred in this context?

Copy link
Copy Markdown
Collaborator Author

@roseb89 roseb89 Apr 2, 2026

Choose a reason for hiding this comment

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

For this particular context, do we feel like using the real username availability API will change what we're testing from an accessibility point of view?

I'm not sure if the mock is going to catch this defect. Since, the tests I'm writing is in response to this ticket. https://newyorkpubliclibrary.atlassian.net/browse/SWIS-366

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I guess to dig a little further -- what about mocking would make this defect/test in particular behave different? If that's the only concern, maybe it makes sense to try it out to validate or disprove our assumptions? I am trying to understand our concerns and testing methodologies here is all

Copy link
Copy Markdown
Collaborator Author

@roseb89 roseb89 Apr 2, 2026

Choose a reason for hiding this comment

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

\

I guess to dig a little further -- what about mocking would make this defect/test in particular behave different? If that's the only concern, maybe it makes sense to try it out to validate or disprove our assumptions? I am trying to understand our concerns and testing methodologies here is all

My existing Accessibility UI tests do not use mocks, but the live environment. @clarissarichard propose a mock solution twice in this PR. Since, that wasn't my original approach, I have to "dig a littler further" to explain my reasonings on using the real live approach to validate or disapprove of a suggested mock strategy that may or may not be the best solution.

Copy link
Copy Markdown
Collaborator

@russellcullen russellcullen Apr 2, 2026

Choose a reason for hiding this comment

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

That makes total sense. I definitely didn't mean to add extra cycles to your plate -- I’m just interested in the tradeoffs since we have two different patterns being discussed. Understanding your reasoning for sticking with the live environment and concerns with mocking helps us all align on the best methodology for these a11y tests moving forward

Copy link
Copy Markdown
Collaborator Author

@roseb89 roseb89 Apr 3, 2026

Choose a reason for hiding this comment

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

I appreciate the deep dive. It was a valuable exercise to align on these A11y best practices, and I’m glad we could clarify why the live environment is necessary to catch these specific focus-loss defects. It gives us a much stronger methodology for these types of tests moving forward.

@roseb89
Copy link
Copy Markdown
Collaborator Author

roseb89 commented Apr 2, 2026

@russellcullen @Toxiapo @clarissarichard

I spoke with Antonio, and he confirmed that our test accounts in DEV/QA are persistent and last indefinitely. They are only flushed during major upgrades or the annual production data backfill/merge or when we delete them manually or through our automated Sierra e2e tests.

Given this stability, the Live Environment remains the most reliable way to test the SWIS-366 focus-loss defect without masking the issue through an instant mock. Since the maintenance overhead is minimal (occurring roughly once a year), I’d like to move forward with the live-integration approach to ensure maximum A11y coverage

@roseb89
Copy link
Copy Markdown
Collaborator Author

roseb89 commented Apr 2, 2026

@russellcullen @Toxiapo @clarissarichard

To clarify the mock vs. live-environment choice: focus-management is highly sensitive to network timing and dynamic rendering.

Using a mock provides an 'instant' response that can create an artificial success state, effectively masking the focus-loss issues that occur during the loading window in the real world. Testing in the live environment ensures we are capturing the full page context—verifying that focus doesn't unexpectedly jump to other components while the username check is "in-flight.

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.

4 participants