Skip to content

Commit

Permalink
Merge pull request #1681 from IntersectMBO/refactor/username-format
Browse files Browse the repository at this point in the history
Ensure Username Uniqueness by Appending Timestamp
  • Loading branch information
kneerose authored Aug 6, 2024
2 parents 4ee15a2 + 239bb4e commit cfd5b11
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
3 changes: 2 additions & 1 deletion tests/govtool-frontend/playwright/lib/_mock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ export const invalid = {

export const valid = {
username: () => {
let username = faker.internet.userName().toLowerCase();
let timeStamp = Date.now();
let username = `${faker.internet.userName().toLowerCase()}_${timeStamp}`;

// Remove any invalid characters
username = username.replace(/[^a-z0-9._]/g, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ test.describe("Temporary user", () => {

test("6K. Should accept valid username.", async () => {
for (let i = 0; i < 100; i++) {
await userPage
.getByTestId("username-input")
.fill(mockValid.username().toLowerCase());
await userPage.getByTestId("username-input").fill(mockValid.username());

await expect(
userPage.getByTestId("username-error-text")
Expand All @@ -152,9 +150,7 @@ test.describe("Temporary user", () => {

test("6L. Should reject invalid username.", async () => {
for (let i = 0; i < 100; i++) {
await userPage
.getByTestId("username-input")
.fill(mockInvalid.username().toLowerCase());
await userPage.getByTestId("username-input").fill(mockInvalid.username());

await expect(userPage.getByTestId("username-error-text")).toBeVisible();
await expect(userPage.getByTestId("proceed-button")).toBeDisabled();
Expand Down

0 comments on commit cfd5b11

Please sign in to comment.