id
stringlengths 12
53
| messages
listlengths 3
3
|
|---|---|
code_cy-runner_19cc6cd2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/fedex-shipping/2.12-surcharge-flat-rate-and-surcharge-percentage.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/no-conditional-expect */\n/* eslint-disable jest/valid-expect */\n/* eslint-disable jest/valid-expect-in-promise */\n/* eslint-disable jest/expect-expect */\nimport { loginViaCookies, updateRetry } from '../../support/common/support.js'\nimport { appSetting } from '../../support/fedex-shipping/outputvalidation'\nimport { data } from '../../fixtures/fedex-shipping-fixtures/shippingRatePayload.json'\nimport { updateSLASettings } from '../../support/fedex-shipping/common.js'\nimport {\n loadCalculateShippingAPI,\n validateCalculateShipping,\n} from '../../support/fedex-shipping/api_testcase.js'\n\nconst prefix = 'Update SLA - Surcharge Flat Rate & Surcharge Percentage'\nlet shippingMethods = []\nconst surchargeFlatRate = 10\nconst surchargePercent = 15\n\ndescribe(`${prefix} Scenarios`, () => {\n loginViaCookies()\n\n it(\n `${prefix} - Update Surcharge Flat Rate and Surcharge Percentage`,\n updateRetry(3),\n () => {\n updateSLASettings(appSetting)\n }\n )\n\n it(`${prefix} - Verify single product shipping price`, updateRetry(3), () => {\n loadCalculateShippingAPI(data).then((response) => {\n validateCalculateShipping(response)\n shippingMethods = response.body\n })\n })\n\n it(\n ` ${prefix} - Update Surcharge Flat Rate and Surcharge Percentage`,\n updateRetry(3),\n () => {\n updateSLASettings(appSetting, surchargeFlatRate, surchargePercent)\n }\n )\n\n it(`${prefix} - Validate Surcharge Changes`, updateRetry(3), () => {\n loadCalculateShippingAPI(data).then((response) => {\n validateCalculateShipping(response)\n\n shippingMethods.forEach((shippingMethod) => {\n response.body.forEach((res) => {\n // eslint-disable-next-line vtex/prefer-early-return\n if (res.shippingMethod === shippingMethod.shippingMethod) {\n const percentage = (shippingMethod.price * surchargePercent) / 100\n const rate = shippingMethod.price + surchargeFlatRate\n const total = percentage + rate\n\n expect(parseFloat(res.price.toFixed(2))).to.equal(\n parseFloat(total.toFixed(2))\n )\n }\n })\n })\n })\n })\n})\n\n```"
}
] |
code_cy-runner_0522e1d1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/fedex-shipping/2.13-verify-fedex-supported-non-supported-countries.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/no-disabled-tests */\n/* eslint-disable jest/expect-expect */\nimport {\n updateRetry,\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport { data } from '../../fixtures/fedex-shipping-fixtures/shippingRatePayload.json'\nimport {\n loadCalculateShippingAPI,\n validateCalculateShipping,\n validateCustomDeliveryTime,\n validateNonSupportedCountryCalculateShipping,\n} from '../../support/fedex-shipping/api_testcase.js'\n\ndescribe('Verify fedex shipping price for Kuwait and verify custom delivery time', () => {\n loginViaCookies()\n\n it(\n `Verify shipping price for fedex supported country Kuwait`,\n updateRetry(5),\n () => {\n data.destination.city = 'Kuwait City'\n data.destination.country = 'KWT'\n data.destination.zipCode = '72303'\n loadCalculateShippingAPI(data, validateCalculateShipping)\n }\n )\n\n it(\n `Verify shipping price for fedex non supported country India`,\n updateRetry(5),\n () => {\n data.destination.state = 'TamilNadu'\n data.destination.city = 'Chennai'\n data.destination.country = 'IND'\n data.destination.zipCode = '600079'\n loadCalculateShippingAPI(\n data,\n validateNonSupportedCountryCalculateShipping\n )\n }\n )\n\n it(`Verify custom delivery time`, updateRetry(4), () => {\n data.destination.state = null\n data.destination.city = null\n data.destination.zipCode = '00010002'\n data.destination.country = 'USA'\n loadCalculateShippingAPI(data, validateCustomDeliveryTime)\n })\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_7131f5ed
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/fedex-shipping/2.4-multi-product-scenarios.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/no-conditional-expect */\n/* eslint-disable jest/expect-expect */\n/* eslint-disable jest/valid-expect */\n/* eslint-disable jest/valid-expect-in-promise */\nimport { loginViaCookies, updateRetry } from '../../support/common/support.js'\nimport { multiProduct } from '../../support/fedex-shipping/outputvalidation.js'\nimport { data } from '../../fixtures/fedex-shipping-fixtures/multiProductPayload.json'\nimport {\n loadCalculateShippingAPI,\n validateCalculateShipping,\n} from '../../support/fedex-shipping/api_testcase.js'\n\nconst { prefix } = multiProduct\nlet shippingMethods = []\n\ndescribe(`${prefix} Scenarios`, () => {\n loginViaCookies()\n\n it(`${prefix} - Verify multi product shipping price`, updateRetry(3), () => {\n loadCalculateShippingAPI(data).then((response) => {\n validateCalculateShipping(response)\n shippingMethods = response.body\n })\n })\n\n it(\n `${prefix} - Set product quantity to 2 and verify shipping price via API`,\n updateRetry(3),\n () => {\n data.items[1].quantity = 2\n loadCalculateShippingAPI(data).then((response) => {\n validateCalculateShipping(response)\n shippingMethods.forEach((shippingMethod) => {\n response.body.forEach((res) => {\n if (\n res.shippingMethod === shippingMethod.shippingMethod &&\n res.numberOfPackages === 2\n ) {\n expect(shippingMethod.shippingMethod).to.equal(res.shippingMethod)\n\n expect(parseFloat(res.price.toFixed(2))).to.equal(\n shippingMethod.price * 2\n )\n }\n })\n })\n })\n }\n )\n})\n\n```"
}
] |
code_cy-runner_58e51d3e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/fedex-shipping/2.1-graphql.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/expect-expect */\nimport {\n updateRetry,\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support'\nimport {\n getAppSettings,\n validateGetAppSettingsResponse,\n getDocks,\n validateGetDockConnectionResponse,\n saveAppSetting,\n validateSaveAppSettingResponse,\n updateDockConnection,\n validateUpdateDockConnectionResponse,\n verifyInventoryIsUnlimitedForFedexWareHouse,\n validateInventory,\n loadingDock,\n verifyDockisActive,\n warehouse,\n validateWareHouseIsActiveAndLinkedWithDocks,\n} from '../../support/fedex-shipping/graphql_testcase'\nimport {\n appSetting,\n docks,\n warehouseId,\n Apache2020SkuId,\n Amacsa2020SkuId,\n} from '../../support/fedex-shipping/outputvalidation'\nimport {\n FEDEX_SHIPPING_APP,\n INVENTORY_GRAPHQL_APP,\n LOGISTICS_CARRIER_GRAPHQL_APP,\n} from '../../support/fedex-shipping/graphql_apps'\nimport { graphql } from '../../support/common/graphql_utils'\n\nconst prefix = 'Graphql testcase'\n\ndescribe('FedEx GraphQL Validation', () => {\n loginViaCookies()\n\n it(`${prefix} - Get App Settings`, updateRetry(2), () => {\n cy.visit('/')\n graphql(FEDEX_SHIPPING_APP, getAppSettings(), (response) => {\n validateGetAppSettingsResponse(response)\n cy.setAppSettingstoJSON('config', response.body)\n })\n })\n\n it(`${prefix} - save App Settings`, updateRetry(2), () => {\n graphql(\n FEDEX_SHIPPING_APP,\n saveAppSetting(appSetting),\n validateSaveAppSettingResponse\n )\n })\n\n it('Get userAuthCookie and set cookie', updateRetry(2), () => {\n cy.qe('Getting user auth cookie and setting cookie')\n cy.getVtexItems().then((vtex) => {\n const cookieName = vtex.userAuthCookieName\n\n cy.getCookie(cookieName).then(({ value }) => {\n cy.setAppSettingstoJSON(cookieName, value)\n })\n })\n })\n\n it(`${prefix} - Update Dock Connection`, updateRetry(2), () => {\n for (const { id } of Object.values(docks)) {\n graphql(\n FEDEX_SHIPPING_APP,\n updateDockConnection(id, false),\n validateUpdateDockConnectionResponse\n )\n }\n })\n\n it(`${prefix} - Get Docks`, updateRetry(2), () => {\n graphql(\n FEDEX_SHIPPING_APP,\n getDocks(),\n validateGetDockConnectionResponse,\n Object.values(docks)\n )\n })\n\n it(`Verify by UI - Test Credentials`, () => {\n cy.qe('Visit admin fedex-shipping page')\n cy.visit('/admin/app/fedex-shipping')\n cy.get('#meter').should('be.visible').should('not.have.value', '')\n cy.qe(\"To verify test credentials click on 'Test Credentials' button\")\n cy.contains('Test Credentials').should('be.visible').click()\n cy.qe(\"Once tested,it will show 'Success' popup\")\n cy.contains('Success')\n })\n\n it(`${prefix} - For fedex docks, verify inventory is set to infinite`, () => {\n graphql(\n INVENTORY_GRAPHQL_APP,\n verifyInventoryIsUnlimitedForFedexWareHouse(warehouseId, Apache2020SkuId),\n validateInventory\n )\n graphql(\n INVENTORY_GRAPHQL_APP,\n verifyInventoryIsUnlimitedForFedexWareHouse(warehouseId, Amacsa2020SkuId),\n validateInventory\n )\n })\n\n it(`${prefix} - Fedex docks should be active`, () => {\n for (const { id } of Object.values(docks)) {\n graphql(\n LOGISTICS_CARRIER_GRAPHQL_APP,\n loadingDock(id),\n verifyDockisActive\n )\n }\n })\n\n it(`${prefix} - Fedex warehouse should be active and linked with fedex docks`, () => {\n graphql(\n LOGISTICS_CARRIER_GRAPHQL_APP,\n warehouse(warehouseId),\n validateWareHouseIsActiveAndLinkedWithDocks,\n Object.values(docks)\n )\n })\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_14471b2b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/fedex-shipping/2.9-validate-shipping-from-different-origins.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/valid-expect */\n/* eslint-disable jest/valid-expect-in-promise */\n/* eslint-disable jest/expect-expect */\nimport { loginViaCookies, updateRetry } from '../../support/common/support.js'\nimport { data } from '../../fixtures/fedex-shipping-fixtures/shippingRatePayload.json'\nimport {\n loadCalculateShippingAPI,\n validateCalculateShipping,\n} from '../../support/fedex-shipping/api_testcase.js'\n\ndescribe('Validate Ship Rates API from different origins', () => {\n loginViaCookies()\n\n it(\n 'For Non Supported Country - eg: Poland should get response with status code 500',\n updateRetry(5),\n () => {\n cy.qe('Validate invalid shipping address by giving poland address')\n cy.addDelayBetweenRetries(3000)\n data.destination = {\n zipCode: '00-005',\n country: 'PL',\n state: null,\n city: null,\n coordinates: null,\n residential: false,\n }\n loadCalculateShippingAPI(data).then((response) => {\n expect(response.status).to.have.equal(404)\n })\n }\n )\n\n it(\n 'Use Shipment from Italy to USA(Supported country) ( Origin -> destination = ITA -> USA)',\n updateRetry(5),\n () => {\n cy.addDelayBetweenRetries(10000)\n data.destination = {\n zipCode: '33301',\n country: 'USA',\n state: null,\n city: null,\n coordinates: null,\n residential: false,\n }\n data.origin = {\n zipCode: '06010',\n country: 'ITA',\n state: null,\n city: null,\n coordinates: null,\n residential: false,\n }\n loadCalculateShippingAPI(data, validateCalculateShipping)\n }\n )\n\n it(\n 'Use Shipment From USA(Supported country) to Italy ( Origin -> destination = USA -> ITA)',\n updateRetry(5),\n () => {\n cy.addDelayBetweenRetries(10000)\n data.destination = {\n zipCode: '06010',\n country: 'ITA',\n state: null,\n city: null,\n coordinates: null,\n residential: false,\n }\n data.origin = {\n zipCode: '33301',\n country: 'USA',\n state: null,\n city: null,\n coordinates: null,\n residential: false,\n }\n loadCalculateShippingAPI(data, validateCalculateShipping)\n }\n )\n})\n\n```"
}
] |
code_cy-runner_bc0b60ba
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.6.2-buyer_scenarios_orgA_costA2.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport b2b from '../../support/b2b/constants.js'\nimport { ROLE_DROP_DOWN, STATUSES } from '../../support/b2b/utils.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\nimport { verifySession } from '../../support/b2b/common.js'\nimport { createQuote, filterQuoteByStatus } from '../../support/b2b/quotes.js'\nimport {\n quickOrderByCategory,\n quickOrderByCategoryNegativeTestCase,\n} from '../../support/quick-order/testcase.js'\n\ndescribe('Organization A - Cost Center A2 - Buyer Scenarios', () => {\n loginViaCookies({ storeFrontCookie: false })\n const { users, costCenter2, quotes, product3, gmailCreds } = b2b.OrganizationA\n\n loginToStoreFront(users.Buyer2, ROLE_DROP_DOWN.Buyer, gmailCreds)\n verifySession(b2b.OrganizationA, costCenter2.name, ROLE_DROP_DOWN.Buyer)\n quickOrderByCategory(ROLE_DROP_DOWN.Buyer, quotes.Buyer2.quotes1, '$84.60')\n quickOrderByCategoryNegativeTestCase(\n ROLE_DROP_DOWN.Buyer,\n quotes.Buyer2.quotes2,\n '$4,230.00'\n )\n createQuote({\n product: product3,\n quoteEnv: quotes.Buyer2.quotes3,\n role: ROLE_DROP_DOWN.Buyer,\n })\n filterQuoteByStatus(STATUSES.pending)\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_e9d490c6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/wipe.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/no-conditional-expect */\n/* eslint-disable jest/consistent-test-it */\n/* eslint-disable jest/valid-expect */\nimport b2b from '../../support/b2b/constants.js'\nimport {\n loginViaCookies,\n updateRetry,\n preserveCookie,\n} from '../../support/common/support.js'\nimport { deleteOrganization } from '../../support/b2b/graphql.js'\n\nconst config = Cypress.env()\n\n// Constants\nconst { name } = config.workspace\n\n// Define constants\nconst APP_NAME = 'vtex.b2b-organizations-graphql'\nconst APP_VERSION = '*.x'\nconst APP = `${APP_NAME}@${APP_VERSION}`\n\nfunction deleteCostCenter(organization, costCenter) {\n it(`Delete ${costCenter.name} - ${organization}`, updateRetry(2), () => {\n cy.getVtexItems().then((vtex) => {\n const CUSTOM_URL = `${vtex.baseUrl}/_v/private/admin-graphql-ide/v0/${APP}`\n\n const GRAPHQL_DELETE_ORAGANIZATION_MUTATION =\n 'mutation' + '($id: ID!)' + '{deleteCostCenter(id: $id){status}}'\n\n cy.getOrganizationItems().then((items) => {\n const costCenterId = items[costCenter.name]\n\n if (costCenterId) {\n cy.callGraphqlAndAddLogs({\n url: CUSTOM_URL,\n query: GRAPHQL_DELETE_ORAGANIZATION_MUTATION,\n variables: {\n id: costCenterId,\n },\n }).then((response) => {\n expect(response.status).to.equal(200)\n expect(response.body.data.deleteCostCenter.status).to.equal(\n 'success'\n )\n })\n }\n })\n })\n })\n}\n\nfunction deleteUsers() {\n it('Delete users via graphql', updateRetry(5), () => {\n cy.getVtexItems().then((vtex) => {\n cy.url().then((url) => {\n if (url.includes('blank')) {\n cy.visit('/')\n }\n })\n const CUSTOM_URL = `${vtex.baseUrl}/_v/private/admin-graphql-ide/v0/${APP}`\n\n const GRAPHQL_DELETE_ORAGANIZATION_MUTATION =\n 'mutation' +\n '($id: ID!,$email:String!,$clId: ID!)' +\n '{removeUser(id: $id,email:$email,clId:$clId){status}}'\n\n const GRAPHQL_GET_USERS_QUERY =\n 'query' +\n '($pageSize: Int,$search: String)' +\n '{getUsersPaginated(pageSize: $pageSize,search: $search){data{id,email,clId}}}'\n\n cy.callGraphqlAndAddLogs({\n url: CUSTOM_URL,\n query: GRAPHQL_GET_USERS_QUERY,\n variables: {\n pageSize: 100,\n search: name,\n },\n headers: { VtexIdclientAutCookie: vtex.userAuthCookieValue },\n }).then((response) => {\n expect(response.status).to.equal(200)\n const clients = response.body.data.getUsersPaginated.data\n\n expect(clients).to.not.equal(null)\n if (clients.length > 0) {\n for (const { clId, id, email } of clients) {\n cy.callGraphqlAndAddLogs({\n url: CUSTOM_URL,\n query: GRAPHQL_DELETE_ORAGANIZATION_MUTATION,\n variables: {\n id,\n email,\n clId,\n },\n }).then((removeUserResponse) => {\n expect(removeUserResponse.status).to.equal(200)\n expect(removeUserResponse.body.data.removeUser.status).to.equal(\n 'success'\n )\n })\n }\n }\n })\n })\n })\n}\n\ndescribe('Wipe datas', () => {\n const {\n organizationName: organizationA,\n costCenter1,\n costCenter2,\n } = b2b.OrganizationA\n\n const { organizationName: organizationB, costCenter1: costCenterB1 } =\n b2b.OrganizationB\n\n loginViaCookies({ storeFrontCookie: false })\n\n deleteUsers()\n deleteCostCenter(organizationA, costCenter1)\n deleteCostCenter(organizationA, costCenter2)\n deleteCostCenter(organizationB, costCenterB1)\n deleteOrganization(name)\n deleteOrganization(name, true)\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_b93aee61
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.13.1-sales_manager_scenarios.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport b2b from '../../support/b2b/constants.js'\nimport {\n ROLE_ID_EMAIL_MAPPING as roleObject,\n STATUSES,\n} from '../../support/b2b/utils.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\nimport {\n productShouldNotbeAvailableTestCase,\n verifySession,\n userShouldNotImpersonateThisUser,\n} from '../../support/b2b/common.js'\nimport { searchQuote, filterQuoteByStatus } from '../../support/b2b/quotes.js'\nimport { salesManagerQuotesAccess } from '../../support/b2b/impersonation_quote_access.js'\n\ndescribe('Organization A - Cost Center A1 - Sales Manager Basic Scenario', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n const { nonAvailableProduct, users, costCenter1, quotes, gmailCreds } =\n b2b.OrganizationA\n\n const { organizationName: organizationB, quotes: organizationBQuote } =\n b2b.OrganizationB\n\n loginToStoreFront(\n users.SalesManager,\n roleObject.SalesManager.role,\n gmailCreds\n )\n verifySession(\n b2b.OrganizationA,\n costCenter1.name,\n roleObject.SalesManager.role\n )\n userShouldNotImpersonateThisUser(\n roleObject.SalesManager.role,\n roleObject.SalesRepresentative.role,\n users.SalesRep\n )\n productShouldNotbeAvailableTestCase(nonAvailableProduct)\n salesManagerQuotesAccess(b2b.OrganizationA, organizationB, organizationBQuote)\n\n searchQuote(quotes.OrganizationAdmin.quotes1)\n filterQuoteByStatus(STATUSES.pending)\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_49bfc661
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.6.1-buyer_scenarios_orgA_costA2.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport b2b from '../../support/b2b/constants.js'\nimport { ROLE_DROP_DOWN } from '../../support/b2b/utils.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\nimport {\n productShouldNotbeAvailableTestCase,\n verifySession,\n} from '../../support/b2b/common.js'\nimport { quoteShouldNotBeVisibleTestCase } from '../../support/b2b/quotes.js'\n\ndescribe('Organization A - Cost Center A2 - Buyer Scenarios', () => {\n loginViaCookies({ storeFrontCookie: false })\n const {\n organizationName,\n nonAvailableProduct,\n users,\n costCenter2,\n quotes,\n gmailCreds,\n } = b2b.OrganizationA\n\n const { organizationName: organizationB, quotes: organizationBQuote } =\n b2b.OrganizationB\n\n loginToStoreFront(users.Buyer2, ROLE_DROP_DOWN.Buyer, gmailCreds)\n verifySession(b2b.OrganizationA, costCenter2.name, ROLE_DROP_DOWN.Buyer)\n productShouldNotbeAvailableTestCase(nonAvailableProduct)\n quoteShouldNotBeVisibleTestCase(\n organizationName,\n quotes.OrganizationAdmin.quotes1,\n organizationName\n )\n quoteShouldNotBeVisibleTestCase(\n organizationName,\n organizationBQuote.OrganizationAdmin.quotes1,\n organizationB\n )\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_b97cf73f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.2.2-add_buyer_approver_organizationA.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport b2b from '../../support/b2b/constants.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\nimport { addUser } from '../../support/b2b/add_users.js'\nimport {\n ROLE_DROP_DOWN,\n ROLE_DROP_DOWN_EMAIL_MAPPING as role,\n} from '../../support/b2b/utils.js'\nimport {\n createQuote,\n // filterQuote,\n searchQuote,\n} from '../../support/b2b/quotes.js'\nimport { verifyBindings } from '../../support/b2b/graphql.js'\n\ndescribe('OrganizationA - Create a Buyer and Approver, associate Cost Center and assign payment terms', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n const {\n organizationName,\n costCenter1,\n costCenter2,\n users,\n product,\n quotes,\n gmailCreds,\n } = b2b.OrganizationA\n\n verifyBindings(users.OrganizationAdmin1, true)\n\n loginToStoreFront(\n users.OrganizationAdmin1,\n ROLE_DROP_DOWN.OrganizationAdmin,\n gmailCreds\n )\n\n addUser({\n organizationName,\n costCenter: costCenter1.name,\n role: role.Buyer1,\n gmailCreds,\n })\n addUser({\n organizationName,\n costCenter: costCenter1.name,\n role: role.Approver1,\n gmailCreds,\n })\n\n addUser({\n organizationName,\n costCenter: costCenter2.name,\n role: role.Buyer2,\n gmailCreds,\n })\n\n // Add/Delete users in costcenter1 - Hold\n // Add/Update users for costcenter2 - Hold bug\n\n addUser({\n organizationName,\n costCenter: costCenter2.name,\n role: role.OrganizationAdmin2,\n gmailCreds,\n })\n addUser({\n organizationName,\n costCenter: costCenter2.name,\n role: role.Approver2,\n gmailCreds,\n })\n\n createQuote({\n product,\n quoteEnv: quotes.OrganizationAdmin.quotes1,\n role: ROLE_DROP_DOWN.OrganizationAdmin,\n })\n searchQuote(quotes.OrganizationAdmin.quotes1)\n // filterQuote(costCenter1.name)\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_78bfd0dc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.1.3-organization_negative_testcases.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { loginViaCookies } from '../../support/common/support.js'\nimport {\n createOrganizationWithInvalidEmail,\n createOrganizationWithoutName,\n createOrganizationWithoutCostCenterNameAndAddress,\n} from '../../support/b2b/organization_request.js'\nimport b2b from '../../support/b2b/constants.js'\n\ndescribe('Organization Negative TestCases', () => {\n loginViaCookies({ storeFrontCookie: false })\n const email = b2b.OrganizationA.users.OrganizationAdmin1\n\n createOrganizationWithoutCostCenterNameAndAddress(\n b2b.OrganizationA.organizationName,\n {\n costCenterName: b2b.OrganizationA.costCenter1.name,\n costCenterAddress: b2b.OrganizationA.costCenter1.addresses[0],\n },\n email\n )\n\n createOrganizationWithoutName(\n b2b.OrganizationA.organizationName,\n {\n costCenterName: b2b.OrganizationA.costCenter1.name,\n costCenterAddress: b2b.OrganizationA.costCenter1.addresses[0],\n },\n email\n )\n createOrganizationWithInvalidEmail(\n b2b.OrganizationA.organizationName,\n {\n costCenterName: b2b.OrganizationA.costCenter1.name,\n costCenterAddress: b2b.OrganizationA.costCenter1.addresses[0],\n },\n email\n )\n})\n\n```"
}
] |
code_cy-runner_a83b8b65
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.8.2-organization_admin_scenarios-orgA.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport b2b from '../../support/b2b/constants.js'\nimport { ROLE_DROP_DOWN, STATUSES } from '../../support/b2b/utils.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\nimport { verifySession } from '../../support/b2b/common.js'\nimport {\n checkoutProduct,\n fillContactInfo,\n verifyAddress,\n verifyPayment,\n ordertheProduct,\n} from '../../support/b2b/checkout.js'\nimport {\n // rejectQuote,\n filterQuoteByStatus,\n} from '../../support/b2b/quotes.js'\nimport {\n quickOrderBySkuAndQuantityTestCase1,\n quickOrderBySkuAndQuantityTestCase2,\n quickOrderBySkuAnd51QuantityTestCase,\n} from '../../support/quick-order/testcase.js'\n\ndescribe('Organization A - Cost Center A1 - Organization Admin2 Scenario', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n const { product, costCenter2, users, quotes, gmailCreds } = b2b.OrganizationA\n\n loginToStoreFront(\n users.OrganizationAdmin2,\n ROLE_DROP_DOWN.OrganizationAdmin,\n gmailCreds\n )\n verifySession(\n b2b.OrganizationA,\n costCenter2.name,\n ROLE_DROP_DOWN.OrganizationAdmin\n )\n quickOrderBySkuAndQuantityTestCase1(\n ROLE_DROP_DOWN.OrganizationAdmin,\n quotes.OrganizationAdmin2.quotes1,\n '$162.00'\n )\n quickOrderBySkuAndQuantityTestCase2(ROLE_DROP_DOWN.OrganizationAdmin)\n quickOrderBySkuAnd51QuantityTestCase(ROLE_DROP_DOWN.OrganizationAdmin)\n filterQuoteByStatus(STATUSES.declined)\n\n checkoutProduct(product)\n fillContactInfo()\n verifyAddress(costCenter2.addresses)\n verifyPayment(false)\n ordertheProduct(ROLE_DROP_DOWN.OrganizationAdmin)\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_b1e9d01a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.14.1-sales_rep_scenarios.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport b2b from '../../support/b2b/constants.js'\nimport {\n ROLE_ID_EMAIL_MAPPING as roleObject,\n STATUSES,\n} from '../../support/b2b/utils.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\nimport {\n productShouldNotbeAvailableTestCase,\n verifySession,\n userShouldNotImpersonateThisUser,\n} from '../../support/b2b/common.js'\nimport {\n searchQuote,\n updateQuote,\n filterQuoteByStatus,\n} from '../../support/b2b/quotes.js'\nimport { salesRepQuotesAccess } from '../../support/b2b/impersonation_quote_access.js'\n\ndescribe('Organization A - Cost Center A1 - Sales Rep Basic Scenario', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n const { nonAvailableProduct, users, costCenter1, quotes, gmailCreds } =\n b2b.OrganizationA\n\n const { organizationName: organizationB, quotes: organizationBQuote } =\n b2b.OrganizationB\n\n loginToStoreFront(\n users.SalesRep,\n roleObject.SalesRepresentative.role,\n gmailCreds\n )\n verifySession(\n b2b.OrganizationA,\n costCenter1.name,\n roleObject.SalesRepresentative.role\n )\n\n productShouldNotbeAvailableTestCase(nonAvailableProduct)\n salesRepQuotesAccess(b2b.OrganizationA, organizationB, organizationBQuote)\n\n userShouldNotImpersonateThisUser(\n roleObject.SalesRepresentative.role,\n roleObject.SalesManager.role,\n users.SalesManager\n )\n searchQuote(quotes.SalesRep.updateQuote)\n const price = '30.00'\n\n updateQuote(quotes.SalesRep.updateQuote, { price })\n filterQuoteByStatus(STATUSES.revised)\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_efe2d9fc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.2.1-add_buyer_approver_organizationA.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport b2b from '../../support/b2b/constants.js'\nimport {\n addPaymentTermsCollectionPriceTablesTestCase,\n setOrganizationIdInJSON,\n} from '../../support/b2b/common.js'\nimport {\n addAddressinCostCenter,\n deleteCostCenter,\n addCostCenter,\n updateCostCenter,\n updatePaymentTermsinCostCenter,\n} from '../../support/b2b/cost_center.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\nimport { ROLE_DROP_DOWN, PAYMENT_TERMS } from '../../support/b2b/utils.js'\nimport { verifyBindings } from '../../support/b2b/graphql.js'\n\ndescribe('OrganizationA - Create a Buyer and Approver, associate Cost Center and assign payment terms', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n const {\n organizationName,\n costCenter1,\n costCenter2,\n costCenter3,\n users,\n gmailCreds,\n } = b2b.OrganizationA\n\n verifyBindings(users.OrganizationAdmin1, true)\n\n loginToStoreFront(\n users.OrganizationAdmin1,\n ROLE_DROP_DOWN.OrganizationAdmin,\n gmailCreds\n )\n\n setOrganizationIdInJSON(organizationName, costCenter1.name)\n addPaymentTermsCollectionPriceTablesTestCase(b2b.OrganizationA)\n\n // CostCenter 2 - Scenarios\n addCostCenter(organizationName, costCenter2.name, costCenter2.addresses[0])\n updatePaymentTermsinCostCenter(\n organizationName,\n costCenter2.name,\n PAYMENT_TERMS.Promissory\n )\n addAddressinCostCenter(costCenter2.name, costCenter2.addresses[1])\n\n // // Cost Center 3 - Scenarios\n addCostCenter(\n organizationName,\n costCenter3.temporaryName,\n costCenter3.addresses[0]\n )\n updateCostCenter(costCenter3.temporaryName, costCenter3.name)\n deleteCostCenter(costCenter3.name)\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_e131b2ce
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.5.2-buyer_scenarios_orgA_costA1.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport b2b from '../../support/b2b/constants.js'\nimport { ROLE_DROP_DOWN, STATUSES } from '../../support/b2b/utils.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\nimport { verifySession } from '../../support/b2b/common.js'\nimport { createQuote, filterQuoteByStatus } from '../../support/b2b/quotes.js'\nimport {\n quickOrderByOneByOneTestCase,\n quickOrderByOneByOneNegativeTestCase,\n} from '../../support/quick-order/testcase.js'\n\ndescribe('Organization A - Cost Center A1 - Buyer Create Quote Scenarios', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n const { costCenter1, users, product, product2, quotes, gmailCreds } =\n b2b.OrganizationA\n\n loginToStoreFront(users.Buyer1, ROLE_DROP_DOWN.Buyer, gmailCreds)\n verifySession(b2b.OrganizationA, costCenter1.name, ROLE_DROP_DOWN.Buyer)\n createQuote({\n product,\n quoteEnv: quotes.Buyer.quotes4,\n role: ROLE_DROP_DOWN.Buyer,\n })\n createQuote({\n product,\n quoteEnv: quotes.Buyer.quotes5,\n role: ROLE_DROP_DOWN.Buyer,\n })\n quickOrderByOneByOneTestCase(\n ROLE_DROP_DOWN.Buyer,\n product2,\n quotes.Buyer.quotes6,\n '$486.00'\n )\n quickOrderByOneByOneNegativeTestCase(\n ROLE_DROP_DOWN.Buyer,\n product2,\n quotes.Buyer.quotes7,\n '$24,300.00'\n )\n filterQuoteByStatus(STATUSES.ready)\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_989c5a85
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.4.3-show_organization_by_adding_principal_sales_channel.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/valid-expect */\nimport {\n loginViaCookies,\n preserveCookie,\n updateRetry,\n} from '../../support/common/support.js'\nimport { ROLE_DROP_DOWN } from '../../support/b2b/utils.js'\nimport b2b from '../../support/b2b/constants.js'\nimport {\n verifySalesChannel,\n verifyBindings,\n addBindingsWhichShowsOrganization,\n} from '../../support/b2b/graphql.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\n\nconst { users, gmailCreds } = b2b.OrganizationB\n\ndescribe('Add binding which shows Organization in profile page', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n addBindingsWhichShowsOrganization()\n\n verifySalesChannel(1)\n\n verifyBindings(users.OrganizationAdmin1, true)\n\n loginToStoreFront(\n users.OrganizationAdmin1,\n ROLE_DROP_DOWN.OrganizationAdmin,\n gmailCreds\n )\n\n it('Verify Organization is showing up', updateRetry(2), () => {\n cy.organizationShouldShowInProfile()\n })\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_46306959
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.12.2-sales_admin_scenarios.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport b2b from '../../support/b2b/constants.js'\nimport {\n ROLE_ID_EMAIL_MAPPING as roleObject,\n ROLE_DROP_DOWN,\n // ROLE_DROP_DOWN_EMAIL_MAPPING as role,\n STATUSES,\n} from '../../support/b2b/utils.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\nimport {\n salesUserShouldImpersonateNonSalesUser,\n verifySession,\n stopImpersonation,\n} from '../../support/b2b/common.js'\nimport {\n searchQuote,\n createQuote,\n // discountSliderShouldNotExist,\n updateQuote,\n // rejectQuote,\n // filterQuote,\n filterQuoteByStatus,\n} from '../../support/b2b/quotes.js'\nimport { salesAdminQuotesAccess } from '../../support/b2b/impersonation_quote_access.js'\n\ndescribe('Organization A - Cost Center A1 - Sales Admin Impersonation Scenario', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n const { product, costCenter1, users, quotes, gmailCreds } = b2b.OrganizationA\n\n const { organizationName: organizationB, quotes: organizationBQuote } =\n b2b.OrganizationB\n\n const impersonatedRole = ROLE_DROP_DOWN.Approver\n\n loginToStoreFront(users.SalesAdmin, roleObject.SalesAdmin.role, gmailCreds)\n verifySession(b2b.OrganizationA, costCenter1.name, roleObject.SalesAdmin.role)\n\n salesUserShouldImpersonateNonSalesUser(\n roleObject.SalesAdmin.role,\n impersonatedRole,\n users.Approver1\n )\n\n updateQuote(quotes.Buyer.quotes1, { discount: '20' })\n updateQuote(quotes.Buyer.quotes2, { notes: 'Notes' })\n const price = '250.00'\n const quantity = '10'\n\n updateQuote(quotes.Buyer.quotes6, { price, quantity })\n filterQuoteByStatus(STATUSES.ready, STATUSES.declined)\n\n salesAdminQuotesAccess(b2b.OrganizationA, organizationB, organizationBQuote)\n\n const quote = 'IMPERSONATE_QUOTE_1'\n\n createQuote({\n product,\n quoteEnv: quote,\n role: roleObject.SalesManager.role,\n impersonatedRole,\n })\n searchQuote(quote, users.Approver1)\n stopImpersonation(\n b2b.OrganizationA,\n costCenter1.name,\n roleObject.SalesAdmin.role\n )\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_689632fa
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.13.2-sales_manager_scenarios.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport b2b from '../../support/b2b/constants.js'\nimport {\n ROLE_ID_EMAIL_MAPPING as roleObject,\n ROLE_DROP_DOWN,\n} from '../../support/b2b/utils.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\nimport {\n salesUserShouldImpersonateNonSalesUser,\n verifySession,\n stopImpersonation,\n} from '../../support/b2b/common.js'\nimport { createQuote, searchQuote } from '../../support/b2b/quotes.js'\nimport { salesManagerQuotesAccess } from '../../support/b2b/impersonation_quote_access.js'\n\ndescribe('Organization A - Cost Center A1 - Sales Manager Impersonation Scenario', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n const { users, product, costCenter1, gmailCreds } = b2b.OrganizationA\n\n const { organizationName: organizationB, quotes: organizationBQuote } =\n b2b.OrganizationB\n\n loginToStoreFront(\n users.SalesManager,\n roleObject.SalesManager.role,\n gmailCreds\n )\n verifySession(\n b2b.OrganizationA,\n costCenter1.name,\n roleObject.SalesManager.role\n )\n\n const impersonatedRole = ROLE_DROP_DOWN.OrganizationAdmin\n\n salesUserShouldImpersonateNonSalesUser(\n roleObject.SalesManager.role,\n impersonatedRole,\n users.OrganizationAdmin1\n )\n const quote = 'IMPERSONATE_QUOTE_2'\n\n salesManagerQuotesAccess(b2b.OrganizationA, organizationB, organizationBQuote)\n\n createQuote({\n product,\n quoteEnv: quote,\n role: roleObject.SalesManager.role,\n impersonatedRole,\n })\n searchQuote(quote, users.OrganizationAdmin1)\n stopImpersonation(\n b2b.OrganizationA,\n costCenter1.name,\n roleObject.SalesManager.role\n )\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_cbe3728e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.3-add_buyer_approver_organizationB.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport b2b from '../../support/b2b/constants.js'\nimport {\n addPaymentTermsCollectionPriceTablesTestCase,\n setOrganizationIdInJSON,\n} from '../../support/b2b/common.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\nimport { addUser, duplicateUserTestCase } from '../../support/b2b/add_users.js'\nimport {\n ROLE_DROP_DOWN_EMAIL_MAPPING as role,\n ROLE_DROP_DOWN,\n} from '../../support/b2b/utils.js'\nimport { createQuote } from '../../support/b2b/quotes.js'\n\ndescribe('OrganizationB - Create a Buyer and Approver associate Cost Center and assign payment terms', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n const { organizationName, costCenter1, users, product, quotes, gmailCreds } =\n b2b.OrganizationB\n\n loginToStoreFront(\n users.OrganizationAdmin1,\n ROLE_DROP_DOWN.OrganizationAdmin,\n gmailCreds\n )\n setOrganizationIdInJSON(organizationName, costCenter1.name)\n addPaymentTermsCollectionPriceTablesTestCase(b2b.OrganizationB)\n addUser({\n organizationName,\n costCenter: costCenter1.name,\n role: role.Buyer1,\n gmailCreds,\n })\n addUser({\n organizationName,\n costCenter: costCenter1.name,\n role: role.Approver1,\n gmailCreds,\n })\n duplicateUserTestCase({\n organizationName,\n costCenter: costCenter1.name,\n role: role.Approver1,\n gmailCreds,\n })\n createQuote({\n product,\n quoteEnv: quotes.OrganizationAdmin.quotes1,\n role: ROLE_DROP_DOWN.OrganizationAdmin,\n })\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_d12aaa94
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.5.1-buyer_scenarios_orgA_costA1.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport b2b from '../../support/b2b/constants.js'\nimport {\n ROLE_DROP_DOWN_EMAIL_MAPPING as role,\n ROLE_DROP_DOWN,\n ROLE_ID_EMAIL_MAPPING as roleObject,\n} from '../../support/b2b/utils.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\nimport {\n productShouldNotbeAvailableTestCase,\n verifySession,\n userAndCostCenterShouldNotBeEditable,\n userShouldNotImpersonateThisUser,\n} from '../../support/b2b/common.js'\nimport {\n searchQuote,\n createQuote,\n quoteShouldbeVisibleTestCase,\n quoteShouldNotBeVisibleTestCase,\n} from '../../support/b2b/quotes.js'\n\ndescribe('Organization A - Cost Center A1 - Buyer Scenarios', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n const {\n organizationName,\n nonAvailableProduct,\n costCenter1,\n users,\n product,\n quotes,\n gmailCreds,\n } = b2b.OrganizationA\n\n const { organizationName: organizationB, quotes: organizationBQuote } =\n b2b.OrganizationB\n\n loginToStoreFront(users.Buyer1, ROLE_DROP_DOWN.Buyer, gmailCreds)\n verifySession(b2b.OrganizationA, costCenter1.name, ROLE_DROP_DOWN.Buyer)\n productShouldNotbeAvailableTestCase(nonAvailableProduct)\n userAndCostCenterShouldNotBeEditable({\n organizationName,\n costCenter: costCenter1.name,\n gmailCreds,\n role: role.Buyer1,\n })\n userShouldNotImpersonateThisUser(\n ROLE_DROP_DOWN.Buyer,\n roleObject.SalesManager.role,\n users.SalesManager\n )\n quoteShouldbeVisibleTestCase(\n organizationName,\n quotes.OrganizationAdmin.quotes1,\n organizationName\n )\n quoteShouldNotBeVisibleTestCase(\n organizationName,\n organizationBQuote.OrganizationAdmin.quotes1,\n organizationB\n )\n searchQuote(quotes.OrganizationAdmin.quotes1)\n createQuote({\n product,\n quoteEnv: quotes.Buyer.quotes1,\n role: ROLE_DROP_DOWN.Buyer,\n })\n createQuote(\n {\n product,\n quoteEnv: quotes.Buyer.quotes2,\n role: ROLE_DROP_DOWN.Buyer,\n },\n false\n )\n createQuote({\n product,\n quoteEnv: quotes.Buyer.quotes3,\n role: ROLE_DROP_DOWN.Buyer,\n })\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_7b170ece
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.12.1-sales_admin_scenarios.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport b2b from '../../support/b2b/constants.js'\nimport {\n ROLE_ID_EMAIL_MAPPING as roleObject,\n // ROLE_DROP_DOWN_EMAIL_MAPPING as role,\n} from '../../support/b2b/utils.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\nimport {\n productShouldNotbeAvailableTestCase,\n verifySession,\n userShouldNotImpersonateThisUser,\n} from '../../support/b2b/common.js'\nimport {\n searchQuote,\n verifyQuotesAndSavedCarts,\n // discountSliderShouldNotExist,\n // rejectQuote,\n // filterQuote,\n} from '../../support/b2b/quotes.js'\nimport { salesAdminQuotesAccess } from '../../support/b2b/impersonation_quote_access.js'\n\ndescribe('Organization A - Cost Center A1 - Sales Admin Basic Scenario', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n const { nonAvailableProduct, costCenter1, users, quotes, gmailCreds } =\n b2b.OrganizationA\n\n const { organizationName: organizationB, quotes: organizationBQuote } =\n b2b.OrganizationB\n\n loginToStoreFront(users.SalesAdmin, roleObject.SalesAdmin.role, gmailCreds)\n verifySession(b2b.OrganizationA, costCenter1.name, roleObject.SalesAdmin.role)\n productShouldNotbeAvailableTestCase(nonAvailableProduct)\n\n // Impersonate users\n userShouldNotImpersonateThisUser(\n roleObject.SalesAdmin.role,\n roleObject.SalesManager.role,\n users.SalesManager\n )\n salesAdminQuotesAccess(b2b.OrganizationA, organizationB, organizationBQuote)\n\n verifyQuotesAndSavedCarts()\n searchQuote(quotes.Buyer.quotes1)\n\n // filterQuote(costCenter1.name, organizationB)\n\n // discountSliderShouldNotExist(quotes.Buyer2.quotes3)\n\n // rejectQuote(quotes.Buyer.quotes3, roleObject.SalesAdmin.role)\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_9d444f33
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.1.1-create_&_approve_organizationA.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { loginViaCookies } from '../../support/common/support.js'\nimport { createOrganizationTestCase } from '../../support/b2b/organization_request.js'\nimport b2b from '../../support/b2b/constants.js'\nimport { deleteOrganization } from '../../support/b2b/graphql.js'\n\ndescribe('Create & Approve OrganizationA', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n const { organizationName, costCenter1, users } = b2b.OrganizationA\n\n deleteOrganization(organizationName, true)\n deleteOrganization(organizationName)\n\n // Create and approve Organization A request\n createOrganizationTestCase(\n {\n name: organizationName,\n email: users.OrganizationAdmin1,\n },\n {\n costCenterName: costCenter1.name,\n costCenterAddress: costCenter1.addresses[0],\n approved: true,\n }\n )\n})\n\n```"
}
] |
code_cy-runner_8782cc2d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.9-approver_scenarios_orgA.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport b2b from '../../support/b2b/constants.js'\nimport {\n ROLE_DROP_DOWN,\n ROLE_DROP_DOWN_EMAIL_MAPPING as role,\n STATUSES,\n} from '../../support/b2b/utils.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\nimport {\n productShouldNotbeAvailableTestCase,\n verifySession,\n} from '../../support/b2b/common.js'\nimport {\n searchQuote,\n // rejectQuote,\n useQuoteForPlacingTheOrder,\n filterQuoteByStatus,\n quoteShouldbeVisibleTestCase,\n quoteShouldNotBeVisibleTestCase,\n verifyTotal,\n} from '../../support/b2b/quotes.js'\nimport {\n quickOrderByXLS,\n // quickOrderByXLSNegativeTestCase,\n} from '../../support/quick-order/testcase.js'\nimport {\n fillContactInfo,\n verifyAddress,\n verifyPayment,\n} from '../../support/b2b/checkout.js'\n\ndescribe('Organization A - Cost Center A1 - Approver Scenario', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n const {\n organizationName,\n nonAvailableProduct,\n users,\n costCenter1,\n quotes,\n gmailCreds,\n } = b2b.OrganizationA\n\n const { organizationName: organizationB, quotes: organizationBquotes } =\n b2b.OrganizationB\n\n loginToStoreFront(users.Approver1, ROLE_DROP_DOWN.Approver, gmailCreds)\n verifySession(b2b.OrganizationA, costCenter1.name, ROLE_DROP_DOWN.Approver)\n productShouldNotbeAvailableTestCase(nonAvailableProduct)\n quoteShouldbeVisibleTestCase(\n organizationName,\n quotes.OrganizationAdmin.quotes1,\n organizationName\n )\n quoteShouldNotBeVisibleTestCase(\n organizationName,\n organizationBquotes.OrganizationAdmin.quotes1,\n organizationB\n )\n quickOrderByXLS(quotes.Approver.quotes1)\n // Negative test case not working\n // Ticket - https://vtex-dev.atlassian.net/browse/QUICKORDER-36\n // quickOrderByXLSNegativeTestCase(quotes.Approver.quotes2)\n searchQuote(quotes.Buyer.quotes6)\n\n // Reject Quote not working\n // rejectQuote(quotes.Buyer.quotes6, role.Approver1.dropDownText)\n // rejectQuote(quotes.Buyer.quotes4, role.Approver1.dropDownText)\n filterQuoteByStatus(STATUSES.declined)\n\n useQuoteForPlacingTheOrder(quotes.Buyer.quotes1, role.Approver1.dropDownText)\n verifyTotal(quotes.Buyer.quotes1)\n fillContactInfo()\n verifyAddress(costCenter1.addresses)\n verifyPayment()\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_b23af52d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.8.1-organization_admin_scenarios-orgA.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport b2b from '../../support/b2b/constants.js'\nimport {\n ROLE_DROP_DOWN,\n ROLE_ID_EMAIL_MAPPING as roleObject,\n} from '../../support/b2b/utils.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\nimport {\n productShouldNotbeAvailableTestCase,\n verifySession,\n userShouldNotImpersonateThisUser,\n} from '../../support/b2b/common.js'\nimport { organizationAdminShouldNotAbleToEditSalesUsers } from '../../support/b2b/organization_request.js'\nimport {\n searchQuote,\n // rejectQuote,\n quoteShouldbeVisibleTestCase,\n quoteShouldNotBeVisibleTestCase,\n} from '../../support/b2b/quotes.js'\n\ndescribe('Organization A - Cost Center A1 - Organization Admin2 Scenario', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n const {\n organizationName,\n nonAvailableProduct,\n costCenter2,\n users,\n quotes,\n gmailCreds,\n } = b2b.OrganizationA\n\n const { organizationName: organizationB, quotes: organizationBQuote } =\n b2b.OrganizationB\n\n loginToStoreFront(\n users.OrganizationAdmin2,\n ROLE_DROP_DOWN.OrganizationAdmin,\n gmailCreds\n )\n verifySession(\n b2b.OrganizationA,\n costCenter2.name,\n ROLE_DROP_DOWN.OrganizationAdmin\n )\n organizationAdminShouldNotAbleToEditSalesUsers()\n userShouldNotImpersonateThisUser(\n ROLE_DROP_DOWN.OrganizationAdmin,\n roleObject.SalesManager.role,\n users.SalesManager\n )\n userShouldNotImpersonateThisUser(\n ROLE_DROP_DOWN.OrganizationAdmin,\n ROLE_DROP_DOWN.Buyer,\n users.Buyer1\n )\n productShouldNotbeAvailableTestCase(nonAvailableProduct)\n quoteShouldbeVisibleTestCase(\n organizationName,\n quotes.OrganizationAdmin.quotes1,\n organizationName\n )\n quoteShouldbeVisibleTestCase(\n organizationName,\n quotes.Buyer2.quotes1,\n organizationName\n )\n quoteShouldNotBeVisibleTestCase(\n organizationName,\n organizationBQuote.OrganizationAdmin.quotes1,\n organizationB\n )\n searchQuote(quotes.OrganizationAdmin.quotes1)\n // rejectQuote(\n // quotes.OrganizationAdmin2.declineQuote,\n // ROLE_DROP_DOWN.OrganizationAdmin\n // )\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_1301228d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.11-approver_scenarios_orgB.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport b2b from '../../support/b2b/constants.js'\nimport { ROLE_DROP_DOWN } from '../../support/b2b/utils.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\nimport {\n productShouldNotbeAvailableTestCase,\n verifySession,\n} from '../../support/b2b/common.js'\nimport {\n checkoutProduct,\n fillContactInfo,\n verifyAddress,\n verifyPayment,\n ordertheProduct,\n} from '../../support/b2b/checkout.js'\nimport {\n quoteShouldbeVisibleTestCase,\n quoteShouldNotBeVisibleTestCase,\n} from '../../support/b2b/quotes.js'\n\ndescribe('Organization B - Cost Center B1 - Approver Scenario', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n const {\n product,\n nonAvailableProduct,\n costCenter1,\n users,\n quotes,\n organizationName,\n gmailCreds,\n } = b2b.OrganizationB\n\n const { organizationName: organizationA, quotes: organizationAQuotes } =\n b2b.OrganizationA\n\n loginToStoreFront(users.Approver1, ROLE_DROP_DOWN.Approver, gmailCreds)\n verifySession(b2b.OrganizationB, costCenter1.name, ROLE_DROP_DOWN.Approver)\n productShouldNotbeAvailableTestCase(nonAvailableProduct)\n quoteShouldbeVisibleTestCase(\n organizationName,\n quotes.OrganizationAdmin.quotes1,\n organizationName\n )\n quoteShouldNotBeVisibleTestCase(\n organizationName,\n organizationAQuotes.OrganizationAdmin.quotes1,\n organizationA\n )\n checkoutProduct(product)\n fillContactInfo()\n verifyAddress(costCenter1.addresses)\n verifyPayment(false)\n ordertheProduct(ROLE_DROP_DOWN.Approver)\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_48f054f1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.14.2-sales_rep_scenarios.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport b2b from '../../support/b2b/constants.js'\nimport {\n ROLE_DROP_DOWN,\n ROLE_ID_EMAIL_MAPPING as roleObject,\n STATUSES,\n} from '../../support/b2b/utils.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\nimport {\n salesUserShouldImpersonateNonSalesUser,\n verifySession,\n stopImpersonation,\n} from '../../support/b2b/common.js'\nimport {\n searchQuote,\n createQuote,\n updateQuote,\n filterQuoteByStatus,\n} from '../../support/b2b/quotes.js'\nimport { salesRepQuotesAccess } from '../../support/b2b/impersonation_quote_access.js'\n\ndescribe('Organization A - Cost Center A1 - Sales Rep Impersonation Scenario', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n const { users, product, costCenter1, quotes, gmailCreds } = b2b.OrganizationA\n\n const { organizationName: organizationB, quotes: organizationBQuote } =\n b2b.OrganizationB\n\n const impersonatedRole = ROLE_DROP_DOWN.Buyer\n\n loginToStoreFront(\n users.SalesRep,\n roleObject.SalesRepresentative.role,\n gmailCreds\n )\n verifySession(\n b2b.OrganizationA,\n costCenter1.name,\n roleObject.SalesRepresentative.role\n )\n\n salesUserShouldImpersonateNonSalesUser(\n roleObject.SalesRepresentative.role,\n impersonatedRole,\n users.Buyer1\n )\n\n searchQuote(quotes.SalesRep.updateQuote)\n const price = '30.00'\n\n updateQuote(quotes.SalesRep.updateQuote, { price })\n filterQuoteByStatus(STATUSES.revised)\n salesRepQuotesAccess(b2b.OrganizationA, organizationB, organizationBQuote)\n\n const quote = 'IMPERSONATE_QUOTE_3'\n\n createQuote({\n product,\n quoteEnv: quote,\n role: roleObject.SalesRepresentative.role,\n impersonatedRole,\n })\n searchQuote(quote, users.Buyer1)\n stopImpersonation(\n b2b.OrganizationA,\n costCenter1.name,\n roleObject.SalesRepresentative.role\n )\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_218b628c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.4.2-hide_organization_by_adding_dolar_sales_channel.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/valid-expect */\nimport {\n loginViaCookies,\n preserveCookie,\n updateRetry,\n} from '../../support/common/support.js'\nimport { ROLE_DROP_DOWN } from '../../support/b2b/utils.js'\nimport b2b from '../../support/b2b/constants.js'\nimport {\n verifySalesChannel,\n verifyBindings,\n addBindingsWhichHidesOrganization,\n addBindingsWhichShowsOrganization,\n} from '../../support/b2b/graphql.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\n\nconst { users, gmailCreds } = b2b.OrganizationB\n\ndescribe('Add Binding which hides Organization in profile page', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n addBindingsWhichHidesOrganization()\n\n verifySalesChannel(0)\n\n verifyBindings(users.OrganizationAdmin1, false)\n\n loginToStoreFront(\n users.OrganizationAdmin1,\n ROLE_DROP_DOWN.OrganizationAdmin,\n gmailCreds\n )\n\n it('Verify Organization is not showing up', updateRetry(2), () => {\n cy.reloadOnLastNAttempts(1)\n cy.organizationShouldNotShowInProfile()\n })\n\n addBindingsWhichShowsOrganization()\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_7d54d2dd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.1.2-multi_organizations_requests_from_organizationB.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { loginViaCookies } from '../../support/common/support.js'\nimport {\n createOrganizationTestCase,\n approveOrganization,\n} from '../../support/b2b/organization_request.js'\nimport b2b from '../../support/b2b/constants.js'\nimport { deleteOrganization } from '../../support/b2b/graphql.js'\n\ndescribe('Create, Decline OrganizationB', () => {\n before(() => {\n cy.clearLocalStorage()\n })\n loginViaCookies({ storeFrontCookie: false })\n const email = b2b.OrganizationB.users.OrganizationAdmin1\n const name = b2b.OrganizationB.organizationName\n const costCenterName = b2b.OrganizationB.costCenter1.name\n const [costCenterAddress] = b2b.OrganizationB.costCenter1.addresses\n\n const organization = { name, email }\n const costCenter = {\n costCenterName,\n costCenterAddress,\n }\n\n const { organizationName, costCenter1, users } = b2b.OrganizationB\n\n deleteOrganization(organizationName, true)\n deleteOrganization(organizationName)\n\n // Create and decline Organization B\n createOrganizationTestCase(\n {\n name: organizationName,\n email: users.OrganizationAdmin1,\n },\n {\n costCenterName: costCenter1.name,\n costCenterAddress: costCenter1.addresses[0],\n declined: true,\n }\n )\n\n describe('Create, Approve OrganizationB', () => {\n // Create Organization B request\n createOrganizationTestCase(organization, costCenter)\n\n // Approve Organization B\n approveOrganization(b2b.OrganizationB.organizationName)\n })\n})\n\n```"
}
] |
code_cy-runner_42a7d194
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.4.1-add-remaining-users.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/valid-expect */\nimport {\n loginViaCookies,\n updateRetry,\n preserveCookie,\n} from '../../support/common/support.js'\nimport {\n ROLE_ID_EMAIL_MAPPING,\n OTHER_ROLES,\n ROLE_DROP_DOWN,\n} from '../../support/b2b/utils.js'\nimport { addUserViaGraphql } from '../../support/b2b/add_users.js'\nimport { syncCheckoutUICustom } from '../../support/common/testcase.js'\nimport b2b from '../../support/b2b/constants.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\n\nconst { users, gmailCreds } = b2b.OrganizationA\n\ndescribe('Sync Checkout UI Custom & Add Sales Users via Graphql', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n loginToStoreFront(\n users.OrganizationAdmin1,\n ROLE_DROP_DOWN.OrganizationAdmin,\n gmailCreds\n )\n\n it('Set roles in organization JSON', updateRetry(3), () => {\n cy.getVtexItems().then((vtex) => {\n const APP_NAME = 'vtex.storefront-permissions'\n const APP_VERSION = '1.x'\n const APP = `${APP_NAME}@${APP_VERSION}`\n\n const CUSTOM_URL = `${vtex.baseUrl}/_v/private/admin-graphql-ide/v0/${APP}`\n const GRAPHQL_LIST_ROLE_QUERY = 'query' + '{listRoles{id,name}}'\n\n cy.callGraphqlAndAddLogs({\n url: CUSTOM_URL,\n query: GRAPHQL_LIST_ROLE_QUERY,\n }).then((response) => {\n const rolesObject = response.body.data.listRoles.filter((r) =>\n OTHER_ROLES.includes(r.name)\n )\n\n expect(rolesObject.length).to.equal(3)\n rolesObject.map((r) => cy.setOrganizationItem(`${r.name}-id`, r.id))\n })\n })\n })\n\n syncCheckoutUICustom()\n\n const roles = Object.keys(ROLE_ID_EMAIL_MAPPING)\n\n roles.forEach((r) => {\n addUserViaGraphql(gmailCreds, r)\n })\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_eadaac33
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.10-approver_scenarios_orgA_costcenter2.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport b2b from '../../support/b2b/constants.js'\nimport {\n ROLE_DROP_DOWN,\n ROLE_DROP_DOWN_EMAIL_MAPPING as role,\n} from '../../support/b2b/utils.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\nimport {\n verifySession,\n productShouldNotbeAvailableTestCase,\n} from '../../support/b2b/common.js'\nimport {\n fillContactInfo,\n verifyAddress,\n verifyPayment,\n} from '../../support/b2b/checkout.js'\nimport {\n searchQuote,\n quoteShouldbeVisibleTestCase,\n quoteShouldNotBeVisibleTestCase,\n useQuoteForPlacingTheOrder,\n verifyTotal,\n} from '../../support/b2b/quotes.js'\n\ndescribe('Organization A - Cost Center A2 - Approver Scenario', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n const {\n organizationName,\n quotes,\n nonAvailableProduct,\n costCenter2,\n users,\n gmailCreds,\n } = b2b.OrganizationA\n\n const { organizationName: organizationB, quotes: organizationBquotes } =\n b2b.OrganizationB\n\n loginToStoreFront(users.Approver2, ROLE_DROP_DOWN.Approver, gmailCreds)\n verifySession(b2b.OrganizationA, costCenter2.name, ROLE_DROP_DOWN.Approver)\n productShouldNotbeAvailableTestCase(nonAvailableProduct)\n quoteShouldbeVisibleTestCase(\n organizationName,\n quotes.Buyer2.quotes1,\n organizationName\n )\n quoteShouldNotBeVisibleTestCase(\n organizationName,\n organizationBquotes.OrganizationAdmin.quotes1,\n organizationB\n )\n searchQuote(quotes.Approver2.updateQuote)\n useQuoteForPlacingTheOrder(\n quotes.Approver2.updateQuote,\n role.Approver2.dropDownText\n )\n verifyTotal(quotes.Approver2.updateQuote)\n fillContactInfo()\n verifyAddress(costCenter2.addresses)\n verifyPayment(false)\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_e4f8929d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/b2b/2.7-buyer_scenarios_orgB_costB1.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport b2b from '../../support/b2b/constants.js'\nimport { ROLE_DROP_DOWN } from '../../support/b2b/utils.js'\nimport { loginToStoreFront } from '../../support/b2b/login.js'\nimport {\n productShouldNotbeAvailableTestCase,\n verifySession,\n} from '../../support/b2b/common.js'\nimport {\n createQuote,\n quoteShouldbeVisibleTestCase,\n quoteShouldNotBeVisibleTestCase,\n} from '../../support/b2b/quotes.js'\n\ndescribe('Organization B - Cost Center B1 - Buyer Scenario', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n const {\n organizationName,\n users,\n nonAvailableProduct,\n product,\n quotes,\n costCenter1,\n gmailCreds,\n } = b2b.OrganizationB\n\n const { organizationName: organizationA, quotes: organizationAQuotes } =\n b2b.OrganizationA\n\n loginToStoreFront(users.Buyer1, ROLE_DROP_DOWN.Buyer, gmailCreds)\n verifySession(b2b.OrganizationB, costCenter1.name, ROLE_DROP_DOWN.Buyer)\n productShouldNotbeAvailableTestCase(nonAvailableProduct)\n quoteShouldbeVisibleTestCase(\n organizationName,\n quotes.OrganizationAdmin.quotes1,\n organizationName\n )\n quoteShouldNotBeVisibleTestCase(\n organizationName,\n organizationAQuotes.OrganizationAdmin.quotes1,\n organizationA\n )\n createQuote({\n product,\n quoteEnv: quotes.Buyer.quotes1,\n role: ROLE_DROP_DOWN.Buyer,\n })\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_1e2efc51
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/packing-optimization/2.1-rest-apis.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport { pack } from '../../support/packing-optimization/api_testcase'\nimport { packed } from '../../fixtures/pack.json'\n\ndescribe('Rest-api-testcases', () => {\n loginViaCookies()\n\n pack(packed)\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_6d2d193b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/affirm/2.4-discountProduct.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/expect-expect */\nimport {\n loginViaCookies,\n preserveCookie,\n updateRetry,\n} from '../../support/common/support.js'\nimport { discountProduct } from '../../support/affirm/outputvalidation'\nimport {\n cancelTheOrder,\n getTestVariables,\n verifyOrderStatus,\n} from '../../support/common/testcase.js'\nimport { completeThePayment } from '../../support/affirm/testcase.js'\n\nconst { prefix, productName, postalCode, productQuantity } = discountProduct\n\ndescribe(`${prefix} Scenarios`, () => {\n loginViaCookies()\n\n const discountProductEnvs = getTestVariables(prefix)\n\n discountProductEnvs.sendInvoice = false\n\n it(`In ${prefix} - Adding Product to Cart`, updateRetry(1), () => {\n // Search the product\n cy.searchProduct(productName)\n // Add product to cart\n cy.addProduct(productName, { proceedtoCheckout: true })\n })\n\n it(`In ${prefix} - Updating product quantity to 1`, updateRetry(4), () => {\n // Update Product quantity to 1\n cy.updateProductQuantity(productName, {\n quantity: productQuantity,\n verifySubTotal: false,\n })\n })\n\n it(`In ${prefix} - Updating Shipping Information`, updateRetry(4), () => {\n // Update Shipping Section\n cy.updateShippingInformation({ postalCode, phoneNumber: '(312) 310 3249' })\n })\n\n completeThePayment(discountProduct, discountProductEnvs)\n\n verifyOrderStatus({\n product: discountProduct,\n env: discountProductEnvs.orderIdEnv,\n status: /handling/,\n timeout: 30000,\n })\n\n cancelTheOrder(discountProductEnvs.orderIdEnv)\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_8298687b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/affirm/wipe.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { loginViaCookies } from '../../support/common/support.js'\nimport {\n setWorkspaceAndGatewayAffiliations,\n deleteAddresses,\n} from '../../support/common/testcase.js'\n\ndescribe('Wipe affirm in dynamic environment', () => {\n loginViaCookies()\n\n setWorkspaceAndGatewayAffiliations({ wipe: true })\n deleteAddresses()\n})\n\n```"
}
] |
code_cy-runner_b926b124
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/affirm/2.8-fullRefund.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { singleProduct } from '../../support/affirm/outputvalidation.js'\nimport { refund } from '../../support/common/refund_apis.js'\nimport { getTestVariables } from '../../support/common/testcase.js'\nimport { loginViaCookies } from '../../support/common/support.js'\nimport { getRefundPayload } from '../../support/common/refund.js'\nimport { verifyTransactionInAffirm } from '../../support/affirm/api_testcase.js'\n\ndescribe('Testing Affirm transaction API for full refund', () => {\n const singleProductEnvs = getTestVariables(singleProduct.prefix)\n const { orderIdEnv } = singleProductEnvs\n\n loginViaCookies()\n\n it('Verify whether we have an order to request for full refund', () => {\n cy.getOrderItems().then((order) => {\n if (!order[orderIdEnv]) {\n throw new Error('Order id is missing')\n }\n })\n })\n\n // Request full refund for the ordered product added in 2.2-singleProduct.spec.js & verify paypal transaction\n refund(\n {\n total: singleProduct.getFullRefundTotal, // Amount\n title: 'full', // Refund Type for test case title\n env: orderIdEnv, // variable name where we stored the orderid in node environment\n },\n getRefundPayload\n )\n\n verifyTransactionInAffirm(singleProduct, singleProductEnvs, true)\n})\n\n```"
}
] |
code_cy-runner_d9f37ee7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/affirm/2.2-singleProduct.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/expect-expect */\nimport {\n loginViaCookies,\n preserveCookie,\n updateRetry,\n} from '../../support/common/support.js'\nimport { singleProduct } from '../../support/affirm/outputvalidation'\nimport { getTestVariables } from '../../support/common/testcase.js'\nimport { completeThePayment } from '../../support/affirm/testcase.js'\n\nconst { prefix, productName, postalCode, productQuantity } = singleProduct\n\nconst singleProductEnvs = getTestVariables(prefix)\n\ndescribe(`${prefix} Scenarios`, () => {\n loginViaCookies()\n\n it(`In ${prefix} - Adding Product to Cart`, updateRetry(1), () => {\n // Search the product\n cy.searchProduct(productName)\n // Add product to cart\n cy.addProduct(productName, { proceedtoCheckout: true })\n })\n\n it(`In ${prefix} - Updating product quantity to 2`, updateRetry(4), () => {\n // Update Product quantity to 2\n cy.updateProductQuantity(productName, {\n quantity: productQuantity,\n verifySubTotal: false,\n })\n })\n\n it(`In ${prefix} - Updating Shipping Information`, updateRetry(4), () => {\n // Update Shipping Section\n cy.updateShippingInformation({\n postalCode,\n phoneNumber: '(312) 310 3249',\n timeout: 10000,\n })\n })\n\n completeThePayment(singleProduct, singleProductEnvs)\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_bbe66eaa
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/affirm/2.9-partialRefund.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/expect-expect */\nimport { multiProduct } from '../../support/affirm/outputvalidation.js'\nimport { refund } from '../../support/common/refund_apis.js'\nimport { getTestVariables } from '../../support/common/testcase.js'\nimport { loginViaCookies } from '../../support/common/support.js'\nimport { getRefundPayload } from '../../support/common/refund.js'\nimport { verifyTransactionInAffirm } from '../../support/affirm/api_testcase.js'\n\ndescribe('Testing Affirm transaction API for partial refund', () => {\n const multiProductEnvs = getTestVariables(multiProduct.prefix)\n const { orderIdEnv } = multiProductEnvs\n\n loginViaCookies()\n\n it('Verify whether we have an order to request for partial refund', () => {\n cy.getOrderItems().then((order) => {\n if (!order[orderIdEnv]) {\n throw new Error('Order id is missing')\n }\n })\n })\n\n // Request partial refund for the ordered product added in 2.3-multiProduct.spec.js\n refund(\n {\n total: multiProduct.refundedAmount, // Amount\n title: 'partial', // Refund Type for test case title\n env: orderIdEnv, // variable name where we stored the orderid in node environment\n },\n getRefundPayload\n )\n\n verifyTransactionInAffirm(multiProduct, multiProductEnvs, true)\n})\n\n```"
}
] |
code_cy-runner_737fc156
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/affirm/post_setup.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n scroll,\n updateRetry,\n} from '../../support/common/support.js'\nimport {\n setWorkspaceAndGatewayAffiliations,\n startPaymentE2ETests,\n syncCheckoutUICustom,\n} from '../../support/common/testcase.js'\nimport selectors from '../../support/common/selectors'\n\nfunction verifyAffirmPromotion() {\n cy.get(selectors.AffirmPromoComponents, { timeout: 20000 }).should(\n 'be.visible'\n )\n cy.get(selectors.AffirmModal).should('be.visible').first().click()\n cy.get(selectors.AffirmIFrame).should('be.visible')\n cy.getIframeBody(selectors.AffirmIFrame)\n .find(selectors.AffirmClosePopup)\n .should('be.visible')\n .click()\n}\n\ndescribe('Setting up affirm in dynamic environment', () => {\n loginViaCookies()\n\n startPaymentE2ETests()\n setWorkspaceAndGatewayAffiliations()\n syncCheckoutUICustom()\n\n it('Set public token in affirm settigs', () => {\n cy.getVtexItems().then((vtex) => {\n cy.visit('/admin/apps/vtex.affirm-payment/setup/')\n cy.getIframeBody(selectors.AdminConfigurationIFrame)\n .find(selectors.AffirmAdminPublicKey)\n .should('be.visible')\n .clear()\n .type(vtex.publicKeyForPromotionalComponents)\n cy.getIframeBody(selectors.AdminConfigurationIFrame)\n .find(selectors.AffirmSubmitConfiguration)\n .should('be.visible')\n .click()\n })\n })\n\n it('Verify promotions get displayed in storefront', updateRetry(1), () => {\n cy.visit('/')\n cy.waitForSession()\n cy.get(selectors.ProfileLabel, { timeout: 20000 })\n .should('be.visible')\n .should('have.contain', `Hello,`)\n scroll()\n verifyAffirmPromotion()\n cy.url().should('include', '/p')\n cy.get('div[class*=shippingContainer]').should('be.visible')\n verifyAffirmPromotion()\n })\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_20bbefdd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/affirm/2.5-validate-invalid-phonenumber-in-checkout-page.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/expect-expect */\nimport {\n preserveCookie,\n updateRetry,\n loginViaCookies,\n} from '../../support/common/support'\nimport { getTestVariables } from '../../support/common/testcase'\nimport {\n completeThePayment,\n initiatePayment,\n} from '../../support/affirm/testcase.js'\nimport selectors from '../../support/common/selectors'\nimport { discountShipping } from '../../support/affirm/outputvalidation'\n\nconst { productName, postalCode, prefix, productQuantity } = discountShipping\nconst discountShippingProductEnvs = getTestVariables(prefix)\n\ndescribe(`${prefix} Scenarios`, () => {\n loginViaCookies()\n\n it(`In ${prefix} - Adding Product to Cart`, updateRetry(1), () => {\n // Search the product\n cy.searchProduct(productName)\n // Add product to cart\n cy.addProduct(productName)\n })\n\n it(`In ${prefix} - Updating product quantity to 1`, updateRetry(4), () => {\n // Update Product quantity to 1\n cy.updateProductQuantity(productName, {\n quantity: productQuantity,\n verifySubTotal: false,\n })\n })\n\n it(`In ${prefix} - Update Shipping Information`, updateRetry(4), () => {\n cy.updateShippingInformation({ postalCode })\n })\n\n initiatePayment({\n prefix,\n expectedPhoneNo: '(304) 123 4556',\n completePayment: false,\n retries: 2,\n })\n\n it(\n `In ${prefix} - Validate with invalid phone number`,\n updateRetry(3),\n () => {\n cy.intercept('POST', `https://sandbox.affirm.com/api/v2/checkout/`).as(\n 'updateOrderFormShipping'\n )\n\n /* eslint-disable jest/valid-expect-in-promise */\n cy.wait('@updateOrderFormShipping')\n .its('response')\n .then((response) => {\n expect(response.body.message).includes('Please enter a valid mobile')\n })\n }\n )\n\n it(`In ${prefix} - close the pop up`, updateRetry(3), () => {\n cy.getIframeBody(selectors.popUpClose).should('be.visible')\n cy.getIframeBody(selectors.popUpClose)\n .find(selectors.invalidPopUpCloseBtn)\n .should('be.visible')\n .click()\n // eslint-disable-next-line cypress/no-unnecessary-waiting\n cy.wait(10000)\n cy.get(selectors.dataReviewCloseBtn).click()\n })\n\n completeThePayment(discountShipping, discountShippingProductEnvs)\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_ea7f9893
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/affirm/2.6-external-seller.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/expect-expect */\nimport { loginViaCookies, updateRetry } from '../../support/common/support.js'\nimport { externalSeller } from '../../support/affirm/outputvalidation.js'\nimport {\n getTestVariables,\n invoiceAPITestCase,\n sendInvoiceTestCase,\n} from '../../support/common/testcase.js'\nimport { completeThePayment } from '../../support/affirm/testcase.js'\n\nconst { prefix, product1Name, product2Name, postalCode } = externalSeller\nconst externalSellerEnvs = getTestVariables(prefix)\n\nexternalSellerEnvs.sendInvoice = false\n\ndescribe(`${prefix} Scenarios`, () => {\n loginViaCookies()\n\n it(`In ${prefix} - Adding Product to Cart`, updateRetry(1), () => {\n // Search the product\n cy.searchProduct(product1Name)\n // Add product to cart\n cy.addProduct(product1Name, {\n proceedtoCheckout: false,\n })\n // Search the product\n cy.searchProduct(product2Name)\n // Add product to cart\n cy.addProduct(product2Name, {\n proceedtoCheckout: true,\n })\n })\n\n it(`In ${prefix} - Updating Shipping Information`, updateRetry(4), () => {\n // Update Shipping Section\n cy.updateShippingInformation({\n postalCode,\n phoneNumber: '(312) 310 3249',\n })\n })\n\n completeThePayment(externalSeller, externalSellerEnvs, true)\n})\n\ndescribe('Testing Invoice API for Direct Sale', () => {\n it('Get Direct Sale orderId and update in Cypress env', () => {\n cy.getOrderItems().then((order) => {\n if (!order[externalSeller.directSaleEnv]) {\n throw new Error('Direct Sale Order id is missing')\n }\n })\n })\n\n sendInvoiceTestCase({\n product: externalSeller,\n orderIdEnv: externalSeller.directSaleEnv,\n externalSellerTestcase: true,\n })\n\n // Get transactionId from invoiceAPI and store in .orders.json\n invoiceAPITestCase({\n product: externalSeller,\n env: externalSeller.directSaleEnv,\n transactionIdEnv: externalSellerEnvs.transactionIdEnv,\n })\n})\n\ndescribe('Testing Invoice API for External Sale', () => {\n it('Get External Sale orderId and update in Cypress env', () => {\n cy.getOrderItems().then((order) => {\n if (!order[externalSeller.externalSaleEnv]) {\n throw new Error('External Sale Order id is missing')\n }\n })\n })\n\n sendInvoiceTestCase({\n product: externalSeller,\n orderIdEnv: externalSeller.externalSaleEnv,\n externalSellerTestcase: true,\n })\n\n // Get transactionId from invoiceAPI and store in .orders.json\n invoiceAPITestCase({\n product: externalSeller,\n env: externalSeller.externalSaleEnv,\n transactionIdEnv: externalSellerEnvs.transactionIdEnv,\n })\n})\n\n```"
}
] |
code_cy-runner_d2a63cf0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/affirm/2.3-multiProduct.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/expect-expect */\nimport {\n loginViaCookies,\n preserveCookie,\n updateRetry,\n} from '../../support/common/support.js'\nimport { multiProduct } from '../../support/affirm/outputvalidation.js'\nimport { getTestVariables } from '../../support/common/testcase.js'\nimport { completeThePayment } from '../../support/affirm/testcase.js'\n\nconst { prefix, product1Name, product2Name, postalCode, productQuantity } =\n multiProduct\n\ndescribe(`${prefix} Scenarios`, () => {\n loginViaCookies()\n\n const multiProductEnvs = getTestVariables(prefix)\n\n it(`In ${prefix} - Adding Product to Cart`, updateRetry(1), () => {\n // Search the product\n cy.searchProduct(product1Name)\n // Add product to cart\n cy.addProduct(product1Name, { proceedtoCheckout: false })\n // Search the product\n cy.searchProduct(product2Name)\n // Add product to cart\n cy.addProduct(product2Name, {\n proceedtoCheckout: true,\n })\n })\n\n it(`In ${prefix} - Updating product quantity to 2`, updateRetry(4), () => {\n // Update Product quantity to 2\n cy.updateProductQuantity(product1Name, {\n quantity: productQuantity,\n verifySubTotal: false,\n })\n })\n\n it(`In ${prefix} - Updating Shipping Information`, updateRetry(4), () => {\n // Update Shipping Section\n cy.updateShippingInformation({\n postalCode,\n phoneNumber: '(312) 310 3249',\n timeout: 10000,\n })\n })\n\n completeThePayment(multiProduct, multiProductEnvs)\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_d1385489
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/affirm/2.1-graphql.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { updateRetry, loginViaCookies } from '../../support/common/support'\nimport {\n graphql,\n version,\n affirmSettings,\n orderData,\n validateGetVersionResponse,\n validateAffirmSettingsResponse,\n validateOrderDataResponse,\n} from '../../support/affirm/graphql_testcase'\n\nconst prefix = 'Graphql testcase'\n\ndescribe('Affirm GraphQL Validation', () => {\n loginViaCookies()\n\n it(`${prefix} - Get Version`, updateRetry(3), () => {\n graphql(version(), validateGetVersionResponse)\n })\n\n it(`${prefix} - Affirm Settings`, updateRetry(3), () => {\n graphql(affirmSettings(), validateAffirmSettingsResponse)\n })\n\n it(`${prefix} - Get Order Data`, updateRetry(3), () => {\n graphql(orderData(), validateOrderDataResponse)\n })\n})\n\n```"
}
] |
code_cy-runner_2389ae71
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/affirm/2.7-transactions.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/expect-expect */\nimport { loginViaCookies } from '../../support/common/support.js'\nimport {\n singleProduct,\n multiProduct,\n discountShipping,\n discountProduct,\n} from '../../support/affirm/outputvalidation'\nimport {\n getTestVariables,\n verifyTransactionPaymentsAPITestCase,\n} from '../../support/common/testcase.js'\nimport { verifyTransactionInAffirm } from '../../support/affirm/api_testcase.js'\n\ndescribe(`Transaction Scenarios`, () => {\n loginViaCookies()\n\n const singleProductEnvs = getTestVariables(singleProduct.prefix)\n const multiProductEnvs = getTestVariables(multiProduct.prefix)\n const discountShippingEnvs = getTestVariables(discountShipping.prefix)\n const discountProductEnvs = getTestVariables(discountProduct.prefix)\n\n verifyTransactionPaymentsAPITestCase(singleProduct, singleProductEnvs)\n verifyTransactionPaymentsAPITestCase(multiProduct, multiProductEnvs)\n verifyTransactionPaymentsAPITestCase(discountProduct, discountProductEnvs)\n verifyTransactionPaymentsAPITestCase(discountShipping, discountShippingEnvs)\n\n verifyTransactionInAffirm(singleProduct, singleProductEnvs)\n verifyTransactionInAffirm(multiProduct, multiProductEnvs)\n verifyTransactionInAffirm(discountProduct, discountProductEnvs, true) // Verify cancelled order amount is refunded\n verifyTransactionInAffirm(discountShipping, discountShippingEnvs)\n\n /* \n TODO: ExternalSeller shows popup randomly inside and outside the window\n So, for now we disabled this test \n Once it is fixed then will enable again\n https://www.loom.com/share/efe711c4883243058989a712a62dadb9\n const externalSellerEnvs = getTestVariables(externalSeller.prefix)\n verifyTransactionPaymentsAPITestCase(externalSeller, externalSellerEnvs)\n verifyTransactionInAffirm(externalSeller, externalSellerEnvs)\n */\n})\n\n```"
}
] |
code_cy-runner_038a56bf
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/quick-order/wipe.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { loginViaCookies } from '../../support/common/support.js'\nimport { deleteAddresses } from '../../support/common/testcase.js'\n\ndescribe('Wipe addresses in dynamic environment', () => {\n loginViaCookies()\n\n deleteAddresses()\n})\n\n```"
}
] |
code_cy-runner_82b14548
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/quick-order/1.3.1-upload_csv.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n updateRetry,\n} from '../../support/common/support.js'\nimport { quickOrderByXLS } from '../../support/quick-order/testcase.js'\n\ndescribe('Quickorder - Upload CSV testcase', () => {\n loginViaCookies()\n\n quickOrderByXLS(false)\n\n it(\n `In Upload CSV testcase - Verify quantity by price`,\n updateRetry(4),\n () => {\n cy.qe(\n 'Verify the quantity in the quantity badge and the first item should contain 2 and last item should contain 50'\n )\n cy.get('.quantity.badge').first().should('have.text', '2')\n cy.get('.quantity.badge').last().should('have.text', '50')\n }\n )\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_167c8d7d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/quick-order/1.2.1-skucode_quantity.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n updateRetry,\n} from '../../support/common/support.js'\nimport { quickOrderBySkuAndQuantityTestCase1 } from '../../support/quick-order/testcase.js'\nimport { graphql } from '../../support/common/graphql_utils.js'\nimport {\n APP,\n getSkuFromRefIds,\n validateSkuFromRefIdsResponse,\n} from '../../support/quick-order/graphql.js'\n\ndescribe('Quickorder - SkuCode Quantity testcase', () => {\n loginViaCookies()\n\n quickOrderBySkuAndQuantityTestCase1('user', null)\n\n // eslint-disable-next-line jest/expect-expect\n it(\n `In SkuCode Quantity testcase - Verify quantity by price & getSkuFromRefIds graphql`,\n updateRetry(4),\n () => {\n cy.qe(`Verify the quantity to 2 in the checkout page`)\n cy.get('.quantity.badge').first().should('have.text', '2')\n cy.window().then(($win) => {\n cy.qe(`Get Sku's from orderformId using GraphQL\n `)\n graphql(\n APP,\n getSkuFromRefIds($win.vtexjs.checkout.orderForm.orderFormId),\n validateSkuFromRefIdsResponse\n )\n })\n }\n )\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_a663cac7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/quick-order/1.2.2-skucode_quantity_negative_testcase.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport {\n quickOrderBySkuAndQuantityWithValidAndInValidSkuTestCase,\n quickOrderBySkuAnd51QuantityTestCase,\n} from '../../support/quick-order/testcase.js'\n\ndescribe('Quickorder - SkuCode Quantity Negative testcases', () => {\n loginViaCookies()\n\n quickOrderBySkuAndQuantityWithValidAndInValidSkuTestCase('user', null)\n quickOrderBySkuAnd51QuantityTestCase('user', null)\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_19d80519
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/quick-order/1.3.3_download-spreadsheet_verify_data&extension.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n updateRetry,\n} from '../../support/common/support.js'\nimport { verifyExcelFile } from '../../support/quick-order/testcase'\nimport { products } from '../../support/quick-order/product.js'\n\nconst fileName = 'cypress-shared/downloads/model-quickorder.xls'\n\ndescribe('Quickorder - Verify the data and extension in the spreadsheet', () => {\n loginViaCookies()\n\n it('Download the quickOrder spreadsheet', updateRetry(3), () => {\n cy.qe(`Visit the Quickorder Homepage and verify the profile is visible`)\n cy.qe('Verify the url should contain quickorder')\n cy.gotoQuickOrder()\n cy.contains('Click here to download a spreadsheet model').click()\n })\n\n verifyExcelFile(fileName, products)\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_2f3de043
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/quick-order/1.5-categories.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport {\n quickOrderByCategoryNegativeTestCase,\n quickOrderByCategory,\n} from '../../support/quick-order/testcase.js'\n\ndescribe('Quickorder - Category testcases', () => {\n loginViaCookies()\n\n quickOrderByCategory('user', null)\n quickOrderByCategoryNegativeTestCase('user', null)\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_8fd2d3ec
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/quick-order/1.4-one_by_one.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport {\n quickOrderByOneByOneTestCase,\n quickOrderByOneByOneNegativeTestCase,\n} from '../../support/quick-order/testcase.js'\nimport { PRODUCTS } from '../../support/common/utils.js'\n\ndescribe('Quickorder - Category testcases', () => {\n loginViaCookies()\n\n quickOrderByOneByOneTestCase('user', PRODUCTS.coconut, null)\n quickOrderByOneByOneNegativeTestCase('user', PRODUCTS.coconut, null)\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_79b1cdda
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/quick-order/1.1-graphql.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { graphql } from '../../support/common/graphql_utils.js'\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport {\n APP,\n getSellers,\n validateSellers,\n} from '../../support/quick-order/graphql.js'\n\ndescribe('Graphql testcase', () => {\n loginViaCookies()\n\n it('seller query', () => {\n cy.qe(`\n seller query - 'query' +\n '{sellers @context(provider: \"vtex.quickorder\")' +\n '{items{id,name}}}',\n `)\n graphql(APP, getSellers(), validateSellers)\n })\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_aeb2d563
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/location-availability/2.4-location-not-available.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n preserveCookie,\n updateRetry,\n loginViaAPI,\n} from '../../support/common/support'\nimport { canadaDetails } from '../../support/shopper-location/outputvalidation'\nimport selectors from '../../support/common/selectors'\nimport { addAddress } from '../../support/shopper-location/common'\nimport { PRODUCTS_LINK_MAPPING } from '../../support/common/utils'\n\nconst prefix = 'Pickup not available'\n\ndescribe('Validate location non availability', () => {\n loginViaAPI()\n\n addAddress(prefix, { address: canadaDetails })\n\n // eslint-disable-next-line jest/expect-expect\n it(`${prefix} - Verify shipping content`, updateRetry(2), () => {\n cy.qe('Product image should be visible on the home page')\n cy.get(PRODUCTS_LINK_MAPPING.orange.link).should('be.visible')\n cy.qe('For the given shipping address the shipping is unavailable')\n cy.get(selectors.locationUnavailable)\n .should('be.visible')\n .contains('Shipping: Unavailable for')\n })\n\n // eslint-disable-next-line jest/expect-expect\n it(\n `${prefix} - Open product specfication page and verify`,\n updateRetry(2),\n () => {\n cy.openProduct(PRODUCTS_LINK_MAPPING.orange.name, true, true)\n cy.qe(\n 'Verifying the given shipping address in specification page is not available for pickup near your location'\n )\n cy.get(selectors.storeUnavailabilityInformation)\n .should('be.visible')\n .contains(\n 'The selected item is not available for pickup near your location.'\n )\n }\n )\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_68a6805b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/location-availability/wipe.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/valid-expect */\nimport {\n graphql,\n updateShippingPolicy,\n} from '../../support/common/shipping-policy.graphql'\nimport data from '../../support/location-availability/shipping-policy.json'\nimport {\n loginViaCookies,\n preserveCookie,\n} from '../../support/common/support.js'\nimport { deleteAllPickupPoints } from '../../support/location-availability/support'\n\ndescribe('Wipe the pickup points', () => {\n loginViaCookies({ storeFrontCookie: false })\n\n deleteAllPickupPoints()\n\n // If we leave the shipping policy active then it is forcing us to use pickup points in checkout\n // So, make shipping policy as inactive\n it('Update shipping policy status to inactive', () => {\n cy.qe(\n 'If we leave the shipping policy active then it is forcing us to use pickup points in checkout,So make shipping policy as inactive'\n )\n graphql(\n updateShippingPolicy(data.ship1, { status: false, pickup: false }),\n (response) => {\n expect(response.status).to.equal(200)\n }\n )\n graphql(\n updateShippingPolicy(data.ship2, { status: false, pickup: false }),\n (response) => {\n expect(response.status).to.equal(200)\n }\n )\n })\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_91ed638b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/location-availability/2.3-location-availability.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/expect-expect */\nimport {\n preserveCookie,\n updateRetry,\n loginViaAPI,\n} from '../../support/common/support'\nimport { UsDetails3 } from '../../support/shopper-location/outputvalidation'\nimport selectors from '../../support/common/selectors'\nimport { verifyHomePage } from '../../support/shopper-location/common'\nimport { PRODUCTS_LINK_MAPPING } from '../../support/common/utils'\n\nconst { country, postalCode, address, city } = UsDetails3\n\nconst prefix = 'Shipping not avaiable'\n\ndescribe('Validate location availability', () => {\n loginViaAPI()\n\n // eslint-disable-next-line jest/expect-expect\n it(`${prefix} - Go to home and add location`, updateRetry(1), () => {\n cy.addNewLocation(country, postalCode, address, city)\n cy.get(PRODUCTS_LINK_MAPPING.orange.link).should('be.visible')\n verifyHomePage(city, postalCode)\n })\n\n it(\n `${prefix} - Open product specfication page and verify`,\n updateRetry(1),\n () => {\n cy.openProduct(PRODUCTS_LINK_MAPPING.orange.name, true)\n cy.qe('Postal code should be visible on the specification page')\n cy.get(selectors.AvailabilityHeader)\n .should('be.visible')\n .contains('33180')\n }\n )\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_b4bb54c6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/location-availability/2.5-Add-multiple-pickuppoint-and-update-shipping.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n updateRetry,\n preserveCookie,\n loginViaAPI,\n} from '../../support/common/support'\nimport { addPickUpPoint } from '../../support/location-availability/support'\nimport {\n graphql,\n updateShippingPolicy,\n} from '../../support/common/shipping-policy.graphql'\nimport data from '../../support/location-availability/shipping-policy.json'\n\nconst prefix = 'Multiple pickup points'\n\ndescribe('Adding Multiple pickup point & Update Shipping', () => {\n loginViaAPI()\n\n // eslint-disable-next-line jest/expect-expect\n it(`${prefix} - Add Multiple PickUp Point`, updateRetry(1), () => {\n cy.qe('Visit admin pickup points page')\n cy.visit('/admin/app/pickup-points')\n cy.qe('Adding 4 new pickup points')\n for (let id = 1; id <= 4; id++) {\n addPickUpPoint(`Location availability pickup Point ${id}`, id)\n }\n })\n\n it(`${prefix} - Add pickup points in shipping policy`, updateRetry(3), () => {\n data.ship1.shippingPolicy.pickupPointsSettings.pickupPointIds.push(\n '1',\n '2',\n '3'\n )\n cy.qe('Updating shipping policy via updateShippingPolicy graphql')\n graphql(\n updateShippingPolicy(data.ship1, { status: true, pickup: false }),\n (response) => {\n // eslint-disable-next-line jest/valid-expect\n expect(response.status).to.equal(200)\n }\n )\n })\n\n it(\n 'Add pickup points in Location Availability shipping policy',\n updateRetry(3),\n () => {\n data.ship2.shippingPolicy.pickupPointsSettings.pickupPointIds.push('4')\n graphql(\n updateShippingPolicy(data.ship2, { status: true, pickup: false }),\n (response) => {\n // eslint-disable-next-line jest/valid-expect\n expect(response.status).to.equal(200)\n }\n )\n }\n )\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_5df2f453
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/location-availability/2.6-Verify-location-availability props.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { UsDetails3 } from '../../support/shopper-location/outputvalidation'\nimport {\n addLocation,\n verifyHomePage,\n} from '../../support/shopper-location/common'\nimport {\n updateRetry,\n preserveCookie,\n loginViaAPI,\n} from '../../support/common/support'\nimport selectors from '../../support/common/selectors'\nimport { PRODUCTS_LINK_MAPPING } from '../../support/common/utils'\n\nconst { country, postalCode, city } = UsDetails3\n\nconst prefix = 'Location availability props'\n\ndescribe('Verify location availability props', () => {\n loginViaAPI()\n\n // eslint-disable-next-line jest/no-disabled-tests\n it(\n `${prefix} - Adding Location & Verify location Availability`,\n updateRetry(1),\n () => {\n addLocation({ country, postalCode })\n verifyHomePage(city, postalCode)\n }\n )\n\n // eslint-disable-next-line jest/no-disabled-tests\n it(\n `${prefix} - Search results & product specification`,\n updateRetry(3),\n () => {\n cy.openProduct(PRODUCTS_LINK_MAPPING.orange.name, true)\n // eslint-disable-next-line jest/valid-expect-in-promise\n cy.get('body').then(($body) => {\n expect(\n $body.find(selectors.VerifyMaxItem).length\n // eslint-disable-next-line jest/valid-expect\n ).to.equal(3)\n })\n cy.get(selectors.OrderByFaster).should('be.visible')\n }\n )\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_8d1253b7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/location-availability/2.8-verify-distance-not-show.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/expect-expect */\nimport {\n preserveCookie,\n updateRetry,\n loginViaAPI,\n} from '../../support/common/support'\nimport { UsDetails4 } from '../../support/shopper-location/outputvalidation'\nimport { verifyHomePage } from '../../support/location-availability/common'\n\nconst { country, postalCode, city, address } = UsDetails4\n\ndescribe('Verify distance not show in Home page', () => {\n loginViaAPI()\n\n // eslint-disable-next-line jest/expect-expect\n it(\n 'Go to home add location & verify distance not shows',\n updateRetry(3),\n () => {\n cy.addNewLocation(country, postalCode, address, city, true)\n verifyHomePage(city, postalCode, true)\n }\n )\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_7dfa67f1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/location-availability/2.7-Verify-location-availability-without-address-line.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/expect-expect */\nimport {\n preserveCookie,\n updateRetry,\n loginViaAPI,\n} from '../../support/common/support'\nimport { UsDetails3 } from '../../support/shopper-location/outputvalidation'\nimport selectors from '../../support/common/selectors'\nimport {\n addLocation,\n verifyHomePage,\n} from '../../support/shopper-location/common'\nimport { PRODUCTS_LINK_MAPPING } from '../../support/common/utils'\n\nconst { country, postalCode, city } = UsDetails3\n\ndescribe('Validate location availability without address line', () => {\n loginViaAPI()\n\n // eslint-disable-next-line jest/expect-expect\n it('Go to home and add location', updateRetry(1), () => {\n addLocation({ country, postalCode })\n verifyHomePage(city, postalCode)\n })\n\n it('Open product specfication page and verify', updateRetry(1), () => {\n cy.openProduct(PRODUCTS_LINK_MAPPING.orange.name, true)\n cy.get(selectors.AvailabilityHeader).should('be.visible').contains('33180')\n })\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_300c4bdd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/location-availability/2.2-enable-location-and-test.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n preserveCookie,\n updateRetry,\n loginViaAPI,\n} from '../../support/common/support'\nimport {\n UsDetails,\n UsDetails5,\n location,\n} from '../../support/shopper-location/outputvalidation'\nimport selectors from '../../support/common/selectors'\nimport { verifyUpdatedAddress } from '../../support/location-availability/support'\nimport { addAddress } from '../../support/shopper-location/common'\n\nconst { postalCode, address, city, state } = UsDetails5\nconst prefix = 'Enable location'\nconst product = 'coconuts'\n\ndescribe('Enable location validation', () => {\n loginViaAPI()\n\n addAddress(prefix, {\n address: UsDetails,\n lat: location.lat,\n long: location.long,\n })\n\n // eslint-disable-next-line jest/expect-expect\n it(`${prefix} - Open product`, updateRetry(1), () => {\n cy.qe('Address should be visible in the top left of the home page')\n cy.get(selectors.addressContainer).should('be.visible')\n cy.openProduct(product, true)\n })\n\n verifyUpdatedAddress(postalCode, address, city, state)\n\n // eslint-disable-next-line jest/expect-expect\n it('Ordering the product', updateRetry(2), () => {\n cy.orderProduct()\n })\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_32d20b88
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/integration/location-availability/2.1-disable-location-and-test.spec.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n preserveCookie,\n updateRetry,\n loginViaAPI,\n} from '../../support/common/support'\nimport selectors from '../../support/common/selectors'\n\nconst prefix = 'Disable location'\n\ndescribe('Disable location validation', () => {\n loginViaAPI()\n\n // eslint-disable-next-line jest/expect-expect\n it(`${prefix} - Open product`, updateRetry(1), () => {\n cy.openStoreFront()\n cy.qe('Address should be visible in the top left of the home page')\n cy.get(selectors.addressContainer).should('be.visible')\n cy.openProduct('coconuts', true)\n cy.qe(\n \"'Set your location to check availability' should be visible on the specification page\"\n )\n cy.get(selectors.NoAvailabilityHeader).should(\n 'have.text',\n 'Set your location to check availability'\n )\n })\n\n preserveCookie()\n})\n\n```"
}
] |
code_cy-runner_19057b99
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/adyen/graphql.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { updateRetry } from '../common/support'\n\nconst config = Cypress.env()\n\n// Constants\nconst { vtex } = config.base\n\nexport function updateAdyenConnectorSettings() {\n it(`Configuring connector adyen`, updateRetry(2), () => {\n const version = '*.x'\n const app = 'vtex.connector-adyen'\n // Define constants\n const APP_NAME = 'vtex.apps-graphql'\n const APP_VERSION = '3.x'\n const APP = `${APP_NAME}@${APP_VERSION}`\n const CUSTOM_URL = `${vtex.baseUrl}/_v/private/admin-graphql-ide/v0/${APP}`\n const GRAPHQL_MUTATION =\n 'mutation' +\n '($app:String,$version:String,$settings:String)' +\n '{saveAppSettings(app:$app,version:$version,settings:$settings){message}}'\n\n const QUERY_VARIABLES = {\n app,\n version,\n settings: JSON.stringify({\n merchantAccount: vtex.merchantAccount,\n apiKey: vtex.adyenApiKey,\n productionAPI: vtex.adyenProductionAPI,\n webhookUsername: vtex.adyenWebhookUsername,\n webhookPassword: vtex.adyenWebhookPassword,\n useAdyenPlatforms: true,\n vtexAppKey: vtex.apiKey,\n vtexAppToken: vtex.apiToken,\n }),\n }\n\n // Mutating it to the new workspace\n cy.callGraphqlAndAddLogs({\n url: CUSTOM_URL,\n query: GRAPHQL_MUTATION,\n variables: QUERY_VARIABLES,\n }).its('body.data.saveAppSettings.message', { timeout: 10000 })\n })\n}\n\nexport function updateAdyenPlatformSettings() {\n it(`Configuring adyen platform`, updateRetry(2), () => {\n // Define constants\n const version = '*.x'\n const app = 'vtex.adyen-platforms'\n const APP_NAME = 'vtex.apps-graphql'\n const APP_VERSION = '3.x'\n const APP = `${APP_NAME}@${APP_VERSION}`\n const CUSTOM_URL = `${vtex.baseUrl}/_v/private/admin-graphql-ide/v0/${APP}`\n const GRAPHQL_MUTATION =\n 'mutation' +\n '($app:String,$version:String,$settings:String)' +\n '{saveAppSettings(app:$app,version:$version,settings:$settings){message}}'\n\n const QUERY_VARIABLES = {\n app,\n version,\n settings: JSON.stringify({\n apiKey: vtex.adyenPlatformApiKey,\n productionAPI: vtex.adyenPlatformProductionAPI,\n }),\n }\n\n // Mutating it to the new workspace\n cy.callGraphqlAndAddLogs({\n url: CUSTOM_URL,\n query: GRAPHQL_MUTATION,\n variables: QUERY_VARIABLES,\n }).its('body.data.saveAppSettings.message', { timeout: 10000 })\n })\n}\n\n```"
}
] |
code_cy-runner_57e1b2bb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/adyen/testcase.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport selectors from '../common/selectors'\nimport { fillContactInfo, saveOrderId, updateRetry } from '../common/support'\nimport {\n invoiceAPITestCase,\n sendInvoiceTestCase,\n verifyOrderStatus,\n verifyTransactionPaymentsAPITestCase,\n startHandlingOrder,\n} from '../common/testcase'\nimport { verifyOrderInAdyen } from './adyen_apis'\n\nconst config = Cypress.env()\nconst accountHolderCodeJson = '.accountholderCode.json'\n\n// Constants\nconst { vtex } = config.base\nconst {\n adyenLoginUrl,\n adyenLoginUsername,\n adyenLoginAccount,\n adyenLoginPassword,\n} = config.base.vtex\n\nexport function completePaymentWithDinersCard(\n prefix,\n orderIdEnv,\n externalSeller = false\n) {\n it(`In ${prefix} - Ordering the product`, updateRetry(2), () => {\n cy.get(selectors.FirstName).then(($el) => {\n if (Cypress.dom.isVisible($el)) {\n fillContactInfo()\n }\n })\n cy.qe('Click Credit Card option in checkout')\n cy.get(selectors.CreditCardLink).click()\n\n cy.getIframeBody(selectors.PaymentMethodIFrame).then(($body) => {\n if (!$body.find(selectors.CardExist).length) {\n cy.qe('Card not found in the page')\n cy.qe(\"Let's add new card \")\n // Credit cart not exist\n // https://docs.adyen.com/development-resources/testing/test-card-numbers#diners\n const [cardNumber, cardHolderName, expirationMonth, expirationYear] = [\n '3600 6666 3333 44',\n 'Testing',\n '03',\n '30',\n ]\n\n cy.qe(`Type cardNumber - ${cardNumber}`)\n cy.getIframeBody(selectors.PaymentMethodIFrame)\n .find(selectors.CreditCardNumber)\n .type(cardNumber)\n cy.qe(`Type cardHolderName - ${cardHolderName}`)\n cy.getIframeBody(selectors.PaymentMethodIFrame)\n .find(selectors.CreditCardHolderName)\n .type(cardHolderName)\n cy.qe(`Select CreditCardExpirationMonth - ${expirationMonth}`)\n cy.getIframeBody(selectors.PaymentMethodIFrame)\n .find(selectors.CreditCardExpirationMonth)\n .select(expirationMonth)\n cy.qe(`Select CreditCardExpirationYear - ${expirationYear}`)\n cy.getIframeBody(selectors.PaymentMethodIFrame)\n .find(selectors.CreditCardExpirationYear)\n .select(expirationYear)\n }\n\n cy.getIframeBody(selectors.PaymentMethodIFrame).then(($paymentBtn) => {\n if ($paymentBtn.find(selectors.PaymentMethodIFrame).length) {\n cy.qe(\"Diners card found in page let's open it\")\n cy.getIframeBody(selectors.PaymentMethodIFrame)\n .find('.SavedCard span[class*=Diners]')\n .click()\n }\n })\n\n cy.qe('Type CreditCardCode as 737')\n cy.getIframeBody(selectors.PaymentMethodIFrame)\n .find(selectors.CreditCardCode)\n .type('737')\n cy.qe('Click BuyNow button (available at top right side)')\n cy.get(selectors.BuyNowBtn).last().click()\n saveOrderId(orderIdEnv, externalSeller)\n })\n })\n}\n\nexport function verifyAdyenConnectorSettings() {\n it(`Verify adyen connector settings in UI`, updateRetry(2), () => {\n cy.qe('Visit /admin/adyen')\n cy.visit('/admin/adyen')\n cy.localqe(\n `Find Adyen Merchant Account input field and verify it has value ${vtex.merchantAccount}`\n )\n cy.getIframeBody(selectors.AdyenAdminIframe)\n .find(selectors.AdyenAdminSectionPB4)\n .contains('Adyen Merchant Account')\n .find('input')\n .should('have.value', vtex.merchantAccount)\n cy.localqe(\n `Find Adyen API Key input field and verify it has value ${vtex.adyenApiKey}`\n )\n cy.getIframeBody(selectors.AdyenAdminIframe)\n .find(selectors.AdyenAdminSectionPB4)\n .contains('Adyen API Key')\n .find('input')\n .should('have.value', vtex.adyenApiKey)\n cy.localqe(\n `Find Adyen Production API URI input field and verify it has value ${vtex.adyenProductionAPI}`\n )\n cy.getIframeBody(selectors.AdyenAdminIframe)\n .find(selectors.AdyenAdminSectionPB4)\n .contains('Adyen Production API URI')\n .find('input')\n .should('have.value', vtex.adyenProductionAPI)\n cy.localqe(\n `Find Adyen Webhook Username input field and verify it has value ${vtex.adyenWebhookUsername}`\n )\n cy.getIframeBody(selectors.AdyenAdminIframe)\n .find(selectors.AdyenAdminSectionPB4)\n .contains('Adyen Webhook Username')\n .find('input')\n .should('have.value', vtex.adyenWebhookUsername)\n cy.localqe(\n `Find Adyen Webhook Password input field and verify it has value ${vtex.adyenWebhookPassword}`\n )\n cy.getIframeBody(selectors.AdyenAdminIframe)\n .find(selectors.AdyenAdminSectionPB4)\n .contains('Adyen Webhook Password')\n .find('input')\n .should('have.value', vtex.adyenWebhookPassword)\n cy.localqe(\n `Find VTEX App Key input field and verify it has value ${vtex.apiKey}`\n )\n cy.getIframeBody(selectors.AdyenAdminIframe)\n .find(selectors.AdyenAdminSectionPB4)\n .contains('VTEX App Key')\n .find('input')\n .should('have.value', vtex.apiKey)\n cy.localqe(\n `Find VTEX App Token input field and verify it has value ${vtex.apiToken}`\n )\n cy.getIframeBody(selectors.AdyenAdminIframe)\n .find(selectors.AdyenAdminSectionPB6)\n .contains('VTEX App Token')\n .find('input')\n .should('have.value', vtex.apiToken)\n cy.localqe(\n `Find AdyenAdminUsePlatformToggle and verify it has text Using Adyen for Platforms`\n )\n cy.getIframeBody(selectors.AdyenAdminIframe)\n .find(selectors.AdyenAdminUsePlatformToggle)\n .contains('Using Adyen for Platforms')\n .should('have.text', 'Using Adyen for Platforms')\n })\n}\n\nexport function verifyAdyenPlatformSettings() {\n it(`Verify adyen platform settings in UI`, updateRetry(2), () => {\n cy.qe('Visit /admin/app/adyen-for-platforms')\n cy.visit('/admin/app/adyen-for-platforms')\n cy.contains('Settings').should('be.visible')\n cy.qe('Settings section should be visible and click it')\n cy.contains('Settings').should('be.visible').click()\n cy.localqe(\n `Verify ${selectors.AdyenPlatformApiKey} should have value ${vtex.adyenPlatformApiKey}`\n )\n cy.get(selectors.AdyenPlatformApiKey).should(\n 'have.value',\n vtex.adyenPlatformApiKey\n )\n cy.localqe(\n `Verify ${selectors.AdyenPlatformProductionURI} should have value ${vtex.adyenPlatformProductionAPI}`\n )\n cy.get(selectors.AdyenPlatformProductionURI).should(\n 'have.value',\n vtex.adyenPlatformProductionAPI\n )\n })\n}\n\nexport function createOnBoardingLink(create) {\n it('Create the onboarding link', () => {\n const onBoardingInputField = 'input[value*=onboarding]'\n\n cy.qe('Visit /admin/app/adyen-for-platforms')\n cy.visit('/admin/app/adyen-for-platforms')\n cy.qe('Adyen for platforms & productusqa2 should be visible')\n cy.contains('Adyen for Platforms').should('be.visible')\n cy.contains('productusqa2').should('be.visible').click()\n if (create) {\n cy.intercept('POST', `${vtex.baseUrl}/**`).as('RefreshOnboarding')\n cy.qe(\n 'Intercept RefreshOnboarding and get accountHolderCode from response'\n )\n cy.qe('Click on Create new link button')\n cy.contains('Create New Link').should('be.visible')\n cy.contains('Create New Link').click()\n\n /* eslint-disable jest/valid-expect-in-promise */\n cy.wait('@RefreshOnboarding')\n .its('response')\n .then((response) => {\n expect(response)\n .to.have.property('body')\n .to.have.property('data')\n .to.have.property('adyenAccountHolder')\n .to.have.property('accountHolderCode')\n cy.qe('RefreshOnboarding should be called')\n cy.qe(\n `Write accountHolderCode - ${response.body.data.adyenAccountHolder.accountHolderCode} to ${accountHolderCodeJson}`\n )\n cy.writeFile(accountHolderCodeJson, {\n accountHolderCode:\n response.body.data.adyenAccountHolder.accountHolderCode,\n })\n })\n cy.qe('onBoardingInputField should be visible')\n cy.get(onBoardingInputField).should('be.visible')\n } else {\n cy.qe('onBoardingInputField should not exist')\n cy.get(onBoardingInputField).should('not.exist')\n }\n })\n}\n\nexport function loginToAdyen() {\n it('Login to adyen dashboard', updateRetry(2), () => {\n cy.qe(`Visit ${adyenLoginUrl}`)\n cy.visit(adyenLoginUrl)\n cy.get('body').then(($body) => {\n if (!$body.find('div.app').length) {\n cy.qe('We are not logged in')\n cy.localqe(`Type username - ${adyenLoginUsername}`)\n cy.get(selectors.AdyenLoginUsername).type(adyenLoginUsername, {\n log: false,\n })\n cy.localqe('Click Next')\n cy.contains('Next').click()\n cy.localqe(`Type account name - ${adyenLoginAccount}`)\n cy.get(selectors.AdyenLoginAccount).type(adyenLoginAccount, {\n log: false,\n })\n cy.localqe(`Type password - ${adyenLoginPassword}`)\n cy.get(selectors.AdyenLoginPassword).type(adyenLoginPassword, {\n log: false,\n })\n cy.localqe('Submit the form for login')\n cy.get(selectors.AdyenLoginSubmit).click()\n } else {\n cy.qe('We are already logged in to adyen dashboard')\n }\n })\n })\n}\n\nexport function verifyProductInvoiceTestcase(\n product,\n env,\n externalSeller = false\n) {\n verifyOrderStatus({\n product,\n env: env.orderIdEnv,\n status: /handling|invoiced/,\n timeout: 30000,\n })\n\n startHandlingOrder(product, env.orderIdEnv)\n\n verifyOrderStatus({\n product,\n env: env.orderIdEnv,\n status: /handling|invoiced/,\n timeout: 30000,\n })\n\n if (externalSeller === true) {\n verifyExternalSellerInvoice(product, env)\n } else {\n sendInvoiceTestCase({\n product,\n orderIdEnv: env.orderIdEnv,\n })\n\n invoiceAPITestCase({\n product,\n env: env.orderIdEnv,\n transactionIdEnv: env.transactionIdEnv,\n })\n\n verifyOrderStatus({\n product,\n env: env.orderIdEnv,\n status: /handling|invoiced/,\n timeout: 30000,\n })\n }\n\n verifyOrderTransactions(product, env)\n}\n\nexport function verifyExternalSellerInvoice(externalSeller, env) {\n describe(`Testing Invoice API for Direct Sale`, () => {\n it('Get Direct Sale orderId and update in Cypress env', () => {\n cy.getOrderItems().then((order) => {\n if (!order[externalSeller.directSaleEnv]) {\n throw new Error('Direct Sale Order id is missing')\n }\n })\n })\n\n sendInvoiceTestCase({\n product: externalSeller,\n orderIdEnv: externalSeller.directSaleEnv,\n externalSellerTestcase: true,\n })\n\n // Get transactionId from invoiceAPI and store in .orders.json\n invoiceAPITestCase({\n product: externalSeller,\n env: externalSeller.directSaleEnv,\n transactionIdEnv: env.transactionIdEnv,\n })\n\n verifyOrderStatus({\n product: externalSeller,\n env: env.orderIdEnv,\n status: /handling|invoiced/,\n timeout: 30000,\n })\n })\n\n describe(`Testing Invoice API for External Sale`, () => {\n it('Get External Sale orderId and update in Cypress env', () => {\n cy.getOrderItems().then((order) => {\n if (!order[externalSeller.externalSaleEnv]) {\n throw new Error('External Sale Order id is missing')\n }\n })\n })\n\n sendInvoiceTestCase({\n product: externalSeller,\n orderIdEnv: externalSeller.externalSaleEnv,\n externalSellerTestcase: true,\n })\n\n invoiceAPITestCase({\n product: externalSeller,\n env: externalSeller.externalSaleEnv,\n })\n\n verifyOrderStatus({\n product: externalSeller,\n env: env.orderIdEnv,\n status: /handling|invoiced/,\n timeout: 30000,\n })\n })\n}\n\nfunction verifyOrderTransactions(product, env) {\n describe('Verify Order Transactions', updateRetry(2), () => {\n verifyTransactionPaymentsAPITestCase(product, env)\n verifyOrderInAdyen(product, env)\n })\n}\n\n```"
}
] |
code_cy-runner_9e9ab66e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/adyen/api_testcase.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { account, onboarding, hook } from './apis.js'\nimport { updateRetry } from '../common/support'\n\nconst accountHolderJson = '.accountholder.json'\nconst accountTokenJson = '.accounttoken.json'\nconst config = Cypress.env()\n\nconst { baseUrl, adyenWebhookUsername, adyenWebhookPassword } = config.base.vtex\n\nexport function getAllAccount(seller) {\n it('Get All List of Account', updateRetry(3), () => {\n cy.getVtexItems().then((vtex) => {\n cy.getAPI(account(vtex.baseUrl, seller)).then((response) => {\n cy.qe('Verify response status to equal 200')\n expect(response.status).to.have.equal(200)\n cy.qe('Get accountList information from response.body')\n cy.writeFile(accountHolderJson, { accountList: response.body })\n })\n })\n })\n}\n\nexport function getOnBoarding() {\n it('Get Onboarding', updateRetry(6), () => {\n cy.addDelayBetweenRetries(20000)\n cy.getVtexItems().then((vtex) => {\n cy.readFile(accountTokenJson).then((items) => {\n cy.getAPI(onboarding(vtex.baseUrl, items.accountToken.urlToken)).then(\n (response) => {\n cy.qe('Verify response status to equal 200')\n\n expect(response.status).to.have.equal(200)\n }\n )\n })\n })\n })\n}\n\nexport function Adyenhook(data) {\n it('Adyen Hook', updateRetry(3), () => {\n cy.callRestAPIAndAddLogs({\n url: hook(baseUrl),\n auth: {\n username: adyenWebhookUsername,\n password: adyenWebhookPassword,\n },\n body: data,\n }).then((response) => {\n cy.qe('Verify response status to equal 200')\n\n expect(response.status).to.have.equal(200)\n })\n })\n}\n\n```"
}
] |
code_cy-runner_fdde1ba6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/adyen/outputvalidation.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { PRODUCTS } from '../common/utils.js'\n\nexport default {\n createAccount: {\n accountHolderCode: `saravanantestqa${Date.now()\n .toString()\n .substring(6, 13)}`,\n sellerId: 'productusqa2',\n country: 'US',\n legalBusinessName: 'saravanan',\n email: 'saravanan.reddy@vtex.com.br',\n legalEntity: 'Business',\n processingTier: 0,\n },\n sellerAccount: 'productusqa2',\n schedule: 'MONTHLY',\n hook: {\n live: 'false',\n notificationItems: [\n {\n NotificationRequestItem: {\n eventCode: 'AUTHORISATION',\n success: 'true',\n eventDate: '2019-06-28T18:03:50+01:00',\n merchantAccountCode: 'YOUR_MERCHANT_ACCOUNT',\n pspReference: '7914073381342284',\n merchantReference: 'YOUR_REFERENCE',\n amount: {\n value: 1130,\n currency: 'EUR',\n },\n },\n },\n ],\n },\n\n singleProduct: {\n prefix: 'singleProduct',\n postalCode: '33180',\n productName: PRODUCTS.onion,\n productQuantity: '2',\n total: '$ 105.00',\n },\n multiProduct: {\n prefix: 'multiProduct',\n postalCode: '33180',\n total: '$ 203.33',\n product1Name: PRODUCTS.onion,\n product2Name: PRODUCTS.orange,\n productQuantity: '2',\n },\n discountProduct: {\n prefix: 'discountProduct',\n postalCode: '33180',\n total: '$ 95.00',\n productQuantity: '1',\n productName: PRODUCTS.cauliflower,\n env: 'discountProductEnv',\n },\n discountShipping: {\n prefix: 'discountShipping',\n postalCode: '90290',\n total: '$ 109.50',\n productQuantity: '1',\n productName: PRODUCTS.orange,\n env: 'discountShippingOrder',\n },\n externalSeller: {\n prefix: 'externalSeller',\n postalCode: '33180',\n product1Name: PRODUCTS.coconut,\n product2Name: PRODUCTS.tshirt,\n productQuantity: '2',\n directSaleEnv: 'directSaleEnv',\n externalSaleEnv: 'externalSaleEnv',\n },\n promotionProduct: {\n prefix: 'promotionalProduct',\n postalCode: '90290',\n total: '$ 24.77',\n productName: PRODUCTS.greenConventional,\n productQuantity: '2',\n env: 'promotionProductEnv',\n },\n requestRefund: {\n // orderId variable name for getFullRefundTotal\n fullRefundEnv: 'order1',\n // orderId variable name for getPartialRefund\n partialRefundEnv: 'order2',\n getFullRefundTotal: 10500,\n getPartialRefundTotal: 10500,\n },\n}\n\n```"
}
] |
code_cy-runner_acca0268
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/adyen/apis.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nexport default {\n account: (baseUrl, seller) => {\n return `${baseUrl}/_v/api/adyen-platforms/v0/account?seller=${seller}`\n },\n onboarding: (baseUrl, token) => {\n return `${baseUrl}/_v/api/adyen-platforms/v0/onboarding?token=${token}`\n },\n hook: (baseUrl) => {\n return `${baseUrl}/_v/api/connector-adyen/v0/hook`\n },\n}\n\n```"
}
] |
code_cy-runner_4e2296ee
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/adyen/adyen_apis.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { updateRetry } from '../common/support'\n\nconst config = Cypress.env()\nconst { name } = config.workspace\nconst {\n adyenCompanyID,\n adyenApiKey,\n baseUrl,\n adyenWebhookUsername,\n adyenWebhookPassword,\n} = config.base.vtex\n\nconst webhookJson = '.webhook.json'\n\nexport function createAdyenWebhook() {\n it(`Create standard notification webhook in Adyen`, updateRetry(4), () => {\n cy.addDelayBetweenRetries(10000)\n cy.callRestAPIAndAddLogs({\n url: `https://management-test.adyen.com/v1/companies/${adyenCompanyID}/webhooks`,\n headers: {\n 'X-API-Key': adyenApiKey,\n },\n body: {\n type: 'standard',\n url: `https://${name}--productusqa.myvtex.com/_v/api/connector-adyen/v0/hook`,\n username: adyenWebhookUsername,\n password: adyenWebhookPassword,\n active: 'true',\n sslVersion: 'TLSv1.2',\n communicationFormat: 'json',\n acceptsExpiredCertificate: 'false',\n acceptsSelfSignedCertificate: 'true',\n acceptsUntrustedRootCertificate: 'true',\n populateSoapActionHeader: 'false',\n filterMerchantAccountType: 'allAccounts',\n filterMerchantAccounts: [],\n },\n }).then((response) => {\n expect(response.status).to.equal(200)\n expect(response.body.active).to.equal(true)\n cy.writeFile(webhookJson, {\n adyenWebhookID: response.body.id,\n })\n })\n })\n}\n\nexport function deleteAdyenWebhook() {\n it(`Delete webhook in Adyen`, updateRetry(4), () => {\n cy.addDelayBetweenRetries(10000)\n cy.readFile(webhookJson).then((webhookid) => {\n cy.callRestAPIAndAddLogs({\n method: 'DELETE',\n url: `https://management-test.adyen.com/v1/companies/${adyenCompanyID}/webhooks/${webhookid.adyenWebhookID}`,\n headers: {\n 'X-API-Key': adyenApiKey,\n },\n }).then((response) => {\n cy.qe('Verify response staus to equal 204')\n expect(response.status).to.equal(204)\n })\n })\n })\n}\n\nexport function verifyOrderInAdyen(product, { paymentTidEnv }, refund = false) {\n it(`In ${product.prefix} - Verify order in adyen`, updateRetry(4), () => {\n cy.addDelayBetweenRetries(10000)\n cy.getOrderItems().then((item) => {\n cy.getAPI(\n `https://ca-test.adyen.com/ca/ca/ui-api/payments/v1/pspref/${item[paymentTidEnv]}/details`\n ).then((response) => {\n cy.qe('Expect response status to equal 200')\n expect(response.status).to.equal(200)\n cy.qe(\n `Expect response.body.paymentOverview.pspReference to equal ${item[paymentTidEnv]}`\n )\n expect(response.body.paymentOverview.pspReference).to.equal(\n item[paymentTidEnv]\n )\n if (refund) {\n cy.qe(\n 'Expect response.body.paymentOverview.status to equal SentForRefund'\n )\n expect(response.body.paymentOverview.status).to.equal('Refunded')\n }\n })\n })\n })\n}\n\nexport function deleteAccountHoldersFromMasterData() {\n it('Delete account holders from master data', () => {\n cy.qe('Get accountholder information for seller productusqaseller')\n cy.getAPI(\n `${baseUrl}/_v/api/adyen-platforms/v0/account?seller=productusqaseller`\n ).then(({ status, body }) => {\n expect(status).to.equal(200)\n for (const { accountHolderCode } of body) {\n cy.getAPI(\n `https://productusqa.myvtex.com/api/dataentities/account/search?accountHolderCode=${accountHolderCode}&_schema=account-dev@0.1`\n ).then((entitySearchResponse) => {\n const [{ id }] = entitySearchResponse.body\n\n cy.qe(`Get id for ${accountHolderCode} - ${id} from response body`)\n cy.qe(`Response status to equal 200`)\n\n expect(entitySearchResponse.status).to.equal(200)\n cy.callRestAPIAndAddLogs({\n method: 'DELETE',\n url: `https://productusqa.myvtex.com/api/dataentities/account/documents/${id}`,\n }).then((deleteDocumentResponse) => {\n cy.qe(`Delete id - ${id}`)\n cy.qe('Response status to equal 204')\n expect(deleteDocumentResponse.status).to.equal(204)\n })\n })\n }\n })\n })\n}\n\n```"
}
] |
code_cy-runner_7bcfcf3f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/adyen/graphql_testcase.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* eslint-disable jest/expect-expect */\n\nexport function sellers() {\n return {\n query:\n 'query' +\n '{sellers @context(provider: \"vtex.adyen-platforms\"){id,name,logo,isActive,fulfillmentEndpoint,allowHybridPayments,taxCode,email,description,sellerCommissionConfiguration}}',\n queryVariables: {},\n }\n}\n\nexport function getAdyenAccount() {\n return {\n query:\n 'query' +\n '{getAdyenAccount{accountHolderCode,urlToken,accountHolderDetails{email}}}',\n queryVariables: {},\n }\n}\n\nexport function adyenAccountHolder(payload) {\n return {\n query:\n 'query' +\n '($sellerId:String)' +\n '{adyenAccountHolder(sellerId:$sellerId){accountHolderCode,urlToken,accountHolderStatus {status},accounts {accountCode,description,payoutSpeed,status},accountHolderDetails {email}}}',\n queryVariables: { sellerId: payload },\n }\n}\n\nexport function createAccountHolder(createAccount) {\n const query =\n 'mutation' +\n '($accountHolderCode:String!,$sellerId:String!,$country:String!,$legalBusinessName:String!,$email:String!,$legalEntity:String!,$processingTier:Int!)' +\n '{createAccountHolder(accountHolderCode:$accountHolderCode,sellerId:$sellerId,country:$country,legalBusinessName:$legalBusinessName,email:$email,legalEntity:$legalEntity,processingTier:$processingTier){adyenAccountHolder {accountHolderCode}}}'\n\n return {\n query,\n queryVariables: createAccount,\n }\n}\n\nexport function closeAccountHolder(payload) {\n const query =\n 'mutation' +\n '($accountHolderCode:String!)' +\n '{closeAccountHolder(accountHolderCode:$accountHolderCode){accountHolderCode,urlToken}}'\n\n return {\n query,\n queryVariables: {\n accountHolderCode: payload,\n },\n }\n}\n\nexport function refreshOnboarding(payload) {\n const query =\n 'mutation' +\n '($accountHolderCode:String!)' +\n '{refreshOnboarding(accountHolderCode:$accountHolderCode){accountHolderCode,urlToken}}'\n\n return {\n query,\n queryVariables: {\n accountHolderCode: payload,\n },\n }\n}\n\nexport function updateAccount(accountCode, schedule) {\n const query =\n 'mutation' +\n '($accountCode:String!,$schedule:String!)' +\n '{updateAccount (accountCode:$accountCode,schedule:$schedule) @context(provider: \"vtex.adyen-platforms\") {accountCode,schedule}}'\n\n return {\n query,\n queryVariables: {\n accountCode,\n schedule,\n },\n }\n}\n\nexport function onboardingComplete(accountHolderCode) {\n const query =\n 'mutation' +\n '($accountHolderCode:String!)' +\n '{onboardingComplete(accountHolderCode:$accountHolderCode){accountHolderCode,urlToken,invalidFields{errorDescription}}}'\n\n return {\n query,\n queryVariables: {\n accountHolderCode,\n },\n }\n}\n\nexport function validateSellersResponse(response) {\n cy.qe('Verify response have body.data property not equal to null')\n expect(response.body.data).to.not.equal(null)\n}\n\nexport function validateGetAdyenAccountResponse(response) {\n cy.qe('Verify response have body.data property not equal to null')\n expect(response.body.data).to.not.equal(null)\n}\n\nexport function validateCreateAccountHolderResponse(response) {\n cy.qe(\n 'Verify response have body.data.createAccountHolder.adyenAccountHolder property not equal to null'\n )\n expect(\n response.body.data.createAccountHolder.adyenAccountHolder\n ).to.not.equal(null)\n}\n\nexport function validateAdyenAccountHolderResponse(response) {\n cy.qe('Verify response have body.data property not equal to null')\n expect(response.body.data).to.not.equal(null)\n}\n\nexport function validateCloseAccountHolderResponse(response) {\n cy.qe('Verify response have body.data property not equal to null')\n expect(response.body.data).to.not.equal(null)\n}\n\nexport function validateRefreshOnboardingResponse(response) {\n cy.qe(\n 'Verify response have body.data.refreshOnboarding property not equal to null'\n )\n expect(response.body.data.refreshOnboarding).to.not.equal(null)\n}\n\nexport function validateUpdateAccount(response) {\n cy.qe('Verify response have body.data property not equal to null')\n\n expect(response.body.data).to.not.equal(null)\n}\n\nexport function validateonboardingComplete(response) {\n cy.qe('Verify response have body.data property not equal to null')\n\n expect(response.body.data).to.not.equal(null)\n}\n\n```"
}
] |
code_cy-runner_f6d2b620
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/shopper-location/constants.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nexport default {\n invalidPostalCode: 'Invalid postal code.',\n locationNotAvailable: 'Sorry, shipping is not available for your location.',\n faildFindLocation:\n 'Failed to find your location. Please check that you have granted permission for this site to use your location.',\n}\n\n```"
}
] |
code_cy-runner_02086dcb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/shopper-location/geolocation.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nexport function mockLocation(latitude, longitude) {\n return {\n onBeforeLoad(win) {\n cy.stub(win.navigator.geolocation, 'getCurrentPosition').callsFake(\n (cb, err) => {\n if (latitude && longitude) {\n return cb({ coords: { latitude, longitude } })\n }\n\n throw err({ code: 1 }) // 1: rejected, 2: unable, 3: timeout\n }\n )\n },\n }\n}\n\n```"
}
] |
code_cy-runner_9c774be6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/shopper-location/outputvalidation.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nexport default {\n canadaDetails: {\n country: 'CAN',\n url: 'https://www.google.com',\n postalCode: 'N9V 1K8',\n city: 'Essex County',\n state: 'Ontario',\n },\n poland: {\n country: 'POL',\n url: 'https://www.google.com',\n postalCode: '00-014',\n city: 'Warsaw',\n state: 'mazowieckie',\n },\n UsDetails: {\n country: 'United States',\n postalCode: '21287',\n city: 'Baltimore',\n address: '1800 ORLEANS ST , BALTIMORE, MD',\n state: 'Maryland',\n },\n location: {\n lat: '13.0827',\n long: '80.2707',\n city: 'Chennai',\n },\n UsDetails1: {\n country1: 'United States',\n postalCode1: '91766',\n city: 'Pomona',\n },\n UsDetails2: {\n country: 'United States',\n postalCode: '93206',\n },\n UsDetails3: {\n country: 'United States',\n postalCode: '33180',\n city: 'Aventura',\n address: '19501 19501 Biscayne Blvd Aventura 33180',\n },\n UsDetails4: {\n country: 'United States',\n postalCode: '23223',\n city: 'Richmond',\n address: '1291 Worley Avenue',\n state: 'Virginia',\n },\n UsDetails5: {\n country: 'United States',\n postalCode: '10014',\n city: 'New York',\n address: 'Christopher Street',\n state: 'New York',\n },\n}\n\n```"
}
] |
code_cy-runner_fefced5e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/shopper-location/common.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport selectors from '../common/selectors'\nimport { scroll, updateRetry } from '../common/support'\nimport { mockLocation } from './geolocation'\n\nexport function verifyShopperLocation() {\n cy.get(selectors.SaveButtonInChangeLocationPopUp).should('not.exist')\n cy.get(selectors.verifyLocationInHome).should('be.visible')\n // eslint-disable-next-line cypress/no-force\n cy.get(selectors.AddToCart)\n .contains(/Add to Cart/i)\n .should('be.visible')\n .click({ force: true })\n cy.get(selectors.ProceedToCheckOut).should('be.visible').click()\n cy.get(selectors.orderButton).click()\n}\n\nexport function addLocation(data) {\n cy.intercept('**/event-api/v1/*/event').as('events')\n cy.qe('Visit Store frontend')\n cy.visit('/', mockLocation(data.lat, data.long))\n cy.wait('@events')\n cy.get(selectors.ProfileLabel, { timeout: 10000 })\n .should('be.visible')\n .should('have.contain', `Hello,`)\n scroll()\n cy.qe(\n 'Address container should be visible in the top left of the home page & click on it'\n )\n cy.get(selectors.addressContainer).click()\n cy.qe('Add shipping address')\n cy.get(selectors.countryDropdown).select(data.country)\n cy.get(selectors.addressInputContainer)\n .first()\n .clear()\n .should('be.visible')\n .type(data.postalCode)\n cy.getVtexItems().then((vtex) => {\n cy.intercept('POST', `${vtex.baseUrl}/**`, (req) => {\n if (req.body.operationName === 'setRegionId') {\n req.continue()\n }\n }).as('setRegionId')\n cy.intercept('POST', `${vtex.baseUrl}/**`, (req) => {\n if (req.body.operationName === 'updateOrderFormShipping') {\n req.continue()\n }\n }).as('updateOrderFormShipping')\n cy.once('uncaught:exception', () => {\n return false\n })\n cy.get(selectors.SaveButtonInChangeLocationPopUp)\n .should('be.visible')\n .click()\n cy.wait('@setRegionId', { timeout: 10000 })\n cy.wait('@updateOrderFormShipping', { timeout: 10000 })\n })\n}\n\nexport function verifyLocation(lat, long) {\n cy.intercept('**/event-api/v1/*/event').as('events')\n cy.qe(`${lat ? 'Enable' : 'Disable'} location permission in the browser`)\n cy.visit('/', mockLocation(lat, long))\n cy.qe('Visit store front')\n cy.wait('@events')\n cy.get(selectors.ProfileLabel, { timeout: 10000 })\n .should('be.visible')\n .should('have.contain', `Hello,`)\n scroll()\n cy.qe('Address container should be visible in the top left of the home page')\n cy.get(selectors.addressContainer).should('be.visible')\n cy.qe('On click to address container should open a popup')\n cy.get(selectors.addressContainer).click()\n cy.get(selectors.AddressModelLayout).should('be.visible')\n cy.qe('Now user should see change location button inside the popup')\n cy.get(selectors.ChangeLocationButton).click()\n}\n\nexport function addAddress(prefix, { address, lat, long }) {\n it(\n `${prefix} - Go to store front and add shipping address`,\n updateRetry(1),\n () => {\n cy.intercept('**/event-api/v1/*/event').as('events')\n cy.qe(\n 'Visiting store front and using mocklocation function to setting the location'\n )\n cy.visit('/', mockLocation(lat, long))\n cy.wait('@events')\n cy.get(selectors.ProfileLabel, { timeout: 10000 })\n .should('be.visible')\n .should('have.contain', `Hello,`)\n scroll()\n cy.qe(\n 'Address container should be visible in the top left of the home page & on click to address container should open a popup'\n )\n cy.get(selectors.addressContainer, { timeout: 20000 })\n .should('be.visible')\n .click()\n cy.qe('Adding the shipping address')\n cy.get(selectors.findMyLocation).click()\n cy.qe('Adding the shipping address')\n cy.get(selectors.countryDropdown).select(address.country)\n // eslint-disable-next-line cypress/no-unnecessary-waiting\n cy.get(selectors.addressInputContainer)\n .first()\n .should('not.be.disabled')\n .clear()\n .type(address.postalCode, { delay: 100 })\n autocomplete(address.city, address.state)\n cy.get(selectors.SaveButtonInChangeLocationPopUp)\n .should('be.visible')\n .click()\n .should(() => {\n expect(localStorage.getItem('orderform')).not.to.be.empty\n })\n }\n )\n}\n\nexport function autocomplete(city, province) {\n cy.getVtexItems().then((vtex) => {\n cy.intercept('POST', vtex.baseUrl).as('events')\n cy.wait('@events')\n cy.intercept('GET', '**=US').as('maps')\n cy.get(`div[class*=addressInputContainer] input[value=\"${city}\"]`)\n .invoke('val')\n .should('equal', city)\n cy.wait('@maps').its('response.statusCode').should('equal', 200)\n cy.get(selectors.ShopperLocationTextFields).should('be.visible')\n cy.get(selectors.ShopperLocationTextFields).then((elements) => {\n if (elements.length === 4) {\n cy.get(selectors.ProvinceField).should('exist').select(province)\n } else {\n cy.get(selectors.ShopperLocationTextFields)\n .last()\n .should('not.have.value', '')\n .clear()\n .type(province)\n }\n })\n })\n}\n\nexport function orderProductTestCase(\n prefix,\n { country, postalCode, address, city }\n) {\n it(`${prefix} - Adding Location`, updateRetry(2), () => {\n cy.qe(\n `Here it shows the browser popup of location allow or disable.Have to click on ${prefix}.Add the shipping address`\n )\n cy.addNewLocation(country, postalCode, address, city)\n })\n\n it(\n `${prefix} - Verifying Address in home page & checkout page`,\n updateRetry(2),\n () => {\n cy.qe(\n 'Verifying the address container in homepage and in checkout page of the saved address is showing'\n )\n verifyShopperLocation()\n }\n )\n\n it(`${prefix} - Ordering the product`, updateRetry(2), () => {\n cy.qe(\n 'After veriying the address in checkout page,have to make promissory payment and ordering a product'\n )\n cy.orderProduct()\n })\n}\n\nexport function verifyHomePage(city, postalCode) {\n // cy.get('div[class*=vtex-modal-layout]').should('not.be.visible')\n cy.scrollTo(0, 500)\n cy.getVtexItems().then((vtex) => {\n cy.intercept('POST', `${vtex.baseUrl}/**`, (req) => {\n if (req.body.operationName === 'updateOrderFormShipping') {\n req.continue()\n }\n }).as('updateOrderFormShipping')\n cy.qe('Verify address container is visible under product')\n cy.get(selectors.addressContainer).should('be.visible')\n cy.qe('Verify city is visible under the product')\n cy.get(selectors.AddressCity).contains(city)\n cy.qe('Verify postal code under the product')\n cy.get(selectors.AddressZip).contains(postalCode)\n cy.get(selectors.Distance).contains('Distance:')\n cy.wait('@updateOrderFormShipping', { timeout: 20000 })\n })\n}\n\n```"
}
] |
code_cy-runner_2b009926
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/shopper-location/settings.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { updateRetry } from '../common/support'\n\nconst version = '*.x'\nconst app = 'vtex.shopper-location'\n\nexport function updateSettings(\n country,\n url,\n { automaticRedirect = false } = {}\n) {\n it(\n `Configuring ${\n automaticRedirect ? 'automatic' : ''\n } redirect with country ${country} in ${app}`,\n updateRetry(2),\n () => {\n cy.getVtexItems().then((vtex) => {\n // Define constants\n const APP_NAME = 'vtex.apps-graphql'\n const APP_VERSION = '3.x'\n const APP = `${APP_NAME}@${APP_VERSION}`\n const CUSTOM_URL = `${vtex.baseUrl}/_v/private/admin-graphql-ide/v0/${APP}`\n\n cy.qe(\n 'Update a app settings via graphQl.The graphQl mutation we use in UI,mutation{($app:String,$version:String,$settings:String) {saveAppSettings(app:$app,version:$version,settings:$settings){message}}'\n )\n const GRAPHQL_MUTATION =\n 'mutation' +\n '($app:String,$version:String,$settings:String)' +\n '{saveAppSettings(app:$app,version:$version,settings:$settings){message}}'\n\n const QUERY_VARIABLES = {\n app,\n version,\n settings: `{\"automaticRedirect\":${automaticRedirect},\"redirects\":[{\"country\":\"${country}\",\"url\":\"${url}\"}]}`,\n }\n\n // Mutating it to the new workspace\n cy.callGraphqlAndAddLogs({\n url: CUSTOM_URL,\n query: GRAPHQL_MUTATION,\n variables: QUERY_VARIABLES,\n }).its('body.data.saveAppSettings.message', { timeout: 10000 })\n })\n }\n )\n}\n\n```"
}
] |
code_cy-runner_d7398e39
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/fedex-shipping/api_testcase.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { loadDocksAPI, calculateShippingAPI } from '../common/apis'\nimport { updateRetry } from '../common/support'\n\nexport function loadDocks() {\n it('Load all dock connection', updateRetry(3), () => {\n cy.getVtexItems().then((vtex) => {\n cy.getAPI(loadDocksAPI(vtex.baseUrl)).then((response) => {\n cy.qe('Expect response status to be 200')\n expect(response.status).to.have.equal(200)\n })\n })\n })\n}\n\nexport function loadCalculateShippingAPI(data, validateResponseFn) {\n return cy.getVtexItems().then((vtex) => {\n cy.getAppSettingstoJSON().then((items) => {\n cy.callRestAPIAndAddLogs({\n url: calculateShippingAPI(vtex.account, Cypress.env('workspace').name),\n headers: {\n VtexIdclientAutCookie: items[vtex.userAuthCookieName],\n },\n body: data,\n }).as('RESPONSE')\n\n if (validateResponseFn) {\n cy.get('@RESPONSE').then((response) => {\n cy.qe('Expect status to be 200')\n expect(response.status).to.have.equal(200)\n validateResponseFn(response)\n })\n } else {\n return cy.get('@RESPONSE')\n }\n })\n })\n}\n\nexport function validateCalculateShipping(response) {\n expect(response.status).to.have.equal(200)\n cy.qe('Expect response body to be an array and have length of above 0')\n // If we receive empty array with valid payload then we can assume that fedex shipping site is down\n expect(response.body).to.be.an('array').and.to.have.lengthOf.above(0)\n}\n\nexport function validateNonSupportedCountryCalculateShipping(response) {\n expect(response.status).to.have.equal(200)\n expect(response.body).to.be.an('array').and.to.be.empty\n // If we receive empty array with valid payload then we can assume that fedex shipping site is down\n // expect(response.body).to.be.an('array').and.to.have.lengthOf.above(0)\n}\n\nexport function validateCustomDeliveryTime(response) {\n expect(response.status).to.have.equal(200)\n expect(response.body).to.be.an('array').and.to.have.lengthOf.above(0)\n if (response.body[0].estimateDate === null) {\n expect(response.body[0].estimateDate).to.have.equal('0')\n }\n}\n\n```"
}
] |
code_cy-runner_bc86a810
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/fedex-shipping/outputvalidation.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nexport default {\n appSetting: {\n userCredentialKey: Cypress.env().base.fedex.userCredentialKey,\n userCredentialPassword: Cypress.env().base.fedex.userCredentialPassword,\n parentCredentialKey: '',\n parentCredentialPassword: '',\n clientDetailMeterNumber: Cypress.env().base.fedex.clientDetailMeterNumber,\n clientDetailAccountNumber:\n Cypress.env().base.fedex.clientDetailAccountNumber,\n isLive: false,\n residential: true,\n optimizeShippingType: 0,\n unitWeight: 'KG',\n unitDimension: 'CM',\n packingAccessKey: '',\n defaultDeliveryEstimateInDays: '0',\n },\n packingOptimizationSettings: {\n accessKey: 'fedexdev',\n containerList: [\n {\n id: 1,\n length: 20,\n width: 20,\n height: 20,\n description: 'cypress test',\n },\n ],\n },\n smartPackingAccessKey: 'fedexdev',\n docks: {\n fedexUSDock: {\n id: 'FD',\n name: 'Fedex US Dock',\n shippingRatesProviders: ['vtexus.fedex-shipping'],\n },\n fedexBrazilDock: {\n id: 'S0001-E0001-Dock',\n name: 'Fedex Italy Dock',\n shippingRatesProviders: ['vtexus.fedex-shipping'],\n },\n fedexIndiaDock: {\n id: 'IND00112233',\n name: 'Fedex India Dock',\n shippingRatesProviders: ['vtexus.fedex-shipping'],\n },\n fedexKuwaitDock: {\n id: 'KUWA0112233',\n name: 'Fedex Kuwait Dock',\n shippingRatesProviders: ['vtexus.fedex-shipping'],\n },\n },\n warehouseId: 'Fedex_WareHouse',\n Apache2020SkuId: '880330',\n Amacsa2020SkuId: '880350',\n singleProduct: {\n prefix: 'Single Product',\n postalCode: '33180',\n },\n multiProduct: {\n prefix: 'Multi Product',\n postalCode: '33180',\n },\n}\n\n```"
}
] |
code_cy-runner_e80eebaa
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/fedex-shipping/graphql_apps.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nexport default {\n FEDEX_SHIPPING_APP: 'vtexus.fedex-shipping',\n INVENTORY_GRAPHQL_APP: 'vtex.inventory-graphql',\n LOGISTICS_CARRIER_GRAPHQL_APP: 'vtex.logistics-carrier-graphql',\n PACKING_OPTIMIZATION: 'vtex.packing-optimization',\n}\n\n```"
}
] |
code_cy-runner_9451f1c7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/fedex-shipping/common.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n saveAppSetting,\n validateSaveAppSettingResponse,\n} from './graphql_testcase'\nimport { FEDEX_SHIPPING_APP } from './graphql_apps.js'\nimport { graphql } from '../common/graphql_utils'\n\nexport function updateSLASettings(appSetting, rate = 0, percentage = 0) {\n cy.getAppSettingstoJSON().then((items) => {\n const { slaSettings } = items.config.data.getAppSettings\n\n for (const ship in slaSettings) {\n slaSettings[ship].surchargeFlatRate = rate\n slaSettings[ship].surchargePercent = percentage\n }\n\n graphql(\n FEDEX_SHIPPING_APP,\n saveAppSetting(appSetting, slaSettings),\n validateSaveAppSettingResponse\n )\n })\n}\n\nexport function filterByShippingMethod(response, sla) {\n return response.body.filter(\n (r) =>\n r.shippingMethod === sla.FirstOvernight ||\n r.shippingMethod === sla.StandardOvernight\n )\n}\n\n```"
}
] |
code_cy-runner_0b91d804
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/fedex-shipping/graphql_testcase.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n/* \nvtexus.fedex-shipping and vtex.packing-optimization uses same graphql name\neg: getAppSettings(), saveAppSetting()\n\nIf we run getAppSettings() or saveAppSetting(). It throws Error\nInvalid GraphQL query. Multiple app dependencies have defined \\\"getAppSettings\\\". \nTo fix this ambiguity you can use the @context directive to specify the app you need this data from\n\n\nTo solve this error use @context(provider: \"vtexus.fedex-shipping\")\n*/\n\nexport function getAppSettings() {\n cy.qe('Get app settings via graphql')\n const query =\n 'query' +\n '{ getAppSettings @context(provider: \"vtexus.fedex-shipping\")' +\n '{defaultDeliveryEstimateInDays,userCredentialKey,userCredentialPassword,parentCredentialKey,parentCredentialPassword,clientDetailAccountNumber,clientDetailMeterNumber,isLive,residential,optimizeShippingType,unitWeight,unitDimension,packingAccessKey,slaSettings{sla,hidden,surchargePercent,surchargeFlatRate}}}'\n\n return {\n query,\n }\n}\n\nexport function getDocks() {\n const query =\n 'query' + '{ getDocks{docksList{id,name,shippingRatesProviders}}}'\n\n cy.qe('Get Docks via graphQl')\n\n return {\n query,\n }\n}\n\nexport function saveAppSetting(appDatas, allSla) {\n if (allSla) {\n appDatas.slaSettings = allSla\n }\n\n cy.qe('Save App setting via graphql.')\n\n const query =\n 'mutation' +\n '($userCredentialKey: String, $userCredentialPassword: String, $defaultDeliveryEstimateInDays: String, $parentCredentialKey: String, $parentCredentialPassword: String, $clientDetailMeterNumber: String, $clientDetailAccountNumber: String, $isLive: Boolean, $residential: Boolean,$optimizeShippingType: Int,$unitWeight: String,$unitDimension: String,$packingAccessKey: String,$slaSettings:[SlaSettingsInput])' +\n '{saveAppSetting(appSetting: {userCredentialKey:$userCredentialKey,userCredentialPassword:$userCredentialPassword,defaultDeliveryEstimateInDays:$defaultDeliveryEstimateInDays,parentCredentialKey:$parentCredentialKey,parentCredentialPassword:$parentCredentialPassword,clientDetailMeterNumber:$clientDetailMeterNumber,clientDetailAccountNumber:$clientDetailAccountNumber,isLive:$isLive,residential:$residential,optimizeShippingType:$optimizeShippingType,unitWeight:$unitWeight,unitDimension:$unitDimension,packingAccessKey:$packingAccessKey,slaSettings:$slaSettings})' +\n '@context(provider: \"vtexus.fedex-shipping\")}'\n\n return {\n query,\n queryVariables: appDatas,\n }\n}\n\nexport function savePackingOptimizationAppSetting(settings) {\n cy.qe('Save packing optimization app settings via graphql.')\n\n const query =\n 'mutation' +\n '($accessKey: String, $containerList: [ContainerInput])' +\n '{saveAppSetting(appSetting: {accessKey:$accessKey,containerList:$containerList})' +\n '@context(provider: \"vtex.packing-optimization\")}'\n\n return {\n query,\n queryVariables: settings,\n }\n}\n\nexport function updateDockConnection(id, remove = false) {\n const queryVariables = { dockId: id, toRemove: remove }\n\n cy.qe('Update dock connection via graphQl.')\n\n const query =\n 'mutation' +\n '($dockId: String, $toRemove: Boolean)' +\n '{updateDockConnection(updateDock: {dockId:$dockId,toRemove:$toRemove})}'\n\n return {\n query,\n queryVariables,\n }\n}\n\nexport function loadingDock(id) {\n cy.qe('Load a docks via graphql')\n\n const query = 'query' + '($id: ID!)' + '{loadingDock(id:$id){isActive}}'\n const queryVariables = { id }\n\n return {\n query,\n queryVariables,\n }\n}\n\nexport function validateGetAppSettingsResponse(response) {\n expect(response.body.data.getAppSettings).to.not.equal(null)\n}\n\nexport function validateGetDockConnectionResponse(response) {\n const { docksList } = response.body.data.getDocks\n\n expect(docksList).to.be.an('array').and.to.have.lengthOf.above(0)\n const results = docksList.filter(\n ({ shippingRatesProviders, name }) =>\n shippingRatesProviders.length > 1 && name.includes('Fedex')\n )\n\n expect(results.length).to.equal(4)\n}\n\nexport function validateSaveAppSettingResponse(response) {\n expect(response.body.data.saveAppSetting).to.equal(true)\n}\n\nexport function validateUpdateDockConnectionResponse(response) {\n expect(response.body.data.updateDockConnection).to.equal(true)\n}\n\nexport function verifyInventoryIsUnlimitedForFedexWareHouse(warehouseId, sku) {\n cy.qe(\n 'Verifying Inventory is unlimited via graphql.The graphQl query is,query($sku: ID!, $warehouseId: ID!){inventoryProduct(sku:$sku,warehouseId:$warehouseId){unlimited}}'\n )\n const query =\n 'query' +\n '($sku: ID!, $warehouseId: ID!)' +\n '{inventoryProduct(sku:$sku,warehouseId:$warehouseId){unlimited}}'\n\n const queryVariables = { sku, warehouseId }\n\n return {\n query,\n queryVariables,\n }\n}\n\nexport function validateInventory(response) {\n expect(response.body.data.inventoryProduct.unlimited).to.equal(true)\n}\n\nexport function verifyDockisActive(response) {\n expect(response.body.data.loadingDock.isActive).to.equal(true)\n}\n\nexport function warehouse(id) {\n cy.qe('Verify warehouse is active via graphQl')\n\n const query =\n 'query' +\n '($id: ID!)' +\n '{warehouse(id:$id){isActive,warehouseDocks{dockId}}}'\n\n const queryVariables = { id }\n\n return {\n query,\n queryVariables,\n }\n}\n\nexport function validateWareHouseIsActiveAndLinkedWithDocks(\n response,\n dockValues\n) {\n const { isActive, warehouseDocks } = response.body.data.warehouse\n\n expect(isActive).to.equal(true)\n const [actualDockId1, actualDockId2, actualDockId3, actualDockId4] = [\n warehouseDocks[0].dockId,\n warehouseDocks[1].dockId,\n warehouseDocks[2].dockId,\n warehouseDocks[3].dockId,\n ]\n\n const [expectedDockId1, expectedDockId2, expectedDockId3, expectedDockId4] = [\n dockValues[0].id,\n dockValues[1].id,\n dockValues[2].id,\n dockValues[3].id,\n ]\n\n expect(actualDockId1).to.equal(expectedDockId1)\n expect(actualDockId2).to.equal(expectedDockId2)\n expect(actualDockId3).to.equal(expectedDockId3)\n expect(actualDockId4).to.equal(expectedDockId4)\n}\n\n```"
}
] |
code_cy-runner_b67bef90
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/fedex-shipping/sla.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nexport default {\n FedexHomeDelivery: 'FedEx Home Delivery',\n FirstOvernight: 'First Overnight',\n FedexGroundDelivery: 'FedEx Ground',\n InternationalEconomy: 'International Economy',\n StandardOvernight: 'Standard Overnight',\n}\n\n```"
}
] |
code_cy-runner_c1aa9125
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/b2b/organization_request.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport selectors from '../common/selectors.js'\nimport { OTHER_ROLES } from './utils.js'\nimport { GRAPHL_OPERATIONS } from '../graphql_operations.js'\nimport { BUTTON_LABEL } from '../validation_text.js'\nimport { OrganizationRequestStatus } from './constants.js'\nimport { updateRetry } from '../common/support.js'\n\n// Define constants\nconst APP_NAME = 'vtex.b2b-organizations-graphql'\nconst APP_VERSION = '0.x'\nconst APP = `${APP_NAME}@${APP_VERSION}`\n\nfunction getOrganisationPayload(\n organisation,\n { costCenterName, costCenterAddress },\n email\n) {\n return {\n name: organisation,\n b2bCustomerAdmin: {\n firstName: 'Robot',\n lastName: email,\n email,\n },\n defaultCostCenter: {\n name: costCenterName,\n ...costCenterAddress,\n },\n }\n}\n\nfunction verifyOrganizationData(\n { name, b2bCustomerAdmin },\n defaultCostCenter,\n invalidEmail = false\n) {\n cy.url().then((url) => {\n if (url.includes('blank')) {\n // Local storage holds previous organization request information. So, Clear Local Storage\n cy.clearLocalStorage()\n cy.visit('/', {\n retryOnStatusCodeFailure: true,\n retryOnNetworkFailure: true,\n })\n cy.intercept('POST', 'https://sp.vtex.com/event-api/v1/*/event').as(\n 'EVENTS'\n )\n cy.wait('@EVENTS')\n }\n\n cy.get('body').then(($body) => {\n if ($body.find(selectors.PopupMsg).length) {\n cy.get('button > div')\n .contains(BUTTON_LABEL.create)\n .should('be.visible')\n .click()\n }\n })\n\n const { firstName, lastName } = b2bCustomerAdmin\n const email = invalidEmail || b2bCustomerAdmin.email\n\n cy.qe('From Top Right Navbar - Click Organization Signup link')\n cy.get(selectors.OrganisationSignup, { timeout: 25000 })\n .should('be.visible')\n .click()\n cy.qe(\n 'Verify on click to organization signup link not redirects us to 404 page'\n )\n cy.get(selectors.PageNotFound, { timeout: 10000 }).should('not.exist')\n\n if (name) {\n cy.qe(`For OrganizationName field, type ${name}`)\n cy.get(selectors.OrganizationName)\n .clear()\n .type(name)\n .should('have.value', name)\n } else {\n cy.qe('Clear OrganizationName field')\n cy.get(selectors.OrganizationName).clear()\n }\n\n cy.qe(`For firstName field, Type ${firstName}`)\n cy.get(selectors.FirstNameinB2B)\n .clear()\n .type(firstName)\n .should('have.value', firstName)\n cy.qe(`For lastname field, Type ${lastName}`)\n cy.get(selectors.LastNameinB2B)\n .clear()\n .type(lastName)\n .should('have.value', lastName)\n cy.qe(`For email field, clear and type ${email}`)\n cy.get(selectors.EmailinB2B).clear().type(email).should('have.value', email)\n if (defaultCostCenter) {\n cy.qe(`For costcenter field, clear and type ${defaultCostCenter.name}`)\n cy.get(selectors.CostCenter)\n .clear()\n .type(defaultCostCenter.name)\n .should('have.value', defaultCostCenter.name)\n cy.fillAddressInCostCenter(defaultCostCenter)\n } else {\n cy.log(`Skip! defaultCostCenter - It is ${defaultCostCenter}`)\n }\n })\n}\n\nfunction submitOrganization(org) {\n cy.qe(\n `Click Submit btn and wait for this graphql ${GRAPHL_OPERATIONS.CreateOrganizationRequest} to be called`\n )\n cy.waitForGraphql(\n GRAPHL_OPERATIONS.CreateOrganizationRequest,\n selectors.SubmitOrganization\n ).then((req) => {\n cy.qe('Verify popup is shown with text pending approval')\n cy.get(selectors.PopupMsg).should('be.visible').contains('pending approval')\n const { id } = req.response.body.data.createOrganizationRequest\n\n cy.qe(\n `Get organizationRequest id from this graphql ${GRAPHL_OPERATIONS.CreateOrganizationRequest} and store in .organizations.json`\n )\n cy.setOrganizationItem(org, id)\n })\n}\n\nfunction generateSubTitle(approved, declined) {\n let subTitle = 'organization is in pending state'\n\n if (approved) {\n subTitle = `we are able to Approve via graphql`\n } else if (declined) {\n subTitle = `we are able to Decline via graphql`\n }\n\n return subTitle\n}\n\nexport function createOrganizationTestCase(\n organization,\n { costCenterName, costCenterAddress, approved = false, declined = false }\n) {\n const msg = generateSubTitle(approved, declined)\n\n it(\n `Creating ${organization.name} via storefront & verify ${msg}`,\n updateRetry(1),\n () => {\n cy.qe(`Creating ${organization.name} via storefront & verify ${msg}`)\n cy.getVtexItems().then((vtex) => {\n const { name, b2bCustomerAdmin, defaultCostCenter } =\n getOrganisationPayload(\n organization.name,\n {\n costCenterName,\n costCenterAddress,\n },\n organization.email\n )\n\n verifyOrganizationData({ name, b2bCustomerAdmin }, defaultCostCenter)\n submitOrganization(organization.name)\n if (approved) {\n updateOrganizationRequestStatus(\n { vtex },\n organization.name,\n OrganizationRequestStatus.approved\n )\n } else if (declined) {\n updateOrganizationRequestStatus(\n { vtex },\n organization.name,\n OrganizationRequestStatus.declined\n )\n }\n })\n }\n )\n}\n\nexport function approveOrganization(organization) {\n it(`Approving ${organization} request`, updateRetry(1), () => {\n cy.qe(`Approving ${organization} request`)\n cy.getVtexItems().then((vtex) => {\n updateOrganizationRequestStatus(\n { vtex, verify: false },\n organization,\n OrganizationRequestStatus.approved\n )\n })\n })\n}\n\nfunction updateOrganizationRequestStatus({ vtex, verify = true }, org, status) {\n cy.getOrganizationItems().then((items) => {\n const CUSTOM_URL = `${vtex.baseUrl}/_v/private/admin-graphql-ide/v0/${APP}`\n\n const GRAPHQL_ORAGANIZATION_UPDATE_MUTATION =\n 'mutation' +\n '($id: ID!,$status: String!)' +\n '{updateOrganizationRequest(id: $id,status:$status){id,status}}'\n\n const variables = {\n id: items[org],\n status,\n }\n\n cy.callGraphqlAndAddLogs({\n url: CUSTOM_URL,\n query: GRAPHQL_ORAGANIZATION_UPDATE_MUTATION,\n variables,\n }).then(() => {\n if (verify) {\n const statusInUI =\n status === OrganizationRequestStatus.approved ? 'created' : 'declined'\n\n cy.reload(true).contains(statusInUI)\n }\n })\n })\n}\n\nexport function requestOrganizationAndVerifyPopup(\n organization,\n { costCenterName, costCenterAddress },\n status\n) {\n const msg =\n status === OrganizationRequestStatus.approved\n ? 'approved request'\n : 'pending request'\n\n it(\n `Creating ${organization.name} via storefront and verify we are getting this message ${msg} in popup`,\n updateRetry(1),\n () => {\n const { name, b2bCustomerAdmin, defaultCostCenter } =\n getOrganisationPayload(\n organization.name,\n {\n costCenterName,\n costCenterAddress,\n },\n organization.email\n )\n\n verifyOrganizationData(\n { name, b2bCustomerAdmin },\n defaultCostCenter,\n organization.email\n )\n // cy.get(selectors.SubmitOrganization).click()\n\n cy.waitForGraphql(\n GRAPHL_OPERATIONS.CreateOrganizationRequest,\n selectors.SubmitOrganization\n ).then(() => {\n cy.contains(msg)\n })\n }\n )\n}\n\nexport function createOrganizationRequestTestCase(\n organization,\n { costCenterName, costCenterAddress },\n email\n) {\n it(`Creating ${organization.name} via storefront`, updateRetry(1), () => {\n const { name, b2bCustomerAdmin, defaultCostCenter } =\n getOrganisationPayload(\n organization,\n {\n costCenterName,\n costCenterAddress,\n },\n email\n )\n\n verifyOrganizationData(\n { name, b2bCustomerAdmin },\n defaultCostCenter,\n organization.email\n )\n cy.get(selectors.SubmitOrganization).click()\n })\n}\n\nexport function createOrganizationWithInvalidEmail(\n organization,\n { costCenterName, costCenterAddress },\n email\n) {\n it(`Creating ${organization} with invalid email`, updateRetry(1), () => {\n cy.qe(`Creating ${organization} with invalid email`)\n const { name, b2bCustomerAdmin, defaultCostCenter } =\n getOrganisationPayload(\n organization,\n {\n costCenterName,\n costCenterAddress,\n },\n email\n )\n\n const invalidEmail = 'dev+test.com'\n\n verifyOrganizationData(\n { name, b2bCustomerAdmin },\n defaultCostCenter,\n invalidEmail\n )\n cy.get(selectors.SubmitOrganization)\n .should('be.visible')\n .should('be.disabled')\n })\n}\n\nexport function createOrganizationWithoutCostCenterNameAndAddress(\n organization,\n { costCenterName, costCenterAddress },\n email\n) {\n it(\n `Creating Organization without cost center name & address`,\n updateRetry(1),\n () => {\n cy.qe(`Creating Organization without cost center name & address`)\n const { name, b2bCustomerAdmin } = getOrganisationPayload(\n organization,\n {\n costCenterName,\n costCenterAddress,\n },\n email\n )\n\n verifyOrganizationData({ name, b2bCustomerAdmin }, null, null)\n\n cy.get(selectors.SubmitOrganization)\n .should('be.visible')\n .should('be.disabled')\n }\n )\n}\n\nexport function createOrganizationWithoutName(\n organization,\n { costCenterName, costCenterAddress },\n email\n) {\n it(`Creating Organization without name`, updateRetry(1), () => {\n cy.qe(`Creating Organization without name`)\n const { b2bCustomerAdmin, defaultCostCenter } = getOrganisationPayload(\n organization,\n { costCenterName, costCenterAddress },\n email\n )\n\n verifyOrganizationData(\n { name: null, b2bCustomerAdmin },\n defaultCostCenter,\n null\n )\n cy.get(selectors.SubmitOrganization)\n .should('be.visible')\n .should('be.disabled')\n })\n}\n\nexport function organizationAdminShouldNotAbleToEditSalesUsers() {\n it(\n `Organization admin should not be able to edit Sales Users`,\n updateRetry(2),\n () => {\n cy.gotoMyOrganization()\n cy.get(selectors.AddUser).should('be.visible')\n for (const role of OTHER_ROLES) {\n cy.contains(role).should('have.class', 'c-disabled')\n }\n }\n )\n}\n\n```"
}
] |
code_cy-runner_8d1bc9bb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/b2b/constants.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { PRODUCTS } from '../common/utils.js'\nimport {\n ROLE_DROP_DOWN_EMAIL_MAPPING,\n ROLE_ID_EMAIL_MAPPING,\n generateEmailWithSuffix,\n} from './utils.js'\n\nconst ORGANIZATION_A = `OrganizationA-${Cypress.env().workspace.name}`\nconst ORGANIZATION_B = `OrganizationB-${Cypress.env().workspace.name}`\n\nexport const OrganizationRequestStatus = {\n approved: 'approved',\n declined: 'declined',\n pending: 'pending',\n}\n\nexport const USA_ADDRESS_1 = {\n postalCode: '33301',\n country: 'USA',\n street: 'Amy Sonnenblick MD Pl, 12 NE 12th Ave',\n receiverName: 'Robot',\n}\n\nexport const USA_ADDRESS_2 = {\n postalCode: '90290',\n country: 'USA',\n street: 'Kerry Lane',\n receiverName: 'Robot',\n}\n\nexport const USA_ADDRESS_3 = {\n postalCode: '30342',\n country: 'USA',\n street: '2851 Stroop Hill Road',\n receiverName: 'Robot',\n}\n\nexport const USA_ADDRESS_4 = {\n postalCode: '33180',\n country: 'USA',\n street: '19501 Biscayne Blvd',\n receiverName: 'Robot',\n}\n\nexport const FRANCE_ADDRESS = {\n postalCode: '93200',\n country: 'FRA',\n street: '91 Rue de Strasbourg',\n receiverName: 'Robot',\n}\n\nfunction quotesListForOrganizationA() {\n const Buyer = {\n quotes1: `${ORGANIZATION_A}-b1q1`, //\n quotes2: `${ORGANIZATION_A}-b1q2`, // add notes by sales admin\n quotes3: `${ORGANIZATION_A}-b1q3`, // declined by sales admin\n quotes4: `${ORGANIZATION_A}-b1q4`, // declined by approver\n quotes5: `${ORGANIZATION_A}-b1q5`, // declined by organization admin\n quotes6: `${ORGANIZATION_A}-b1q6`, // created from quickorder - Sales Admin change price to $30\n // and update quantity 10\n quotes7: `${ORGANIZATION_A}-b1q6`, // quote with quantity 50\n }\n\n const Buyer2 = {\n quotes1: `${ORGANIZATION_A}-b2q1`, // created from quickorder - by categories\n quotes2: `${ORGANIZATION_A}-b2q2`, // created from quickorder - by categories with quantity 50\n quotes3: `${ORGANIZATION_A}-b2q3`, // create quote with discounted product. so that further discount is not possibled\n }\n\n const OrganizationAdmin2 = {\n quotes1: `${ORGANIZATION_A}-oa2q1`, // created from quickorder - sku,quantity\n declineQuote: Buyer.quotes5,\n }\n\n const Approver = {\n quotes1: `${ORGANIZATION_A}-a1q1`,\n quotes2: `${ORGANIZATION_A}-a1q2`,\n declineQuote: Buyer.quotes3,\n }\n\n const Approver2 = {\n updateQuote: Buyer2.quotes1,\n declineQuote: Buyer.quotes3,\n }\n\n const SalesRep = {\n updateQuote: Approver.quotes1,\n declineQuote: Buyer.quotes4,\n }\n\n const OrganizationAdmin = {\n quotes1: `${ORGANIZATION_A}-oa1q1`,\n }\n\n return {\n OrganizationAdmin,\n OrganizationAdmin2,\n Buyer,\n Buyer2,\n Approver,\n Approver2,\n SalesRep,\n }\n}\n\nfunction quotesListForOrganizationB() {\n const Buyer = {\n quotes1: `${ORGANIZATION_B}-b1q1`,\n }\n\n const OrganizationAdmin = {\n quotes1: `${ORGANIZATION_B}-oa1q1`,\n }\n\n return {\n OrganizationAdmin,\n Buyer,\n }\n}\n\nfunction generateCostCenterName(organizationName, costCenterName) {\n return `${organizationName}-${costCenterName}`\n}\n\nconst { gmail } = Cypress.env().base\n\nconst ORG_A_GMAIL_CREDS = {\n email: gmail.emailId1,\n clientId: gmail.clientId1,\n clientSecret: gmail.clientSecret1,\n refreshToken: gmail.refreshToken1,\n}\n\nconst ORG_B_GMAIL_CREDS = {\n email: gmail.emailId2,\n clientId: gmail.clientId2,\n clientSecret: gmail.clientSecret2,\n refreshToken: gmail.refreshToken2,\n}\n\nexport default {\n OrganizationA: {\n organizationName: ORGANIZATION_A,\n costCenter1: {\n name: generateCostCenterName(ORGANIZATION_A, 'CostCenterA1'),\n addresses: [USA_ADDRESS_1],\n },\n costCenter2: {\n name: generateCostCenterName(ORGANIZATION_A, 'CostCenterA2'),\n addresses: [USA_ADDRESS_1, USA_ADDRESS_4],\n deleteAddress: USA_ADDRESS_3,\n temporaryAddress: USA_ADDRESS_2,\n receiverName: 'Robo2',\n },\n costCenter3: {\n temporaryName: generateCostCenterName(ORGANIZATION_A, 'cost3'),\n name: generateCostCenterName(ORGANIZATION_A, 'CostCenterA3'),\n addresses: [USA_ADDRESS_3],\n },\n costCenter4: {\n temporaryName: generateCostCenterName(ORGANIZATION_A, 'costA'),\n name: generateCostCenterName(ORGANIZATION_A, 'CostCenterA4'),\n addresses: [USA_ADDRESS_1, USA_ADDRESS_2, USA_ADDRESS_3],\n },\n collections: [\n {\n id: '141',\n name: 'Food',\n },\n {\n id: '140',\n name: 'Tech',\n },\n {\n id: '144',\n name: 'Clothes',\n },\n ],\n paymentTerms: [\n {\n id: '201',\n name: 'Promissory',\n },\n {\n id: '202',\n name: 'NET 30',\n },\n ],\n priceTables: 'gold',\n product: PRODUCTS.orange,\n product2: PRODUCTS.coconut,\n product3: PRODUCTS.tshirt,\n nonAvailableProduct: PRODUCTS.irobot,\n quotes: quotesListForOrganizationA(),\n gmailCreds: ORG_A_GMAIL_CREDS,\n users: {\n OrganizationAdmin1: generateEmailWithSuffix(\n ORG_A_GMAIL_CREDS.email,\n ORGANIZATION_A,\n ROLE_DROP_DOWN_EMAIL_MAPPING.OrganizationAdmin1.suffixInEmail\n ),\n OrganizationAdmin2: generateEmailWithSuffix(\n ORG_A_GMAIL_CREDS.email,\n ORGANIZATION_A,\n ROLE_DROP_DOWN_EMAIL_MAPPING.OrganizationAdmin2.suffixInEmail\n ),\n Buyer1: generateEmailWithSuffix(\n ORG_A_GMAIL_CREDS.email,\n ORGANIZATION_A,\n ROLE_DROP_DOWN_EMAIL_MAPPING.Buyer1.suffixInEmail\n ),\n Buyer2: generateEmailWithSuffix(\n ORG_A_GMAIL_CREDS.email,\n ORGANIZATION_A,\n ROLE_DROP_DOWN_EMAIL_MAPPING.Buyer2.suffixInEmail\n ),\n Buyer3: generateEmailWithSuffix(\n ORG_A_GMAIL_CREDS.email,\n ORGANIZATION_A,\n ROLE_DROP_DOWN_EMAIL_MAPPING.Buyer3.suffixInEmail\n ),\n Buyer4: generateEmailWithSuffix(\n ORG_A_GMAIL_CREDS.email,\n ORGANIZATION_A,\n ROLE_DROP_DOWN_EMAIL_MAPPING.Buyer4.suffixInEmail\n ),\n Approver1: generateEmailWithSuffix(\n ORG_A_GMAIL_CREDS.email,\n ORGANIZATION_A,\n ROLE_DROP_DOWN_EMAIL_MAPPING.Approver1.suffixInEmail\n ),\n Approver2: generateEmailWithSuffix(\n ORG_A_GMAIL_CREDS.email,\n ORGANIZATION_A,\n ROLE_DROP_DOWN_EMAIL_MAPPING.Approver2.suffixInEmail\n ),\n Approver3: generateEmailWithSuffix(\n ORG_A_GMAIL_CREDS.email,\n ORGANIZATION_A,\n ROLE_DROP_DOWN_EMAIL_MAPPING.Approver3.suffixInEmail\n ),\n SalesRep: generateEmailWithSuffix(\n ORG_A_GMAIL_CREDS.email,\n ORGANIZATION_A,\n ROLE_ID_EMAIL_MAPPING.SalesRepresentative.suffixInEmail\n ),\n SalesAdmin: generateEmailWithSuffix(\n ORG_A_GMAIL_CREDS.email,\n ORGANIZATION_A,\n ROLE_ID_EMAIL_MAPPING.SalesAdmin.suffixInEmail\n ),\n SalesManager: generateEmailWithSuffix(\n ORG_A_GMAIL_CREDS.email,\n ORGANIZATION_A,\n ROLE_ID_EMAIL_MAPPING.SalesManager.suffixInEmail\n ),\n },\n },\n OrganizationB: {\n organizationName: ORGANIZATION_B,\n costCenter1: {\n name: generateCostCenterName(ORGANIZATION_B, 'CostCenterB1'),\n addresses: [USA_ADDRESS_2],\n },\n collections: [\n {\n id: '143',\n name: 'House',\n },\n {\n id: '142',\n name: 'Tools',\n },\n ],\n paymentTerms: [\n {\n id: '202',\n name: 'NET 30',\n },\n ],\n priceTables: 'silver',\n product: PRODUCTS.irobot,\n nonAvailableProduct: PRODUCTS.tshirt,\n quotes: quotesListForOrganizationB(),\n gmailCreds: ORG_B_GMAIL_CREDS,\n users: {\n OrganizationAdmin1: generateEmailWithSuffix(\n ORG_B_GMAIL_CREDS.email,\n ORGANIZATION_B,\n ROLE_DROP_DOWN_EMAIL_MAPPING.OrganizationAdmin1.suffixInEmail\n ),\n\n Buyer1: generateEmailWithSuffix(\n ORG_B_GMAIL_CREDS.email,\n ORGANIZATION_B,\n ROLE_DROP_DOWN_EMAIL_MAPPING.Buyer1.suffixInEmail\n ),\n Approver1: generateEmailWithSuffix(\n ORG_B_GMAIL_CREDS.email,\n ORGANIZATION_B,\n ROLE_DROP_DOWN_EMAIL_MAPPING.Approver1.suffixInEmail\n ),\n },\n },\n}\n\n```"
}
] |
code_cy-runner_101efc87
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/b2b/add_users.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport selectors from '../common/selectors.js'\nimport { updateRetry } from '../common/support.js'\nimport {\n generateEmailWithSuffix,\n generateName,\n ROLE_ID_EMAIL_MAPPING,\n validateToastMsg,\n} from './utils.js'\nimport b2b from './constants.js'\nimport { GRAPHL_OPERATIONS } from '../graphql_operations.js'\nimport { BUTTON_LABEL, TOAST_MSG } from '../validation_text.js'\n\nexport function addUserFn(\n { userName, email, costCenter, duplicateUser = false },\n dropDownText\n) {\n cy.gotoMyOrganization()\n cy.get(selectors.AddUser).should('be.visible')\n cy.get('body').then(($body) => {\n if ($body.text().includes(email) && !duplicateUser) {\n cy.log('User already added')\n } else {\n cy.get(selectors.AddUser).click()\n cy.get(selectors.UserName)\n .clear()\n .type(userName)\n .should('have.value', userName)\n cy.get(selectors.UserEmail)\n .clear()\n .type(email)\n .should('have.value', email)\n cy.get(selectors.UserCostCenter)\n .select(costCenter)\n .find('option:selected')\n .should('have.text', costCenter)\n cy.get(selectors.UserRole)\n .select(dropDownText)\n .find('option:selected')\n .should('have.text', dropDownText)\n cy.waitForGraphql(GRAPHL_OPERATIONS.GetUsers, selectors.SubmitUser)\n // validateToastMsg(TOAST_MSG.added)\n }\n })\n}\n\nexport function addUser({ organizationName, costCenter, role, gmailCreds }) {\n const { suffixInEmail, dropDownText } = role\n\n it(\n `Adding ${dropDownText} in ${organizationName} with ${costCenter}`,\n updateRetry(3),\n () => {\n const userName = generateName(suffixInEmail)\n const email = generateEmailWithSuffix(\n gmailCreds.email,\n organizationName,\n suffixInEmail\n )\n\n addUserFn({ userName, email, costCenter }, dropDownText)\n }\n )\n}\n\nexport function duplicateUserTestCase({\n organizationName,\n costCenter,\n role,\n gmailCreds,\n}) {\n const { suffixInEmail, dropDownText } = role\n const email = generateEmailWithSuffix(\n gmailCreds.email,\n organizationName,\n suffixInEmail\n )\n\n it(\n `Add duplicate user ${email} from same organization and verify popup`,\n updateRetry(3),\n () => {\n const userName = generateName(suffixInEmail)\n\n addUserFn(\n { userName, email, costCenter, duplicateUser: true },\n dropDownText\n )\n validateToastMsg(TOAST_MSG.userAlreadyRegisteredInThisOrganization)\n }\n )\n}\n\nexport function addAndupdateUser({\n organization,\n currentCostCenter,\n updateCostCenter,\n currentRole,\n updatedRole,\n gmailCreds,\n}) {\n const { suffixInEmail, dropDownText } = updatedRole\n const userName = generateName(suffixInEmail)\n const email = generateEmailWithSuffix(\n gmailCreds.email,\n organization,\n suffixInEmail\n )\n\n it(`Adding ${email} & update its role & Costcenter`, updateRetry(3), () => {\n const { dropDownText: previous } = currentRole\n\n addUserFn({ userName, email, costCenter: currentCostCenter }, previous)\n cy.contains(email).should('be.visible').click()\n cy.get(selectors.CostCenterDropDownInEdit, { timeout: 2000 }).select(\n updateCostCenter\n )\n cy.get(selectors.RoleDropDownInEdit).select(dropDownText)\n cy.get(selectors.UpdateUser).click()\n validateToastMsg(TOAST_MSG.updated)\n })\n}\n\nexport function addSameUserAgainInOrganization({\n organization,\n costCenter,\n currentRole,\n updatedRole,\n gmailCreds,\n}) {\n const { suffixInEmail, dropDownText } = updatedRole\n const userName = generateName(suffixInEmail)\n const email = generateEmailWithSuffix(\n gmailCreds.email,\n organization,\n suffixInEmail\n )\n\n const { dropDownText: previous } = currentRole\n\n it.skip(\n `Adding ${email} with role ${previous} & update the role to ${dropDownText}`,\n updateRetry(3),\n () => {\n addUserFn({ userName, email, costCenter }, previous)\n addUserFn({ userName, email, costCenter }, dropDownText)\n }\n )\n}\n\nexport function addAnddeleteUser({\n organization,\n costCenter,\n role,\n gmailCreds,\n}) {\n const { suffixInEmail, dropDownText } = role\n const userName = generateName(suffixInEmail)\n const email = generateEmailWithSuffix(gmailCreds, organization, suffixInEmail)\n\n it(`Add & Delete a user ${email}`, () => {\n addUserFn({ userName, email, costCenter }, dropDownText)\n cy.contains(email).click()\n cy.get(`input[value='${email}']`).should('be.disabled')\n cy.get(selectors.Remove)\n .contains(BUTTON_LABEL.remove)\n .should('be.visible')\n .click()\n cy.get(selectors.ModalConfirmation).should('be.visible')\n cy.get(selectors.ModalConfirmation)\n .contains(BUTTON_LABEL.remove)\n .last()\n .should('be.visible')\n .click()\n cy.get('body').then(($body) => {\n if ($body.find(selectors.ModalClose).length) {\n cy.get(selectors.ModalConfirmation)\n .contains(BUTTON_LABEL.cancel)\n .click()\n }\n })\n })\n}\n\nexport function updateRoleOfTheUser({\n organization,\n costCenter,\n currentRole,\n updatedRole,\n gmailCreds,\n}) {\n it(\n `Updating the user from this role ${currentRole.dropDownText} to this role ${updatedRole.dropDownText} in ${organization} with ${costCenter}`,\n updateRetry(3),\n () => {\n const { suffixInEmail } = currentRole\n const { dropDownText } = updatedRole\n\n cy.gotoMyOrganization()\n cy.get(selectors.AddUser).should('be.visible')\n cy.contains(\n generateEmailWithSuffix(gmailCreds.email, organization, suffixInEmail)\n )\n .should('be.visible')\n .click()\n cy.get(selectors.CostCenterDropDownInEdit).select(costCenter)\n cy.get(selectors.RoleDropDownInEdit).select(dropDownText)\n cy.get(selectors.UpdateUser).click()\n validateToastMsg(TOAST_MSG.updated)\n }\n )\n}\n\nexport function updateCostCenterOftheUser({\n organization,\n role,\n currentCostCenter,\n updatedCostCenter,\n gmailCreds,\n}) {\n it(\n `Updating the user from this costcenter ${currentCostCenter} to this costcenter ${updatedCostCenter} in ${organization}`,\n updateRetry(3),\n () => {\n const { suffixInEmail } = role\n\n cy.gotoMyOrganization()\n cy.get(selectors.AddUser).should('be.visible')\n cy.contains(\n generateEmailWithSuffix(gmailCreds.email, organization, suffixInEmail)\n )\n .should('be.visible')\n .click()\n cy.get(selectors.CostCenterDropDownInEdit).select(updatedCostCenter)\n cy.get(selectors.UpdateUser).click()\n validateToastMsg(TOAST_MSG.updated)\n }\n )\n}\n\nexport function addUserViaGraphql(gmailCreds, roleKey) {\n const { organizationName, costCenter1 } = b2b.OrganizationA\n\n it(\n `Adding ${roleKey} in ${organizationName} with ${costCenter1.name}`,\n updateRetry(3),\n () => {\n const { suffixInEmail, role } = ROLE_ID_EMAIL_MAPPING[roleKey]\n // Define constants\n const APP_NAME = 'vtex.storefront-permissions'\n const APP_VERSION = '1.x'\n const APP = `${APP_NAME}@${APP_VERSION}`\n\n cy.getVtexItems().then((vtex) => {\n cy.getOrganizationItems().then((organizationItems) => {\n const CUSTOM_URL = `${vtex.baseUrl}/_v/private/admin-graphql-ide/v0/${APP}`\n const GRAPHQL_ADD_USER_MUTATION =\n 'mutation' +\n '($roleId: ID!,$orgId: ID,$costId: ID,$name: String!,$email:String!)' +\n '{saveUser(roleId:$roleId,orgId:$orgId,costId:$costId,name:$name,email:$email){' +\n 'id,status}}'\n\n const variables = {\n roleId: organizationItems[`${role}-id`],\n orgId: organizationItems[organizationName],\n costId: organizationItems[costCenter1.name],\n name: generateName(role),\n email: generateEmailWithSuffix(\n gmailCreds.email,\n organizationName,\n suffixInEmail\n ),\n }\n\n expect(variables.roleId).to.not.be.undefined\n expect(variables.orgId).to.not.be.undefined\n expect(variables.costId).to.not.be.undefined\n\n cy.callGraphqlAndAddLogs({\n url: CUSTOM_URL,\n query: GRAPHQL_ADD_USER_MUTATION,\n variables,\n }).then((resp) => {\n expect(resp.body.data.saveUser.status).to.equal('success')\n })\n })\n })\n }\n )\n}\n\n```"
}
] |
code_cy-runner_8bafe5d4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/b2b/env_organization.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n// ***********************************************\n// Keeps the variables of the environment\n// ***********************************************\n\n// File to persist env between tests\nconst organizationJson = '.organization.json'\n\n// Set Organization item\nCypress.Commands.add(\n 'setOrganizationItem',\n (organizationItem, organizationValue) => {\n cy.readFile(organizationJson).then((items) => {\n items[organizationItem] = organizationValue\n cy.writeFile(organizationJson, items)\n })\n }\n)\n\n// Get Organization vars\nCypress.Commands.add('getOrganizationItems', () => {\n cy.readFile(organizationJson).then((items) => {\n return items\n })\n})\n\n```"
}
] |
code_cy-runner_c023d01a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/b2b/graphql.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { updateRetry } from '../common/support.js'\n\n// Define constants\nconst config = Cypress.env()\nconst APP_NAME = 'vtex.b2b-organizations-graphql'\nconst APP_VERSION = '*.x'\nconst APP = `${APP_NAME}@${APP_VERSION}`\nconst { vtex } = config.base\nconst CUSTOM_URL = `${vtex.baseUrl}/_v/private/admin-graphql-ide/v0/${APP}`\n\nexport function deleteOrganization(search, organizationRequest = false) {\n // Default is organization, if organization request is true then delete organization request\n const func = organizationRequest ? 'Request' : ''\n\n it(\n `Deleting Organizations${func} which we created in this workspace ${search}`,\n updateRetry(2),\n () => {\n cy.qe(\n `Deleting Organizations${func} which we created in this workspace ${search}`\n )\n const GRAPHQL_DELETE_MUTATION =\n 'mutation' +\n '($id: ID!)' +\n `{deleteOrganization${func}(id: $id){status}}`\n\n const queryName = `getOrganization${func}s`\n\n const GRAPHQL_SEARCH_QUERY =\n 'query' +\n '($search: String!)' +\n `{${queryName}(search: $search){data{id,name}}}`\n\n const SEARCH_QUERY_VARIABLES = { search }\n\n cy.callGraphqlAndAddLogs({\n url: CUSTOM_URL,\n query: GRAPHQL_SEARCH_QUERY,\n variables: SEARCH_QUERY_VARIABLES,\n }).then((response) => {\n expect(response.status).to.equal(200)\n expect(response.body).to.not.have.own.property('errors')\n for (const { id } of response.body.data[queryName].data) {\n cy.qe(\n 'If we are getting data property from response, then we already have an organization created '\n )\n cy.qe(\"Let's delete that organization request\")\n\n cy.callGraphqlAndAddLogs({\n url: CUSTOM_URL,\n query: GRAPHQL_DELETE_MUTATION,\n variables: {\n id,\n },\n }).then((response2) => {\n expect(response2.status).to.equal(200)\n expect(\n response2.body.data[`deleteOrganization${func}`].status\n ).to.equal('success')\n })\n }\n })\n }\n )\n}\n\nexport function verifySalesChannel(binding = true) {\n const salesChannel = binding ? 'Principal' : 'Dolar'\n\n it(`Verify Sales Channel having ${salesChannel}`, updateRetry(2), () => {\n cy.addDelayBetweenRetries(2000)\n const GRAPHQL_GET_SALES_CHANNEL_QUERY = 'query' + `{getSalesChannels{name}}`\n\n cy.callGraphqlAndAddLogs({\n url: CUSTOM_URL,\n query: GRAPHQL_GET_SALES_CHANNEL_QUERY,\n }).then(({ status, body }) => {\n expect(status).to.equal(200)\n expect(body.data.getSalesChannels.length).equal(1)\n expect(body.data.getSalesChannels[0].name).equal(salesChannel)\n })\n })\n}\n\nexport function verifyBindings(email, binding) {\n it(`Verify Bindings with this emailId - ${email}`, updateRetry(4), () => {\n cy.addDelayBetweenRetries(30000)\n const GRAPHQL_GET_SALES_CHANNEL_QUERY =\n 'query($email:String!){' + `getBinding(email:$email)}`\n\n cy.qe(`Verify Bindings with this emailId - ${email}`)\n\n cy.callGraphqlAndAddLogs({\n url: CUSTOM_URL,\n query: GRAPHQL_GET_SALES_CHANNEL_QUERY,\n variables: { email },\n }).then(({ status, body }) => {\n expect(status).to.equal(200)\n cy.qe(\n `Verify we get status as 200 & we have getBinding property with value ${binding}`\n )\n expect(body).to.have.property('data')\n expect(body.data).to.have.property('getBinding')\n expect(body.data.getBinding).equal(binding)\n })\n })\n}\n\nfunction bindingsMutation(payload) {\n const GRAPHQL_GET_SALES_CHANNEL_QUERY =\n 'mutation($channels: [SalesChannelsInput]!){' +\n `saveSalesChannels(channels: $channels){` +\n `id,status,message}}`\n\n cy.callGraphqlAndAddLogs({\n url: CUSTOM_URL,\n query: GRAPHQL_GET_SALES_CHANNEL_QUERY,\n variables: payload,\n }).then(({ status, body }) => {\n expect(status).to.equal(200)\n expect(body.data.saveSalesChannels.status).equal('success')\n })\n}\n\nexport function addBindingsWhichShowsOrganization() {\n it(`Add Bindings which shows organization in profile page`, () => {\n bindingsMutation({\n channels: [\n {\n id: '1',\n name: 'Principal',\n },\n ],\n })\n })\n}\n\nexport function addBindingsWhichHidesOrganization() {\n it(`Add Bindings which hides organization in profile page`, () => {\n bindingsMutation({\n channels: [\n {\n id: 2,\n name: 'Dolar',\n },\n ],\n })\n })\n}\n\n```"
}
] |
code_cy-runner_011df519
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/b2b/cost_center.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport selectors from '../common/selectors.js'\nimport { validateToastMsg } from './utils.js'\nimport { GRAPHL_OPERATIONS } from '../graphql_operations.js'\nimport { BUTTON_LABEL, TOAST_MSG } from '../validation_text.js'\nimport { updateRetry } from '../common/support.js'\n\nexport function addCostCenter(organization, costCenter, costCenterAddress) {\n it(\n `Adding Cost Center ${costCenter} in ${organization}`,\n updateRetry(2),\n () => {\n cy.gotoMyOrganization()\n cy.get(selectors.AddCostCenter).should('be.visible')\n cy.get('body').then(($body) => {\n if ($body.text().includes(costCenter)) {\n cy.qe('CostCenter already added')\n } else {\n cy.qe('Click Add Cost Center')\n cy.get(selectors.AddCostCenter).click()\n cy.qe(`Type ${costCenter} in costCenterName Field`)\n cy.get(selectors.CostCenterName)\n .clear()\n .type(costCenter)\n .should('have.value', costCenter)\n cy.get(selectors.Street)\n .scrollIntoView()\n .should('be.visible')\n .should('be.enabled')\n cy.fillAddressInCostCenter(costCenterAddress)\n cy.waitForGraphql(\n GRAPHL_OPERATIONS.GetCostCentersByOrganizationIdStorefront,\n selectors.SubmitCostCenter\n ).then((req) => {\n cy.qe(\n `Store ${costCenter}:${req.response.body.data.createCostCenter.id} in organization.json`\n )\n cy.setOrganizationItem(\n costCenter,\n req.response.body.data.createCostCenter.id\n )\n })\n }\n })\n }\n )\n}\n\nexport function updateCostCenter(oldcostCenterName, updatedcostcenterName) {\n it(`Update cost center ${oldcostCenterName}`, updateRetry(1), () => {\n cy.addReloadBetweenRetries()\n cy.gotoCostCenter(oldcostCenterName)\n cy.get(`input[value='${oldcostCenterName}']`)\n .should('be.visible')\n .clear()\n .type(updatedcostcenterName)\n cy.get(selectors.CostCenterHeader)\n .contains(BUTTON_LABEL.save)\n .should('be.visible')\n .click()\n cy.get(`input[value='${updatedcostcenterName}']`).should('be.visible')\n })\n}\n\nexport function deleteCostCenter(costcenter) {\n it(`Delete cost center ${costcenter}`, updateRetry(1), () => {\n cy.gotoCostCenter(costcenter)\n cy.get('div').contains(BUTTON_LABEL.delete).should('be.visible').click()\n cy.get(selectors.ModalConfirmation).should('be.visible')\n cy.get(selectors.ModalConfirmation)\n .contains(BUTTON_LABEL.delete)\n .last()\n .should('be.visible')\n .click()\n cy.get(selectors.MyOrganizationCostCenterUserDiv).should('have.length', 4)\n cy.contains(costcenter, { timeout: 8000 }).should('not.exist')\n })\n}\n\nfunction submitAddressInCostCenter(postalCode) {\n cy.getVtexItems().then((vtex) => {\n cy.get(selectors.SubmitCostCenter).click()\n cy.get(selectors.PostalCodeInAddressList)\n .last()\n .should('have.text', postalCode)\n cy.intercept('POST', `${vtex.baseUrl}/**`, (req) => {\n if (\n req.body.operationName === GRAPHL_OPERATIONS.GetCostCenterStorefront\n ) {\n req.continue()\n }\n }).as(GRAPHL_OPERATIONS.GetCostCenterStorefront)\n cy.get(selectors.SaveChangesInCostCenter)\n .first()\n .contains(BUTTON_LABEL.save)\n .click()\n cy.wait(`@${GRAPHL_OPERATIONS.GetCostCenterStorefront}`)\n validateToastMsg(TOAST_MSG.updated)\n })\n}\n\nexport function addAddressinCostCenter(\n costCenter,\n costCenterAddress,\n updatedAddress = false\n) {\n it(`Adding New Address for ${costCenter}`, updateRetry(2), () => {\n cy.qe(`Adding New Address for ${costCenter}`)\n cy.gotoCostCenter(costCenter)\n const { postalCode } = costCenterAddress\n\n cy.get(selectors.PostalCodeInAddressList).then(($els) => {\n const postalCodes = [...$els].map((el) => el.innerText)\n\n if (updatedAddress) {\n const updatedAddressLoc = postalCodes.indexOf(updatedAddress.postalCode)\n\n if (updatedAddressLoc !== -1) {\n cy.qe('Address already updated')\n }\n } else {\n cy.get(selectors.PostalCodeInAddressList)\n .last()\n .invoke('text')\n .then((code) => {\n if (code === postalCode) {\n cy.qe('Address already added in CostCenter')\n } else {\n cy.get(selectors.AddAddress).click()\n cy.fillAddressInCostCenter(costCenterAddress)\n submitAddressInCostCenter(postalCode)\n }\n })\n }\n })\n })\n}\n\nexport function openOptionsForAddress(costCenterAddress) {\n const { postalCode } = costCenterAddress\n\n cy.get(selectors.PostalCodeInAddressList).then(($els) => {\n const postalCodes = [...$els].map((el) => el.innerText)\n const child = postalCodes.indexOf(postalCode)\n\n cy.get(selectors.PostalCodeInAddressList)\n .eq(child)\n .should('have.text', postalCode)\n cy.get(selectors.CostCenterOption).eq(child).click()\n })\n}\n\nexport function updateAddress(\n costCenter,\n currentCostCenterAddress,\n newCostCenterAddress\n) {\n it(\n `Updating address & receiver in ${costCenter} for this postalCode ${currentCostCenterAddress.postalCode} to ${newCostCenterAddress.postalCode}`,\n updateRetry(1),\n () => {\n cy.gotoCostCenter(costCenter)\n cy.get(selectors.PostalCodeInAddressList).then(($els) => {\n const postalCodes = [...$els].map((el) => el.innerText)\n const newCostCenterAddressLoc = postalCodes.indexOf(\n newCostCenterAddress.postalCode\n )\n\n if (newCostCenterAddressLoc !== -1) {\n cy.log('Address already updated')\n } else {\n openOptionsForAddress(currentCostCenterAddress)\n cy.get(selectors.CostCenterAddressEditOption).click()\n const { postalCode } = newCostCenterAddress\n\n cy.fillAddressInCostCenter(newCostCenterAddress)\n submitAddressInCostCenter(postalCode)\n }\n })\n }\n )\n}\n\nexport function deleteAddressFromCostCenter(costCenter, costCenterAddress) {\n const { postalCode } = costCenterAddress\n\n it(\n `Delete Address ${postalCode} from cost center ${costCenter}`,\n updateRetry(1),\n () => {\n cy.gotoCostCenter(costCenter)\n openOptionsForAddress(costCenterAddress)\n cy.get(selectors.CostCenterAddressDeleteOption).click()\n cy.get(selectors.ModalConfirmation).should('be.visible')\n cy.get(selectors.ModalConfirmation)\n .contains(BUTTON_LABEL.delete)\n .last()\n .should('be.visible')\n .click()\n cy.get(selectors.PostalCodeInAddressList).should(\n 'not.have.text',\n postalCode\n )\n cy.contains(BUTTON_LABEL.save).should('be.visible').click()\n cy.gotoMyOrganization()\n }\n )\n}\n\nexport function updatePaymentTermsinCostCenter(\n organization,\n costCenter,\n paymentTerms\n) {\n it(\n `Verify Organization Admin is able to disable ${costCenter} the payment terms ${paymentTerms} in ${organization}`,\n updateRetry(2),\n () => {\n cy.qe(\n `Verify Organization Admin is able to disable ${costCenter} the payment terms ${paymentTerms} in ${organization}`\n )\n cy.addReloadBetweenRetries()\n cy.gotoCostCenter(costCenter)\n cy.get(selectors.PromissoryCheckbox)\n .invoke('prop', 'checked')\n .then((checked) => {\n if (checked) {\n cy.qe(`Click PromissoryCheckbox`)\n cy.get(selectors.PromissoryCheckbox).click()\n }\n })\n cy.waitForGraphql(\n GRAPHL_OPERATIONS.GetCostCenterStorefront,\n selectors.SaveChangesInCostCenter\n )\n validateToastMsg(TOAST_MSG.updated)\n }\n )\n}\n\n```"
}
] |
code_cy-runner_d569294c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/b2b/login.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { getAccessToken } from '../extract.js'\nimport selectors from '../common/selectors.js'\n\nexport function visitHomePage() {\n cy.getVtexItems().then((vtex) => {\n cy.url().then((url) => {\n if (url.includes('blank') || url !== vtex.baseUrl) {\n cy.intercept('POST', 'https://sp.vtex.com/event-api/v1/*/event').as(\n 'EVENTS'\n )\n cy.qe(\n 'Visit home page/storefront and wait for EVENTS api to get called'\n )\n cy.visit('/', {\n retryOnStatusCodeFailure: true,\n retryOnNetworkFailure: true,\n })\n cy.wait('@EVENTS')\n } else {\n cy.log('We are already in storefront homepage')\n }\n })\n })\n}\n\nexport function loginWithCookiesStoredInJSON(cookieValue) {\n cy.getVtexItems().then((vtex) => {\n cy.setCookie(`${vtex.authCookieName}_${vtex.account}`, cookieValue, {\n log: false,\n })\n })\n visitHomePage()\n cy.waitForSession()\n cy.get(selectors.ProfileLabel).should('be.visible')\n}\n\nexport function storeUserCookie(email) {\n cy.getVtexItems().then((vtex) => {\n cy.getCookie(`${vtex.authCookieName}_${vtex.account}`).then((cookie) => {\n cy.qe('Store the userAuthCookie in organization.json')\n cy.setOrganizationItem(email, cookie.value)\n })\n })\n}\n\nexport function loginToStoreFront(email, role, gmailCreds) {\n it(\n `Logging in to storefront as ${role}`,\n { defaultCommandTimeout: 60000, retries: 1 },\n () => {\n cy.qe(`Logging in to storefront as ${role}`)\n cy.addDelayBetweenRetries(10000)\n cy.getOrganizationItems().then((organization) => {\n if (organization[email]) {\n cy.qe(`For this email ${email}, Logging in with saved cookies`)\n cy.log(email)\n // If we already logged in to this user in previous testcase, then use that cookie to re-login\n loginWithCookiesStoredInJSON(organization[email])\n } else {\n visitHomePage()\n cy.get('body').then(async ($body) => {\n if ($body.find(selectors.SignInBtn).length) {\n const accessToken = await getAccessToken(email, gmailCreds)\n\n cy.intercept('POST', '**/startlogin').as('startlogin')\n cy.intercept('POST', '**/accesskey/send').as('send')\n cy.qe('SignInBtn should be visible and click it')\n cy.get(selectors.SignInBtn).should('be.visible').click()\n cy.qe('AccessCode Btn should be visible and click it')\n cy.get(selectors.AccessCode).should('be.visible').click()\n cy.qe(`Type ${email} in Email field`)\n cy.get(selectors.Email)\n .should('be.visible')\n .focus()\n .clear()\n .type(email)\n cy.qe(`Click submit btn`)\n cy.get(selectors.Submit)\n .click()\n .then(async () => {\n cy.wait('@startlogin')\n .its('response.statusCode')\n .should('eq', 200)\n cy.qe('Wait for startLogin and send API')\n cy.wait('@send').its('response.statusCode').should('eq', 200)\n const newAccessToken = await getAccessToken(\n email,\n gmailCreds,\n accessToken\n )\n\n cy.qe(`Type ${newAccessToken} in token field`)\n cy.get(selectors.Token).clear().type(newAccessToken)\n cy.qe(`Click Submit Btn`)\n cy.get(selectors.Submit).click()\n cy.waitForSession()\n cy.qe(`Wait for profileLabel to be visible in the page`)\n cy.get(selectors.ProfileLabel).should('be.visible')\n storeUserCookie(email)\n })\n } else if ($body.find(selectors.ProfileLabel).length) {\n cy.qe('Already logged in')\n } else {\n cy.qe('SignInBtn is not found in the page')\n throw new Error('Selectors not loaded within time period')\n }\n })\n }\n })\n }\n )\n}\n\n```"
}
] |
code_cy-runner_58848bfa
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/b2b/quotes.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport selectors from '../common/selectors.js'\nimport { STATUSES } from './utils.js'\nimport { GRAPHL_OPERATIONS } from '../graphql_operations.js'\nimport { BUTTON_LABEL } from '../validation_text.js'\nimport { updateRetry } from '../common/support.js'\n\nconst DEFAULT_QUOTE_TOTAL = '$0.00'\n\nexport function fillQuoteInformation({\n quoteEnv,\n impersonatedRole,\n requestQuote = true,\n notes = false,\n}) {\n cy.getVtexItems().then((vtex) => {\n cy.get(selectors.ItemsPriceInCart, { timeout: 15000 }).then(($div) => {\n // Make sure remove button is visible\n cy.qe(`\n Remove product should be visible\n `)\n cy.get(selectors.RemoveProduct).should('be.visible')\n cy.get('#total-price div[class*=checkout-summary]')\n .should('be.visible')\n .invoke('text')\n .should('match', /\\d/)\n .should('contain', '$')\n\n const price = $div.text()\n\n cy.qe(`Waiting for the getorderform graphql`)\n cy.waitForGraphql('GetOrderForm', selectors.CreateQuote)\n cy.qe('Currency container should be visible')\n\n cy.get(selectors.CurrencyContainer, { timeout: 20000 }).should(\n 'be.visible'\n )\n cy.qe('QuoteTotal should be visible')\n cy.get(selectors.QuoteTotal, { timeout: 20000 }).should('be.visible')\n cy.qe(\n `Quotename should be visble and type Quoteenv - ${quoteEnv} should be possible`\n )\n cy.get(selectors.QuoteName).should('be.visible').clear().type(quoteEnv)\n if (notes) {\n cy.get(selectors.Notes).should('be.visible').clear().type(notes)\n }\n\n cy.qe('Adding intercept for the createQuote')\n cy.intercept('POST', `${vtex.baseUrl}/**`, (req) => {\n if (req.body.operationName === GRAPHL_OPERATIONS.CreateQuote) {\n req.continue()\n }\n }).as(GRAPHL_OPERATIONS.CreateQuote)\n\n if (requestQuote) {\n if (!impersonatedRole) {\n cy.get('div')\n .contains(selectors.RequestQuote, { timeout: 20000 })\n .should('be.visible')\n .should('not.be.disabled')\n .click()\n } else {\n cy.get('div')\n .contains(selectors.SaveQuote, { timeout: 20000 })\n .should('be.visible')\n .should('not.be.disabled')\n .click()\n }\n } else {\n cy.get('div')\n .contains(selectors.SaveForLater, { timeout: 20000 })\n .should('be.visible')\n .should('not.be.disabled')\n .click()\n }\n\n cy.qe('ToggleFields should be visible')\n cy.get(selectors.ToggleFields).should('be.visible')\n\n cy.wait(`@${GRAPHL_OPERATIONS.CreateQuote}`).then((req) => {\n const quoteId = req.response.body.data.createQuote.replace(\n 'quotes-',\n ''\n )\n\n cy.qe(`Save the QuoteEnv - price, ${price} `)\n cy.setQuoteItem(`${quoteEnv}-price`, price)\n cy.setQuoteItem(quoteEnv, quoteId)\n })\n })\n })\n}\n\nexport function createQuote(\n { product, quoteEnv, role, impersonatedRole },\n requestQuote = true,\n notes = false\n) {\n const expectedStatus = requestQuote ? STATUSES.pending : STATUSES.ready\n\n const title = impersonatedRole\n ? `Create Quote by ${role} who impersonated ${impersonatedRole}, verify state is ${expectedStatus} and store in env ${quoteEnv}`\n : `Create Quote as ${role}, verify state is ${expectedStatus} and store in env ${quoteEnv}`\n\n it(title, updateRetry(2), () => {\n cy.closeCart()\n cy.searchProductinB2B(product)\n cy.waitForGraphql('addToCart', selectors.B2BAddtoCart)\n fillQuoteInformation({ quoteEnv, requestQuote, notes, impersonatedRole })\n })\n}\n\nexport function quoteShouldNotBeVisibleTestCase(\n currentOrganization,\n quoteId,\n organization\n) {\n it(\n `${organization} user created Quote - ${quoteId} should not be visible for ${currentOrganization} user`,\n updateRetry(3),\n () => {\n viewQuote(quoteId, false)\n cy.get(selectors.QuoteFromMyQuotesPage, { timeout: 15000 })\n .invoke('text')\n .should('not.include', quoteId)\n }\n )\n}\n\nexport function quoteShouldbeVisibleTestCase(\n currentOrganization,\n quoteId,\n organization\n) {\n it(\n `${organization} user created Quote - ${quoteId} should be visible for ${currentOrganization} user`,\n updateRetry(3),\n () => {\n viewQuote(quoteId, false)\n cy.get(selectors.QuoteFromMyQuotesPage, { timeout: 15000 })\n .invoke('text')\n .should('include', quoteId)\n }\n )\n}\n\nfunction getdescription({ notes, discount, quantity, price }) {\n let description = null\n\n if (notes) {\n description = `Adding notes - ${notes}`\n } else if (discount) {\n description = `Adding discount of ${discount}`\n } else if (quantity && price) {\n description = `Updating price with ${price}, quantity ${quantity}`\n } else if (quantity) {\n description = `Updating quantity with ${quantity}`\n } else if (price) {\n description = `Updating price with ${price}`\n }\n\n return `${description} for this quote`\n}\n\nfunction getExpectedStatus({ notes, discount, quantity, price }) {\n if (!notes && !discount && !quantity && !price) {\n throw Error('Atleast one of the options should be updated')\n }\n\n return discount || quantity || price ? STATUSES.ready : STATUSES.revised\n}\n\nfunction updateDiscount(discount, expectedStatus, saveQuote) {\n const { QuoteTotal, DiscountSliderContainer, SliderSelector, SliderToolTip } =\n selectors\n\n const transformAttribute = 'transform: translateX(50px) translateX(-50%)'\n\n cy.get(selectors.QuoteOrginalTotal)\n .first()\n .should('not.have.text', DEFAULT_QUOTE_TOTAL)\n .invoke('text')\n .then((amountText) => {\n cy.get(selectors.QuoteStatus)\n .first()\n .invoke('text')\n .then((status) => {\n if (status !== expectedStatus) {\n cy.wrap(true).as(saveQuote)\n\n const amount = +amountText.replace('$', '')\n\n const discountedPrice = amount * ((100 - discount) / 100)\n\n cy.get(DiscountSliderContainer)\n .invoke('attr', 'style', transformAttribute)\n .should('have.attr', 'style', transformAttribute)\n .trigger('change')\n\n cy.get(SliderToolTip).click()\n\n cy.get(SliderToolTip)\n .should('not.have.text', '0%')\n .invoke('text')\n .then((percentage) => {\n const currentPercentage = +percentage.replace('%', '')\n\n cy.get(DiscountSliderContainer)\n .should('not.have.attr', 'style', transformAttribute)\n .invoke('attr', 'style')\n .then((transform) => {\n const r = /transform: translateX\\((\\d.*)px\\)/\n\n const pixelPerPercentage =\n transform.match(r)[1] / currentPercentage\n\n const expectedpixel = pixelPerPercentage * discount\n\n cy.get(DiscountSliderContainer).invoke(\n 'attr',\n 'style',\n `transform: translateX(${expectedpixel}px) translateX(-50%)`\n )\n\n cy.get(SliderSelector).should('be.visible').click()\n\n cy.get(SliderToolTip, {\n timeout: 4000,\n }).should('have.text', `${discount}%`)\n\n cy.get(SliderSelector).should('be.visible').click()\n\n cy.get(QuoteTotal, { timeout: 8000 })\n .first()\n .should('have.text', `$${discountedPrice.toFixed(2)}`)\n })\n })\n } else {\n cy.log(`Discount already updated`)\n }\n })\n })\n}\n\nfunction updateNotes(notes, saveQuote) {\n cy.get(selectors.Notes)\n .last()\n .invoke('text')\n .then((notesDescription) => {\n if (notesDescription !== `Notes:\\n${notes}`) {\n cy.wrap(true).as(saveQuote)\n cy.scrollTo('bottom')\n cy.get(selectors.Notes).should('be.visible').clear().type(notes)\n } else {\n cy.wrap(false).as(saveQuote)\n }\n })\n}\n\nfunction updatePrice(price, multiple, saveQuote) {\n cy.checkAndFillData(selectors.PriceField, price, 0).then(\n (updatePriceField1) => {\n cy.wrap(updatePriceField1).as(saveQuote)\n if (multiple) {\n cy.checkAndFillData(selectors.PriceField, price, 1).then(\n (updatePriceField2) => {\n if (!updatePriceField1 || updatePriceField2) {\n cy.wrap(updatePriceField2).as(saveQuote)\n }\n }\n )\n }\n }\n )\n}\n\nfunction updateQuantity(quantity, saveQuote) {\n cy.checkAndFillData(selectors.QuantityField, quantity).then((update) => {\n cy.wrap(update).as(saveQuote)\n })\n}\n\nfunction viewQuote(quote, open = true) {\n cy.gotoMyQuotes()\n cy.get(selectors.QuoteSearchQuery).clear().type(quote)\n cy.get(selectors.QuoteSearch).should('be.visible').click()\n if (open) {\n cy.contains(quote).click()\n cy.get(selectors.ProfileLabel).should('be.visible')\n cy.get(selectors.PageHeader)\n .should('be.visible')\n .should('contain', BUTTON_LABEL.QuoteDetails)\n cy.get(selectors.QuoteStatus).should('be.visible')\n } else {\n cy.log('Opening Quote is not allowed')\n }\n}\n\nexport function updateQuote(\n quote,\n { notes = false, discount = false, quantity = false, price = null },\n multiple = false\n) {\n const expectedStatus = getExpectedStatus({ notes, discount, quantity, price })\n const saveQuote = 'saveQuote'\n\n it(\n `${getdescription({\n notes,\n discount,\n quantity,\n price,\n })} - ${quote} and verify status ${expectedStatus}`,\n updateRetry(3),\n () => {\n cy.wrap(false).as(saveQuote)\n viewQuote(quote)\n\n if (notes) updateNotes(notes, saveQuote)\n\n if (discount) updateDiscount(discount, expectedStatus, saveQuote)\n\n if (price) updatePrice(price, multiple, saveQuote)\n\n if (quantity) updateQuantity(quantity, saveQuote)\n\n // eslint-disable-next-line cypress/no-unnecessary-waiting\n cy.wait(2000)\n\n cy.get(`@${saveQuote}`).then((response) => {\n cy.get(selectors.QuoteStatus, { timeout: 8000 })\n .invoke('text')\n .then((currentStatus) => {\n if (currentStatus !== expectedStatus) {\n if (response) {\n cy.waitForGraphql(\n GRAPHL_OPERATIONS.UpdateQuote,\n selectors.SaveQuote,\n true\n )\n } else {\n cy.log('Quote already got updated')\n }\n\n cy.get(selectors.QuoteStatus, { timeout: 8000 }).should(\n 'have.text',\n expectedStatus\n )\n }\n })\n })\n }\n )\n}\n\nexport function rejectQuote(quote, role) {\n const expectedStatus = STATUSES.declined\n\n it(`Decline quote from ${role}`, { retries: 2 }, () => {\n cy.gotoMyQuotes()\n cy.get(selectors.QuoteSearchQuery).clear().type(`${quote}{enter}`)\n cy.contains(quote).click()\n cy.get(selectors.ProfileLabel).should('be.visible')\n cy.get(selectors.QuoteStatus).should('be.visible')\n cy.get(selectors.QuoteTotal)\n .first()\n .should('not.have.text', DEFAULT_QUOTE_TOTAL)\n cy.checkStatusAndReject(expectedStatus).then((reject) => {\n if (reject) {\n cy.waitForGraphql(GRAPHL_OPERATIONS.UpdateQuote, selectors.Decline)\n cy.get(selectors.QuoteStatus).last().should('have.text', expectedStatus)\n } else {\n cy.log('Quote already rejeted')\n }\n })\n })\n}\n\nexport function useQuoteForPlacingTheOrder(quote, role) {\n it(`Use Quote from ${role}`, updateRetry(2), () => {\n cy.gotoMyQuotes()\n cy.get(selectors.QuoteSearchQuery).clear().type(`${quote}{enter}`)\n cy.contains(quote).click()\n cy.get(selectors.ProfileLabel).should('be.visible')\n cy.get(selectors.QuoteStatus).should('be.visible')\n cy.get(selectors.QuoteTotal)\n .first()\n .should('not.have.text', DEFAULT_QUOTE_TOTAL)\n .invoke('text')\n .then((amountText) => {\n const amount = parseFloat(\n amountText.replace(/ /g, '').replace('$', ''),\n 10\n )\n\n cy.setQuoteItem(`${quote}-price`, amount)\n\n cy.waitForGraphql(\n GRAPHL_OPERATIONS.UpdateQuote,\n selectors.UseQuoteButton\n )\n })\n })\n}\n\nexport function verifyTotal(quote) {\n it(\n `Take subtotal/total from quotes and use that to verify total in checkoutPage`,\n updateRetry(2),\n () => {\n cy.addDelayBetweenRetries(5000)\n cy.getQuotesItems().then((quotes) => {\n const price = quotes[`${quote}-price`]\n\n cy.url().then((url) => {\n if (!url.includes('checkout')) {\n cy.get('h1').contains('Quote')\n cy.get('div').contains('Checkout').click({ force: true })\n cy.get('div').contains('promo').should('be.visible')\n cy.get('div').contains('Checkout').click({ force: true })\n } else {\n cy.log('Already in checkout page')\n }\n })\n\n cy.get(selectors.CartTimeline)\n .should('be.visible')\n .click({ force: true })\n cy.get(selectors.ProceedtoPaymentBtn).should('be.visible')\n cy.get('body').then(($body) => {\n if ($body.find('tr.Discounts').length) {\n cy.get(selectors.TotalLabel, { timeout: 10000 })\n .first()\n .should('be.visible')\n .should('have.contain', `$ ${price.toFixed(2)}`)\n } else {\n cy.get(selectors.SubTotalLabel, { timeout: 10000 })\n .should('be.visible')\n .contains('Subtotal', { timeout: 6000 })\n .siblings('td.monetary', { timeout: 3000 })\n .should('have.text', `$ ${price.toFixed(2)}`)\n }\n })\n\n cy.get(selectors.ProceedtoPaymentBtn).should('be.visible').click()\n })\n }\n )\n}\n\nexport function searchQuote(quote, email = false) {\n const title = email\n ? `Searched Quote must have createdBy field with this email ${email}`\n : `Only Searched quote results should be available to the user`\n\n it(title, updateRetry(3), () => {\n cy.gotoMyQuotes()\n cy.get(selectors.QuoteSearchQuery)\n .should('be.visible')\n .clear()\n .type(`${quote}{enter}`)\n cy.contains(quote, { timeout: 15000 }).should('be.visible')\n cy.waitForGraphql(GRAPHL_OPERATIONS.GetQuotes, selectors.QuoteSearch)\n cy.get(selectors.QuoteFromMyQuotesPage).then(($els) => {\n let quotesList = Array.from($els, (el) => el.innerText)\n\n quotesList = quotesList.slice(0, quotesList.length / 2 + 1)\n quotesList.shift()\n expect(quotesList.every((q) => q.includes(quote))).to.be.true\n if (email) {\n cy.contains(email.toLowerCase(), { timeout: 8000 })\n }\n })\n })\n}\n\nfunction getPosition(organization, multi) {\n if (organization) return 2\n if (multi) return 3\n\n return 2\n}\n\nfunction fillFilterBy(data, organization = false, multi = false) {\n cy.getVtexItems().then((vtex) => {\n const filterBy = organization ? 'Organization' : 'Cost Center'\n const downarrowCount = !organization\n ? '{downarrow}{downarrow}{enter}'\n : '{downarrow}{enter}'\n\n cy.contains(/More/i).click()\n cy.contains(/Select a filter/i)\n .click()\n .clear()\n .type(downarrowCount)\n cy.get(selectors.FilterLabel).contains(filterBy, {\n matchCase: false,\n })\n cy.get(selectors.FilterInput).clear().type(data)\n cy.intercept('POST', `${vtex.baseUrl}/**`, (req) => {\n if (req.body.operationName === GRAPHL_OPERATIONS.GetQuotes) {\n req.continue()\n }\n }).as(GRAPHL_OPERATIONS.GetQuotes)\n cy.get('button > div').contains('Apply').click()\n cy.wait(`@${GRAPHL_OPERATIONS.GetQuotes}`)\n const position = getPosition(organization, multi)\n\n cy.get(`.ma2:nth-child(${position}) span.nowrap`)\n .invoke('text')\n .should('contain', `${data}`)\n })\n}\n\nfunction getTitleForFilterQuoteTestCase(organization, costCenter) {\n if (costCenter) return `costCenter ${costCenter}`\n if (organization && costCenter) {\n return `organization - ${organization} & costCenter - ${costCenter}`\n }\n}\n\nexport function filterQuote(costCenter, organization = false) {\n const title = getTitleForFilterQuoteTestCase(organization, costCenter)\n\n it(`Filter by ${title}`, () => {\n cy.gotoMyQuotes()\n cy.get(selectors.QuoteSearchQuery).clear()\n if (organization) {\n fillFilterBy(organization, organization)\n }\n\n if (costCenter) {\n fillFilterBy(costCenter, false, organization)\n }\n\n cy.get(selectors.Datas).then(($els) => {\n const texts = [...$els].map((el) => el.innerText)\n const rows = texts.filter((el) => el.includes('\\n'))\n\n for (const row of rows) {\n const datas = row.split('\\n')\n\n for (let i = 7; i <= datas.length; i += 8) {\n if (organization) expect(datas[i - 1]).equal(organization)\n expect(datas[i]).equal(costCenter)\n }\n }\n })\n })\n}\n\nconst checkAllElementsAreTrue = (resp) => resp.every(Boolean)\n\nexport function filterQuoteByStatus(expectedStatus1, expectedStatus2 = null) {\n const title = `Filter Quote by status ${expectedStatus1} ${\n expectedStatus2 ? `and ${expectedStatus2}` : ''\n }`\n\n it(title, updateRetry(2), () => {\n cy.gotoMyQuotes()\n cy.get(selectors.QuoteSearchQuery).clear()\n cy.get(selectors.QuotesFilterByStatus).click()\n for (const status in STATUSES) {\n const checkBoxSelector = `input[value='${status}']`\n\n cy.get(checkBoxSelector)\n .invoke('prop', 'checked')\n .then((checked) => {\n if (\n (!checked &&\n (status === expectedStatus1 || status === expectedStatus2)) ||\n (checked &&\n status !== expectedStatus1 &&\n status !== expectedStatus2)\n ) {\n cy.get(checkBoxSelector).click()\n }\n })\n }\n\n cy.get('button > div').contains('Apply').click()\n cy.get(selectors.QuoteFromMyQuotesPage).then(($els) => {\n let quotesList = Array.from($els, (el) => el.innerText)\n\n cy.get(selectors.ClearFilter).click()\n quotesList.reverse()\n quotesList = quotesList.slice(0, quotesList.length / 2)\n const comparison = quotesList.map((q) => {\n return q.includes(expectedStatus1) || q.includes(expectedStatus2)\n })\n\n expect(checkAllElementsAreTrue(comparison)).to.be.true\n })\n })\n}\n\nexport function preventQuoteUpdation() {\n it(\n 'In checkout page, Quote should not be able to update',\n updateRetry(3),\n () => {\n cy.get('tr:nth-child(1) > div > td.quantity > input')\n .should('be.visible')\n .should('not.be.disabled')\n .focus()\n .clear()\n .type(`{backspace}5{enter}`)\n cy.get('#clear-cart').should('be.visible')\n }\n )\n}\n\nexport function discountSliderShouldNotExist(quote) {\n it(`Discount Slider should not exist for this quote ${quote}`, () => {\n viewQuote(quote)\n cy.get(selectors.DiscountSliderContainer).should('not.exist')\n cy.get(selectors.Discount).should('have.text', '97%')\n })\n}\n\nexport function verifyQuotesAndSavedCarts() {\n it(\n `Verify when we click QuotesAndSavedCarts section it should redirect us to quotes page`,\n updateRetry(1),\n () => {\n cy.gotoMyOrganization()\n cy.contains(selectors.QuotesAndSavedCarts).should('be.visible').click()\n cy.get(selectors.MyQuotes).should('be.visible').click()\n }\n )\n}\n\n```"
}
] |
code_cy-runner_c8b49307
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/b2b/impersonation_quote_access.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport {\n quoteShouldbeVisibleTestCase,\n quoteShouldNotBeVisibleTestCase,\n} from './quotes.js'\n\nexport function salesAdminQuotesAccess(\n { organizationName, quotes },\n organizationB,\n organizationBQuote\n) {\n quoteShouldbeVisibleTestCase(\n organizationName,\n quotes.Buyer2.quotes1,\n organizationName\n )\n quoteShouldbeVisibleTestCase(\n organizationName,\n organizationBQuote.OrganizationAdmin.quotes1,\n organizationB\n )\n}\n\nexport function salesManagerQuotesAccess(\n { organizationName, quotes },\n organizationB,\n organizationBQuote\n) {\n quoteShouldbeVisibleTestCase(\n organizationName,\n quotes.OrganizationAdmin.quotes1,\n organizationName\n )\n quoteShouldbeVisibleTestCase(\n organizationName,\n quotes.Buyer2.quotes1,\n organizationName\n )\n quoteShouldNotBeVisibleTestCase(\n organizationName,\n organizationBQuote.OrganizationAdmin.quotes1,\n organizationB\n )\n}\n\nexport function salesRepQuotesAccess(\n { organizationName, quotes },\n organizationB,\n organizationBQuote\n) {\n quoteShouldNotBeVisibleTestCase(\n organizationName,\n quotes.Buyer2.quotes1,\n organizationName\n )\n quoteShouldNotBeVisibleTestCase(\n organizationName,\n organizationBQuote.OrganizationAdmin.quotes1,\n organizationB\n )\n quoteShouldbeVisibleTestCase(\n organizationName,\n quotes.OrganizationAdmin.quotes1,\n organizationName\n )\n}\n\n```"
}
] |
code_cy-runner_0c32a089
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/b2b/common.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport selectors from '../common/selectors.js'\nimport { generateEmailWithSuffix, validateToastMsg } from './utils.js'\nimport { BUTTON_LABEL, TOAST_MSG } from '../validation_text.js'\nimport { GRAPHL_OPERATIONS } from '../graphql_operations.js'\nimport { updateRetry } from '../common/support.js'\n\n// Define constants\nconst APP_NAME = 'vtex.b2b-organizations-graphql'\nconst APP_VERSION = '0.x'\nconst APP = `${APP_NAME}@${APP_VERSION}`\n\nfunction verifyStoreFrontPermissionInSessions(response) {\n cy.qe(\n `Get organization and costcenter ids from storefront-permission property & Expect organziationId ,costCenterId has -`\n )\n expect(response.body)\n .to.have.property('namespaces')\n .to.have.property('storefront-permissions')\n .to.have.property('organization')\n .to.have.property('value')\n .to.contain('-')\n expect(response.body.namespaces['storefront-permissions'])\n .to.have.property('costcenter')\n .to.have.property('value')\n .to.contain('-')\n\n return {\n organizationId:\n response.body.namespaces['storefront-permissions'].organization.value,\n costCenterId:\n response.body.namespaces['storefront-permissions'].costcenter.value,\n }\n}\n\nexport function setOrganizationIdInJSON(organization, costCenter) {\n it(\n 'Getting Organization,CostCenter Id from session and set this in organizations.json file',\n { retries: 5, responseTimeout: 10000 },\n () => {\n cy.addDelayBetweenRetries(15000)\n cy.getAPI('/api/sessions?items=*').then((response) => {\n cy.qe(`Namespaces, storefront-permission should exist in response`)\n const { organizationId, costCenterId } =\n verifyStoreFrontPermissionInSessions(response)\n\n cy.qe(\n 'Store organizationId & costCenterId in stateFile - .organization.json'\n )\n // Saving organization & costcenter id in organization.json and this id will be deleted this wipe.spec.js\n cy.setOrganizationItem(organization, organizationId)\n cy.setOrganizationItem(costCenter, costCenterId)\n })\n }\n )\n}\n\nfunction addPaymentTermsCollectionPriceTables(organizationItems, organization) {\n const { organizationName, collections, paymentTerms, priceTables } =\n organization\n\n const id = organizationItems[organizationName]\n\n return {\n id,\n name: organizationName,\n status: 'active',\n collections,\n paymentTerms,\n priceTables,\n }\n}\n\nexport function addPaymentTermsCollectionPriceTablesTestCase(organization) {\n it(\n `Add Payment Terms/Collections/Price Tables for ${organization.organizationName}`,\n updateRetry(3),\n () => {\n cy.getVtexItems().then((vtex) => {\n cy.getOrganizationItems().then((organizationItems) => {\n const CUSTOM_URL = `${vtex.baseUrl}/_v/private/admin-graphql-ide/v0/${APP}`\n const GRAPHQL_UPDATE_ORGANISATION_MUTATION =\n 'mutation' +\n '($id:ID!,$name: String!,$status: String!,$collections:[CollectionInput],$paymentTerms:[PaymentTermInput],$priceTables:[String])' +\n '{updateOrganization(id:$id,name:$name,status:$status,collections:$collections,paymentTerms:$paymentTerms,priceTables:$priceTables){' +\n 'status}}'\n\n const variables = addPaymentTermsCollectionPriceTables(\n organizationItems,\n organization\n )\n\n cy.callGraphqlAndAddLogs({\n url: CUSTOM_URL,\n query: GRAPHQL_UPDATE_ORGANISATION_MUTATION,\n variables,\n }).then((resp) => {\n cy.qe(\n 'response.body.data.updateOrganization.status should have success'\n )\n expect(resp.body.data.updateOrganization.status).to.equal('success')\n })\n })\n })\n }\n )\n}\n\nfunction verifyWidget(organization, costCenter, role) {\n cy.get(selectors.UserWidget, { timeout: 15000 })\n .eq(0)\n .should('contain', `Organization: ${organization.organizationName}`)\n cy.get(`${selectors.UserWidget} ${selectors.Tag}`, { timeout: 3000 }).should(\n 'have.text',\n 'Active'\n )\n cy.get(selectors.UserWidget, { timeout: 3000 })\n .eq(1)\n .should('contain', `Cost Center: ${costCenter}`)\n cy.get(selectors.UserWidget, { timeout: 3000 })\n .eq(2)\n .should('contain', `My Role: ${role}`)\n}\n\nexport function verifySession(organization, costCenter, role) {\n it(\n 'Verifying Session items must have expected priceTable and collections',\n updateRetry(3),\n () => {\n cy.reloadOnLastNAttempts(2)\n cy.addDelayBetweenRetries(10000)\n cy.getAPI('/api/sessions?items=*').then((response) => {\n verifyStoreFrontPermissionInSessions(response)\n expect(response.body.namespaces)\n .to.have.property('profile')\n .to.have.property('priceTables')\n .to.have.property('value')\n expect(response.body.namespaces)\n .to.have.property('search')\n .to.have.property('facets')\n .to.have.property('value')\n\n expect(response.body.namespaces.profile.priceTables.value).to.equal(\n organization.priceTables\n )\n expect(response.body.namespaces.search.facets.value).to.equal(\n organization.collections\n .map((ele) => `productClusterIds=${ele.id};`)\n .join('')\n )\n })\n verifyWidget(organization, costCenter, role)\n }\n )\n}\n\nexport function productShouldNotbeAvailableTestCase(product) {\n it(\n 'Products from outside collection should not be visible to the user',\n updateRetry(2),\n () => {\n cy.searchProductinB2B(product, false)\n cy.get(selectors.PageNotFound).should('be.visible')\n }\n )\n}\n\nexport function userAndCostCenterShouldNotBeEditable({\n organizationName,\n costCenter,\n role,\n gmailCreds,\n}) {\n it(\n `Trying to update user and cost center in ${organizationName} with role ${role.dropDownText}`,\n updateRetry(1),\n () => {\n const { suffixInEmail } = role\n\n cy.gotoMyOrganization()\n cy.get(selectors.AddUser).should('be.visible')\n cy.get(\n '.vtex-table__container .ReactVirtualized__Grid__innerScrollContainer'\n )\n .last()\n .contains(\n generateEmailWithSuffix(\n gmailCreds.email,\n organizationName,\n suffixInEmail\n )\n )\n .should('have.class', 'c-disabled')\n cy.get(selectors.AddUser).should('be.visible').should('be.disabled')\n cy.get(selectors.AddCostCenter).should('be.visible').should('be.disabled')\n cy.get(\n '.vtex-table__container .ReactVirtualized__Grid__innerScrollContainer'\n )\n .eq(1)\n .contains(costCenter)\n .click()\n cy.get(selectors.CostCenterHeader)\n .contains(BUTTON_LABEL.save)\n .should('be.disabled')\n cy.get(selectors.CostCenterHeader)\n .contains(BUTTON_LABEL.delete)\n .should('be.disabled')\n }\n )\n}\n\nexport function performImpersonation(user1, email) {\n cy.getVtexItems().then((vtex) => {\n const isSalesManagerOrRep = !!user1.match(/Manager|Representative/i)\n\n cy.gotoMyOrganization(false, isSalesManagerOrRep)\n cy.intercept('POST', `${vtex.baseUrl}/**`, (req) => {\n if (req.body.operationName === GRAPHL_OPERATIONS.GetUsers) {\n req.continue()\n }\n }).as(GRAPHL_OPERATIONS.GetUsers)\n cy.get('input[type=search]').should('be.visible').clear().type(`${email}`)\n cy.get('input[type=search] ~ span > div > span > svg[class*=search]')\n .should('be.visible')\n .click()\n\n cy.get('svg[class*=dots]', { timeout: 15000 }).should('have.length', 1)\n cy.get('div[role=rowgroup] > div > span').contains(email)\n\n const SalesAdmin = !!user1.match(/Sales Admin/i)\n const childIndex = SalesAdmin ? 5 : 4\n\n cy.get(\n `div[class=ReactVirtualized__Grid__innerScrollContainer] > div:nth-child(${childIndex}) > div`,\n { timeout: 10000 }\n )\n .should('be.visible')\n .click()\n\n cy.get(selectors.ImpersonateButton)\n .should('have.text', 'Impersonate User')\n .click()\n })\n}\n\nexport function userShouldNotImpersonateThisUser(user1, user2, email) {\n it(\n `Verifying ${user1} is not able to impersonate ${user2}`,\n updateRetry(2),\n () => {\n cy.performImpersonation(user1, email)\n validateToastMsg(TOAST_MSG.impersonatePermissionError)\n }\n )\n}\n\nfunction validateImpersonation(user1, email) {\n cy.performImpersonation(user1, email)\n cy.getVtexItems().then((vtex) => {\n cy.intercept('POST', `${vtex.baseUrl}/**`, (req) => {\n if (req.body.operationName === GRAPHL_OPERATIONS.Session) {\n req.continue()\n }\n }).as(GRAPHL_OPERATIONS.Session)\n })\n validateToastMsg(TOAST_MSG.initializing)\n cy.wait(`@${GRAPHL_OPERATIONS.Session}`)\n // cy.get(selectors.UserWidget).eq(2).should('contain', `My Role: ${user2}`)\n cy.get(selectors.UserImpersonationWidget)\n .should('be.visible')\n .should('contain', `Impersonating: ${email}`)\n cy.get('span').contains(email).should('be.visible')\n cy.get(selectors.MyQuotes).should('be.visible')\n cy.contains('Stop Impersonation').should('be.visible')\n}\n\nexport function salesUserShouldImpersonateNonSalesUser(user1, user2, email) {\n it(`Verifying ${user1} is able to impersonate ${user2}`, () => {\n validateImpersonation(user1, email)\n cy.get('input[type=search]').should('be.visible')\n })\n}\n\nexport function stopImpersonation() {\n it(`Verifying stopImpersonation`, () => {\n cy.getVtexItems().then((vtex) => {\n cy.intercept('POST', `${vtex.baseUrl}/**`, (req) => {\n if (req.body.operationName === GRAPHL_OPERATIONS.GetQuotes) {\n req.continue()\n }\n }).as(GRAPHL_OPERATIONS.GetQuotes)\n cy.contains('Stop Impersonation').should('be.visible').click()\n cy.waitForSession()\n cy.wait(`@${GRAPHL_OPERATIONS.GetQuotes}`)\n cy.get(selectors.UserImpersonationWidget).should('not.exist')\n cy.get(selectors.ProfileLabel).should('be.visible')\n })\n })\n}\n\n```"
}
] |
code_cy-runner_10c75fe8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/b2b/utils.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport selectors from '../common/selectors.js'\n\nexport function generateName(role) {\n return `${role}-Robot`\n}\n\nexport function generateEmailWithSuffix(email, organization, role) {\n const [basename, domain] = email.split('@')\n const emailWithPrefix = `${basename}+${\n Cypress.env().workspace.name\n }${organization.slice(0, 3)}${organization\n .split('-')[0]\n .slice(-1)}${role}a@${domain}`\n\n return emailWithPrefix.toLowerCase()\n}\n\nexport const STATUSES = {\n ready: 'ready',\n placed: 'placed',\n declined: 'declined',\n expired: 'expired',\n pending: 'pending',\n revised: 'revised',\n}\n\nexport const ROLE_DROP_DOWN = {\n OrganizationAdmin: 'Organization Admin',\n Buyer: 'Organization Buyer',\n Approver: 'Organization Approver',\n}\n\nexport const ROLE_DROP_DOWN_EMAIL_MAPPING = {\n OrganizationAdmin1: {\n dropDownText: ROLE_DROP_DOWN.OrganizationAdmin,\n suffixInEmail: 'oa1',\n },\n OrganizationAdmin2: {\n dropDownText: ROLE_DROP_DOWN.OrganizationAdmin,\n suffixInEmail: 'oa2',\n },\n OrganizationAdmin3: {\n dropDownText: ROLE_DROP_DOWN.OrganizationAdmin,\n suffixInEmail: 'oa3',\n },\n Buyer1: { dropDownText: ROLE_DROP_DOWN.Buyer, suffixInEmail: 'b1' },\n Buyer2: { dropDownText: ROLE_DROP_DOWN.Buyer, suffixInEmail: 'b2' },\n Buyer3: { dropDownText: ROLE_DROP_DOWN.Buyer, suffixInEmail: 'b3' },\n Buyer4: {\n dropDownText: ROLE_DROP_DOWN.Buyer,\n suffixInEmail: 'b3',\n },\n Approver1: { dropDownText: ROLE_DROP_DOWN.Approver, suffixInEmail: 'a1' },\n Approver2: { dropDownText: ROLE_DROP_DOWN.Approver, suffixInEmail: 'a2' },\n Approver3: { dropDownText: ROLE_DROP_DOWN.Approver, suffixInEmail: 'a3' },\n}\n\nexport const OTHER_ROLES = [\n 'Sales Admin',\n 'Sales Representative',\n 'Sales Manager',\n]\n\nexport const ROLE_ID_EMAIL_MAPPING = {\n SalesAdmin: { role: OTHER_ROLES[0], suffixInEmail: 'sa' },\n SalesRepresentative: { role: OTHER_ROLES[1], suffixInEmail: 'sr' },\n SalesManager: { role: OTHER_ROLES[2], suffixInEmail: 'sm' },\n}\n\nexport const PAYMENT_TERMS = {\n Promissory: 'Promissory',\n NET30: 'NET 30',\n}\n\nexport function validateToastMsg(msg) {\n cy.qe(\n `Toast message ${msg} should be shown in this selector ${selectors.ToastMsgInB2B}`\n )\n cy.get(selectors.ToastMsgInB2B, { timeout: 8000 })\n .should('be.visible')\n .contains(msg)\n}\n\nexport function validateToolTipMsg(message, position = 0) {\n cy.qe(\n `Validating the tooltip message - ${message} and its position - ${position}`\n )\n cy.get('span[class*=danger]', { timeout: 15000 })\n .should('be.visible')\n .eq(position)\n .trigger('mouseover')\n cy.get('div[role=tooltip]', { timeout: 5000 })\n .should('be.visible')\n .eq(position)\n .contains(message)\n}\n\n```"
}
] |
code_cy-runner_9fd0bbcd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/b2b/env_quotes.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n// ***********************************************\n// Keeps the variables of the environment\n// ***********************************************\n\n// File to persist env between tests\nconst quotesJson = '.quotes.json'\n\n// Set VTEX item\nCypress.Commands.add('setQuoteItem', (quoteItem, quoteValue) => {\n cy.readFile(quotesJson).then((items) => {\n items[quoteItem] = quoteValue\n cy.writeFile(quotesJson, items)\n })\n})\n\n// Get VTEX vars\nCypress.Commands.add('getQuotesItems', () => {\n cy.readFile(quotesJson).then((items) => {\n return items\n })\n})\n\n```"
}
] |
code_cy-runner_8303a62e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/b2b/checkout.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport selectors from '../common/selectors.js'\nimport { updateRetry } from '../common/support.js'\nimport { BUTTON_LABEL } from '../validation_text.js'\nimport { PAYMENT_TERMS } from './utils.js'\n\nexport function checkoutProduct(product) {\n it('Checkout the Product', updateRetry(2), () => {\n cy.searchProductinB2B(product)\n cy.get(selectors.searchResult)\n .first()\n .should('have.text', product.toLowerCase())\n cy.get('span[class*=add-to-cart]').should('be.visible').first().click()\n cy.intercept('**/checkout/**').as('checkout')\n cy.get(selectors.ProceedtoCheckout).click()\n cy.wait('@checkout')\n cy.get('body').then(($body) => {\n if ($body.find(selectors.DeliveryAddress).length) {\n // Contact Information already filled\n cy.get(selectors.DeliveryAddress).should('be.visible')\n } else if ($body.find(selectors.ShippingCalculateLink).length) {\n // Contact information needs to be filled\n cy.get(selectors.ShippingCalculateLink).should('be.visible')\n }\n })\n cy.get(selectors.ProceedtoPaymentBtn).should('be.visible').click()\n })\n}\n\nexport function fillContactInfo() {\n it('Fill Contact Information', updateRetry(3), () => {\n cy.get(selectors.FirstName).then(($el) => {\n if (Cypress.dom.isVisible($el)) {\n cy.get(selectors.FirstName).clear().type('Syed', { delay: 50 })\n cy.get(selectors.LastName).clear().type('Mujeeb', { delay: 50 })\n cy.get(selectors.Phone).clear().type('(304) 123 4556', { delay: 50 })\n cy.get(selectors.ProceedtoShipping).should('be.visible').click()\n cy.get('body').then(($body) => {\n if ($body.find(selectors.ReceiverName).length) {\n cy.get(selectors.ReceiverName, { timeout: 5000 })\n .clear()\n .type('Syed')\n }\n })\n cy.get(selectors.GotoPaymentBtn, { timeout: 5000 }).should('be.visible')\n } else {\n cy.log('Contact information already filled')\n }\n })\n })\n}\n\nfunction clickGotoPayment() {\n cy.get('body').then(($body) => {\n if ($body.find(selectors.GotoPaymentBtn).length) {\n cy.get(selectors.GotoPaymentBtn, { timeout: 5000 })\n .should('be.visible')\n .click()\n }\n })\n}\n\nexport function verifyAddress(address) {\n it('Verify Auto fill Address in checkout', updateRetry(3), () => {\n cy.setorderFormDebugItem()\n if (cy.state('runnable')._currentRetry > 1) {\n cy.reload()\n cy.get(selectors.EditShipping).should('be.visible').click()\n }\n\n cy.get('body').then(($shipping) => {\n if ($shipping.find(selectors.EditShipping).length) {\n cy.get(selectors.EditShipping).should('be.visible').click()\n } else if ($shipping.find(selectors.OpenShipping).length) {\n cy.get(selectors.OpenShipping, { timeout: 5000 }).click()\n }\n })\n\n for (const { postalCode } of address) {\n cy.get(selectors.PostalCodeText, { timeout: 5000 })\n .contains(postalCode)\n .click()\n }\n\n clickGotoPayment()\n })\n}\n\nexport function verifyPayment(promissory = true) {\n it('Verify enabled payments is shown in the checkout', updateRetry(3), () => {\n if (cy.state('runnable')._currentRetry > 0) cy.reload()\n clickGotoPayment()\n if (promissory) {\n cy.get(`[data-name='${PAYMENT_TERMS.Promissory}']`).should('be.visible')\n } else {\n cy.get(`[data-name='${PAYMENT_TERMS.Promissory}']`).should(\n 'not.be.visible'\n )\n }\n\n cy.get(`[data-name='${PAYMENT_TERMS.NET30}']`).should('be.visible')\n })\n}\n\nexport function ordertheProduct(role) {\n it(`Verify ${role} is able to order the product`, () => {\n cy.get(`[data-name='${PAYMENT_TERMS.NET30}']`)\n .should('be.visible')\n .click({ force: true })\n // eslint-disable-next-line cypress/no-unnecessary-waiting\n cy.wait(5000)\n cy.contains(BUTTON_LABEL.completeOrder)\n .should('be.visible')\n .click({ force: true })\n cy.get(selectors.Search, { timeout: 30000 }).should('be.visible')\n })\n}\n\n```"
}
] |
code_cy-runner_e8eb340e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/common/constants.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nexport const AUTH_COOKIE_NAME_ENV = 'AUTH_COOKIE_NAME'\n\n// Address list for shipping information\nexport const addressList = {\n 33180: {\n country: 'USA',\n deliveryScreenAddress: '19501 Biscayne Blvd ',\n fullAddress: ' 19501 19501 Biscayne Blvd Aventura 33180',\n },\n 90290: {\n country: 'USA',\n deliveryScreenAddress: 'Kerry Lane ',\n fullAddress: ' Kerry Ln Topanga 90290',\n },\n 93200: {\n country: 'FRA',\n deliveryScreenAddress: '91 Rue de Strasbourg ',\n fullAddress: ' 91 Rue de Strasbourg Saint-Denis 93200',\n },\n 'N9V 1K8': {\n country: 'CAN',\n deliveryScreenAddress: 'Texas Road 8',\n fullAddress: '8 Texas Road',\n },\n 94536: {\n country: 'USA',\n deliveryScreenAddress: 'Shinn Street ',\n fullAddress: ' Shinn Street Fremont, CA 94536',\n },\n}\n\n// VTEX_AUTH_HEADER for API Calls\nexport const VTEX_AUTH_HEADER = (apiKey, apiToken) => {\n return {\n 'X-VTEX-API-AppKey': apiKey,\n 'X-VTEX-API-AppToken': apiToken,\n }\n}\n\n// We set failOnStatusCode to false\n// On failure, this will help us to avoid printing tokens in the screen.\nexport const FAIL_ON_STATUS_CODE = {\n failOnStatusCode: false,\n}\n\nexport const FAIL_ON_STATUS_CODE_STRING = 'failOnStatusCode: false,'\n\nexport const ENTITIES = {\n CLIENTS: { id: 'CL', searchKey: 'email' },\n ADDRESSES: { id: 'AD', searchKey: 'userId' },\n CHECKOUTCUSTOM: { id: 'checkoutcustom' },\n}\n\nexport const HEADERS = {\n headers: {\n 'user-agent':\n 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36',\n },\n}\n\n```"
}
] |
code_cy-runner_4d93ae13
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/common/graphql_utils.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { FAIL_ON_STATUS_CODE } from './constants'\n\nconst config = Cypress.env()\n\n// Constants\nconst { vtex } = config.base\n\nexport function commonGraphlValidation(response) {\n expect(response.status).to.equal(200)\n expect(response.body.data).to.not.equal(null)\n expect(response.body).to.not.equal('OK')\n expect(response.body).to.not.have.own.property('errors')\n}\n\nexport function graphql(\n app,\n getQuery,\n validateResponseFn = null,\n params = null\n) {\n const { query, queryVariables } = getQuery\n\n // Define constants\n const CUSTOM_URL = `${vtex.baseUrl}/_v/private/admin-graphql-ide/v0/${app}`\n\n // Note: Don't replace this cy.request with cy.callRestAPIAndAddLogs\n // We already adding graphql here\n cy.request({\n method: 'POST',\n url: CUSTOM_URL,\n body: {\n query,\n variables: queryVariables,\n },\n ...FAIL_ON_STATUS_CODE,\n }).as('RESPONSE')\n\n cy.addGraphqlLogs(query, queryVariables)\n\n if (validateResponseFn) {\n cy.get('@RESPONSE').then((response) => {\n commonGraphlValidation(response)\n validateResponseFn(response, params)\n })\n } else {\n return cy.get('@RESPONSE')\n }\n}\n\n```"
}
] |
code_cy-runner_d3f811a5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/common/edition_app_list.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nexport default {\n ordersBroadcast: {\n app: 'vtex.orders-broadcast',\n version: '0.x',\n },\n sno: {\n app: 'vtex.sno',\n version: '0.x',\n },\n}\n\n```"
}
] |
code_cy-runner_774701f9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/common/selectors.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nexport default {\n // *************HomePage Constants start here************ //\n\n SignInBtn: '.vtex-login-2-x-container > div >button',\n Email: 'input[name=email]',\n Password: '[class*=emailVerifi] > form > div input[type=password]',\n ForgotPassword: 'a[class*=forgot]',\n PasswordValidation: '.w-80',\n SignInFormBtn: 'div[class*=sendButton] > button',\n SignInLabel: '.vtex-login-2-x-label',\n ProfileLabel: 'span[class*=profile]',\n LogoutBtn: '[data-test=\"logout\"]',\n Search: 'input[placeholder=Search]',\n OpenCart: 'span[class*=minicart]',\n MyAccount: '.vtex-login-2-x-accountOptions >div >a >button > span',\n Logout:\n '.vtex-login-2-x-accountOptions >div:last-child > button > div > span',\n ProductDiv: 'article > div',\n ProductRating: 'article >div div[class*=vtex-reviews-and-ratings]',\n PayPaliframe: 'iframe[name*=paypal]',\n PayPalImg: \"button[aria-label*='PayPal Pay Later Message']\",\n AddtoCart: 'span[class*=vtex-add-to-cart-button]',\n TotalPrice: '#total-price > div[class*=price]',\n RemoveProduct: 'div[class*=\"removeButton\"]',\n PickupInStore: '.srp-toggle__pickup',\n PickupItems: '.srp-items',\n ProductsQAShipping: \"input[value='Productusqa2']\",\n CloseCart: 'button[class*=minicart]',\n // Below products are from sandboxusdev\n AddtoCartBtnForHat: \"a[href*='003/p'] > article > button\",\n AddtoCartBtnForAdidas: \"a[href*='adidas01/p'] > article > button\",\n AddtoCartBtnForAdidasv5: \"a[href*='adidas01v5/p'] > article > button\",\n // Below product is from external seller\n AddtoCartBtnForTShirt: \"a[href*='adidas-women'] > article > button\",\n // Below products are from productusqa\n AddtoCartBtnForOnion: \"a[href*='onion'] > article > button\",\n AddtoCartBtnForCoconut: \"a[href*='coconut'] > article > button\",\n AddtoCartBtnForOrange: \"a[href*='frutas'] > article > button\",\n AddtoCartBtnForMelon: \"a[href*='watermelon'] > article > button\",\n FillInvoiceButton: '.vtex-omnishipping-1-x-btnDelivery',\n // *************HomePage Constants end here************ //\n\n // *************Search Results Constants end here************ //\n BrandFilter: 'label[for*=brand]',\n ProductAnchorElement: 'section[class*=summary] >a',\n generateAddtoCartSelector: (href) => {\n return `a[href='${href}'] > article > button`\n },\n searchResult: 'h1[class*=vtex-search]',\n // *************Search Results Constants end here************ //\n\n // *************Cart Sidebar Constants starts here************ //\n ProductQuantity:\n 'div[class*=quantityDropdownContainer] > div > label > div > select',\n Paypal: 'div[class*=paypal]',\n SummaryText: 'span[class*=summarySmall]',\n ProceedtoCheckout: '#proceed-to-checkout',\n NewPayPal: 'div[class*=paypal] > span > iframe[name*=paypal]',\n QuantityBadgeInCart: 'span[class*=minicartQuantityBadge]',\n // *************Cart Sidebar Constants end here************ //\n\n // ************* New Cart - PayPal Constants end here************ //\n ItemQuantity: '#items-quantity',\n // ************* New Cart - PayPal Constants end here************ //\n\n // *************Product Page Constants starts here************ //\n AddressForm: 'div[class*=addressForm]',\n NormalShipping: 'label[id=Normal]',\n FilterHeading: 'h5[class*=\"filter\"]',\n\n // *************Product Page Constants end here************ //\n\n // *************Order Form Page Constants starts here************ //\n\n // Progress bar\n\n CartTimeline: 'span[class*=item_cart] > span',\n\n // *************Contact Form Page Constants starts here************ //\n ContactForm: '.form-step.box-edit',\n FirstName: '#client-first-name',\n LastName: '#client-last-name',\n Phone: '#client-phone',\n ProceedtoShipping: '#go-to-shipping',\n GoToPayment: '#go-to-payment',\n // *************Contact Form Page Constants end here************ //\n\n // *************Shipping Section Constants starts here************ //\n ShippingPreview: '#shipping-preview-container',\n ShippingCalculateLink:\n '#shipping-preview-container > div #shipping-calculate-link',\n ProductQuantityInCheckout: (position) => {\n return `tr:nth-child(${position}) > div > td.quantity > input`\n },\n ItemRemove: (position) => {\n return `tr:nth-child(${position}) > div > td.item-remove`\n },\n giftCheckbox: '.available-gift-items > tr > td:nth-child(2) > i',\n PostalCodeFinishedLoading: '#postalCode-finished-loading',\n EditShipping: 'a[id=edit-shipping-data]',\n OpenShipping: '#open-shipping',\n NewAddressBtn: '#new-address-button',\n UpdateSelectedAddressBtn: '#edit-address-button',\n ShippingSectionTitle: 'p[class*=shippingSectionTitle]',\n ShipStreet: '#ship-street',\n ShipAddressQuery: '#ship-addressQuery',\n CalculateBtn: '#cart-shipping-calculate',\n ContinueShipping: '#btn-go-to-shippping-method',\n CalculateShipping: 'button[class*=btnDelivery]',\n ForceShippingFields: '#force-shipping-fields',\n DeliveryAddress: '#deliver-at-text',\n ReceiverName: '#ship-receiverName',\n DeliveryAddressText: '#deliver-at-text > a',\n ChangeShippingAddress: 'button[data-i18n=\"modal.editShipping\"]',\n ConfirmPickup: 'button[id*=confirm-pickup]',\n FillInvoiceAddress: 'p[class*=omnishipping] ~ button[class*=omnishipping]',\n\n // Shipping Section Address Container\n StreetAddress: '#v-custom-ship-street',\n ShipCity: '#ship-city',\n ShipState: '#ship-state',\n ShipCountry: '#ship-country',\n PostalCodeInput: '#ship-postalCode',\n\n // *************Shipping Section Constants end here************ //\n\n // *************Summary Section Constants starts here************ //\n QuantityBadge: '.quantity.badge',\n SummaryCart: 'div[class*=summary-cart] .product-name',\n Discounts: 'tr.Discounts',\n ProceedtoPaymentBtn: 'a[id=cart-to-orderform]',\n ShippingAmtLabel:\n 'td[data-i18n=\"totalizers.Shipping\"] ~ td[data-bind=\"text: valueLabel\"]',\n TaxAmtLabel: \".CustomTax > td[data-bind='text: customTaxTotalLabel']\",\n TotalLabel: 'td[data-bind=\"text: totalLabel\"]',\n ShippingSummary: 'td[data-bind=\"text: valueLabel\"]',\n GotoPaymentBtn: '#btn-go-to-payment',\n SubTotal:\n '.cart-template > .summary-template-holder > div > .totalizers > div table tr.Items > td.monetary',\n DeliveryUnavailable: 'p[id=\"shp-unavailable-delivery-available-pickup\"]>span',\n // *************Summary Section Constants end here************ //\n\n //* ************Payment Section Constants starts here************ //\n ExemptionInput: '[name=tax-exemption__input]',\n SubmitExemption: 'input[class*=tax-exemption__button]',\n VatInput: '[name=vat-number__input]',\n SubmitVat: 'input[class*=vat-number__button]',\n TaxClass: '.CustomTax',\n Net90PaymentBtn: 'a[data-name=Net90]',\n Net90Label: '.payment-description',\n PromissoryPayment: '[data-name=Promissory]',\n BuyNowBtn: '#payment-data-submit > span',\n PaymentConfirmationLabel: '.vtex-order-placed-2-x-confirmationTitle',\n OrderIdLabel: '.vtex-order-placed-2-x-orderNumber',\n CreditCardLink: '#payment-group-creditCardPaymentGroup',\n PaymentMethodIFrame: '.payment-method iframe',\n CardExist: '#use-another-card',\n CreditCard: 'a[data-name*=American]',\n CreditCardNumber: '[name=cardNumber]',\n CreditCardHolderName: \"[name='ccName']\",\n CreditCardExpirationMonth: '[name=cardExpirationMonth]',\n CreditCardExpirationYear: '[name=cardExpirationYear]',\n CreditCardCode: '#creditCardpayment-card-0Code',\n CrediCardCvvCode: '.PaymentCardCVV input',\n PaymentUnAuthorized: 'div[class*=payment-unauthorized]',\n AffirmPayment: '[data-name=Affirm]',\n dataReviewCloseBtn: '.payment-unauthorized-modal > .modal-body > .btn',\n popUpClose: '#affirm-error-modal',\n invalidPopUpCloseBtn:\n 'div[class*=dialog] > div[class*=dialog-close-button-container] > button[class*=dialog-close-button]',\n InstallmentContainer: '.installments span',\n // *************Payment Section Constants end here************ //\n\n // *************Order Form Page Constants end here************ //\n\n // *************B2B Constants starts here************ //\n SignEmail: 'div[class*=emailPassw]',\n Menu: 'div[role=presentation] > svg > use[href*=\"menu\"]',\n OrganisationSignup: 'a[href*=request] > span',\n AccessCode: 'div[class*=access]',\n Header: 'h3[class*=Title]',\n Submit: 'div[class*=login] > button[type=submit]',\n Token: 'input[name=token]',\n OrganizationName: 'div.layout__container > div:nth-child(1) input[required]',\n FirstNameinB2B:\n 'div.layout__container > div:nth-child(2) div[class*=b2b]:nth-child(1) input[type=text]',\n LastNameinB2B:\n 'div.layout__container > div:nth-child(2) div[class*=b2b]:nth-child(2) input[type=text]',\n EmailinB2B:\n 'div.layout__container > div:nth-child(2) div[class*=b2b]:nth-child(3) input[type=text]',\n CostCenter:\n 'div.layout__container > div:nth-child(3) div[class*=b2b]:nth-child(1) input[type=text]',\n PostalCode: 'input[name=postalCode]',\n Street: 'input[name=street]',\n Country: 'select[name=country]',\n City: 'input[name=city]',\n State: 'select[name=state]',\n ReceiverNameinB2B: 'input[name=receiverName]',\n SubmitOrganization: 'div[class*=Submit] button',\n PopupMsg: '.items-start .ph5',\n BuyNowBtnInB2B: 'span[class*=buy]',\n MyQuote: 'a[href*=quote]:nth-child(1)',\n CreateQuote: 'a[href*=quote]',\n PageHeader: 'div[class*=vtex-pageHeader__title]',\n UserWidget: 'div[class*=userWidgetItem]',\n UserImpersonationWidget: 'div[class*=userWidgetImpersonationItem]',\n Tag: '.vtex-tag',\n // *************B2B Account: My Organization Constants start here************ //\n QuotesAndSavedCarts: 'Quotes and Saved Carts',\n Profile: 'a[href*=profile]',\n MyOrganization: 'a[href*=organization]',\n MyOrganizationUserContainer:\n 'div[class=ReactVirtualized__Grid__innerScrollContainer] > div > span',\n MyOrganizationCostCenterUserDiv:\n '.ReactVirtualized__Grid__innerScrollContainer',\n PageNotFound: 'div[class*=notFound]',\n PageBlock: 'div[class*=styleguide__pageBlock]',\n ImpersonateButton: 'button[data-testid=menu-option-0] > span',\n\n // *************B2B Account: My Organization - Add Cost Center Constants start here************ //\n AddCostCenter:\n 'div[class*=layout__container] > div:nth-child(1) #toolbar button',\n CostCenterName:\n 'div[class*=scroll] > div:nth-of-type(1) div[class*=input] input[type=text]',\n CostCenterHeader: 'div[class*=vtex-pageHeader]',\n CloseModal: 'div[class*=modal__close]',\n SubmitCostCenter: '.nowrap > span:last-child > button',\n PromissoryCheckbox: '.mv4:nth-child(1) input[type=checkbox]',\n SaveChangesInCostCenter: '.mr4 div',\n AddAddress: 'div[class*=vtex-card] > div > button[type=button]',\n ToastMsgInB2B: 'div[class*=vtex-toast] .pr5',\n ModalConfirmation: 'div[class*=modal__confirm]',\n ModalClose: 'div[class*=modal__close]',\n DeleteCostCenter: 'div[class*=modal__confirm]',\n Remove: 'button[class*=danger]',\n CostCenterAddressEditOption: 'button[data-testid=\"menu-option-0\"]',\n CostCenterAddressDeleteOption: 'button[data-testid=\"menu-option-1\"]',\n CostCenterOption: '.vtex-card .relative button',\n // *************B2B Account: My Organization - Add Cost Center Constants end here************ //\n // *************B2B Account: My Organization - Add User Constants start here************ //\n AddUser: 'div[class*=layout__container] > div:nth-child(2) #toolbar button',\n UserName:\n 'div[class*=scroll] > div:nth-of-type(1) div[class*=input] input[type=text]',\n UserEmail:\n 'div[class*=scroll] > div:nth-of-type(2) div[class*=input] input[type=text]',\n UserCostCenter:\n 'div[class*=scroll] > div:nth-of-type(3) div[class*=dropdown] > select',\n UserRole:\n 'div[class*=scroll] > div:nth-of-type(4) div[class*=dropdown] > select',\n SubmitUser: '.nowrap > span:nth-child(2) button',\n RemoveUser: '.nowrap > span:nth-child(2) button',\n UpdateUser: '.nowrap > span:nth-child(3) button',\n // *************B2B Account: My Organization - Add User Constants start here************ //\n // *************B2B Account: My Organization - Edit User Constants start here************ //\n CostCenterDropDownInEdit:\n 'div[class*=scroll] > div:nth-of-type(2) div[class*=dropdown] > select',\n RoleDropDownInEdit:\n 'div[class*=scroll] > div:nth-of-type(3) div[class*=dropdown] > select',\n // *************B2B Account: My Organization - Edit User Constants end here************ //\n // *************B2B Account: My Organization Constants end here************ //\n // *************B2B Product Constants start here************ //\n B2BAddtoCart: 'span[class*=add-to-cart]',\n // *************B2B Product Constants end here************ //\n\n QuickOrder: 'a[href*=quick]',\n MiniCartQuantityForMaxOrder:\n 'div[class*=quantityInputContainer] input[id*=quantity-input]',\n MiniCartProductName: 'a[class*=productName]',\n QuickOrderPage: () => {\n return {\n popupMsgSelector: 'div[class*=toast-container] div[class*=copy]',\n popupMsg: 'Products successfuly added to the cart',\n skus: {\n textArea: 'label[class*=textarea] > textarea',\n validate: 'div[class*=validate i]:nth-of-type(1) > button',\n addtoCart: 'div[class*=buttonsBlock] > button:nth-child(2)',\n invalid: 'span[class*=danger]',\n content: 'div[class*=vtex-table] input[type=text]',\n tableContainer: '.vtex-table__container',\n button: 'div[class*=vtex-button]',\n remove: 'button[class*=remove]',\n title: '.vtex-rich-text-0-x-heading--quickTitle',\n },\n uploadXLS: {\n deleteFile: 'svg[class*=icon-delete]',\n file: 'input[type=file]',\n validate: 'div[class*=validate i] > button',\n },\n oneByOne: {\n search: 'input[placeholder*=product]',\n quantity: 'input[type=number]',\n add: 'div[class*=third] > div[class*=Add]',\n clear: '.vtex__icon-clear',\n },\n categories: {\n title: 'h3[class*=Quickorder]',\n product: 'Sporting',\n quantity: 'div[class*=category] input[type=number]',\n addtoCart: 'div[class*=categoryProduct] button',\n },\n }\n },\n generateAddtoCartB2BSelector: (href) => {\n return `a[href='${href}'] > article button`\n },\n QuoteName: 'input[data-test=string]',\n QuoteNotFound:\n '[data-testid=totalizer-item-subtotal] [data-testid=totalizer-value]',\n Notes: '.vtex-textarea > textarea',\n RequestQuote: /Request Quote/i,\n SaveQuote: /Save Quote/i,\n SaveForLater: /Save for Later/i,\n QuoteStatus: '[data-testid=totalizer-value] > .vtex-tag',\n CurrencyContainer: 'span[class*=currencyContainer]',\n QuoteStatusInMyQuotesPage:\n '.ReactVirtualized__Grid:nth-child(2) div[role=\"rowgroup\"] > div[class*=items] div[class*=tag]',\n QuoteFromMyQuotesPage: '.flex-column div[role=grid] div div[class*=br]',\n updateHistory: '.vtex-card > p',\n ToggleFields: '#toggleFieldsBtn',\n // *************B2B Constants My Quotes start here************ //\n MyQuotes: 'span[class*=orderQuote]',\n QuoteSearchQuery: 'input[type=search]',\n QuoteLink: 'a[href*=quote]',\n QuoteSearch: '#toolbar svg[class*=search]',\n QuotesToolBar: '#toolbar',\n QuotesFilterByStatus: '.ma2:nth-child(1) button',\n StatusLabel: 'label[class*=label]',\n QuotesFilterByMoreOptions: '.ma2:nth-child(2) button',\n // *************B2B Constants My Quotes - Filter start here************ //\n FilterLabel: 'div[class*=singleValue]',\n FilterInput: '.flex-auto div[class*=input-prefix__group] > input',\n Datas: '.ReactVirtualized__Grid:nth-of-type(2) div',\n ClearFilter: '.vtex__icon-clear',\n // *************B2B Constants My Quotes - Filter end here************ //\n // *************B2B Constants My Quotes section end here************ //\n // *************B2B Constants Quote Details section start here************ //\n PriceField: 'input[name=price]',\n QuoteOrginalTotal:\n 'div[data-testid=totalizer-item-original-subtotal] div[data-testid=totalizer-value]',\n QuoteTotal:\n 'div[data-testid=totalizer-item-quoted-subtotal] div[data-testid=totalizer-value]',\n Discount:\n 'div[data-testid*=percentage-discount] div[data-testid=totalizer-value]',\n SubTotalLabel: '.totalizers-list > tr > td.info',\n NewProductPrice: '.totalizers-list > tr > td.monetary',\n DiscountSliderContainer: '.vtex-slider__selector-container',\n SliderSelector: '.vtex-slider__selector',\n SliderToolTip: '.vtex-slider__selector-tooltip',\n SliderContainer: '.vtex-slider-container',\n QuantityField: 'input[name=quantity]',\n Decline: 'button[class*=danger]',\n SubmitToSalesRep: 'Submit',\n UseQuote: 'Use Quote',\n BackBtn: 'div[class*=pageHeader] span',\n UseQuoteButton: '.nowrap > span:nth-child(3) button',\n // *************B2B Constants Quote Details section end here************ //\n // *************B2B Constants Checkout section start here************ //\n PostalCodeText: 'div[class*=address-summary] .postalCode',\n ShippingAddressList: 'label.address-item',\n BackToAddressList: '#back-to-address-list',\n StreetInAddressList: 'span.street',\n PostalCodeInAddressList: 'span.postalCode',\n AccessDenied: 'div[class*=denied]',\n // *************B2B Constants Checkout section end here************ //\n QuantityInCart: 'div[class*=quantityInputContainer] input[id*=quantity]',\n ItemsPriceInCart: '#items-price',\n // *************B2B Constants end here************ //\n\n // *************** Location availability & Shopper location ********\n\n province: 'div[class*=dropdown__container] > select',\n addressInputContainer: 'div[class*=addressInputContainer] input',\n countryDropdown: 'div[class*=address-form] > select',\n AddressContainerForProduct: 'div[class*=location-availability]',\n ChangeLocationButton:\n 'section[class*=changeLocationGeoContainer] .vtex-button',\n addressContainer: 'div[class*=userAddressContainer]',\n switchButton: '.nt4 > .vtex-button > .vtex-button__label',\n AddressModelLayout: 'div[class*=vtex-modal-layout]',\n AddressErrorContainer: 'div[class*=changeLocationGeoErrorContainer]',\n ChangeLocationError: 'div[class*=input__error]',\n Address: 'div[class*=addressInputContainer] > label',\n verifyLocationInHome: 'div[class*=addressInfoAddressContainer]',\n AddToCart:\n 'button[type=button] > div[class*=vtex-button__label] >div[class*=buttonDataContainer] > span[class*=buttonText]',\n ProceedToCheckOut: '#proceed-to-checkout > .vtex-button__label',\n verifyLocationInCheckOut: '.srp-address-title',\n orderButton: 'a[id=cart-to-orderform]',\n SaveButtonInChangeLocationPopUp:\n 'section[class*=changeLocationSubmitContainer] > button[class*=pointer]',\n PaymentBtn: '#btn-go-to-payment',\n PickUpBtn: '.srp-toggle__pickup',\n SelectState: '.vtex-styleguide-9-x-container > .o-0',\n AvailabilityHeader: 'span[class*=availabilityHeaderLink]',\n NoAvailabilityHeader: 'div[class*=availabilityHeader]',\n city: 'div[class*=addressInputContainer] > label',\n shippingContent:\n 'div[class*=container] > p > span[class*=freeShipping] span[class*=freeShippingLabel]',\n locationUnavailable: 'div[class*=container] > p ',\n shippingUnavailabilityInformation:\n 'div[class*=shippingListContainer] > div[class*=shippingListEmptyMessage]',\n storeUnavailabilityInformation:\n 'div[class*=storeListContainer] > div[class*=storeListEmptyMessage]',\n shippingUnavailable: 'div[class*=container] > p',\n unavailableLocation:\n 'div[class*=shippingListContainer] > div[class*=shippingListEmptyMessage]',\n AddPickUpButton: '.w-70-ns > :nth-child(2) > .vtex-button__label',\n PickUpPointName: 'input[name=name]',\n PickUpPointId: 'input[name=id]',\n PickUpAddress: '.vtex-input .pac-target-input',\n CheckBox: 'input[value=\"monday-active\"]',\n WorkStartTime: 'input[name=\"openingTime\"]',\n WorkEndTime: 'input[name=\"closingTime\"]',\n SaveChanges: '.flex.justify-end > .pb7 > .vtex-button > .vtex-button__label',\n ChangesSaved: 'div[class*=vtex-toast] .pr5',\n VtexButton: '.vtex-button',\n UploadInput: 'input[type=file]',\n CloseIcon: '.vtex-modal__close-icon',\n VtexAlert: '.vtex-alert .ph5',\n AddressCity:\n 'div[class*=addressDistanceContainer] > span[class*=addressCity]',\n AddressZip:\n 'div[class*=addressDistanceContainer] > span[class*=addressCity] > span[class*=addressZip]',\n Distance: 'div[class*=addressDistanceContainer] > span[class*=distance]',\n shippingInfo: 'p[class*=firstShipping]',\n VerifyMaxItem: 'div[class*=storeList] > div[class*=pickupItem]',\n OrderByFaster:\n 'div[class*=storeList] > div[class*=pickupItem] > div[class*=pickupEstimate] > div[class*=estimateTranslated]',\n findMyLocation:\n 'div[class*=changeLocationFormContainer] > section[class*=changeLocationGeoContainer] > button[class*=vtex-button]',\n shippingErrorMessage:\n 'section[class*=changeLocationGeoContainer] > div[class*=changeLocationGeoErrorContainer]',\n closeButton: 'div[class*=closeButtonContainer] > button[class*=closeButton]',\n addressUpdation:\n 'div[class*=userAddressContainer] > section > div[class*=flex] > div[class*=flex-auto] > div[class*=items-center] > div[class*=addressInfoTextContainer] > div[class*=addressInfoAddressContainer]',\n InputText: \"input[type='text']\",\n ShopperLocationTextFields:\n 'div[class*=fields-container] div[class*=shopper-location] input[type=text]',\n ProvinceField:\n 'div[class*=fields-container] div[class*=shopper-location] select',\n // End here\n\n // Affirm payment selectors\n AffirmPaymentOption: 'a[data-name=\"Affirm\"]',\n AffirmPhoneNumberField: 'input[data-testid=\"phone-number-field\"]',\n AffirmSubmit: 'button[data-testid=\"submit-button\"]',\n AffirmPhonePin: 'input[data-testid=\"phone-pin-field\"]',\n AffirmInstallmentOption: 'span[data-test=\"installment-length\"]',\n AffirmIndicatorOption:\n 'label[for=\"autopay-toggle\"] div[data-testid=\"indicator\"]', // Auto payment & Privacy policy option selector\n AffirmDisClosureCheckbox: 'label[for=\"confirm-disclosure-checkbox\"]',\n AffirmAdminPublicKey: '#root_publicApiKey',\n AdminConfigurationIFrame: '[data-testid=admin-iframe-container]',\n AffirmSubmitConfiguration: 'button[type=\"submit\"]',\n AffirmPromoComponents: 'p[class*=affirm-components]',\n AffirmModal: 'a[class*=affirm-modal]',\n AffirmIFrame: 'iframe[class=affirm-sandbox-iframe]',\n AffirmClosePopup: 'button[id=close-button]',\n\n // Adyen selectors starts\n AdyenAdminIframe: 'iframe[data-testid=\"admin-iframe-container\"]',\n AdyenAdminSectionPB4: 'section[class=\"pb4\"]',\n AdyenAdminSectionPB6: 'section[class=\"pb6\"]',\n AdyenAdminUsePlatformToggle: 'section[class=\"pb4\"] span',\n AdyenPlatformApiKey: 'input[id=\"apiKey\"]',\n AdyenPlatformProductionURI: 'input[id=\"liveEndpoint\"]',\n AdyenLoginUsername: 'input[name=\"userName\"]',\n AdyenLoginPassword: 'input[type=\"password\"]',\n AdyenLoginAccount: 'input[name=\"account\"]',\n AdyenLoginSubmit: 'button[type=\"submit\"]',\n // End here\n\n // Fedex-Shipping selectors\n SmartPackingAccessKey: '#accessKey', // Fedex Smart Packing Access key field\n PickingOptimizeAlert: 'div[role=\"alert\"] p', // Fedex alert\n PackingBoxLength: '#length', // Packing optimization Box Length\n PackingBoxHeight: '#height', // Packing optimization Box Height\n PackingBoxWidth: '#width', // Packing optimization Box Width\n PackingBoxTable: 'table[class*=packing-optimization] > tbody > tr', // Packing optimization Box Table\n // End here\n}\n\n```"
}
] |
code_cy-runner_997d3fbd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/common/env_orders.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\n// Files to save state\n// MUST exist on the plase EMPTY\nconst ordersJson = '.orders.json'\n\n// Save orders\nCypress.Commands.add('setOrderItem', (orderItem, orderValue) => {\n cy.readFile(ordersJson).then((items) => {\n items[orderItem] = orderValue\n cy.writeFile(ordersJson, items)\n })\n})\n\n// Get orders\nCypress.Commands.add('getOrderItems', () => {\n cy.readFile(ordersJson).then((items) => {\n return items\n })\n})\n\n```"
}
] |
code_cy-runner_0060890f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/common/api_commands.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { searchInMasterData, deleteDocumentInMasterData } from './wipe.js'\nimport {\n VTEX_AUTH_HEADER,\n FAIL_ON_STATUS_CODE,\n FAIL_ON_STATUS_CODE_STRING,\n} from './constants.js'\nimport { invoiceAPI, cancelOrderAPI } from './apis.js'\n\nCypress.Commands.add('searchInMasterData', searchInMasterData)\nCypress.Commands.add('deleteDocumentInMasterData', deleteDocumentInMasterData)\n\n// Send Invoice API Test Case\nCypress.Commands.add('sendInvoiceAPI', (body, orderId) => {\n cy.getVtexItems().then((vtex) => {\n const url = `${invoiceAPI(vtex.baseUrl)}/${orderId}/invoice`\n\n cy.callRestAPIAndAddLogs({\n url,\n body,\n })\n })\n})\n\nCypress.Commands.add('cancelOrder', (orderId) => {\n cy.getVtexItems().then((vtex) => {\n cy.getOrderItems().then((item) => {\n const url = cancelOrderAPI(vtex.baseUrl, item[orderId])\n\n cy.callRestAPIAndAddLogs({\n url,\n }).then((response) => {\n expect(response.status).to.equal(200)\n })\n })\n })\n})\n\n// Get API Test Case\nCypress.Commands.add('getAPI', (url, headers, auth = null) => {\n cy.qe(`cy.request({\n method: 'GET',\n url: ${url},\n ${FAIL_ON_STATUS_CODE_STRING} \n })`)\n cy.request({\n method: 'GET',\n url,\n auth,\n headers,\n ...FAIL_ON_STATUS_CODE,\n })\n})\n\n// Order Tax API Test Case\nCypress.Commands.add('orderTaxApi', (requestPayload, tax) => {\n cy.getVtexItems().then((vtex) => {\n cy.callRestAPIAndAddLogs({\n url: `${vtex.baseUrl}/${\n Cypress.env('workspace').prefix\n }/checkout/order-tax`,\n headers: {\n Authorization: vtex.authorizationHeader,\n ...VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken),\n },\n body: requestPayload,\n }).then((response) => {\n expect(response.status).to.equal(200)\n\n const reqIds = requestPayload.items.map(({ id }) => id)\n const respIds = response.body.itemTaxResponse.map(({ id }) => id)\n\n expect(reqIds.sort()).to.deep.equal(respIds.sort())\n let taxFromAPI = 0\n\n response.body.itemTaxResponse.forEach((item) => {\n item.taxes.map((obj) => (taxFromAPI += obj.value))\n })\n expect(taxFromAPI.toFixed(2)).to.equal(tax.replace('$ ', ''))\n })\n })\n})\n\n```"
}
] |
code_cy-runner_0b61c1fb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/common/transactions_constants.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nexport const transactionConstants = {\n COMPLETED: 'COMPLETED',\n SHIPPING: 'SHIPPING',\n NAME: 'Syed Mujeeb',\n ONLINE: 'online',\n CANCELLED: 'Cancelled',\n\n // Transaction endpoint constants ends here\n SETTLING: 'Settling',\n INTENT: 'CAPTURE',\n // Transaction endpoint constants ends here\n\n // Transaction/interaction endpoint constants starts here\n PaymentAuthorizationWorker: 'PaymentAuthorizationWorker',\n PaymentGateway: 'PaymentGateway',\n // statuses\n TransactionFinished: {\n Status: 'Transaction Finished',\n Message: 'Transaction settlement finished',\n },\n TransactionCancelled: {\n Status: 'Transaction Cancelled',\n Message: 'Transaction cancelation has finished',\n },\n TransactionSettling: {\n Status: 'Transaction Settling',\n Message: 'Transaction settlement finished',\n },\n PaymentFinished: {\n Status: 'Payment Finished',\n Message: 'Payment settlement finished',\n },\n\n // Transaction/interaction endpoint constants ends here\n\n // Transaction/payment endpoint starts here\n FINISHED: 'Finished',\n APPROVED: 'Approved',\n PayPalCP: 'PayPalCP',\n IMMEDIATECAPTURE: 'IMMEDIATECAPTURE',\n // Transaction/payment endpoint ends here\n\n // Transaction/settlement endpoint starts here\n AutoSettlement: 'auto-settlement',\n UpOnRquest: 'upon-request',\n // Transaction/settlement endpoint ends here\n\n // Transaction/refund endpoint starts here\n REFUNDED: 'REFUNDED',\n INVOICED: 'invoiced',\n RefundConnectorResponse: 'refundingConnectorResponse',\n // Transaction/refund endpoint ends here\n}\n\n```"
}
] |
code_cy-runner_5e43ddb4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/common/testcase.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { VTEX_AUTH_HEADER, ENTITIES } from './constants.js'\nimport { updateRetry } from './support.js'\nimport {\n cancelOrderAPI,\n affiliationAPI,\n invoiceAPI,\n transactionAPI,\n startHandlingAPI,\n getOrderAPI,\n} from './apis.js'\nimport { isValidDate } from './utils.js'\nimport getConfiguration from './checkout_ui_custom.js'\n\nconst config = Cypress.env()\nconst WIPE_ENV = 'wipe'\n\nconst { vtex } = config.base\n\n// Constants\nconst {\n account,\n apiKey,\n apiToken,\n authorizationHeader,\n baseUrl,\n appKey,\n appToken,\n affiliationId,\n robotMail,\n urlExternalSeller,\n} = vtex\n\nconst { prefix } = config.workspace\nconst WORKSPACE = config.workspace.name\n\nexport const ORDER_FORM_CONFIG = `https://${account}.vtexcommercestable.com.br/api/checkout/pvt/configuration/orderForm`\n\nexport function configureTargetWorkspace(app, version, workspace = 'master') {\n it(\n `Configuring target workspace as ${workspace} in ${app}`,\n updateRetry(2),\n () => {\n cy.getOrderItems().then((order) => {\n if (order[WIPE_ENV]) {\n // Define constants\n const APP_NAME = 'vtex.apps-graphql'\n const APP_VERSION = '3.x'\n const APP = `${APP_NAME}@${APP_VERSION}`\n const CUSTOM_URL = `https://${account}.myvtex.com/_v/private/admin-graphql-ide/v0/${APP}`\n\n const GRAPHQL_MUTATION =\n 'mutation' +\n '($app:String,$version:String,$settings:String)' +\n '{saveAppSettings(app:$app,version:$version,settings:$settings){message}}'\n\n const QUERY_VARIABLES = {\n app,\n version,\n settings: `{\"targetWorkspace\":\"${workspace}\"}`,\n }\n\n // Mutating it to the new workspace\n cy.callGraphqlAndAddLogs({\n url: CUSTOM_URL,\n query: GRAPHQL_MUTATION,\n variables: QUERY_VARIABLES,\n })\n .its('body.data.saveAppSettings.message', { timeout: 10000 })\n .should('contain', workspace)\n } else {\n cy.log('Tax configuration is configured with another workspace')\n }\n })\n }\n )\n}\n\nfunction callOrderFormConfiguration() {\n cy.getAPI(ORDER_FORM_CONFIG, VTEX_AUTH_HEADER(apiKey, apiToken))\n .as('ORDERFORM')\n .its('status')\n .should('equal', 200)\n\n return cy.get('@ORDERFORM')\n}\n\nfunction makeDecision(workspace) {\n if (!workspace) {\n // If workspace is null then we are on wipe step\n callOrderFormConfiguration().then(({ body }) => {\n // if we have workspace name in taxConfiguration then return true else null\n cy.setOrderItem(\n WIPE_ENV,\n body.taxConfiguration\n ? body.taxConfiguration.url.includes(WORKSPACE)\n : null\n )\n })\n } else {\n // if workspace is not null then we are on postSetup step\n cy.log('Setting workspace in taxConfiguration')\n cy.setOrderItem(WIPE_ENV, true)\n }\n}\n\nexport function configureTaxConfigurationInOrderForm(workspace = null) {\n it(`Configuring tax configuration in Order Form Configuration API`, () => {\n makeDecision(workspace)\n cy.getOrderItems().then((order) => {\n if (order[WIPE_ENV]) {\n callOrderFormConfiguration().then((response) => {\n response.body.taxConfiguration = workspace\n ? {\n url: `https://${workspace}--${account}.myvtex.com/${prefix}/checkout/order-tax`,\n authorizationHeader,\n allowExecutionAfterErrors: false,\n integratedAuthentication: false,\n appId: new Date(),\n }\n : {}\n cy.callRestAPIAndAddLogs({\n url: ORDER_FORM_CONFIG,\n body: response.body,\n })\n .its('status')\n .should('equal', 204)\n })\n } else {\n cy.setOrderItem(WIPE_ENV, false)\n cy.log('Tax configuration is configured with another workspace')\n }\n })\n })\n}\n\nexport function cancelTheOrder(orderEnv) {\n it(`Cancel the Order`, () => {\n cy.getOrderItems().then((order) => {\n cy.callRestAPIAndAddLogs({\n url: cancelOrderAPI(baseUrl, order[orderEnv]),\n body: {\n reason: 'Customer bought it by mistake',\n },\n })\n .its('status')\n .should('equal', 200)\n })\n })\n}\n\nexport function startE2E(app, workspace) {\n // This startE2E() is for tax App\n // eg: Avalara, Cybersource, Digital River\n it(`Start ${app} E2E tests with this ${workspace}`, () => {\n callOrderFormConfiguration().then((response) => {\n const { taxConfiguration } = response.body\n\n if (!taxConfiguration) {\n expect(response.body.taxConfiguration).to.be.null\n } else {\n const { appId, url } = response.body.taxConfiguration\n const validDate = isValidDate(new Date(appId))\n\n if (validDate) {\n const minutes = Math.abs(\n // 1 minute = 60000 milliseconds\n parseInt((new Date() - new Date(appId)) / 60000, 10)\n )\n\n // if the workspace was blocked longer than 30 minutes then\n // skip validation & force update taxConfiguration\n\n if (minutes >= 30) {\n const [WORKSPACE_IN_TAX_CONFIG] = url.split('//')[1].split('--')\n\n cy.log(\n `TaxConfiguration is used by this workspace ${WORKSPACE_IN_TAX_CONFIG} for more than or equal to 30 minutes i.e for ${minutes} minutes`\n )\n } else {\n expect(url).to.include(workspace)\n }\n } else {\n cy.log('appId is having invalid Date!')\n }\n }\n })\n })\n}\n\nfunction verifyEnvs(paymentEnvs = false) {\n if (apiKey && apiToken) {\n if (paymentEnvs) {\n if (appKey && appToken && affiliationId) {\n cy.log('All envs are available in VTEX_QE.json')\n } else {\n cy.log('Some envs are missing in VTEX_QE.json')\n }\n }\n } else {\n cy.log('Some envs are missing in VTEX_QE.json')\n }\n}\n\nexport function startPaymentE2ETests() {\n // If you are using this function in your testcase\n // then ensure, you are having affiliationId, apiKey and apiToken in .VTEX_QE.json\n it(`Start ${prefix} E2E tests with this workspace ${WORKSPACE}`, () => {\n verifyEnvs(true)\n })\n}\n\nexport const AUTO_SETTLEMENT_OPTIONS = {\n enable: 'after_antifraud',\n disable: 'disabled',\n afterAuthorization: 'after_authorization',\n}\n\nexport function setWorkspaceAndGatewayAffiliations({\n autoSellement = true,\n afterAuthorization = false,\n wipe = false,\n} = {}) {\n // If you are using this function in your testcase\n // then ensure, you are having affiliationId, apiKey,apiToken,appKey and appToken in .VTEX_QE.json\n\n let autoSellementValue = autoSellement\n ? AUTO_SETTLEMENT_OPTIONS.enable\n : AUTO_SETTLEMENT_OPTIONS.disable\n\n if (afterAuthorization) {\n autoSellementValue = AUTO_SETTLEMENT_OPTIONS.afterAuthorization\n }\n\n const workspace = wipe ? '' : WORKSPACE\n\n it(\n `In ${prefix} - Setting workspace value as \"${workspace}\" with payment capture ${autoSellementValue}`,\n updateRetry(3),\n () => {\n cy.getAPI(\n affiliationAPI(affiliationId),\n VTEX_AUTH_HEADER(apiKey, apiToken)\n ).then((response) => {\n const { configuration } = response.body\n const workspaceIndex = configuration.findIndex(\n (obj) => obj.name === 'workspace'\n )\n\n const autoSettleIndex = configuration.findIndex(\n (obj) => obj.name === 'autoSettle'\n )\n\n const appKeyIndex = configuration.findIndex(\n (obj) => obj.name === 'appKey'\n )\n\n const appTokenIndex = configuration.findIndex(\n (obj) => obj.name === 'appToken'\n )\n\n response.body.configuration[workspaceIndex].value = workspace\n response.body.configuration[autoSettleIndex].value = autoSellementValue\n cy.qe(`Set workspace as ${workspace}`)\n cy.qe(`Set autoSettle as ${autoSellementValue}`)\n response.body.configuration[appKeyIndex].value = appKey || ''\n response.body.configuration[appTokenIndex].value = appToken || ''\n cy.localqe(`Set appKey as ${appKey}`)\n cy.localqe(`Set appToken as ${appToken}`)\n cy.qe('Now update affiliation using PUT method')\n cy.qe('Verify the response status to equal 201')\n cy.callRestAPIAndAddLogs({\n method: 'PUT',\n url: affiliationAPI(affiliationId),\n body: response.body,\n })\n .its('status')\n .should('equal', 201)\n })\n }\n )\n}\n\nexport function syncCheckoutUICustom() {\n // eslint-disable-next-line jest/expect-expect\n it(\n `In ${prefix} - Sync Checkout UI Custom via API`,\n { retries: 9, responseTimeout: 5000, requestTimeout: 5000 },\n () => {\n // Define constants\n const APP_NAME = 'vtex.checkout-ui-custom'\n const APP_VERSION = '*.x'\n const APP = `${APP_NAME}@${APP_VERSION}`\n const CUSTOM_URL = `https://${vtex.account}.myvtex.com/_v/private/admin-graphql-ide/v0/${APP}`\n\n cy.qe(\n 'Save a new workspace via graphQl(As it gets delay response in checkout UI ,we save it through graphql).The graphQl mutation we use in UI,mutation{($email: String, $workspace: String, $layout: CustomFields, $javascript: String, $css: String, $javascriptActive: Boolean, $cssActive: Boolean, $colors: CustomFields) {saveChanges (email: $email, workspace: $workspace, layout: $layout, javascript: $javascript, css: $css, javascriptActive: $javascriptActive, cssActive: $cssActive, colors: $colors))}}'\n )\n const GRAPHQL_MUTATION =\n 'mutation' +\n '($email: String, $workspace: String, $layout: CustomFields, $javascript: String, $css: String, $javascriptActive: Boolean, $cssActive: Boolean, $colors: CustomFields)' +\n '{saveChanges (email: $email, workspace: $workspace, layout: $layout, javascript: $javascript, css: $css, javascriptActive: $javascriptActive, cssActive: $cssActive, colors: $colors) @context(provider: \"vtex.checkout-ui-custom\")}'\n\n cy.callGraphqlAndAddLogs({\n url: CUSTOM_URL,\n query: GRAPHQL_MUTATION,\n variables: getConfiguration(WORKSPACE),\n }).then(({ body }) => {\n expect(body).to.not.have.own.property('errors')\n expect(body.data.saveChanges).to.include('DocumentId')\n })\n }\n )\n}\n\nexport function deleteAddresses() {\n it('Getting user & then deleting addresses associated with that user', () => {\n cy.qe('Getting user & then deleting addresses associated with that user')\n cy.qe(`\n curl --location --request GET '${baseUrl}/entities/CL/search?email=${robotMail}' \\\n--header 'X-VTEX-API-AppKey: AppKey' \\\n--header 'X-VTEX-API-AppToken: AppToken' \\\n `)\n cy.searchInMasterData(ENTITIES.CLIENTS, robotMail).then((clients) => {\n cy.searchInMasterData(ENTITIES.ADDRESSES, clients[0].id).then(\n (addresses) => {\n for (const { id } of addresses) {\n cy.deleteDocumentInMasterData(ENTITIES.ADDRESSES, id)\n }\n }\n )\n })\n })\n}\n\n/*\nBelow fn operates with getTestVariables\n*/\n\nexport function getTestVariables(testCasePrefix) {\n return {\n orderIdEnv: testCasePrefix,\n transactionIdEnv: `${testCasePrefix}-transactionIdEnv`,\n paymentTidEnv: `${testCasePrefix}-paymentTidEnv`,\n productTotalEnv: `${testCasePrefix}-productTotalEnv`,\n }\n}\n\nexport function sendInvoiceTestCase({\n product,\n orderIdEnv,\n externalSellerTestcase = false,\n}) {\n let total\n\n it(`In ${product.prefix} - Send Invoice`, () => {\n cy.getOrderItems().then((item) => {\n if (externalSellerTestcase) {\n if (product.directSaleEnv === orderIdEnv) {\n total = product.directSaleAmount\n } else {\n total = product.externalSellerAmount\n }\n }\n // If this is not externalSellerTestCase then it is for refund test case\n else {\n total =\n product.totalWithoutTax || product.total || product.totalProductPrice\n }\n\n cy.sendInvoiceAPI(\n {\n invoiceNumber: '54321',\n invoiceValue: total\n .replace('$ ', '')\n .replace(/\\./, '')\n .replace(/,/, ''),\n invoiceUrl: null,\n issuanceDate: new Date(),\n invoiceKey: null,\n },\n item[orderIdEnv],\n orderIdEnv === product.externalSaleEnv\n ).then((response) => {\n cy.qe('Verify response status to be 200')\n expect(response.status).to.equal(200)\n })\n })\n })\n}\n\nfunction generateInvoiceAPIURL(product, item, env) {\n return env === product.externalSaleEnv\n ? `${invoiceAPI(urlExternalSeller)}/QSS-${item[env]}`\n : `${invoiceAPI(baseUrl)}/${item[env]}`\n}\n\nexport function invoiceAPITestCase({\n product,\n env,\n transactionIdEnv = false,\n pickup = false,\n}) {\n it(\n `In ${product.prefix} -Invoice API should have expected information`,\n updateRetry(2),\n () => {\n cy.getOrderItems().then((item) => {\n cy.getAPI(\n generateInvoiceAPIURL(product, item, env),\n VTEX_AUTH_HEADER(apiKey, apiToken)\n ).then((response) => {\n cy.qe('Verify response status to equal 200')\n expect(response.status).to.equal(200)\n expect(response)\n .to.have.property('body')\n .to.have.property('shippingData')\n .to.have.property('address')\n .to.have.property('postalCode')\n const postalCode = pickup\n ? product.pickUpPostalCode\n : product.postalCode\n\n cy.qe(\n `Verify response should have postalCode ${postalCode} in response.body.shippingData.address.postalCode`\n )\n\n expect(response.body.shippingData.address.postalCode).to.equal(\n postalCode\n )\n // Setting Transaction Id in .orders.json\n if (transactionIdEnv) {\n expect(response.body)\n .to.have.property('paymentData')\n .to.have.property('transactions')\n\n cy.qe(\n `Set transactionId - ${transactionIdEnv}:${response.body.paymentData.transactions[0].transactionId} in orders.json`\n )\n\n cy.setOrderItem(\n transactionIdEnv,\n response.body.paymentData.transactions[0].transactionId\n )\n }\n })\n })\n }\n )\n}\n\nfunction checkTransactionIdIsAvailable(transactionIdEnv) {\n if (!transactionIdEnv) {\n throw new Error('Transaction Id is undefined')\n }\n}\n\nexport function verifyTransactionPaymentsAPITestCase(\n product,\n { transactionIdEnv, paymentTidEnv },\n fn = null\n) {\n it(\n `In ${product.prefix} - Verify Transaction Payment`,\n updateRetry(2),\n () => {\n cy.addDelayBetweenRetries(2000)\n cy.getOrderItems().then((order) => {\n checkTransactionIdIsAvailable(order[transactionIdEnv])\n cy.getAPI(\n `${transactionAPI(vtex.baseUrl)}/${order[transactionIdEnv]}/payments`,\n VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken)\n ).then((response) => {\n cy.qe('Verify response status to equal 200')\n expect(response.status).to.equal(200)\n expect(response.body[0].tid).to.not.equal(undefined)\n // Store payment tid in .orders.json\n cy.qe(`Set paymentTid - ${response.body[0].tid} in orders.json `)\n cy.setOrderItem(paymentTidEnv, response.body[0].tid)\n fn && fn(response)\n })\n })\n }\n )\n}\n\nexport function startHandlingOrder(product, env) {\n it(`In ${product.prefix} - Start handling order`, updateRetry(3), () => {\n cy.addDelayBetweenRetries(5000)\n cy.getOrderItems().then((item) => {\n cy.callRestAPIAndAddLogs({\n url: startHandlingAPI(baseUrl, item[env]),\n }).then((response) => {\n cy.qe(`Verify response status should be 200 or 409`)\n expect(response.status).to.match(/204|409/)\n })\n })\n })\n}\n\nexport function verifyOrderStatus({ product, env, status, timeout = 10000 }) {\n it(\n `In ${product.prefix} - Verify order status is ${status}`,\n updateRetry(5),\n () => {\n cy.addDelayBetweenRetries(timeout)\n cy.getOrderItems().then((order) => {\n cy.getAPI(\n getOrderAPI(vtex.baseUrl, order[env]),\n VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken)\n ).then((response) => {\n cy.qe(\n `Verify response status should be 200 and body status should be ${status}`\n )\n expect(response.status).to.equal(200)\n expect(response.body.status).to.match(status)\n })\n })\n }\n )\n}\n\nexport function checkoutProduct(product) {\n const {\n prefix: testPrefix,\n productName,\n postalCode,\n productQuantity,\n } = product\n\n it(`In ${testPrefix} - Adding Product to Cart`, updateRetry(1), () => {\n // Search the product\n cy.searchProduct(productName)\n // Add product to cart\n cy.addProduct(productName, { proceedtoCheckout: true })\n })\n\n it(\n `In ${testPrefix} - Updating product quantity to ${productQuantity}`,\n updateRetry(4),\n () => {\n // Update Product quantity to 1\n cy.updateProductQuantity(productName, {\n quantity: productQuantity,\n verifySubTotal: false,\n })\n }\n )\n\n it(`In ${testPrefix} - Updating Shipping Information`, updateRetry(4), () => {\n // Update Shipping Section\n cy.updateShippingInformation({ postalCode })\n })\n}\n\n```"
}
] |
code_cy-runner_1f2fea92
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of cy-runner/cypress-shared/support/common/support.js from the cy-runner VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport selectors from './selectors.js'\nimport { addressList, AUTH_COOKIE_NAME_ENV } from './constants.js'\nimport { AdminLogin } from './apis.js'\nimport {\n generateAddtoCartSelector,\n generateAddtoCartCardSelector,\n getLogFile,\n} from './utils.js'\n\nexport function scroll() {\n // So, scroll first then look for selectors\n cy.scrollTo(0, 1000)\n // eslint-disable-next-line cypress/no-unnecessary-waiting\n cy.wait(1000)\n cy.scrollTo(0, -100)\n}\n\nfunction setAuthCookie(authResponse) {\n expect(authResponse.body).to.have.property('authCookie')\n // Set AUTH_COOKIE\n Cypress.env(AUTH_COOKIE_NAME_ENV, authResponse.body.authCookie.Name)\n cy.setCookie(\n authResponse.body.authCookie.Name,\n authResponse.body.authCookie.Value,\n { log: false }\n )\n}\n\n// Set Product Quantity\nfunction setProductQuantity({ position, quantity, timeout }, subTotal, check) {\n cy.intercept('**/update').as('update')\n cy.qe('Intercept update API')\n cy.qe(`Focus product quantity input field and update quantity as ${quantity}`)\n cy.get(selectors.ProductQuantityInCheckout(position), { timeout: 15000 })\n .should('be.visible')\n .should('not.be.disabled')\n .focus()\n .type(`{backspace}${quantity}{enter}`)\n cy.get(selectors.ItemRemove(position), { timeout: 15000 }).should(\n 'not.have.css',\n 'display',\n 'none'\n )\n\n cy.wait('@update', { timeout })\n cy.qe('Wait for update API to get called')\n\n if (check) {\n cy.qe('verify the subTotal in the right side of the cart items')\n cy.qe(`SubTotal should be ${subTotal}`)\n cy.get(selectors.SubTotal, { timeout }).should('have.text', subTotal)\n }\n}\n\nfunction clickProceedtoCheckout() {\n // Click Proceed to Checkout button\n cy.get(selectors.ProceedtoCheckout).should('be.visible').click()\n cy.get(selectors.CartTimeline, { timeout: 30000 })\n .should('be.visible')\n .click({ force: true })\n}\n\n// Add product to cart\nexport function addProduct(\n searchKey,\n { proceedtoCheckout = true, paypal = false, productDetailPage = false } = {}\n) {\n // Add product to cart\n cy.qe(`\n Verfiying the search result is visible and having the text ${searchKey} in lowercase\n Verifying the ProfileLabel should be visible and contain the text Hello\n Verifying the BrandFilter should not be disabled\n Adding product - ${searchKey} to cart\n Verify the shipping and taxes in the mini cart\n click on proceed to checkout\n `)\n cy.get(selectors.searchResult).should('have.text', searchKey.toLowerCase())\n cy.get(selectors.ProductAnchorElement)\n .should('have.attr', 'href')\n .then((href) => {\n cy.get(selectors.ProfileLabel)\n .should('be.visible')\n .should('have.contain', `Hello,`)\n cy.get(selectors.BrandFilter).should('not.be.disabled')\n if (productDetailPage) {\n cy.get(generateAddtoCartCardSelector(href)).first().click()\n cy.get('[name=postalCode]').clear().type('33180').type('{enter}')\n cy.get(selectors.ProductsQAShipping).click()\n // Make sure proceed to payment is visible\n cy.get(selectors.AddtoCart).should('be.visible').click()\n } else {\n cy.get(generateAddtoCartSelector(href)).first().click()\n // Make sure proceed to payment is visible\n cy.get(selectors.ProceedtoCheckout).should('be.visible')\n }\n\n // Make sure shipping and taxes is visible\n cy.get(selectors.SummaryText).should('have.contain', 'Shipping and taxes')\n // Make sure remove button is visible\n cy.get(selectors.RemoveProduct).should('be.visible')\n cy.get('#items-price div[class*=price]').should('have.contain', '$')\n if (paypal) {\n // cy.get(selectors.ProceedtoCheckout).should('be.visible').click()\n // cy.get(selectors.ItemQuantity).should('be.visible')\n if (proceedtoCheckout) {\n clickProceedtoCheckout()\n }\n } else if (proceedtoCheckout) {\n clickProceedtoCheckout()\n } else {\n cy.closeCart()\n }\n })\n}\n\n// Buy Product\nexport function buyProduct() {\n // Click Buy Product\n cy.get(selectors.BuyNowBtn).last().click()\n}\n\n// Close Cart\nexport function closeCart() {\n cy.get(selectors.CloseCart).click()\n}\n\nexport function fillAddress(postalCode, timeout = 5000) {\n cy.get(selectors.CartTimeline).should('be.visible').click()\n const { fullAddress, country } = addressList[postalCode]\n\n cy.get('body').then(($body) => {\n if ($body.find(selectors.ShippingPreview).length) {\n // shipping preview should be visible\n cy.get(selectors.ShippingPreview).should('be.visible')\n if ($body.find(selectors.DeliveryAddress).length) {\n cy.get(selectors.DeliveryAddress).should('be.visible').click()\n } else if ($body.find(selectors.ShippingCalculateLink).length) {\n cy.get(selectors.ShippingCalculateLink).should('be.visible').click()\n }\n }\n\n cy.get(selectors.ShipCountry, { timeout })\n .should('not.be.disabled')\n .select('USA')\n .select(country)\n\n cy.get('body').then(($shippingBody) => {\n if ($shippingBody.find(selectors.ShipAddressQuery).length) {\n // Type shipping address query\n // Google autocompletion takes some seconds to show dropdown\n // So, we use 500 seconds wait before and after typing of address\n cy.get(selectors.ShipAddressQuery)\n .should('not.be.disabled')\n .focus()\n .clear()\n\n cy.get(selectors.ShipAddressQuery) // eslint-disable-line cypress/no-unnecessary-waiting\n .click()\n .type(` ${fullAddress}`, { delay: 150 })\n .wait(1000)\n .type('{downarrow}{enter}')\n } else {\n cy.get(selectors.PostalCodeInput, { timeout: 10000 })\n .should('be.visible')\n .clear()\n .type(postalCode)\n }\n })\n })\n}\n\nfunction fillAddressLine1(deliveryScreenAddress) {\n cy.get('body').then(($shippingBlock) => {\n if ($shippingBlock.find(selectors.ShipStreet).length) {\n cy.get(selectors.ShipStreet).clear().type(deliveryScreenAddress)\n cy.get(selectors.GotoPaymentBtn).should('be.visible').click()\n }\n })\n}\n\nconst PHONE_NUMBER = '(304) 123 4556'\n\nexport function fillContactInfo(\n shippingStrategySelector,\n phoneNumber,\n checkoutcustom\n) {\n cy.qe('Found customer with no order history')\n phoneNumber = phoneNumber || PHONE_NUMBER\n cy.get(selectors.QuantityBadge).should('be.visible')\n cy.get(selectors.SummaryCart).should('be.visible')\n cy.qe('Verify quantityBadge and summarycart should be visible')\n // Delay in ms\n const firstName = 'Syed'\n const lastName = 'Mujeeb'\n\n cy.qe(`Type firstName ${firstName}`)\n cy.qe(`Type lastName ${lastName}`)\n cy.qe(`Type phone ${phoneNumber}`)\n\n cy.get(selectors.FirstName).clear().type(firstName, {\n delay: 50,\n })\n cy.get(selectors.LastName).clear().type(lastName, {\n delay: 50,\n })\n cy.get(selectors.Phone).clear().type(phoneNumber, {\n delay: 50,\n })\n\n if (checkoutcustom) {\n // eslint-disable-next-line cypress/no-unnecessary-waiting\n cy.wait(5000)\n }\n\n cy.qe(\n 'Click proceedtoShipping button and verify that button gets hidden from ui'\n )\n cy.get(selectors.ProceedtoShipping).should('be.visible').click()\n cy.get(selectors.ProceedtoShipping, { timeout: 1000 }).should(\n 'not.be.visible'\n )\n\n if (checkoutcustom) {\n cy.qe('Wait for 5s')\n // eslint-disable-next-line cypress/no-unnecessary-waiting\n cy.wait(5000)\n }\n\n // This block is getting visible only for checkout ui custom E2E tests\n // Screenshot: https://vtex-dev.atlassian.net/browse/ENGINEERS-549?focusedCommentId=69893\n // So, for now this block will work only for checkout ui custom\n if (checkoutcustom) {\n cy.get('body').then(($shippingBlockForCheckoutCustom) => {\n if (\n $shippingBlockForCheckoutCustom.find(selectors.ContinueShipping).length\n ) {\n const streetAddress = '19501 Biscayne Blvd'\n const postalCode = '33301'\n const city = 'Aventura'\n const state = 'CA'\n\n cy.qe(`Type Street address - ${streetAddress}`)\n cy.get(selectors.StreetAddress).clear().type(streetAddress)\n cy.qe(`Type postalCode - ${postalCode}`)\n cy.get(selectors.PostalCodeInput).clear().type(postalCode)\n cy.qe(`Type shipCity - ${city}`)\n cy.get(selectors.ShipCity).clear().type(city)\n cy.qe(`Select shipState - ${state}`)\n cy.get(selectors.ShipState, { timeout: 5000 })\n .should('not.be.disabled')\n .select(state)\n }\n })\n }\n\n cy.get('body').then(($shippingBlock) => {\n if ($shippingBlock.find(selectors.ContinueShipping).length) {\n cy.qe('Click continue shipping btn')\n cy.get(selectors.ContinueShipping, { timeout: 15000 })\n .should('be.visible')\n .click({ force: true })\n }\n\n if ($shippingBlock.find(selectors.ReceiverName).length) {\n cy.qe('Type ReceiverName - Syed')\n cy.get(selectors.ReceiverName, { timeout: 5000 })\n .should('be.visible')\n .type('Syed', {\n delay: 50,\n })\n shippingStrategySelector &&\n cy.get(shippingStrategySelector).should('be.visible').click()\n cy.qe('Click GotoPaymentBtn')\n cy.get(selectors.GotoPaymentBtn).should('be.visible').click()\n } else {\n cy.log('Shipping block is not shown! May be ReceiverName already filled')\n }\n })\n}\n\nexport function updateShippingInformation({\n postalCode,\n pickup = false,\n invalid = false,\n timeout = 5000,\n shippingStrategySelector = null,\n phoneNumber = PHONE_NUMBER,\n checkoutcustom = false,\n}) {\n cy.qe(\n `Click on proceed to payment button\n Fill the contact information by filling the firstname,lastName and phone number\n Adding intercept for shipping data\n Select the country and fill the address in the shipping address\n Click on DeliveryAddressText and wait for shippingdata intercept be completed\n Select pickup in store option in shipping preview container\n Click on ProceedtoPaymentBtn\n `\n )\n const { deliveryScreenAddress } = addressList[postalCode]\n\n cy.addDelayBetweenRetries(3000)\n if (cy.state('runnable')._currentRetry > 2) cy.reload()\n cy.setorderFormDebugItem()\n cy.get(selectors.CartTimeline).should('be.visible').click({ force: true })\n cy.get(selectors.ProceedtoPaymentBtn).should('be.visible').click()\n cy.get(selectors.FirstName).then(($el) => {\n if (Cypress.dom.isVisible($el)) {\n fillContactInfo(shippingStrategySelector, phoneNumber, checkoutcustom)\n }\n })\n\n cy.intercept('**/shippingData').as('shippingData')\n cy.fillAddress(postalCode, timeout).then(() => {\n if (invalid) {\n cy.get(selectors.DeliveryUnavailable, { timeout }).contains(\n 'cannot be shipped to the given address.'\n )\n cy.get(selectors.DeliveryAddressText, { timeout }).click()\n } else if (pickup) {\n cy.wait('@shippingData')\n cy.get(selectors.PickupInStore, { timeout }).should('be.visible').click()\n cy.get(selectors.PickupItems, { timeout })\n .should('be.visible')\n .contains('Pickup')\n cy.get(selectors.ProceedtoPaymentBtn).should('be.visible').click()\n } else {\n cy.get(selectors.DeliveryAddressText, { timeout: 15000 })\n .invoke('text')\n .should(\n 'match',\n new RegExp(`^${deliveryScreenAddress}|^${postalCode}$`, 'gi')\n )\n cy.get(selectors.ProceedtoPaymentBtn).should('be.visible').click()\n }\n\n fillAddressLine1(deliveryScreenAddress)\n })\n}\n\nexport function updateProductQuantity(\n product,\n {\n quantity = '1',\n multiProduct = false,\n verifySubTotal = true,\n timeout = 5000,\n } = {}\n) {\n cy.qe(`Updating the product quantity to ${quantity} `)\n cy.get(selectors.CartTimeline).should('be.visible').click({ force: true })\n if (multiProduct) {\n // Set First product quantity and don't verify subtotal because we passed false\n setProductQuantity(\n { position: 1, quantity, timeout },\n product.subTotal,\n false\n )\n // if multiProduct is true, then remove the set quantity and verify subtotal for multiProduct\n // Set second product quantity and verify subtotal\n setProductQuantity(\n { position: 2, quantity: 1, timeout },\n product.subTotal,\n verifySubTotal\n )\n } else {\n // Set First product quantity and verify subtotal\n setProductQuantity(\n { position: 1, quantity, timeout },\n product.subTotal,\n verifySubTotal\n )\n }\n}\n\n// LoginAsAdmin via API\nexport function loginAsAdmin() {\n // Get Vtex Iems\n cy.getVtexItems().then((vtex) => {\n cy.request(`${vtex.authUrl}/start`).then((response) => {\n expect(response.body).to.have.property('authenticationToken')\n cy.request({\n method: 'GET',\n url: AdminLogin(vtex.apiKey, vtex.apiToken),\n }).then((authResponse) => {\n setAuthCookie(authResponse)\n })\n })\n })\n}\n\n// LoginAsUser via API\nexport function loginAsUser(email, password) {\n // Get Vtex Iems\n cy.getVtexItems().then((vtex) => {\n let authenticationToken = null\n\n cy.request({\n method: 'POST',\n url: `${vtex.authUrl}/startlogin`,\n form: true,\n body: {\n accountName: vtex.account,\n scope: vtex.account,\n returnUrl: vtex.baseUrl,\n callbackUrl: `${vtex.baseUrl}/api/vtexid/oauth/finish?popup=false`,\n user: email,\n },\n }).then((response) => {\n authenticationToken = response.headers['set-cookie'][0]\n .split(';')[0]\n .split('=')\n .pop()\n\n cy.request({\n method: 'POST',\n url: `${vtex.authUrl}/classic/validate`,\n form: true,\n body: {\n login: email,\n password,\n authenticationToken,\n },\n }).then((authResponse) => {\n setAuthCookie(authResponse)\n })\n })\n })\n}\n\nexport function net30Payment() {\n cy.promissoryPayment()\n cy.buyProduct()\n}\n\nexport function saveOrderId(orderIdEnv = false, externalSeller = false) {\n // This page take longer time to load. So, wait for profile icon to visible then get orderid from url\n cy.get(selectors.Search, { timeout: 30000 })\n cy.url().then((url) => {\n const orderId = `${url.split('=').pop()}-01`\n\n // If we are ordering product\n // then store orderId in .orders.json\n if (orderIdEnv) {\n cy.qe(`Set orderId ${orderIdEnv}:${orderId} in orders.json`)\n cy.setOrderItem(orderIdEnv, orderId)\n }\n\n if (externalSeller) {\n cy.qe(\n `Set orderId ${externalSeller.directSaleEnv}:${orderId} in orders.json`\n )\n cy.qe(\n `Set orderId ${externalSeller.externalSaleEnv}:${orderId.slice(\n 0,\n -1\n )}2 in orders.json`\n )\n\n cy.setOrderItem(externalSeller.directSaleEnv, orderId)\n cy.setOrderItem(\n externalSeller.externalSaleEnv,\n `${orderId.slice(0, -1)}2`\n )\n }\n })\n}\n\n// Do promissory payment\nexport function promissoryPayment() {\n cy.get(selectors.PromissoryPayment).click()\n}\n\n// Search Product\nexport function searchProduct(searchKey) {\n cy.qe(\n `Adding intercept to wait for the events API to be completed before visting home page`\n )\n cy.intercept('**/event-api/v1/*/event').as('events')\n cy.visit('/')\n cy.wait('@events')\n cy.qe(\"Verify the store front page should contain 'Hello'\")\n cy.get('body').should('contain', 'Hello')\n cy.qe('Verifying the search bar should be visible in the store front')\n cy.qe(`searching product - ${searchKey} in the store front search bar`)\n // Search product in search bar\n cy.get(selectors.Search)\n .should('be.visible')\n .clear()\n .type(searchKey)\n .type('{enter}')\n // Page should load successfully now searchResult & Filter should be visible\n cy.qe(\n `Verfiying the search result is visible and having the text ${searchKey} in lowercase`\n )\n cy.get(selectors.searchResult)\n .should('be.visible')\n .should('have.text', searchKey.toLowerCase())\n cy.qe(`Verifying the filterHeading should be visible`)\n cy.get(selectors.FilterHeading).should('be.visible')\n}\n\nexport function stopTestCaseOnFailure() {\n // Arrow function doesn't provide us a way to use this.currentTest\n // So, we are using normal function\n // eslint-disable-next-line func-names\n afterEach(function () {\n cy.qe('================================================')\n\n if (\n this.currentTest.state === 'passed' ||\n this.currentTest.currentRetry() === this.currentTest.retries()\n ) {\n cy.writeFile(getLogFile(), Cypress.env('logs'), { flag: 'a+' })\n cy.clearLogs()\n } else {\n cy.clearLogs()\n }\n\n if (\n this.currentTest.currentRetry() === this.currentTest.retries() &&\n this.currentTest.state === 'failed'\n ) {\n Cypress.runner.stop()\n }\n })\n}\n\n/* Test Setup - Use Cookies to Login\n before()\n a) Inject Authentication cookie\n afterEach()\n a) Stop Execution if testcase gets failed in all retries\n*/\n// TODO: Once we replace testSetup() to loginViaCookies() in all projects\n// Then, Move logic() code to loginViaCookies() and delete testSetup(),logic()\n\nfunction logic(storeFrontCookie, stop) {\n before(() => {\n cy.qe()\n cy.clearLogs()\n // Inject cookies\n cy.getVtexItems().then((vtex) => {\n cy.setCookie(vtex.authCookieName, vtex.adminAuthCookieValue, {\n log: false,\n })\n if (storeFrontCookie) {\n loginAsUser(vtex.robotMail, vtex.robotPassword)\n }\n })\n })\n beforeEach(function () {\n cy.qe(\n `Testcase title - ${\n Cypress.mocha.getRunner().suite.ctx.currentTest.title\n }, Attempt Number - ${this.currentTest.currentRetry() + 1}`\n )\n })\n if (stop) stopTestCaseOnFailure()\n}\n\nexport function testSetup(storeFrontCookie = true, stop = true) {\n logic(storeFrontCookie, stop)\n}\n\nexport function loginViaCookies({ storeFrontCookie = true, stop = true } = {}) {\n logic(storeFrontCookie, stop)\n}\n\n/* loginViaAPI - Use API for login\n before()\n a) Inject Authentication cookie\n afterEach()\n a) Stop Execution if testcase gets failed in all retries\n*/\n\nexport function loginViaAPI({ storeFrontCookie = true, stop = true } = {}) {\n before(() => {\n cy.qe()\n // LoginAsAdmin\n loginAsAdmin()\n if (storeFrontCookie) {\n // LoginAsUser and visit home page\n cy.getVtexItems().then((vtex) => {\n loginAsUser(vtex.robotMail, vtex.robotPassword)\n })\n }\n })\n if (stop) stopTestCaseOnFailure()\n}\n\nexport function preserveCookie() {\n afterEach(() => {\n // Code to Handle the Sesssions in cypress.\n // Keep the Session alive when you jump to another test\n cy.getCookies().then((cookies) => {\n const namesOfCookies = cookies.map((c) => c.name)\n\n Cypress.Cookies.preserveOnce(...namesOfCookies)\n })\n })\n}\n\nexport function updateRetry(retry) {\n return { retries: retry }\n}\n\n// Verify Total by adding amounts in shipping summary\nexport function verifyTotal(totalAmount) {\n cy.get(selectors.ShippingSummary)\n .invoke('text')\n .then((costString) => {\n const costArray = costString.split('$').slice(1)\n const total = costArray.reduce((sum, number) => {\n return sum + parseFloat(number.replace(',', ''))\n }, 0)\n\n cy.get(selectors.TotalLabel)\n .first()\n .invoke('text')\n .then((totalText) => {\n expect(totalText.replace(',', '').replace('$ ', '')).to.equal(\n (total / 2).toFixed(2).replace(',', '')\n )\n cy.qe('Get total amount from TotalLabel')\n cy.qe(`Verify ${totalText} should be equal to ${totalAmount}`)\n expect(totalText).to.equal(totalAmount)\n })\n })\n}\n\nexport function clickBtnOnVisibility(selector) {\n cy.get(selector).then(($el) => {\n if (Cypress.dom.isVisible($el)) {\n cy.get(selector).should('be.visible').click()\n }\n })\n}\n\n```"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.