Skip to content
Open
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## [Unreleased]

### Changed

- [ENGINEERS-1228] - Use multiple email addresses in B2B tests

## [2.4.2] - 2023-03-12

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Organization A - Cost Center A1 - Sales Rep Basic Scenario', () => {
b2b.OrganizationB

loginToStoreFront(
users.SalesRep,
users.SalesRepresentative,
roleObject.SalesRepresentative.role,
gmailCreds
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Organization A - Cost Center A1 - Sales Rep Impersonation Scenario', (
const impersonatedRole = ROLE_DROP_DOWN.Buyer

loginToStoreFront(
users.SalesRep,
users.SalesRepresentative,
roleObject.SalesRepresentative.role,
gmailCreds
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ describe('OrganizationA - Create a Buyer and Approver, associate Cost Center and
organizationName,
costCenter: costCenter1.name,
role: role.Buyer1,
gmailCreds,
email: users.Buyer1,
})
addUser({
organizationName,
costCenter: costCenter1.name,
role: role.Approver1,
gmailCreds,
email: users.Approver1,
})

addUser({
organizationName,
costCenter: costCenter2.name,
role: role.Buyer2,
gmailCreds,
email: users.Buyer2,
})

// Add/Delete users in costcenter1 - Hold
Expand All @@ -64,13 +64,13 @@ describe('OrganizationA - Create a Buyer and Approver, associate Cost Center and
organizationName,
costCenter: costCenter2.name,
role: role.OrganizationAdmin2,
gmailCreds,
email: users.OrganizationAdmin2,
})
addUser({
organizationName,
costCenter: costCenter2.name,
role: role.Approver2,
gmailCreds,
email: users.Approver2,
})

