From 5de500d511fdfd8887cdc6fb6e4c299c86bb4de6 Mon Sep 17 00:00:00 2001 From: Dmytro Asieiev Date: Wed, 20 Mar 2024 22:21:37 +0300 Subject: [PATCH] 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; -}