From cef65d2639fe23b34e96db43921ec8c7deb73deb Mon Sep 17 00:00:00 2001 From: Syed-Vtex Date: Thu, 23 Mar 2023 13:05:44 +0530 Subject: [PATCH 1/2] Use multiple email addresses in B2B tests --- CHANGELOG.md | 4 ++++ ...2-add_buyer_approver_organizationA.spec.js | 10 ++++---- ...3-add_buyer_approver_organizationB.spec.js | 4 ++-- cypress-shared/support/b2b/add_users.js | 7 +----- cypress-shared/support/b2b/constants.js | 24 +++++++++++++++---- 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 047f48ab..559230c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## [Unreleased] +### Changed + +- [ENGINEERS-1228] - Use multiple email addresses in B2B tests + ## [2.4.2] - 2023-03-12 ### Changed diff --git a/cypress-shared/integration/b2b/2.2.2-add_buyer_approver_organizationA.spec.js b/cypress-shared/integration/b2b/2.2.2-add_buyer_approver_organizationA.spec.js index 57cf03fd..82f04508 100644 --- a/cypress-shared/integration/b2b/2.2.2-add_buyer_approver_organizationA.spec.js +++ b/cypress-shared/integration/b2b/2.2.2-add_buyer_approver_organizationA.spec.js @@ -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 @@ -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({ diff --git a/cypress-shared/integration/b2b/2.3-add_buyer_approver_organizationB.spec.js b/cypress-shared/integration/b2b/2.3-add_buyer_approver_organizationB.spec.js index fb601a76..0caa7825 100644 --- a/cypress-shared/integration/b2b/2.3-add_buyer_approver_organizationB.spec.js +++ b/cypress-shared/integration/b2b/2.3-add_buyer_approver_organizationB.spec.js @@ -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, diff --git a/cypress-shared/support/b2b/add_users.js b/cypress-shared/support/b2b/add_users.js index d99e91f3..047a5154 100644 --- a/cypress-shared/support/b2b/add_users.js +++ b/cypress-shared/support/b2b/add_users.js @@ -43,7 +43,7 @@ export function addUserFn( }) } -export function addUser({ organizationName, costCenter, role, gmailCreds }) { +export function addUser({ organizationName, costCenter, role, email }) { const { suffixInEmail, dropDownText } = role it( @@ -51,11 +51,6 @@ export function addUser({ organizationName, costCenter, role, gmailCreds }) { updateRetry(3), () => { const userName = generateName(suffixInEmail) - const email = generateEmailWithSuffix( - gmailCreds.email, - organizationName, - suffixInEmail - ) addUserFn({ userName, email, costCenter }, dropDownText) } diff --git a/cypress-shared/support/b2b/constants.js b/cypress-shared/support/b2b/constants.js index b3543b62..05e1872e 100644 --- a/cypress-shared/support/b2b/constants.js +++ b/cypress-shared/support/b2b/constants.js @@ -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, @@ -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 ), @@ -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 ), @@ -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 ), @@ -245,12 +259,12 @@ export default { 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 ), From 6f2e9d113803c446fd630b7ba153add7dc24f629 Mon Sep 17 00:00:00 2001 From: Syed-Vtex Date: Thu, 23 Mar 2023 17:11:19 +0530 Subject: [PATCH 2/2] Fix sales user testcase --- .../integration/b2b/2.14.1-sales_rep_scenarios.spec.js | 2 +- .../integration/b2b/2.14.2-sales_rep_scenarios.spec.js | 2 +- .../integration/b2b/2.4.1-add-remaining-users.spec.js | 2 +- cypress-shared/support/b2b/add_users.js | 10 +++------- cypress-shared/support/b2b/constants.js | 2 +- cypress-shared/support/b2b/login.js | 2 +- cypress-shared/support/b2b/utils.js | 1 + 7 files changed, 9 insertions(+), 12 deletions(-) diff --git a/cypress-shared/integration/b2b/2.14.1-sales_rep_scenarios.spec.js b/cypress-shared/integration/b2b/2.14.1-sales_rep_scenarios.spec.js index 69cb2fb2..ea5965cb 100644 --- a/cypress-shared/integration/b2b/2.14.1-sales_rep_scenarios.spec.js +++ b/cypress-shared/integration/b2b/2.14.1-sales_rep_scenarios.spec.js @@ -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 ) diff --git a/cypress-shared/integration/b2b/2.14.2-sales_rep_scenarios.spec.js b/cypress-shared/integration/b2b/2.14.2-sales_rep_scenarios.spec.js index 10a15c2d..da3604d0 100644 --- a/cypress-shared/integration/b2b/2.14.2-sales_rep_scenarios.spec.js +++ b/cypress-shared/integration/b2b/2.14.2-sales_rep_scenarios.spec.js @@ -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 ) diff --git a/cypress-shared/integration/b2b/2.4.1-add-remaining-users.spec.js b/cypress-shared/integration/b2b/2.4.1-add-remaining-users.spec.js index 5758bee9..fb33c14c 100644 --- a/cypress-shared/integration/b2b/2.4.1-add-remaining-users.spec.js +++ b/cypress-shared/integration/b2b/2.4.1-add-remaining-users.spec.js @@ -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() diff --git a/cypress-shared/support/b2b/add_users.js b/cypress-shared/support/b2b/add_users.js index 047a5154..478363a3 100644 --- a/cypress-shared/support/b2b/add_users.js +++ b/cypress-shared/support/b2b/add_users.js @@ -232,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' @@ -259,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 diff --git a/cypress-shared/support/b2b/constants.js b/cypress-shared/support/b2b/constants.js index 05e1872e..34a863a6 100644 --- a/cypress-shared/support/b2b/constants.js +++ b/cypress-shared/support/b2b/constants.js @@ -253,7 +253,7 @@ 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 diff --git a/cypress-shared/support/b2b/login.js b/cypress-shared/support/b2b/login.js index 1bb15fd6..50279ba1 100644 --- a/cypress-shared/support/b2b/login.js +++ b/cypress-shared/support/b2b/login.js @@ -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}`) diff --git a/cypress-shared/support/b2b/utils.js b/cypress-shared/support/b2b/utils.js index 1ada1bb6..72d98d6e 100644 --- a/cypress-shared/support/b2b/utils.js +++ b/cypress-shared/support/b2b/utils.js @@ -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' },