From ef9d0a5098c19103ace975a84b8f353323626eb5 Mon Sep 17 00:00:00 2001 From: Dmytro Asieiev Date: Mon, 18 Mar 2024 18:51:52 +0300 Subject: [PATCH 1/7] Added creation scenario from company user [skip ci] --- .../request-creation.cy.ts | 140 ++++++ .../dynamic-request-creation.json | 456 ++++++++++++++++++ .../static-request-creation.json | 3 + cypress/support/commands.ts | 2 +- .../pages/yves/catalog/catalog-page.ts | 41 ++ .../pages/yves/catalog/catalog-repository.ts | 7 + .../repositories/suite-catalog-repository.ts | 13 + .../merchant-relation-request-create-page.ts | 38 ++ ...hant-relation-request-create-repository.ts | 7 + ...hant-relation-request-create-repository.ts | 14 + .../merchant-relation-request-details-page.ts | 13 + ...ant-relation-request-details-repository.ts | 1 + ...ant-relation-request-details-repository.ts | 5 + .../merchant-relation-request-index-page.ts | 17 + ...chant-relation-request-index-repository.ts | 3 + ...chant-relation-request-index-repository.ts | 8 + .../user/select/company-user-select-page.ts | 17 + .../select/company-user-select-repository.ts | 4 + .../suite-company-user-select-repository.ts | 9 + cypress/support/pages/yves/index.ts | 6 + .../pages/yves/merchant/merchant-page.ts | 17 + .../yves/merchant/merchant-repository.ts | 3 + .../repositories/suite-merchant-repository.ts | 8 + cypress/support/types/mp/shared/index.ts | 3 +- cypress/support/types/mp/shared/merchant.ts | 1 + .../{product.ts => product-concrete.ts} | 4 - .../support/types/mp/shared/product-offer.ts | 3 + cypress/support/types/yves/checkout.ts | 6 +- cypress/support/types/yves/comments.ts | 4 +- cypress/support/types/yves/index.ts | 1 + .../yves/merchant-b2b-contract-requests.ts | 48 ++ .../yves/shared/company-business-unit.ts | 5 + .../support/types/yves/shared/company-user.ts | 3 + cypress/support/types/yves/shared/company.ts | 4 + cypress/support/types/yves/shared/index.ts | 9 +- cypress/support/types/yves/shared/merchant.ts | 4 + .../{product.ts => product-concrete.ts} | 2 +- .../types/yves/shared/product-offer.ts | 3 + cypress/support/types/yves/shared/url.ts | 3 + cypress/support/types/yves/shared/user.ts | 5 + .../utils/inversify/inversify.config.ts | 12 + cypress/support/utils/inversify/types.ts | 6 + 42 files changed, 945 insertions(+), 13 deletions(-) create mode 100644 cypress/e2e/yves/merchant-b2b-contract-requests/request-creation.cy.ts create mode 100644 cypress/fixtures/suite/yves/merchant-b2b-contract-requests/dynamic-request-creation.json create mode 100644 cypress/fixtures/suite/yves/merchant-b2b-contract-requests/static-request-creation.json create mode 100644 cypress/support/pages/yves/catalog/catalog-page.ts create mode 100644 cypress/support/pages/yves/catalog/catalog-repository.ts create mode 100644 cypress/support/pages/yves/catalog/repositories/suite-catalog-repository.ts create mode 100644 cypress/support/pages/yves/company/merchant-relation-request/create/merchant-relation-request-create-page.ts create mode 100644 cypress/support/pages/yves/company/merchant-relation-request/create/merchant-relation-request-create-repository.ts create mode 100644 cypress/support/pages/yves/company/merchant-relation-request/create/repositories/suite-merchant-relation-request-create-repository.ts create mode 100644 cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-page.ts create mode 100644 cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-repository.ts create mode 100644 cypress/support/pages/yves/company/merchant-relation-request/details/repositories/suite-merchant-relation-request-details-repository.ts create mode 100644 cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-page.ts create mode 100644 cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-repository.ts create mode 100644 cypress/support/pages/yves/company/merchant-relation-request/index/repositories/suite-merchant-relation-request-index-repository.ts create mode 100644 cypress/support/pages/yves/company/user/select/company-user-select-page.ts create mode 100644 cypress/support/pages/yves/company/user/select/company-user-select-repository.ts create mode 100644 cypress/support/pages/yves/company/user/select/repositories/suite-company-user-select-repository.ts create mode 100644 cypress/support/pages/yves/merchant/merchant-page.ts create mode 100644 cypress/support/pages/yves/merchant/merchant-repository.ts create mode 100644 cypress/support/pages/yves/merchant/repositories/suite-merchant-repository.ts rename cypress/support/types/mp/shared/{product.ts => product-concrete.ts} (52%) create mode 100644 cypress/support/types/mp/shared/product-offer.ts create mode 100644 cypress/support/types/yves/merchant-b2b-contract-requests.ts create mode 100644 cypress/support/types/yves/shared/company-business-unit.ts create mode 100644 cypress/support/types/yves/shared/company-user.ts create mode 100644 cypress/support/types/yves/shared/company.ts create mode 100644 cypress/support/types/yves/shared/merchant.ts rename cypress/support/types/yves/shared/{product.ts => product-concrete.ts} (67%) create mode 100644 cypress/support/types/yves/shared/product-offer.ts create mode 100644 cypress/support/types/yves/shared/url.ts create mode 100644 cypress/support/types/yves/shared/user.ts diff --git a/cypress/e2e/yves/merchant-b2b-contract-requests/request-creation.cy.ts b/cypress/e2e/yves/merchant-b2b-contract-requests/request-creation.cy.ts new file mode 100644 index 00000000..9e888d64 --- /dev/null +++ b/cypress/e2e/yves/merchant-b2b-contract-requests/request-creation.cy.ts @@ -0,0 +1,140 @@ +import { container } from '@utils'; +import { + CatalogPage, + CompanyUserSelectPage, + MerchantPage, + MerchantRelationRequestCreatePage, + MerchantRelationRequestDetailsPage, + MerchantRelationRequestIndexPage, +} from '../../../support/pages/yves'; +import { CustomerLoginScenario } from '../../../support/scenarios/yves'; +import { MerchantB2bContractRequestsStaticFixtures, RequestCreationDynamicFixtures } from '../../../support/types/yves'; + +/** + * Merchant Relation Requests & Enhanced Merchant Relations checklists: {@link https://spryker.atlassian.net/wiki/spaces/CCS/pages/4105896492/Business+Journey+B2B+Marketplace+-+to+automate} + */ +describe('request creation', { tags: ['@merchant-b2b-contract-requests'] }, (): void => { + const catalogPage = container.get(CatalogPage); + const companyUserSelectPage = container.get(CompanyUserSelectPage); + const merchantRelationRequestCreatePage = container.get(MerchantRelationRequestCreatePage); + const merchantRelationRequestDetailsPage = container.get(MerchantRelationRequestDetailsPage); + const merchantRelationRequestIndexPage = container.get(MerchantRelationRequestIndexPage); + const merchantPage = container.get(MerchantPage); + const customerLoginScenario = container.get(CustomerLoginScenario); + + let dynamicFixtures: RequestCreationDynamicFixtures; + let staticFixtures: MerchantB2bContractRequestsStaticFixtures; + + before((): void => { + ({ dynamicFixtures, staticFixtures } = Cypress.env()); + }); + + beforeEach((): void => { + customerLoginScenario.execute({ + email: dynamicFixtures.customer.email, + password: staticFixtures.defaultPassword, + }); + companyUserSelectPage.visit(); + }); + + it('company user should be able to create request from PDP', (): void => { + companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany1.id_company_user); + + catalogPage.openFirstSuggestedProduct(dynamicFixtures.concreteProduct.abstract_sku); + catalogPage.createMerchantRelationRequest(dynamicFixtures.productOfferFromMerchant2.product_offer_reference); + + merchantRelationRequestCreatePage.create({ + ownerBusinessUnitId: dynamicFixtures.businessUnit1FromCompany1.id_company_business_unit, + businessUnitIds: [ + dynamicFixtures.businessUnit1FromCompany1.id_company_business_unit, + dynamicFixtures.businessUnit2FromCompany1.id_company_business_unit, + ], + }); + + merchantRelationRequestDetailsPage.assertPageLocation(); + }); + + it('company user should not be able to create request from merchant profile without business units', (): void => { + companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser2FromCompany1.id_company_user); + + cy.visit(dynamicFixtures.merchantUrl2.url); + merchantPage.sendMerchantRelationRequest(); + + merchantRelationRequestCreatePage.create({ + merchantReference: dynamicFixtures.merchant1.merchant_reference, + ownerBusinessUnitId: dynamicFixtures.businessUnit2FromCompany1.id_company_business_unit, + businessUnitIds: [], + }); + + merchantRelationRequestCreatePage.assertPageLocation(); + }); + + it('company user should be able to create request from merchant profile page', (): void => { + companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser2FromCompany1.id_company_user); + + cy.visit(dynamicFixtures.merchantUrl2.url); + merchantPage.sendMerchantRelationRequest(); + + merchantRelationRequestCreatePage.create({ + ownerBusinessUnitId: dynamicFixtures.businessUnit2FromCompany1.id_company_business_unit, + businessUnitIds: [ + dynamicFixtures.businessUnit1FromCompany1.id_company_business_unit, + dynamicFixtures.businessUnit2FromCompany1.id_company_business_unit, + ], + }); + + merchantRelationRequestDetailsPage.assertPageLocation(); + }); + + it('company user should be able to create request from MR request create page', (): void => { + companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany2.id_company_user); + + merchantRelationRequestIndexPage.visit(); + merchantRelationRequestIndexPage.createMerchantRelationRequest(); + + merchantRelationRequestCreatePage.create({ + merchantReference: dynamicFixtures.merchant1.merchant_reference, + ownerBusinessUnitId: dynamicFixtures.businessUnit1FromCompany2.id_company_business_unit, + businessUnitIds: [ + dynamicFixtures.businessUnit1FromCompany2.id_company_business_unit, + dynamicFixtures.businessUnit2FromCompany2.id_company_business_unit, + ], + }); + + merchantRelationRequestDetailsPage.assertPageLocation(); + }); + + it('company user should be able to create request with only one business unit', (): void => { + companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany2.id_company_user); + + merchantRelationRequestCreatePage.visit(); + merchantRelationRequestCreatePage.create({ + merchantReference: dynamicFixtures.merchant1.merchant_reference, + ownerBusinessUnitId: dynamicFixtures.businessUnit1FromCompany2.id_company_business_unit, + businessUnitIds: [dynamicFixtures.businessUnit1FromCompany2.id_company_business_unit], + }); + + merchantRelationRequestDetailsPage.assertPageLocation(); + }); + + it('sold by merchant contains MR request links', (): void => { + companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany1.id_company_user); + catalogPage.openFirstSuggestedProduct(dynamicFixtures.concreteProduct.abstract_sku); + + const productOffers = catalogPage.getSoldByProductOffers(); + const createRequestLink = catalogPage.getMerchantRelationRequestLinkAttribute(); + + productOffers.children().each(($productOffer) => { + const productOfferReference = $productOffer.find('input[type="radio"]').attr('value'); + + if ( + productOfferReference === dynamicFixtures.productOfferFromMerchant1.product_offer_reference || + productOfferReference === dynamicFixtures.productOfferFromMerchant2.product_offer_reference + ) { + cy.wrap($productOffer).find(createRequestLink).should('exist'); + } else if (productOfferReference === dynamicFixtures.productOfferFromMerchant3.product_offer_reference) { + cy.wrap($productOffer).find(createRequestLink).should('not.exist'); + } + }); + }); +}); diff --git a/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/dynamic-request-creation.json b/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/dynamic-request-creation.json new file mode 100644 index 00000000..cde00a84 --- /dev/null +++ b/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/dynamic-request-creation.json @@ -0,0 +1,456 @@ +{ + "data": { + "type": "dynamic-fixtures", + "attributes": { + "synchronize": true, + "operations": [ + { + "type": "transfer", + "name": "LocaleTransfer", + "key": "localeEN", + "arguments": { "id_locale": 66, "locale_name": "en_US" } + }, + { + "type": "transfer", + "name": "LocaleTransfer", + "key": "localeDE", + "arguments": { "id_locale": 46, "locale_name": "de_DE" } + }, + { + "type": "builder", + "name": "LocalizedAttributesBuilder", + "key": "localizedAttribute" + }, + { + "type": "transfer", + "name": "StoreTransfer", + "key": "store", + "arguments": { "id_store": 1, "name": "DE" } + }, + { + "type": "array-object", + "key": "stores", + "arguments": ["#store"] + }, + { + "type": "helper", + "name": "haveUser", + "key": "merchantUser1FromMerchant1", + "arguments": [{ "password": "change123" }] + }, + { + "type": "helper", + "name": "haveUser", + "key": "merchantUser2FromMerchant1", + "arguments": [{ "password": "change123" }] + }, + { + "type": "builder", + "name": "MerchantProfileBuilder", + "key": "merchantProfile1" + }, + { + "type": "helper", + "name": "haveMerchant", + "key": "merchant1", + "arguments": [ + { + "merchantProfile": "#merchantProfile1", + "isActive": true, + "isOpenForRelationRequest": true, + "status": "approved", + "storeRelation": { + "idStores": ["#store.id_store"] + } + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "key": "merchantUrl1", + "arguments": [ + { + "fkLocale": "#localeEN.id_locale", + "fkResourceMerchant": "#merchant1.id_merchant", + "urlPrefix": "/en/merchant/dummy-en-prefix-", + "url": "#merchant1.name" + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "arguments": [ + { + "fkLocale": "#localeDE.id_locale", + "fkResourceMerchant": "#merchant1.id_merchant", + "urlPrefix": "/de/merchant/dummy-de-prefix-", + "url": "#merchant1.name" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantUserWithAclEntities", + "arguments": ["#merchant1", "#merchantUser1FromMerchant1"] + }, + { + "type": "helper", + "name": "haveMerchantUserWithAclEntities", + "arguments": ["#merchant1", "#merchantUser2FromMerchant1"] + }, + { + "type": "helper", + "name": "haveUser", + "key": "merchantUserFromMerchant2", + "arguments": [{ "password": "change123" }] + }, + { + "type": "builder", + "name": "MerchantProfileBuilder", + "key": "merchantProfile2" + }, + { + "type": "helper", + "name": "haveMerchant", + "key": "merchant2", + "arguments": [ + { + "merchantProfile": "#merchantProfile2", + "isActive": true, + "isOpenForRelationRequest": true, + "status": "approved", + "storeRelation": { + "idStores": ["#store.id_store"] + } + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "key": "merchantUrl2", + "arguments": [ + { + "fkLocale": "#localeEN.id_locale", + "fkResourceMerchant": "#merchant2.id_merchant", + "urlPrefix": "/en/merchant/dummy-en-prefix-", + "url": "#merchant2.name" + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "arguments": [ + { + "fkLocale": "#localeDE.id_locale", + "fkResourceMerchant": "#merchant2.id_merchant", + "urlPrefix": "/de/merchant/dummy-de-prefix-", + "url": "#merchant2.name" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantUserWithAclEntities", + "arguments": ["#merchant2", "#merchantUserFromMerchant2"] + }, + { + "type": "helper", + "name": "haveUser", + "key": "merchantUserFromMerchant3", + "arguments": [{ "password": "change123" }] + }, + { + "type": "builder", + "name": "MerchantProfileBuilder", + "key": "merchantProfile3" + }, + { + "type": "helper", + "name": "haveMerchant", + "key": "merchant3", + "arguments": [ + { + "merchantProfile": "#merchantProfile3", + "isActive": true, + "isOpenForRelationRequest": false, + "status": "approved", + "storeRelation": { + "idStores": ["#store.id_store"] + } + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "key": "merchantUrl3", + "arguments": [ + { + "fkLocale": "#localeEN.id_locale", + "fkResourceMerchant": "#merchant3.id_merchant", + "urlPrefix": "/en/merchant/dummy-en-prefix-", + "url": "#merchant3.name" + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "arguments": [ + { + "fkLocale": "#localeDE.id_locale", + "fkResourceMerchant": "#merchant3.id_merchant", + "urlPrefix": "/de/merchant/dummy-de-prefix-", + "url": "#merchant3.name" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantUserWithAclEntities", + "arguments": ["#merchant3", "#merchantUserFromMerchant3"] + }, + { + "type": "transfer", + "name": "ProductImageTransfer", + "key": "productImage", + "arguments": { + "externalUrlSmall": "https://images.icecat.biz/img/gallery_mediums/30691822_1486.jpg", + "externalUrlLarge": "https://images.icecat.biz/img/gallery/30691822_1486.jpg" + } + }, + { + "type": "helper", + "name": "haveFullProduct", + "key": "concreteProduct", + "arguments": [ + {}, + { + "idTaxSet": 1, + "localizedAttributes": [ + { "locale": "#localeEN", "name": "#localizedAttribute.name" }, + { "locale": "#localeDE", "name": "#localizedAttribute.name" } + ] + } + ] + }, + { + "type": "helper", + "name": "haveProductImageSet", + "arguments": [ + { + "name": "default", + "idProduct": "#concreteProduct.id_product_concrete", + "idProductAbstract": "#concreteProduct.fk_product_abstract", + "productImages": ["#productImage"] + } + ] + }, + { + "type": "helper", + "name": "havePriceProduct", + "arguments": [ + { + "skuProductAbstract": "#concreteProduct.abstract_sku", + "skuProduct": "#concreteProduct.sku", + "moneyValue": { "netAmount": 30000, "grossAmount": 30000 } + } + ] + }, + { + "type": "helper", + "name": "haveProductOffer", + "key": "productOfferFromMerchant1", + "arguments": [ + { + "isActive": true, + "status": "approved", + "idProductConcrete": "#concreteProduct.id_product_concrete", + "concreteSku": "#concreteProduct.sku", + "merchantReference": "#merchant1.merchant_reference", + "stores": "#stores" + } + ] + }, + { + "type": "helper", + "name": "haveProductOfferStock", + "arguments": [ + { + "idProductOffer": "#productOfferFromMerchant1.id_product_offer", + "productOfferReference": "#productOfferFromMerchant1.product_offer_reference", + "isNeverOutOfStock": true + }, + "#merchant1.stocks" + ] + }, + { + "type": "helper", + "name": "haveProductOffer", + "key": "productOfferFromMerchant2", + "arguments": [ + { + "isActive": true, + "status": "approved", + "idProductConcrete": "#concreteProduct.id_product_concrete", + "concreteSku": "#concreteProduct.sku", + "merchantReference": "#merchant2.merchant_reference", + "stores": "#stores" + } + ] + }, + { + "type": "helper", + "name": "haveProductOfferStock", + "arguments": [ + { + "idProductOffer": "#productOfferFromMerchant2.id_product_offer", + "productOfferReference": "#productOfferFromMerchant2.product_offer_reference", + "isNeverOutOfStock": true + }, + "#merchant2.stocks" + ] + }, + { + "type": "helper", + "name": "haveProductOffer", + "key": "productOfferFromMerchant3", + "arguments": [ + { + "isActive": true, + "status": "approved", + "idProductConcrete": "#concreteProduct.id_product_concrete", + "concreteSku": "#concreteProduct.sku", + "merchantReference": "#merchant3.merchant_reference", + "stores": "#stores" + } + ] + }, + { + "type": "helper", + "name": "haveProductOfferStock", + "arguments": [ + { + "idProductOffer": "#productOfferFromMerchant3.id_product_offer", + "productOfferReference": "#productOfferFromMerchant3.product_offer_reference", + "isNeverOutOfStock": true + }, + "#merchant3.stocks" + ] + }, + { + "type": "helper", + "name": "haveCountry", + "key": "country" + }, + { + "type": "helper", + "name": "haveCustomer", + "key": "customer", + "arguments": [{ "locale": "#localeEN", "password": "change123" }] + }, + { + "type": "helper", + "name": "confirmCustomer", + "key": "confirmedCustomer", + "arguments": ["#customer"] + }, + { + "type": "helper", + "name": "haveCompany", + "key": "company1", + "arguments": [{ "isActive": true, "status": "approved" }] + }, + { + "type": "helper", + "name": "haveCompany", + "key": "company2", + "arguments": [{ "isActive": true, "status": "approved" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit1FromCompany1", + "arguments": [{ "fkCompany": "#company1.id_company" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit2FromCompany1", + "arguments": [{ "fkCompany": "#company1.id_company" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit1FromCompany2", + "arguments": [{ "fkCompany": "#company2.id_company" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit2FromCompany2", + "arguments": [{ "fkCompany": "#company2.id_company" }] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission", + "arguments": ["CreateMerchantRelationRequestPermissionPlugin"] + }, + { + "type": "helper", + "name": "haveCompanyRoleWithPermissions", + "arguments": [{ "isDefault": true, "fkCompany": "#company1.id_company" }, ["#permission"]] + }, + { + "type": "helper", + "name": "haveCompanyRoleWithPermissions", + "arguments": [{ "isDefault": true, "fkCompany": "#company2.id_company" }, ["#permission"]] + }, + { + "type": "helper", + "name": "haveCompanyUser", + "key": "companyUser1FromCompany1", + "arguments": [ + { + "customer": "#customer", + "fkCustomer": "#customer.id_customer", + "fkCompany": "#company1.id_company", + "fkCompanyBusinessUnit": "#businessUnit1FromCompany1.id_company_business_unit" + } + ] + }, + { + "type": "helper", + "name": "haveCompanyUser", + "key": "companyUser2FromCompany1", + "arguments": [ + { + "customer": "#customer", + "fkCustomer": "#customer.id_customer", + "fkCompany": "#company1.id_company", + "fkCompanyBusinessUnit": "#businessUnit2FromCompany1.id_company_business_unit" + } + ] + }, + { + "type": "helper", + "name": "haveCompanyUser", + "key": "companyUser1FromCompany2", + "arguments": [ + { + "customer": "#customer", + "fkCustomer": "#customer.id_customer", + "fkCompany": "#company2.id_company", + "fkCompanyBusinessUnit": "#businessUnit1FromCompany2.id_company_business_unit" + } + ] + } + ] + } + } +} diff --git a/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/static-request-creation.json b/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/static-request-creation.json new file mode 100644 index 00000000..ba4339e8 --- /dev/null +++ b/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/static-request-creation.json @@ -0,0 +1,3 @@ +{ + "defaultPassword": "change123" +} diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index f91dac9a..dadc6e23 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -43,7 +43,7 @@ Cypress.Commands.add('loadDynamicFixturesByPayload', (dynamicFixturesFilePath) = 'Content-Type': 'application/vnd.api+json', }, body: operationRequestPayload, - timeout: 40000, + timeout: 60000, }) .then((response) => { if (Array.isArray(response.body.data)) { diff --git a/cypress/support/pages/yves/catalog/catalog-page.ts b/cypress/support/pages/yves/catalog/catalog-page.ts new file mode 100644 index 00000000..7d0d220a --- /dev/null +++ b/cypress/support/pages/yves/catalog/catalog-page.ts @@ -0,0 +1,41 @@ +import { REPOSITORIES, autoWired } from '@utils'; +import { inject, injectable } from 'inversify'; + +import { YvesPage } from '../yves-page'; +import { CatalogRepository } from './catalog-repository'; + +@injectable() +@autoWired +export class CatalogPage extends YvesPage { + @inject(REPOSITORIES.CatalogRepository) private repository: CatalogRepository; + + protected PAGE_URL = '/search'; + + openFirstSuggestedProduct = (query: string): void => { + this.repository.getSearchInput().clear().type(query); + this.repository.getFirstSuggestedProduct().click(); + }; + + selectSoldByProductOffer = (productOfferReference: string): void => { + this.repository.getSoldByProductOfferRadios().check(productOfferReference, { force: true }); + }; + + createMerchantRelationRequest = (productOfferReference: string): void => { + this.repository + .getSoldByProductOffers() + .children() + .each(($productOffer) => { + if ($productOffer.find('input[type="radio"]').attr('value') === productOfferReference) { + cy.wrap($productOffer).find(this.repository.getMerchantRelationRequestLinkAttribute()).click(); + } + }); + }; + + getSoldByProductOffers = (): Cypress.Chainable => { + return this.repository.getSoldByProductOffers(); + }; + + getMerchantRelationRequestLinkAttribute = (): string => { + return this.repository.getMerchantRelationRequestLinkAttribute(); + }; +} diff --git a/cypress/support/pages/yves/catalog/catalog-repository.ts b/cypress/support/pages/yves/catalog/catalog-repository.ts new file mode 100644 index 00000000..33c1c8b2 --- /dev/null +++ b/cypress/support/pages/yves/catalog/catalog-repository.ts @@ -0,0 +1,7 @@ +export interface CatalogRepository { + getSearchInput(): Cypress.Chainable; + getFirstSuggestedProduct(): Cypress.Chainable; + getSoldByProductOffers(): Cypress.Chainable; + getSoldByProductOfferRadios(): Cypress.Chainable; + getMerchantRelationRequestLinkAttribute(): string; +} diff --git a/cypress/support/pages/yves/catalog/repositories/suite-catalog-repository.ts b/cypress/support/pages/yves/catalog/repositories/suite-catalog-repository.ts new file mode 100644 index 00000000..60ca83dc --- /dev/null +++ b/cypress/support/pages/yves/catalog/repositories/suite-catalog-repository.ts @@ -0,0 +1,13 @@ +import { injectable } from 'inversify'; +import { CatalogRepository } from '../catalog-repository'; +import * as Cypress from 'cypress'; + +@injectable() +export class SuiteCatalogRepository implements CatalogRepository { + getSearchInput = (): Cypress.Chainable => cy.get('[data-qa="component search-form"] input').first(); + getFirstSuggestedProduct = (): Cypress.Chainable => cy.get('[data-qa="component suggestion-product"] a').first(); + getSoldByProductOffers = (): Cypress.Chainable => cy.get('[data-qa="component merchant-product-offer-item"]'); + getSoldByProductOfferRadios = (): Cypress.Chainable => + cy.get('[data-qa="component merchant-product-offer-item"] input[type="radio"]'); + getMerchantRelationRequestLinkAttribute = (): string => '[data-qa="merchant-relation-request-create-link"]'; +} diff --git a/cypress/support/pages/yves/company/merchant-relation-request/create/merchant-relation-request-create-page.ts b/cypress/support/pages/yves/company/merchant-relation-request/create/merchant-relation-request-create-page.ts new file mode 100644 index 00000000..2affb725 --- /dev/null +++ b/cypress/support/pages/yves/company/merchant-relation-request/create/merchant-relation-request-create-page.ts @@ -0,0 +1,38 @@ +import { REPOSITORIES, autoWired } from '@utils'; +import { inject, injectable } from 'inversify'; +import { YvesPage } from '../../../yves-page'; +import { MerchantRelationRequestCreateRepository } from './merchant-relation-request-create-repository'; + +interface CreateMerchantRelationRequestParams { + merchantReference?: string; + ownerBusinessUnitId: number; + businessUnitIds: number[]; + messageToMerchant?: string; +} + +@injectable() +@autoWired +export class MerchantRelationRequestCreatePage extends YvesPage { + @inject(REPOSITORIES.MerchantRelationRequestCreateRepository) + private repository: MerchantRelationRequestCreateRepository; + + protected PAGE_URL = '/company/merchant-relation-request/create'; + + create = (params: CreateMerchantRelationRequestParams): void => { + if (params.merchantReference) { + this.repository.getMerchantSelect().select(params.merchantReference); + } + + this.repository.getBusinessUnitOwnerSelect().select(params.ownerBusinessUnitId.toString()); + + if (params.businessUnitIds.length > 0) { + this.repository.getBusinessUnitCheckboxes().check(params.businessUnitIds.map(String), { force: true }); + } + + if (params.messageToMerchant) { + this.repository.getRequestNoteInput().clear().type(params.messageToMerchant); + } + + this.repository.getSubmitButton().click(); + }; +} diff --git a/cypress/support/pages/yves/company/merchant-relation-request/create/merchant-relation-request-create-repository.ts b/cypress/support/pages/yves/company/merchant-relation-request/create/merchant-relation-request-create-repository.ts new file mode 100644 index 00000000..c675a6c9 --- /dev/null +++ b/cypress/support/pages/yves/company/merchant-relation-request/create/merchant-relation-request-create-repository.ts @@ -0,0 +1,7 @@ +export interface MerchantRelationRequestCreateRepository { + getMerchantSelect(): Cypress.Chainable; + getBusinessUnitOwnerSelect(): Cypress.Chainable; + getBusinessUnitCheckboxes(): Cypress.Chainable; + getRequestNoteInput(): Cypress.Chainable; + getSubmitButton(): Cypress.Chainable; +} diff --git a/cypress/support/pages/yves/company/merchant-relation-request/create/repositories/suite-merchant-relation-request-create-repository.ts b/cypress/support/pages/yves/company/merchant-relation-request/create/repositories/suite-merchant-relation-request-create-repository.ts new file mode 100644 index 00000000..1cd1b855 --- /dev/null +++ b/cypress/support/pages/yves/company/merchant-relation-request/create/repositories/suite-merchant-relation-request-create-repository.ts @@ -0,0 +1,14 @@ +import { injectable } from 'inversify'; +import { MerchantRelationRequestCreateRepository } from '../merchant-relation-request-create-repository'; + +@injectable() +export class SuiteMerchantRelationRequestCreateRepository implements MerchantRelationRequestCreateRepository { + getMerchantSelect = (): Cypress.Chainable => cy.get('#merchant_relation_request_form_merchant_merchantReference'); + getBusinessUnitOwnerSelect = (): Cypress.Chainable => + cy.get('#merchant_relation_request_form_ownerCompanyBusinessUnit_idCompanyBusinessUnit'); + getBusinessUnitCheckboxes = (): Cypress.Chainable => + cy.get('#merchant_relation_request_form_assigneeCompanyBusinessUnits input'); + getRequestNoteInput = (): Cypress.Chainable => cy.get('#merchant_relation_request_form_requestNote'); + getSubmitButton = (): Cypress.Chainable => + cy.get('form[name=merchant_relation_request_form]').find('[type="submit"]'); +} diff --git a/cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-page.ts b/cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-page.ts new file mode 100644 index 00000000..e42ea6f8 --- /dev/null +++ b/cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-page.ts @@ -0,0 +1,13 @@ +import { REPOSITORIES, autoWired } from '@utils'; +import { inject, injectable } from 'inversify'; +import { YvesPage } from '../../../yves-page'; +import { MerchantRelationRequestDetailsRepository } from './merchant-relation-request-details-repository'; + +@injectable() +@autoWired +export class MerchantRelationRequestDetailsPage extends YvesPage { + @inject(REPOSITORIES.MerchantRelationRequestDetailsRepository) + private repository: MerchantRelationRequestDetailsRepository; + + protected PAGE_URL = '/company/merchant-relation-request/details'; +} diff --git a/cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-repository.ts b/cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-repository.ts new file mode 100644 index 00000000..5291571d --- /dev/null +++ b/cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-repository.ts @@ -0,0 +1 @@ +export interface MerchantRelationRequestDetailsRepository {} diff --git a/cypress/support/pages/yves/company/merchant-relation-request/details/repositories/suite-merchant-relation-request-details-repository.ts b/cypress/support/pages/yves/company/merchant-relation-request/details/repositories/suite-merchant-relation-request-details-repository.ts new file mode 100644 index 00000000..d812aa5b --- /dev/null +++ b/cypress/support/pages/yves/company/merchant-relation-request/details/repositories/suite-merchant-relation-request-details-repository.ts @@ -0,0 +1,5 @@ +import { injectable } from 'inversify'; +import { MerchantRelationRequestDetailsRepository } from '../merchant-relation-request-details-repository'; + +@injectable() +export class SuiteMerchantRelationRequestDetailsRepository implements MerchantRelationRequestDetailsRepository {} diff --git a/cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-page.ts b/cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-page.ts new file mode 100644 index 00000000..7fd17b71 --- /dev/null +++ b/cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-page.ts @@ -0,0 +1,17 @@ +import { REPOSITORIES, autoWired } from '@utils'; +import { inject, injectable } from 'inversify'; +import { YvesPage } from '../../../yves-page'; +import { MerchantRelationRequestIndexRepository } from './merchant-relation-request-index-repository'; + +@injectable() +@autoWired +export class MerchantRelationRequestIndexPage extends YvesPage { + @inject(REPOSITORIES.MerchantRelationRequestIndexRepository) + private repository: MerchantRelationRequestIndexRepository; + + protected PAGE_URL = '/company/merchant-relation-request'; + + createMerchantRelationRequest = (): void => { + this.repository.getMerchantRelationRequestButton().click(); + }; +} diff --git a/cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-repository.ts b/cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-repository.ts new file mode 100644 index 00000000..42c9f52e --- /dev/null +++ b/cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-repository.ts @@ -0,0 +1,3 @@ +export interface MerchantRelationRequestIndexRepository { + getMerchantRelationRequestButton(): Cypress.Chainable; +} diff --git a/cypress/support/pages/yves/company/merchant-relation-request/index/repositories/suite-merchant-relation-request-index-repository.ts b/cypress/support/pages/yves/company/merchant-relation-request/index/repositories/suite-merchant-relation-request-index-repository.ts new file mode 100644 index 00000000..572a2c3f --- /dev/null +++ b/cypress/support/pages/yves/company/merchant-relation-request/index/repositories/suite-merchant-relation-request-index-repository.ts @@ -0,0 +1,8 @@ +import { injectable } from 'inversify'; +import { MerchantRelationRequestIndexRepository } from '../merchant-relation-request-index-repository'; + +@injectable() +export class SuiteMerchantRelationRequestIndexRepository implements MerchantRelationRequestIndexRepository { + getMerchantRelationRequestButton = (): Cypress.Chainable => + cy.get('[data-qa="create-merchant-relation-request-button"]'); +} diff --git a/cypress/support/pages/yves/company/user/select/company-user-select-page.ts b/cypress/support/pages/yves/company/user/select/company-user-select-page.ts new file mode 100644 index 00000000..c4272217 --- /dev/null +++ b/cypress/support/pages/yves/company/user/select/company-user-select-page.ts @@ -0,0 +1,17 @@ +import { REPOSITORIES, autoWired } from '@utils'; +import { inject, injectable } from 'inversify'; +import { YvesPage } from '../../../yves-page'; +import { CompanyUserSelectRepository } from './company-user-select-repository'; + +@injectable() +@autoWired +export class CompanyUserSelectPage extends YvesPage { + @inject(REPOSITORIES.CompanyUserSelectRepository) private repository: CompanyUserSelectRepository; + + protected PAGE_URL = '/company/user/select'; + + selectBusinessUnit = (idCompanyUser: number): void => { + this.repository.getBusinessUnitSelect().select(idCompanyUser.toString()); + this.repository.getSubmitButton().click(); + }; +} diff --git a/cypress/support/pages/yves/company/user/select/company-user-select-repository.ts b/cypress/support/pages/yves/company/user/select/company-user-select-repository.ts new file mode 100644 index 00000000..4efbc3d8 --- /dev/null +++ b/cypress/support/pages/yves/company/user/select/company-user-select-repository.ts @@ -0,0 +1,4 @@ +export interface CompanyUserSelectRepository { + getBusinessUnitSelect(): Cypress.Chainable; + getSubmitButton(): Cypress.Chainable; +} diff --git a/cypress/support/pages/yves/company/user/select/repositories/suite-company-user-select-repository.ts b/cypress/support/pages/yves/company/user/select/repositories/suite-company-user-select-repository.ts new file mode 100644 index 00000000..715f552e --- /dev/null +++ b/cypress/support/pages/yves/company/user/select/repositories/suite-company-user-select-repository.ts @@ -0,0 +1,9 @@ +import { injectable } from 'inversify'; +import { CompanyUserSelectRepository } from '../company-user-select-repository'; + +@injectable() +export class SuiteCompanyUserSelectRepository implements CompanyUserSelectRepository { + getBusinessUnitSelect = (): Cypress.Chainable => cy.get('#company_user_account_selector_form_companyUserAccount'); + getSubmitButton = (): Cypress.Chainable => + cy.get('form[name=company_user_account_selector_form]').find('[type="submit"]'); +} diff --git a/cypress/support/pages/yves/index.ts b/cypress/support/pages/yves/index.ts index 654d06f9..3b6f7368 100644 --- a/cypress/support/pages/yves/index.ts +++ b/cypress/support/pages/yves/index.ts @@ -8,3 +8,9 @@ export * from './checkout/summary/checkout-summary-page'; export * from './comment/cart/comment-cart-page'; export * from './login/login-page'; export * from './multi-cart/multi-cart-page'; +export * from './catalog/catalog-page'; +export * from './company/user/select/company-user-select-page'; +export * from './company/merchant-relation-request/create/merchant-relation-request-create-page'; +export * from './company/merchant-relation-request/details/merchant-relation-request-details-page'; +export * from './company/merchant-relation-request/index/merchant-relation-request-index-page'; +export * from './merchant/merchant-page'; diff --git a/cypress/support/pages/yves/merchant/merchant-page.ts b/cypress/support/pages/yves/merchant/merchant-page.ts new file mode 100644 index 00000000..c26133bc --- /dev/null +++ b/cypress/support/pages/yves/merchant/merchant-page.ts @@ -0,0 +1,17 @@ +import { REPOSITORIES, autoWired } from '@utils'; +import { inject, injectable } from 'inversify'; + +import { YvesPage } from '../yves-page'; +import { MerchantRepository } from './merchant-repository'; + +@injectable() +@autoWired +export class MerchantPage extends YvesPage { + @inject(REPOSITORIES.MerchantRepository) private repository: MerchantRepository; + + protected PAGE_URL = '/merchant'; + + sendMerchantRelationRequest = (): void => { + this.repository.getMerchantRelationRequestButton().click(); + }; +} diff --git a/cypress/support/pages/yves/merchant/merchant-repository.ts b/cypress/support/pages/yves/merchant/merchant-repository.ts new file mode 100644 index 00000000..549cadaf --- /dev/null +++ b/cypress/support/pages/yves/merchant/merchant-repository.ts @@ -0,0 +1,3 @@ +export interface MerchantRepository { + getMerchantRelationRequestButton(): Cypress.Chainable; +} diff --git a/cypress/support/pages/yves/merchant/repositories/suite-merchant-repository.ts b/cypress/support/pages/yves/merchant/repositories/suite-merchant-repository.ts new file mode 100644 index 00000000..97994946 --- /dev/null +++ b/cypress/support/pages/yves/merchant/repositories/suite-merchant-repository.ts @@ -0,0 +1,8 @@ +import { injectable } from 'inversify'; +import { MerchantRepository } from '../merchant-repository'; + +@injectable() +export class SuiteMerchantRepository implements MerchantRepository { + getMerchantRelationRequestButton = (): Cypress.Chainable => + cy.get('[data-qa="merchant-relation-request-create-button"]'); +} diff --git a/cypress/support/types/mp/shared/index.ts b/cypress/support/types/mp/shared/index.ts index dcc5ebb6..225ea302 100644 --- a/cypress/support/types/mp/shared/index.ts +++ b/cypress/support/types/mp/shared/index.ts @@ -1,5 +1,6 @@ export * from './customer'; export * from './merchant'; -export * from './product'; +export * from './product-concrete'; +export * from './product-offer'; export * from './quote'; export * from './user'; diff --git a/cypress/support/types/mp/shared/merchant.ts b/cypress/support/types/mp/shared/merchant.ts index 8533267d..51f3787b 100644 --- a/cypress/support/types/mp/shared/merchant.ts +++ b/cypress/support/types/mp/shared/merchant.ts @@ -1,3 +1,4 @@ export interface Merchant { + merchant_reference: string; name: string; } diff --git a/cypress/support/types/mp/shared/product.ts b/cypress/support/types/mp/shared/product-concrete.ts similarity index 52% rename from cypress/support/types/mp/shared/product.ts rename to cypress/support/types/mp/shared/product-concrete.ts index 6b02a20f..5f9611b7 100644 --- a/cypress/support/types/mp/shared/product.ts +++ b/cypress/support/types/mp/shared/product-concrete.ts @@ -2,7 +2,3 @@ export interface ProductConcrete { sku: string; abstract_sku: string; } - -export interface ProductOffer { - product_offer_reference: string; -} diff --git a/cypress/support/types/mp/shared/product-offer.ts b/cypress/support/types/mp/shared/product-offer.ts new file mode 100644 index 00000000..4bd9a025 --- /dev/null +++ b/cypress/support/types/mp/shared/product-offer.ts @@ -0,0 +1,3 @@ +export interface ProductOffer { + product_offer_reference: string; +} diff --git a/cypress/support/types/yves/checkout.ts b/cypress/support/types/yves/checkout.ts index dd42c6fe..ba7a243b 100644 --- a/cypress/support/types/yves/checkout.ts +++ b/cypress/support/types/yves/checkout.ts @@ -1,10 +1,10 @@ -import { Address, Customer, Product, Quote } from './shared'; +import { Address, Customer, ProductConcrete, Quote } from './shared'; export interface BasicCheckoutDynamicFixtures { customer: Customer; address: Address; - product1: Product; - product2: Product; + product1: ProductConcrete; + product2: ProductConcrete; quote1: Quote; quote2: Quote; quote3: Quote; diff --git a/cypress/support/types/yves/comments.ts b/cypress/support/types/yves/comments.ts index ad871584..0c26cda0 100644 --- a/cypress/support/types/yves/comments.ts +++ b/cypress/support/types/yves/comments.ts @@ -1,8 +1,8 @@ -import { Customer, Product, Quote } from './shared'; +import { Customer, ProductConcrete, Quote } from './shared'; export interface CartCommentsDynamicFixtures { customer: Customer; - product: Product; + product: ProductConcrete; quote: Quote; emptyQuote: Quote; } diff --git a/cypress/support/types/yves/index.ts b/cypress/support/types/yves/index.ts index 6f046e28..cfd54498 100644 --- a/cypress/support/types/yves/index.ts +++ b/cypress/support/types/yves/index.ts @@ -1,2 +1,3 @@ export * from './checkout'; export * from './comments'; +export * from './merchant-b2b-contract-requests'; diff --git a/cypress/support/types/yves/merchant-b2b-contract-requests.ts b/cypress/support/types/yves/merchant-b2b-contract-requests.ts new file mode 100644 index 00000000..f9e869ff --- /dev/null +++ b/cypress/support/types/yves/merchant-b2b-contract-requests.ts @@ -0,0 +1,48 @@ +import { + Company, + CompanyBusinessUnit, + CompanyUser, + Customer, + Merchant, + ProductConcrete, + ProductOffer, + Url, + User, +} from './shared'; + +export interface RequestCreationDynamicFixtures { + merchant1: Merchant; + merchantUrl1: Url; + merchantUser1FromMerchant1: User; + merchantUser2FromMerchant1: User; + + merchant2: Merchant; + merchantUrl2: Url; + merchantUserFromMerchant2: User; + + merchant3: Merchant; + merchantUrl3: Url; + merchantUserFromMerchant3: User; + + concreteProduct: ProductConcrete; + productOfferFromMerchant1: ProductOffer; + productOfferFromMerchant2: ProductOffer; + productOfferFromMerchant3: ProductOffer; + + customer: Customer; + + company1: Company; + businessUnit1FromCompany1: CompanyBusinessUnit; + businessUnit2FromCompany1: CompanyBusinessUnit; + companyUser1FromCompany1: CompanyUser; + companyUser2FromCompany1: CompanyUser; + + company2: Company; + businessUnit1FromCompany2: CompanyBusinessUnit; + businessUnit2FromCompany2: CompanyBusinessUnit; + companyUser1FromCompany2: CompanyUser; +} + +export interface MerchantB2bContractRequestsStaticFixtures { + defaultPassword: string; +} diff --git a/cypress/support/types/yves/shared/company-business-unit.ts b/cypress/support/types/yves/shared/company-business-unit.ts new file mode 100644 index 00000000..76bffdf3 --- /dev/null +++ b/cypress/support/types/yves/shared/company-business-unit.ts @@ -0,0 +1,5 @@ +export interface CompanyBusinessUnit { + id_company_business_unit: number; + key: string; + name: string; +} diff --git a/cypress/support/types/yves/shared/company-user.ts b/cypress/support/types/yves/shared/company-user.ts new file mode 100644 index 00000000..250de7f7 --- /dev/null +++ b/cypress/support/types/yves/shared/company-user.ts @@ -0,0 +1,3 @@ +export interface CompanyUser { + id_company_user: number; +} diff --git a/cypress/support/types/yves/shared/company.ts b/cypress/support/types/yves/shared/company.ts new file mode 100644 index 00000000..5bb94f87 --- /dev/null +++ b/cypress/support/types/yves/shared/company.ts @@ -0,0 +1,4 @@ +export interface Company { + key: string; + name: string; +} diff --git a/cypress/support/types/yves/shared/index.ts b/cypress/support/types/yves/shared/index.ts index d1eab8c2..90f606c5 100644 --- a/cypress/support/types/yves/shared/index.ts +++ b/cypress/support/types/yves/shared/index.ts @@ -1,4 +1,11 @@ export * from './address'; export * from './customer'; -export * from './product'; +export * from './product-concrete'; export * from './quote'; +export * from './company'; +export * from './company-user'; +export * from './company-business-unit'; +export * from './product-offer'; +export * from './url'; +export * from './merchant'; +export * from './user'; diff --git a/cypress/support/types/yves/shared/merchant.ts b/cypress/support/types/yves/shared/merchant.ts new file mode 100644 index 00000000..51f3787b --- /dev/null +++ b/cypress/support/types/yves/shared/merchant.ts @@ -0,0 +1,4 @@ +export interface Merchant { + merchant_reference: string; + name: string; +} diff --git a/cypress/support/types/yves/shared/product.ts b/cypress/support/types/yves/shared/product-concrete.ts similarity index 67% rename from cypress/support/types/yves/shared/product.ts rename to cypress/support/types/yves/shared/product-concrete.ts index 47e94acf..801a31a3 100644 --- a/cypress/support/types/yves/shared/product.ts +++ b/cypress/support/types/yves/shared/product-concrete.ts @@ -1,4 +1,4 @@ -export interface Product { +export interface ProductConcrete { id_product_concrete: number; sku: string; abstract_sku: string; diff --git a/cypress/support/types/yves/shared/product-offer.ts b/cypress/support/types/yves/shared/product-offer.ts new file mode 100644 index 00000000..4bd9a025 --- /dev/null +++ b/cypress/support/types/yves/shared/product-offer.ts @@ -0,0 +1,3 @@ +export interface ProductOffer { + product_offer_reference: string; +} diff --git a/cypress/support/types/yves/shared/url.ts b/cypress/support/types/yves/shared/url.ts new file mode 100644 index 00000000..1b6cc537 --- /dev/null +++ b/cypress/support/types/yves/shared/url.ts @@ -0,0 +1,3 @@ +export interface Url { + url: string; +} diff --git a/cypress/support/types/yves/shared/user.ts b/cypress/support/types/yves/shared/user.ts new file mode 100644 index 00000000..63f2a4e3 --- /dev/null +++ b/cypress/support/types/yves/shared/user.ts @@ -0,0 +1,5 @@ +export interface User { + username: string; + first_name: string; + last_name: string; +} diff --git a/cypress/support/utils/inversify/inversify.config.ts b/cypress/support/utils/inversify/inversify.config.ts index d3ea0ddf..24283ad0 100644 --- a/cypress/support/utils/inversify/inversify.config.ts +++ b/cypress/support/utils/inversify/inversify.config.ts @@ -17,6 +17,12 @@ import { B2bLoginRepository } from '../../pages/yves/login/repositories/b2b-logi import { SuiteLoginRepository } from '../../pages/yves/login/repositories/suite-login-repository'; import { B2bMultiCartRepository } from '../../pages/yves/multi-cart/repositories/b2b-multi-cart-repository'; import { SuiteMultiCartRepository } from '../../pages/yves/multi-cart/repositories/suite-multi-cart-repository'; +import { SuiteCatalogRepository } from '../../pages/yves/catalog/repositories/suite-catalog-repository'; +import { SuiteCompanyUserSelectRepository } from '../../pages/yves/company/user/select/repositories/suite-company-user-select-repository'; +import { SuiteMerchantRelationRequestCreateRepository } from '../../pages/yves/company/merchant-relation-request/create/repositories/suite-merchant-relation-request-create-repository'; +import { SuiteMerchantRelationRequestDetailsRepository } from '../../pages/yves/company/merchant-relation-request/details/repositories/suite-merchant-relation-request-details-repository'; +import { SuiteMerchantRepository } from '../../pages/yves/merchant/repositories/suite-merchant-repository'; +import { SuiteMerchantRelationRequestIndexRepository } from '../../pages/yves/company/merchant-relation-request/index/repositories/suite-merchant-relation-request-index-repository'; type BindingsMap = { [K in REPOSITORIES]?: interfaces.Newable }; @@ -31,6 +37,12 @@ const suiteMappings: BindingsMap = { [REPOSITORIES.CheckoutPaymentRepository]: SuiteCheckoutPaymentRepository, [REPOSITORIES.CheckoutSummaryRepository]: SuiteCheckoutSummaryRepository, [REPOSITORIES.AgentLoginRepository]: SuiteAgentLoginRepository, + [REPOSITORIES.CatalogRepository]: SuiteCatalogRepository, + [REPOSITORIES.CompanyUserSelectRepository]: SuiteCompanyUserSelectRepository, + [REPOSITORIES.MerchantRelationRequestCreateRepository]: SuiteMerchantRelationRequestCreateRepository, + [REPOSITORIES.MerchantRelationRequestDetailsRepository]: SuiteMerchantRelationRequestDetailsRepository, + [REPOSITORIES.MerchantRelationRequestIndexRepository]: SuiteMerchantRelationRequestIndexRepository, + [REPOSITORIES.MerchantRepository]: SuiteMerchantRepository, }; const b2bMappings: BindingsMap = { diff --git a/cypress/support/utils/inversify/types.ts b/cypress/support/utils/inversify/types.ts index 69cfb2be..005096d0 100644 --- a/cypress/support/utils/inversify/types.ts +++ b/cypress/support/utils/inversify/types.ts @@ -9,4 +9,10 @@ export const enum REPOSITORIES { CheckoutPaymentRepository = 'CheckoutPaymentRepository', CheckoutSummaryRepository = 'CheckoutSummaryRepository', AgentLoginRepository = 'AgentLoginRepository', + CatalogRepository = 'CatalogRepository', + CompanyUserSelectRepository = 'CompanyUserSelectRepository', + MerchantRelationRequestCreateRepository = 'MerchantRelationRequestCreateRepository', + MerchantRelationRequestDetailsRepository = 'MerchantRelationRequestDetailsRepository', + MerchantRelationRequestIndexRepository = 'MerchantRelationRequestIndexRepository', + MerchantRepository = 'MerchantRepository', } From 1fd12ed167bf53467a67fd2f39a1ead13d2e5dd6 Mon Sep 17 00:00:00 2001 From: Dmytro Asieiev Date: Tue, 19 Mar 2024 14:57:54 +0300 Subject: [PATCH 2/7] Added management scenario from company user [skip ci] --- .../request-management.cy.ts | 148 +++++ .../__dummy.json | 456 +++++++++++++++ .../dynamic-request-creation.json | 44 -- .../dynamic-request-management.json | 534 ++++++++++++++++++ .../static-request-management.json | 3 + .../merchant-relation-request-details-page.ts | 4 + ...ant-relation-request-details-repository.ts | 4 +- ...ant-relation-request-details-repository.ts | 4 +- .../merchant-relation-request-index-page.ts | 30 + ...chant-relation-request-index-repository.ts | 6 + ...chant-relation-request-index-repository.ts | 9 + .../yves/merchant-b2b-contract-requests.ts | 54 ++ cypress/support/types/yves/shared/customer.ts | 2 + cypress/support/types/yves/shared/index.ts | 1 + .../yves/shared/merchant-relation-request.ts | 4 + cypress/support/types/yves/shared/merchant.ts | 1 + package-lock.json | 8 +- package.json | 2 +- 18 files changed, 1263 insertions(+), 51 deletions(-) create mode 100644 cypress/e2e/yves/merchant-b2b-contract-requests/request-management.cy.ts create mode 100644 cypress/fixtures/suite/yves/merchant-b2b-contract-requests/__dummy.json create mode 100644 cypress/fixtures/suite/yves/merchant-b2b-contract-requests/dynamic-request-management.json create mode 100644 cypress/fixtures/suite/yves/merchant-b2b-contract-requests/static-request-management.json create mode 100644 cypress/support/types/yves/shared/merchant-relation-request.ts diff --git a/cypress/e2e/yves/merchant-b2b-contract-requests/request-management.cy.ts b/cypress/e2e/yves/merchant-b2b-contract-requests/request-management.cy.ts new file mode 100644 index 00000000..eba332fd --- /dev/null +++ b/cypress/e2e/yves/merchant-b2b-contract-requests/request-management.cy.ts @@ -0,0 +1,148 @@ +import { container } from '@utils'; +import { + CompanyUserSelectPage, + MerchantRelationRequestDetailsPage, + MerchantRelationRequestIndexPage, +} from '../../../support/pages/yves'; +import { CustomerLoginScenario } from '../../../support/scenarios/yves'; +import { + MerchantB2bContractRequestsStaticFixtures, + RequestManagementDynamicFixtures, +} from '../../../support/types/yves'; + +/** + * Merchant Relation Requests & Enhanced Merchant Relations checklists: {@link https://spryker.atlassian.net/wiki/spaces/CCS/pages/4105896492/Business+Journey+B2B+Marketplace+-+to+automate} + */ +describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, (): void => { + const companyUserSelectPage = container.get(CompanyUserSelectPage); + const merchantRelationRequestIndexPage = container.get(MerchantRelationRequestIndexPage); + const merchantRelationRequestDetailsPage = container.get(MerchantRelationRequestDetailsPage); + const customerLoginScenario = container.get(CustomerLoginScenario); + + let dynamicFixtures: RequestManagementDynamicFixtures; + let staticFixtures: MerchantB2bContractRequestsStaticFixtures; + + before((): void => { + ({ dynamicFixtures, staticFixtures } = Cypress.env()); + }); + + beforeEach((): void => { + customerLoginScenario.execute({ + email: dynamicFixtures.customer.email, + password: staticFixtures.defaultPassword, + }); + companyUserSelectPage.visit(); + }); + + it('company user should be able to filter MR requests by status', (): void => { + companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany1.id_company_user); + const statuses = ['Pending', 'Canceled', 'Approved', 'Rejected']; + + statuses.forEach((status: string): void => { + merchantRelationRequestIndexPage.visit(); + merchantRelationRequestIndexPage.filterRequests({ status: status.toLowerCase() }); + const foundRequest = merchantRelationRequestIndexPage.getFirstRequest(); + + foundRequest.should('contain', status); + foundRequest.should('contain', dynamicFixtures.merchant1.name); + foundRequest.should('contain', dynamicFixtures.customer.first_name + ' ' + dynamicFixtures.customer.last_name); + foundRequest.should('contain', dynamicFixtures.businessUnit1FromCompany1.name); + }); + }); + + it('company user should be able to filter MR requests by merchant', (): void => { + companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany2.id_company_user); + const merchants = [dynamicFixtures.merchant1, dynamicFixtures.merchant2]; + + merchants.forEach((merchant): void => { + merchantRelationRequestIndexPage.visit(); + merchantRelationRequestIndexPage.filterRequests({ idMerchant: merchant.id_merchant }); + const foundRequest = merchantRelationRequestIndexPage.getFirstRequest(); + + foundRequest.should('contain', 'Canceled'); + foundRequest.should('contain', merchant.name); + foundRequest.should('contain', dynamicFixtures.customer.first_name + ' ' + dynamicFixtures.customer.last_name); + foundRequest.should('contain', dynamicFixtures.businessUnit1FromCompany2.name); + }); + }); + + it('company user should be able to filter MR requests by business unit owner', (): void => { + companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany2.id_company_user); + const businessUnits = [dynamicFixtures.businessUnit1FromCompany2, dynamicFixtures.businessUnit2FromCompany2]; + + businessUnits.forEach((businessUnit): void => { + merchantRelationRequestIndexPage.visit(); + merchantRelationRequestIndexPage.filterRequests({ + idMerchant: dynamicFixtures.merchant3.id_merchant, + idBusinessUnitOwner: businessUnit.id_company_business_unit, + }); + + const foundRequest = merchantRelationRequestIndexPage.getFirstRequest(); + + foundRequest.should('contain', 'Approved'); + foundRequest.should('contain', dynamicFixtures.merchant3.name); + foundRequest.should('contain', dynamicFixtures.customer.first_name + ' ' + dynamicFixtures.customer.last_name); + foundRequest.should('contain', businessUnit.name); + }); + }); + + it('company user from same company should be able to see requests from another user', (): void => { + companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser2FromCompany1.id_company_user); + + merchantRelationRequestIndexPage.visit(); + merchantRelationRequestIndexPage.getFirstRequest().should('exist'); + }); + + it('company user from same company should not be able to cancel request from another user', (): void => { + companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser2FromCompany1.id_company_user); + + merchantRelationRequestIndexPage.visit(); + merchantRelationRequestIndexPage.filterRequests({ status: 'pending' }); + merchantRelationRequestIndexPage.openFirstRequest(); + + merchantRelationRequestDetailsPage.getCancelButton().should('not.exist'); + }); + + it('company user should not be able to cancel request from canceled status', (): void => { + companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany1.id_company_user); + + merchantRelationRequestIndexPage.visit(); + merchantRelationRequestIndexPage.filterRequests({ status: 'canceled' }); + merchantRelationRequestIndexPage.openFirstRequest(); + + merchantRelationRequestDetailsPage.getCancelButton().should('not.exist'); + }); + + it('company user should not be able to cancel request from approved status', (): void => { + companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany1.id_company_user); + + merchantRelationRequestIndexPage.visit(); + merchantRelationRequestIndexPage.filterRequests({ status: 'approved' }); + merchantRelationRequestIndexPage.openFirstRequest(); + + merchantRelationRequestDetailsPage.getCancelButton().should('not.exist'); + }); + + it('company user should not be able to cancel request from rejected status', (): void => { + companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany1.id_company_user); + + merchantRelationRequestIndexPage.visit(); + merchantRelationRequestIndexPage.filterRequests({ status: 'rejected' }); + merchantRelationRequestIndexPage.openFirstRequest(); + + merchantRelationRequestDetailsPage.getCancelButton().should('not.exist'); + }); + + it('company user should be able to cancel request from pending status', (): void => { + companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany1.id_company_user); + + merchantRelationRequestIndexPage.visit(); + merchantRelationRequestIndexPage.filterRequests({ status: 'pending' }); + merchantRelationRequestIndexPage.openFirstRequest(); + + merchantRelationRequestDetailsPage.getCancelButton().should('exist'); + merchantRelationRequestDetailsPage.getCancelButton().click(); + + merchantRelationRequestIndexPage.assertPageLocation(); + }); +}); diff --git a/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/__dummy.json b/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/__dummy.json new file mode 100644 index 00000000..cde00a84 --- /dev/null +++ b/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/__dummy.json @@ -0,0 +1,456 @@ +{ + "data": { + "type": "dynamic-fixtures", + "attributes": { + "synchronize": true, + "operations": [ + { + "type": "transfer", + "name": "LocaleTransfer", + "key": "localeEN", + "arguments": { "id_locale": 66, "locale_name": "en_US" } + }, + { + "type": "transfer", + "name": "LocaleTransfer", + "key": "localeDE", + "arguments": { "id_locale": 46, "locale_name": "de_DE" } + }, + { + "type": "builder", + "name": "LocalizedAttributesBuilder", + "key": "localizedAttribute" + }, + { + "type": "transfer", + "name": "StoreTransfer", + "key": "store", + "arguments": { "id_store": 1, "name": "DE" } + }, + { + "type": "array-object", + "key": "stores", + "arguments": ["#store"] + }, + { + "type": "helper", + "name": "haveUser", + "key": "merchantUser1FromMerchant1", + "arguments": [{ "password": "change123" }] + }, + { + "type": "helper", + "name": "haveUser", + "key": "merchantUser2FromMerchant1", + "arguments": [{ "password": "change123" }] + }, + { + "type": "builder", + "name": "MerchantProfileBuilder", + "key": "merchantProfile1" + }, + { + "type": "helper", + "name": "haveMerchant", + "key": "merchant1", + "arguments": [ + { + "merchantProfile": "#merchantProfile1", + "isActive": true, + "isOpenForRelationRequest": true, + "status": "approved", + "storeRelation": { + "idStores": ["#store.id_store"] + } + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "key": "merchantUrl1", + "arguments": [ + { + "fkLocale": "#localeEN.id_locale", + "fkResourceMerchant": "#merchant1.id_merchant", + "urlPrefix": "/en/merchant/dummy-en-prefix-", + "url": "#merchant1.name" + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "arguments": [ + { + "fkLocale": "#localeDE.id_locale", + "fkResourceMerchant": "#merchant1.id_merchant", + "urlPrefix": "/de/merchant/dummy-de-prefix-", + "url": "#merchant1.name" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantUserWithAclEntities", + "arguments": ["#merchant1", "#merchantUser1FromMerchant1"] + }, + { + "type": "helper", + "name": "haveMerchantUserWithAclEntities", + "arguments": ["#merchant1", "#merchantUser2FromMerchant1"] + }, + { + "type": "helper", + "name": "haveUser", + "key": "merchantUserFromMerchant2", + "arguments": [{ "password": "change123" }] + }, + { + "type": "builder", + "name": "MerchantProfileBuilder", + "key": "merchantProfile2" + }, + { + "type": "helper", + "name": "haveMerchant", + "key": "merchant2", + "arguments": [ + { + "merchantProfile": "#merchantProfile2", + "isActive": true, + "isOpenForRelationRequest": true, + "status": "approved", + "storeRelation": { + "idStores": ["#store.id_store"] + } + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "key": "merchantUrl2", + "arguments": [ + { + "fkLocale": "#localeEN.id_locale", + "fkResourceMerchant": "#merchant2.id_merchant", + "urlPrefix": "/en/merchant/dummy-en-prefix-", + "url": "#merchant2.name" + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "arguments": [ + { + "fkLocale": "#localeDE.id_locale", + "fkResourceMerchant": "#merchant2.id_merchant", + "urlPrefix": "/de/merchant/dummy-de-prefix-", + "url": "#merchant2.name" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantUserWithAclEntities", + "arguments": ["#merchant2", "#merchantUserFromMerchant2"] + }, + { + "type": "helper", + "name": "haveUser", + "key": "merchantUserFromMerchant3", + "arguments": [{ "password": "change123" }] + }, + { + "type": "builder", + "name": "MerchantProfileBuilder", + "key": "merchantProfile3" + }, + { + "type": "helper", + "name": "haveMerchant", + "key": "merchant3", + "arguments": [ + { + "merchantProfile": "#merchantProfile3", + "isActive": true, + "isOpenForRelationRequest": false, + "status": "approved", + "storeRelation": { + "idStores": ["#store.id_store"] + } + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "key": "merchantUrl3", + "arguments": [ + { + "fkLocale": "#localeEN.id_locale", + "fkResourceMerchant": "#merchant3.id_merchant", + "urlPrefix": "/en/merchant/dummy-en-prefix-", + "url": "#merchant3.name" + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "arguments": [ + { + "fkLocale": "#localeDE.id_locale", + "fkResourceMerchant": "#merchant3.id_merchant", + "urlPrefix": "/de/merchant/dummy-de-prefix-", + "url": "#merchant3.name" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantUserWithAclEntities", + "arguments": ["#merchant3", "#merchantUserFromMerchant3"] + }, + { + "type": "transfer", + "name": "ProductImageTransfer", + "key": "productImage", + "arguments": { + "externalUrlSmall": "https://images.icecat.biz/img/gallery_mediums/30691822_1486.jpg", + "externalUrlLarge": "https://images.icecat.biz/img/gallery/30691822_1486.jpg" + } + }, + { + "type": "helper", + "name": "haveFullProduct", + "key": "concreteProduct", + "arguments": [ + {}, + { + "idTaxSet": 1, + "localizedAttributes": [ + { "locale": "#localeEN", "name": "#localizedAttribute.name" }, + { "locale": "#localeDE", "name": "#localizedAttribute.name" } + ] + } + ] + }, + { + "type": "helper", + "name": "haveProductImageSet", + "arguments": [ + { + "name": "default", + "idProduct": "#concreteProduct.id_product_concrete", + "idProductAbstract": "#concreteProduct.fk_product_abstract", + "productImages": ["#productImage"] + } + ] + }, + { + "type": "helper", + "name": "havePriceProduct", + "arguments": [ + { + "skuProductAbstract": "#concreteProduct.abstract_sku", + "skuProduct": "#concreteProduct.sku", + "moneyValue": { "netAmount": 30000, "grossAmount": 30000 } + } + ] + }, + { + "type": "helper", + "name": "haveProductOffer", + "key": "productOfferFromMerchant1", + "arguments": [ + { + "isActive": true, + "status": "approved", + "idProductConcrete": "#concreteProduct.id_product_concrete", + "concreteSku": "#concreteProduct.sku", + "merchantReference": "#merchant1.merchant_reference", + "stores": "#stores" + } + ] + }, + { + "type": "helper", + "name": "haveProductOfferStock", + "arguments": [ + { + "idProductOffer": "#productOfferFromMerchant1.id_product_offer", + "productOfferReference": "#productOfferFromMerchant1.product_offer_reference", + "isNeverOutOfStock": true + }, + "#merchant1.stocks" + ] + }, + { + "type": "helper", + "name": "haveProductOffer", + "key": "productOfferFromMerchant2", + "arguments": [ + { + "isActive": true, + "status": "approved", + "idProductConcrete": "#concreteProduct.id_product_concrete", + "concreteSku": "#concreteProduct.sku", + "merchantReference": "#merchant2.merchant_reference", + "stores": "#stores" + } + ] + }, + { + "type": "helper", + "name": "haveProductOfferStock", + "arguments": [ + { + "idProductOffer": "#productOfferFromMerchant2.id_product_offer", + "productOfferReference": "#productOfferFromMerchant2.product_offer_reference", + "isNeverOutOfStock": true + }, + "#merchant2.stocks" + ] + }, + { + "type": "helper", + "name": "haveProductOffer", + "key": "productOfferFromMerchant3", + "arguments": [ + { + "isActive": true, + "status": "approved", + "idProductConcrete": "#concreteProduct.id_product_concrete", + "concreteSku": "#concreteProduct.sku", + "merchantReference": "#merchant3.merchant_reference", + "stores": "#stores" + } + ] + }, + { + "type": "helper", + "name": "haveProductOfferStock", + "arguments": [ + { + "idProductOffer": "#productOfferFromMerchant3.id_product_offer", + "productOfferReference": "#productOfferFromMerchant3.product_offer_reference", + "isNeverOutOfStock": true + }, + "#merchant3.stocks" + ] + }, + { + "type": "helper", + "name": "haveCountry", + "key": "country" + }, + { + "type": "helper", + "name": "haveCustomer", + "key": "customer", + "arguments": [{ "locale": "#localeEN", "password": "change123" }] + }, + { + "type": "helper", + "name": "confirmCustomer", + "key": "confirmedCustomer", + "arguments": ["#customer"] + }, + { + "type": "helper", + "name": "haveCompany", + "key": "company1", + "arguments": [{ "isActive": true, "status": "approved" }] + }, + { + "type": "helper", + "name": "haveCompany", + "key": "company2", + "arguments": [{ "isActive": true, "status": "approved" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit1FromCompany1", + "arguments": [{ "fkCompany": "#company1.id_company" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit2FromCompany1", + "arguments": [{ "fkCompany": "#company1.id_company" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit1FromCompany2", + "arguments": [{ "fkCompany": "#company2.id_company" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit2FromCompany2", + "arguments": [{ "fkCompany": "#company2.id_company" }] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission", + "arguments": ["CreateMerchantRelationRequestPermissionPlugin"] + }, + { + "type": "helper", + "name": "haveCompanyRoleWithPermissions", + "arguments": [{ "isDefault": true, "fkCompany": "#company1.id_company" }, ["#permission"]] + }, + { + "type": "helper", + "name": "haveCompanyRoleWithPermissions", + "arguments": [{ "isDefault": true, "fkCompany": "#company2.id_company" }, ["#permission"]] + }, + { + "type": "helper", + "name": "haveCompanyUser", + "key": "companyUser1FromCompany1", + "arguments": [ + { + "customer": "#customer", + "fkCustomer": "#customer.id_customer", + "fkCompany": "#company1.id_company", + "fkCompanyBusinessUnit": "#businessUnit1FromCompany1.id_company_business_unit" + } + ] + }, + { + "type": "helper", + "name": "haveCompanyUser", + "key": "companyUser2FromCompany1", + "arguments": [ + { + "customer": "#customer", + "fkCustomer": "#customer.id_customer", + "fkCompany": "#company1.id_company", + "fkCompanyBusinessUnit": "#businessUnit2FromCompany1.id_company_business_unit" + } + ] + }, + { + "type": "helper", + "name": "haveCompanyUser", + "key": "companyUser1FromCompany2", + "arguments": [ + { + "customer": "#customer", + "fkCustomer": "#customer.id_customer", + "fkCompany": "#company2.id_company", + "fkCompanyBusinessUnit": "#businessUnit1FromCompany2.id_company_business_unit" + } + ] + } + ] + } + } +} diff --git a/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/dynamic-request-creation.json b/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/dynamic-request-creation.json index cde00a84..0660af56 100644 --- a/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/dynamic-request-creation.json +++ b/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/dynamic-request-creation.json @@ -32,18 +32,6 @@ "key": "stores", "arguments": ["#store"] }, - { - "type": "helper", - "name": "haveUser", - "key": "merchantUser1FromMerchant1", - "arguments": [{ "password": "change123" }] - }, - { - "type": "helper", - "name": "haveUser", - "key": "merchantUser2FromMerchant1", - "arguments": [{ "password": "change123" }] - }, { "type": "builder", "name": "MerchantProfileBuilder", @@ -90,22 +78,6 @@ } ] }, - { - "type": "helper", - "name": "haveMerchantUserWithAclEntities", - "arguments": ["#merchant1", "#merchantUser1FromMerchant1"] - }, - { - "type": "helper", - "name": "haveMerchantUserWithAclEntities", - "arguments": ["#merchant1", "#merchantUser2FromMerchant1"] - }, - { - "type": "helper", - "name": "haveUser", - "key": "merchantUserFromMerchant2", - "arguments": [{ "password": "change123" }] - }, { "type": "builder", "name": "MerchantProfileBuilder", @@ -152,17 +124,6 @@ } ] }, - { - "type": "helper", - "name": "haveMerchantUserWithAclEntities", - "arguments": ["#merchant2", "#merchantUserFromMerchant2"] - }, - { - "type": "helper", - "name": "haveUser", - "key": "merchantUserFromMerchant3", - "arguments": [{ "password": "change123" }] - }, { "type": "builder", "name": "MerchantProfileBuilder", @@ -209,11 +170,6 @@ } ] }, - { - "type": "helper", - "name": "haveMerchantUserWithAclEntities", - "arguments": ["#merchant3", "#merchantUserFromMerchant3"] - }, { "type": "transfer", "name": "ProductImageTransfer", diff --git a/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/dynamic-request-management.json b/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/dynamic-request-management.json new file mode 100644 index 00000000..0a57820a --- /dev/null +++ b/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/dynamic-request-management.json @@ -0,0 +1,534 @@ +{ + "data": { + "type": "dynamic-fixtures", + "attributes": { + "synchronize": true, + "operations": [ + { + "type": "transfer", + "name": "LocaleTransfer", + "key": "localeEN", + "arguments": { "id_locale": 66, "locale_name": "en_US" } + }, + { + "type": "transfer", + "name": "LocaleTransfer", + "key": "localeDE", + "arguments": { "id_locale": 46, "locale_name": "de_DE" } + }, + { + "type": "builder", + "name": "LocalizedAttributesBuilder", + "key": "localizedAttribute" + }, + { + "type": "transfer", + "name": "StoreTransfer", + "key": "store", + "arguments": { "id_store": 1, "name": "DE" } + }, + { + "type": "array-object", + "key": "stores", + "arguments": ["#store"] + }, + { + "type": "builder", + "name": "MerchantProfileBuilder", + "key": "merchantProfile1" + }, + { + "type": "helper", + "name": "haveMerchant", + "key": "merchant1", + "arguments": [ + { + "merchantProfile": "#merchantProfile1", + "isActive": true, + "isOpenForRelationRequest": true, + "status": "approved", + "storeRelation": { + "idStores": ["#store.id_store"] + } + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "key": "merchantUrl1", + "arguments": [ + { + "fkLocale": "#localeEN.id_locale", + "fkResourceMerchant": "#merchant1.id_merchant", + "urlPrefix": "/en/merchant/dummy-en-prefix-", + "url": "#merchant1.name" + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "arguments": [ + { + "fkLocale": "#localeDE.id_locale", + "fkResourceMerchant": "#merchant1.id_merchant", + "urlPrefix": "/de/merchant/dummy-de-prefix-", + "url": "#merchant1.name" + } + ] + }, + { + "type": "builder", + "name": "MerchantProfileBuilder", + "key": "merchantProfile2" + }, + { + "type": "helper", + "name": "haveMerchant", + "key": "merchant2", + "arguments": [ + { + "merchantProfile": "#merchantProfile2", + "isActive": true, + "isOpenForRelationRequest": true, + "status": "approved", + "storeRelation": { + "idStores": ["#store.id_store"] + } + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "key": "merchantUrl2", + "arguments": [ + { + "fkLocale": "#localeEN.id_locale", + "fkResourceMerchant": "#merchant2.id_merchant", + "urlPrefix": "/en/merchant/dummy-en-prefix-", + "url": "#merchant2.name" + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "arguments": [ + { + "fkLocale": "#localeDE.id_locale", + "fkResourceMerchant": "#merchant2.id_merchant", + "urlPrefix": "/de/merchant/dummy-de-prefix-", + "url": "#merchant2.name" + } + ] + }, + { + "type": "builder", + "name": "MerchantProfileBuilder", + "key": "merchantProfile3" + }, + { + "type": "helper", + "name": "haveMerchant", + "key": "merchant3", + "arguments": [ + { + "merchantProfile": "#merchantProfile3", + "isActive": true, + "isOpenForRelationRequest": false, + "status": "approved", + "storeRelation": { + "idStores": ["#store.id_store"] + } + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "key": "merchantUrl3", + "arguments": [ + { + "fkLocale": "#localeEN.id_locale", + "fkResourceMerchant": "#merchant3.id_merchant", + "urlPrefix": "/en/merchant/dummy-en-prefix-", + "url": "#merchant3.name" + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "arguments": [ + { + "fkLocale": "#localeDE.id_locale", + "fkResourceMerchant": "#merchant3.id_merchant", + "urlPrefix": "/de/merchant/dummy-de-prefix-", + "url": "#merchant3.name" + } + ] + }, + { + "type": "transfer", + "name": "ProductImageTransfer", + "key": "productImage", + "arguments": { + "externalUrlSmall": "https://images.icecat.biz/img/gallery_mediums/30691822_1486.jpg", + "externalUrlLarge": "https://images.icecat.biz/img/gallery/30691822_1486.jpg" + } + }, + { + "type": "helper", + "name": "haveFullProduct", + "key": "concreteProduct", + "arguments": [ + {}, + { + "idTaxSet": 1, + "localizedAttributes": [ + { "locale": "#localeEN", "name": "#localizedAttribute.name" }, + { "locale": "#localeDE", "name": "#localizedAttribute.name" } + ] + } + ] + }, + { + "type": "helper", + "name": "haveProductImageSet", + "arguments": [ + { + "name": "default", + "idProduct": "#concreteProduct.id_product_concrete", + "idProductAbstract": "#concreteProduct.fk_product_abstract", + "productImages": ["#productImage"] + } + ] + }, + { + "type": "helper", + "name": "havePriceProduct", + "arguments": [ + { + "skuProductAbstract": "#concreteProduct.abstract_sku", + "skuProduct": "#concreteProduct.sku", + "moneyValue": { "netAmount": 30000, "grossAmount": 30000 } + } + ] + }, + { + "type": "helper", + "name": "haveProductOffer", + "key": "productOfferFromMerchant1", + "arguments": [ + { + "isActive": true, + "status": "approved", + "idProductConcrete": "#concreteProduct.id_product_concrete", + "concreteSku": "#concreteProduct.sku", + "merchantReference": "#merchant1.merchant_reference", + "stores": "#stores" + } + ] + }, + { + "type": "helper", + "name": "haveProductOfferStock", + "arguments": [ + { + "idProductOffer": "#productOfferFromMerchant1.id_product_offer", + "productOfferReference": "#productOfferFromMerchant1.product_offer_reference", + "isNeverOutOfStock": true + }, + "#merchant1.stocks" + ] + }, + { + "type": "helper", + "name": "haveProductOffer", + "key": "productOfferFromMerchant2", + "arguments": [ + { + "isActive": true, + "status": "approved", + "idProductConcrete": "#concreteProduct.id_product_concrete", + "concreteSku": "#concreteProduct.sku", + "merchantReference": "#merchant2.merchant_reference", + "stores": "#stores" + } + ] + }, + { + "type": "helper", + "name": "haveProductOfferStock", + "arguments": [ + { + "idProductOffer": "#productOfferFromMerchant2.id_product_offer", + "productOfferReference": "#productOfferFromMerchant2.product_offer_reference", + "isNeverOutOfStock": true + }, + "#merchant2.stocks" + ] + }, + { + "type": "helper", + "name": "haveProductOffer", + "key": "productOfferFromMerchant3", + "arguments": [ + { + "isActive": true, + "status": "approved", + "idProductConcrete": "#concreteProduct.id_product_concrete", + "concreteSku": "#concreteProduct.sku", + "merchantReference": "#merchant3.merchant_reference", + "stores": "#stores" + } + ] + }, + { + "type": "helper", + "name": "haveProductOfferStock", + "arguments": [ + { + "idProductOffer": "#productOfferFromMerchant3.id_product_offer", + "productOfferReference": "#productOfferFromMerchant3.product_offer_reference", + "isNeverOutOfStock": true + }, + "#merchant3.stocks" + ] + }, + { + "type": "helper", + "name": "haveCountry", + "key": "country" + }, + { + "type": "helper", + "name": "haveCustomer", + "key": "customer", + "arguments": [{ "locale": "#localeEN", "password": "change123" }] + }, + { + "type": "helper", + "name": "confirmCustomer", + "key": "confirmedCustomer", + "arguments": ["#customer"] + }, + { + "type": "helper", + "name": "haveCompany", + "key": "company1", + "arguments": [{ "isActive": true, "status": "approved" }] + }, + { + "type": "helper", + "name": "haveCompany", + "key": "company2", + "arguments": [{ "isActive": true, "status": "approved" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit1FromCompany1", + "arguments": [{ "fkCompany": "#company1.id_company" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit2FromCompany1", + "arguments": [{ "fkCompany": "#company1.id_company" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit1FromCompany2", + "arguments": [{ "fkCompany": "#company2.id_company" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit2FromCompany2", + "arguments": [{ "fkCompany": "#company2.id_company" }] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission", + "arguments": ["CreateMerchantRelationRequestPermissionPlugin"] + }, + { + "type": "helper", + "name": "haveCompanyRoleWithPermissions", + "arguments": [{ "isDefault": true, "fkCompany": "#company1.id_company" }, ["#permission"]] + }, + { + "type": "helper", + "name": "haveCompanyRoleWithPermissions", + "arguments": [{ "isDefault": true, "fkCompany": "#company2.id_company" }, ["#permission"]] + }, + { + "type": "helper", + "name": "haveCompanyUser", + "key": "companyUser1FromCompany1", + "arguments": [ + { + "customer": "#customer", + "fkCustomer": "#customer.id_customer", + "fkCompany": "#company1.id_company", + "fkCompanyBusinessUnit": "#businessUnit1FromCompany1.id_company_business_unit" + } + ] + }, + { + "type": "helper", + "name": "haveCompanyUser", + "key": "companyUser2FromCompany1", + "arguments": [ + { + "customer": "#customer", + "fkCustomer": "#customer.id_customer", + "fkCompany": "#company1.id_company", + "fkCompanyBusinessUnit": "#businessUnit2FromCompany1.id_company_business_unit" + } + ] + }, + { + "type": "helper", + "name": "haveCompanyUser", + "key": "companyUser1FromCompany2", + "arguments": [ + { + "customer": "#customer", + "fkCustomer": "#customer.id_customer", + "fkCompany": "#company2.id_company", + "fkCompanyBusinessUnit": "#businessUnit1FromCompany2.id_company_business_unit" + } + ] + }, + { + "type": "array-object", + "key": "assigneeCompanyBusinessUnitsFromCompany1", + "arguments": ["#businessUnit1FromCompany1", "#businessUnit2FromCompany1"] + }, + { + "type": "array-object", + "key": "assigneeCompanyBusinessUnitsFromCompany2", + "arguments": ["#businessUnit1FromCompany2", "#businessUnit2FromCompany2"] + }, + { + "type": "helper", + "name": "haveMerchantRelationRequest", + "key": "pendingRequest", + "arguments": [ + { + "status": "pending", + "merchant": "#merchant1", + "companyUser": "#companyUser1FromCompany1", + "ownerCompanyBusinessUnit": "#businessUnit1FromCompany1", + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany1" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantRelationRequest", + "key": "canceledRequest", + "arguments": [ + { + "status": "canceled", + "merchant": "#merchant1", + "companyUser": "#companyUser1FromCompany1", + "ownerCompanyBusinessUnit": "#businessUnit1FromCompany1", + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany1" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantRelationRequest", + "key": "approvedRequest", + "arguments": [ + { + "status": "approved", + "merchant": "#merchant1", + "companyUser": "#companyUser1FromCompany1", + "ownerCompanyBusinessUnit": "#businessUnit1FromCompany1", + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany1" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantRelationRequest", + "key": "rejectedRequest", + "arguments": [ + { + "status": "rejected", + "merchant": "#merchant1", + "companyUser": "#companyUser1FromCompany1", + "ownerCompanyBusinessUnit": "#businessUnit1FromCompany1", + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany1" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantRelationRequest", + "key": "requestFromMerchant1", + "arguments": [ + { + "status": "canceled", + "merchant": "#merchant1", + "companyUser": "#companyUser1FromCompany2", + "ownerCompanyBusinessUnit": "#businessUnit1FromCompany2", + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany2" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantRelationRequest", + "key": "requestFromMerchant2", + "arguments": [ + { + "status": "canceled", + "merchant": "#merchant2", + "companyUser": "#companyUser1FromCompany2", + "ownerCompanyBusinessUnit": "#businessUnit1FromCompany2", + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany2" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantRelationRequest", + "key": "requestFromUnit1", + "arguments": [ + { + "status": "approved", + "merchant": "#merchant3", + "companyUser": "#companyUser1FromCompany2", + "ownerCompanyBusinessUnit": "#businessUnit1FromCompany2", + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany2" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantRelationRequest", + "key": "requestFromUnit2", + "arguments": [ + { + "status": "approved", + "merchant": "#merchant3", + "companyUser": "#companyUser1FromCompany2", + "ownerCompanyBusinessUnit": "#businessUnit2FromCompany2", + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany2" + } + ] + } + ] + } + } +} diff --git a/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/static-request-management.json b/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/static-request-management.json new file mode 100644 index 00000000..ba4339e8 --- /dev/null +++ b/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/static-request-management.json @@ -0,0 +1,3 @@ +{ + "defaultPassword": "change123" +} diff --git a/cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-page.ts b/cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-page.ts index e42ea6f8..6267e1fe 100644 --- a/cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-page.ts +++ b/cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-page.ts @@ -10,4 +10,8 @@ export class MerchantRelationRequestDetailsPage extends YvesPage { private repository: MerchantRelationRequestDetailsRepository; protected PAGE_URL = '/company/merchant-relation-request/details'; + + getCancelButton = (): Cypress.Chainable => { + return this.repository.getCancelButton(); + }; } diff --git a/cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-repository.ts b/cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-repository.ts index 5291571d..53463686 100644 --- a/cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-repository.ts +++ b/cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-repository.ts @@ -1 +1,3 @@ -export interface MerchantRelationRequestDetailsRepository {} +export interface MerchantRelationRequestDetailsRepository { + getCancelButton(): Cypress.Chainable; +} diff --git a/cypress/support/pages/yves/company/merchant-relation-request/details/repositories/suite-merchant-relation-request-details-repository.ts b/cypress/support/pages/yves/company/merchant-relation-request/details/repositories/suite-merchant-relation-request-details-repository.ts index d812aa5b..f4223994 100644 --- a/cypress/support/pages/yves/company/merchant-relation-request/details/repositories/suite-merchant-relation-request-details-repository.ts +++ b/cypress/support/pages/yves/company/merchant-relation-request/details/repositories/suite-merchant-relation-request-details-repository.ts @@ -2,4 +2,6 @@ import { injectable } from 'inversify'; import { MerchantRelationRequestDetailsRepository } from '../merchant-relation-request-details-repository'; @injectable() -export class SuiteMerchantRelationRequestDetailsRepository implements MerchantRelationRequestDetailsRepository {} +export class SuiteMerchantRelationRequestDetailsRepository implements MerchantRelationRequestDetailsRepository { + getCancelButton = (): Cypress.Chainable => cy.get('[data-qa="merchant-relation-request-cancel-button"]'); +} diff --git a/cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-page.ts b/cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-page.ts index 7fd17b71..116894e4 100644 --- a/cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-page.ts +++ b/cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-page.ts @@ -3,6 +3,12 @@ import { inject, injectable } from 'inversify'; import { YvesPage } from '../../../yves-page'; import { MerchantRelationRequestIndexRepository } from './merchant-relation-request-index-repository'; +interface MerchantRelationRequestFilterParams { + idMerchant?: number; + idBusinessUnitOwner?: number; + status?: string; +} + @injectable() @autoWired export class MerchantRelationRequestIndexPage extends YvesPage { @@ -14,4 +20,28 @@ export class MerchantRelationRequestIndexPage extends YvesPage { createMerchantRelationRequest = (): void => { this.repository.getMerchantRelationRequestButton().click(); }; + + filterRequests = (params: MerchantRelationRequestFilterParams): void => { + if (params.idMerchant) { + this.repository.getFilterMerchantSelect().select(params.idMerchant.toString()); + } + + if (params.idBusinessUnitOwner) { + this.repository.getFilterBusinessUnitOwnerSelect().select(params.idBusinessUnitOwner.toString()); + } + + if (params.status) { + this.repository.getFilterStatusSelect().select(params.status); + } + + this.repository.getApplyButton().click(); + }; + + getFirstRequest = (): Cypress.Chainable => { + return this.repository.getFirstTableRaw(); + }; + + openFirstRequest = (): Cypress.Chainable => { + return this.repository.getFirstTableRaw().find(this.repository.getViewLinkSelector()).click(); + }; } diff --git a/cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-repository.ts b/cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-repository.ts index 42c9f52e..1a4904e9 100644 --- a/cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-repository.ts +++ b/cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-repository.ts @@ -1,3 +1,9 @@ export interface MerchantRelationRequestIndexRepository { getMerchantRelationRequestButton(): Cypress.Chainable; + getFilterMerchantSelect(): Cypress.Chainable; + getFilterBusinessUnitOwnerSelect(): Cypress.Chainable; + getFilterStatusSelect(): Cypress.Chainable; + getApplyButton(): Cypress.Chainable; + getFirstTableRaw(): Cypress.Chainable; + getViewLinkSelector(): string; } diff --git a/cypress/support/pages/yves/company/merchant-relation-request/index/repositories/suite-merchant-relation-request-index-repository.ts b/cypress/support/pages/yves/company/merchant-relation-request/index/repositories/suite-merchant-relation-request-index-repository.ts index 572a2c3f..d01349a2 100644 --- a/cypress/support/pages/yves/company/merchant-relation-request/index/repositories/suite-merchant-relation-request-index-repository.ts +++ b/cypress/support/pages/yves/company/merchant-relation-request/index/repositories/suite-merchant-relation-request-index-repository.ts @@ -5,4 +5,13 @@ import { MerchantRelationRequestIndexRepository } from '../merchant-relation-req export class SuiteMerchantRelationRequestIndexRepository implements MerchantRelationRequestIndexRepository { getMerchantRelationRequestButton = (): Cypress.Chainable => cy.get('[data-qa="create-merchant-relation-request-button"]'); + getFilterMerchantSelect = (): Cypress.Chainable => cy.get('#merchantRelationRequestSearchForm_filters_merchant'); + getFilterBusinessUnitOwnerSelect = (): Cypress.Chainable => + cy.get('#merchantRelationRequestSearchForm_filters_owner_business_unit'); + getFilterStatusSelect = (): Cypress.Chainable => cy.get('#merchantRelationRequestSearchForm_filters_status'); + getApplyButton = (): Cypress.Chainable => + cy.get('form[name=merchantRelationRequestSearchForm]').find('[name="buttonSubmit"]'); + getFirstTableRaw = (): Cypress.Chainable => + cy.get('[data-qa="component merchant-relation-request-view-table"] tbody tr:first-child'); + getViewLinkSelector = (): string => '[data-qa="merchant-relation-request-view-link"]'; } diff --git a/cypress/support/types/yves/merchant-b2b-contract-requests.ts b/cypress/support/types/yves/merchant-b2b-contract-requests.ts index f9e869ff..e66e419c 100644 --- a/cypress/support/types/yves/merchant-b2b-contract-requests.ts +++ b/cypress/support/types/yves/merchant-b2b-contract-requests.ts @@ -4,6 +4,7 @@ import { CompanyUser, Customer, Merchant, + MerchantRelationRequest, ProductConcrete, ProductOffer, Url, @@ -11,6 +12,59 @@ import { } from './shared'; export interface RequestCreationDynamicFixtures { + merchant1: Merchant; + merchantUrl1: Url; + merchant2: Merchant; + merchantUrl2: Url; + merchant3: Merchant; + merchantUrl3: Url; + + concreteProduct: ProductConcrete; + productOfferFromMerchant1: ProductOffer; + productOfferFromMerchant2: ProductOffer; + productOfferFromMerchant3: ProductOffer; + + customer: Customer; + + businessUnit1FromCompany1: CompanyBusinessUnit; + businessUnit2FromCompany1: CompanyBusinessUnit; + companyUser1FromCompany1: CompanyUser; + companyUser2FromCompany1: CompanyUser; + + businessUnit1FromCompany2: CompanyBusinessUnit; + businessUnit2FromCompany2: CompanyBusinessUnit; + companyUser1FromCompany2: CompanyUser; +} + +export interface RequestManagementDynamicFixtures { + merchant1: Merchant; + merchant2: Merchant; + merchant3: Merchant; + + customer: Customer; + + businessUnit1FromCompany1: CompanyBusinessUnit; + businessUnit2FromCompany1: CompanyBusinessUnit; + companyUser1FromCompany1: CompanyUser; + companyUser2FromCompany1: CompanyUser; + + businessUnit1FromCompany2: CompanyBusinessUnit; + businessUnit2FromCompany2: CompanyBusinessUnit; + companyUser1FromCompany2: CompanyUser; + + pendingRequest: MerchantRelationRequest; + canceledRequest: MerchantRelationRequest; + approvedRequest: MerchantRelationRequest; + rejectedRequest: MerchantRelationRequest; + + requestFromMerchant1: MerchantRelationRequest; + requestFromMerchant2: MerchantRelationRequest; + + requestFromUnit1: MerchantRelationRequest; + requestFromUnit2: MerchantRelationRequest; +} + +export interface Dummy { merchant1: Merchant; merchantUrl1: Url; merchantUser1FromMerchant1: User; diff --git a/cypress/support/types/yves/shared/customer.ts b/cypress/support/types/yves/shared/customer.ts index 9e663dd4..9753c696 100644 --- a/cypress/support/types/yves/shared/customer.ts +++ b/cypress/support/types/yves/shared/customer.ts @@ -1,3 +1,5 @@ export interface Customer { email: string; + first_name: string; + last_name: string; } diff --git a/cypress/support/types/yves/shared/index.ts b/cypress/support/types/yves/shared/index.ts index 90f606c5..3b2a0dee 100644 --- a/cypress/support/types/yves/shared/index.ts +++ b/cypress/support/types/yves/shared/index.ts @@ -9,3 +9,4 @@ export * from './product-offer'; export * from './url'; export * from './merchant'; export * from './user'; +export * from './merchant-relation-request'; diff --git a/cypress/support/types/yves/shared/merchant-relation-request.ts b/cypress/support/types/yves/shared/merchant-relation-request.ts new file mode 100644 index 00000000..c317cf57 --- /dev/null +++ b/cypress/support/types/yves/shared/merchant-relation-request.ts @@ -0,0 +1,4 @@ +export interface MerchantRelationRequest { + id_merchant_relation_request: number; + uuid: string; +} diff --git a/cypress/support/types/yves/shared/merchant.ts b/cypress/support/types/yves/shared/merchant.ts index 51f3787b..b7a623f7 100644 --- a/cypress/support/types/yves/shared/merchant.ts +++ b/cypress/support/types/yves/shared/merchant.ts @@ -1,4 +1,5 @@ export interface Merchant { + id_merchant: number; merchant_reference: string; name: string; } diff --git a/package-lock.json b/package-lock.json index 4b010ae1..79747cc1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@types/dotenv": "^8.2.0", "@typescript-eslint/eslint-plugin": "^6.21.0", "@typescript-eslint/parser": "^6.13.1", - "cypress": "^13.6.6", + "cypress": "^13.7.0", "eslint": "^8.57.0", "eslint-plugin-cypress": "^2.15.1", "inversify": "^6.0.2", @@ -1734,9 +1734,9 @@ } }, "node_modules/cypress": { - "version": "13.6.6", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.6.6.tgz", - "integrity": "sha512-S+2S9S94611hXimH9a3EAYt81QM913ZVA03pUmGDfLTFa5gyp85NJ8dJGSlEAEmyRsYkioS1TtnWtbv/Fzt11A==", + "version": "13.7.0", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.7.0.tgz", + "integrity": "sha512-UimjRSJJYdTlvkChcdcfywKJ6tUYuwYuk/n1uMMglrvi+ZthNhoRYcxnWgTqUtkl17fXrPAsD5XT2rcQYN1xKA==", "dev": true, "hasInstallScript": true, "dependencies": { diff --git a/package.json b/package.json index 70691268..3b1d95f6 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "@types/dotenv": "^8.2.0", "@typescript-eslint/eslint-plugin": "^6.21.0", "@typescript-eslint/parser": "^6.13.1", - "cypress": "^13.6.6", + "cypress": "^13.7.0", "eslint": "^8.57.0", "eslint-plugin-cypress": "^2.15.1", "inversify": "^6.0.2", From 192ec3ccfd2e6d06c693a8f019189a75350c5e0a Mon Sep 17 00:00:00 2001 From: Dmytro Asieiev Date: Wed, 20 Mar 2024 16:14:51 +0300 Subject: [PATCH 3/7] Added management scenario from merchant user [skip ci] --- .../request-management.cy.ts | 138 ++++ .../dynamic-request-management.json | 594 ++++++++++++++++++ .../static-request-management.json | 4 + cypress/support/pages/mp/index.ts | 2 + .../merchant-relation-requests-page.ts | 62 ++ .../merchant-relation-requests-repository.ts | 18 + .../merchant-relations-page.ts | 31 + .../merchant-relations-repository.ts | 10 + .../mp/merchant-user-login-scenario.ts | 11 +- cypress/support/types/mp/index.ts | 1 + .../mp/merchant-b2b-contract-requests.ts | 98 +++ .../types/mp/shared/company-business-unit.ts | 5 + .../support/types/mp/shared/company-user.ts | 3 + cypress/support/types/mp/shared/company.ts | 4 + cypress/support/types/mp/shared/index.ts | 5 + .../mp/shared/merchant-relation-request.ts | 4 + cypress/support/types/mp/shared/url.ts | 3 + 17 files changed, 990 insertions(+), 3 deletions(-) create mode 100644 cypress/e2e/mp/merchant-b2b-contract-requests/request-management.cy.ts create mode 100644 cypress/fixtures/suite/mp/merchant-b2b-contract-requests/dynamic-request-management.json create mode 100644 cypress/fixtures/suite/mp/merchant-b2b-contract-requests/static-request-management.json create mode 100644 cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-page.ts create mode 100644 cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-repository.ts create mode 100644 cypress/support/pages/mp/merchant-relations/merchant-relations-page.ts create mode 100644 cypress/support/pages/mp/merchant-relations/merchant-relations-repository.ts create mode 100644 cypress/support/types/mp/merchant-b2b-contract-requests.ts create mode 100644 cypress/support/types/mp/shared/company-business-unit.ts create mode 100644 cypress/support/types/mp/shared/company-user.ts create mode 100644 cypress/support/types/mp/shared/company.ts create mode 100644 cypress/support/types/mp/shared/merchant-relation-request.ts create mode 100644 cypress/support/types/mp/shared/url.ts diff --git a/cypress/e2e/mp/merchant-b2b-contract-requests/request-management.cy.ts b/cypress/e2e/mp/merchant-b2b-contract-requests/request-management.cy.ts new file mode 100644 index 00000000..380b3d35 --- /dev/null +++ b/cypress/e2e/mp/merchant-b2b-contract-requests/request-management.cy.ts @@ -0,0 +1,138 @@ +import { container } from '@utils'; +import { MerchantUserLoginScenario } from '../../../support/scenarios/mp'; +import { RequestManagementDynamicFixtures, RequestManagementStaticFixtures } from '../../../support/types/mp'; +import { MerchantRelationRequestsPage, MerchantRelationsPage } from '../../../support/pages/mp'; + +/** + * Merchant Relation Requests & Enhanced Merchant Relations checklists: {@link https://spryker.atlassian.net/wiki/spaces/CCS/pages/4105896492/Business+Journey+B2B+Marketplace+-+to+automate} + */ +describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, (): void => { + const merchantRelationRequestsPage = container.get(MerchantRelationRequestsPage); + const merchantRelationsPage = container.get(MerchantRelationsPage); + const merchantUserLoginScenario = container.get(MerchantUserLoginScenario); + + let dynamicFixtures: RequestManagementDynamicFixtures; + let staticFixtures: RequestManagementStaticFixtures; + + before((): void => { + ({ dynamicFixtures, staticFixtures } = Cypress.env()); + }); + + it('all merchant user should be able see merchant relation requests', (): void => { + merchantUserLoginScenario.execute({ + username: dynamicFixtures.merchantUser1FromMerchant1.username, + password: staticFixtures.defaultPassword, + }); + + merchantRelationRequestsPage.visit(); + merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit1FromCompany1.name).should('exist'); + + merchantUserLoginScenario.execute({ + username: dynamicFixtures.merchantUser2FromMerchant1.username, + password: staticFixtures.defaultPassword, + }); + + merchantRelationRequestsPage.visit(); + merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit1FromCompany1.name).should('exist'); + }); + + it('merchant user should be able to left internal comments', (): void => { + merchantUserLoginScenario.execute({ + username: dynamicFixtures.merchantUser1FromMerchant1.username, + password: staticFixtures.defaultPassword, + }); + + merchantRelationRequestsPage.visit(); + merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit1FromCompany1.name).click(); + merchantRelationRequestsPage.getDrawer(); + merchantRelationRequestsPage.addInternalComment(staticFixtures.internalComment); + + merchantUserLoginScenario.execute({ + username: dynamicFixtures.merchantUser2FromMerchant1.username, + password: staticFixtures.defaultPassword, + }); + + merchantRelationRequestsPage.visit(); + merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit1FromCompany1.name).click(); + merchantRelationRequestsPage.getDrawer().contains(staticFixtures.internalComment); + }); + + it('merchant user should be able to approve request with BU splitting', (): void => { + merchantUserLoginScenario.execute({ + username: dynamicFixtures.merchantUser1FromMerchant1.username, + password: staticFixtures.defaultPassword, + }); + + merchantRelationRequestsPage.visit(); + merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit2FromCompany1.name).click(); + merchantRelationRequestsPage.getDrawer(); + merchantRelationRequestsPage.addInternalComment(staticFixtures.internalComment); + merchantRelationRequestsPage.approveRequest(true); + + merchantRelationsPage.visit(); + merchantRelationsPage.findRelation(dynamicFixtures.businessUnit6FromCompany1.name).click(); + merchantRelationsPage.getDrawer().contains(staticFixtures.internalComment); + + merchantRelationsPage.visit(); + merchantRelationsPage.findRelation(dynamicFixtures.businessUnit7FromCompany1.name).click(); + merchantRelationsPage.getDrawer().contains(staticFixtures.internalComment); + }); + + it('merchant user should be able to reject request', (): void => { + merchantUserLoginScenario.execute({ + username: dynamicFixtures.merchantUserFromMerchant2.username, + password: staticFixtures.defaultPassword, + }); + + merchantRelationRequestsPage.visit(); + merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit1FromCompany1.name).click(); + merchantRelationRequestsPage.getDrawer(); + merchantRelationRequestsPage.rejectRequest(); + + merchantRelationRequestsPage.visit(); + merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit1FromCompany1.name).click(); + merchantRelationRequestsPage.getDrawer().contains('Rejected'); + }); + + it('merchant user should not be able to approve request with deselected business units', (): void => { + merchantUserLoginScenario.execute({ + username: dynamicFixtures.merchantUserFromMerchant2.username, + password: staticFixtures.defaultPassword, + }); + + merchantRelationRequestsPage.visit(); + merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit2FromCompany1.name).click(); + merchantRelationRequestsPage.getDrawer(); + + merchantRelationRequestsPage.uncheckBusinessUnits([ + dynamicFixtures.businessUnit6FromCompany1.id_company_business_unit, + dynamicFixtures.businessUnit7FromCompany1.id_company_business_unit, + ]); + merchantRelationRequestsPage.approveRequest(false); + + merchantRelationRequestsPage.visit(); + merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit2FromCompany1.name).click(); + merchantRelationRequestsPage.getDrawer().contains('Pending'); + }); + + it('merchant user should be able to revise and approve request', (): void => { + merchantUserLoginScenario.execute({ + username: dynamicFixtures.merchantUserFromMerchant2.username, + password: staticFixtures.defaultPassword, + }); + + merchantRelationRequestsPage.visit(); + merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit2FromCompany1.name).click(); + + merchantRelationRequestsPage.getDrawer(); + merchantRelationRequestsPage.uncheckBusinessUnits([ + dynamicFixtures.businessUnit6FromCompany1.id_company_business_unit, + ]); + merchantRelationRequestsPage.approveRequest(false); + + merchantRelationsPage.visit(); + merchantRelationsPage.findRelation(dynamicFixtures.businessUnit6FromCompany1.name, 0); + merchantRelationsPage.findRelation(dynamicFixtures.businessUnit7FromCompany1.name).click(); + merchantRelationsPage.getDrawer().contains(dynamicFixtures.businessUnit7FromCompany1.name); + }); +}); diff --git a/cypress/fixtures/suite/mp/merchant-b2b-contract-requests/dynamic-request-management.json b/cypress/fixtures/suite/mp/merchant-b2b-contract-requests/dynamic-request-management.json new file mode 100644 index 00000000..90126d0e --- /dev/null +++ b/cypress/fixtures/suite/mp/merchant-b2b-contract-requests/dynamic-request-management.json @@ -0,0 +1,594 @@ +{ + "data": { + "type": "dynamic-fixtures", + "attributes": { + "synchronize": true, + "operations": [ + { + "type": "transfer", + "name": "LocaleTransfer", + "key": "localeEN", + "arguments": { "id_locale": 66, "locale_name": "en_US" } + }, + { + "type": "transfer", + "name": "LocaleTransfer", + "key": "localeDE", + "arguments": { "id_locale": 46, "locale_name": "de_DE" } + }, + { + "type": "builder", + "name": "LocalizedAttributesBuilder", + "key": "localizedAttribute" + }, + { + "type": "transfer", + "name": "StoreTransfer", + "key": "store", + "arguments": { "id_store": 1, "name": "DE" } + }, + { + "type": "array-object", + "key": "stores", + "arguments": ["#store"] + }, + { + "type": "helper", + "name": "haveUser", + "key": "merchantUser1FromMerchant1", + "arguments": [{ "password": "change123" }] + }, + { + "type": "helper", + "name": "haveUser", + "key": "merchantUser2FromMerchant1", + "arguments": [{ "password": "change123" }] + }, + { + "type": "builder", + "name": "MerchantProfileBuilder", + "key": "merchantProfile1" + }, + { + "type": "helper", + "name": "haveMerchant", + "key": "merchant1", + "arguments": [ + { + "merchantProfile": "#merchantProfile1", + "isActive": true, + "isOpenForRelationRequest": true, + "status": "approved", + "storeRelation": { + "idStores": ["#store.id_store"] + } + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "key": "merchantUrl1", + "arguments": [ + { + "fkLocale": "#localeEN.id_locale", + "fkResourceMerchant": "#merchant1.id_merchant", + "urlPrefix": "/en/merchant/dummy-en-prefix-", + "url": "#merchant1.name" + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "arguments": [ + { + "fkLocale": "#localeDE.id_locale", + "fkResourceMerchant": "#merchant1.id_merchant", + "urlPrefix": "/de/merchant/dummy-de-prefix-", + "url": "#merchant1.name" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantUserWithAclEntities", + "arguments": ["#merchant1", "#merchantUser1FromMerchant1"] + }, + { + "type": "helper", + "name": "haveMerchantUserWithAclEntities", + "arguments": ["#merchant1", "#merchantUser2FromMerchant1"] + }, + { + "type": "helper", + "name": "haveUser", + "key": "merchantUserFromMerchant2", + "arguments": [{ "password": "change123" }] + }, + { + "type": "builder", + "name": "MerchantProfileBuilder", + "key": "merchantProfile2" + }, + { + "type": "helper", + "name": "haveMerchant", + "key": "merchant2", + "arguments": [ + { + "merchantProfile": "#merchantProfile2", + "isActive": true, + "isOpenForRelationRequest": true, + "status": "approved", + "storeRelation": { + "idStores": ["#store.id_store"] + } + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "key": "merchantUrl2", + "arguments": [ + { + "fkLocale": "#localeEN.id_locale", + "fkResourceMerchant": "#merchant2.id_merchant", + "urlPrefix": "/en/merchant/dummy-en-prefix-", + "url": "#merchant2.name" + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "arguments": [ + { + "fkLocale": "#localeDE.id_locale", + "fkResourceMerchant": "#merchant2.id_merchant", + "urlPrefix": "/de/merchant/dummy-de-prefix-", + "url": "#merchant2.name" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantUserWithAclEntities", + "arguments": ["#merchant2", "#merchantUserFromMerchant2"] + }, + { + "type": "helper", + "name": "haveUser", + "key": "merchantUserFromMerchant3", + "arguments": [{ "password": "change123" }] + }, + { + "type": "builder", + "name": "MerchantProfileBuilder", + "key": "merchantProfile3" + }, + { + "type": "helper", + "name": "haveMerchant", + "key": "merchant3", + "arguments": [ + { + "merchantProfile": "#merchantProfile3", + "isActive": true, + "isOpenForRelationRequest": false, + "status": "approved", + "storeRelation": { + "idStores": ["#store.id_store"] + } + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "key": "merchantUrl3", + "arguments": [ + { + "fkLocale": "#localeEN.id_locale", + "fkResourceMerchant": "#merchant3.id_merchant", + "urlPrefix": "/en/merchant/dummy-en-prefix-", + "url": "#merchant3.name" + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "arguments": [ + { + "fkLocale": "#localeDE.id_locale", + "fkResourceMerchant": "#merchant3.id_merchant", + "urlPrefix": "/de/merchant/dummy-de-prefix-", + "url": "#merchant3.name" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantUserWithAclEntities", + "arguments": ["#merchant3", "#merchantUserFromMerchant3"] + }, + { + "type": "transfer", + "name": "ProductImageTransfer", + "key": "productImage", + "arguments": { + "externalUrlSmall": "https://images.icecat.biz/img/gallery_mediums/30691822_1486.jpg", + "externalUrlLarge": "https://images.icecat.biz/img/gallery/30691822_1486.jpg" + } + }, + { + "type": "helper", + "name": "haveFullProduct", + "key": "concreteProduct", + "arguments": [ + {}, + { + "idTaxSet": 1, + "localizedAttributes": [ + { "locale": "#localeEN", "name": "#localizedAttribute.name" }, + { "locale": "#localeDE", "name": "#localizedAttribute.name" } + ] + } + ] + }, + { + "type": "helper", + "name": "haveProductImageSet", + "arguments": [ + { + "name": "default", + "idProduct": "#concreteProduct.id_product_concrete", + "idProductAbstract": "#concreteProduct.fk_product_abstract", + "productImages": ["#productImage"] + } + ] + }, + { + "type": "helper", + "name": "havePriceProduct", + "arguments": [ + { + "skuProductAbstract": "#concreteProduct.abstract_sku", + "skuProduct": "#concreteProduct.sku", + "moneyValue": { "netAmount": 30000, "grossAmount": 30000 } + } + ] + }, + { + "type": "helper", + "name": "haveProductOffer", + "key": "productOfferFromMerchant1", + "arguments": [ + { + "isActive": true, + "status": "approved", + "idProductConcrete": "#concreteProduct.id_product_concrete", + "concreteSku": "#concreteProduct.sku", + "merchantReference": "#merchant1.merchant_reference", + "stores": "#stores" + } + ] + }, + { + "type": "helper", + "name": "haveProductOfferStock", + "arguments": [ + { + "idProductOffer": "#productOfferFromMerchant1.id_product_offer", + "productOfferReference": "#productOfferFromMerchant1.product_offer_reference", + "isNeverOutOfStock": true + }, + "#merchant1.stocks" + ] + }, + { + "type": "helper", + "name": "haveProductOffer", + "key": "productOfferFromMerchant2", + "arguments": [ + { + "isActive": true, + "status": "approved", + "idProductConcrete": "#concreteProduct.id_product_concrete", + "concreteSku": "#concreteProduct.sku", + "merchantReference": "#merchant2.merchant_reference", + "stores": "#stores" + } + ] + }, + { + "type": "helper", + "name": "haveProductOfferStock", + "arguments": [ + { + "idProductOffer": "#productOfferFromMerchant2.id_product_offer", + "productOfferReference": "#productOfferFromMerchant2.product_offer_reference", + "isNeverOutOfStock": true + }, + "#merchant2.stocks" + ] + }, + { + "type": "helper", + "name": "haveProductOffer", + "key": "productOfferFromMerchant3", + "arguments": [ + { + "isActive": true, + "status": "approved", + "idProductConcrete": "#concreteProduct.id_product_concrete", + "concreteSku": "#concreteProduct.sku", + "merchantReference": "#merchant3.merchant_reference", + "stores": "#stores" + } + ] + }, + { + "type": "helper", + "name": "haveProductOfferStock", + "arguments": [ + { + "idProductOffer": "#productOfferFromMerchant3.id_product_offer", + "productOfferReference": "#productOfferFromMerchant3.product_offer_reference", + "isNeverOutOfStock": true + }, + "#merchant3.stocks" + ] + }, + { + "type": "helper", + "name": "haveCountry", + "key": "country" + }, + { + "type": "helper", + "name": "haveCustomer", + "key": "customer", + "arguments": [{ "locale": "#localeEN", "password": "change123" }] + }, + { + "type": "helper", + "name": "confirmCustomer", + "key": "confirmedCustomer", + "arguments": ["#customer"] + }, + { + "type": "helper", + "name": "haveCompany", + "key": "company1", + "arguments": [{ "isActive": true, "status": "approved" }] + }, + { + "type": "helper", + "name": "haveCompany", + "key": "company2", + "arguments": [{ "isActive": true, "status": "approved" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit1FromCompany1", + "arguments": [{ "fkCompany": "#company1.id_company" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit2FromCompany1", + "arguments": [{ "fkCompany": "#company1.id_company" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit3FromCompany1", + "arguments": [{ "fkCompany": "#company1.id_company" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit4FromCompany1", + "arguments": [{ "fkCompany": "#company1.id_company" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit5FromCompany1", + "arguments": [{ "fkCompany": "#company1.id_company" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit6FromCompany1", + "arguments": [{ "fkCompany": "#company1.id_company" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit7FromCompany1", + "arguments": [{ "fkCompany": "#company1.id_company" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit1FromCompany2", + "arguments": [{ "fkCompany": "#company2.id_company" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit2FromCompany2", + "arguments": [{ "fkCompany": "#company2.id_company" }] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission", + "arguments": ["CreateMerchantRelationRequestPermissionPlugin"] + }, + { + "type": "helper", + "name": "haveCompanyRoleWithPermissions", + "arguments": [{ "isDefault": true, "fkCompany": "#company1.id_company" }, ["#permission"]] + }, + { + "type": "helper", + "name": "haveCompanyRoleWithPermissions", + "arguments": [{ "isDefault": true, "fkCompany": "#company2.id_company" }, ["#permission"]] + }, + { + "type": "helper", + "name": "haveCompanyUser", + "key": "companyUser1FromCompany1", + "arguments": [ + { + "customer": "#customer", + "fkCustomer": "#customer.id_customer", + "fkCompany": "#company1.id_company", + "fkCompanyBusinessUnit": "#businessUnit1FromCompany1.id_company_business_unit" + } + ] + }, + { + "type": "helper", + "name": "haveCompanyUser", + "key": "companyUser2FromCompany1", + "arguments": [ + { + "customer": "#customer", + "fkCustomer": "#customer.id_customer", + "fkCompany": "#company1.id_company", + "fkCompanyBusinessUnit": "#businessUnit2FromCompany1.id_company_business_unit" + } + ] + }, + { + "type": "helper", + "name": "haveCompanyUser", + "key": "companyUser1FromCompany2", + "arguments": [ + { + "customer": "#customer", + "fkCustomer": "#customer.id_customer", + "fkCompany": "#company2.id_company", + "fkCompanyBusinessUnit": "#businessUnit1FromCompany2.id_company_business_unit" + } + ] + }, + { + "type": "array-object", + "key": "assigneeCompanyBusinessUnitsFromCompany1", + "arguments": ["#businessUnit6FromCompany1", "#businessUnit7FromCompany1"] + }, + { + "type": "array-object", + "key": "assigneeCompanyBusinessUnitsFromCompany2", + "arguments": ["#businessUnit1FromCompany2", "#businessUnit2FromCompany2"] + }, + { + "type": "helper", + "name": "haveMerchantRelationRequest", + "key": "request1FromMerchant1", + "arguments": [ + { + "status": "pending", + "merchant": "#merchant1", + "companyUser": "#companyUser1FromCompany2", + "ownerCompanyBusinessUnit": "#businessUnit1FromCompany1", + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany1" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantRelationRequest", + "key": "request2FromMerchant1", + "arguments": [ + { + "status": "pending", + "merchant": "#merchant1", + "companyUser": "#companyUser1FromCompany2", + "ownerCompanyBusinessUnit": "#businessUnit2FromCompany1", + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany1" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantRelationRequest", + "key": "request3FromMerchant1", + "arguments": [ + { + "status": "canceled", + "merchant": "#merchant1", + "companyUser": "#companyUser1FromCompany2", + "ownerCompanyBusinessUnit": "#businessUnit3FromCompany1", + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany1" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantRelationRequest", + "key": "request4FromMerchant1", + "arguments": [ + { + "status": "rejected", + "merchant": "#merchant1", + "companyUser": "#companyUser1FromCompany2", + "ownerCompanyBusinessUnit": "#businessUnit4FromCompany1", + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany1" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantRelationRequest", + "key": "request5FromMerchant1", + "arguments": [ + { + "status": "approved", + "merchant": "#merchant1", + "companyUser": "#companyUser1FromCompany2", + "ownerCompanyBusinessUnit": "#businessUnit5FromCompany1", + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany1" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantRelationRequest", + "key": "request1FromMerchant2", + "arguments": [ + { + "status": "pending", + "merchant": "#merchant2", + "companyUser": "#companyUser1FromCompany1", + "ownerCompanyBusinessUnit": "#businessUnit1FromCompany1", + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany1" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantRelationRequest", + "key": "request2FromMerchant2", + "arguments": [ + { + "status": "pending", + "merchant": "#merchant2", + "companyUser": "#companyUser2FromCompany1", + "ownerCompanyBusinessUnit": "#businessUnit2FromCompany1", + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany1" + } + ] + } + ] + } + } +} diff --git a/cypress/fixtures/suite/mp/merchant-b2b-contract-requests/static-request-management.json b/cypress/fixtures/suite/mp/merchant-b2b-contract-requests/static-request-management.json new file mode 100644 index 00000000..35e3f01b --- /dev/null +++ b/cypress/fixtures/suite/mp/merchant-b2b-contract-requests/static-request-management.json @@ -0,0 +1,4 @@ +{ + "defaultPassword": "change123", + "internalComment": "This is dummy company user data, please replace with real data." +} diff --git a/cypress/support/pages/mp/index.ts b/cypress/support/pages/mp/index.ts index 805f3a11..bd458fbd 100644 --- a/cypress/support/pages/mp/index.ts +++ b/cypress/support/pages/mp/index.ts @@ -6,3 +6,5 @@ export * from './offers/offers-page'; export * from './products/products-page'; export * from './profile/profile-page'; export * from './sales/sales-orders-page'; +export * from './merchant-relation-requests/merchant-relation-requests-page'; +export * from './merchant-relations/merchant-relations-page'; diff --git a/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-page.ts b/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-page.ts new file mode 100644 index 00000000..e0c59b03 --- /dev/null +++ b/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-page.ts @@ -0,0 +1,62 @@ +import { autoWired } from '@utils'; +import { inject, injectable } from 'inversify'; + +import { MpPage } from '../mp-page'; +import { MerchantRelationRequestsRepository } from './merchant-relation-requests-repository'; + +@injectable() +@autoWired +export class MerchantRelationRequestsPage extends MpPage { + @inject(MerchantRelationRequestsRepository) private repository: MerchantRelationRequestsRepository; + + protected PAGE_URL = '/merchant-relation-request-merchant-portal-gui/merchant-relation-requests'; + + findRequest = (query: string): Cypress.Chainable => { + const searchSelector = this.repository.getSearchSelector(); + cy.get(searchSelector).clear(); + cy.get(searchSelector).type(query); + + const interceptAlias = this.faker.string.uuid(); + cy.intercept('GET', '/merchant-relation-request-merchant-portal-gui/merchant-relation-requests/table-data**').as( + interceptAlias + ); + cy.wait(`@${interceptAlias}`).its('response.body.total').should('eq', 1); + + return this.repository.getFirstTableRow(); + }; + + getDrawer = (): Cypress.Chainable => { + return this.repository.getDrawer(); + }; + + addInternalComment = (comment: string): void => { + this.repository.getInternalCommentTextarea().type(comment); + this.repository.getInternalCommentAddCommentButton().click(); + }; + + approveRequest = (isSplitEnabled: boolean): void => { + if (isSplitEnabled) { + this.repository.getDrawer().find(this.repository.getIsSplitEnabledCheckboxSelector()).click(); + } + + this.repository.getDrawer().find('button:contains("Approve")').click(); + this.repository.getApprovalModalConfirmButton().click(); + }; + + rejectRequest = (): void => { + this.repository.getDrawer().find('button:contains("Reject")').click(); + this.repository.getRejectionModalConfirmButton().click(); + }; + + uncheckBusinessUnits = (businessUnitIds: number[]): void => { + this.getDrawer() + .find('[id="assigneeCompanyBusinessUnits[]"]') + .each(($businessUnitCheckbox) => { + const idBusinessUnit = $businessUnitCheckbox.find('[type="checkbox"]').last().attr('value') ?? ''; + + if (businessUnitIds.includes(parseInt(idBusinessUnit))) { + cy.wrap($businessUnitCheckbox.find('[type="checkbox"]').first()).uncheck(); + } + }); + }; +} diff --git a/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-repository.ts b/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-repository.ts new file mode 100644 index 00000000..28a5b320 --- /dev/null +++ b/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-repository.ts @@ -0,0 +1,18 @@ +import { autoWired } from '@utils'; +import { injectable } from 'inversify'; + +@injectable() +@autoWired +export class MerchantRelationRequestsRepository { + getFirstTableRow = (): Cypress.Chainable => cy.get('tbody > :nth-child(1)'); + getSearchSelector = (): string => '.spy-table-search-feature input[type="text"]'; + getDrawer = (): Cypress.Chainable => cy.get('.spy-drawer-wrapper'); + getInternalCommentTextarea = (): Cypress.Chainable => cy.get('.mp-add-comment__form textarea'); + getInternalCommentAddCommentButton = (): Cypress.Chainable => + cy.get('.mp-add-comment__form').find('[shape="circle"]'); + getIsSplitEnabledCheckboxSelector = (): string => '[spy-id="isSplitEnabled"]'; + getApprovalModalConfirmButton = (): Cypress.Chainable => + cy.get('[ng-reflect-ng-class="ant-modal--confirmation"]').find('button:contains("Confirm approval")'); + getRejectionModalConfirmButton = (): Cypress.Chainable => + cy.get('[ng-reflect-ng-class="ant-modal--confirmation"]').find('button:contains("Confirm reject")'); +} diff --git a/cypress/support/pages/mp/merchant-relations/merchant-relations-page.ts b/cypress/support/pages/mp/merchant-relations/merchant-relations-page.ts new file mode 100644 index 00000000..9b5c1529 --- /dev/null +++ b/cypress/support/pages/mp/merchant-relations/merchant-relations-page.ts @@ -0,0 +1,31 @@ +import { autoWired } from '@utils'; +import { inject, injectable } from 'inversify'; + +import { MpPage } from '../mp-page'; +import { MerchantRelationsRepository } from './merchant-relations-repository'; + +@injectable() +@autoWired +export class MerchantRelationsPage extends MpPage { + @inject(MerchantRelationsRepository) private repository: MerchantRelationsRepository; + + protected PAGE_URL = '/merchant-relationship-merchant-portal-gui/merchant-relationship'; + + findRelation = (query: string, counter = 1): Cypress.Chainable => { + const searchSelector = this.repository.getSearchSelector(); + cy.get(searchSelector).clear(); + cy.get(searchSelector).type(query); + + const interceptAlias = this.faker.string.uuid(); + cy.intercept('GET', '/merchant-relationship-merchant-portal-gui/merchant-relationship/table-data**').as( + interceptAlias + ); + cy.wait(`@${interceptAlias}`).its('response.body.total').should('eq', counter); + + return this.repository.getFirstTableRow(); + }; + + getDrawer = (): Cypress.Chainable => { + return this.repository.getDrawer(); + }; +} diff --git a/cypress/support/pages/mp/merchant-relations/merchant-relations-repository.ts b/cypress/support/pages/mp/merchant-relations/merchant-relations-repository.ts new file mode 100644 index 00000000..bbd5896a --- /dev/null +++ b/cypress/support/pages/mp/merchant-relations/merchant-relations-repository.ts @@ -0,0 +1,10 @@ +import { autoWired } from '@utils'; +import { injectable } from 'inversify'; + +@injectable() +@autoWired +export class MerchantRelationsRepository { + getFirstTableRow = (): Cypress.Chainable => cy.get('tbody > :nth-child(1)'); + getSearchSelector = (): string => '.spy-table-search-feature input[type="text"]'; + getDrawer = (): Cypress.Chainable => cy.get('.spy-drawer-wrapper'); +} diff --git a/cypress/support/scenarios/mp/merchant-user-login-scenario.ts b/cypress/support/scenarios/mp/merchant-user-login-scenario.ts index 58602dea..5eda0317 100644 --- a/cypress/support/scenarios/mp/merchant-user-login-scenario.ts +++ b/cypress/support/scenarios/mp/merchant-user-login-scenario.ts @@ -2,15 +2,20 @@ import { LoginPage } from '@pages/mp'; import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; +interface MerchantUserLoginExecuteParams { + username: string; + password: string; +} + @injectable() @autoWired export class MerchantUserLoginScenario { @inject(LoginPage) private loginPage: LoginPage; - execute = (username: string, password: string): void => { - cy.session([username, password], () => { + execute = (params: MerchantUserLoginExecuteParams): void => { + cy.session([params.username, params.password], () => { this.loginPage.visit(); - this.loginPage.login(username, password); + this.loginPage.login(params.username, params.password); }); }; } diff --git a/cypress/support/types/mp/index.ts b/cypress/support/types/mp/index.ts index d7ece27b..7e625a2f 100644 --- a/cypress/support/types/mp/index.ts +++ b/cypress/support/types/mp/index.ts @@ -1 +1,2 @@ export * from './marketplace-agent-assist'; +export * from './merchant-b2b-contract-requests'; diff --git a/cypress/support/types/mp/merchant-b2b-contract-requests.ts b/cypress/support/types/mp/merchant-b2b-contract-requests.ts new file mode 100644 index 00000000..2798d960 --- /dev/null +++ b/cypress/support/types/mp/merchant-b2b-contract-requests.ts @@ -0,0 +1,98 @@ +import { + Company, + CompanyBusinessUnit, + CompanyUser, + Customer, + Merchant, + MerchantRelationRequest, + ProductConcrete, + ProductOffer, + Url, + User, +} from './shared'; + +export interface RequestManagementDynamicFixtures { + merchant1: Merchant; + merchantUrl1: Url; + merchantUser1FromMerchant1: User; + merchantUser2FromMerchant1: User; + + merchant2: Merchant; + merchantUrl2: Url; + merchantUserFromMerchant2: User; + + merchant3: Merchant; + merchantUrl3: Url; + merchantUserFromMerchant3: User; + + concreteProduct: ProductConcrete; + productOfferFromMerchant1: ProductOffer; + productOfferFromMerchant2: ProductOffer; + productOfferFromMerchant3: ProductOffer; + + customer: Customer; + + company1: Company; + businessUnit1FromCompany1: CompanyBusinessUnit; + businessUnit2FromCompany1: CompanyBusinessUnit; + businessUnit3FromCompany1: CompanyBusinessUnit; + businessUnit4FromCompany1: CompanyBusinessUnit; + businessUnit5FromCompany1: CompanyBusinessUnit; + businessUnit6FromCompany1: CompanyBusinessUnit; + businessUnit7FromCompany1: CompanyBusinessUnit; + companyUser1FromCompany1: CompanyUser; + companyUser2FromCompany1: CompanyUser; + + company2: Company; + businessUnit1FromCompany2: CompanyBusinessUnit; + businessUnit2FromCompany2: CompanyBusinessUnit; + companyUser1FromCompany2: CompanyUser; + + request1FromMerchant1: MerchantRelationRequest; + request2FromMerchant1: MerchantRelationRequest; + request3FromMerchant1: MerchantRelationRequest; + request4FromMerchant1: MerchantRelationRequest; + request5FromMerchant1: MerchantRelationRequest; +} + +export interface Dummy { + merchant1: Merchant; + merchantUrl1: Url; + merchantUser1FromMerchant1: User; + merchantUser2FromMerchant1: User; + + merchant2: Merchant; + merchantUrl2: Url; + merchantUserFromMerchant2: User; + + merchant3: Merchant; + merchantUrl3: Url; + merchantUserFromMerchant3: User; + + concreteProduct: ProductConcrete; + productOfferFromMerchant1: ProductOffer; + productOfferFromMerchant2: ProductOffer; + productOfferFromMerchant3: ProductOffer; + + customer: Customer; + + company1: Company; + businessUnit1FromCompany1: CompanyBusinessUnit; + businessUnit2FromCompany1: CompanyBusinessUnit; + companyUser1FromCompany1: CompanyUser; + companyUser2FromCompany1: CompanyUser; + + company2: Company; + businessUnit1FromCompany2: CompanyBusinessUnit; + businessUnit2FromCompany2: CompanyBusinessUnit; + companyUser1FromCompany2: CompanyUser; +} + +export interface RequestManagementStaticFixtures { + defaultPassword: string; + internalComment: string; +} + +export interface MerchantB2bContractRequestsStaticFixtures { + defaultPassword: string; +} diff --git a/cypress/support/types/mp/shared/company-business-unit.ts b/cypress/support/types/mp/shared/company-business-unit.ts new file mode 100644 index 00000000..76bffdf3 --- /dev/null +++ b/cypress/support/types/mp/shared/company-business-unit.ts @@ -0,0 +1,5 @@ +export interface CompanyBusinessUnit { + id_company_business_unit: number; + key: string; + name: string; +} diff --git a/cypress/support/types/mp/shared/company-user.ts b/cypress/support/types/mp/shared/company-user.ts new file mode 100644 index 00000000..250de7f7 --- /dev/null +++ b/cypress/support/types/mp/shared/company-user.ts @@ -0,0 +1,3 @@ +export interface CompanyUser { + id_company_user: number; +} diff --git a/cypress/support/types/mp/shared/company.ts b/cypress/support/types/mp/shared/company.ts new file mode 100644 index 00000000..5bb94f87 --- /dev/null +++ b/cypress/support/types/mp/shared/company.ts @@ -0,0 +1,4 @@ +export interface Company { + key: string; + name: string; +} diff --git a/cypress/support/types/mp/shared/index.ts b/cypress/support/types/mp/shared/index.ts index 225ea302..6a64be59 100644 --- a/cypress/support/types/mp/shared/index.ts +++ b/cypress/support/types/mp/shared/index.ts @@ -4,3 +4,8 @@ export * from './product-concrete'; export * from './product-offer'; export * from './quote'; export * from './user'; +export * from './company'; +export * from './company-business-unit'; +export * from './company-user'; +export * from './merchant-relation-request'; +export * from './url'; diff --git a/cypress/support/types/mp/shared/merchant-relation-request.ts b/cypress/support/types/mp/shared/merchant-relation-request.ts new file mode 100644 index 00000000..c317cf57 --- /dev/null +++ b/cypress/support/types/mp/shared/merchant-relation-request.ts @@ -0,0 +1,4 @@ +export interface MerchantRelationRequest { + id_merchant_relation_request: number; + uuid: string; +} diff --git a/cypress/support/types/mp/shared/url.ts b/cypress/support/types/mp/shared/url.ts new file mode 100644 index 00000000..1b6cc537 --- /dev/null +++ b/cypress/support/types/mp/shared/url.ts @@ -0,0 +1,3 @@ +export interface Url { + url: string; +} From 5de500d511fdfd8887cdc6fb6e4c299c86bb4de6 Mon Sep 17 00:00:00 2001 From: Dmytro Asieiev Date: Wed, 20 Mar 2024 22:21:37 +0300 Subject: [PATCH 4/7] Added management scenario from root user --- .../request-management.cy.ts | 104 +++++++ .../dynamic-request-management.json} | 254 +++++++----------- .../static-request-management.json | 6 + cypress/support/pages/backoffice/index.ts | 3 + ...merchant-relation-request-gui-edit-page.ts | 31 +++ ...nt-relation-request-gui-edit-repository.ts | 15 ++ ...merchant-relation-request-gui-list-page.ts | 40 +++ ...nt-relation-request-gui-list-repository.ts | 11 + .../merchant-relationship-gui-list-page.ts | 34 +++ ...rchant-relationship-gui-list-repository.ts | 10 + cypress/support/types/backoffice/index.ts | 1 + .../merchant-b2b-contract-requests.ts | 49 ++++ .../shared/company-business-unit.ts | 5 + .../types/backoffice/shared/company-user.ts | 3 + .../types/backoffice/shared/company.ts | 5 + .../support/types/backoffice/shared/index.ts | 6 + .../shared/merchant-relation-request.ts | 4 + .../types/backoffice/shared/merchant.ts | 5 + .../support/types/backoffice/shared/url.ts | 3 + .../mp/merchant-b2b-contract-requests.ts | 37 --- 20 files changed, 428 insertions(+), 198 deletions(-) create mode 100644 cypress/e2e/backoffice/merchant-b2b-contract-requests/request-management.cy.ts rename cypress/fixtures/suite/{yves/merchant-b2b-contract-requests/__dummy.json => backoffice/merchant-b2b-contract-requests/dynamic-request-management.json} (67%) create mode 100644 cypress/fixtures/suite/backoffice/merchant-b2b-contract-requests/static-request-management.json create mode 100644 cypress/support/pages/backoffice/merchant-relation-request-gui/edit/merchant-relation-request-gui-edit-page.ts create mode 100644 cypress/support/pages/backoffice/merchant-relation-request-gui/edit/merchant-relation-request-gui-edit-repository.ts create mode 100644 cypress/support/pages/backoffice/merchant-relation-request-gui/list/merchant-relation-request-gui-list-page.ts create mode 100644 cypress/support/pages/backoffice/merchant-relation-request-gui/list/merchant-relation-request-gui-list-repository.ts create mode 100644 cypress/support/pages/backoffice/merchant-relationship-gui/list/merchant-relationship-gui-list-page.ts create mode 100644 cypress/support/pages/backoffice/merchant-relationship-gui/list/merchant-relationship-gui-list-repository.ts create mode 100644 cypress/support/types/backoffice/merchant-b2b-contract-requests.ts create mode 100644 cypress/support/types/backoffice/shared/company-business-unit.ts create mode 100644 cypress/support/types/backoffice/shared/company-user.ts create mode 100644 cypress/support/types/backoffice/shared/company.ts create mode 100644 cypress/support/types/backoffice/shared/merchant-relation-request.ts create mode 100644 cypress/support/types/backoffice/shared/merchant.ts create mode 100644 cypress/support/types/backoffice/shared/url.ts diff --git a/cypress/e2e/backoffice/merchant-b2b-contract-requests/request-management.cy.ts b/cypress/e2e/backoffice/merchant-b2b-contract-requests/request-management.cy.ts new file mode 100644 index 00000000..05c6a3df --- /dev/null +++ b/cypress/e2e/backoffice/merchant-b2b-contract-requests/request-management.cy.ts @@ -0,0 +1,104 @@ +import { container } from '@utils'; +import { RequestManagementDynamicFixtures, RequestManagementStaticFixtures } from '../../../support/types/backoffice'; +import { UserLoginScenario } from '../../../support/scenarios/backoffice'; +import { + MerchantRelationRequestGuiEditPage, + MerchantRelationRequestGuiListPage, + MerchantRelationshipGuiListPage, +} from '../../../support/pages/backoffice'; + +/** + * Merchant Relation Requests & Enhanced Merchant Relations checklists: {@link https://spryker.atlassian.net/wiki/spaces/CCS/pages/4105896492/Business+Journey+B2B+Marketplace+-+to+automate} + */ +describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, (): void => { + const merchantRelationRequestGuiListPage = container.get(MerchantRelationRequestGuiListPage); + const merchantRelationRequestGuiEditPage = container.get(MerchantRelationRequestGuiEditPage); + const merchantRelationshipGuiListPage = container.get(MerchantRelationshipGuiListPage); + const userLoginScenario = container.get(UserLoginScenario); + + let dynamicFixtures: RequestManagementDynamicFixtures; + let staticFixtures: RequestManagementStaticFixtures; + + before((): void => { + ({ dynamicFixtures, staticFixtures } = Cypress.env()); + }); + + beforeEach((): void => { + userLoginScenario.execute({ + username: dynamicFixtures.rootUser.username, + password: staticFixtures.defaultPassword, + }); + }); + + it('operator should be able to see all requests from all merchants', (): void => { + const merchants = [dynamicFixtures.merchant1, dynamicFixtures.merchant2, dynamicFixtures.merchant3]; + + merchants.forEach((merchant) => { + merchantRelationRequestGuiListPage.visit(); + merchantRelationRequestGuiListPage.editLastRequest({ idMerchant: merchant.id_merchant }); + cy.contains(merchant.name); + }); + }); + + it('operator should be able to see internal comments from all merchant users', (): void => { + merchantRelationRequestGuiListPage.visit(); + merchantRelationRequestGuiListPage.editLastRequest({ idMerchant: dynamicFixtures.merchant1.id_merchant }); + + cy.contains(staticFixtures.internalCommentFromMerchantUser1); + cy.contains(staticFixtures.internalCommentFromMerchantUser2); + }); + + it('operator should be able to add internal comment', (): void => { + merchantRelationRequestGuiListPage.visit(); + merchantRelationRequestGuiListPage.editLastRequest({ idMerchant: dynamicFixtures.merchant1.id_merchant }); + merchantRelationRequestGuiEditPage.addInternalComment(staticFixtures.internalCommentFromRootUser); + + merchantRelationRequestGuiListPage.visit(); + merchantRelationRequestGuiListPage.editLastRequest({ idMerchant: dynamicFixtures.merchant1.id_merchant }); + cy.contains(staticFixtures.internalCommentFromRootUser); + }); + + it('operator should be able to reject request', (): void => { + merchantRelationRequestGuiListPage.visit(); + merchantRelationRequestGuiListPage.editLastRequest({ idMerchant: dynamicFixtures.merchant3.id_merchant }); + merchantRelationRequestGuiEditPage.rejectRequest(); + + merchantRelationRequestGuiListPage.visit(); + merchantRelationRequestGuiListPage.viewLastRequest({ idMerchant: dynamicFixtures.merchant3.id_merchant }); + cy.contains('Rejected'); + + merchantRelationshipGuiListPage.visit(); + merchantRelationshipGuiListPage.applyFilters({ idCompany: dynamicFixtures.company2.id_company }); + merchantRelationshipGuiListPage.getEditButtons().should('have.length', 0); + }); + + it('operator should be able to approve request (additionally copy internal comments to relation)', (): void => { + merchantRelationRequestGuiListPage.visit(); + merchantRelationRequestGuiListPage.editLastRequest({ idMerchant: dynamicFixtures.merchant1.id_merchant }); + merchantRelationRequestGuiEditPage.approveRequest(false); + + merchantRelationRequestGuiListPage.visit(); + merchantRelationRequestGuiListPage.viewLastRequest({ idMerchant: dynamicFixtures.merchant1.id_merchant }); + cy.contains('Approved'); + + merchantRelationshipGuiListPage.visit(); + merchantRelationshipGuiListPage.editLastRelation({ idCompany: dynamicFixtures.company1.id_company }); + + cy.contains(staticFixtures.internalCommentFromMerchantUser1); + cy.contains(staticFixtures.internalCommentFromMerchantUser2); + }); + + it('operator should be able to approve request with enabled BU splitting', (): void => { + merchantRelationRequestGuiListPage.visit(); + merchantRelationRequestGuiListPage.editLastRequest({ idMerchant: dynamicFixtures.merchant2.id_merchant }); + merchantRelationRequestGuiEditPage.approveRequest(true); + + merchantRelationRequestGuiListPage.visit(); + merchantRelationRequestGuiListPage.viewLastRequest({ idMerchant: dynamicFixtures.merchant2.id_merchant }); + cy.contains('Approved'); + + merchantRelationshipGuiListPage.visit(); + merchantRelationshipGuiListPage.applyFilters({ idCompany: dynamicFixtures.company2.id_company }); + merchantRelationshipGuiListPage.getEditButtons().should('have.length', 2); + }); +}); diff --git a/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/__dummy.json b/cypress/fixtures/suite/backoffice/merchant-b2b-contract-requests/dynamic-request-management.json similarity index 67% rename from cypress/fixtures/suite/yves/merchant-b2b-contract-requests/__dummy.json rename to cypress/fixtures/suite/backoffice/merchant-b2b-contract-requests/dynamic-request-management.json index cde00a84..f2bb3a78 100644 --- a/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/__dummy.json +++ b/cypress/fixtures/suite/backoffice/merchant-b2b-contract-requests/dynamic-request-management.json @@ -4,6 +4,17 @@ "attributes": { "synchronize": true, "operations": [ + { + "type": "helper", + "name": "haveUser", + "key": "rootUser", + "arguments": [{ "password": "change123" }] + }, + { + "type": "helper", + "name": "addUserToGroup", + "arguments": ["#rootUser.id_user", 1] + }, { "type": "transfer", "name": "LocaleTransfer", @@ -152,17 +163,6 @@ } ] }, - { - "type": "helper", - "name": "haveMerchantUserWithAclEntities", - "arguments": ["#merchant2", "#merchantUserFromMerchant2"] - }, - { - "type": "helper", - "name": "haveUser", - "key": "merchantUserFromMerchant3", - "arguments": [{ "password": "change123" }] - }, { "type": "builder", "name": "MerchantProfileBuilder", @@ -176,7 +176,7 @@ { "merchantProfile": "#merchantProfile3", "isActive": true, - "isOpenForRelationRequest": false, + "isOpenForRelationRequest": true, "status": "approved", "storeRelation": { "idStores": ["#store.id_store"] @@ -209,139 +209,6 @@ } ] }, - { - "type": "helper", - "name": "haveMerchantUserWithAclEntities", - "arguments": ["#merchant3", "#merchantUserFromMerchant3"] - }, - { - "type": "transfer", - "name": "ProductImageTransfer", - "key": "productImage", - "arguments": { - "externalUrlSmall": "https://images.icecat.biz/img/gallery_mediums/30691822_1486.jpg", - "externalUrlLarge": "https://images.icecat.biz/img/gallery/30691822_1486.jpg" - } - }, - { - "type": "helper", - "name": "haveFullProduct", - "key": "concreteProduct", - "arguments": [ - {}, - { - "idTaxSet": 1, - "localizedAttributes": [ - { "locale": "#localeEN", "name": "#localizedAttribute.name" }, - { "locale": "#localeDE", "name": "#localizedAttribute.name" } - ] - } - ] - }, - { - "type": "helper", - "name": "haveProductImageSet", - "arguments": [ - { - "name": "default", - "idProduct": "#concreteProduct.id_product_concrete", - "idProductAbstract": "#concreteProduct.fk_product_abstract", - "productImages": ["#productImage"] - } - ] - }, - { - "type": "helper", - "name": "havePriceProduct", - "arguments": [ - { - "skuProductAbstract": "#concreteProduct.abstract_sku", - "skuProduct": "#concreteProduct.sku", - "moneyValue": { "netAmount": 30000, "grossAmount": 30000 } - } - ] - }, - { - "type": "helper", - "name": "haveProductOffer", - "key": "productOfferFromMerchant1", - "arguments": [ - { - "isActive": true, - "status": "approved", - "idProductConcrete": "#concreteProduct.id_product_concrete", - "concreteSku": "#concreteProduct.sku", - "merchantReference": "#merchant1.merchant_reference", - "stores": "#stores" - } - ] - }, - { - "type": "helper", - "name": "haveProductOfferStock", - "arguments": [ - { - "idProductOffer": "#productOfferFromMerchant1.id_product_offer", - "productOfferReference": "#productOfferFromMerchant1.product_offer_reference", - "isNeverOutOfStock": true - }, - "#merchant1.stocks" - ] - }, - { - "type": "helper", - "name": "haveProductOffer", - "key": "productOfferFromMerchant2", - "arguments": [ - { - "isActive": true, - "status": "approved", - "idProductConcrete": "#concreteProduct.id_product_concrete", - "concreteSku": "#concreteProduct.sku", - "merchantReference": "#merchant2.merchant_reference", - "stores": "#stores" - } - ] - }, - { - "type": "helper", - "name": "haveProductOfferStock", - "arguments": [ - { - "idProductOffer": "#productOfferFromMerchant2.id_product_offer", - "productOfferReference": "#productOfferFromMerchant2.product_offer_reference", - "isNeverOutOfStock": true - }, - "#merchant2.stocks" - ] - }, - { - "type": "helper", - "name": "haveProductOffer", - "key": "productOfferFromMerchant3", - "arguments": [ - { - "isActive": true, - "status": "approved", - "idProductConcrete": "#concreteProduct.id_product_concrete", - "concreteSku": "#concreteProduct.sku", - "merchantReference": "#merchant3.merchant_reference", - "stores": "#stores" - } - ] - }, - { - "type": "helper", - "name": "haveProductOfferStock", - "arguments": [ - { - "idProductOffer": "#productOfferFromMerchant3.id_product_offer", - "productOfferReference": "#productOfferFromMerchant3.product_offer_reference", - "isNeverOutOfStock": true - }, - "#merchant3.stocks" - ] - }, { "type": "helper", "name": "haveCountry", @@ -395,22 +262,6 @@ "key": "businessUnit2FromCompany2", "arguments": [{ "fkCompany": "#company2.id_company" }] }, - { - "type": "helper", - "name": "havePermissionByKey", - "key": "permission", - "arguments": ["CreateMerchantRelationRequestPermissionPlugin"] - }, - { - "type": "helper", - "name": "haveCompanyRoleWithPermissions", - "arguments": [{ "isDefault": true, "fkCompany": "#company1.id_company" }, ["#permission"]] - }, - { - "type": "helper", - "name": "haveCompanyRoleWithPermissions", - "arguments": [{ "isDefault": true, "fkCompany": "#company2.id_company" }, ["#permission"]] - }, { "type": "helper", "name": "haveCompanyUser", @@ -449,6 +300,87 @@ "fkCompanyBusinessUnit": "#businessUnit1FromCompany2.id_company_business_unit" } ] + }, + { + "type": "array-object", + "key": "assigneeCompanyBusinessUnitsFromCompany1", + "arguments": ["#businessUnit1FromCompany1", "#businessUnit2FromCompany1"] + }, + { + "type": "array-object", + "key": "assigneeCompanyBusinessUnitsFromCompany2", + "arguments": ["#businessUnit1FromCompany2", "#businessUnit2FromCompany2"] + }, + { + "type": "helper", + "name": "haveMerchantRelationRequest", + "key": "requestFromMerchant1", + "arguments": [ + { + "status": "pending", + "merchant": "#merchant1", + "companyUser": "#companyUser1FromCompany1", + "ownerCompanyBusinessUnit": "#businessUnit1FromCompany1", + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany1" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantRelationRequest", + "key": "requestFromMerchant2", + "arguments": [ + { + "status": "pending", + "merchant": "#merchant2", + "companyUser": "#companyUser1FromCompany2", + "ownerCompanyBusinessUnit": "#businessUnit1FromCompany2", + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany2" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantRelationRequest", + "key": "requestFromMerchant3", + "arguments": [ + { + "status": "pending", + "merchant": "#merchant3", + "companyUser": "#companyUser1FromCompany2", + "ownerCompanyBusinessUnit": "#businessUnit1FromCompany2", + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany2" + } + ] + }, + { + "type": "helper", + "name": "haveComment", + "arguments": [ + { + "comment": { + "message": "This is dummy message from merchant user 1.", + "fkUser": "#merchantUser1FromMerchant1.id_user" + }, + "ownerType": "merchant_relation_request", + "ownerId": "#requestFromMerchant1.id_merchant_relation_request" + } + ] + }, + { + "type": "helper", + "name": "haveComment", + "key": "commentFromMerchantUser2", + "arguments": [ + { + "comment": { + "message": "This is dummy message from merchant user 2.", + "fkUser": "#merchantUser2FromMerchant1.id_user" + }, + "ownerType": "merchant_relation_request", + "ownerId": "#requestFromMerchant1.id_merchant_relation_request" + } + ] } ] } diff --git a/cypress/fixtures/suite/backoffice/merchant-b2b-contract-requests/static-request-management.json b/cypress/fixtures/suite/backoffice/merchant-b2b-contract-requests/static-request-management.json new file mode 100644 index 00000000..a22bdafc --- /dev/null +++ b/cypress/fixtures/suite/backoffice/merchant-b2b-contract-requests/static-request-management.json @@ -0,0 +1,6 @@ +{ + "defaultPassword": "change123", + "internalCommentFromMerchantUser1": "This is dummy message from merchant user 1.", + "internalCommentFromMerchantUser2": "This is dummy message from merchant user 2.", + "internalCommentFromRootUser": "This is dummy message from root user." +} diff --git a/cypress/support/pages/backoffice/index.ts b/cypress/support/pages/backoffice/index.ts index 2faeedfc..8cb7d1fc 100644 --- a/cypress/support/pages/backoffice/index.ts +++ b/cypress/support/pages/backoffice/index.ts @@ -11,3 +11,6 @@ export * from './user/create/user-create-page'; export * from './user/delete/user-delete-page'; export * from './user/index/user-index-page'; export * from './user/update/user-update-page'; +export * from './merchant-relation-request-gui/list/merchant-relation-request-gui-list-page'; +export * from './merchant-relation-request-gui/edit/merchant-relation-request-gui-edit-page'; +export * from './merchant-relationship-gui/list/merchant-relationship-gui-list-page'; diff --git a/cypress/support/pages/backoffice/merchant-relation-request-gui/edit/merchant-relation-request-gui-edit-page.ts b/cypress/support/pages/backoffice/merchant-relation-request-gui/edit/merchant-relation-request-gui-edit-page.ts new file mode 100644 index 00000000..dbca5119 --- /dev/null +++ b/cypress/support/pages/backoffice/merchant-relation-request-gui/edit/merchant-relation-request-gui-edit-page.ts @@ -0,0 +1,31 @@ +import { autoWired } from '@utils'; +import { inject, injectable } from 'inversify'; +import { BackofficePage } from '../../backoffice-page'; +import { MerchantRelationRequestGuiEditRepository } from './merchant-relation-request-gui-edit-repository'; + +@injectable() +@autoWired +export class MerchantRelationRequestGuiEditPage extends BackofficePage { + @inject(MerchantRelationRequestGuiEditRepository) private repository: MerchantRelationRequestGuiEditRepository; + + protected PAGE_URL = '/merchant-relation-request-gui/edit'; + + addInternalComment = (comment: string): void => { + this.repository.getInternalCommentTextarea().type(comment); + this.repository.getInternalCommentSubmitButton().click(); + }; + + rejectRequest = (): void => { + this.repository.getRejectButton().click(); + this.repository.getConfirmRejectButton().click(); + }; + + approveRequest = (isSplitEnabled: boolean): void => { + this.repository.getApprovalButton().click(); + + if (isSplitEnabled) { + this.repository.getIsSplitEnabledCheckbox().check(); + } + this.repository.getConfirmApprovalButton().click(); + }; +} diff --git a/cypress/support/pages/backoffice/merchant-relation-request-gui/edit/merchant-relation-request-gui-edit-repository.ts b/cypress/support/pages/backoffice/merchant-relation-request-gui/edit/merchant-relation-request-gui-edit-repository.ts new file mode 100644 index 00000000..d8171eac --- /dev/null +++ b/cypress/support/pages/backoffice/merchant-relation-request-gui/edit/merchant-relation-request-gui-edit-repository.ts @@ -0,0 +1,15 @@ +import { autoWired } from '@utils'; +import { injectable } from 'inversify'; + +@injectable() +@autoWired +export class MerchantRelationRequestGuiEditRepository { + getInternalCommentTextarea = (): Cypress.Chainable => cy.get('[action="/comment-gui/comment/add"] textarea'); + getInternalCommentSubmitButton = (): Cypress.Chainable => + cy.get('[action="/comment-gui/comment/add"] [type="submit"]'); + getRejectButton = (): Cypress.Chainable => cy.get('#merchantRelationRequest_reject'); + getApprovalButton = (): Cypress.Chainable => cy.get('#merchantRelationRequest_approve'); + getConfirmRejectButton = (): Cypress.Chainable => cy.get('#reject_merchant_relation_request_form_reject'); + getIsSplitEnabledCheckbox = (): Cypress.Chainable => cy.get('#approve_merchant_relation_request_form_isSplitEnabled'); + getConfirmApprovalButton = (): Cypress.Chainable => cy.get('#approve_merchant_relation_request_form_approve'); +} diff --git a/cypress/support/pages/backoffice/merchant-relation-request-gui/list/merchant-relation-request-gui-list-page.ts b/cypress/support/pages/backoffice/merchant-relation-request-gui/list/merchant-relation-request-gui-list-page.ts new file mode 100644 index 00000000..1773a6c6 --- /dev/null +++ b/cypress/support/pages/backoffice/merchant-relation-request-gui/list/merchant-relation-request-gui-list-page.ts @@ -0,0 +1,40 @@ +import { autoWired } from '@utils'; +import { inject, injectable } from 'inversify'; + +import { BackofficePage } from '../../backoffice-page'; +import { MerchantRelationRequestGuiListRepository } from './merchant-relation-request-gui-list-repository'; + +interface MerchantRelationRequestGuiListParams { + idMerchant?: number; + idCompany?: number; +} + +@injectable() +@autoWired +export class MerchantRelationRequestGuiListPage extends BackofficePage { + @inject(MerchantRelationRequestGuiListRepository) private repository: MerchantRelationRequestGuiListRepository; + + protected PAGE_URL = '/merchant-relation-request-gui/list'; + + editLastRequest = (params: MerchantRelationRequestGuiListParams): void => { + if (params.idMerchant) { + this.repository.getFilterMerchantSelect().select(params.idMerchant.toString()); + } + if (params.idCompany) { + this.repository.getFilterCompanySelect().select(params.idCompany.toString()); + } + + this.repository.getEditButtons().first().click(); + }; + + viewLastRequest = (params: MerchantRelationRequestGuiListParams): void => { + if (params.idMerchant) { + this.repository.getFilterMerchantSelect().select(params.idMerchant.toString()); + } + if (params.idCompany) { + this.repository.getFilterCompanySelect().select(params.idCompany.toString()); + } + + this.repository.getViewButtons().first().click(); + }; +} diff --git a/cypress/support/pages/backoffice/merchant-relation-request-gui/list/merchant-relation-request-gui-list-repository.ts b/cypress/support/pages/backoffice/merchant-relation-request-gui/list/merchant-relation-request-gui-list-repository.ts new file mode 100644 index 00000000..c6f07cb2 --- /dev/null +++ b/cypress/support/pages/backoffice/merchant-relation-request-gui/list/merchant-relation-request-gui-list-repository.ts @@ -0,0 +1,11 @@ +import { autoWired } from '@utils'; +import { injectable } from 'inversify'; + +@injectable() +@autoWired +export class MerchantRelationRequestGuiListRepository { + getFilterMerchantSelect = (): Cypress.Chainable => cy.get('#idMerchant'); + getFilterCompanySelect = (): Cypress.Chainable => cy.get('#idCompany'); + getEditButtons = (): Cypress.Chainable => cy.get('.btn-edit'); + getViewButtons = (): Cypress.Chainable => cy.get('.btn-view'); +} diff --git a/cypress/support/pages/backoffice/merchant-relationship-gui/list/merchant-relationship-gui-list-page.ts b/cypress/support/pages/backoffice/merchant-relationship-gui/list/merchant-relationship-gui-list-page.ts new file mode 100644 index 00000000..b36d6a2c --- /dev/null +++ b/cypress/support/pages/backoffice/merchant-relationship-gui/list/merchant-relationship-gui-list-page.ts @@ -0,0 +1,34 @@ +import { autoWired } from '@utils'; +import { inject, injectable } from 'inversify'; + +import { BackofficePage } from '../../backoffice-page'; +import { MerchantRelationshipGuiListRepository } from './merchant-relationship-gui-list-repository'; + +interface MerchantRelationshipGuiListParams { + idCompany?: number; + query?: string; +} + +@injectable() +@autoWired +export class MerchantRelationshipGuiListPage extends BackofficePage { + @inject(MerchantRelationshipGuiListRepository) private repository: MerchantRelationshipGuiListRepository; + + protected PAGE_URL = '/merchant-relationship-gui/list-merchant-relationship'; + + applyFilters = (params: MerchantRelationshipGuiListParams): void => { + if (params.idCompany) { + this.repository.getFilterCompanySelect().select(params.idCompany.toString()); + } + if (params.query) { + this.repository.getFilterSearchInput().type(params.query); + } + }; + + getEditButtons = (): Cypress.Chainable => this.repository.getEditButtons(); + + editLastRelation = (params: MerchantRelationshipGuiListParams): void => { + this.applyFilters(params); + this.repository.getEditButtons().first().click(); + }; +} diff --git a/cypress/support/pages/backoffice/merchant-relationship-gui/list/merchant-relationship-gui-list-repository.ts b/cypress/support/pages/backoffice/merchant-relationship-gui/list/merchant-relationship-gui-list-repository.ts new file mode 100644 index 00000000..5e4c7cce --- /dev/null +++ b/cypress/support/pages/backoffice/merchant-relationship-gui/list/merchant-relationship-gui-list-repository.ts @@ -0,0 +1,10 @@ +import { autoWired } from '@utils'; +import { injectable } from 'inversify'; + +@injectable() +@autoWired +export class MerchantRelationshipGuiListRepository { + getFilterCompanySelect = (): Cypress.Chainable => cy.get('#company-select'); + getFilterSearchInput = (): Cypress.Chainable => cy.get('#merchant-relationship-table_filter [type="search"]'); + getEditButtons = (): Cypress.Chainable => cy.get('.btn-edit'); +} diff --git a/cypress/support/types/backoffice/index.ts b/cypress/support/types/backoffice/index.ts index b8464999..e8952e00 100644 --- a/cypress/support/types/backoffice/index.ts +++ b/cypress/support/types/backoffice/index.ts @@ -1,2 +1,3 @@ export * from './order-management'; export * from './return-management'; +export * from './merchant-b2b-contract-requests'; diff --git a/cypress/support/types/backoffice/merchant-b2b-contract-requests.ts b/cypress/support/types/backoffice/merchant-b2b-contract-requests.ts new file mode 100644 index 00000000..582a53e3 --- /dev/null +++ b/cypress/support/types/backoffice/merchant-b2b-contract-requests.ts @@ -0,0 +1,49 @@ +import { + Company, + CompanyBusinessUnit, + CompanyUser, + Customer, + Merchant, + MerchantRelationRequest, + Url, + User, +} from './shared'; + +export interface RequestManagementDynamicFixtures { + rootUser: User; + + merchant1: Merchant; + merchantUrl1: Url; + merchantUser1FromMerchant1: User; + merchantUser2FromMerchant1: User; + + merchant2: Merchant; + merchantUrl2: Url; + merchantUserFromMerchant2: User; + + merchant3: Merchant; + merchantUrl3: Url; + + customer: Customer; + + company1: Company; + businessUnit1FromCompany1: CompanyBusinessUnit; + businessUnit2FromCompany1: CompanyBusinessUnit; + companyUser1FromCompany1: CompanyUser; + companyUser2FromCompany1: CompanyUser; + + company2: Company; + businessUnit1FromCompany2: CompanyBusinessUnit; + businessUnit2FromCompany2: CompanyBusinessUnit; + companyUser1FromCompany2: CompanyUser; + + requestFromMerchant1: MerchantRelationRequest; + requestFromMerchant2: MerchantRelationRequest; +} + +export interface RequestManagementStaticFixtures { + defaultPassword: string; + internalCommentFromMerchantUser1: string; + internalCommentFromMerchantUser2: string; + internalCommentFromRootUser: string; +} diff --git a/cypress/support/types/backoffice/shared/company-business-unit.ts b/cypress/support/types/backoffice/shared/company-business-unit.ts new file mode 100644 index 00000000..76bffdf3 --- /dev/null +++ b/cypress/support/types/backoffice/shared/company-business-unit.ts @@ -0,0 +1,5 @@ +export interface CompanyBusinessUnit { + id_company_business_unit: number; + key: string; + name: string; +} diff --git a/cypress/support/types/backoffice/shared/company-user.ts b/cypress/support/types/backoffice/shared/company-user.ts new file mode 100644 index 00000000..250de7f7 --- /dev/null +++ b/cypress/support/types/backoffice/shared/company-user.ts @@ -0,0 +1,3 @@ +export interface CompanyUser { + id_company_user: number; +} diff --git a/cypress/support/types/backoffice/shared/company.ts b/cypress/support/types/backoffice/shared/company.ts new file mode 100644 index 00000000..27e0b572 --- /dev/null +++ b/cypress/support/types/backoffice/shared/company.ts @@ -0,0 +1,5 @@ +export interface Company { + id_company: number; + key: string; + name: string; +} diff --git a/cypress/support/types/backoffice/shared/index.ts b/cypress/support/types/backoffice/shared/index.ts index 351cf336..b97df43b 100644 --- a/cypress/support/types/backoffice/shared/index.ts +++ b/cypress/support/types/backoffice/shared/index.ts @@ -3,3 +3,9 @@ export * from './customer'; export * from './product'; export * from './quote'; export * from './user'; +export * from './company'; +export * from './company-business-unit'; +export * from './company-user'; +export * from './merchant'; +export * from './merchant-relation-request'; +export * from './url'; diff --git a/cypress/support/types/backoffice/shared/merchant-relation-request.ts b/cypress/support/types/backoffice/shared/merchant-relation-request.ts new file mode 100644 index 00000000..c317cf57 --- /dev/null +++ b/cypress/support/types/backoffice/shared/merchant-relation-request.ts @@ -0,0 +1,4 @@ +export interface MerchantRelationRequest { + id_merchant_relation_request: number; + uuid: string; +} diff --git a/cypress/support/types/backoffice/shared/merchant.ts b/cypress/support/types/backoffice/shared/merchant.ts new file mode 100644 index 00000000..b7a623f7 --- /dev/null +++ b/cypress/support/types/backoffice/shared/merchant.ts @@ -0,0 +1,5 @@ +export interface Merchant { + id_merchant: number; + merchant_reference: string; + name: string; +} diff --git a/cypress/support/types/backoffice/shared/url.ts b/cypress/support/types/backoffice/shared/url.ts new file mode 100644 index 00000000..1b6cc537 --- /dev/null +++ b/cypress/support/types/backoffice/shared/url.ts @@ -0,0 +1,3 @@ +export interface Url { + url: string; +} diff --git a/cypress/support/types/mp/merchant-b2b-contract-requests.ts b/cypress/support/types/mp/merchant-b2b-contract-requests.ts index 2798d960..c91d3335 100644 --- a/cypress/support/types/mp/merchant-b2b-contract-requests.ts +++ b/cypress/support/types/mp/merchant-b2b-contract-requests.ts @@ -55,44 +55,7 @@ export interface RequestManagementDynamicFixtures { request5FromMerchant1: MerchantRelationRequest; } -export interface Dummy { - merchant1: Merchant; - merchantUrl1: Url; - merchantUser1FromMerchant1: User; - merchantUser2FromMerchant1: User; - - merchant2: Merchant; - merchantUrl2: Url; - merchantUserFromMerchant2: User; - - merchant3: Merchant; - merchantUrl3: Url; - merchantUserFromMerchant3: User; - - concreteProduct: ProductConcrete; - productOfferFromMerchant1: ProductOffer; - productOfferFromMerchant2: ProductOffer; - productOfferFromMerchant3: ProductOffer; - - customer: Customer; - - company1: Company; - businessUnit1FromCompany1: CompanyBusinessUnit; - businessUnit2FromCompany1: CompanyBusinessUnit; - companyUser1FromCompany1: CompanyUser; - companyUser2FromCompany1: CompanyUser; - - company2: Company; - businessUnit1FromCompany2: CompanyBusinessUnit; - businessUnit2FromCompany2: CompanyBusinessUnit; - companyUser1FromCompany2: CompanyUser; -} - export interface RequestManagementStaticFixtures { defaultPassword: string; internalComment: string; } - -export interface MerchantB2bContractRequestsStaticFixtures { - defaultPassword: string; -} From 9ef63e06a7810500a7e58fe9140ca7584ce15a01 Mon Sep 17 00:00:00 2001 From: Dmytro Asieiev Date: Fri, 22 Mar 2024 15:26:14 +0300 Subject: [PATCH 5/7] Refactored code before review. --- .../request-management.cy.ts | 120 ++++++++++++------ .../order-management/order-creation.cy.ts | 12 +- .../return-management/return-creation.cy.ts | 53 ++++---- .../agent-authorization.cy.ts | 27 +++- .../agent-dashboard.cy.ts | 78 ++++++------ .../agent-impersonation.cy.ts | 48 ++----- .../agent-login.cy.ts | 37 ++++-- .../agent-merchant-portal.cy.ts | 65 +++++----- .../agent-permission.cy.ts | 71 ++--------- .../request-management.cy.ts | 62 ++++----- .../e2e/yves/checkout/basic-checkout.cy.ts | 31 ++--- cypress/e2e/yves/comments/cart-comments.cy.ts | 26 ++-- .../request-creation.cy.ts | 48 ++++--- .../request-management.cy.ts | 45 ++++--- .../pages/backoffice/backoffice-page.ts | 23 ++++ cypress/support/pages/backoffice/index.ts | 9 +- .../pages/backoffice/index/index-page.ts | 2 +- .../pages/backoffice/login/login-page.ts | 14 +- ...merchant-relation-request-gui-edit-page.ts | 31 ----- ...merchant-relation-request-gui-list-page.ts | 40 ------ .../merchant-relation-request-edit-page.ts | 40 ++++++ ...chant-relation-request-edit-repository.ts} | 2 +- .../merchant-relation-request-list-page.ts | 39 ++++++ ...chant-relation-request-list-repository.ts} | 2 +- .../list/merchant-relationship-list-page.ts} | 30 +++-- .../merchant-relationship-list-repository.ts} | 2 +- .../create/merchant-user-create-page.ts | 16 +-- .../merchant/create/merchant-create-page.ts | 19 ++- .../merchant/list/merchant-list-page.ts | 67 ++++------ .../merchant/list/merchant-list-repository.ts | 2 +- .../merchant/update/merchant-update-page.ts | 18 +-- .../update/merchant-update-repository.ts | 2 +- .../create/sales-return-gui-create-page.ts | 18 --- .../create/sales-return-create-page.ts | 17 +++ .../create/sales-return-create-repository.ts} | 2 +- .../sales/detail/sales-detail-page.ts | 23 ++-- .../sales/index/sales-index-page.ts | 6 +- .../user/create/user-create-page.ts | 61 ++++----- .../user/delete/user-delete-page.ts | 5 +- .../backoffice/user/index/user-index-page.ts | 59 ++++----- .../user/index/user-index-repository.ts | 2 +- .../user/update/user-update-page.ts | 3 +- .../agent-dashboard/agent-dashboard-page.ts | 50 +++++--- .../agent-dashboard-repository.ts | 2 + .../pages/mp/agent-login/agent-login-page.ts | 13 +- .../pages/mp/dashboard/dashboard-page.ts | 2 +- cypress/support/pages/mp/index.ts | 1 + cypress/support/pages/mp/login/login-page.ts | 14 +- .../merchant-relation-requests-page.ts | 57 ++++++--- .../merchant-relation-requests-repository.ts | 6 +- .../merchant-relations-page.ts | 20 +-- .../merchant-relations-repository.ts | 2 +- cypress/support/pages/mp/mp-page.ts | 13 ++ .../support/pages/mp/offers/offers-page.ts | 22 +++- .../pages/mp/offers/offers-repository.ts | 3 +- .../pages/mp/products/products-page.ts | 29 +++-- .../pages/mp/products/products-repository.ts | 3 +- .../support/pages/mp/profile/profile-page.ts | 11 +- .../pages/mp/sales/sales-orders-page.ts | 28 ++-- .../pages/mp/sales/sales-orders-repository.ts | 3 +- .../yves/agent-login/agent-login-page.ts | 13 +- cypress/support/pages/yves/cart/cart-page.ts | 35 +++-- .../pages/yves/catalog/catalog-page.ts | 31 +---- .../pages/yves/catalog/catalog-repository.ts | 3 - .../repositories/suite-catalog-repository.ts | 4 - .../checkout/address/checkout-address-page.ts | 40 +++--- .../customer/checkout-customer-page.ts | 2 +- .../checkout/payment/checkout-payment-page.ts | 2 +- .../shipment/checkout-shipment-page.ts | 2 +- .../checkout/summary/checkout-summary-page.ts | 2 +- .../yves/comment/cart/comment-cart-page.ts | 49 ++++--- .../merchant-relation-request-create-page.ts | 18 +-- .../merchant-relation-request-details-page.ts | 2 +- .../merchant-relation-request-index-page.ts | 18 +-- .../user/select/company-user-select-page.ts | 10 +- cypress/support/pages/yves/index.ts | 2 + .../support/pages/yves/login/login-page.ts | 13 +- .../pages/yves/merchant/merchant-page.ts | 2 +- .../pages/yves/multi-cart/multi-cart-page.ts | 18 ++- .../pages/yves/product/product-page.ts | 48 +++++++ .../pages/yves/product/product-repository.ts | 6 + .../repositories/suite-product-repository.ts | 12 ++ .../backoffice/user-login-scenario.ts | 18 ++- .../impersonate-as-merchant-user-scenario.ts | 12 +- .../mp/merchant-agent-login-user-scenario.ts | 18 ++- .../mp/merchant-user-login-scenario.ts | 14 +- .../scenarios/yves/agent-login-scenario.ts | 11 +- .../scenarios/yves/checkout-mp-scenario.ts | 18 ++- .../scenarios/yves/checkout-scenario.ts | 30 ++--- .../scenarios/yves/customer-login-scenario.ts | 18 ++- .../utils/inversify/inversify.config.ts | 2 + cypress/support/utils/inversify/types.ts | 1 + 92 files changed, 1141 insertions(+), 889 deletions(-) delete mode 100644 cypress/support/pages/backoffice/merchant-relation-request-gui/edit/merchant-relation-request-gui-edit-page.ts delete mode 100644 cypress/support/pages/backoffice/merchant-relation-request-gui/list/merchant-relation-request-gui-list-page.ts create mode 100644 cypress/support/pages/backoffice/merchant-relation-request/edit/merchant-relation-request-edit-page.ts rename cypress/support/pages/backoffice/{merchant-relation-request-gui/edit/merchant-relation-request-gui-edit-repository.ts => merchant-relation-request/edit/merchant-relation-request-edit-repository.ts} (93%) create mode 100644 cypress/support/pages/backoffice/merchant-relation-request/list/merchant-relation-request-list-page.ts rename cypress/support/pages/backoffice/{merchant-relation-request-gui/list/merchant-relation-request-gui-list-repository.ts => merchant-relation-request/list/merchant-relation-request-list-repository.ts} (87%) rename cypress/support/pages/backoffice/{merchant-relationship-gui/list/merchant-relationship-gui-list-page.ts => merchant-relationship/list/merchant-relationship-list-page.ts} (50%) rename cypress/support/pages/backoffice/{merchant-relationship-gui/list/merchant-relationship-gui-list-repository.ts => merchant-relationship/list/merchant-relationship-list-repository.ts} (87%) delete mode 100644 cypress/support/pages/backoffice/sales-return-gui/create/sales-return-gui-create-page.ts create mode 100644 cypress/support/pages/backoffice/sales-return/create/sales-return-create-page.ts rename cypress/support/pages/backoffice/{sales-return-gui/create/sales-return-gui-create-repository.ts => sales-return/create/sales-return-create-repository.ts} (87%) create mode 100644 cypress/support/pages/yves/product/product-page.ts create mode 100644 cypress/support/pages/yves/product/product-repository.ts create mode 100644 cypress/support/pages/yves/product/repositories/suite-product-repository.ts diff --git a/cypress/e2e/backoffice/merchant-b2b-contract-requests/request-management.cy.ts b/cypress/e2e/backoffice/merchant-b2b-contract-requests/request-management.cy.ts index 05c6a3df..bf122b66 100644 --- a/cypress/e2e/backoffice/merchant-b2b-contract-requests/request-management.cy.ts +++ b/cypress/e2e/backoffice/merchant-b2b-contract-requests/request-management.cy.ts @@ -1,19 +1,20 @@ import { container } from '@utils'; -import { RequestManagementDynamicFixtures, RequestManagementStaticFixtures } from '../../../support/types/backoffice'; -import { UserLoginScenario } from '../../../support/scenarios/backoffice'; +import { RequestManagementDynamicFixtures, RequestManagementStaticFixtures } from '@interfaces/backoffice'; +import { UserLoginScenario } from '@scenarios/backoffice'; import { - MerchantRelationRequestGuiEditPage, - MerchantRelationRequestGuiListPage, - MerchantRelationshipGuiListPage, -} from '../../../support/pages/backoffice'; + ActionEnum, + MerchantRelationRequestEditPage, + MerchantRelationRequestListPage, + MerchantRelationshipListPage, +} from '@pages/backoffice'; /** * Merchant Relation Requests & Enhanced Merchant Relations checklists: {@link https://spryker.atlassian.net/wiki/spaces/CCS/pages/4105896492/Business+Journey+B2B+Marketplace+-+to+automate} */ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, (): void => { - const merchantRelationRequestGuiListPage = container.get(MerchantRelationRequestGuiListPage); - const merchantRelationRequestGuiEditPage = container.get(MerchantRelationRequestGuiEditPage); - const merchantRelationshipGuiListPage = container.get(MerchantRelationshipGuiListPage); + const merchantRelationRequestListPage = container.get(MerchantRelationRequestListPage); + const merchantRelationRequestEditPage = container.get(MerchantRelationRequestEditPage); + const merchantRelationshipListPage = container.get(MerchantRelationshipListPage); const userLoginScenario = container.get(UserLoginScenario); let dynamicFixtures: RequestManagementDynamicFixtures; @@ -34,71 +35,108 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () const merchants = [dynamicFixtures.merchant1, dynamicFixtures.merchant2, dynamicFixtures.merchant3]; merchants.forEach((merchant) => { - merchantRelationRequestGuiListPage.visit(); - merchantRelationRequestGuiListPage.editLastRequest({ idMerchant: merchant.id_merchant }); + merchantRelationRequestListPage.visit(); + merchantRelationRequestListPage.update({ + action: ActionEnum.edit, + idMerchant: merchant.id_merchant, + }); + cy.contains(merchant.name); }); }); it('operator should be able to see internal comments from all merchant users', (): void => { - merchantRelationRequestGuiListPage.visit(); - merchantRelationRequestGuiListPage.editLastRequest({ idMerchant: dynamicFixtures.merchant1.id_merchant }); + merchantRelationRequestListPage.visit(); + merchantRelationRequestListPage.update({ + action: ActionEnum.edit, + idMerchant: dynamicFixtures.merchant1.id_merchant, + }); cy.contains(staticFixtures.internalCommentFromMerchantUser1); cy.contains(staticFixtures.internalCommentFromMerchantUser2); }); it('operator should be able to add internal comment', (): void => { - merchantRelationRequestGuiListPage.visit(); - merchantRelationRequestGuiListPage.editLastRequest({ idMerchant: dynamicFixtures.merchant1.id_merchant }); - merchantRelationRequestGuiEditPage.addInternalComment(staticFixtures.internalCommentFromRootUser); + merchantRelationRequestListPage.visit(); + merchantRelationRequestListPage.update({ + action: ActionEnum.edit, + idMerchant: dynamicFixtures.merchant1.id_merchant, + }); + + merchantRelationRequestEditPage.addInternalComment({ comment: staticFixtures.internalCommentFromRootUser }); + + merchantRelationRequestListPage.visit(); + merchantRelationRequestListPage.update({ + action: ActionEnum.edit, + idMerchant: dynamicFixtures.merchant1.id_merchant, + }); - merchantRelationRequestGuiListPage.visit(); - merchantRelationRequestGuiListPage.editLastRequest({ idMerchant: dynamicFixtures.merchant1.id_merchant }); cy.contains(staticFixtures.internalCommentFromRootUser); }); it('operator should be able to reject request', (): void => { - merchantRelationRequestGuiListPage.visit(); - merchantRelationRequestGuiListPage.editLastRequest({ idMerchant: dynamicFixtures.merchant3.id_merchant }); - merchantRelationRequestGuiEditPage.rejectRequest(); + merchantRelationRequestListPage.visit(); + merchantRelationRequestListPage.update({ + action: ActionEnum.edit, + idMerchant: dynamicFixtures.merchant3.id_merchant, + }); + + merchantRelationRequestEditPage.reject(); + + merchantRelationRequestListPage.visit(); + merchantRelationRequestListPage.update({ + action: ActionEnum.view, + idMerchant: dynamicFixtures.merchant3.id_merchant, + }); - merchantRelationRequestGuiListPage.visit(); - merchantRelationRequestGuiListPage.viewLastRequest({ idMerchant: dynamicFixtures.merchant3.id_merchant }); cy.contains('Rejected'); - merchantRelationshipGuiListPage.visit(); - merchantRelationshipGuiListPage.applyFilters({ idCompany: dynamicFixtures.company2.id_company }); - merchantRelationshipGuiListPage.getEditButtons().should('have.length', 0); + merchantRelationshipListPage.visit(); + merchantRelationshipListPage.applyFilters({ idCompany: dynamicFixtures.company2.id_company }); + merchantRelationshipListPage.getEditButtons().should('have.length', 0); }); it('operator should be able to approve request (additionally copy internal comments to relation)', (): void => { - merchantRelationRequestGuiListPage.visit(); - merchantRelationRequestGuiListPage.editLastRequest({ idMerchant: dynamicFixtures.merchant1.id_merchant }); - merchantRelationRequestGuiEditPage.approveRequest(false); + merchantRelationRequestListPage.visit(); + merchantRelationRequestListPage.update({ + action: ActionEnum.edit, + idMerchant: dynamicFixtures.merchant1.id_merchant, + }); + + merchantRelationRequestEditPage.approve({ isSplitEnabled: false }); - merchantRelationRequestGuiListPage.visit(); - merchantRelationRequestGuiListPage.viewLastRequest({ idMerchant: dynamicFixtures.merchant1.id_merchant }); + merchantRelationRequestListPage.visit(); + merchantRelationRequestListPage.update({ + action: ActionEnum.view, + idMerchant: dynamicFixtures.merchant1.id_merchant, + }); cy.contains('Approved'); - merchantRelationshipGuiListPage.visit(); - merchantRelationshipGuiListPage.editLastRelation({ idCompany: dynamicFixtures.company1.id_company }); + merchantRelationshipListPage.visit(); + merchantRelationshipListPage.update({ idCompany: dynamicFixtures.company1.id_company }); cy.contains(staticFixtures.internalCommentFromMerchantUser1); cy.contains(staticFixtures.internalCommentFromMerchantUser2); }); it('operator should be able to approve request with enabled BU splitting', (): void => { - merchantRelationRequestGuiListPage.visit(); - merchantRelationRequestGuiListPage.editLastRequest({ idMerchant: dynamicFixtures.merchant2.id_merchant }); - merchantRelationRequestGuiEditPage.approveRequest(true); + merchantRelationRequestListPage.visit(); + merchantRelationRequestListPage.update({ + action: ActionEnum.edit, + idMerchant: dynamicFixtures.merchant2.id_merchant, + }); - merchantRelationRequestGuiListPage.visit(); - merchantRelationRequestGuiListPage.viewLastRequest({ idMerchant: dynamicFixtures.merchant2.id_merchant }); + merchantRelationRequestEditPage.approve({ isSplitEnabled: true }); + + merchantRelationRequestListPage.visit(); + merchantRelationRequestListPage.update({ + action: ActionEnum.view, + idMerchant: dynamicFixtures.merchant2.id_merchant, + }); cy.contains('Approved'); - merchantRelationshipGuiListPage.visit(); - merchantRelationshipGuiListPage.applyFilters({ idCompany: dynamicFixtures.company2.id_company }); - merchantRelationshipGuiListPage.getEditButtons().should('have.length', 2); + merchantRelationshipListPage.visit(); + merchantRelationshipListPage.applyFilters({ idCompany: dynamicFixtures.company2.id_company }); + merchantRelationshipListPage.getEditButtons().should('have.length', 2); }); }); diff --git a/cypress/e2e/backoffice/order-management/order-creation.cy.ts b/cypress/e2e/backoffice/order-management/order-creation.cy.ts index 82527348..e4efc150 100644 --- a/cypress/e2e/backoffice/order-management/order-creation.cy.ts +++ b/cypress/e2e/backoffice/order-management/order-creation.cy.ts @@ -1,9 +1,9 @@ +import { container } from '@utils'; import { OrderCreationDynamicFixtures, OrderManagementStaticFixtures } from '@interfaces/backoffice'; import { SalesIndexPage } from '@pages/backoffice'; import { CartPage } from '@pages/yves'; import { UserLoginScenario } from '@scenarios/backoffice'; import { CheckoutScenario, CustomerLoginScenario } from '@scenarios/yves'; -import { container } from '@utils'; describe('order creation', { tags: ['@order-management'] }, (): void => { const cartPage = container.get(CartPage); @@ -33,14 +33,16 @@ describe('order creation', { tags: ['@order-management'] }, (): void => { username: dynamicFixtures.rootUser.username, password: staticFixtures.defaultPassword, }); - salesIndexPage.viewLastPlacedOrder(); + + salesIndexPage.visit(); + salesIndexPage.view(); cy.get('body').contains(dynamicFixtures.product.name); }); it('should be able to create an order by guest', (): void => { cartPage.visit(); - cartPage.quickAddToCart(dynamicFixtures.product.sku, 1); + cartPage.quickAddToCart({ sku: dynamicFixtures.product.sku, quantity: 1 }); checkoutScenario.execute({ isGuest: true }); cy.contains('Your order has been placed successfully!'); @@ -49,7 +51,9 @@ describe('order creation', { tags: ['@order-management'] }, (): void => { username: dynamicFixtures.rootUser.username, password: staticFixtures.defaultPassword, }); - salesIndexPage.viewLastPlacedOrder(); + + salesIndexPage.visit(); + salesIndexPage.view(); cy.get('body').contains(dynamicFixtures.product.name); }); diff --git a/cypress/e2e/backoffice/return-management/return-creation.cy.ts b/cypress/e2e/backoffice/return-management/return-creation.cy.ts index 8ec1ea63..1c5610aa 100644 --- a/cypress/e2e/backoffice/return-management/return-creation.cy.ts +++ b/cypress/e2e/backoffice/return-management/return-creation.cy.ts @@ -1,13 +1,13 @@ +import { container } from '@utils'; import { ReturnCreationDynamicFixtures, ReturnManagementStaticFixtures } from '@interfaces/backoffice'; -import { SalesDetailPage, SalesIndexPage, SalesReturnGuiCreatePage } from '@pages/backoffice'; +import { SalesDetailPage, SalesIndexPage, SalesReturnCreatePage } from '@pages/backoffice'; import { UserLoginScenario } from '@scenarios/backoffice'; import { CheckoutScenario, CustomerLoginScenario } from '@scenarios/yves'; -import { container } from '@utils'; describe('return creation', { tags: ['@return-management'] }, (): void => { const salesIndexPage = container.get(SalesIndexPage); const salesDetailPage = container.get(SalesDetailPage); - const salesReturnGuiCreatePage = container.get(SalesReturnGuiCreatePage); + const salesReturnCreatePage = container.get(SalesReturnCreatePage); const customerLoginScenario = container.get(CustomerLoginScenario); const userLoginScenario = container.get(UserLoginScenario); const checkoutScenario = container.get(CheckoutScenario); @@ -24,53 +24,46 @@ describe('return creation', { tags: ['@return-management'] }, (): void => { email: dynamicFixtures.customer.email, password: staticFixtures.defaultPassword, }); - }); - it('should be able to create return from (from shipped order state)', (): void => { checkoutScenario.execute({ isGuest: false, isMultiShipment: false, idCustomerAddress: dynamicFixtures.address.id_customer_address, }); + userLoginScenario.execute({ username: dynamicFixtures.rootUser.username, password: staticFixtures.defaultPassword, }); + }); + it('should be able to create return from (from shipped order state)', (): void => { salesIndexPage.visit(); - salesIndexPage.viewLastPlacedOrder(); - salesDetailPage.triggerOms('Pay', true); - salesDetailPage.triggerOms('Skip timeout'); - salesDetailPage.triggerOms('skip picking'); - salesDetailPage.triggerOms('Ship'); + salesIndexPage.view(); + + salesDetailPage.triggerOms({ state: 'Pay', shouldTriggerOmsInCli: true }); + salesDetailPage.triggerOms({ state: 'Skip timeout' }); + salesDetailPage.triggerOms({ state: 'skip picking' }); + salesDetailPage.triggerOms({ state: 'Ship' }); - salesDetailPage.createReturn(); - salesReturnGuiCreatePage.createReturnForAllOrderItems(); + salesDetailPage.create(); + salesReturnCreatePage.create(); cy.contains('Return was successfully created.'); }); it('should be able to create return from (from delivery order state)', (): void => { - checkoutScenario.execute({ - isGuest: false, - isMultiShipment: false, - idCustomerAddress: dynamicFixtures.address.id_customer_address, - }); - userLoginScenario.execute({ - username: dynamicFixtures.rootUser.username, - password: staticFixtures.defaultPassword, - }); - salesIndexPage.visit(); - salesIndexPage.viewLastPlacedOrder(); - salesDetailPage.triggerOms('Pay', true); - salesDetailPage.triggerOms('Skip timeout'); - salesDetailPage.triggerOms('skip picking'); - salesDetailPage.triggerOms('Ship'); - salesDetailPage.triggerOms('Stock update'); + salesIndexPage.view(); + + salesDetailPage.triggerOms({ state: 'Pay', shouldTriggerOmsInCli: true }); + salesDetailPage.triggerOms({ state: 'Skip timeout' }); + salesDetailPage.triggerOms({ state: 'skip picking' }); + salesDetailPage.triggerOms({ state: 'Ship' }); + salesDetailPage.triggerOms({ state: 'Stock update' }); - salesDetailPage.createReturn(); - salesReturnGuiCreatePage.createReturnForAllOrderItems(); + salesDetailPage.create(); + salesReturnCreatePage.create(); cy.contains('Return was successfully created.'); }); diff --git a/cypress/e2e/mp/marketplace-agent-assist/agent-authorization.cy.ts b/cypress/e2e/mp/marketplace-agent-assist/agent-authorization.cy.ts index 6c58b0e0..b277c6ea 100644 --- a/cypress/e2e/mp/marketplace-agent-assist/agent-authorization.cy.ts +++ b/cypress/e2e/mp/marketplace-agent-assist/agent-authorization.cy.ts @@ -1,9 +1,9 @@ +import { container } from '@utils'; import { AgentAuthorizationDynamicFixtures, MarketplaceAgentAssistStaticFixtures } from '@interfaces/mp'; import { IndexPage } from '@pages/backoffice'; import { AgentLoginPage, LoginPage } from '@pages/yves'; import { UserLoginScenario } from '@scenarios/backoffice'; import { MerchantAgentLoginUserScenario } from '@scenarios/mp'; -import { container } from '@utils'; /** * Agent Assist in Merchant Portal checklists: {@link https://spryker.atlassian.net/wiki/spaces/CCS/pages/3975741526/Agent+Assist+in+Merchant+Portal+Checklists} @@ -44,7 +44,10 @@ describe('agent authorization', { tags: ['@marketplace-agent-assist'] }, (): voi it('agent (merchant user) should not be able to login to storefront agent dashboard', (): void => { yvesAgentLoginPage.visit(); - yvesAgentLoginPage.login(dynamicFixtures.merchantAgentUser.username, staticFixtures.defaultPassword); + yvesAgentLoginPage.login({ + username: dynamicFixtures.merchantAgentUser.username, + password: staticFixtures.defaultPassword, + }); cy.contains(yvesAgentLoginPage.getFailedAuthenticationText()); yvesAgentLoginPage.assertPageLocation(); @@ -52,7 +55,10 @@ describe('agent authorization', { tags: ['@marketplace-agent-assist'] }, (): voi it('merchant user should not be able to login to storefront agent dashboard', (): void => { yvesAgentLoginPage.visit(); - yvesAgentLoginPage.login(dynamicFixtures.merchantAgentUser.username, staticFixtures.defaultPassword); + yvesAgentLoginPage.login({ + username: dynamicFixtures.merchantUser.username, + password: staticFixtures.defaultPassword, + }); cy.contains(yvesAgentLoginPage.getFailedAuthenticationText()); yvesAgentLoginPage.assertPageLocation(); @@ -60,7 +66,10 @@ describe('agent authorization', { tags: ['@marketplace-agent-assist'] }, (): voi it('agent (merchant user) should not be able to login to storefront', (): void => { yvesLoginPage.visit(); - yvesLoginPage.login(dynamicFixtures.merchantAgentUser.username, staticFixtures.defaultPassword); + yvesLoginPage.login({ + email: dynamicFixtures.merchantAgentUser.username, + password: staticFixtures.defaultPassword, + }); cy.contains(yvesLoginPage.getFailedAuthenticationText()); yvesLoginPage.assertPageLocation(); @@ -68,7 +77,10 @@ describe('agent authorization', { tags: ['@marketplace-agent-assist'] }, (): voi it('agent (customer) should not be able to login to storefront', (): void => { yvesLoginPage.visit(); - yvesLoginPage.login(dynamicFixtures.customerAgentUser.username, staticFixtures.defaultPassword); + yvesLoginPage.login({ + email: dynamicFixtures.customerAgentUser.username, + password: staticFixtures.defaultPassword, + }); cy.contains(yvesLoginPage.getFailedAuthenticationText()); yvesLoginPage.assertPageLocation(); @@ -76,7 +88,10 @@ describe('agent authorization', { tags: ['@marketplace-agent-assist'] }, (): voi it('merchant user should not be able to login to storefront', (): void => { yvesLoginPage.visit(); - yvesLoginPage.login(dynamicFixtures.merchantUser.username, staticFixtures.defaultPassword); + yvesLoginPage.login({ + email: dynamicFixtures.merchantUser.username, + password: staticFixtures.defaultPassword, + }); cy.contains(yvesLoginPage.getFailedAuthenticationText()); yvesLoginPage.assertPageLocation(); diff --git a/cypress/e2e/mp/marketplace-agent-assist/agent-dashboard.cy.ts b/cypress/e2e/mp/marketplace-agent-assist/agent-dashboard.cy.ts index a001284b..7bb00339 100644 --- a/cypress/e2e/mp/marketplace-agent-assist/agent-dashboard.cy.ts +++ b/cypress/e2e/mp/marketplace-agent-assist/agent-dashboard.cy.ts @@ -1,8 +1,7 @@ +import { container } from '@utils'; import { AgentDashboardDynamicFixtures, MarketplaceAgentAssistStaticFixtures } from '@interfaces/mp'; import { AgentDashboardPage, DashboardPage, AgentLoginPage as MpAgentLoginPage } from '@pages/mp'; -import { UserLoginScenario } from '@scenarios/backoffice'; import { MerchantAgentLoginUserScenario } from '@scenarios/mp'; -import { container } from '@utils'; /** * Agent Assist in Merchant Portal checklists: {@link https://spryker.atlassian.net/wiki/spaces/CCS/pages/3975741526/Agent+Assist+in+Merchant+Portal+Checklists} @@ -11,7 +10,6 @@ describe('agent dashboard', { tags: ['@marketplace-agent-assist'] }, (): void => const mpAgentLoginPage = container.get(MpAgentLoginPage); const mpDashboardPage = container.get(DashboardPage); const mpAgentDashboardPage = container.get(AgentDashboardPage); - const userLoginScenario = container.get(UserLoginScenario); const merchantAgentLoginUserScenario = container.get(MerchantAgentLoginUserScenario); let dynamicFixtures: AgentDashboardDynamicFixtures; @@ -46,7 +44,7 @@ describe('agent dashboard', { tags: ['@marketplace-agent-assist'] }, (): void => }); mpAgentDashboardPage.visit(); - mpAgentDashboardPage.findMerchantUser(dynamicFixtures.merchantUser.username).should('exist'); + mpAgentDashboardPage.find({ query: dynamicFixtures.merchantUser.username }).should('exist'); }); it('agent should be able to filter by merchant user properties', (): void => { @@ -56,110 +54,106 @@ describe('agent dashboard', { tags: ['@marketplace-agent-assist'] }, (): void => }); mpAgentDashboardPage.visit(); - mpAgentDashboardPage.findMerchantUser(dynamicFixtures.merchant.name, 3).should('exist'); - mpAgentDashboardPage.findMerchantUser(dynamicFixtures.merchantUser.username).should('exist'); + mpAgentDashboardPage.find({ query: dynamicFixtures.merchant.name, expectedCount: 3 }).should('exist'); + mpAgentDashboardPage.find({ query: dynamicFixtures.merchantUser.username }).should('exist'); }); it('agent should be able to see/assist inactive merchant user in a table', (): void => { mpAgentLoginPage.visit(); - mpAgentLoginPage.login(dynamicFixtures.merchantAgentUser.username, staticFixtures.defaultPassword); + mpAgentLoginPage.login({ + username: dynamicFixtures.merchantAgentUser.username, + password: staticFixtures.defaultPassword, + }); mpAgentDashboardPage.visit(); - mpAgentDashboardPage.findMerchantUser(dynamicFixtures.deactivatedMerchantUser.username).should('exist'); + mpAgentDashboardPage.find({ query: dynamicFixtures.deactivatedMerchantUser.username }).should('exist'); mpAgentDashboardPage.visit(); - mpAgentDashboardPage.assistMerchantUser(dynamicFixtures.deactivatedMerchantUser.username); + mpAgentDashboardPage.assist({ query: dynamicFixtures.deactivatedMerchantUser.username }); mpDashboardPage.assertPageLocation(); }); it('agent should be able to see/assist deleted merchant user in a table', (): void => { mpAgentLoginPage.visit(); - mpAgentLoginPage.login(dynamicFixtures.merchantAgentUser.username, staticFixtures.defaultPassword); + mpAgentLoginPage.login({ + username: dynamicFixtures.merchantAgentUser.username, + password: staticFixtures.defaultPassword, + }); mpAgentDashboardPage.visit(); - mpAgentDashboardPage.findMerchantUser(dynamicFixtures.deletedMerchantUser.username).should('exist'); + mpAgentDashboardPage.find({ query: dynamicFixtures.deletedMerchantUser.username }).should('exist'); mpAgentDashboardPage.visit(); - mpAgentDashboardPage.assistMerchantUser(dynamicFixtures.deletedMerchantUser.username); + mpAgentDashboardPage.assist({ query: dynamicFixtures.deletedMerchantUser.username }); mpDashboardPage.assertPageLocation(); }); it('agent should be able to see/assist merchant users from active (without approved access) merchant', (): void => { - userLoginScenario.execute({ - username: dynamicFixtures.rootUser.username, + mpAgentLoginPage.visit(); + mpAgentLoginPage.login({ + username: dynamicFixtures.merchantAgentUser.username, password: staticFixtures.defaultPassword, }); - mpAgentLoginPage.visit(); - mpAgentLoginPage.login(dynamicFixtures.merchantAgentUser.username, staticFixtures.defaultPassword); - mpAgentDashboardPage.visit(); - mpAgentDashboardPage - .findMerchantUser(dynamicFixtures.merchantUserFromActiveDeniedMerchant.username) - .should('exist'); + mpAgentDashboardPage.find({ query: dynamicFixtures.merchantUserFromActiveDeniedMerchant.username }).should('exist'); mpAgentDashboardPage.visit(); - mpAgentDashboardPage.assistMerchantUser(dynamicFixtures.merchantUserFromActiveDeniedMerchant.username); + mpAgentDashboardPage.assist({ query: dynamicFixtures.merchantUserFromActiveDeniedMerchant.username }); mpDashboardPage.assertPageLocation(); }); it('agent should be able to see/assist merchant users from inactive (with approved access) merchant', (): void => { - userLoginScenario.execute({ - username: dynamicFixtures.rootUser.username, + mpAgentLoginPage.visit(); + mpAgentLoginPage.login({ + username: dynamicFixtures.merchantAgentUser.username, password: staticFixtures.defaultPassword, }); - mpAgentLoginPage.visit(); - mpAgentLoginPage.login(dynamicFixtures.merchantAgentUser.username, staticFixtures.defaultPassword); - mpAgentDashboardPage.visit(); mpAgentDashboardPage - .findMerchantUser(dynamicFixtures.merchantUserFromInactiveApprovedMerchant.username) + .find({ query: dynamicFixtures.merchantUserFromInactiveApprovedMerchant.username }) .should('exist'); mpAgentDashboardPage.visit(); - mpAgentDashboardPage.assistMerchantUser(dynamicFixtures.merchantUserFromInactiveApprovedMerchant.username); + mpAgentDashboardPage.assist({ query: dynamicFixtures.merchantUserFromInactiveApprovedMerchant.username }); mpDashboardPage.assertPageLocation(); }); it('agent should be able to see/assist merchant users from inactive (without approved access) merchant', (): void => { - userLoginScenario.execute({ - username: dynamicFixtures.rootUser.username, + mpAgentLoginPage.visit(); + mpAgentLoginPage.login({ + username: dynamicFixtures.merchantAgentUser.username, password: staticFixtures.defaultPassword, }); - mpAgentLoginPage.visit(); - mpAgentLoginPage.login(dynamicFixtures.merchantAgentUser.username, staticFixtures.defaultPassword); - mpAgentDashboardPage.visit(); mpAgentDashboardPage - .findMerchantUser(dynamicFixtures.merchantUserFromInactiveDeniedMerchant.username) + .find({ query: dynamicFixtures.merchantUserFromInactiveDeniedMerchant.username }) .should('exist'); mpAgentDashboardPage.visit(); - mpAgentDashboardPage.assistMerchantUser(dynamicFixtures.merchantUserFromInactiveDeniedMerchant.username); + mpAgentDashboardPage.assist({ query: dynamicFixtures.merchantUserFromInactiveDeniedMerchant.username }); mpDashboardPage.assertPageLocation(); }); it('agent should be able to see/assist merchant users from active (with approved access) merchant', (): void => { - userLoginScenario.execute({ - username: dynamicFixtures.rootUser.username, + mpAgentLoginPage.visit(); + mpAgentLoginPage.login({ + username: dynamicFixtures.merchantAgentUser.username, password: staticFixtures.defaultPassword, }); - mpAgentLoginPage.visit(); - mpAgentLoginPage.login(dynamicFixtures.merchantAgentUser.username, staticFixtures.defaultPassword); - mpAgentDashboardPage.visit(); - mpAgentDashboardPage.findMerchantUser(dynamicFixtures.merchantUser.username).should('exist'); + mpAgentDashboardPage.find({ query: dynamicFixtures.merchantUser.username }).should('exist'); mpAgentDashboardPage.visit(); - mpAgentDashboardPage.assistMerchantUser(dynamicFixtures.merchantUser.username); + mpAgentDashboardPage.assist({ query: dynamicFixtures.merchantUser.username }); mpDashboardPage.assertPageLocation(); }); diff --git a/cypress/e2e/mp/marketplace-agent-assist/agent-impersonation.cy.ts b/cypress/e2e/mp/marketplace-agent-assist/agent-impersonation.cy.ts index bfffbdd4..b756e1c4 100644 --- a/cypress/e2e/mp/marketplace-agent-assist/agent-impersonation.cy.ts +++ b/cypress/e2e/mp/marketplace-agent-assist/agent-impersonation.cy.ts @@ -1,3 +1,4 @@ +import { container } from '@utils'; import { AgentImpersonationDynamicFixtures, MarketplaceAgentAssistStaticFixtures } from '@interfaces/mp'; import { AgentDashboardPage, @@ -7,7 +8,6 @@ import { } from '@pages/mp'; import { LoginPage } from '@pages/yves'; import { ImpersonateAsMerchantUserScenario } from '@scenarios/mp'; -import { container } from '@utils'; /** * Agent Assist in Merchant Portal checklists: {@link https://spryker.atlassian.net/wiki/spaces/CCS/pages/3975741526/Agent+Assist+in+Merchant+Portal+Checklists} @@ -27,13 +27,15 @@ describe('agent impersonation', { tags: ['@marketplace-agent-assist'] }, (): voi ({ dynamicFixtures, staticFixtures } = Cypress.env()); }); - it('agent should be able to see merchant user information during impersonation', (): void => { - impersonateScenario.execute( - dynamicFixtures.merchantAgentUser.username, - staticFixtures.defaultPassword, - dynamicFixtures.merchantUser.username - ); + beforeEach((): void => { + impersonateScenario.execute({ + username: dynamicFixtures.merchantAgentUser.username, + password: staticFixtures.defaultPassword, + query: dynamicFixtures.merchantUser.username, + }); + }); + it('agent should be able to see merchant user information during impersonation', (): void => { mpDashboardPage.visit(); cy.get('body').find(`div:contains("${dynamicFixtures.merchant.name}")`).should('exist'); cy.get('body').find(`div:contains("${dynamicFixtures.merchantUser.username}")`).should('exist'); @@ -44,24 +46,12 @@ describe('agent impersonation', { tags: ['@marketplace-agent-assist'] }, (): voi }); it('agent should be able to see agent assist buttons during impersonation', (): void => { - impersonateScenario.execute( - dynamicFixtures.merchantAgentUser.username, - staticFixtures.defaultPassword, - dynamicFixtures.merchantUser.username - ); - - cy.get('body').find('a:contains("End User Assistance")').should('exist'); - cy.get('body').find('a:contains("Log out Agent")').should('exist'); + cy.get('body').find(mpAgentDashboardPage.getEndUserAssistanceSelector()).should('exist'); + cy.get('body').find(mpAgentDashboardPage.getLogoutAgentSelector()).should('exist'); }); it('agent should be able to finish impersonation', (): void => { - impersonateScenario.execute( - dynamicFixtures.merchantAgentUser.username, - staticFixtures.defaultPassword, - dynamicFixtures.merchantUser.username - ); - - cy.get('body').find('a:contains("End User Assistance")').click(); + cy.get('body').find(mpAgentDashboardPage.getEndUserAssistanceSelector()).click(); mpAgentDashboardPage.assertPageLocation(); // Ensure that agent finished assistant session and don't have access to MP dashboard @@ -70,13 +60,7 @@ describe('agent impersonation', { tags: ['@marketplace-agent-assist'] }, (): voi }); it('agent should be able to fully logout from all sessions', (): void => { - impersonateScenario.execute( - dynamicFixtures.merchantAgentUser.username, - staticFixtures.defaultPassword, - dynamicFixtures.merchantUser.username - ); - - cy.get('body').find('a:contains("Log out Agent")').click(); + cy.get('body').find(mpAgentDashboardPage.getLogoutAgentSelector()).click(); mpAgentLoginPage.assertPageLocation(); mpAgentDashboardPage.visit(); @@ -87,12 +71,6 @@ describe('agent impersonation', { tags: ['@marketplace-agent-assist'] }, (): voi }); it('agent should be able to fully logout from user profile menu', (): void => { - impersonateScenario.execute( - dynamicFixtures.merchantAgentUser.username, - staticFixtures.defaultPassword, - dynamicFixtures.merchantUser.username - ); - mpDashboardPage.logout(); yvesLoginPage.assertPageLocation(); }); diff --git a/cypress/e2e/mp/marketplace-agent-assist/agent-login.cy.ts b/cypress/e2e/mp/marketplace-agent-assist/agent-login.cy.ts index e95cad18..07c28b2a 100644 --- a/cypress/e2e/mp/marketplace-agent-assist/agent-login.cy.ts +++ b/cypress/e2e/mp/marketplace-agent-assist/agent-login.cy.ts @@ -1,3 +1,4 @@ +import { container } from '@utils'; import { AgentLoginDynamicFixtures, MarketplaceAgentAssistStaticFixtures } from '@interfaces/mp'; import { AgentDashboardPage, @@ -6,7 +7,6 @@ import { LoginPage as MpLoginPage, } from '@pages/mp'; import { MerchantAgentLoginUserScenario } from '@scenarios/mp'; -import { container } from '@utils'; /** * Agent Assist in Merchant Portal checklists: {@link https://spryker.atlassian.net/wiki/spaces/CCS/pages/3975741526/Agent+Assist+in+Merchant+Portal+Checklists} @@ -27,7 +27,10 @@ describe('agent login', { tags: ['@marketplace-agent-assist'] }, (): void => { it('agent (customer) should not be able to login to MP dashboard', (): void => { mpLoginPage.visit(); - mpLoginPage.login(dynamicFixtures.customerAgentUser.username, staticFixtures.defaultPassword); + mpLoginPage.login({ + username: dynamicFixtures.customerAgentUser.username, + password: staticFixtures.defaultPassword, + }); cy.contains(mpLoginPage.getFailedAuthenticationText()); mpLoginPage.assertPageLocation(); @@ -35,7 +38,10 @@ describe('agent login', { tags: ['@marketplace-agent-assist'] }, (): void => { it('agent (merchant user) should not be able to login to MP dashboard', (): void => { mpLoginPage.visit(); - mpLoginPage.login(dynamicFixtures.merchantAgentUser.username, staticFixtures.defaultPassword); + mpLoginPage.login({ + username: dynamicFixtures.merchantAgentUser.username, + password: staticFixtures.defaultPassword, + }); cy.contains(mpLoginPage.getFailedAuthenticationText()); mpLoginPage.assertPageLocation(); @@ -43,7 +49,10 @@ describe('agent login', { tags: ['@marketplace-agent-assist'] }, (): void => { it('merchant user should be able to login to MP dashboard', (): void => { mpLoginPage.visit(); - mpLoginPage.login(dynamicFixtures.merchantUser.username, staticFixtures.defaultPassword); + mpLoginPage.login({ + username: dynamicFixtures.merchantUser.username, + password: staticFixtures.defaultPassword, + }); cy.contains('Dashboard'); mpDashboardPage.assertPageLocation(); @@ -51,7 +60,10 @@ describe('agent login', { tags: ['@marketplace-agent-assist'] }, (): void => { it('deactivated merchant user should not be able to login to MP dashboard', (): void => { mpLoginPage.visit(); - mpLoginPage.login(dynamicFixtures.deactivatedMerchantUser.username, staticFixtures.defaultPassword); + mpLoginPage.login({ + username: dynamicFixtures.deactivatedMerchantUser.username, + password: staticFixtures.defaultPassword, + }); cy.contains(mpLoginPage.getFailedAuthenticationText()); mpLoginPage.assertPageLocation(); @@ -59,7 +71,10 @@ describe('agent login', { tags: ['@marketplace-agent-assist'] }, (): void => { it('deleted merchant user should not be able to login to MP dashboard', (): void => { mpLoginPage.visit(); - mpLoginPage.login(dynamicFixtures.deletedMerchantUser.username, staticFixtures.defaultPassword); + mpLoginPage.login({ + username: dynamicFixtures.deletedMerchantUser.username, + password: staticFixtures.defaultPassword, + }); cy.contains(mpLoginPage.getFailedAuthenticationText()); mpLoginPage.assertPageLocation(); @@ -67,7 +82,10 @@ describe('agent login', { tags: ['@marketplace-agent-assist'] }, (): void => { it('agent (customer) should not be able to login to MP agent dashboard', (): void => { mpAgentLoginPage.visit(); - mpAgentLoginPage.login(dynamicFixtures.customerAgentUser.username, staticFixtures.defaultPassword); + mpAgentLoginPage.login({ + username: dynamicFixtures.customerAgentUser.username, + password: staticFixtures.defaultPassword, + }); cy.contains(mpAgentLoginPage.getFailedAuthenticationText()); mpAgentLoginPage.assertPageLocation(); @@ -75,7 +93,10 @@ describe('agent login', { tags: ['@marketplace-agent-assist'] }, (): void => { it('merchant user should not be able to login to MP agent dashboard', (): void => { mpAgentLoginPage.visit(); - mpAgentLoginPage.login(dynamicFixtures.merchantUser.username, staticFixtures.defaultPassword); + mpAgentLoginPage.login({ + username: dynamicFixtures.merchantUser.username, + password: staticFixtures.defaultPassword, + }); cy.contains(mpAgentLoginPage.getFailedAuthenticationText()); mpAgentLoginPage.assertPageLocation(); diff --git a/cypress/e2e/mp/marketplace-agent-assist/agent-merchant-portal.cy.ts b/cypress/e2e/mp/marketplace-agent-assist/agent-merchant-portal.cy.ts index a3863ac5..10019dcc 100644 --- a/cypress/e2e/mp/marketplace-agent-assist/agent-merchant-portal.cy.ts +++ b/cypress/e2e/mp/marketplace-agent-assist/agent-merchant-portal.cy.ts @@ -1,3 +1,4 @@ +import { container } from '@utils'; import { AgentMerchantPortalDynamicFixtures, MarketplaceAgentAssistStaticFixtures } from '@interfaces/mp'; import { SalesDetailPage, SalesIndexPage } from '@pages/backoffice'; import { OffersPage, ProductsPage, ProfilePage, SalesOrdersPage } from '@pages/mp'; @@ -5,7 +6,6 @@ import { CartPage } from '@pages/yves'; import { UserLoginScenario } from '@scenarios/backoffice'; import { ImpersonateAsMerchantUserScenario } from '@scenarios/mp'; import { CheckoutMpScenario, CustomerLoginScenario } from '@scenarios/yves'; -import { container } from '@utils'; /** * Agent Assist in Merchant Portal checklists: {@link https://spryker.atlassian.net/wiki/spaces/CCS/pages/3975741526/Agent+Assist+in+Merchant+Portal+Checklists} @@ -34,7 +34,7 @@ describe('agent merchant portal', { tags: ['@marketplace-agent-assist'] }, (): v customerLoginScenario.execute({ email: dynamicFixtures.customer.email, password: staticFixtures.defaultPassword }); cartPage.visit(); - cartPage.quickAddToCart(dynamicFixtures.productConcreteForOffer.sku); + cartPage.quickAddToCart({ sku: dynamicFixtures.productConcreteForOffer.sku, quantity: 1 }); checkoutMpScenario.execute({ isGuest: false }); userLoginScenario.execute({ @@ -42,61 +42,62 @@ describe('agent merchant portal', { tags: ['@marketplace-agent-assist'] }, (): v password: staticFixtures.defaultPassword, }); - salesIndexPage.viewLastPlacedOrder(); - salesDetailPage.triggerOms('Pay'); - salesDetailPage.triggerOms('skip picking', true); + salesIndexPage.visit(); + salesIndexPage.view(); + salesDetailPage.triggerOms({ state: 'Pay' }); + salesDetailPage.triggerOms({ state: 'skip picking', shouldTriggerOmsInCli: true }); - impersonateScenario.execute( - dynamicFixtures.merchantAgentUser.username, - staticFixtures.defaultPassword, - dynamicFixtures.merchantUser.username - ); + impersonateScenario.execute({ + username: dynamicFixtures.merchantAgentUser.username, + password: staticFixtures.defaultPassword, + query: dynamicFixtures.merchantUser.username, + }); salesOrdersPage.visit(); - salesOrdersPage.cancelOrder(dynamicFixtures.customer.email); + salesOrdersPage.cancel({ query: dynamicFixtures.customer.email }); // Ensure that order was canceled salesOrdersPage.visit(); - salesOrdersPage.findOrder(dynamicFixtures.customer.email).contains('canceled'); + salesOrdersPage.find({ query: dynamicFixtures.customer.email }).contains('canceled'); }); it('agent should be able to modify merchant profile information during impersonation', (): void => { - impersonateScenario.execute( - dynamicFixtures.merchantAgentUser.username, - staticFixtures.defaultPassword, - dynamicFixtures.merchantUser.username - ); + impersonateScenario.execute({ + username: dynamicFixtures.merchantAgentUser.username, + password: staticFixtures.defaultPassword, + query: dynamicFixtures.merchantUser.username, + }); profilePage.visit(); - profilePage.updateMerchantPhoneNumber(); + profilePage.updatePhone(); cy.get('body').contains('The Profile has been changed successfully.'); }); it('agent should be able to modify product information during impersonation', (): void => { - impersonateScenario.execute( - dynamicFixtures.merchantAgentUser.username, - staticFixtures.defaultPassword, - dynamicFixtures.merchantUser.username - ); + impersonateScenario.execute({ + username: dynamicFixtures.merchantAgentUser.username, + password: staticFixtures.defaultPassword, + query: dynamicFixtures.merchantUser.username, + }); productsPage.visit(); - productsPage.findProduct(dynamicFixtures.productConcreteForMerchant.abstract_sku).click(); - productsPage.getDrawer().find('button:contains("Save")').click(); + productsPage.find({ query: dynamicFixtures.productConcreteForMerchant.abstract_sku }).click(); + productsPage.getDrawer().find(productsPage.getSaveButtonSelector()).click(); cy.get('body').contains('The Product is saved.'); }); it('agent should be able to modify offer information during impersonation', (): void => { - impersonateScenario.execute( - dynamicFixtures.merchantAgentUser.username, - staticFixtures.defaultPassword, - dynamicFixtures.merchantUser.username - ); + impersonateScenario.execute({ + username: dynamicFixtures.merchantAgentUser.username, + password: staticFixtures.defaultPassword, + query: dynamicFixtures.merchantUser.username, + }); offersPage.visit(); - offersPage.findOffer(dynamicFixtures.productOffer.product_offer_reference).click(); - offersPage.getDrawer().find('button:contains("Save")').click(); + offersPage.find({ query: dynamicFixtures.productOffer.product_offer_reference }).click(); + offersPage.getDrawer().find(offersPage.getSaveButtonSelector()).click(); cy.get('body').contains('The Offer is saved.'); }); diff --git a/cypress/e2e/mp/marketplace-agent-assist/agent-permission.cy.ts b/cypress/e2e/mp/marketplace-agent-assist/agent-permission.cy.ts index 4f7781bf..d3ab180a 100644 --- a/cypress/e2e/mp/marketplace-agent-assist/agent-permission.cy.ts +++ b/cypress/e2e/mp/marketplace-agent-assist/agent-permission.cy.ts @@ -1,7 +1,7 @@ +import { container } from '@utils'; import { AgentPermissionDynamicFixtures, MarketplaceAgentAssistStaticFixtures } from '@interfaces/mp'; -import { UserIndexPage, UserUpdatePage } from '@pages/backoffice'; +import { ActionEnum, UserIndexPage, UserUpdatePage } from '@pages/backoffice'; import { UserLoginScenario } from '@scenarios/backoffice'; -import { container } from '@utils'; /** * Agent Assist in Merchant Portal checklists: {@link https://spryker.atlassian.net/wiki/spaces/CCS/pages/3975741526/Agent+Assist+in+Merchant+Portal+Checklists} @@ -18,14 +18,16 @@ describe('agent permission', { tags: ['@marketplace-agent-assist'] }, (): void = ({ dynamicFixtures, staticFixtures } = Cypress.env()); }); - it('backoffice user should be able to see new merchant agent permission checkbox', (): void => { + beforeEach((): void => { userLoginScenario.execute({ username: dynamicFixtures.rootUser.username, password: staticFixtures.defaultPassword, }); + }); + it('backoffice user should be able to see new merchant agent permission checkbox', (): void => { backofficeUserIndexPage.visit(); - backofficeUserIndexPage.editUser(dynamicFixtures.rootUser.username); + backofficeUserIndexPage.update({ action: ActionEnum.edit, query: dynamicFixtures.rootUser.username }); backofficeUserUpdatePage .getAgentMerchantCheckbox() @@ -35,13 +37,8 @@ describe('agent permission', { tags: ['@marketplace-agent-assist'] }, (): void = }); it('backoffice user should be able to see renamed customer agent permission checkbox', (): void => { - userLoginScenario.execute({ - username: dynamicFixtures.rootUser.username, - password: staticFixtures.defaultPassword, - }); - backofficeUserIndexPage.visit(); - backofficeUserIndexPage.editUser(dynamicFixtures.rootUser.username); + backofficeUserIndexPage.update({ action: ActionEnum.edit, query: dynamicFixtures.rootUser.username }); backofficeUserUpdatePage .getAgentCustomerCheckbox() @@ -51,97 +48,57 @@ describe('agent permission', { tags: ['@marketplace-agent-assist'] }, (): void = }); it('backoffice user should be able to see existing user with merchant agent permission', (): void => { - userLoginScenario.execute({ - username: dynamicFixtures.rootUser.username, - password: staticFixtures.defaultPassword, - }); - backofficeUserIndexPage.visit(); - backofficeUserIndexPage.editUser(dynamicFixtures.merchantAgentUser.username); + backofficeUserIndexPage.update({ action: ActionEnum.edit, query: dynamicFixtures.merchantAgentUser.username }); backofficeUserUpdatePage.getAgentMerchantCheckbox().should('be.checked'); }); it('backoffice user should be able to see "Agent Customer" column in user table', (): void => { - userLoginScenario.execute({ - username: dynamicFixtures.rootUser.username, - password: staticFixtures.defaultPassword, - }); - backofficeUserIndexPage.visit(); backofficeUserIndexPage.getUserTableHeader().contains('Agent Customer'); }); it('backoffice user should be able to see "Agent Merchant" column in user table', (): void => { - userLoginScenario.execute({ - username: dynamicFixtures.rootUser.username, - password: staticFixtures.defaultPassword, - }); - backofficeUserIndexPage.visit(); backofficeUserIndexPage.getUserTableHeader().contains('Agent Merchant'); }); it('backoffice user should be able to see imported user with "Agent Customer" permission', (): void => { - userLoginScenario.execute({ - username: dynamicFixtures.rootUser.username, - password: staticFixtures.defaultPassword, - }); - backofficeUserIndexPage.visit(); backofficeUserIndexPage - .findUser(dynamicFixtures.customerAgentUser.username) + .find({ query: dynamicFixtures.customerAgentUser.username }) .contains('Agent') .should('have.length', 1); }); it('backoffice user should be able to see imported user with "Agent Merchant" permission', (): void => { - userLoginScenario.execute({ - username: dynamicFixtures.rootUser.username, - password: staticFixtures.defaultPassword, - }); - backofficeUserIndexPage.visit(); backofficeUserIndexPage - .findUser(dynamicFixtures.merchantAgentUser.username) + .find({ query: dynamicFixtures.merchantAgentUser.username }) .contains('Agent') .should('have.length', 1); }); it('backoffice user should be able to create new user without checked merchant agent permission by default', (): void => { - userLoginScenario.execute({ - username: dynamicFixtures.rootUser.username, - password: staticFixtures.defaultPassword, - }); - backofficeUserIndexPage.visit(); - backofficeUserIndexPage.editUser(dynamicFixtures.rootUser.username); + backofficeUserIndexPage.update({ action: ActionEnum.edit, query: dynamicFixtures.rootUser.username }); backofficeUserUpdatePage.getAgentMerchantCheckbox().should('not.be.checked'); }); it('backoffice user should be able to create new user with merchant agent permission', (): void => { - userLoginScenario.execute({ - username: dynamicFixtures.rootUser.username, - password: staticFixtures.defaultPassword, - }); - backofficeUserIndexPage.visit(); - backofficeUserIndexPage.editUser(dynamicFixtures.merchantAgentUser.username); + backofficeUserIndexPage.update({ action: ActionEnum.edit, query: dynamicFixtures.merchantAgentUser.username }); backofficeUserUpdatePage.getAgentMerchantCheckbox().should('be.checked'); }); it('backoffice user should be able to modify existing user by setting merchant agent permission', (): void => { - userLoginScenario.execute({ - username: dynamicFixtures.rootUser.username, - password: staticFixtures.defaultPassword, - }); - backofficeUserIndexPage.visit(); - backofficeUserIndexPage.editUser(dynamicFixtures.rootUser.username); + backofficeUserIndexPage.update({ action: ActionEnum.edit, query: dynamicFixtures.rootUser.username }); backofficeUserUpdatePage.getAgentMerchantCheckbox().should('not.be.checked'); backofficeUserUpdatePage.checkMerchantAgentCheckbox(); - backofficeUserIndexPage.editUser(dynamicFixtures.rootUser.username); + backofficeUserIndexPage.update({ action: ActionEnum.edit, query: dynamicFixtures.rootUser.username }); backofficeUserUpdatePage.getAgentMerchantCheckbox().should('be.checked'); }); }); diff --git a/cypress/e2e/mp/merchant-b2b-contract-requests/request-management.cy.ts b/cypress/e2e/mp/merchant-b2b-contract-requests/request-management.cy.ts index 380b3d35..4868cd6f 100644 --- a/cypress/e2e/mp/merchant-b2b-contract-requests/request-management.cy.ts +++ b/cypress/e2e/mp/merchant-b2b-contract-requests/request-management.cy.ts @@ -1,7 +1,7 @@ import { container } from '@utils'; -import { MerchantUserLoginScenario } from '../../../support/scenarios/mp'; -import { RequestManagementDynamicFixtures, RequestManagementStaticFixtures } from '../../../support/types/mp'; -import { MerchantRelationRequestsPage, MerchantRelationsPage } from '../../../support/pages/mp'; +import { RequestManagementDynamicFixtures, RequestManagementStaticFixtures } from '@interfaces/mp'; +import { MerchantRelationRequestsPage, MerchantRelationsPage } from '@pages/mp'; +import { MerchantUserLoginScenario } from '@scenarios/mp'; /** * Merchant Relation Requests & Enhanced Merchant Relations checklists: {@link https://spryker.atlassian.net/wiki/spaces/CCS/pages/4105896492/Business+Journey+B2B+Marketplace+-+to+automate} @@ -25,7 +25,7 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () }); merchantRelationRequestsPage.visit(); - merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit1FromCompany1.name).should('exist'); + merchantRelationRequestsPage.find({ query: dynamicFixtures.businessUnit1FromCompany1.name }).should('exist'); merchantUserLoginScenario.execute({ username: dynamicFixtures.merchantUser2FromMerchant1.username, @@ -33,7 +33,7 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () }); merchantRelationRequestsPage.visit(); - merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit1FromCompany1.name).should('exist'); + merchantRelationRequestsPage.find({ query: dynamicFixtures.businessUnit1FromCompany1.name }).should('exist'); }); it('merchant user should be able to left internal comments', (): void => { @@ -43,9 +43,9 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () }); merchantRelationRequestsPage.visit(); - merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit1FromCompany1.name).click(); + merchantRelationRequestsPage.find({ query: dynamicFixtures.businessUnit1FromCompany1.name }).click(); merchantRelationRequestsPage.getDrawer(); - merchantRelationRequestsPage.addInternalComment(staticFixtures.internalComment); + merchantRelationRequestsPage.addInternalComment({ comment: staticFixtures.internalComment }); merchantUserLoginScenario.execute({ username: dynamicFixtures.merchantUser2FromMerchant1.username, @@ -53,7 +53,7 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () }); merchantRelationRequestsPage.visit(); - merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit1FromCompany1.name).click(); + merchantRelationRequestsPage.find({ query: dynamicFixtures.businessUnit1FromCompany1.name }).click(); merchantRelationRequestsPage.getDrawer().contains(staticFixtures.internalComment); }); @@ -64,17 +64,17 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () }); merchantRelationRequestsPage.visit(); - merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit2FromCompany1.name).click(); + merchantRelationRequestsPage.find({ query: dynamicFixtures.businessUnit2FromCompany1.name }).click(); merchantRelationRequestsPage.getDrawer(); - merchantRelationRequestsPage.addInternalComment(staticFixtures.internalComment); - merchantRelationRequestsPage.approveRequest(true); + merchantRelationRequestsPage.addInternalComment({ comment: staticFixtures.internalComment }); + merchantRelationRequestsPage.approve({ isSplitEnabled: true }); merchantRelationsPage.visit(); - merchantRelationsPage.findRelation(dynamicFixtures.businessUnit6FromCompany1.name).click(); + merchantRelationsPage.find({ query: dynamicFixtures.businessUnit6FromCompany1.name }).click(); merchantRelationsPage.getDrawer().contains(staticFixtures.internalComment); merchantRelationsPage.visit(); - merchantRelationsPage.findRelation(dynamicFixtures.businessUnit7FromCompany1.name).click(); + merchantRelationsPage.find({ query: dynamicFixtures.businessUnit7FromCompany1.name }).click(); merchantRelationsPage.getDrawer().contains(staticFixtures.internalComment); }); @@ -85,12 +85,12 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () }); merchantRelationRequestsPage.visit(); - merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit1FromCompany1.name).click(); + merchantRelationRequestsPage.find({ query: dynamicFixtures.businessUnit1FromCompany1.name }).click(); merchantRelationRequestsPage.getDrawer(); - merchantRelationRequestsPage.rejectRequest(); + merchantRelationRequestsPage.reject(); merchantRelationRequestsPage.visit(); - merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit1FromCompany1.name).click(); + merchantRelationRequestsPage.find({ query: dynamicFixtures.businessUnit1FromCompany1.name }).click(); merchantRelationRequestsPage.getDrawer().contains('Rejected'); }); @@ -101,17 +101,19 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () }); merchantRelationRequestsPage.visit(); - merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit2FromCompany1.name).click(); + merchantRelationRequestsPage.find({ query: dynamicFixtures.businessUnit2FromCompany1.name }).click(); merchantRelationRequestsPage.getDrawer(); - merchantRelationRequestsPage.uncheckBusinessUnits([ - dynamicFixtures.businessUnit6FromCompany1.id_company_business_unit, - dynamicFixtures.businessUnit7FromCompany1.id_company_business_unit, - ]); - merchantRelationRequestsPage.approveRequest(false); + merchantRelationRequestsPage.uncheckBusinessUnits({ + businessUnitIds: [ + dynamicFixtures.businessUnit6FromCompany1.id_company_business_unit, + dynamicFixtures.businessUnit7FromCompany1.id_company_business_unit, + ], + }); + merchantRelationRequestsPage.approve(); merchantRelationRequestsPage.visit(); - merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit2FromCompany1.name).click(); + merchantRelationRequestsPage.find({ query: dynamicFixtures.businessUnit2FromCompany1.name }).click(); merchantRelationRequestsPage.getDrawer().contains('Pending'); }); @@ -122,17 +124,17 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () }); merchantRelationRequestsPage.visit(); - merchantRelationRequestsPage.findRequest(dynamicFixtures.businessUnit2FromCompany1.name).click(); + merchantRelationRequestsPage.find({ query: dynamicFixtures.businessUnit2FromCompany1.name }).click(); merchantRelationRequestsPage.getDrawer(); - merchantRelationRequestsPage.uncheckBusinessUnits([ - dynamicFixtures.businessUnit6FromCompany1.id_company_business_unit, - ]); - merchantRelationRequestsPage.approveRequest(false); + merchantRelationRequestsPage.uncheckBusinessUnits({ + businessUnitIds: [dynamicFixtures.businessUnit6FromCompany1.id_company_business_unit], + }); + merchantRelationRequestsPage.approve(); merchantRelationsPage.visit(); - merchantRelationsPage.findRelation(dynamicFixtures.businessUnit6FromCompany1.name, 0); - merchantRelationsPage.findRelation(dynamicFixtures.businessUnit7FromCompany1.name).click(); + merchantRelationsPage.find({ query: dynamicFixtures.businessUnit6FromCompany1.name, expectedCount: 0 }); + merchantRelationsPage.find({ query: dynamicFixtures.businessUnit7FromCompany1.name }).click(); merchantRelationsPage.getDrawer().contains(dynamicFixtures.businessUnit7FromCompany1.name); }); }); diff --git a/cypress/e2e/yves/checkout/basic-checkout.cy.ts b/cypress/e2e/yves/checkout/basic-checkout.cy.ts index e61a7d06..077c127f 100644 --- a/cypress/e2e/yves/checkout/basic-checkout.cy.ts +++ b/cypress/e2e/yves/checkout/basic-checkout.cy.ts @@ -1,7 +1,7 @@ +import { container } from '@utils'; import { CheckoutStaticFixtures, BasicCheckoutDynamicFixtures } from '@interfaces/yves'; import { CartPage } from '@pages/yves'; import { CheckoutScenario, CustomerLoginScenario } from '@scenarios/yves'; -import { container } from '@utils'; describe('basic checkout', { tags: ['@checkout'] }, (): void => { const cartPage = container.get(CartPage); @@ -17,20 +17,18 @@ describe('basic checkout', { tags: ['@checkout'] }, (): void => { it('guest customer should checkout to single shipment', (): void => { cartPage.visit(); - cartPage.quickAddToCart(dynamicFixtures.product1.sku, 1); - cartPage.quickAddToCart(dynamicFixtures.product2.sku, 1); + cartPage.quickAddToCart({ sku: dynamicFixtures.product1.sku, quantity: 1 }); + cartPage.quickAddToCart({ sku: dynamicFixtures.product2.sku, quantity: 1 }); - checkoutScenario.execute({ - isGuest: true, - }); + checkoutScenario.execute({ isGuest: true }); cy.contains('Your order has been placed successfully!'); }); it('guest customer should checkout to multi shipment address', { tags: ['@smoke'] }, (): void => { cartPage.visit(); - cartPage.quickAddToCart(dynamicFixtures.product1.sku, 1); - cartPage.quickAddToCart(dynamicFixtures.product2.sku, 1); + cartPage.quickAddToCart({ sku: dynamicFixtures.product1.sku, quantity: 1 }); + cartPage.quickAddToCart({ sku: dynamicFixtures.product2.sku, quantity: 1 }); checkoutScenario.execute({ isGuest: true, @@ -46,11 +44,7 @@ describe('basic checkout', { tags: ['@checkout'] }, (): void => { password: staticFixtures.defaultPassword, }); - checkoutScenario.execute({ - isGuest: false, - isMultiShipment: false, - idCustomerAddress: dynamicFixtures.address.id_customer_address, - }); + checkoutScenario.execute({ idCustomerAddress: dynamicFixtures.address.id_customer_address }); cy.contains('Your order has been placed successfully!'); }); @@ -61,10 +55,7 @@ describe('basic checkout', { tags: ['@checkout'] }, (): void => { password: staticFixtures.defaultPassword, }); - checkoutScenario.execute({ - isGuest: false, - isMultiShipment: false, - }); + checkoutScenario.execute(); cy.contains('Your order has been placed successfully!'); }); @@ -79,7 +70,6 @@ describe('basic checkout', { tags: ['@checkout'] }, (): void => { }); checkoutScenario.execute({ - isGuest: false, isMultiShipment: true, idCustomerAddress: dynamicFixtures.address.id_customer_address, }); @@ -97,10 +87,7 @@ describe('basic checkout', { tags: ['@checkout'] }, (): void => { password: staticFixtures.defaultPassword, }); - checkoutScenario.execute({ - isGuest: false, - isMultiShipment: true, - }); + checkoutScenario.execute({ isMultiShipment: true }); cy.contains('Your order has been placed successfully!'); } diff --git a/cypress/e2e/yves/comments/cart-comments.cy.ts b/cypress/e2e/yves/comments/cart-comments.cy.ts index 4b51c851..f2efb324 100644 --- a/cypress/e2e/yves/comments/cart-comments.cy.ts +++ b/cypress/e2e/yves/comments/cart-comments.cy.ts @@ -1,7 +1,7 @@ +import { container } from '@utils'; import { CartCommentsDynamicFixtures, CartCommentsStaticFixtures } from '@interfaces/yves'; import { CommentCartPage, MultiCartPage } from '@pages/yves'; import { CustomerLoginScenario } from '@scenarios/yves'; -import { container } from '@utils'; describe('cart comments', { tags: ['@comments'] }, (): void => { const multiCartPage = container.get(MultiCartPage); @@ -24,54 +24,54 @@ describe('cart comments', { tags: ['@comments'] }, (): void => { it('customer should be able to add comments to cart with items', (): void => { multiCartPage.visit(); - multiCartPage.selectCart(dynamicFixtures.quote.name); + multiCartPage.selectCart({ name: dynamicFixtures.quote.name }); commentCartPage.visit(); staticFixtures.commentsToAdd.forEach((commentMessage) => { - commentCartPage.addComment(commentMessage); + commentCartPage.add({ message: commentMessage }); commentCartPage.getCommentThreadListSection().contains(commentMessage).should('exist'); }); }); it('customer should be able to modify comment in cart with items', (): void => { commentCartPage.visit(); - commentCartPage.addComment(staticFixtures.commentToModify); - commentCartPage.updateCommentByCommentText(staticFixtures.commentToModify, staticFixtures.modifiedComment); + commentCartPage.add({ message: staticFixtures.commentToModify }); + commentCartPage.update({ oldMessage: staticFixtures.commentToModify, newMessage: staticFixtures.modifiedComment }); commentCartPage.getCommentThreadListSection().contains(staticFixtures.modifiedComment).should('exist'); }); it('customer should be able to remove comment in cart with items', (): void => { commentCartPage.visit(); - commentCartPage.addComment(staticFixtures.commentsToRemove); - commentCartPage.removeCommentByCommentText(staticFixtures.commentsToRemove); + commentCartPage.add({ message: staticFixtures.commentsToRemove }); + commentCartPage.remove({ message: staticFixtures.commentsToRemove }); commentCartPage.getCommentThreadListSection().contains(staticFixtures.commentsToRemove).should('not.exist'); }); it('customer should be able to add comments to empty cart', (): void => { multiCartPage.visit(); - multiCartPage.selectCart(dynamicFixtures.emptyQuote.name); + multiCartPage.selectCart({ name: dynamicFixtures.emptyQuote.name }); commentCartPage.visit(); staticFixtures.commentsToAdd.forEach((commentMessage) => { - commentCartPage.addComment(commentMessage); + commentCartPage.add({ message: commentMessage }); commentCartPage.getCommentThreadListSection().contains(commentMessage).should('exist'); }); }); it('customer should be able to modify comment in empty cart', (): void => { commentCartPage.visit(); - commentCartPage.addComment(staticFixtures.commentToModify); - commentCartPage.updateCommentByCommentText(staticFixtures.commentToModify, staticFixtures.modifiedComment); + commentCartPage.add({ message: staticFixtures.commentToModify }); + commentCartPage.update({ oldMessage: staticFixtures.commentToModify, newMessage: staticFixtures.modifiedComment }); commentCartPage.getCommentThreadListSection().contains(staticFixtures.modifiedComment).should('exist'); }); it('customer should be able to remove comment in empty cart', (): void => { commentCartPage.visit(); - commentCartPage.addComment(staticFixtures.commentsToRemove); - commentCartPage.removeCommentByCommentText(staticFixtures.commentsToRemove); + commentCartPage.add({ message: staticFixtures.commentsToRemove }); + commentCartPage.remove({ message: staticFixtures.commentsToRemove }); commentCartPage.getCommentThreadListSection().contains(staticFixtures.commentsToRemove).should('not.exist'); }); diff --git a/cypress/e2e/yves/merchant-b2b-contract-requests/request-creation.cy.ts b/cypress/e2e/yves/merchant-b2b-contract-requests/request-creation.cy.ts index 9e888d64..98d5bee3 100644 --- a/cypress/e2e/yves/merchant-b2b-contract-requests/request-creation.cy.ts +++ b/cypress/e2e/yves/merchant-b2b-contract-requests/request-creation.cy.ts @@ -1,4 +1,5 @@ import { container } from '@utils'; +import { MerchantB2bContractRequestsStaticFixtures, RequestCreationDynamicFixtures } from '@interfaces/yves'; import { CatalogPage, CompanyUserSelectPage, @@ -6,15 +7,16 @@ import { MerchantRelationRequestCreatePage, MerchantRelationRequestDetailsPage, MerchantRelationRequestIndexPage, -} from '../../../support/pages/yves'; -import { CustomerLoginScenario } from '../../../support/scenarios/yves'; -import { MerchantB2bContractRequestsStaticFixtures, RequestCreationDynamicFixtures } from '../../../support/types/yves'; + ProductPage, +} from '@pages/yves'; +import { CustomerLoginScenario } from '@scenarios/yves'; /** * Merchant Relation Requests & Enhanced Merchant Relations checklists: {@link https://spryker.atlassian.net/wiki/spaces/CCS/pages/4105896492/Business+Journey+B2B+Marketplace+-+to+automate} */ describe('request creation', { tags: ['@merchant-b2b-contract-requests'] }, (): void => { const catalogPage = container.get(CatalogPage); + const productPage = container.get(ProductPage); const companyUserSelectPage = container.get(CompanyUserSelectPage); const merchantRelationRequestCreatePage = container.get(MerchantRelationRequestCreatePage); const merchantRelationRequestDetailsPage = container.get(MerchantRelationRequestDetailsPage); @@ -38,10 +40,14 @@ describe('request creation', { tags: ['@merchant-b2b-contract-requests'] }, (): }); it('company user should be able to create request from PDP', (): void => { - companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany1.id_company_user); + companyUserSelectPage.selectBusinessUnit({ + idCompanyUser: dynamicFixtures.companyUser1FromCompany1.id_company_user, + }); - catalogPage.openFirstSuggestedProduct(dynamicFixtures.concreteProduct.abstract_sku); - catalogPage.createMerchantRelationRequest(dynamicFixtures.productOfferFromMerchant2.product_offer_reference); + catalogPage.search({ query: dynamicFixtures.concreteProduct.abstract_sku }); + productPage.createMerchantRelationRequest({ + productOfferReference: dynamicFixtures.productOfferFromMerchant2.product_offer_reference, + }); merchantRelationRequestCreatePage.create({ ownerBusinessUnitId: dynamicFixtures.businessUnit1FromCompany1.id_company_business_unit, @@ -55,7 +61,9 @@ describe('request creation', { tags: ['@merchant-b2b-contract-requests'] }, (): }); it('company user should not be able to create request from merchant profile without business units', (): void => { - companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser2FromCompany1.id_company_user); + companyUserSelectPage.selectBusinessUnit({ + idCompanyUser: dynamicFixtures.companyUser2FromCompany1.id_company_user, + }); cy.visit(dynamicFixtures.merchantUrl2.url); merchantPage.sendMerchantRelationRequest(); @@ -70,7 +78,9 @@ describe('request creation', { tags: ['@merchant-b2b-contract-requests'] }, (): }); it('company user should be able to create request from merchant profile page', (): void => { - companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser2FromCompany1.id_company_user); + companyUserSelectPage.selectBusinessUnit({ + idCompanyUser: dynamicFixtures.companyUser2FromCompany1.id_company_user, + }); cy.visit(dynamicFixtures.merchantUrl2.url); merchantPage.sendMerchantRelationRequest(); @@ -87,10 +97,12 @@ describe('request creation', { tags: ['@merchant-b2b-contract-requests'] }, (): }); it('company user should be able to create request from MR request create page', (): void => { - companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany2.id_company_user); + companyUserSelectPage.selectBusinessUnit({ + idCompanyUser: dynamicFixtures.companyUser1FromCompany2.id_company_user, + }); merchantRelationRequestIndexPage.visit(); - merchantRelationRequestIndexPage.createMerchantRelationRequest(); + merchantRelationRequestIndexPage.create(); merchantRelationRequestCreatePage.create({ merchantReference: dynamicFixtures.merchant1.merchant_reference, @@ -105,7 +117,9 @@ describe('request creation', { tags: ['@merchant-b2b-contract-requests'] }, (): }); it('company user should be able to create request with only one business unit', (): void => { - companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany2.id_company_user); + companyUserSelectPage.selectBusinessUnit({ + idCompanyUser: dynamicFixtures.companyUser1FromCompany2.id_company_user, + }); merchantRelationRequestCreatePage.visit(); merchantRelationRequestCreatePage.create({ @@ -118,14 +132,16 @@ describe('request creation', { tags: ['@merchant-b2b-contract-requests'] }, (): }); it('sold by merchant contains MR request links', (): void => { - companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany1.id_company_user); - catalogPage.openFirstSuggestedProduct(dynamicFixtures.concreteProduct.abstract_sku); + companyUserSelectPage.selectBusinessUnit({ + idCompanyUser: dynamicFixtures.companyUser1FromCompany1.id_company_user, + }); + catalogPage.search({ query: dynamicFixtures.concreteProduct.abstract_sku }); - const productOffers = catalogPage.getSoldByProductOffers(); - const createRequestLink = catalogPage.getMerchantRelationRequestLinkAttribute(); + const productOffers = productPage.getSoldByProductOffers(); + const createRequestLink = productPage.getMerchantRelationRequestLinkAttribute(); productOffers.children().each(($productOffer) => { - const productOfferReference = $productOffer.find('input[type="radio"]').attr('value'); + const productOfferReference = $productOffer.find(productPage.getInputRadioSelector()).attr('value'); if ( productOfferReference === dynamicFixtures.productOfferFromMerchant1.product_offer_reference || diff --git a/cypress/e2e/yves/merchant-b2b-contract-requests/request-management.cy.ts b/cypress/e2e/yves/merchant-b2b-contract-requests/request-management.cy.ts index eba332fd..f6768328 100644 --- a/cypress/e2e/yves/merchant-b2b-contract-requests/request-management.cy.ts +++ b/cypress/e2e/yves/merchant-b2b-contract-requests/request-management.cy.ts @@ -1,14 +1,11 @@ import { container } from '@utils'; +import { MerchantB2bContractRequestsStaticFixtures, RequestManagementDynamicFixtures } from '@interfaces/yves'; import { CompanyUserSelectPage, MerchantRelationRequestDetailsPage, MerchantRelationRequestIndexPage, -} from '../../../support/pages/yves'; -import { CustomerLoginScenario } from '../../../support/scenarios/yves'; -import { - MerchantB2bContractRequestsStaticFixtures, - RequestManagementDynamicFixtures, -} from '../../../support/types/yves'; +} from '@pages/yves'; +import { CustomerLoginScenario } from '@scenarios/yves'; /** * Merchant Relation Requests & Enhanced Merchant Relations checklists: {@link https://spryker.atlassian.net/wiki/spaces/CCS/pages/4105896492/Business+Journey+B2B+Marketplace+-+to+automate} @@ -35,7 +32,9 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () }); it('company user should be able to filter MR requests by status', (): void => { - companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany1.id_company_user); + companyUserSelectPage.selectBusinessUnit({ + idCompanyUser: dynamicFixtures.companyUser1FromCompany1.id_company_user, + }); const statuses = ['Pending', 'Canceled', 'Approved', 'Rejected']; statuses.forEach((status: string): void => { @@ -51,7 +50,9 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () }); it('company user should be able to filter MR requests by merchant', (): void => { - companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany2.id_company_user); + companyUserSelectPage.selectBusinessUnit({ + idCompanyUser: dynamicFixtures.companyUser1FromCompany2.id_company_user, + }); const merchants = [dynamicFixtures.merchant1, dynamicFixtures.merchant2]; merchants.forEach((merchant): void => { @@ -67,7 +68,9 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () }); it('company user should be able to filter MR requests by business unit owner', (): void => { - companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany2.id_company_user); + companyUserSelectPage.selectBusinessUnit({ + idCompanyUser: dynamicFixtures.companyUser1FromCompany2.id_company_user, + }); const businessUnits = [dynamicFixtures.businessUnit1FromCompany2, dynamicFixtures.businessUnit2FromCompany2]; businessUnits.forEach((businessUnit): void => { @@ -87,14 +90,18 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () }); it('company user from same company should be able to see requests from another user', (): void => { - companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser2FromCompany1.id_company_user); + companyUserSelectPage.selectBusinessUnit({ + idCompanyUser: dynamicFixtures.companyUser2FromCompany1.id_company_user, + }); merchantRelationRequestIndexPage.visit(); merchantRelationRequestIndexPage.getFirstRequest().should('exist'); }); it('company user from same company should not be able to cancel request from another user', (): void => { - companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser2FromCompany1.id_company_user); + companyUserSelectPage.selectBusinessUnit({ + idCompanyUser: dynamicFixtures.companyUser2FromCompany1.id_company_user, + }); merchantRelationRequestIndexPage.visit(); merchantRelationRequestIndexPage.filterRequests({ status: 'pending' }); @@ -104,7 +111,9 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () }); it('company user should not be able to cancel request from canceled status', (): void => { - companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany1.id_company_user); + companyUserSelectPage.selectBusinessUnit({ + idCompanyUser: dynamicFixtures.companyUser1FromCompany1.id_company_user, + }); merchantRelationRequestIndexPage.visit(); merchantRelationRequestIndexPage.filterRequests({ status: 'canceled' }); @@ -114,7 +123,9 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () }); it('company user should not be able to cancel request from approved status', (): void => { - companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany1.id_company_user); + companyUserSelectPage.selectBusinessUnit({ + idCompanyUser: dynamicFixtures.companyUser1FromCompany1.id_company_user, + }); merchantRelationRequestIndexPage.visit(); merchantRelationRequestIndexPage.filterRequests({ status: 'approved' }); @@ -124,7 +135,9 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () }); it('company user should not be able to cancel request from rejected status', (): void => { - companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany1.id_company_user); + companyUserSelectPage.selectBusinessUnit({ + idCompanyUser: dynamicFixtures.companyUser1FromCompany1.id_company_user, + }); merchantRelationRequestIndexPage.visit(); merchantRelationRequestIndexPage.filterRequests({ status: 'rejected' }); @@ -134,7 +147,9 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () }); it('company user should be able to cancel request from pending status', (): void => { - companyUserSelectPage.selectBusinessUnit(dynamicFixtures.companyUser1FromCompany1.id_company_user); + companyUserSelectPage.selectBusinessUnit({ + idCompanyUser: dynamicFixtures.companyUser1FromCompany1.id_company_user, + }); merchantRelationRequestIndexPage.visit(); merchantRelationRequestIndexPage.filterRequests({ status: 'pending' }); diff --git a/cypress/support/pages/backoffice/backoffice-page.ts b/cypress/support/pages/backoffice/backoffice-page.ts index 06597c4e..06b422cd 100644 --- a/cypress/support/pages/backoffice/backoffice-page.ts +++ b/cypress/support/pages/backoffice/backoffice-page.ts @@ -8,4 +8,27 @@ export class BackofficePage extends AbstractPage { visit = (options?: Partial): void => { cy.visitBackoffice(this.PAGE_URL, options); }; + + protected interceptTable = (params: InterceptGuiTableParams): void => { + const expectedCount = params.expectedCount ?? 1; + const interceptAlias = this.faker.string.uuid(); + + cy.intercept('GET', params.url).as(interceptAlias); + cy.wait(`@${interceptAlias}`).its('response.body.recordsFiltered').should('eq', expectedCount); + }; +} + +export enum ActionEnum { + view, + edit, + activate, + deactivate, + approveAccess, + denyAccess, + delete, +} + +interface InterceptGuiTableParams { + url: string; + expectedCount?: number; } diff --git a/cypress/support/pages/backoffice/index.ts b/cypress/support/pages/backoffice/index.ts index 8cb7d1fc..0f4b7bc2 100644 --- a/cypress/support/pages/backoffice/index.ts +++ b/cypress/support/pages/backoffice/index.ts @@ -1,3 +1,4 @@ +export * from './backoffice-page'; export * from './index/index-page'; export * from './login/login-page'; export * from './merchant/create/merchant-create-page'; @@ -6,11 +7,11 @@ export * from './merchant/update/merchant-update-page'; export * from './merchant-user/create/merchant-user-create-page'; export * from './sales/detail/sales-detail-page'; export * from './sales/index/sales-index-page'; -export * from './sales-return-gui/create/sales-return-gui-create-page'; +export * from './sales-return/create/sales-return-create-page'; export * from './user/create/user-create-page'; export * from './user/delete/user-delete-page'; export * from './user/index/user-index-page'; export * from './user/update/user-update-page'; -export * from './merchant-relation-request-gui/list/merchant-relation-request-gui-list-page'; -export * from './merchant-relation-request-gui/edit/merchant-relation-request-gui-edit-page'; -export * from './merchant-relationship-gui/list/merchant-relationship-gui-list-page'; +export * from './merchant-relation-request/list/merchant-relation-request-list-page'; +export * from './merchant-relation-request/edit/merchant-relation-request-edit-page'; +export * from './merchant-relationship/list/merchant-relationship-list-page'; diff --git a/cypress/support/pages/backoffice/index/index-page.ts b/cypress/support/pages/backoffice/index/index-page.ts index 8d2e6ae6..760eba7a 100644 --- a/cypress/support/pages/backoffice/index/index-page.ts +++ b/cypress/support/pages/backoffice/index/index-page.ts @@ -1,7 +1,7 @@ import { autoWired } from '@utils'; import { injectable } from 'inversify'; -import { BackofficePage } from '../backoffice-page'; +import { BackofficePage } from '@pages/backoffice'; @injectable() @autoWired diff --git a/cypress/support/pages/backoffice/login/login-page.ts b/cypress/support/pages/backoffice/login/login-page.ts index 00f5703b..bf374097 100644 --- a/cypress/support/pages/backoffice/login/login-page.ts +++ b/cypress/support/pages/backoffice/login/login-page.ts @@ -1,7 +1,6 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; - -import { BackofficePage } from '../backoffice-page'; +import { BackofficePage } from '@pages/backoffice'; import { LoginRepository } from './login-repository'; @injectable() @@ -11,10 +10,15 @@ export class LoginPage extends BackofficePage { protected PAGE_URL = '/security-gui/login'; - login = (username: string, password: string): void => { - this.repository.getEmailInput().clear().type(username); - this.repository.getPasswordInput().clear().type(password); + login = (params: LoginParams): void => { + this.repository.getEmailInput().clear().type(params.username); + this.repository.getPasswordInput().clear().type(params.password); this.repository.getSubmitButton().click(); }; } + +interface LoginParams { + username: string; + password: string; +} diff --git a/cypress/support/pages/backoffice/merchant-relation-request-gui/edit/merchant-relation-request-gui-edit-page.ts b/cypress/support/pages/backoffice/merchant-relation-request-gui/edit/merchant-relation-request-gui-edit-page.ts deleted file mode 100644 index dbca5119..00000000 --- a/cypress/support/pages/backoffice/merchant-relation-request-gui/edit/merchant-relation-request-gui-edit-page.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { autoWired } from '@utils'; -import { inject, injectable } from 'inversify'; -import { BackofficePage } from '../../backoffice-page'; -import { MerchantRelationRequestGuiEditRepository } from './merchant-relation-request-gui-edit-repository'; - -@injectable() -@autoWired -export class MerchantRelationRequestGuiEditPage extends BackofficePage { - @inject(MerchantRelationRequestGuiEditRepository) private repository: MerchantRelationRequestGuiEditRepository; - - protected PAGE_URL = '/merchant-relation-request-gui/edit'; - - addInternalComment = (comment: string): void => { - this.repository.getInternalCommentTextarea().type(comment); - this.repository.getInternalCommentSubmitButton().click(); - }; - - rejectRequest = (): void => { - this.repository.getRejectButton().click(); - this.repository.getConfirmRejectButton().click(); - }; - - approveRequest = (isSplitEnabled: boolean): void => { - this.repository.getApprovalButton().click(); - - if (isSplitEnabled) { - this.repository.getIsSplitEnabledCheckbox().check(); - } - this.repository.getConfirmApprovalButton().click(); - }; -} diff --git a/cypress/support/pages/backoffice/merchant-relation-request-gui/list/merchant-relation-request-gui-list-page.ts b/cypress/support/pages/backoffice/merchant-relation-request-gui/list/merchant-relation-request-gui-list-page.ts deleted file mode 100644 index 1773a6c6..00000000 --- a/cypress/support/pages/backoffice/merchant-relation-request-gui/list/merchant-relation-request-gui-list-page.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { autoWired } from '@utils'; -import { inject, injectable } from 'inversify'; - -import { BackofficePage } from '../../backoffice-page'; -import { MerchantRelationRequestGuiListRepository } from './merchant-relation-request-gui-list-repository'; - -interface MerchantRelationRequestGuiListParams { - idMerchant?: number; - idCompany?: number; -} - -@injectable() -@autoWired -export class MerchantRelationRequestGuiListPage extends BackofficePage { - @inject(MerchantRelationRequestGuiListRepository) private repository: MerchantRelationRequestGuiListRepository; - - protected PAGE_URL = '/merchant-relation-request-gui/list'; - - editLastRequest = (params: MerchantRelationRequestGuiListParams): void => { - if (params.idMerchant) { - this.repository.getFilterMerchantSelect().select(params.idMerchant.toString()); - } - if (params.idCompany) { - this.repository.getFilterCompanySelect().select(params.idCompany.toString()); - } - - this.repository.getEditButtons().first().click(); - }; - - viewLastRequest = (params: MerchantRelationRequestGuiListParams): void => { - if (params.idMerchant) { - this.repository.getFilterMerchantSelect().select(params.idMerchant.toString()); - } - if (params.idCompany) { - this.repository.getFilterCompanySelect().select(params.idCompany.toString()); - } - - this.repository.getViewButtons().first().click(); - }; -} diff --git a/cypress/support/pages/backoffice/merchant-relation-request/edit/merchant-relation-request-edit-page.ts b/cypress/support/pages/backoffice/merchant-relation-request/edit/merchant-relation-request-edit-page.ts new file mode 100644 index 00000000..5d477455 --- /dev/null +++ b/cypress/support/pages/backoffice/merchant-relation-request/edit/merchant-relation-request-edit-page.ts @@ -0,0 +1,40 @@ +import { autoWired } from '@utils'; +import { inject, injectable } from 'inversify'; +import { BackofficePage } from '@pages/backoffice'; +import { MerchantRelationRequestEditRepository } from './merchant-relation-request-edit-repository'; + +@injectable() +@autoWired +export class MerchantRelationRequestEditPage extends BackofficePage { + @inject(MerchantRelationRequestEditRepository) private repository: MerchantRelationRequestEditRepository; + + protected PAGE_URL = '/merchant-relation-request-gui/edit'; + + addInternalComment = (params: AddInternalCommentParams): void => { + this.repository.getInternalCommentTextarea().type(params.comment); + this.repository.getInternalCommentSubmitButton().click(); + }; + + reject = (): void => { + this.repository.getRejectButton().click(); + this.repository.getConfirmRejectButton().click(); + }; + + approve = (params: ApproveParams): void => { + this.repository.getApprovalButton().click(); + + if (params.isSplitEnabled) { + this.repository.getIsSplitEnabledCheckbox().check(); + } + + this.repository.getConfirmApprovalButton().click(); + }; +} + +interface AddInternalCommentParams { + comment: string; +} + +interface ApproveParams { + isSplitEnabled?: boolean; +} diff --git a/cypress/support/pages/backoffice/merchant-relation-request-gui/edit/merchant-relation-request-gui-edit-repository.ts b/cypress/support/pages/backoffice/merchant-relation-request/edit/merchant-relation-request-edit-repository.ts similarity index 93% rename from cypress/support/pages/backoffice/merchant-relation-request-gui/edit/merchant-relation-request-gui-edit-repository.ts rename to cypress/support/pages/backoffice/merchant-relation-request/edit/merchant-relation-request-edit-repository.ts index d8171eac..886d0321 100644 --- a/cypress/support/pages/backoffice/merchant-relation-request-gui/edit/merchant-relation-request-gui-edit-repository.ts +++ b/cypress/support/pages/backoffice/merchant-relation-request/edit/merchant-relation-request-edit-repository.ts @@ -3,7 +3,7 @@ import { injectable } from 'inversify'; @injectable() @autoWired -export class MerchantRelationRequestGuiEditRepository { +export class MerchantRelationRequestEditRepository { getInternalCommentTextarea = (): Cypress.Chainable => cy.get('[action="/comment-gui/comment/add"] textarea'); getInternalCommentSubmitButton = (): Cypress.Chainable => cy.get('[action="/comment-gui/comment/add"] [type="submit"]'); diff --git a/cypress/support/pages/backoffice/merchant-relation-request/list/merchant-relation-request-list-page.ts b/cypress/support/pages/backoffice/merchant-relation-request/list/merchant-relation-request-list-page.ts new file mode 100644 index 00000000..b33cce8d --- /dev/null +++ b/cypress/support/pages/backoffice/merchant-relation-request/list/merchant-relation-request-list-page.ts @@ -0,0 +1,39 @@ +import { autoWired } from '@utils'; +import { inject, injectable } from 'inversify'; +import { BackofficePage, ActionEnum } from '@pages/backoffice'; +import { MerchantRelationRequestListRepository } from './merchant-relation-request-list-repository'; + +@injectable() +@autoWired +export class MerchantRelationRequestListPage extends BackofficePage { + @inject(MerchantRelationRequestListRepository) private repository: MerchantRelationRequestListRepository; + + protected PAGE_URL = '/merchant-relation-request-gui/list'; + + update = (params: UpdateParams): void => { + if (params.idMerchant) { + this.repository.getFilterMerchantSelect().select(params.idMerchant.toString()); + } + + if (params.idCompany) { + this.repository.getFilterCompanySelect().select(params.idCompany.toString()); + } + + switch (params.action) { + case ActionEnum.view: + this.repository.getViewButtons().first().click(); + break; + case ActionEnum.edit: + this.repository.getEditButtons().first().click(); + break; + default: + break; + } + }; +} + +interface UpdateParams { + action: ActionEnum; + idMerchant?: number; + idCompany?: number; +} diff --git a/cypress/support/pages/backoffice/merchant-relation-request-gui/list/merchant-relation-request-gui-list-repository.ts b/cypress/support/pages/backoffice/merchant-relation-request/list/merchant-relation-request-list-repository.ts similarity index 87% rename from cypress/support/pages/backoffice/merchant-relation-request-gui/list/merchant-relation-request-gui-list-repository.ts rename to cypress/support/pages/backoffice/merchant-relation-request/list/merchant-relation-request-list-repository.ts index c6f07cb2..c0e59f65 100644 --- a/cypress/support/pages/backoffice/merchant-relation-request-gui/list/merchant-relation-request-gui-list-repository.ts +++ b/cypress/support/pages/backoffice/merchant-relation-request/list/merchant-relation-request-list-repository.ts @@ -3,7 +3,7 @@ import { injectable } from 'inversify'; @injectable() @autoWired -export class MerchantRelationRequestGuiListRepository { +export class MerchantRelationRequestListRepository { getFilterMerchantSelect = (): Cypress.Chainable => cy.get('#idMerchant'); getFilterCompanySelect = (): Cypress.Chainable => cy.get('#idCompany'); getEditButtons = (): Cypress.Chainable => cy.get('.btn-edit'); diff --git a/cypress/support/pages/backoffice/merchant-relationship-gui/list/merchant-relationship-gui-list-page.ts b/cypress/support/pages/backoffice/merchant-relationship/list/merchant-relationship-list-page.ts similarity index 50% rename from cypress/support/pages/backoffice/merchant-relationship-gui/list/merchant-relationship-gui-list-page.ts rename to cypress/support/pages/backoffice/merchant-relationship/list/merchant-relationship-list-page.ts index b36d6a2c..972b0904 100644 --- a/cypress/support/pages/backoffice/merchant-relationship-gui/list/merchant-relationship-gui-list-page.ts +++ b/cypress/support/pages/backoffice/merchant-relationship/list/merchant-relationship-list-page.ts @@ -1,25 +1,21 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { BackofficePage } from '../../backoffice-page'; -import { MerchantRelationshipGuiListRepository } from './merchant-relationship-gui-list-repository'; - -interface MerchantRelationshipGuiListParams { - idCompany?: number; - query?: string; -} +import { BackofficePage } from '@pages/backoffice'; +import { MerchantRelationshipListRepository } from './merchant-relationship-list-repository'; @injectable() @autoWired -export class MerchantRelationshipGuiListPage extends BackofficePage { - @inject(MerchantRelationshipGuiListRepository) private repository: MerchantRelationshipGuiListRepository; +export class MerchantRelationshipListPage extends BackofficePage { + @inject(MerchantRelationshipListRepository) private repository: MerchantRelationshipListRepository; protected PAGE_URL = '/merchant-relationship-gui/list-merchant-relationship'; - applyFilters = (params: MerchantRelationshipGuiListParams): void => { + applyFilters = (params: ApplyFiltersParams): void => { if (params.idCompany) { this.repository.getFilterCompanySelect().select(params.idCompany.toString()); } + if (params.query) { this.repository.getFilterSearchInput().type(params.query); } @@ -27,8 +23,18 @@ export class MerchantRelationshipGuiListPage extends BackofficePage { getEditButtons = (): Cypress.Chainable => this.repository.getEditButtons(); - editLastRelation = (params: MerchantRelationshipGuiListParams): void => { - this.applyFilters(params); + update = (params: UpdateParams): void => { + this.applyFilters({ idCompany: params.idCompany, query: params.query }); this.repository.getEditButtons().first().click(); }; } + +interface ApplyFiltersParams { + idCompany?: number; + query?: string; +} + +interface UpdateParams { + idCompany?: number; + query?: string; +} diff --git a/cypress/support/pages/backoffice/merchant-relationship-gui/list/merchant-relationship-gui-list-repository.ts b/cypress/support/pages/backoffice/merchant-relationship/list/merchant-relationship-list-repository.ts similarity index 87% rename from cypress/support/pages/backoffice/merchant-relationship-gui/list/merchant-relationship-gui-list-repository.ts rename to cypress/support/pages/backoffice/merchant-relationship/list/merchant-relationship-list-repository.ts index 5e4c7cce..208f3fec 100644 --- a/cypress/support/pages/backoffice/merchant-relationship-gui/list/merchant-relationship-gui-list-repository.ts +++ b/cypress/support/pages/backoffice/merchant-relationship/list/merchant-relationship-list-repository.ts @@ -3,7 +3,7 @@ import { injectable } from 'inversify'; @injectable() @autoWired -export class MerchantRelationshipGuiListRepository { +export class MerchantRelationshipListRepository { getFilterCompanySelect = (): Cypress.Chainable => cy.get('#company-select'); getFilterSearchInput = (): Cypress.Chainable => cy.get('#merchant-relationship-table_filter [type="search"]'); getEditButtons = (): Cypress.Chainable => cy.get('.btn-edit'); diff --git a/cypress/support/pages/backoffice/merchant-user/create/merchant-user-create-page.ts b/cypress/support/pages/backoffice/merchant-user/create/merchant-user-create-page.ts index aaa58050..1463903b 100644 --- a/cypress/support/pages/backoffice/merchant-user/create/merchant-user-create-page.ts +++ b/cypress/support/pages/backoffice/merchant-user/create/merchant-user-create-page.ts @@ -1,14 +1,8 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { BackofficePage } from '../../backoffice-page'; +import { BackofficePage } from '@pages/backoffice'; import { MerchantUserCreateRepository } from './merchant-user-create-repository'; -interface User { - username: string; - firstName: string; - lastName: string; -} - @injectable() @autoWired export class MerchantUserCreatePage extends BackofficePage { @@ -16,7 +10,7 @@ export class MerchantUserCreatePage extends BackofficePage { protected PAGE_URL = '/merchant-user-gui/edit-merchant-user'; - createMerchantUser = (): User => { + create = (): User => { const uniquePrefix: string = this.faker.number.int({ min: 1000, max: 9999 }).toString(); const merchantUser = { @@ -34,3 +28,9 @@ export class MerchantUserCreatePage extends BackofficePage { return merchantUser; }; } + +interface User { + username: string; + firstName: string; + lastName: string; +} diff --git a/cypress/support/pages/backoffice/merchant/create/merchant-create-page.ts b/cypress/support/pages/backoffice/merchant/create/merchant-create-page.ts index 57c75187..b08322dd 100644 --- a/cypress/support/pages/backoffice/merchant/create/merchant-create-page.ts +++ b/cypress/support/pages/backoffice/merchant/create/merchant-create-page.ts @@ -1,15 +1,8 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { BackofficePage } from '../../backoffice-page'; +import { BackofficePage } from '@pages/backoffice'; import { MerchantCreateRepository } from './merchant-create-repository'; -interface Merchant { - name: string; - reference: string; - email: string; - url: string; -} - @injectable() @autoWired export class MerchantCreatePage extends BackofficePage { @@ -17,7 +10,7 @@ export class MerchantCreatePage extends BackofficePage { protected PAGE_URL = '/merchant-gui/create-merchant'; - createMerchant = (): Merchant => { + create = (): Merchant => { const identifier = this.faker.string.uuid(); const merchant = { @@ -35,8 +28,14 @@ export class MerchantCreatePage extends BackofficePage { this.repository.getENUrlInput().clear().type(merchant.url); this.repository.getSaveButton().click(); - cy.contains('Merchant created successfully.').should('exist'); return merchant; }; } + +interface Merchant { + name: string; + reference: string; + email: string; + url: string; +} diff --git a/cypress/support/pages/backoffice/merchant/list/merchant-list-page.ts b/cypress/support/pages/backoffice/merchant/list/merchant-list-page.ts index 59944e67..5486946a 100644 --- a/cypress/support/pages/backoffice/merchant/list/merchant-list-page.ts +++ b/cypress/support/pages/backoffice/merchant/list/merchant-list-page.ts @@ -1,7 +1,6 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; - -import { BackofficePage } from '../../backoffice-page'; +import { BackofficePage, ActionEnum } from '@pages/backoffice'; import { MerchantListRepository } from './merchant-list-repository'; @injectable() @@ -11,59 +10,49 @@ export class MerchantListPage extends BackofficePage { protected PAGE_URL = '/merchant-gui/list-merchant'; - editMerchant = (query: string): void => { - this.findMerchant(query).find(this.repository.getEditButtonSelector()).click(); - }; - - activateMerchant = (query: string): void => { - this.findMerchant(query).then((merchantRow) => { - const button = merchantRow.find(this.repository.getActivateButtonSelector()); + update = (params: UpdateParams): void => { + const findParams = { query: params.query, expectedCount: 1 }; - if (button.length) { - button.click(); + this.find(findParams).then(($merchantRow) => { + if (params.action === ActionEnum.edit) { + cy.wrap($merchantRow).find(this.repository.getEditButtonSelector()).should('exist').click(); } - }); - }; - - deactivateMerchant = (query: string): void => { - this.findMerchant(query).then((merchantRow) => { - const button = merchantRow.find(this.repository.getDeactivateButtonSelector()); - if (button.length) { - button.click(); + if (params.action === ActionEnum.activate) { + cy.wrap($merchantRow).find(this.repository.getActivateButtonSelector()).should('exist').click(); } - }); - }; - approveAccessMerchant = (query: string): void => { - this.findMerchant(query).then((merchantRow) => { - const button = merchantRow.find(this.repository.getApproveAccessButtonSelector()); - - if (button.length) { - button.click(); + if (params.action === ActionEnum.deactivate) { + cy.wrap($merchantRow).find(this.repository.getDeactivateButtonSelector()).should('exist').click(); } - }); - }; - denyAccessMerchant = (query: string): void => { - this.findMerchant(query).then((merchantRow) => { - const button = merchantRow.find(this.repository.getDenyAccessButtonSelector()); + if (params.action === ActionEnum.approveAccess) { + cy.wrap($merchantRow).find(this.repository.getDeactivateButtonSelector()).should('exist').click(); + } - if (button.length) { - button.click(); + if (params.action === ActionEnum.denyAccess) { + cy.wrap($merchantRow).find(this.repository.getDeactivateButtonSelector()).should('exist').click(); } }); }; - findMerchant = (query: string): Cypress.Chainable => { + find = (params: FindParams): Cypress.Chainable => { const searchSelector = this.repository.getSearchSelector(); cy.get(searchSelector).clear(); - cy.get(searchSelector).type(query); + cy.get(searchSelector).type(params.query); - const interceptAlias = this.faker.string.uuid(); - cy.intercept('GET', '/merchant-gui/list-merchant/table**').as(interceptAlias); - cy.wait(`@${interceptAlias}`).its('response.body.recordsFiltered').should('eq', 1); + this.interceptTable({ url: '/merchant-gui/list-merchant/table**', expectedCount: params.expectedCount }); return this.repository.getFirstTableRow(); }; } + +interface UpdateParams { + action: ActionEnum; + query: string; +} + +interface FindParams { + query: string; + expectedCount?: number; +} diff --git a/cypress/support/pages/backoffice/merchant/list/merchant-list-repository.ts b/cypress/support/pages/backoffice/merchant/list/merchant-list-repository.ts index 03ee36ca..7d559291 100644 --- a/cypress/support/pages/backoffice/merchant/list/merchant-list-repository.ts +++ b/cypress/support/pages/backoffice/merchant/list/merchant-list-repository.ts @@ -4,7 +4,7 @@ import { injectable } from 'inversify'; @injectable() @autoWired export class MerchantListRepository { - getFirstTableRow = (): Cypress.Chainable => cy.get('tbody > :nth-child(1)'); + getFirstTableRow = (): Cypress.Chainable => cy.get('tbody > :nth-child(1):visible'); getSearchSelector = (): string => '[type="search"]'; getEditButtonSelector = (): string => 'a:contains("Edit")'; getActivateButtonSelector = (): string => 'button:contains("Activate")'; diff --git a/cypress/support/pages/backoffice/merchant/update/merchant-update-page.ts b/cypress/support/pages/backoffice/merchant/update/merchant-update-page.ts index 12eb663b..e316433d 100644 --- a/cypress/support/pages/backoffice/merchant/update/merchant-update-page.ts +++ b/cypress/support/pages/backoffice/merchant/update/merchant-update-page.ts @@ -1,7 +1,6 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; - -import { BackofficePage } from '../../backoffice-page'; +import { BackofficePage } from '@pages/backoffice'; import { MerchantUpdateRepository } from './merchant-update-repository'; @injectable() @@ -11,20 +10,23 @@ export class MerchantUpdatePage extends BackofficePage { protected PAGE_URL = '/merchant-gui/edit-merchant'; - findUser = (email: string): Cypress.Chainable => { + find = (params: FindParams): Cypress.Chainable => { const searchSelector = this.repository.getSearchSelector(); cy.get(searchSelector).clear(); - cy.get(searchSelector).type(email); + cy.get(searchSelector).type(params.query); - const interceptAlias = this.faker.string.uuid(); - cy.intercept('GET', '/merchant-user-gui/index/table**').as(interceptAlias); - cy.wait(`@${interceptAlias}`).its('response.body.recordsFiltered').should('eq', 1); + this.interceptTable({ url: '/merchant-user-gui/index/table**', expectedCount: params.expectedCount }); return this.repository.getFirstTableRow(); }; - createNewUser = (): void => { + create = (): void => { this.repository.getUsersTab().click(); this.repository.getAddMerchantUserButton().click(); }; } + +interface FindParams { + query: string; + expectedCount?: number; +} diff --git a/cypress/support/pages/backoffice/merchant/update/merchant-update-repository.ts b/cypress/support/pages/backoffice/merchant/update/merchant-update-repository.ts index a3bf9917..01e8ca64 100644 --- a/cypress/support/pages/backoffice/merchant/update/merchant-update-repository.ts +++ b/cypress/support/pages/backoffice/merchant/update/merchant-update-repository.ts @@ -5,7 +5,7 @@ import { injectable } from 'inversify'; @autoWired export class MerchantUpdateRepository { getUsersTab = (): Cypress.Chainable => cy.get('[data-tab-content-id="tab-content-merchant-user"]'); - getFirstTableRow = (): Cypress.Chainable => cy.get('tbody > :nth-child(1)'); + getFirstTableRow = (): Cypress.Chainable => cy.get('tbody > :nth-child(1):visible'); getSearchSelector = (): string => '.dataTables_filter input[type="search"]'; getAddMerchantUserButton = (): Cypress.Chainable => cy.get('body').find('a:contains("Add Merchant User")'); } diff --git a/cypress/support/pages/backoffice/sales-return-gui/create/sales-return-gui-create-page.ts b/cypress/support/pages/backoffice/sales-return-gui/create/sales-return-gui-create-page.ts deleted file mode 100644 index eb0f5138..00000000 --- a/cypress/support/pages/backoffice/sales-return-gui/create/sales-return-gui-create-page.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { autoWired } from '@utils'; -import { inject, injectable } from 'inversify'; - -import { BackofficePage } from '../../backoffice-page'; -import { SalesReturnGuiCreateRepository } from './sales-return-gui-create-repository'; - -@injectable() -@autoWired -export class SalesReturnGuiCreatePage extends BackofficePage { - @inject(SalesReturnGuiCreateRepository) private repository: SalesReturnGuiCreateRepository; - - protected PAGE_URL = '/sales-return-gui/create'; - - createReturnForAllOrderItems = (): void => { - this.repository.getAllItemsCheckbox().check(); - this.repository.getCreateReturnButton().click(); - }; -} diff --git a/cypress/support/pages/backoffice/sales-return/create/sales-return-create-page.ts b/cypress/support/pages/backoffice/sales-return/create/sales-return-create-page.ts new file mode 100644 index 00000000..d722ada7 --- /dev/null +++ b/cypress/support/pages/backoffice/sales-return/create/sales-return-create-page.ts @@ -0,0 +1,17 @@ +import { autoWired } from '@utils'; +import { inject, injectable } from 'inversify'; +import { BackofficePage } from '@pages/backoffice'; +import { SalesReturnCreateRepository } from './sales-return-create-repository'; + +@injectable() +@autoWired +export class SalesReturnCreatePage extends BackofficePage { + @inject(SalesReturnCreateRepository) private repository: SalesReturnCreateRepository; + + protected PAGE_URL = '/sales-return-gui/create'; + + create = (): void => { + this.repository.getAllItemsCheckbox().check(); + this.repository.getCreateReturnButton().click(); + }; +} diff --git a/cypress/support/pages/backoffice/sales-return-gui/create/sales-return-gui-create-repository.ts b/cypress/support/pages/backoffice/sales-return/create/sales-return-create-repository.ts similarity index 87% rename from cypress/support/pages/backoffice/sales-return-gui/create/sales-return-gui-create-repository.ts rename to cypress/support/pages/backoffice/sales-return/create/sales-return-create-repository.ts index e9f723f3..677b2893 100644 --- a/cypress/support/pages/backoffice/sales-return-gui/create/sales-return-gui-create-repository.ts +++ b/cypress/support/pages/backoffice/sales-return/create/sales-return-create-repository.ts @@ -3,7 +3,7 @@ import { injectable } from 'inversify'; @injectable() @autoWired -export class SalesReturnGuiCreateRepository { +export class SalesReturnCreateRepository { getAllItemsCheckbox = (): Cypress.Chainable => cy.get('.js-check-all-items'); getCreateReturnButton = (): Cypress.Chainable => cy.get('form[name=return_create_form]').find('button:contains("Create return")'); diff --git a/cypress/support/pages/backoffice/sales/detail/sales-detail-page.ts b/cypress/support/pages/backoffice/sales/detail/sales-detail-page.ts index ab24a8a4..5a81e79c 100644 --- a/cypress/support/pages/backoffice/sales/detail/sales-detail-page.ts +++ b/cypress/support/pages/backoffice/sales/detail/sales-detail-page.ts @@ -1,34 +1,41 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { BackofficePage } from '../../backoffice-page'; +import { BackofficePage } from '@pages/backoffice'; import { SalesDetailRepository } from './sales-detail-repository'; @injectable() @autoWired export class SalesDetailPage extends BackofficePage { - protected PAGE_URL = '/sales/detail'; - @inject(SalesDetailRepository) private repository: SalesDetailRepository; - triggerOms = (state: string, shouldTriggerOmsInCli = false): void => { - if (shouldTriggerOmsInCli) { + protected PAGE_URL = '/sales/detail'; + + triggerOms = (params: TriggerOmsParams): void => { + if (params.shouldTriggerOmsInCli) { cy.runCliCommands(['console oms:check-condition', 'console oms:check-timeout']); } cy.url().then((url) => { cy.reloadUntilFound( url, - this.repository.getOmsButtonSelector(state), + this.repository.getOmsButtonSelector(params.state), this.repository.getTriggerOmsDivSelector(), 30, 500 ); - cy.get(this.repository.getTriggerOmsDivSelector()).find(this.repository.getOmsButtonSelector(state)).click(); + cy.get(this.repository.getTriggerOmsDivSelector()) + .find(this.repository.getOmsButtonSelector(params.state)) + .click(); }); }; - createReturn = (): void => { + create = (): void => { this.repository.getReturnButton().click(); }; } + +interface TriggerOmsParams { + state: string; + shouldTriggerOmsInCli?: boolean; +} diff --git a/cypress/support/pages/backoffice/sales/index/sales-index-page.ts b/cypress/support/pages/backoffice/sales/index/sales-index-page.ts index e9a6888a..e0fd8131 100644 --- a/cypress/support/pages/backoffice/sales/index/sales-index-page.ts +++ b/cypress/support/pages/backoffice/sales/index/sales-index-page.ts @@ -1,7 +1,6 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; - -import { BackofficePage } from '../../backoffice-page'; +import { BackofficePage } from '@pages/backoffice'; import { SalesIndexRepository } from './sales-index-repository'; @injectable() @@ -11,8 +10,7 @@ export class SalesIndexPage extends BackofficePage { protected PAGE_URL = '/sales'; - viewLastPlacedOrder = (): void => { - cy.visitBackoffice(this.PAGE_URL); + view = (): void => { this.repository.getViewButtons().first().click(); }; } diff --git a/cypress/support/pages/backoffice/user/create/user-create-page.ts b/cypress/support/pages/backoffice/user/create/user-create-page.ts index b53c8384..64b6c44b 100644 --- a/cypress/support/pages/backoffice/user/create/user-create-page.ts +++ b/cypress/support/pages/backoffice/user/create/user-create-page.ts @@ -1,13 +1,8 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { BackofficePage } from '../../backoffice-page'; +import { BackofficePage } from '@pages/backoffice'; import { UserCreateRepository } from './user-create-repository'; -interface User { - username: string; - password: string; -} - @injectable() @autoWired export class UserCreatePage extends BackofficePage { @@ -17,43 +12,41 @@ export class UserCreatePage extends BackofficePage { private DEFAULT_PASSWORD = 'Change123@_'; private EN_LOCALE_VALUE = '66'; - createRootUser = (): User => { + create = (params: CreateParams): User => { const user = { - username: this.faker.internet.email(), - password: this.DEFAULT_PASSWORD, + username: params.username || this.faker.internet.email(), + password: params.password || this.DEFAULT_PASSWORD, }; - this.fillCreateUserForm(user.username, user.password); + this.repository.getUsernameInput().clear().type(user.username); + this.repository.getPasswordInput().clear().type(user.password); + this.repository.getRepeatPasswordInput().clear().type(user.password); + this.repository.getFirstNameInput().clear().type(this.faker.person.firstName()); + this.repository.getLastNameInput().clear().type(this.faker.person.lastName()); + this.repository.getInterfaceLanguageSelect().select(this.EN_LOCALE_VALUE); - this.repository.getRootGroupCheckbox().check(); - this.repository.getCreateUserButton().click(); - cy.contains('User was created successfully.').should('exist'); + if (params.isRootUser) { + this.repository.getRootGroupCheckbox().check(); + } - return user; - }; + if (params.isAgentMerchant) { + this.repository.getAgentMerchantCheckbox().check(); + } - createAgentMerchantUser = (): User => { - const user = { - username: this.faker.internet.email(), - password: this.DEFAULT_PASSWORD, - }; - - this.fillCreateUserForm(user.username, user.password); - - this.repository.getRootGroupCheckbox().check(); - this.repository.getAgentMerchantCheckbox().check(); this.repository.getCreateUserButton().click(); - cy.contains('User was created successfully.').should('exist'); return user; }; +} - private fillCreateUserForm = (username: string, password: string): void => { - this.repository.getUsernameInput().clear().type(username); - this.repository.getPasswordInput().clear().type(password); - this.repository.getRepeatPasswordInput().clear().type(password); - this.repository.getFirstNameInput().clear().type(this.faker.person.firstName()); - this.repository.getLastNameInput().clear().type(this.faker.person.lastName()); - this.repository.getInterfaceLanguageSelect().select(this.EN_LOCALE_VALUE); - }; +interface CreateParams { + username?: string; + password?: string; + isRootUser?: boolean; + isAgentMerchant?: boolean; +} + +interface User { + username: string; + password: string; } diff --git a/cypress/support/pages/backoffice/user/delete/user-delete-page.ts b/cypress/support/pages/backoffice/user/delete/user-delete-page.ts index 4f910b98..c42e1876 100644 --- a/cypress/support/pages/backoffice/user/delete/user-delete-page.ts +++ b/cypress/support/pages/backoffice/user/delete/user-delete-page.ts @@ -1,7 +1,6 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; - -import { BackofficePage } from '../../backoffice-page'; +import { BackofficePage } from '@pages/backoffice'; import { UserDeleteRepository } from './user-delete-repository'; @injectable() @@ -11,7 +10,7 @@ export class UserDeletePage extends BackofficePage { protected PAGE_URL = '/user/edit/confirm-delete'; - confirmDelete = (): void => { + confirm = (): void => { this.repository.getDeleteButton().click(); }; } diff --git a/cypress/support/pages/backoffice/user/index/user-index-page.ts b/cypress/support/pages/backoffice/user/index/user-index-page.ts index 421cddf9..34390bc2 100644 --- a/cypress/support/pages/backoffice/user/index/user-index-page.ts +++ b/cypress/support/pages/backoffice/user/index/user-index-page.ts @@ -1,7 +1,6 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; - -import { BackofficePage } from '../../backoffice-page'; +import { BackofficePage, ActionEnum } from '@pages/backoffice'; import { UserIndexRepository } from './user-index-repository'; @injectable() @@ -11,52 +10,38 @@ export class UserIndexPage extends BackofficePage { protected PAGE_URL = '/user'; - createNewUser = (): void => { + add = (): void => { this.repository.getAddNewUserButton().click(); }; - editUser = (query: string): void => { - this.findUser(query).find(this.repository.getEditButtonSelector()).click(); - }; - - deactivateUser = (query: string): void => { - this.findUser(query).then((merchantRow) => { - const button = merchantRow.find(this.repository.getDeactivateButtonSelector()); + update = (params: UpdateParams): void => { + const findParams = { query: params.query, expectedCount: 1 }; - if (button.length) { - button.click(); + this.find(findParams).then(($userRow) => { + if (params.action === ActionEnum.edit) { + cy.wrap($userRow).find(this.repository.getEditButtonSelector()).should('exist').click(); } - }); - }; - - deleteUser = (query: string): void => { - this.findUser(query).then((merchantRow) => { - const button = merchantRow.find(this.repository.getDeleteButtonSelector()); - if (button.length) { - button.click(); + if (params.action === ActionEnum.deactivate) { + cy.wrap($userRow).find(this.repository.getDeactivateButtonSelector()).should('exist').click(); } - }); - }; - activateUser = (query: string): void => { - this.findUser(query).then((merchantRow) => { - const button = merchantRow.find(this.repository.getActivateButtonSelector()); + if (params.action === ActionEnum.activate) { + cy.wrap($userRow).find(this.repository.getActivateButtonSelector()).should('exist').click(); + } - if (button.length) { - button.click(); + if (params.action === ActionEnum.delete) { + cy.wrap($userRow).find(this.repository.getDeleteButtonSelector()).should('exist').click(); } }); }; - findUser = (query: string): Cypress.Chainable => { + find = (params: FindParams): Cypress.Chainable => { const searchSelector = this.repository.getSearchSelector(); cy.get(searchSelector).clear(); - cy.get(searchSelector).type(query); + cy.get(searchSelector).type(params.query); - const interceptAlias = this.faker.string.uuid(); - cy.intercept('GET', '/user/index/table**').as(interceptAlias); - cy.wait(`@${interceptAlias}`).its('response.body.recordsFiltered').should('eq', 1); + this.interceptTable({ url: '/user/index/table**', expectedCount: params.expectedCount }); return this.repository.getFirstTableRow(); }; @@ -65,3 +50,13 @@ export class UserIndexPage extends BackofficePage { return this.repository.getTableHeader(); }; } + +interface FindParams { + query: string; + expectedCount?: number; +} + +interface UpdateParams { + action: ActionEnum; + query: string; +} diff --git a/cypress/support/pages/backoffice/user/index/user-index-repository.ts b/cypress/support/pages/backoffice/user/index/user-index-repository.ts index 07d7bf33..2b908d6d 100644 --- a/cypress/support/pages/backoffice/user/index/user-index-repository.ts +++ b/cypress/support/pages/backoffice/user/index/user-index-repository.ts @@ -4,7 +4,7 @@ import { injectable } from 'inversify'; @injectable() @autoWired export class UserIndexRepository { - getFirstTableRow = (): Cypress.Chainable => cy.get('tbody > :nth-child(1)'); + getFirstTableRow = (): Cypress.Chainable => cy.get('tbody > :nth-child(1):visible'); getEditButtonSelector = (): string => 'a:contains("Edit")'; getDeactivateButtonSelector = (): string => 'button:contains("Deactivate")'; getDeleteButtonSelector = (): string => 'button:contains("Delete")'; diff --git a/cypress/support/pages/backoffice/user/update/user-update-page.ts b/cypress/support/pages/backoffice/user/update/user-update-page.ts index ef95bfb3..f0015b99 100644 --- a/cypress/support/pages/backoffice/user/update/user-update-page.ts +++ b/cypress/support/pages/backoffice/user/update/user-update-page.ts @@ -1,7 +1,6 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; - -import { BackofficePage } from '../../backoffice-page'; +import { BackofficePage } from '@pages/backoffice'; import { UserUpdateRepository } from './user-update-repository'; @injectable() diff --git a/cypress/support/pages/mp/agent-dashboard/agent-dashboard-page.ts b/cypress/support/pages/mp/agent-dashboard/agent-dashboard-page.ts index 0fadcfa1..3954c822 100644 --- a/cypress/support/pages/mp/agent-dashboard/agent-dashboard-page.ts +++ b/cypress/support/pages/mp/agent-dashboard/agent-dashboard-page.ts @@ -1,7 +1,7 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { MpPage } from '../mp-page'; +import { MpPage } from '@pages/mp'; import { AgentDashboardRepository } from './agent-dashboard-repository'; @injectable() @@ -11,30 +11,46 @@ export class AgentDashboardPage extends MpPage { protected PAGE_URL = '/agent-dashboard-merchant-portal-gui/merchant-users'; - getDashboardSidebarSelector = (): Cypress.Chainable => { - return this.repository.getDashboardSidebarSelector(); - }; + assist = (params: AssistParams): void => { + const findParams = { query: params.query, expectedCount: 1 }; - assistMerchantUser = (query: string): void => { - this.findMerchantUser(query).then((merchantUserRow) => { - const button = merchantUserRow.find(this.repository.getAssistUserButtonSelector()); - - if (button.length) { - button.click(); - this.repository.getModalConfirmButton().click(); - } + this.find(findParams).then(($merchantUserRow) => { + cy.wrap($merchantUserRow).find(this.repository.getAssistUserButtonSelector()).should('exist').click(); + this.repository.getModalConfirmButton().click(); }); }; - findMerchantUser = (query: string, counter = 1): Cypress.Chainable => { + find = (params: FindParams): Cypress.Chainable => { const searchSelector = this.repository.getSearchSelector(); cy.get(searchSelector).clear(); - cy.get(searchSelector).type(query); + cy.get(searchSelector).type(params.query); - const interceptAlias = this.faker.string.uuid(); - cy.intercept('GET', '/agent-dashboard-merchant-portal-gui/merchant-users/table-data**').as(interceptAlias); - cy.wait(`@${interceptAlias}`).its('response.body.total').should('eq', counter); + this.interceptTable({ + url: '/agent-dashboard-merchant-portal-gui/merchant-users/table-data**', + expectedCount: params.expectedCount, + }); return this.repository.getFirstTableRow(); }; + + getDashboardSidebarSelector = (): Cypress.Chainable => { + return this.repository.getDashboardSidebarSelector(); + }; + + getEndUserAssistanceSelector = (): string => { + return this.repository.getEndUserAssistanceSelector(); + }; + + getLogoutAgentSelector = (): string => { + return this.repository.getLogoutAgentSelector(); + }; +} + +interface AssistParams { + query: string; +} + +interface FindParams { + query: string; + expectedCount?: number; } diff --git a/cypress/support/pages/mp/agent-dashboard/agent-dashboard-repository.ts b/cypress/support/pages/mp/agent-dashboard/agent-dashboard-repository.ts index 9b74ef83..91248d22 100644 --- a/cypress/support/pages/mp/agent-dashboard/agent-dashboard-repository.ts +++ b/cypress/support/pages/mp/agent-dashboard/agent-dashboard-repository.ts @@ -8,6 +8,8 @@ export class AgentDashboardRepository { getFirstTableRow = (): Cypress.Chainable => cy.get('nz-table-inner-default tbody > :nth-child(1)'); getSearchSelector = (): string => '.spy-table-search-feature input[type="text"]'; getAssistUserButtonSelector = (): string => 'button:contains("Assist User")'; + getEndUserAssistanceSelector = (): string => 'a:contains("End User Assistance")'; + getLogoutAgentSelector = (): string => 'a:contains("Log out Agent")'; getModalConfirmButton = (): Cypress.Chainable => cy.get('[ng-reflect-ng-class="ant-modal--confirmation"]').find('button:contains("Confirm")'); } diff --git a/cypress/support/pages/mp/agent-login/agent-login-page.ts b/cypress/support/pages/mp/agent-login/agent-login-page.ts index 11edd82d..1da91048 100644 --- a/cypress/support/pages/mp/agent-login/agent-login-page.ts +++ b/cypress/support/pages/mp/agent-login/agent-login-page.ts @@ -1,7 +1,7 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { MpPage } from '../mp-page'; +import { MpPage } from '@pages/mp'; import { AgentLoginRepository } from './agent-login-repository'; @injectable() @@ -11,9 +11,9 @@ export class AgentLoginPage extends MpPage { protected PAGE_URL = '/agent-security-merchant-portal-gui/login'; - login = (username: string, password: string): void => { - this.repository.getEmailInput().clear().type(username); - this.repository.getPasswordInput().clear().type(password); + login = (params: LoginParams): void => { + this.repository.getEmailInput().clear().type(params.username); + this.repository.getPasswordInput().clear().type(params.password); this.repository.getSubmitButton().click(); }; @@ -22,3 +22,8 @@ export class AgentLoginPage extends MpPage { return this.repository.getFailedAuthenticationText(); }; } + +interface LoginParams { + username: string; + password: string; +} diff --git a/cypress/support/pages/mp/dashboard/dashboard-page.ts b/cypress/support/pages/mp/dashboard/dashboard-page.ts index bb158461..7091c18f 100644 --- a/cypress/support/pages/mp/dashboard/dashboard-page.ts +++ b/cypress/support/pages/mp/dashboard/dashboard-page.ts @@ -1,7 +1,7 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { MpPage } from '../mp-page'; +import { MpPage } from '@pages/mp'; import { DashboardRepository } from './dashboard-repository'; @injectable() diff --git a/cypress/support/pages/mp/index.ts b/cypress/support/pages/mp/index.ts index bd458fbd..450eb33f 100644 --- a/cypress/support/pages/mp/index.ts +++ b/cypress/support/pages/mp/index.ts @@ -1,3 +1,4 @@ +export * from './mp-page'; export * from './agent-dashboard/agent-dashboard-page'; export * from './agent-login/agent-login-page'; export * from './dashboard/dashboard-page'; diff --git a/cypress/support/pages/mp/login/login-page.ts b/cypress/support/pages/mp/login/login-page.ts index b9790104..5efed580 100644 --- a/cypress/support/pages/mp/login/login-page.ts +++ b/cypress/support/pages/mp/login/login-page.ts @@ -1,7 +1,7 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { MpPage } from '../mp-page'; +import { MpPage } from '@pages/mp'; import { LoginRepository } from './login-repository'; @injectable() @@ -11,10 +11,9 @@ export class LoginPage extends MpPage { protected PAGE_URL = '/security-merchant-portal-gui/login'; - login = (username: string, password: string): void => { - cy.visitMerchantPortal(this.PAGE_URL); - this.repository.getEmailInput().clear().type(username); - this.repository.getPasswordInput().clear().type(password); + login = (params: LoginParams): void => { + this.repository.getEmailInput().clear().type(params.username); + this.repository.getPasswordInput().clear().type(params.password); this.repository.getSubmitButton().click(); }; @@ -23,3 +22,8 @@ export class LoginPage extends MpPage { return this.repository.getFailedAuthenticationText(); }; } + +interface LoginParams { + username: string; + password: string; +} diff --git a/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-page.ts b/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-page.ts index e0c59b03..910345cf 100644 --- a/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-page.ts +++ b/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-page.ts @@ -1,7 +1,7 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { MpPage } from '../mp-page'; +import { MpPage } from '@pages/mp'; import { MerchantRelationRequestsRepository } from './merchant-relation-requests-repository'; @injectable() @@ -11,16 +11,15 @@ export class MerchantRelationRequestsPage extends MpPage { protected PAGE_URL = '/merchant-relation-request-merchant-portal-gui/merchant-relation-requests'; - findRequest = (query: string): Cypress.Chainable => { + find = (params: FindParams): Cypress.Chainable => { const searchSelector = this.repository.getSearchSelector(); cy.get(searchSelector).clear(); - cy.get(searchSelector).type(query); + cy.get(searchSelector).type(params.query); - const interceptAlias = this.faker.string.uuid(); - cy.intercept('GET', '/merchant-relation-request-merchant-portal-gui/merchant-relation-requests/table-data**').as( - interceptAlias - ); - cy.wait(`@${interceptAlias}`).its('response.body.total').should('eq', 1); + this.interceptTable({ + url: '/merchant-relation-request-merchant-portal-gui/merchant-relation-requests/table-data**', + expectedCount: params.expectedCount, + }); return this.repository.getFirstTableRow(); }; @@ -29,34 +28,52 @@ export class MerchantRelationRequestsPage extends MpPage { return this.repository.getDrawer(); }; - addInternalComment = (comment: string): void => { - this.repository.getInternalCommentTextarea().type(comment); + addInternalComment = (params: AddInternalCommentParams): void => { + this.repository.getInternalCommentTextarea().type(params.comment); this.repository.getInternalCommentAddCommentButton().click(); }; - approveRequest = (isSplitEnabled: boolean): void => { - if (isSplitEnabled) { + approve = (params?: ApproveParams): void => { + if (params?.isSplitEnabled) { this.repository.getDrawer().find(this.repository.getIsSplitEnabledCheckboxSelector()).click(); } - this.repository.getDrawer().find('button:contains("Approve")').click(); + this.repository.getDrawer().find(this.repository.getApproveButtonSelector()).click(); this.repository.getApprovalModalConfirmButton().click(); }; - rejectRequest = (): void => { - this.repository.getDrawer().find('button:contains("Reject")').click(); + reject = (): void => { + this.repository.getDrawer().find(this.repository.getRejectButtonSelector()).click(); this.repository.getRejectionModalConfirmButton().click(); }; - uncheckBusinessUnits = (businessUnitIds: number[]): void => { + uncheckBusinessUnits = (params: UncheckBusinessUnitsParams): void => { this.getDrawer() - .find('[id="assigneeCompanyBusinessUnits[]"]') + .find(this.repository.getBusinessUnitsCheckboxSelector()) .each(($businessUnitCheckbox) => { - const idBusinessUnit = $businessUnitCheckbox.find('[type="checkbox"]').last().attr('value') ?? ''; + const checkboxSelector = this.repository.getBusinessUnitCheckboxSelector(); + const idBusinessUnit = $businessUnitCheckbox.find(checkboxSelector).last().attr('value') ?? ''; - if (businessUnitIds.includes(parseInt(idBusinessUnit))) { - cy.wrap($businessUnitCheckbox.find('[type="checkbox"]').first()).uncheck(); + if (params.businessUnitIds.includes(parseInt(idBusinessUnit))) { + cy.wrap($businessUnitCheckbox.find(checkboxSelector).first()).uncheck(); } }); }; } + +interface FindParams { + query: string; + expectedCount?: number; +} + +interface AddInternalCommentParams { + comment: string; +} + +interface ApproveParams { + isSplitEnabled: boolean; +} + +interface UncheckBusinessUnitsParams { + businessUnitIds: number[]; +} diff --git a/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-repository.ts b/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-repository.ts index 28a5b320..4b0f114d 100644 --- a/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-repository.ts +++ b/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-repository.ts @@ -4,13 +4,17 @@ import { injectable } from 'inversify'; @injectable() @autoWired export class MerchantRelationRequestsRepository { - getFirstTableRow = (): Cypress.Chainable => cy.get('tbody > :nth-child(1)'); + getFirstTableRow = (): Cypress.Chainable => cy.get('tbody > :nth-child(1):visible'); getSearchSelector = (): string => '.spy-table-search-feature input[type="text"]'; getDrawer = (): Cypress.Chainable => cy.get('.spy-drawer-wrapper'); getInternalCommentTextarea = (): Cypress.Chainable => cy.get('.mp-add-comment__form textarea'); getInternalCommentAddCommentButton = (): Cypress.Chainable => cy.get('.mp-add-comment__form').find('[shape="circle"]'); getIsSplitEnabledCheckboxSelector = (): string => '[spy-id="isSplitEnabled"]'; + getApproveButtonSelector = (): string => 'button:contains("Approve")'; + getRejectButtonSelector = (): string => 'button:contains("Reject")'; + getBusinessUnitsCheckboxSelector = (): string => '[id="assigneeCompanyBusinessUnits[]"]'; + getBusinessUnitCheckboxSelector = (): string => '[type="checkbox"]'; getApprovalModalConfirmButton = (): Cypress.Chainable => cy.get('[ng-reflect-ng-class="ant-modal--confirmation"]').find('button:contains("Confirm approval")'); getRejectionModalConfirmButton = (): Cypress.Chainable => diff --git a/cypress/support/pages/mp/merchant-relations/merchant-relations-page.ts b/cypress/support/pages/mp/merchant-relations/merchant-relations-page.ts index 9b5c1529..032bd362 100644 --- a/cypress/support/pages/mp/merchant-relations/merchant-relations-page.ts +++ b/cypress/support/pages/mp/merchant-relations/merchant-relations-page.ts @@ -1,7 +1,7 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { MpPage } from '../mp-page'; +import { MpPage } from '@pages/mp'; import { MerchantRelationsRepository } from './merchant-relations-repository'; @injectable() @@ -11,16 +11,15 @@ export class MerchantRelationsPage extends MpPage { protected PAGE_URL = '/merchant-relationship-merchant-portal-gui/merchant-relationship'; - findRelation = (query: string, counter = 1): Cypress.Chainable => { + find = (params: FindParams): Cypress.Chainable => { const searchSelector = this.repository.getSearchSelector(); cy.get(searchSelector).clear(); - cy.get(searchSelector).type(query); + cy.get(searchSelector).type(params.query); - const interceptAlias = this.faker.string.uuid(); - cy.intercept('GET', '/merchant-relationship-merchant-portal-gui/merchant-relationship/table-data**').as( - interceptAlias - ); - cy.wait(`@${interceptAlias}`).its('response.body.total').should('eq', counter); + this.interceptTable({ + url: '/merchant-relationship-merchant-portal-gui/merchant-relationship/table-data**', + expectedCount: params.expectedCount, + }); return this.repository.getFirstTableRow(); }; @@ -29,3 +28,8 @@ export class MerchantRelationsPage extends MpPage { return this.repository.getDrawer(); }; } + +interface FindParams { + query: string; + expectedCount?: number; +} diff --git a/cypress/support/pages/mp/merchant-relations/merchant-relations-repository.ts b/cypress/support/pages/mp/merchant-relations/merchant-relations-repository.ts index bbd5896a..4e204372 100644 --- a/cypress/support/pages/mp/merchant-relations/merchant-relations-repository.ts +++ b/cypress/support/pages/mp/merchant-relations/merchant-relations-repository.ts @@ -4,7 +4,7 @@ import { injectable } from 'inversify'; @injectable() @autoWired export class MerchantRelationsRepository { - getFirstTableRow = (): Cypress.Chainable => cy.get('tbody > :nth-child(1)'); + getFirstTableRow = (): Cypress.Chainable => cy.get('tbody > :nth-child(1):visible'); getSearchSelector = (): string => '.spy-table-search-feature input[type="text"]'; getDrawer = (): Cypress.Chainable => cy.get('.spy-drawer-wrapper'); } diff --git a/cypress/support/pages/mp/mp-page.ts b/cypress/support/pages/mp/mp-page.ts index 424c0eff..7a9f444e 100644 --- a/cypress/support/pages/mp/mp-page.ts +++ b/cypress/support/pages/mp/mp-page.ts @@ -8,4 +8,17 @@ export class MpPage extends AbstractPage { visit = (options?: Partial): void => { cy.visitMerchantPortal(this.PAGE_URL, options); }; + + protected interceptTable = (params: InterceptMpGuiTableParams): void => { + const expectedCount = params.expectedCount ?? 1; + const interceptAlias = this.faker.string.uuid(); + + cy.intercept('GET', params.url).as(interceptAlias); + cy.wait(`@${interceptAlias}`).its('response.body.total').should('eq', expectedCount); + }; +} + +interface InterceptMpGuiTableParams { + url: string; + expectedCount?: number; } diff --git a/cypress/support/pages/mp/offers/offers-page.ts b/cypress/support/pages/mp/offers/offers-page.ts index 775805f8..3028822d 100644 --- a/cypress/support/pages/mp/offers/offers-page.ts +++ b/cypress/support/pages/mp/offers/offers-page.ts @@ -1,7 +1,7 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { MpPage } from '../mp-page'; +import { MpPage } from '@pages/mp'; import { OffersRepository } from './offers-repository'; @injectable() @@ -11,14 +11,15 @@ export class OffersPage extends MpPage { protected PAGE_URL = '/product-offer-merchant-portal-gui/product-offers'; - findOffer = (query: string): Cypress.Chainable => { + find = (params: FindParams): Cypress.Chainable => { const searchSelector = this.repository.getSearchSelector(); cy.get(searchSelector).clear(); - cy.get(searchSelector).type(query); + cy.get(searchSelector).type(params.query); - const interceptAlias = this.faker.string.uuid(); - cy.intercept('GET', '/product-offer-merchant-portal-gui/product-offers/table-data**').as(interceptAlias); - cy.wait(`@${interceptAlias}`).its('response.body.total').should('eq', 1); + this.interceptTable({ + url: '/product-offer-merchant-portal-gui/product-offers/table-data**', + expectedCount: params.expectedCount, + }); return this.repository.getFirstTableRow(); }; @@ -26,4 +27,13 @@ export class OffersPage extends MpPage { getDrawer = (): Cypress.Chainable => { return this.repository.getDrawer(); }; + + getSaveButtonSelector = (): string => { + return this.repository.getSaveButtonSelector(); + }; +} + +interface FindParams { + query: string; + expectedCount?: number; } diff --git a/cypress/support/pages/mp/offers/offers-repository.ts b/cypress/support/pages/mp/offers/offers-repository.ts index 9d183a46..eb6d2fc0 100644 --- a/cypress/support/pages/mp/offers/offers-repository.ts +++ b/cypress/support/pages/mp/offers/offers-repository.ts @@ -4,7 +4,8 @@ import { injectable } from 'inversify'; @injectable() @autoWired export class OffersRepository { - getFirstTableRow = (): Cypress.Chainable => cy.get('tbody > :nth-child(1)'); + getFirstTableRow = (): Cypress.Chainable => cy.get('tbody > :nth-child(1):visible'); getSearchSelector = (): string => '.spy-table-search-feature input[type="text"]'; + getSaveButtonSelector = (): string => 'button:contains("Save")'; getDrawer = (): Cypress.Chainable => cy.get('.spy-drawer-wrapper'); } diff --git a/cypress/support/pages/mp/products/products-page.ts b/cypress/support/pages/mp/products/products-page.ts index 77e90578..f450839e 100644 --- a/cypress/support/pages/mp/products/products-page.ts +++ b/cypress/support/pages/mp/products/products-page.ts @@ -1,7 +1,7 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { MpPage } from '../mp-page'; +import { MpPage } from '@pages/mp'; import { ProductsRepository } from './products-repository'; @injectable() @@ -11,14 +11,15 @@ export class ProductsPage extends MpPage { protected PAGE_URL = '/product-merchant-portal-gui/products'; - findProduct = (query: string): Cypress.Chainable => { + find = (params: FindParams): Cypress.Chainable => { const searchSelector = this.repository.getSearchSelector(); cy.get(searchSelector).clear(); - cy.get(searchSelector).type(query); + cy.get(searchSelector).type(params.query); - const interceptAlias = this.faker.string.uuid(); - cy.intercept('GET', '/product-merchant-portal-gui/products/table-data**').as(interceptAlias); - cy.wait(`@${interceptAlias}`).its('response.body.total').should('eq', 1); + this.interceptTable({ + url: '/product-merchant-portal-gui/products/table-data**', + expectedCount: params.expectedCount, + }); return this.repository.getFirstTableRow(); }; @@ -27,10 +28,20 @@ export class ProductsPage extends MpPage { const drawer = this.repository.getDrawer(); // Wait for the drawer to be visible - const interceptAlias = this.faker.string.uuid(); - cy.intercept('GET', '/product-merchant-portal-gui/products-concrete/table-data**').as(interceptAlias); - cy.wait(`@${interceptAlias}`).its('response.body.total').should('eq', 1); + this.interceptTable({ + url: '/product-merchant-portal-gui/products-concrete/table-data**', + expectedCount: 1, + }); return drawer; }; + + getSaveButtonSelector = (): string => { + return this.repository.getSaveButtonSelector(); + }; +} + +interface FindParams { + query: string; + expectedCount?: number; } diff --git a/cypress/support/pages/mp/products/products-repository.ts b/cypress/support/pages/mp/products/products-repository.ts index 7a96f5d8..6d52686c 100644 --- a/cypress/support/pages/mp/products/products-repository.ts +++ b/cypress/support/pages/mp/products/products-repository.ts @@ -4,7 +4,8 @@ import { injectable } from 'inversify'; @injectable() @autoWired export class ProductsRepository { - getFirstTableRow = (): Cypress.Chainable => cy.get('tbody > :nth-child(1)'); + getFirstTableRow = (): Cypress.Chainable => cy.get('tbody > :nth-child(1):visible'); getSearchSelector = (): string => '.spy-table-search-feature input[type="text"]'; + getSaveButtonSelector = (): string => 'button:contains("Save")'; getDrawer = (): Cypress.Chainable => cy.get('.spy-drawer-wrapper'); } diff --git a/cypress/support/pages/mp/profile/profile-page.ts b/cypress/support/pages/mp/profile/profile-page.ts index e905fe29..6718bac5 100644 --- a/cypress/support/pages/mp/profile/profile-page.ts +++ b/cypress/support/pages/mp/profile/profile-page.ts @@ -1,7 +1,7 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { MpPage } from '../mp-page'; +import { MpPage } from '@pages/mp'; import { ProfileRepository } from './profile-repository'; @injectable() @@ -11,11 +11,16 @@ export class ProfilePage extends MpPage { protected PAGE_URL = '/merchant-profile-merchant-portal-gui/profile'; - updateMerchantPhoneNumber = (phone?: string): void => { + updatePhone = (params?: UpdatePhoneParams): void => { this.repository .getPhoneNumberInput() .clear() - .type(phone ?? this.faker.phone.number()); + .type(params?.phone ?? this.faker.phone.number()); + this.repository.getProfileForm().submit(); }; } + +interface UpdatePhoneParams { + phone: string; +} diff --git a/cypress/support/pages/mp/sales/sales-orders-page.ts b/cypress/support/pages/mp/sales/sales-orders-page.ts index 65000cbf..a5a4a0f8 100644 --- a/cypress/support/pages/mp/sales/sales-orders-page.ts +++ b/cypress/support/pages/mp/sales/sales-orders-page.ts @@ -1,7 +1,7 @@ import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { MpPage } from '../mp-page'; +import { MpPage } from '@pages/mp'; import { SalesOrdersRepository } from './sales-orders-repository'; @injectable() @@ -11,20 +11,30 @@ export class SalesOrdersPage extends MpPage { protected PAGE_URL = '/sales-merchant-portal-gui/orders'; - findOrder = (query: string): Cypress.Chainable => { + find = (params: FindParams): Cypress.Chainable => { const searchSelector = this.repository.getSearchSelector(); cy.get(searchSelector).clear(); - cy.get(searchSelector).type(query); + cy.get(searchSelector).type(params.query); - const interceptAlias = this.faker.string.uuid(); - cy.intercept('GET', '/sales-merchant-portal-gui/orders/table-data**').as(interceptAlias); - cy.wait(`@${interceptAlias}`).its('response.body.total').should('eq', 1); + this.interceptTable({ + url: '/sales-merchant-portal-gui/orders/table-data**', + expectedCount: params.expectedCount, + }); return this.repository.getFirstTableRow(); }; - cancelOrder = (query: string): void => { - this.findOrder(query).click(); - this.repository.getDrawer().find('button:contains("Cancel")').click(); + cancel = (params: CancelParams): void => { + this.find({ query: params.query }).click(); + this.repository.getDrawer().find(this.repository.getCancelButtonSelector()).click(); }; } + +interface FindParams { + query: string; + expectedCount?: number; +} + +interface CancelParams { + query: string; +} diff --git a/cypress/support/pages/mp/sales/sales-orders-repository.ts b/cypress/support/pages/mp/sales/sales-orders-repository.ts index a1b7d66d..f62a3c64 100644 --- a/cypress/support/pages/mp/sales/sales-orders-repository.ts +++ b/cypress/support/pages/mp/sales/sales-orders-repository.ts @@ -4,7 +4,8 @@ import { injectable } from 'inversify'; @injectable() @autoWired export class SalesOrdersRepository { - getFirstTableRow = (): Cypress.Chainable => cy.get('tbody > :nth-child(1)'); + getFirstTableRow = (): Cypress.Chainable => cy.get('tbody > :nth-child(1):visible'); getSearchSelector = (): string => '.spy-table-search-feature input[type="text"]'; + getCancelButtonSelector = (): string => 'button:contains("Cancel")'; getDrawer = (): Cypress.Chainable => cy.get('.spy-drawer-wrapper'); } diff --git a/cypress/support/pages/yves/agent-login/agent-login-page.ts b/cypress/support/pages/yves/agent-login/agent-login-page.ts index b80e5869..9026afd8 100644 --- a/cypress/support/pages/yves/agent-login/agent-login-page.ts +++ b/cypress/support/pages/yves/agent-login/agent-login-page.ts @@ -1,7 +1,7 @@ import { REPOSITORIES, autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { YvesPage } from '../yves-page'; +import { YvesPage } from '@pages/yves'; import { AgentLoginRepository } from './agent-login-repository'; @injectable() @@ -11,9 +11,9 @@ export class AgentLoginPage extends YvesPage { protected PAGE_URL = '/agent/login'; - login = (username: string, password: string): void => { - this.repository.getLoginEmailInput().clear().type(username); - this.repository.getLoginPasswordInput().clear().type(password); + login = (params: LoginParams): void => { + this.repository.getLoginEmailInput().clear().type(params.username); + this.repository.getLoginPasswordInput().clear().type(params.password); this.repository.getLoginForm().submit(); }; @@ -22,3 +22,8 @@ export class AgentLoginPage extends YvesPage { return this.repository.getFailedAuthenticationText(); }; } + +interface LoginParams { + username: string; + password: string; +} diff --git a/cypress/support/pages/yves/cart/cart-page.ts b/cypress/support/pages/yves/cart/cart-page.ts index 1bb656df..b86a9811 100644 --- a/cypress/support/pages/yves/cart/cart-page.ts +++ b/cypress/support/pages/yves/cart/cart-page.ts @@ -1,7 +1,7 @@ import { REPOSITORIES, autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { YvesPage } from '../yves-page'; +import { YvesPage } from '@pages/yves'; import { CartRepository } from './cart-repository'; @injectable() @@ -11,25 +11,24 @@ export class CartPage extends YvesPage { protected PAGE_URL = '/cart'; - quickAddToCart = (sku: string, quantity?: number): void => { - this.repository.getQuickAddToCartSkuField().clear().type(sku); + quickAddToCart = (params: QuickAddToCartParams): void => { + this.repository.getQuickAddToCartSkuField().clear().type(params.sku); this.repository.getQuickAddToCartProductListField().click(); this.repository .getQuickAddToCartQuantityField() .clear() - .type(String(quantity ?? 1)); + .type(String(params?.quantity || 1)); this.repository.getQuickAddToCartSubmitButton().click(); - cy.contains('Items added successfully').should('exist'); }; startCheckout = (): void => { this.repository.getCheckoutButton().click(); }; - removeProduct = (sku: string): void => { - const form = this.repository.findCartItemRemovalForm(sku); + removeProduct = (params: RemoveProductParams): void => { + const form = this.repository.findCartItemRemovalForm(params.sku); if (!form) { return; @@ -38,15 +37,15 @@ export class CartPage extends YvesPage { form.submit(); }; - changeQuantity = (sku: string, newQuantity: number): void => { - const form = this.repository.findCartItemChangeQuantityForm(sku); - const input = this.repository.getCartItemChangeQuantityField(sku); + changeQuantity = (params: ChangeQuantityParams): void => { + const form = this.repository.findCartItemChangeQuantityForm(params.sku); + const input = this.repository.getCartItemChangeQuantityField(params.sku); if (!form || !input) { return; } - input.type('{selectall}').type(String(newQuantity)); + input.type('{selectall}').type(String(params.quantity)); form.submit(); }; @@ -58,3 +57,17 @@ export class CartPage extends YvesPage { } }; } + +interface QuickAddToCartParams { + sku: string; + quantity?: number; +} + +interface RemoveProductParams { + sku: string; +} + +interface ChangeQuantityParams { + sku: string; + quantity: number; +} diff --git a/cypress/support/pages/yves/catalog/catalog-page.ts b/cypress/support/pages/yves/catalog/catalog-page.ts index 7d0d220a..acada3db 100644 --- a/cypress/support/pages/yves/catalog/catalog-page.ts +++ b/cypress/support/pages/yves/catalog/catalog-page.ts @@ -1,7 +1,7 @@ import { REPOSITORIES, autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { YvesPage } from '../yves-page'; +import { YvesPage } from '@pages/yves'; import { CatalogRepository } from './catalog-repository'; @injectable() @@ -11,31 +11,12 @@ export class CatalogPage extends YvesPage { protected PAGE_URL = '/search'; - openFirstSuggestedProduct = (query: string): void => { - this.repository.getSearchInput().clear().type(query); + search = (params: SearchParams): void => { + this.repository.getSearchInput().clear().type(params.query); this.repository.getFirstSuggestedProduct().click(); }; +} - selectSoldByProductOffer = (productOfferReference: string): void => { - this.repository.getSoldByProductOfferRadios().check(productOfferReference, { force: true }); - }; - - createMerchantRelationRequest = (productOfferReference: string): void => { - this.repository - .getSoldByProductOffers() - .children() - .each(($productOffer) => { - if ($productOffer.find('input[type="radio"]').attr('value') === productOfferReference) { - cy.wrap($productOffer).find(this.repository.getMerchantRelationRequestLinkAttribute()).click(); - } - }); - }; - - getSoldByProductOffers = (): Cypress.Chainable => { - return this.repository.getSoldByProductOffers(); - }; - - getMerchantRelationRequestLinkAttribute = (): string => { - return this.repository.getMerchantRelationRequestLinkAttribute(); - }; +interface SearchParams { + query: string; } diff --git a/cypress/support/pages/yves/catalog/catalog-repository.ts b/cypress/support/pages/yves/catalog/catalog-repository.ts index 33c1c8b2..30e45a43 100644 --- a/cypress/support/pages/yves/catalog/catalog-repository.ts +++ b/cypress/support/pages/yves/catalog/catalog-repository.ts @@ -1,7 +1,4 @@ export interface CatalogRepository { getSearchInput(): Cypress.Chainable; getFirstSuggestedProduct(): Cypress.Chainable; - getSoldByProductOffers(): Cypress.Chainable; - getSoldByProductOfferRadios(): Cypress.Chainable; - getMerchantRelationRequestLinkAttribute(): string; } diff --git a/cypress/support/pages/yves/catalog/repositories/suite-catalog-repository.ts b/cypress/support/pages/yves/catalog/repositories/suite-catalog-repository.ts index 60ca83dc..bfb403a8 100644 --- a/cypress/support/pages/yves/catalog/repositories/suite-catalog-repository.ts +++ b/cypress/support/pages/yves/catalog/repositories/suite-catalog-repository.ts @@ -6,8 +6,4 @@ import * as Cypress from 'cypress'; export class SuiteCatalogRepository implements CatalogRepository { getSearchInput = (): Cypress.Chainable => cy.get('[data-qa="component search-form"] input').first(); getFirstSuggestedProduct = (): Cypress.Chainable => cy.get('[data-qa="component suggestion-product"] a').first(); - getSoldByProductOffers = (): Cypress.Chainable => cy.get('[data-qa="component merchant-product-offer-item"]'); - getSoldByProductOfferRadios = (): Cypress.Chainable => - cy.get('[data-qa="component merchant-product-offer-item"] input[type="radio"]'); - getMerchantRelationRequestLinkAttribute = (): string => '[data-qa="merchant-relation-request-create-link"]'; } diff --git a/cypress/support/pages/yves/checkout/address/checkout-address-page.ts b/cypress/support/pages/yves/checkout/address/checkout-address-page.ts index 3c65e846..b21064af 100644 --- a/cypress/support/pages/yves/checkout/address/checkout-address-page.ts +++ b/cypress/support/pages/yves/checkout/address/checkout-address-page.ts @@ -1,19 +1,8 @@ import { REPOSITORIES, autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { YvesPage } from '../../yves-page'; +import { YvesPage } from '@pages/yves'; import { CheckoutAddressRepository } from './checkout-address-repository'; -interface Address { - firstName: string; - lastName: string; - address1: string; - address2: string; - zipCode: string; - city: string; - company: string; - phone: string; -} - @injectable() @autoWired export class CheckoutAddressPage extends YvesPage { @@ -21,9 +10,9 @@ export class CheckoutAddressPage extends YvesPage { protected PAGE_URL = '/checkout/address'; - fillShippingAddress = (idCustomerAddress?: number): void => { - if (idCustomerAddress) { - this.repository.getSelectShippingAddressField().select(idCustomerAddress.toString()); + fillShippingAddress = (params?: FillShippingAddressParams): void => { + if (params?.idCustomerAddress) { + this.repository.getSelectShippingAddressField().select(params.idCustomerAddress.toString()); this.repository.getShippingAddressBillingSameAsShippingCheckbox().check({ force: true }); this.repository.getNextButton().click(); @@ -50,7 +39,7 @@ export class CheckoutAddressPage extends YvesPage { this.repository.getNextButton().click(); }; - fillMultiShippingAddress = (idCustomerAddress?: number): void => { + fillMultiShippingAddress = (params?: FillShippingAddressParams): void => { this.repository.getMultiShipmentTriggerButton().click(); this.repository @@ -61,10 +50,10 @@ export class CheckoutAddressPage extends YvesPage { this.repository.getMultiShipmentAddressItemDeliveryRadio($addressItem, index).click({ force: true }); - if (idCustomerAddress) { + if (params?.idCustomerAddress) { this.repository .getMultiShipmentAddressItemAddressField($addressItem, index) - .select(idCustomerAddress.toString(), { force: true }); + .select(params.idCustomerAddress.toString(), { force: true }); return; } @@ -145,3 +134,18 @@ export class CheckoutAddressPage extends YvesPage { }; }; } + +interface FillShippingAddressParams { + idCustomerAddress?: number; +} + +interface Address { + firstName: string; + lastName: string; + address1: string; + address2: string; + zipCode: string; + city: string; + company: string; + phone: string; +} diff --git a/cypress/support/pages/yves/checkout/customer/checkout-customer-page.ts b/cypress/support/pages/yves/checkout/customer/checkout-customer-page.ts index 5e846a06..29caff8e 100644 --- a/cypress/support/pages/yves/checkout/customer/checkout-customer-page.ts +++ b/cypress/support/pages/yves/checkout/customer/checkout-customer-page.ts @@ -1,7 +1,7 @@ import { REPOSITORIES, autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { YvesPage } from '../../yves-page'; +import { YvesPage } from '@pages/yves'; import { CheckoutCustomerRepository } from './checkout-customer-repository'; @injectable() diff --git a/cypress/support/pages/yves/checkout/payment/checkout-payment-page.ts b/cypress/support/pages/yves/checkout/payment/checkout-payment-page.ts index 2a6f4dc4..e0d2d545 100644 --- a/cypress/support/pages/yves/checkout/payment/checkout-payment-page.ts +++ b/cypress/support/pages/yves/checkout/payment/checkout-payment-page.ts @@ -1,7 +1,7 @@ import { REPOSITORIES, autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { YvesPage } from '../../yves-page'; +import { YvesPage } from '@pages/yves'; import { CheckoutPaymentRepository } from './checkout-payment-repository'; @injectable() diff --git a/cypress/support/pages/yves/checkout/shipment/checkout-shipment-page.ts b/cypress/support/pages/yves/checkout/shipment/checkout-shipment-page.ts index 90114167..5d160339 100644 --- a/cypress/support/pages/yves/checkout/shipment/checkout-shipment-page.ts +++ b/cypress/support/pages/yves/checkout/shipment/checkout-shipment-page.ts @@ -1,7 +1,7 @@ import { REPOSITORIES, autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { YvesPage } from '../../yves-page'; +import { YvesPage } from '@pages/yves'; import { CheckoutShipmentRepository } from './checkout-shipment-repository'; @injectable() diff --git a/cypress/support/pages/yves/checkout/summary/checkout-summary-page.ts b/cypress/support/pages/yves/checkout/summary/checkout-summary-page.ts index 3ba76175..65e8933e 100644 --- a/cypress/support/pages/yves/checkout/summary/checkout-summary-page.ts +++ b/cypress/support/pages/yves/checkout/summary/checkout-summary-page.ts @@ -1,7 +1,7 @@ import { REPOSITORIES, autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { YvesPage } from '../../yves-page'; +import { YvesPage } from '@pages/yves'; import { CheckoutSummaryRepository } from './checkout-summary-repository'; @injectable() diff --git a/cypress/support/pages/yves/comment/cart/comment-cart-page.ts b/cypress/support/pages/yves/comment/cart/comment-cart-page.ts index ad887382..4a5b7aa2 100644 --- a/cypress/support/pages/yves/comment/cart/comment-cart-page.ts +++ b/cypress/support/pages/yves/comment/cart/comment-cart-page.ts @@ -1,7 +1,7 @@ import { REPOSITORIES, autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { YvesPage } from '../../yves-page'; +import { YvesPage } from '@pages/yves'; import { CommentCartRepository } from './comment-cart-repository'; @injectable() @@ -11,34 +11,34 @@ export class CommentCartPage extends YvesPage { protected PAGE_URL = '/cart'; - addComment = (commentMessage: string): void => { - this.repository.getAddCommentForm().last().find('textarea').clear().type(commentMessage); + add = (params: AddParams): void => { + this.repository.getAddCommentForm().last().find('textarea').clear().type(params.message); this.repository.getAddCommentForm().last().find(this.repository.getAddCommentButtonSelector()).click(); }; - updateFirstComment = (commentMessage: string): void => { - const textarea = this.repository.getFirstCommentTextarea(); - textarea.clear().type(commentMessage); - - this.getCommentThreadListSection().first().find(this.repository.getUpdateCommentButtonSelector()).click(); - }; - - updateCommentByCommentText = (initialCommentMessage: string, newCommentMessage: string): void => { - const textarea = this.repository.getCommentTextareaByCommentText(initialCommentMessage); + update = (params: UpdateParams): void => { + const textarea = this.repository.getCommentTextareaByCommentText(params.oldMessage); - textarea.clear().type(newCommentMessage); + textarea.clear().type(params.newMessage); textarea.parent().find(this.repository.getUpdateCommentButtonSelector()).click(); }; - removeCommentByCommentText = (commentMessage: string): void => { + remove = (params: RemoveParams): void => { this.repository - .getCommentTextareaByCommentText(commentMessage) + .getCommentTextareaByCommentText(params.message) .parent() .find(this.repository.getRemoveCommentButtonSelector()) .click(); }; - removeFirstComment = (): void => { + updateFirst = (params: UpdateFirstParams): void => { + const textarea = this.repository.getFirstCommentTextarea(); + textarea.clear().type(params.message); + + this.getCommentThreadListSection().first().find(this.repository.getUpdateCommentButtonSelector()).click(); + }; + + removeFirst = (): void => { this.getCommentThreadListSection().find(this.repository.getRemoveCommentButtonSelector()).click(); }; @@ -46,3 +46,20 @@ export class CommentCartPage extends YvesPage { return this.repository.getCommentThreadListSection(); }; } + +interface AddParams { + message: string; +} + +interface UpdateParams { + oldMessage: string; + newMessage: string; +} + +interface RemoveParams { + message: string; +} + +interface UpdateFirstParams { + message: string; +} diff --git a/cypress/support/pages/yves/company/merchant-relation-request/create/merchant-relation-request-create-page.ts b/cypress/support/pages/yves/company/merchant-relation-request/create/merchant-relation-request-create-page.ts index 2affb725..66a47d60 100644 --- a/cypress/support/pages/yves/company/merchant-relation-request/create/merchant-relation-request-create-page.ts +++ b/cypress/support/pages/yves/company/merchant-relation-request/create/merchant-relation-request-create-page.ts @@ -1,15 +1,8 @@ import { REPOSITORIES, autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { YvesPage } from '../../../yves-page'; +import { YvesPage } from '@pages/yves'; import { MerchantRelationRequestCreateRepository } from './merchant-relation-request-create-repository'; -interface CreateMerchantRelationRequestParams { - merchantReference?: string; - ownerBusinessUnitId: number; - businessUnitIds: number[]; - messageToMerchant?: string; -} - @injectable() @autoWired export class MerchantRelationRequestCreatePage extends YvesPage { @@ -18,7 +11,7 @@ export class MerchantRelationRequestCreatePage extends YvesPage { protected PAGE_URL = '/company/merchant-relation-request/create'; - create = (params: CreateMerchantRelationRequestParams): void => { + create = (params: CreateParams): void => { if (params.merchantReference) { this.repository.getMerchantSelect().select(params.merchantReference); } @@ -36,3 +29,10 @@ export class MerchantRelationRequestCreatePage extends YvesPage { this.repository.getSubmitButton().click(); }; } + +interface CreateParams { + merchantReference?: string; + ownerBusinessUnitId: number; + businessUnitIds: number[]; + messageToMerchant?: string; +} diff --git a/cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-page.ts b/cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-page.ts index 6267e1fe..c6e8ad2a 100644 --- a/cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-page.ts +++ b/cypress/support/pages/yves/company/merchant-relation-request/details/merchant-relation-request-details-page.ts @@ -1,6 +1,6 @@ import { REPOSITORIES, autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { YvesPage } from '../../../yves-page'; +import { YvesPage } from '@pages/yves'; import { MerchantRelationRequestDetailsRepository } from './merchant-relation-request-details-repository'; @injectable() diff --git a/cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-page.ts b/cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-page.ts index 116894e4..b264582e 100644 --- a/cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-page.ts +++ b/cypress/support/pages/yves/company/merchant-relation-request/index/merchant-relation-request-index-page.ts @@ -1,14 +1,8 @@ import { REPOSITORIES, autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { YvesPage } from '../../../yves-page'; +import { YvesPage } from '@pages/yves'; import { MerchantRelationRequestIndexRepository } from './merchant-relation-request-index-repository'; -interface MerchantRelationRequestFilterParams { - idMerchant?: number; - idBusinessUnitOwner?: number; - status?: string; -} - @injectable() @autoWired export class MerchantRelationRequestIndexPage extends YvesPage { @@ -17,11 +11,11 @@ export class MerchantRelationRequestIndexPage extends YvesPage { protected PAGE_URL = '/company/merchant-relation-request'; - createMerchantRelationRequest = (): void => { + create = (): void => { this.repository.getMerchantRelationRequestButton().click(); }; - filterRequests = (params: MerchantRelationRequestFilterParams): void => { + filterRequests = (params: FilterRequestsParams): void => { if (params.idMerchant) { this.repository.getFilterMerchantSelect().select(params.idMerchant.toString()); } @@ -45,3 +39,9 @@ export class MerchantRelationRequestIndexPage extends YvesPage { return this.repository.getFirstTableRaw().find(this.repository.getViewLinkSelector()).click(); }; } + +interface FilterRequestsParams { + idMerchant?: number; + idBusinessUnitOwner?: number; + status?: string; +} diff --git a/cypress/support/pages/yves/company/user/select/company-user-select-page.ts b/cypress/support/pages/yves/company/user/select/company-user-select-page.ts index c4272217..84dd306b 100644 --- a/cypress/support/pages/yves/company/user/select/company-user-select-page.ts +++ b/cypress/support/pages/yves/company/user/select/company-user-select-page.ts @@ -1,6 +1,6 @@ import { REPOSITORIES, autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { YvesPage } from '../../../yves-page'; +import { YvesPage } from '@pages/yves'; import { CompanyUserSelectRepository } from './company-user-select-repository'; @injectable() @@ -10,8 +10,12 @@ export class CompanyUserSelectPage extends YvesPage { protected PAGE_URL = '/company/user/select'; - selectBusinessUnit = (idCompanyUser: number): void => { - this.repository.getBusinessUnitSelect().select(idCompanyUser.toString()); + selectBusinessUnit = (params: SelectBusinessUnitParams): void => { + this.repository.getBusinessUnitSelect().select(params.idCompanyUser.toString()); this.repository.getSubmitButton().click(); }; } + +interface SelectBusinessUnitParams { + idCompanyUser: number; +} diff --git a/cypress/support/pages/yves/index.ts b/cypress/support/pages/yves/index.ts index 3b6f7368..c12db616 100644 --- a/cypress/support/pages/yves/index.ts +++ b/cypress/support/pages/yves/index.ts @@ -1,3 +1,4 @@ +export * from './yves-page'; export * from './cart/cart-page'; export * from './agent-login/agent-login-page'; export * from './checkout/address/checkout-address-page'; @@ -14,3 +15,4 @@ export * from './company/merchant-relation-request/create/merchant-relation-requ export * from './company/merchant-relation-request/details/merchant-relation-request-details-page'; export * from './company/merchant-relation-request/index/merchant-relation-request-index-page'; export * from './merchant/merchant-page'; +export * from './product/product-page'; diff --git a/cypress/support/pages/yves/login/login-page.ts b/cypress/support/pages/yves/login/login-page.ts index 85db593f..df7eed29 100644 --- a/cypress/support/pages/yves/login/login-page.ts +++ b/cypress/support/pages/yves/login/login-page.ts @@ -1,7 +1,7 @@ import { REPOSITORIES, autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { YvesPage } from '../yves-page'; +import { YvesPage } from '@pages/yves'; import { LoginRepository } from './login-repository'; @injectable() @@ -11,9 +11,9 @@ export class LoginPage extends YvesPage { protected PAGE_URL = '/login'; - login = (email: string, password: string): void => { - this.repository.getLoginEmailInput().clear().type(email); - this.repository.getLoginPasswordInput().clear().type(password); + login = (params: LoginParams): void => { + this.repository.getLoginEmailInput().clear().type(params.email); + this.repository.getLoginPasswordInput().clear().type(params.password); this.repository.getLoginForm().submit(); }; @@ -22,3 +22,8 @@ export class LoginPage extends YvesPage { return this.repository.getFailedAuthenticationText(); }; } + +interface LoginParams { + email: string; + password: string; +} diff --git a/cypress/support/pages/yves/merchant/merchant-page.ts b/cypress/support/pages/yves/merchant/merchant-page.ts index c26133bc..2fd6401d 100644 --- a/cypress/support/pages/yves/merchant/merchant-page.ts +++ b/cypress/support/pages/yves/merchant/merchant-page.ts @@ -1,7 +1,7 @@ import { REPOSITORIES, autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { YvesPage } from '../yves-page'; +import { YvesPage } from '@pages/yves'; import { MerchantRepository } from './merchant-repository'; @injectable() diff --git a/cypress/support/pages/yves/multi-cart/multi-cart-page.ts b/cypress/support/pages/yves/multi-cart/multi-cart-page.ts index 4ea74f3c..a41018be 100644 --- a/cypress/support/pages/yves/multi-cart/multi-cart-page.ts +++ b/cypress/support/pages/yves/multi-cart/multi-cart-page.ts @@ -1,7 +1,7 @@ import { REPOSITORIES, autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -import { YvesPage } from '../yves-page'; +import { YvesPage } from '@pages/yves'; import { MultiCartRepository } from './multi-cart-repository'; @injectable() @@ -11,9 +11,9 @@ export class MultiCartPage extends YvesPage { protected PAGE_URL = '/multi-cart'; - createCart = (name?: string): void => { + createCart = (params?: CreateCartParams): void => { cy.visit(`${this.PAGE_URL}/create`); - const cartName = name ?? `Cart #${this.faker.string.uuid()}`; + const cartName = params?.name ?? `Cart #${this.faker.string.uuid()}`; this.repository.getCreateCartNameInput().clear().type(cartName); this.repository.getCreateCartForm().submit(); @@ -21,7 +21,15 @@ export class MultiCartPage extends YvesPage { cy.contains(`Cart '${cartName}' was created successfully`).should('exist'); }; - selectCart = (name: string): void => { - this.repository.getQuoteTable().contains(name).click(); + selectCart = (params: SelectCartParams): void => { + this.repository.getQuoteTable().contains(params.name).click(); }; } + +interface CreateCartParams { + name?: string; +} + +interface SelectCartParams { + name: string; +} diff --git a/cypress/support/pages/yves/product/product-page.ts b/cypress/support/pages/yves/product/product-page.ts new file mode 100644 index 00000000..5dea5c82 --- /dev/null +++ b/cypress/support/pages/yves/product/product-page.ts @@ -0,0 +1,48 @@ +import { REPOSITORIES, autoWired } from '@utils'; +import { inject, injectable } from 'inversify'; + +import { YvesPage } from '@pages/yves'; +import { ProductRepository } from './product-repository'; + +@injectable() +@autoWired +export class ProductPage extends YvesPage { + @inject(REPOSITORIES.ProductRepository) private repository: ProductRepository; + + protected PAGE_URL = ''; + + selectSoldByProductOffer = (params: SelectSoldByProductOfferParams): void => { + this.repository.getSoldByProductOfferRadios().check(params.productOfferReference, { force: true }); + }; + + createMerchantRelationRequest = (params: CreateMerchantRelationRequestParams): void => { + this.repository + .getSoldByProductOffers() + .children() + .each(($productOffer) => { + if ($productOffer.find('input[type="radio"]').attr('value') === params.productOfferReference) { + cy.wrap($productOffer).find(this.repository.getMerchantRelationRequestLinkAttribute()).click(); + } + }); + }; + + getSoldByProductOffers = (): Cypress.Chainable => { + return this.repository.getSoldByProductOffers(); + }; + + getMerchantRelationRequestLinkAttribute = (): string => { + return this.repository.getMerchantRelationRequestLinkAttribute(); + }; + + getInputRadioSelector = (): string => { + return this.repository.getInputRadioSelector(); + }; +} + +interface SelectSoldByProductOfferParams { + productOfferReference: string; +} + +interface CreateMerchantRelationRequestParams { + productOfferReference: string; +} diff --git a/cypress/support/pages/yves/product/product-repository.ts b/cypress/support/pages/yves/product/product-repository.ts new file mode 100644 index 00000000..845ca415 --- /dev/null +++ b/cypress/support/pages/yves/product/product-repository.ts @@ -0,0 +1,6 @@ +export interface ProductRepository { + getSoldByProductOffers(): Cypress.Chainable; + getSoldByProductOfferRadios(): Cypress.Chainable; + getMerchantRelationRequestLinkAttribute(): string; + getInputRadioSelector(): string; +} diff --git a/cypress/support/pages/yves/product/repositories/suite-product-repository.ts b/cypress/support/pages/yves/product/repositories/suite-product-repository.ts new file mode 100644 index 00000000..98c98f16 --- /dev/null +++ b/cypress/support/pages/yves/product/repositories/suite-product-repository.ts @@ -0,0 +1,12 @@ +import { injectable } from 'inversify'; +import { ProductRepository } from '../product-repository'; +import * as Cypress from 'cypress'; + +@injectable() +export class SuiteProductRepository implements ProductRepository { + getSoldByProductOffers = (): Cypress.Chainable => cy.get('[data-qa="component merchant-product-offer-item"]'); + getSoldByProductOfferRadios = (): Cypress.Chainable => + cy.get('[data-qa="component merchant-product-offer-item"] input[type="radio"]'); + getMerchantRelationRequestLinkAttribute = (): string => '[data-qa="merchant-relation-request-create-link"]'; + getInputRadioSelector = (): string => 'input[type="radio"]'; +} diff --git a/cypress/support/scenarios/backoffice/user-login-scenario.ts b/cypress/support/scenarios/backoffice/user-login-scenario.ts index c85bf869..4a0b0d86 100644 --- a/cypress/support/scenarios/backoffice/user-login-scenario.ts +++ b/cypress/support/scenarios/backoffice/user-login-scenario.ts @@ -2,22 +2,20 @@ import { LoginPage } from '@pages/backoffice'; import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -interface UserLoginExecuteParams { - username: string; - password: string; -} - @injectable() @autoWired export class UserLoginScenario { @inject(LoginPage) private loginPage: LoginPage; - execute = (params: UserLoginExecuteParams): void => { - const { username, password } = params; - - cy.session([username, password], () => { + execute = (params: ExecuteParams): void => { + cy.session([params.username, params.password], () => { this.loginPage.visit(); - this.loginPage.login(username, password); + this.loginPage.login(params); }); }; } + +interface ExecuteParams { + username: string; + password: string; +} diff --git a/cypress/support/scenarios/mp/impersonate-as-merchant-user-scenario.ts b/cypress/support/scenarios/mp/impersonate-as-merchant-user-scenario.ts index 6b482568..afa798a7 100644 --- a/cypress/support/scenarios/mp/impersonate-as-merchant-user-scenario.ts +++ b/cypress/support/scenarios/mp/impersonate-as-merchant-user-scenario.ts @@ -8,11 +8,17 @@ export class ImpersonateAsMerchantUserScenario { @inject(AgentLoginPage) private agentLoginPage: AgentLoginPage; @inject(AgentDashboardPage) private mpAgentDashboardPage: AgentDashboardPage; - execute = (username: string, password: string, merchantUsername: string): void => { + execute = (params: ExecuteParams): void => { this.agentLoginPage.visit(); - this.agentLoginPage.login(username, password); + this.agentLoginPage.login({ username: params.username, password: params.password }); this.mpAgentDashboardPage.visit(); - this.mpAgentDashboardPage.assistMerchantUser(merchantUsername); + this.mpAgentDashboardPage.assist({ query: params.query }); }; } + +interface ExecuteParams { + username: string; + password: string; + query: string; +} diff --git a/cypress/support/scenarios/mp/merchant-agent-login-user-scenario.ts b/cypress/support/scenarios/mp/merchant-agent-login-user-scenario.ts index f132428f..8ba01a28 100644 --- a/cypress/support/scenarios/mp/merchant-agent-login-user-scenario.ts +++ b/cypress/support/scenarios/mp/merchant-agent-login-user-scenario.ts @@ -2,22 +2,20 @@ import { AgentLoginPage } from '@pages/mp'; import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -interface MerchantAgentLoginExecuteParams { - username: string; - password: string; -} - @injectable() @autoWired export class MerchantAgentLoginUserScenario { @inject(AgentLoginPage) private agentLoginPage: AgentLoginPage; - execute = (params: MerchantAgentLoginExecuteParams): void => { - const { username, password } = params; - - cy.session([username, password], () => { + execute = (params: ExecuteParams): void => { + cy.session([params.username, params.password], () => { this.agentLoginPage.visit(); - this.agentLoginPage.login(username, password); + this.agentLoginPage.login(params); }); }; } + +interface ExecuteParams { + username: string; + password: string; +} diff --git a/cypress/support/scenarios/mp/merchant-user-login-scenario.ts b/cypress/support/scenarios/mp/merchant-user-login-scenario.ts index 5eda0317..cf717c8b 100644 --- a/cypress/support/scenarios/mp/merchant-user-login-scenario.ts +++ b/cypress/support/scenarios/mp/merchant-user-login-scenario.ts @@ -2,20 +2,20 @@ import { LoginPage } from '@pages/mp'; import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -interface MerchantUserLoginExecuteParams { - username: string; - password: string; -} - @injectable() @autoWired export class MerchantUserLoginScenario { @inject(LoginPage) private loginPage: LoginPage; - execute = (params: MerchantUserLoginExecuteParams): void => { + execute = (params: ExecuteParams): void => { cy.session([params.username, params.password], () => { this.loginPage.visit(); - this.loginPage.login(params.username, params.password); + this.loginPage.login(params); }); }; } + +interface ExecuteParams { + username: string; + password: string; +} diff --git a/cypress/support/scenarios/yves/agent-login-scenario.ts b/cypress/support/scenarios/yves/agent-login-scenario.ts index 1e5bdc62..4c30f94b 100644 --- a/cypress/support/scenarios/yves/agent-login-scenario.ts +++ b/cypress/support/scenarios/yves/agent-login-scenario.ts @@ -7,10 +7,15 @@ import { inject, injectable } from 'inversify'; export class AgentLoginScenario { @inject(AgentLoginPage) private loginPage: AgentLoginPage; - execute = (username: string, password: string): void => { - cy.session([username, password], () => { + execute = (params: ExecuteParams): void => { + cy.session([params.username, params.password], () => { this.loginPage.visit(); - this.loginPage.login(username, password); + this.loginPage.login(params); }); }; } + +interface ExecuteParams { + username: string; + password: string; +} diff --git a/cypress/support/scenarios/yves/checkout-mp-scenario.ts b/cypress/support/scenarios/yves/checkout-mp-scenario.ts index eb74c40a..28131de1 100644 --- a/cypress/support/scenarios/yves/checkout-mp-scenario.ts +++ b/cypress/support/scenarios/yves/checkout-mp-scenario.ts @@ -9,11 +9,6 @@ import { import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -interface CheckoutMpExecuteParams { - isGuest: boolean; - isMultiShipment?: boolean; -} - @injectable() @autoWired export class CheckoutMpScenario { @@ -24,17 +19,15 @@ export class CheckoutMpScenario { @inject(CheckoutPaymentPage) private checkoutPaymentPage: CheckoutPaymentPage; @inject(CheckoutSummaryPage) private checkoutSummaryPage: CheckoutSummaryPage; - execute = (params: CheckoutMpExecuteParams): void => { - const { isGuest, isMultiShipment } = params; - + execute = (params: ExecuteParams): void => { this.cartPage.visit(); this.cartPage.startCheckout(); - if (isGuest) { + if (params?.isGuest) { this.checkoutCustomerPage.checkoutAsGuest(); } - this.fillShippingAddress(isMultiShipment); + this.fillShippingAddress(params?.isMultiShipment); this.checkoutShipmentPage.setStandardShippingMethod(); this.checkoutPaymentPage.setDummyMarketplacePaymentMethod(); this.checkoutSummaryPage.placeOrder(); @@ -52,3 +45,8 @@ export class CheckoutMpScenario { this.checkoutAddressPage.fillShippingAddress(); }; } + +interface ExecuteParams { + isGuest?: boolean; + isMultiShipment?: boolean; +} diff --git a/cypress/support/scenarios/yves/checkout-scenario.ts b/cypress/support/scenarios/yves/checkout-scenario.ts index e9f1419a..cbd74586 100644 --- a/cypress/support/scenarios/yves/checkout-scenario.ts +++ b/cypress/support/scenarios/yves/checkout-scenario.ts @@ -9,12 +9,6 @@ import { import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -interface CheckoutExecuteParams { - isGuest: boolean; - isMultiShipment?: boolean; - idCustomerAddress?: number; -} - @injectable() @autoWired export class CheckoutScenario { @@ -25,17 +19,15 @@ export class CheckoutScenario { @inject(CheckoutPaymentPage) private checkoutPaymentPage: CheckoutPaymentPage; @inject(CheckoutSummaryPage) private checkoutSummaryPage: CheckoutSummaryPage; - execute = (params: CheckoutExecuteParams): void => { - const { isGuest, isMultiShipment, idCustomerAddress } = params; - + execute = (params?: ExecuteParams): void => { this.cartPage.visit(); this.cartPage.startCheckout(); - if (isGuest) { + if (params?.isGuest) { this.checkoutCustomerPage.checkoutAsGuest(); } - this.fillShippingAddress(isMultiShipment, idCustomerAddress); + this.fillShippingAddress(params); this.checkoutShipmentPage.setStandardShippingMethod(); this.checkoutPaymentPage.setDummyPaymentMethod(); this.checkoutSummaryPage.placeOrder(); @@ -43,13 +35,21 @@ export class CheckoutScenario { cy.runCliCommands(['console oms:check-condition', 'console oms:check-timeout']); }; - private fillShippingAddress = (isMultiShipment = false, idCustomerAddress?: number): void => { - if (isMultiShipment) { - this.checkoutAddressPage.fillMultiShippingAddress(idCustomerAddress); + private fillShippingAddress = (params?: ExecuteParams): void => { + const fillShippingAddressParams = { idCustomerAddress: params?.idCustomerAddress }; + + if (params?.isMultiShipment) { + this.checkoutAddressPage.fillMultiShippingAddress(fillShippingAddressParams); return; } - this.checkoutAddressPage.fillShippingAddress(idCustomerAddress); + this.checkoutAddressPage.fillShippingAddress(fillShippingAddressParams); }; } + +interface ExecuteParams { + isGuest?: boolean; + isMultiShipment?: boolean; + idCustomerAddress?: number; +} diff --git a/cypress/support/scenarios/yves/customer-login-scenario.ts b/cypress/support/scenarios/yves/customer-login-scenario.ts index 454159ea..47422ee3 100644 --- a/cypress/support/scenarios/yves/customer-login-scenario.ts +++ b/cypress/support/scenarios/yves/customer-login-scenario.ts @@ -2,22 +2,20 @@ import { LoginPage } from '@pages/yves'; import { autoWired } from '@utils'; import { inject, injectable } from 'inversify'; -interface CustomerLoginExecuteParams { - email: string; - password: string; -} - @injectable() @autoWired export class CustomerLoginScenario { @inject(LoginPage) private loginPage: LoginPage; - execute = (params: CustomerLoginExecuteParams): void => { - const { email, password } = params; - - cy.session([email, password], () => { + execute = (params: ExecuteParams): void => { + cy.session([params.email, params.password], () => { this.loginPage.visit(); - this.loginPage.login(email, password); + this.loginPage.login(params); }); }; } + +interface ExecuteParams { + email: string; + password: string; +} diff --git a/cypress/support/utils/inversify/inversify.config.ts b/cypress/support/utils/inversify/inversify.config.ts index 24283ad0..c02f9166 100644 --- a/cypress/support/utils/inversify/inversify.config.ts +++ b/cypress/support/utils/inversify/inversify.config.ts @@ -23,6 +23,7 @@ import { SuiteMerchantRelationRequestCreateRepository } from '../../pages/yves/c import { SuiteMerchantRelationRequestDetailsRepository } from '../../pages/yves/company/merchant-relation-request/details/repositories/suite-merchant-relation-request-details-repository'; import { SuiteMerchantRepository } from '../../pages/yves/merchant/repositories/suite-merchant-repository'; import { SuiteMerchantRelationRequestIndexRepository } from '../../pages/yves/company/merchant-relation-request/index/repositories/suite-merchant-relation-request-index-repository'; +import { SuiteProductRepository } from '../../pages/yves/product/repositories/suite-product-repository'; type BindingsMap = { [K in REPOSITORIES]?: interfaces.Newable }; @@ -38,6 +39,7 @@ const suiteMappings: BindingsMap = { [REPOSITORIES.CheckoutSummaryRepository]: SuiteCheckoutSummaryRepository, [REPOSITORIES.AgentLoginRepository]: SuiteAgentLoginRepository, [REPOSITORIES.CatalogRepository]: SuiteCatalogRepository, + [REPOSITORIES.ProductRepository]: SuiteProductRepository, [REPOSITORIES.CompanyUserSelectRepository]: SuiteCompanyUserSelectRepository, [REPOSITORIES.MerchantRelationRequestCreateRepository]: SuiteMerchantRelationRequestCreateRepository, [REPOSITORIES.MerchantRelationRequestDetailsRepository]: SuiteMerchantRelationRequestDetailsRepository, diff --git a/cypress/support/utils/inversify/types.ts b/cypress/support/utils/inversify/types.ts index 005096d0..6123233a 100644 --- a/cypress/support/utils/inversify/types.ts +++ b/cypress/support/utils/inversify/types.ts @@ -10,6 +10,7 @@ export const enum REPOSITORIES { CheckoutSummaryRepository = 'CheckoutSummaryRepository', AgentLoginRepository = 'AgentLoginRepository', CatalogRepository = 'CatalogRepository', + ProductRepository = 'ProductRepository', CompanyUserSelectRepository = 'CompanyUserSelectRepository', MerchantRelationRequestCreateRepository = 'MerchantRelationRequestCreateRepository', MerchantRelationRequestDetailsRepository = 'MerchantRelationRequestDetailsRepository', From 23ade3e6f10494a2cd0377fa95aa7bfc7802577f Mon Sep 17 00:00:00 2001 From: Dmytro Asieiev Date: Mon, 25 Mar 2024 14:03:36 +0300 Subject: [PATCH 6/7] Added additional checks, updated cypress lib. --- .../request-management.cy.ts | 20 +++++++++++++++++++ .../request-management.cy.ts | 15 +++++++++++++- .../request-creation.cy.ts | 2 +- .../request-management.cy.ts | 16 +++++++++++++-- .../static-request-management.json | 3 ++- .../dynamic-request-management.json | 3 ++- .../static-request-management.json | 3 ++- .../dynamic-request-management.json | 3 ++- .../static-request-management.json | 3 ++- .../merchant-relation-requests-page.ts | 4 ++++ .../merchant-relation-requests-repository.ts | 1 + .../merchant-b2b-contract-requests.ts | 1 + .../mp/merchant-b2b-contract-requests.ts | 1 + .../yves/merchant-b2b-contract-requests.ts | 5 +++++ package-lock.json | 8 ++++---- package.json | 2 +- 16 files changed, 76 insertions(+), 14 deletions(-) diff --git a/cypress/e2e/backoffice/merchant-b2b-contract-requests/request-management.cy.ts b/cypress/e2e/backoffice/merchant-b2b-contract-requests/request-management.cy.ts index bf122b66..fc8e3e85 100644 --- a/cypress/e2e/backoffice/merchant-b2b-contract-requests/request-management.cy.ts +++ b/cypress/e2e/backoffice/merchant-b2b-contract-requests/request-management.cy.ts @@ -74,6 +74,26 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () cy.contains(staticFixtures.internalCommentFromRootUser); }); + it.skip('operator should be able to add internal comment with emoji', (): void => { + merchantRelationRequestListPage.visit(); + merchantRelationRequestListPage.update({ + action: ActionEnum.edit, + idMerchant: dynamicFixtures.merchant1.id_merchant, + }); + + merchantRelationRequestEditPage.addInternalComment({ + comment: staticFixtures.internalCommentFromRootUserWithEmoji, + }); + + merchantRelationRequestListPage.visit(); + merchantRelationRequestListPage.update({ + action: ActionEnum.edit, + idMerchant: dynamicFixtures.merchant1.id_merchant, + }); + + cy.contains(staticFixtures.internalCommentFromRootUserWithEmoji); + }); + it('operator should be able to reject request', (): void => { merchantRelationRequestListPage.visit(); merchantRelationRequestListPage.update({ diff --git a/cypress/e2e/mp/merchant-b2b-contract-requests/request-management.cy.ts b/cypress/e2e/mp/merchant-b2b-contract-requests/request-management.cy.ts index 4868cd6f..d839cecb 100644 --- a/cypress/e2e/mp/merchant-b2b-contract-requests/request-management.cy.ts +++ b/cypress/e2e/mp/merchant-b2b-contract-requests/request-management.cy.ts @@ -18,7 +18,20 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () ({ dynamicFixtures, staticFixtures } = Cypress.env()); }); - it('all merchant user should be able see merchant relation requests', (): void => { + it('merchant user should be able to see request note from company user', (): void => { + merchantUserLoginScenario.execute({ + username: dynamicFixtures.merchantUserFromMerchant2.username, + password: staticFixtures.defaultPassword, + }); + + merchantRelationRequestsPage.visit(); + merchantRelationRequestsPage.find({ query: dynamicFixtures.businessUnit1FromCompany1.name }).click(); + merchantRelationRequestsPage.getDrawer(); + + merchantRelationRequestsPage.getMessageFromCompanyValue().should('eq', staticFixtures.requestNote); + }); + + it('all merchant users should be able see merchant relation requests', (): void => { merchantUserLoginScenario.execute({ username: dynamicFixtures.merchantUser1FromMerchant1.username, password: staticFixtures.defaultPassword, diff --git a/cypress/e2e/yves/merchant-b2b-contract-requests/request-creation.cy.ts b/cypress/e2e/yves/merchant-b2b-contract-requests/request-creation.cy.ts index 98d5bee3..087a0930 100644 --- a/cypress/e2e/yves/merchant-b2b-contract-requests/request-creation.cy.ts +++ b/cypress/e2e/yves/merchant-b2b-contract-requests/request-creation.cy.ts @@ -69,7 +69,7 @@ describe('request creation', { tags: ['@merchant-b2b-contract-requests'] }, (): merchantPage.sendMerchantRelationRequest(); merchantRelationRequestCreatePage.create({ - merchantReference: dynamicFixtures.merchant1.merchant_reference, + // merchantReference: dynamicFixtures.merchant1.merchant_reference, ownerBusinessUnitId: dynamicFixtures.businessUnit2FromCompany1.id_company_business_unit, businessUnitIds: [], }); diff --git a/cypress/e2e/yves/merchant-b2b-contract-requests/request-management.cy.ts b/cypress/e2e/yves/merchant-b2b-contract-requests/request-management.cy.ts index f6768328..2a2464a1 100644 --- a/cypress/e2e/yves/merchant-b2b-contract-requests/request-management.cy.ts +++ b/cypress/e2e/yves/merchant-b2b-contract-requests/request-management.cy.ts @@ -1,5 +1,5 @@ import { container } from '@utils'; -import { MerchantB2bContractRequestsStaticFixtures, RequestManagementDynamicFixtures } from '@interfaces/yves'; +import { RequestManagementDynamicFixtures, RequestManagementStaticFixtures } from '@interfaces/yves'; import { CompanyUserSelectPage, MerchantRelationRequestDetailsPage, @@ -17,7 +17,7 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () const customerLoginScenario = container.get(CustomerLoginScenario); let dynamicFixtures: RequestManagementDynamicFixtures; - let staticFixtures: MerchantB2bContractRequestsStaticFixtures; + let staticFixtures: RequestManagementStaticFixtures; before((): void => { ({ dynamicFixtures, staticFixtures } = Cypress.env()); @@ -31,6 +31,18 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () companyUserSelectPage.visit(); }); + it('company user should be able to see decision note from rejected request', (): void => { + companyUserSelectPage.selectBusinessUnit({ + idCompanyUser: dynamicFixtures.companyUser1FromCompany1.id_company_user, + }); + + merchantRelationRequestIndexPage.visit(); + merchantRelationRequestIndexPage.filterRequests({ status: 'rejected' }); + merchantRelationRequestIndexPage.openFirstRequest(); + + cy.contains(staticFixtures.decisionNote); + }); + it('company user should be able to filter MR requests by status', (): void => { companyUserSelectPage.selectBusinessUnit({ idCompanyUser: dynamicFixtures.companyUser1FromCompany1.id_company_user, diff --git a/cypress/fixtures/suite/backoffice/merchant-b2b-contract-requests/static-request-management.json b/cypress/fixtures/suite/backoffice/merchant-b2b-contract-requests/static-request-management.json index a22bdafc..9aaedbdb 100644 --- a/cypress/fixtures/suite/backoffice/merchant-b2b-contract-requests/static-request-management.json +++ b/cypress/fixtures/suite/backoffice/merchant-b2b-contract-requests/static-request-management.json @@ -2,5 +2,6 @@ "defaultPassword": "change123", "internalCommentFromMerchantUser1": "This is dummy message from merchant user 1.", "internalCommentFromMerchantUser2": "This is dummy message from merchant user 2.", - "internalCommentFromRootUser": "This is dummy message from root user." + "internalCommentFromRootUser": "This is dummy message from root user.", + "internalCommentFromRootUserWithEmoji": "This is dummy message from root user with emoji. 😊" } diff --git a/cypress/fixtures/suite/mp/merchant-b2b-contract-requests/dynamic-request-management.json b/cypress/fixtures/suite/mp/merchant-b2b-contract-requests/dynamic-request-management.json index 90126d0e..00467923 100644 --- a/cypress/fixtures/suite/mp/merchant-b2b-contract-requests/dynamic-request-management.json +++ b/cypress/fixtures/suite/mp/merchant-b2b-contract-requests/dynamic-request-management.json @@ -570,7 +570,8 @@ "merchant": "#merchant2", "companyUser": "#companyUser1FromCompany1", "ownerCompanyBusinessUnit": "#businessUnit1FromCompany1", - "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany1" + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany1", + "requestNote": "This is request note from company user." } ] }, diff --git a/cypress/fixtures/suite/mp/merchant-b2b-contract-requests/static-request-management.json b/cypress/fixtures/suite/mp/merchant-b2b-contract-requests/static-request-management.json index 35e3f01b..a5673631 100644 --- a/cypress/fixtures/suite/mp/merchant-b2b-contract-requests/static-request-management.json +++ b/cypress/fixtures/suite/mp/merchant-b2b-contract-requests/static-request-management.json @@ -1,4 +1,5 @@ { "defaultPassword": "change123", - "internalComment": "This is dummy company user data, please replace with real data." + "internalComment": "This is dummy company user data, please replace with real data.", + "requestNote": "This is request note from company user." } diff --git a/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/dynamic-request-management.json b/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/dynamic-request-management.json index 0a57820a..0a6e5ca5 100644 --- a/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/dynamic-request-management.json +++ b/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/dynamic-request-management.json @@ -468,7 +468,8 @@ "merchant": "#merchant1", "companyUser": "#companyUser1FromCompany1", "ownerCompanyBusinessUnit": "#businessUnit1FromCompany1", - "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany1" + "assigneeCompanyBusinessUnits": "#assigneeCompanyBusinessUnitsFromCompany1", + "decisionNote": "Rejected due to some reason" } ] }, diff --git a/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/static-request-management.json b/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/static-request-management.json index ba4339e8..6a9497b7 100644 --- a/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/static-request-management.json +++ b/cypress/fixtures/suite/yves/merchant-b2b-contract-requests/static-request-management.json @@ -1,3 +1,4 @@ { - "defaultPassword": "change123" + "defaultPassword": "change123", + "decisionNote": "Rejected due to some reason" } diff --git a/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-page.ts b/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-page.ts index 910345cf..71577b40 100644 --- a/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-page.ts +++ b/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-page.ts @@ -59,6 +59,10 @@ export class MerchantRelationRequestsPage extends MpPage { } }); }; + + getMessageFromCompanyValue = (): Cypress.Chainable => { + return this.repository.getMessageFromCompanyValue(); + }; } interface FindParams { diff --git a/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-repository.ts b/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-repository.ts index 4b0f114d..272164a2 100644 --- a/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-repository.ts +++ b/cypress/support/pages/mp/merchant-relation-requests/merchant-relation-requests-repository.ts @@ -19,4 +19,5 @@ export class MerchantRelationRequestsRepository { cy.get('[ng-reflect-ng-class="ant-modal--confirmation"]').find('button:contains("Confirm approval")'); getRejectionModalConfirmButton = (): Cypress.Chainable => cy.get('[ng-reflect-ng-class="ant-modal--confirmation"]').find('button:contains("Confirm reject")'); + getMessageFromCompanyValue = (): Cypress.Chainable => cy.get('[spy-id="requestNote"]').invoke('val'); } diff --git a/cypress/support/types/backoffice/merchant-b2b-contract-requests.ts b/cypress/support/types/backoffice/merchant-b2b-contract-requests.ts index 582a53e3..b1a9f057 100644 --- a/cypress/support/types/backoffice/merchant-b2b-contract-requests.ts +++ b/cypress/support/types/backoffice/merchant-b2b-contract-requests.ts @@ -46,4 +46,5 @@ export interface RequestManagementStaticFixtures { internalCommentFromMerchantUser1: string; internalCommentFromMerchantUser2: string; internalCommentFromRootUser: string; + internalCommentFromRootUserWithEmoji: string; } diff --git a/cypress/support/types/mp/merchant-b2b-contract-requests.ts b/cypress/support/types/mp/merchant-b2b-contract-requests.ts index c91d3335..e436c4f1 100644 --- a/cypress/support/types/mp/merchant-b2b-contract-requests.ts +++ b/cypress/support/types/mp/merchant-b2b-contract-requests.ts @@ -58,4 +58,5 @@ export interface RequestManagementDynamicFixtures { export interface RequestManagementStaticFixtures { defaultPassword: string; internalComment: string; + requestNote: string; } diff --git a/cypress/support/types/yves/merchant-b2b-contract-requests.ts b/cypress/support/types/yves/merchant-b2b-contract-requests.ts index e66e419c..f33a2afa 100644 --- a/cypress/support/types/yves/merchant-b2b-contract-requests.ts +++ b/cypress/support/types/yves/merchant-b2b-contract-requests.ts @@ -97,6 +97,11 @@ export interface Dummy { companyUser1FromCompany2: CompanyUser; } +export interface RequestManagementStaticFixtures { + defaultPassword: string; + decisionNote: string; +} + export interface MerchantB2bContractRequestsStaticFixtures { defaultPassword: string; } diff --git a/package-lock.json b/package-lock.json index 79747cc1..f5ceb481 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@types/dotenv": "^8.2.0", "@typescript-eslint/eslint-plugin": "^6.21.0", "@typescript-eslint/parser": "^6.13.1", - "cypress": "^13.7.0", + "cypress": "^13.7.1", "eslint": "^8.57.0", "eslint-plugin-cypress": "^2.15.1", "inversify": "^6.0.2", @@ -1734,9 +1734,9 @@ } }, "node_modules/cypress": { - "version": "13.7.0", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.7.0.tgz", - "integrity": "sha512-UimjRSJJYdTlvkChcdcfywKJ6tUYuwYuk/n1uMMglrvi+ZthNhoRYcxnWgTqUtkl17fXrPAsD5XT2rcQYN1xKA==", + "version": "13.7.1", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.7.1.tgz", + "integrity": "sha512-4u/rpFNxOFCoFX/Z5h+uwlkBO4mWzAjveURi3vqdSu56HPvVdyGTxGw4XKGWt399Y1JwIn9E1L9uMXQpc0o55w==", "dev": true, "hasInstallScript": true, "dependencies": { diff --git a/package.json b/package.json index 3b1d95f6..3183d61a 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "@types/dotenv": "^8.2.0", "@typescript-eslint/eslint-plugin": "^6.21.0", "@typescript-eslint/parser": "^6.13.1", - "cypress": "^13.7.0", + "cypress": "^13.7.1", "eslint": "^8.57.0", "eslint-plugin-cypress": "^2.15.1", "inversify": "^6.0.2", From f0c0f00aee7598152135c03cfa48299287a848da Mon Sep 17 00:00:00 2001 From: Dmytro Asieiev Date: Tue, 26 Mar 2024 17:27:08 +0300 Subject: [PATCH 7/7] Reverted changes. --- .../merchant-b2b-contract-requests/request-management.cy.ts | 2 +- .../static-request-management.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/backoffice/merchant-b2b-contract-requests/request-management.cy.ts b/cypress/e2e/backoffice/merchant-b2b-contract-requests/request-management.cy.ts index fc8e3e85..72e52ca1 100644 --- a/cypress/e2e/backoffice/merchant-b2b-contract-requests/request-management.cy.ts +++ b/cypress/e2e/backoffice/merchant-b2b-contract-requests/request-management.cy.ts @@ -74,7 +74,7 @@ describe('request management', { tags: ['@merchant-b2b-contract-requests'] }, () cy.contains(staticFixtures.internalCommentFromRootUser); }); - it.skip('operator should be able to add internal comment with emoji', (): void => { + it('operator should be able to add internal comment with emoji', (): void => { merchantRelationRequestListPage.visit(); merchantRelationRequestListPage.update({ action: ActionEnum.edit, diff --git a/cypress/fixtures/suite/backoffice/merchant-b2b-contract-requests/static-request-management.json b/cypress/fixtures/suite/backoffice/merchant-b2b-contract-requests/static-request-management.json index 9aaedbdb..43c876d7 100644 --- a/cypress/fixtures/suite/backoffice/merchant-b2b-contract-requests/static-request-management.json +++ b/cypress/fixtures/suite/backoffice/merchant-b2b-contract-requests/static-request-management.json @@ -3,5 +3,5 @@ "internalCommentFromMerchantUser1": "This is dummy message from merchant user 1.", "internalCommentFromMerchantUser2": "This is dummy message from merchant user 2.", "internalCommentFromRootUser": "This is dummy message from root user.", - "internalCommentFromRootUserWithEmoji": "This is dummy message from root user with emoji. 😊" + "internalCommentFromRootUserWithEmoji": "This is dummy message from root user with ✅ emoji." }