createQuote({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ describe('OrganizationB - Create a Buyer and Approver associate Cost Center and
organizationName,
costCenter: costCenter1.name,
role: role.Buyer1,
gmailCreds,
email: users.Buyer1,
})
addUser({
organizationName,
costCenter: costCenter1.name,
role: role.Approver1,
gmailCreds,
email: users.Approver1,
})
duplicateUserTestCase({
organizationName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('Sync Checkout UI Custom & Add Sales Users via Graphql', () => {
const roles = Object.keys(ROLE_ID_EMAIL_MAPPING)

roles.forEach((r) => {
addUserViaGraphql(gmailCreds, r)
addUserViaGraphql(users, r)
})

preserveCookie()
Expand Down
17 changes: 4 additions & 13 deletions cypress-shared/support/b2b/add_users.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,14 @@ export function addUserFn(
})
}

export function addUser({ organizationName, costCenter, role, gmailCreds }) {
export function addUser({ organizationName, costCenter, role, email }) {
const { suffixInEmail, dropDownText } = role

it(
`Adding ${dropDownText} in ${organizationName} with ${costCenter}`,
updateRetry(3),
() => {
const userName = generateName(suffixInEmail)
const email = generateEmailWithSuffix(
gmailCreds.email,
organizationName,
suffixInEmail
)

addUserFn({ userName, email, costCenter }, dropDownText)
}
Expand Down Expand Up @@ -237,14 +232,14 @@ export function updateCostCenterOftheUser({
)
}

export function addUserViaGraphql(gmailCreds, roleKey) {
export function addUserViaGraphql(users, roleKey) {
const { organizationName, costCenter1 } = b2b.OrganizationA

it(
`Adding ${roleKey} in ${organizationName} with ${costCenter1.name}`,
updateRetry(3),
() => {
const { suffixInEmail, role } = ROLE_ID_EMAIL_MAPPING[roleKey]
const { role } = ROLE_ID_EMAIL_MAPPING[roleKey]
// Define constants
const APP_NAME = 'vtex.storefront-permissions'
const APP_VERSION = '1.x'
Expand All @@ -264,11 +259,7 @@ export function addUserViaGraphql(gmailCreds, roleKey) {
orgId: organizationItems[organizationName],
costId: organizationItems[costCenter1.name],
name: generateName(role),
email: generateEmailWithSuffix(
gmailCreds.email,
organizationName,
suffixInEmail
),
email: users[roleKey],
}

expect(variables.roleId).to.not.be.undefined
Expand Down
26 changes: 20 additions & 6 deletions cypress-shared/support/b2b/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,20 @@ const ORG_A_GMAIL_CREDS = {
refreshToken: gmail.refreshToken1,
}

const ORG_A_GMAIL_CREDS3 = {
email: gmail.emailId3,
clientId: gmail.clientId3,
clientSecret: gmail.clientSecret3,
refreshToken: gmail.refreshToken3,
}

const ORG_A_GMAIL_CREDS4 = {
email: gmail.emailId4,
clientId: gmail.clientId4,
clientSecret: gmail.clientSecret4,
refreshToken: gmail.refreshToken4,
}

const ORG_B_GMAIL_CREDS = {
email: gmail.emailId2,
clientId: gmail.clientId2,
Expand Down Expand Up @@ -200,7 +214,7 @@ export default {
ROLE_DROP_DOWN_EMAIL_MAPPING.OrganizationAdmin1.suffixInEmail
),
OrganizationAdmin2: generateEmailWithSuffix(
ORG_A_GMAIL_CREDS.email,
ORG_A_GMAIL_CREDS4.email,
ORGANIZATION_A,
ROLE_DROP_DOWN_EMAIL_MAPPING.OrganizationAdmin2.suffixInEmail
),
Expand All @@ -210,7 +224,7 @@ export default {
ROLE_DROP_DOWN_EMAIL_MAPPING.Buyer1.suffixInEmail
),
Buyer2: generateEmailWithSuffix(
ORG_A_GMAIL_CREDS.email,
ORG_A_GMAIL_CREDS3.email,
ORGANIZATION_A,
ROLE_DROP_DOWN_EMAIL_MAPPING.Buyer2.suffixInEmail
),
Expand All @@ -230,7 +244,7 @@ export default {
ROLE_DROP_DOWN_EMAIL_MAPPING.Approver1.suffixInEmail
),
Approver2: generateEmailWithSuffix(
ORG_A_GMAIL_CREDS.email,
ORG_A_GMAIL_CREDS3.email,
ORGANIZATION_A,
ROLE_DROP_DOWN_EMAIL_MAPPING.Approver2.suffixInEmail
),
Expand All @@ -239,18 +253,18 @@ export default {
ORGANIZATION_A,
ROLE_DROP_DOWN_EMAIL_MAPPING.Approver3.suffixInEmail
),
SalesRep: generateEmailWithSuffix(
SalesRepresentative: generateEmailWithSuffix(
ORG_A_GMAIL_CREDS.email,
ORGANIZATION_A,
ROLE_ID_EMAIL_MAPPING.SalesRepresentative.suffixInEmail
),
SalesAdmin: generateEmailWithSuffix(
ORG_A_GMAIL_CREDS.email,
ORG_B_GMAIL_CREDS.email,
ORGANIZATION_A,
ROLE_ID_EMAIL_MAPPING.SalesAdmin.suffixInEmail
),
SalesManager: generateEmailWithSuffix(
ORG_A_GMAIL_CREDS.email,
ORG_A_GMAIL_CREDS4.email,
ORGANIZATION_A,
ROLE_ID_EMAIL_MAPPING.SalesManager.suffixInEmail
),
Expand Down
2 changes: 1 addition & 1 deletion cypress-shared/support/b2b/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function storeUserCookie(email) {

export function loginToStoreFront(email, role, gmailCreds) {
it(
`Logging in to storefront as ${role}`,
`Logging in to storefront as ${role} with email - ${email}`,
{ defaultCommandTimeout: 60000, retries: 1 },
() => {
cy.qe(`Logging in to storefront as ${role}`)
Expand Down
1 change: 1 addition & 0 deletions cypress-shared/support/b2b/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const OTHER_ROLES = [
]

export const ROLE_ID_EMAIL_MAPPING = {
// Below Roles should match with users roles in b2b/constants.js
SalesAdmin: { role: OTHER_ROLES[0], suffixInEmail: 'sa' },
SalesRepresentative: { role: OTHER_ROLES[1], suffixInEmail: 'sr' },
SalesManager: { role: OTHER_ROLES[2], suffixInEmail: 'sm' },
Expand Down