Skip to content

Commit

Permalink
fix: Check if primary and secondary users exist
Browse files Browse the repository at this point in the history
  • Loading branch information
fleks-dev committed Dec 14, 2023
1 parent fce1738 commit 7c9d810
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions templates/cypress/support/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,31 @@ const localUsers = localUsersFile && localUsersFile[env];
// eg. test@gmail.com -> [email protected]
// tmpUsers.primary.email = tmpUsers.primary.email.replace('@', `+${Math.floor(Math.random() * 1000)}@`)

tmpUsers.primary.name = (
Cypress.env('PRIMARY_USER') ||
(localUsers && localUsers.primary.name) ||
tmpUsers.primary.name
).toLowerCase();
if (tmpUsers.primary) {
tmpUsers.primary.name = (
Cypress.env('PRIMARY_USER') ||
(localUsers && localUsers.primary && localUsers.primary.name) ||
(tmpUsers.primary && tmpUsers.primary.name)
).toLowerCase()

tmpUsers.secondary.name = (
Cypress.env('SECONDARY_USER') ||
(localUsers && localUsers.secondary.name) ||
tmpUsers.secondary.name
).toLowerCase();
tmpUsers.primary.password =
Cypress.env('PRIMARY_USER_PW') ||
(localUsers && localUsers.primary && localUsers.primary.password) ||
(tmpUsers.primary && tmpUsers.primary.password)
}

tmpUsers.primary.password =
Cypress.env('PRIMARY_USER_PW') || (localUsers && localUsers.primary.password) || tmpUsers.primary.password;
if (tmpUsers.secondary) {
tmpUsers.secondary.name = (
Cypress.env('SECONDARY_USER') ||
(localUsers && localUsers.secondary && localUsers.secondary.name) ||
(tmpUsers.secondary && tmpUsers.secondary.name)
).toLowerCase()

tmpUsers.secondary.password =
Cypress.env('SECONDARY_USER_PW') || (localUsers && localUsers.secondary.password) || tmpUsers.secondary.password;
tmpUsers.secondary.password =
Cypress.env('SECONDARY_USER_PW') ||
(localUsers && localUsers.secondary && localUsers.secondary.password) ||
(tmpUsers.secondary && tmpUsers.secondary.password)
}

export const users = tmpUsers

Expand Down

0 comments on commit 7c9d810

Please sign in to comment.