From 9565cef2fefe246efbad3a9d83bee4f9731549f9 Mon Sep 17 00:00:00 2001 From: Dmytro Asieiev Date: Mon, 9 Dec 2024 22:26:39 +0300 Subject: [PATCH 1/4] Added missing Order Management tests. --- .../order-creation-dms.cy.ts | 192 +++++++++++++++++ .../order-creation.cy.ts | 115 +++++++++++ .../dynamic-order-creation-dms.json | 193 ++++++++++++++++++ .../dynamic-order-creation.json | 193 ++++++++++++++++++ .../static-order-creation-dms.json | 16 ++ .../static-order-creation.json | 3 + .../assign-store-to-merchant-scenario.ts | 43 ++++ cypress/support/scenarios/backoffice/index.ts | 1 + cypress/support/types/mp/index.ts | 1 + .../types/mp/marketplace-order-management.ts | 29 +++ cypress/support/types/mp/shared/index.ts | 2 + .../support/types/mp/shared/payment-method.ts | 4 + cypress/support/types/mp/shared/store.ts | 7 + 13 files changed, 799 insertions(+) create mode 100644 cypress/e2e/mp/marketplace-order-management/order-creation-dms.cy.ts create mode 100644 cypress/e2e/mp/marketplace-order-management/order-creation.cy.ts create mode 100644 cypress/fixtures/suite/mp/marketplace-order-management/dynamic-order-creation-dms.json create mode 100644 cypress/fixtures/suite/mp/marketplace-order-management/dynamic-order-creation.json create mode 100644 cypress/fixtures/suite/mp/marketplace-order-management/static-order-creation-dms.json create mode 100644 cypress/fixtures/suite/mp/marketplace-order-management/static-order-creation.json create mode 100644 cypress/support/scenarios/backoffice/assign-store-to-merchant-scenario.ts create mode 100644 cypress/support/types/mp/marketplace-order-management.ts create mode 100644 cypress/support/types/mp/shared/payment-method.ts create mode 100644 cypress/support/types/mp/shared/store.ts diff --git a/cypress/e2e/mp/marketplace-order-management/order-creation-dms.cy.ts b/cypress/e2e/mp/marketplace-order-management/order-creation-dms.cy.ts new file mode 100644 index 00000000..995d19e5 --- /dev/null +++ b/cypress/e2e/mp/marketplace-order-management/order-creation-dms.cy.ts @@ -0,0 +1,192 @@ +import { container } from '@utils'; +import { OrderCreationDmsDynamicFixtures, OrderCreationDmsStaticFixtures } from '@interfaces/mp'; +import { SalesDetailPage, SalesIndexPage } from '@pages/backoffice'; +import { CatalogPage, ProductPage } from '@pages/yves'; +import { + AssignStoreToDefaultShipmentMethodsScenario, + AssignStoreToDefaultShipmentTypesScenario, + AssignStoreToDefaultWarehouseScenario, + AssignStoreToMerchantScenario, + AssignStoreToPaymentMethodsScenario, + AssignStoreToProductScenario, + CreateStoreScenario, + UserLoginScenario, +} from '@scenarios/backoffice'; +import { CheckoutMpScenario, CustomerLoginScenario, SelectStoreScenario } from '@scenarios/yves'; +import { ActionEnum, SalesOrdersPage } from '@pages/mp'; +import { MerchantUserLoginScenario } from '@scenarios/mp'; + +describeDmsSuiteAndMp('order creation dms', { tags: ['@mp', '@marketplace-order-management', '@dms'] }, (): void => { + const catalogPage = container.get(CatalogPage); + const productPage = container.get(ProductPage); + const salesIndexPage = container.get(SalesIndexPage); + const salesDetailPage = container.get(SalesDetailPage); + const salesOrdersPage = container.get(SalesOrdersPage); + const userLoginScenario = container.get(UserLoginScenario); + const customerLoginScenario = container.get(CustomerLoginScenario); + const checkoutMpScenario = container.get(CheckoutMpScenario); + const merchantUserLoginScenario = container.get(MerchantUserLoginScenario); + const createStoreScenario = container.get(CreateStoreScenario); + const assignStoreToProductScenario = container.get(AssignStoreToProductScenario); + const assignStoreToDefaultWarehouseScenario = container.get(AssignStoreToDefaultWarehouseScenario); + const assignStoreToDefaultShipmentMethodsScenario = container.get(AssignStoreToDefaultShipmentMethodsScenario); + const assignStoreToPaymentMethodsScenario = container.get(AssignStoreToPaymentMethodsScenario); + const assignStoreToDefaultShipmentTypesScenario = container.get(AssignStoreToDefaultShipmentTypesScenario); + const assignStoreToMerchantScenario = container.get(AssignStoreToMerchantScenario); + const selectStoreScenario = container.get(SelectStoreScenario); + + let staticFixtures: OrderCreationDmsStaticFixtures; + let dynamicFixtures: OrderCreationDmsDynamicFixtures; + + before((): void => { + ({ staticFixtures, dynamicFixtures } = Cypress.env()); + + userLoginScenario.execute({ + username: dynamicFixtures.rootUser.username, + password: staticFixtures.defaultPassword, + }); + + createStoreScenario.execute({ store: staticFixtures.store, shouldTriggerPublishAndSync: true }); + + assignStoreToMerchant(dynamicFixtures.merchant.name); + assignStoreToProduct(dynamicFixtures.merchantProduct.abstract_sku); + + setupDefaultStoreRelations(); + }); + + beforeEach((): void => { + selectStoreScenario.execute(staticFixtures.store.name); + }); + + it('merchant user should be able close an order from guest', (): void => { + addOneProductToCart(); + checkoutMpScenario.execute({ isGuest: true, shouldTriggerOmsInCli: true }); + + userLoginScenario.execute({ + username: dynamicFixtures.rootUser.username, + password: staticFixtures.defaultPassword, + }); + + assertMarketplacePaymentOmsTransitions(); + }); + + it('merchant user should be able close an order from customer', (): void => { + customerLoginScenario.execute({ + email: dynamicFixtures.customer.email, + password: staticFixtures.defaultPassword, + }); + + selectStoreScenario.execute(staticFixtures.store.name); + + addOneProductToCart(); + checkoutMpScenario.execute({ + idCustomerAddress: dynamicFixtures.address.id_customer_address, + shouldTriggerOmsInCli: true, + }); + + userLoginScenario.execute({ + username: dynamicFixtures.rootUser.username, + password: staticFixtures.defaultPassword, + }); + + assertMarketplacePaymentOmsTransitions(); + }); + + function addOneProductToCart(): void { + catalogPage.visit(); + catalogPage.searchProductFromSuggestions({ query: dynamicFixtures.merchantProduct.sku }); + productPage.addToCart(); + } + + function assertMarketplacePaymentOmsTransitions(): void { + salesIndexPage.visit(); + salesIndexPage.view(); + + salesIndexPage.getOrderReference().then((orderReference) => { + salesDetailPage.triggerOms({ state: 'Pay', shouldTriggerOmsInCli: true }); + salesDetailPage.triggerOms({ state: 'skip picking', shouldTriggerOmsInCli: true }); + + merchantUserLoginScenario.execute({ + username: dynamicFixtures.merchantUser.username, + password: staticFixtures.defaultPassword, + }); + + closeOrderFromMerchantPortal(orderReference); + closeOrderFromBackoffice(); + }); + } + + function closeOrderFromMerchantPortal(orderReference: string): void { + if (!['b2b-mp', 'suite'].includes(Cypress.env('repositoryId'))) { + salesOrdersPage.visit(); + salesOrdersPage.update({ query: orderReference, action: ActionEnum.sendToDistribution }); + + salesOrdersPage.visit(); + salesOrdersPage.update({ query: orderReference, action: ActionEnum.confirmAtCenter }); + } + + salesOrdersPage.visit(); + salesOrdersPage.update({ query: orderReference, action: ActionEnum.ship }); + + salesOrdersPage.visit(); + salesOrdersPage.update({ query: orderReference, action: ActionEnum.deliver }); + } + + function closeOrderFromBackoffice(): void { + userLoginScenario.execute({ + username: dynamicFixtures.rootUser.username, + password: staticFixtures.defaultPassword, + }); + + salesIndexPage.visit(); + salesIndexPage.view(); + + salesDetailPage.triggerOms({ state: 'Close' }); + } + + function assignStoreToMerchant(merchantName: string): void { + assignStoreToMerchantScenario.execute({ + merchantName: merchantName, + storeName: staticFixtures.store.name, + shouldTriggerPublishAndSync: true, + }); + } + + function assignStoreToProduct(abstractSku: string): void { + assignStoreToProductScenario.execute({ + abstractProductSku: abstractSku, + storeName: staticFixtures.store.name, + shouldTriggerPublishAndSync: true, + }); + } + + function setupDefaultStoreRelations(): void { + assignStoreToDefaultWarehouseScenario.execute({ + storeName: staticFixtures.store.name, + shouldTriggerPublishAndSync: true, + }); + assignStoreToDefaultShipmentMethodsScenario.execute({ + storeName: staticFixtures.store.name, + shouldTriggerPublishAndSync: true, + }); + assignStoreToPaymentMethodsScenario.execute({ + storeName: staticFixtures.store.name, + shouldTriggerPublishAndSync: true, + paymentMethods: staticFixtures.paymentMethods, + }); + + if (['suite', 'b2c-mp'].includes(Cypress.env('repositoryId'))) { + assignStoreToDefaultShipmentTypesScenario.execute({ + store: staticFixtures.store.name, + username: dynamicFixtures.rootUser.username, + password: staticFixtures.defaultPassword, + }); + } + } +}); + +function describeDmsSuiteAndMp(title: string, options: { tags: string[] }, fn: () => void): void { + (Cypress.env('isDynamicStoreEnabled') && ['suite', 'b2c-mp', 'b2b-mp'].includes(Cypress.env('repositoryId')) + ? describe + : describe.skip)(title, fn); +} diff --git a/cypress/e2e/mp/marketplace-order-management/order-creation.cy.ts b/cypress/e2e/mp/marketplace-order-management/order-creation.cy.ts new file mode 100644 index 00000000..f62c12b2 --- /dev/null +++ b/cypress/e2e/mp/marketplace-order-management/order-creation.cy.ts @@ -0,0 +1,115 @@ +import { container } from '@utils'; +import { OrderCreationDynamicFixtures, OrderCreationStaticFixtures } from '@interfaces/mp'; +import { SalesDetailPage, SalesIndexPage } from '@pages/backoffice'; +import { CatalogPage, ProductPage } from '@pages/yves'; +import { UserLoginScenario } from '@scenarios/backoffice'; +import { CheckoutMpScenario, CustomerLoginScenario } from '@scenarios/yves'; +import { ActionEnum, SalesOrdersPage } from '@pages/mp'; +import { MerchantUserLoginScenario } from '@scenarios/mp'; + +describeSuiteAndMp('order creation', { tags: ['@mp', '@marketplace-order-management'] }, (): void => { + const catalogPage = container.get(CatalogPage); + const productPage = container.get(ProductPage); + const salesIndexPage = container.get(SalesIndexPage); + const salesDetailPage = container.get(SalesDetailPage); + const salesOrdersPage = container.get(SalesOrdersPage); + const userLoginScenario = container.get(UserLoginScenario); + const customerLoginScenario = container.get(CustomerLoginScenario); + const checkoutMpScenario = container.get(CheckoutMpScenario); + const merchantUserLoginScenario = container.get(MerchantUserLoginScenario); + + let staticFixtures: OrderCreationStaticFixtures; + let dynamicFixtures: OrderCreationDynamicFixtures; + + before((): void => { + ({ staticFixtures, dynamicFixtures } = Cypress.env()); + }); + + it('merchant user should be able close an order from guest', (): void => { + addOneProductToCart(); + checkoutMpScenario.execute({ isGuest: true, shouldTriggerOmsInCli: true }); + + userLoginScenario.execute({ + username: dynamicFixtures.rootUser.username, + password: staticFixtures.defaultPassword, + }); + + assertMarketplacePaymentOmsTransitions(); + }); + + it('merchant user should be able close an order from customer', (): void => { + customerLoginScenario.execute({ + email: dynamicFixtures.customer.email, + password: staticFixtures.defaultPassword, + }); + + addOneProductToCart(); + checkoutMpScenario.execute({ + idCustomerAddress: dynamicFixtures.address.id_customer_address, + shouldTriggerOmsInCli: true, + }); + + userLoginScenario.execute({ + username: dynamicFixtures.rootUser.username, + password: staticFixtures.defaultPassword, + }); + + assertMarketplacePaymentOmsTransitions(); + }); + + function addOneProductToCart(): void { + catalogPage.visit(); + catalogPage.searchProductFromSuggestions({ query: dynamicFixtures.merchantProduct.sku }); + productPage.addToCart(); + } + + function assertMarketplacePaymentOmsTransitions(): void { + salesIndexPage.visit(); + salesIndexPage.view(); + + salesIndexPage.getOrderReference().then((orderReference) => { + salesDetailPage.triggerOms({ state: 'Pay', shouldTriggerOmsInCli: true }); + salesDetailPage.triggerOms({ state: 'skip picking', shouldTriggerOmsInCli: true }); + + merchantUserLoginScenario.execute({ + username: dynamicFixtures.merchantUser.username, + password: staticFixtures.defaultPassword, + }); + + closeOrderFromMerchantPortal(orderReference); + closeOrderFromBackoffice(); + }); + } + + function closeOrderFromMerchantPortal(orderReference: string): void { + if (!['b2b-mp', 'suite'].includes(Cypress.env('repositoryId'))) { + salesOrdersPage.visit(); + salesOrdersPage.update({ query: orderReference, action: ActionEnum.sendToDistribution }); + + salesOrdersPage.visit(); + salesOrdersPage.update({ query: orderReference, action: ActionEnum.confirmAtCenter }); + } + + salesOrdersPage.visit(); + salesOrdersPage.update({ query: orderReference, action: ActionEnum.ship }); + + salesOrdersPage.visit(); + salesOrdersPage.update({ query: orderReference, action: ActionEnum.deliver }); + } + + function closeOrderFromBackoffice(): void { + userLoginScenario.execute({ + username: dynamicFixtures.rootUser.username, + password: staticFixtures.defaultPassword, + }); + + salesIndexPage.visit(); + salesIndexPage.view(); + + salesDetailPage.triggerOms({ state: 'Close' }); + } +}); + +function describeSuiteAndMp(title: string, options: { tags: string[] }, fn: () => void): void { + (['suite', 'b2c-mp', 'b2b-mp'].includes(Cypress.env('repositoryId')) ? describe : describe.skip)(title, fn); +} diff --git a/cypress/fixtures/suite/mp/marketplace-order-management/dynamic-order-creation-dms.json b/cypress/fixtures/suite/mp/marketplace-order-management/dynamic-order-creation-dms.json new file mode 100644 index 00000000..592bceac --- /dev/null +++ b/cypress/fixtures/suite/mp/marketplace-order-management/dynamic-order-creation-dms.json @@ -0,0 +1,193 @@ +{ + "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": "helper", + "name": "haveCountry", + "key": "country" + }, + { + "type": "helper", + "name": "haveUser", + "key": "rootUser", + "arguments": [{ "password": "change123" }] + }, + { + "type": "helper", + "name": "addUserToGroup", + "arguments": ["#rootUser.id_user", 1] + }, + { + "type": "helper", + "name": "haveCustomer", + "key": "customer", + "arguments": [{ "locale": "#localeEN", "password": "change123" }] + }, + { + "type": "helper", + "name": "haveCustomerAddress", + "key": "address", + "arguments": [{ "fkCustomer": "#customer.id_customer", "fkCountry": "#country.id_country" }] + }, + { + "type": "helper", + "name": "confirmCustomer", + "key": "confirmedCustomer", + "arguments": ["#customer"] + }, + { + "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": "merchantUser", + "arguments": [{ "password": "change123" }] + }, + { + "type": "builder", + "name": "MerchantProfileBuilder", + "key": "merchantProfile" + }, + { + "type": "helper", + "name": "haveMerchant", + "key": "merchant", + "arguments": [ + { + "merchantProfile": "#merchantProfile", + "isActive": true, + "isOpenForRelationRequest": true, + "status": "approved", + "storeRelation": { + "idStores": ["#store.id_store"] + } + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "key": "merchantUrl1", + "arguments": [ + { + "fkLocale": "#localeEN.id_locale", + "fkResourceMerchant": "#merchant.id_merchant", + "urlPrefix": "/en/merchant/dummy-en-prefix-", + "url": "#merchant.name" + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "arguments": [ + { + "fkLocale": "#localeDE.id_locale", + "fkResourceMerchant": "#merchant.id_merchant", + "urlPrefix": "/de/merchant/dummy-de-prefix-", + "url": "#merchant.name" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantUserWithAclEntities", + "arguments": ["#merchant", "#merchantUser"] + }, + { + "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": "merchantProduct", + "arguments": [ + {}, + { + "idTaxSet": 1, + "localizedAttributes": [ + { "locale": "#localeEN", "name": "#localizedAttribute.name" }, + { "locale": "#localeDE", "name": "#localizedAttribute.name" } + ] + } + ] + }, + { + "type": "helper", + "name": "haveProductImageSet", + "arguments": [ + { + "name": "default", + "idProduct": "#merchantProduct.id_product_concrete", + "idProductAbstract": "#merchantProduct.fk_product_abstract", + "productImages": ["#productImage"] + } + ] + }, + { + "type": "helper", + "name": "havePriceProduct", + "arguments": [ + { + "skuProductAbstract": "#merchantProduct.abstract_sku", + "skuProduct": "#merchantProduct.sku", + "moneyValue": { "netAmount": 50000, "grossAmount": 50000 } + } + ] + }, + { + "type": "helper", + "name": "haveProductInStock", + "arguments": [ + { "sku": "#merchantProduct.sku", "isNeverOutOfStock": "1", "fkStock": 1, "stockType": "Warehouse1" } + ] + }, + { + "type": "helper", + "name": "haveMerchantProduct", + "arguments": [ + { + "idProductAbstract": "#merchantProduct.fk_product_abstract", + "idMerchant": "#merchant.id_merchant" + } + ] + } + ] + } + } +} diff --git a/cypress/fixtures/suite/mp/marketplace-order-management/dynamic-order-creation.json b/cypress/fixtures/suite/mp/marketplace-order-management/dynamic-order-creation.json new file mode 100644 index 00000000..592bceac --- /dev/null +++ b/cypress/fixtures/suite/mp/marketplace-order-management/dynamic-order-creation.json @@ -0,0 +1,193 @@ +{ + "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": "helper", + "name": "haveCountry", + "key": "country" + }, + { + "type": "helper", + "name": "haveUser", + "key": "rootUser", + "arguments": [{ "password": "change123" }] + }, + { + "type": "helper", + "name": "addUserToGroup", + "arguments": ["#rootUser.id_user", 1] + }, + { + "type": "helper", + "name": "haveCustomer", + "key": "customer", + "arguments": [{ "locale": "#localeEN", "password": "change123" }] + }, + { + "type": "helper", + "name": "haveCustomerAddress", + "key": "address", + "arguments": [{ "fkCustomer": "#customer.id_customer", "fkCountry": "#country.id_country" }] + }, + { + "type": "helper", + "name": "confirmCustomer", + "key": "confirmedCustomer", + "arguments": ["#customer"] + }, + { + "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": "merchantUser", + "arguments": [{ "password": "change123" }] + }, + { + "type": "builder", + "name": "MerchantProfileBuilder", + "key": "merchantProfile" + }, + { + "type": "helper", + "name": "haveMerchant", + "key": "merchant", + "arguments": [ + { + "merchantProfile": "#merchantProfile", + "isActive": true, + "isOpenForRelationRequest": true, + "status": "approved", + "storeRelation": { + "idStores": ["#store.id_store"] + } + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "key": "merchantUrl1", + "arguments": [ + { + "fkLocale": "#localeEN.id_locale", + "fkResourceMerchant": "#merchant.id_merchant", + "urlPrefix": "/en/merchant/dummy-en-prefix-", + "url": "#merchant.name" + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "arguments": [ + { + "fkLocale": "#localeDE.id_locale", + "fkResourceMerchant": "#merchant.id_merchant", + "urlPrefix": "/de/merchant/dummy-de-prefix-", + "url": "#merchant.name" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantUserWithAclEntities", + "arguments": ["#merchant", "#merchantUser"] + }, + { + "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": "merchantProduct", + "arguments": [ + {}, + { + "idTaxSet": 1, + "localizedAttributes": [ + { "locale": "#localeEN", "name": "#localizedAttribute.name" }, + { "locale": "#localeDE", "name": "#localizedAttribute.name" } + ] + } + ] + }, + { + "type": "helper", + "name": "haveProductImageSet", + "arguments": [ + { + "name": "default", + "idProduct": "#merchantProduct.id_product_concrete", + "idProductAbstract": "#merchantProduct.fk_product_abstract", + "productImages": ["#productImage"] + } + ] + }, + { + "type": "helper", + "name": "havePriceProduct", + "arguments": [ + { + "skuProductAbstract": "#merchantProduct.abstract_sku", + "skuProduct": "#merchantProduct.sku", + "moneyValue": { "netAmount": 50000, "grossAmount": 50000 } + } + ] + }, + { + "type": "helper", + "name": "haveProductInStock", + "arguments": [ + { "sku": "#merchantProduct.sku", "isNeverOutOfStock": "1", "fkStock": 1, "stockType": "Warehouse1" } + ] + }, + { + "type": "helper", + "name": "haveMerchantProduct", + "arguments": [ + { + "idProductAbstract": "#merchantProduct.fk_product_abstract", + "idMerchant": "#merchant.id_merchant" + } + ] + } + ] + } + } +} diff --git a/cypress/fixtures/suite/mp/marketplace-order-management/static-order-creation-dms.json b/cypress/fixtures/suite/mp/marketplace-order-management/static-order-creation-dms.json new file mode 100644 index 00000000..10ee0ed9 --- /dev/null +++ b/cypress/fixtures/suite/mp/marketplace-order-management/static-order-creation-dms.json @@ -0,0 +1,16 @@ +{ + "defaultPassword": "change123", + "store": { + "name": "TEST_STORE", + "currency": "EUR", + "locale": "en_US", + "country": "DE", + "timezone": "Europe/Berlin" + }, + "paymentMethods": [ + { + "key": "dummyMarketplacePaymentInvoice", + "name": "Dummy Marketplace Payment" + } + ] +} diff --git a/cypress/fixtures/suite/mp/marketplace-order-management/static-order-creation.json b/cypress/fixtures/suite/mp/marketplace-order-management/static-order-creation.json new file mode 100644 index 00000000..ba4339e8 --- /dev/null +++ b/cypress/fixtures/suite/mp/marketplace-order-management/static-order-creation.json @@ -0,0 +1,3 @@ +{ + "defaultPassword": "change123" +} diff --git a/cypress/support/scenarios/backoffice/assign-store-to-merchant-scenario.ts b/cypress/support/scenarios/backoffice/assign-store-to-merchant-scenario.ts new file mode 100644 index 00000000..f1b7d190 --- /dev/null +++ b/cypress/support/scenarios/backoffice/assign-store-to-merchant-scenario.ts @@ -0,0 +1,43 @@ +import { autoWired } from '@utils'; +import { inject, injectable } from 'inversify'; +import { MerchantListPage, MerchantUpdatePage } from '@pages/backoffice'; + +@injectable() +@autoWired +export class AssignStoreToMerchantScenario { + @inject(MerchantUpdatePage) private merchantUpdatePage: MerchantUpdatePage; + @inject(MerchantListPage) private merchantListPage: MerchantListPage; + + execute = (params: ExecuteParams): void => { + this.merchantListPage.visit(); + this.merchantListPage + .find({ + searchQuery: params.merchantName, + tableUrl: '/merchant-gui/list-merchant/table**', + }) + .then(($row) => { + const isStoreAssigned = this.merchantListPage.rowIsAssignedToStore({ + row: $row, + storeName: params.storeName, + }); + + this.merchantListPage.clickEditAction($row); + + if (isStoreAssigned) { + return; + } + + this.merchantUpdatePage.assignAllAvailableStore(); + + if (params.shouldTriggerPublishAndSync) { + cy.runCliCommands(['console queue:worker:start --stop-when-empty']); + } + }); + }; +} + +interface ExecuteParams { + merchantName: string; + storeName?: string; + shouldTriggerPublishAndSync?: boolean; +} diff --git a/cypress/support/scenarios/backoffice/index.ts b/cypress/support/scenarios/backoffice/index.ts index 65ead81b..acc233b4 100644 --- a/cypress/support/scenarios/backoffice/index.ts +++ b/cypress/support/scenarios/backoffice/index.ts @@ -13,3 +13,4 @@ export * from './assign-store-to-default-payment-methods-scenario'; export * from './assign-store-to-default-shipment-types-scenario'; export * from './assign-store-to-default-warehouse-scenario'; export * from './enable-cms-block-for-all-stores-scenario'; +export * from './assign-store-to-merchant-scenario'; diff --git a/cypress/support/types/mp/index.ts b/cypress/support/types/mp/index.ts index 1f288a33..290a5f63 100644 --- a/cypress/support/types/mp/index.ts +++ b/cypress/support/types/mp/index.ts @@ -3,3 +3,4 @@ export * from './merchant-b2b-contract-requests'; export * from './marketplace-merchant-commission'; export * from './marketplace-product-concretes'; export * from './marketplace-products'; +export * from './marketplace-order-management'; diff --git a/cypress/support/types/mp/marketplace-order-management.ts b/cypress/support/types/mp/marketplace-order-management.ts new file mode 100644 index 00000000..40321823 --- /dev/null +++ b/cypress/support/types/mp/marketplace-order-management.ts @@ -0,0 +1,29 @@ +import { Address, Customer, Merchant, PaymentMethod, ProductConcrete, Store, User } from './shared'; + +export interface OrderCreationDynamicFixtures { + rootUser: User; + merchant: Merchant; + merchantUser: User; + customer: Customer; + address: Address; + merchantProduct: ProductConcrete; +} + +export interface OrderCreationDmsDynamicFixtures { + rootUser: User; + merchant: Merchant; + merchantUser: User; + customer: Customer; + address: Address; + merchantProduct: ProductConcrete; +} + +export interface OrderCreationStaticFixtures { + defaultPassword: string; +} + +export interface OrderCreationDmsStaticFixtures { + defaultPassword: string; + store: Store; + paymentMethods: PaymentMethod[]; +} diff --git a/cypress/support/types/mp/shared/index.ts b/cypress/support/types/mp/shared/index.ts index 498e30a9..179c1ddd 100644 --- a/cypress/support/types/mp/shared/index.ts +++ b/cypress/support/types/mp/shared/index.ts @@ -10,3 +10,5 @@ export * from './company-user'; export * from './merchant-relation-request'; export * from './url'; export * from './address'; +export * from './payment-method'; +export * from './store'; diff --git a/cypress/support/types/mp/shared/payment-method.ts b/cypress/support/types/mp/shared/payment-method.ts new file mode 100644 index 00000000..18680081 --- /dev/null +++ b/cypress/support/types/mp/shared/payment-method.ts @@ -0,0 +1,4 @@ +export interface PaymentMethod { + key: string; + name: string; +} diff --git a/cypress/support/types/mp/shared/store.ts b/cypress/support/types/mp/shared/store.ts new file mode 100644 index 00000000..3fc26c85 --- /dev/null +++ b/cypress/support/types/mp/shared/store.ts @@ -0,0 +1,7 @@ +export interface Store { + name: string; + locale: string; + currency: string; + country: string; + timezone: string; +} From 56fbfb6480323337f9238cae94992ca90f13b56c Mon Sep 17 00:00:00 2001 From: Dmytro Asieiev Date: Tue, 10 Dec 2024 14:01:50 +0300 Subject: [PATCH 2/4] Added missing tests for OMS for b2c/b2b shops. --- .../order-management/order-creation-dms.cy.ts | 155 ++++++++++++++++++ .../order-creation-dms.cy.ts | 32 +--- .../yves/checkout/basic-checkout-dms.cy.ts | 32 +--- .../dynamic-order-creation-dms.json | 103 ++++++++++++ .../static-order-creation-dms.json | 16 ++ cypress/support/scenarios/backoffice/index.ts | 1 + .../setup-default-store-relations-scenario.ts | 61 +++++++ .../types/backoffice/order-management.ts | 15 +- .../support/types/backoffice/shared/index.ts | 1 + .../types/backoffice/shared/payment-method.ts | 4 + 10 files changed, 367 insertions(+), 53 deletions(-) create mode 100644 cypress/e2e/backoffice/order-management/order-creation-dms.cy.ts create mode 100644 cypress/fixtures/suite/backoffice/order-management/dynamic-order-creation-dms.json create mode 100644 cypress/fixtures/suite/backoffice/order-management/static-order-creation-dms.json create mode 100644 cypress/support/scenarios/backoffice/setup-default-store-relations-scenario.ts create mode 100644 cypress/support/types/backoffice/shared/payment-method.ts diff --git a/cypress/e2e/backoffice/order-management/order-creation-dms.cy.ts b/cypress/e2e/backoffice/order-management/order-creation-dms.cy.ts new file mode 100644 index 00000000..94c405f5 --- /dev/null +++ b/cypress/e2e/backoffice/order-management/order-creation-dms.cy.ts @@ -0,0 +1,155 @@ +import { container } from '@utils'; +import { OrderCreationDmsDynamicFixtures, OrderManagementDmsStaticFixtures } from '@interfaces/backoffice'; +import { CatalogPage, ProductPage } from '@pages/yves'; +import { CheckoutScenario, CustomerLoginScenario, SelectStoreScenario } from '@scenarios/yves'; +import { + CreateStoreScenario, + UserLoginScenario, + AssignStoreToProductScenario, + EnableCmsBlockForAllStoresScenario, + SetupDefaultStoreRelationsScenario, +} from '@scenarios/backoffice'; +import { SalesDetailPage, SalesIndexPage } from '@pages/backoffice'; + +describeIfDynamicStoreEnabled( + 'order creation dms', + { tags: ['@backoffice', '@order-management', '@dms'] }, + (): void => { + const catalogPage = container.get(CatalogPage); + const productPage = container.get(ProductPage); + const salesIndexPage = container.get(SalesIndexPage); + const salesDetailPage = container.get(SalesDetailPage); + + const checkoutScenario = container.get(CheckoutScenario); + const userLoginScenario = container.get(UserLoginScenario); + const customerLoginScenario = container.get(CustomerLoginScenario); + const selectStoreScenario = container.get(SelectStoreScenario); + const createStoreScenario = container.get(CreateStoreScenario); + const assignStoreToProductScenario = container.get(AssignStoreToProductScenario); + const enableCmsBlockForAllStoresScenario = container.get(EnableCmsBlockForAllStoresScenario); + const setupDefaultStoreRelationsScenario = container.get(SetupDefaultStoreRelationsScenario); + + let staticFixtures: OrderManagementDmsStaticFixtures; + let dynamicFixtures: OrderCreationDmsDynamicFixtures; + + before((): void => { + ({ staticFixtures, dynamicFixtures } = Cypress.env()); + + userLoginScenario.execute({ + username: dynamicFixtures.rootUser.username, + password: staticFixtures.defaultPassword, + }); + + createStoreScenario.execute({ store: staticFixtures.store, shouldTriggerPublishAndSync: true }); + + assignStoreToProductScenario.execute({ + abstractProductSku: dynamicFixtures.product.abstract_sku, + storeName: staticFixtures.store.name, + shouldTriggerPublishAndSync: true, + }); + + setupDefaultStoreRelations(); + setupDefaultCmsBlockForStore(); + }); + + beforeEach((): void => { + selectStoreScenario.execute(staticFixtures.store.name); + }); + + skipB2BIt('backoffice user should be able close an order from guest', (): void => { + addOneProductToCart(); + checkoutScenario.execute({ isGuest: true, shouldTriggerOmsInCli: true }); + + userLoginScenario.execute({ + username: dynamicFixtures.rootUser.username, + password: staticFixtures.defaultPassword, + }); + + assertOmsTransitions(); + }); + + it('backoffice user should be able close an order from customer', (): void => { + customerLoginScenario.execute({ + email: dynamicFixtures.customer.email, + password: staticFixtures.defaultPassword, + }); + + selectStoreScenario.execute(staticFixtures.store.name); + + addOneProductToCart(); + checkoutScenario.execute({ + idCustomerAddress: dynamicFixtures.address.id_customer_address, + shouldTriggerOmsInCli: true, + }); + + userLoginScenario.execute({ + username: dynamicFixtures.rootUser.username, + password: staticFixtures.defaultPassword, + }); + + assertOmsTransitions(); + }); + + function assertOmsTransitions(): void { + salesIndexPage.visit(); + salesIndexPage.view(); + + salesDetailPage.triggerOms({ state: 'Pay', shouldTriggerOmsInCli: true }); + salesDetailPage.triggerOms({ state: 'Skip timeout', shouldTriggerOmsInCli: true }); + salesDetailPage.triggerOms({ state: 'skip picking' }); + salesDetailPage.triggerOms({ state: 'Ship' }); + salesDetailPage.triggerOms({ state: 'Stock update' }); + salesDetailPage.triggerOms({ state: 'Close' }); + } + + function addOneProductToCart(): void { + catalogPage.visit(); + catalogPage.searchProductFromSuggestions({ query: dynamicFixtures.product.sku }); + productPage.addToCart(); + } + + function setupDefaultStoreRelations(): void { + setupDefaultStoreRelationsScenario.execute({ + storeName: staticFixtures.store.name, + paymentMethods: staticFixtures.paymentMethods, + rootUser: { + username: dynamicFixtures.rootUser.username, + password: staticFixtures.defaultPassword, + }, + }); + } + + function setupDefaultCmsBlockForStore(): void { + enableCmsBlockForAllStoresScenario.execute({ + cmsBlockName: 'order-confirmation--text', + storeName: staticFixtures.store.name, + shouldTriggerPublishAndSync: true, + }); + enableCmsBlockForAllStoresScenario.execute({ + cmsBlockName: 'order-confirmation--html', + storeName: staticFixtures.store.name, + shouldTriggerPublishAndSync: true, + }); + enableCmsBlockForAllStoresScenario.execute({ + cmsBlockName: 'order-shipped--text', + storeName: staticFixtures.store.name, + shouldTriggerPublishAndSync: true, + }); + enableCmsBlockForAllStoresScenario.execute({ + cmsBlockName: 'order-shipped--html', + storeName: staticFixtures.store.name, + shouldTriggerPublishAndSync: true, + }); + } + + function skipB2BIt(description: string, testFn: () => void): void { + (['b2b'].includes(Cypress.env('repositoryId')) ? it.skip : it)(description, testFn); + } + } +); + +function describeIfDynamicStoreEnabled(title: string, options: { tags: string[] }, fn: () => void): void { + (Cypress.env('isDynamicStoreEnabled') && ['suite', 'b2c', 'b2b'].includes(Cypress.env('repositoryId')) + ? describe + : describe.skip)(title, fn); +} diff --git a/cypress/e2e/mp/marketplace-order-management/order-creation-dms.cy.ts b/cypress/e2e/mp/marketplace-order-management/order-creation-dms.cy.ts index 995d19e5..feb24fd2 100644 --- a/cypress/e2e/mp/marketplace-order-management/order-creation-dms.cy.ts +++ b/cypress/e2e/mp/marketplace-order-management/order-creation-dms.cy.ts @@ -3,13 +3,10 @@ import { OrderCreationDmsDynamicFixtures, OrderCreationDmsStaticFixtures } from import { SalesDetailPage, SalesIndexPage } from '@pages/backoffice'; import { CatalogPage, ProductPage } from '@pages/yves'; import { - AssignStoreToDefaultShipmentMethodsScenario, - AssignStoreToDefaultShipmentTypesScenario, - AssignStoreToDefaultWarehouseScenario, AssignStoreToMerchantScenario, - AssignStoreToPaymentMethodsScenario, AssignStoreToProductScenario, CreateStoreScenario, + SetupDefaultStoreRelationsScenario, UserLoginScenario, } from '@scenarios/backoffice'; import { CheckoutMpScenario, CustomerLoginScenario, SelectStoreScenario } from '@scenarios/yves'; @@ -28,10 +25,7 @@ describeDmsSuiteAndMp('order creation dms', { tags: ['@mp', '@marketplace-order- const merchantUserLoginScenario = container.get(MerchantUserLoginScenario); const createStoreScenario = container.get(CreateStoreScenario); const assignStoreToProductScenario = container.get(AssignStoreToProductScenario); - const assignStoreToDefaultWarehouseScenario = container.get(AssignStoreToDefaultWarehouseScenario); - const assignStoreToDefaultShipmentMethodsScenario = container.get(AssignStoreToDefaultShipmentMethodsScenario); - const assignStoreToPaymentMethodsScenario = container.get(AssignStoreToPaymentMethodsScenario); - const assignStoreToDefaultShipmentTypesScenario = container.get(AssignStoreToDefaultShipmentTypesScenario); + const setupDefaultStoreRelationsScenario = container.get(SetupDefaultStoreRelationsScenario); const assignStoreToMerchantScenario = container.get(AssignStoreToMerchantScenario); const selectStoreScenario = container.get(SelectStoreScenario); @@ -50,7 +44,6 @@ describeDmsSuiteAndMp('order creation dms', { tags: ['@mp', '@marketplace-order- assignStoreToMerchant(dynamicFixtures.merchant.name); assignStoreToProduct(dynamicFixtures.merchantProduct.abstract_sku); - setupDefaultStoreRelations(); }); @@ -161,27 +154,14 @@ describeDmsSuiteAndMp('order creation dms', { tags: ['@mp', '@marketplace-order- } function setupDefaultStoreRelations(): void { - assignStoreToDefaultWarehouseScenario.execute({ - storeName: staticFixtures.store.name, - shouldTriggerPublishAndSync: true, - }); - assignStoreToDefaultShipmentMethodsScenario.execute({ - storeName: staticFixtures.store.name, - shouldTriggerPublishAndSync: true, - }); - assignStoreToPaymentMethodsScenario.execute({ + setupDefaultStoreRelationsScenario.execute({ storeName: staticFixtures.store.name, - shouldTriggerPublishAndSync: true, paymentMethods: staticFixtures.paymentMethods, - }); - - if (['suite', 'b2c-mp'].includes(Cypress.env('repositoryId'))) { - assignStoreToDefaultShipmentTypesScenario.execute({ - store: staticFixtures.store.name, + rootUser: { username: dynamicFixtures.rootUser.username, password: staticFixtures.defaultPassword, - }); - } + }, + }); } }); diff --git a/cypress/e2e/yves/checkout/basic-checkout-dms.cy.ts b/cypress/e2e/yves/checkout/basic-checkout-dms.cy.ts index 869241df..c388b310 100644 --- a/cypress/e2e/yves/checkout/basic-checkout-dms.cy.ts +++ b/cypress/e2e/yves/checkout/basic-checkout-dms.cy.ts @@ -3,13 +3,10 @@ import { BasicCheckoutDmsDynamicFixtures, BasicCheckoutDmsStaticFixtures } from import { CatalogPage, CustomerOverviewPage, ProductPage } from '@pages/yves'; import { CheckoutScenario, CustomerLoginScenario, SelectStoreScenario } from '@scenarios/yves'; import { - AssignStoreToPaymentMethodsScenario, - AssignStoreToDefaultShipmentMethodsScenario, - AssignStoreToDefaultShipmentTypesScenario, - AssignStoreToDefaultWarehouseScenario, AssignStoreToProductScenario, CreateStoreScenario, UserLoginScenario, + SetupDefaultStoreRelationsScenario, } from '@scenarios/backoffice'; describeIfDynamicStoreEnabled('basic checkout dms', { tags: ['@yves', '@checkout', '@dms'] }, (): void => { @@ -21,11 +18,8 @@ describeIfDynamicStoreEnabled('basic checkout dms', { tags: ['@yves', '@checkout const assignStoreToProductScenario = container.get(AssignStoreToProductScenario); const selectStoreScenario = container.get(SelectStoreScenario); const userLoginScenario = container.get(UserLoginScenario); - const assignStoreToDefaultShipmentMethodsScenario = container.get(AssignStoreToDefaultShipmentMethodsScenario); - const assignStoreToPaymentMethodsScenario = container.get(AssignStoreToPaymentMethodsScenario); - const assignStoreToDefaultShipmentTypesScenario = container.get(AssignStoreToDefaultShipmentTypesScenario); - const assignStoreToDefaultWarehouseScenario = container.get(AssignStoreToDefaultWarehouseScenario); const createStoreScenario = container.get(CreateStoreScenario); + const setupDefaultStoreRelationsScenario = container.get(SetupDefaultStoreRelationsScenario); let staticFixtures: BasicCheckoutDmsStaticFixtures; let dynamicFixtures: BasicCheckoutDmsDynamicFixtures; @@ -42,7 +36,6 @@ describeIfDynamicStoreEnabled('basic checkout dms', { tags: ['@yves', '@checkout assignStoreToProduct(dynamicFixtures.product1.abstract_sku); assignStoreToProduct(dynamicFixtures.product2.abstract_sku); - setupDefaultStoreRelations(); }); @@ -172,27 +165,14 @@ describeIfDynamicStoreEnabled('basic checkout dms', { tags: ['@yves', '@checkout } function setupDefaultStoreRelations(): void { - assignStoreToDefaultWarehouseScenario.execute({ - storeName: staticFixtures.store.name, - shouldTriggerPublishAndSync: true, - }); - assignStoreToDefaultShipmentMethodsScenario.execute({ + setupDefaultStoreRelationsScenario.execute({ storeName: staticFixtures.store.name, - shouldTriggerPublishAndSync: true, - }); - assignStoreToPaymentMethodsScenario.execute({ - storeName: staticFixtures.store.name, - shouldTriggerPublishAndSync: true, paymentMethods: staticFixtures.paymentMethods, - }); - - if (['suite', 'b2c-mp'].includes(Cypress.env('repositoryId'))) { - assignStoreToDefaultShipmentTypesScenario.execute({ - store: staticFixtures.store.name, + rootUser: { username: dynamicFixtures.rootUser.username, password: staticFixtures.defaultPassword, - }); - } + }, + }); } function skipB2BIt(description: string, testFn: () => void): void { diff --git a/cypress/fixtures/suite/backoffice/order-management/dynamic-order-creation-dms.json b/cypress/fixtures/suite/backoffice/order-management/dynamic-order-creation-dms.json new file mode 100644 index 00000000..ecda2ee0 --- /dev/null +++ b/cypress/fixtures/suite/backoffice/order-management/dynamic-order-creation-dms.json @@ -0,0 +1,103 @@ +{ + "data": { + "type": "dynamic-fixtures", + "attributes": { + "synchronize": true, + "operations": [ + { + "type": "transfer", + "name": "StoreTransfer", + "key": "store", + "arguments": { "id_store": 1 } + }, + { + "type": "transfer", + "name": "LocaleTransfer", + "key": "locale", + "arguments": { "id_locale": 66, "locale_name": "en_US" } + }, + { + "type": "helper", + "name": "haveCountry", + "key": "country" + }, + { + "type": "helper", + "name": "haveCustomer", + "key": "customer", + "arguments": [{ "locale": "#locale", "password": "change123" }] + }, + { + "type": "helper", + "name": "haveCustomerAddress", + "key": "address", + "arguments": [{ "fkCustomer": "#customer.id_customer", "fkCountry": "#country.id_country" }] + }, + { + "type": "helper", + "name": "confirmCustomer", + "key": "confirmedCustomer", + "arguments": ["#customer"] + }, + { + "type": "helper", + "name": "haveFullProduct", + "key": "product", + "arguments": [{}, { "idTaxSet": 1 }] + }, + { + "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": "haveProductImageSet", + "arguments": [ + { + "name": "default", + "idProduct": "#product.id_product_concrete", + "idProductAbstract": "#product.fk_product_abstract", + "productImages": ["#productImage"] + } + ] + }, + { + "type": "helper", + "name": "havePriceProduct", + "key": "productWithPrice", + "arguments": [ + { + "skuProductAbstract": "#product.abstract_sku", + "skuProduct": "#product.sku", + "moneyValue": { + "netAmount": 50000, + "grossAmount": 50000 + } + } + ] + }, + { + "type": "helper", + "name": "haveProductInStock", + "arguments": [{ "sku": "#product.sku", "isNeverOutOfStock": "1", "fkStock": 1, "stockType": "Warehouse1" }] + }, + { + "type": "helper", + "name": "haveUser", + "key": "rootUser", + "arguments": [{ "password": "change123" }] + }, + { + "type": "helper", + "name": "addUserToGroup", + "arguments": ["#rootUser.id_user", 1] + } + ] + } + } +} diff --git a/cypress/fixtures/suite/backoffice/order-management/static-order-creation-dms.json b/cypress/fixtures/suite/backoffice/order-management/static-order-creation-dms.json new file mode 100644 index 00000000..c195d51c --- /dev/null +++ b/cypress/fixtures/suite/backoffice/order-management/static-order-creation-dms.json @@ -0,0 +1,16 @@ +{ + "defaultPassword": "change123", + "store": { + "name": "TEST_STORE", + "currency": "EUR", + "locale": "en_US", + "country": "DE", + "timezone": "Europe/Berlin" + }, + "paymentMethods": [ + { + "key": "dummyPaymentInvoice", + "name": "Invoice" + } + ] +} diff --git a/cypress/support/scenarios/backoffice/index.ts b/cypress/support/scenarios/backoffice/index.ts index acc233b4..9d1dadba 100644 --- a/cypress/support/scenarios/backoffice/index.ts +++ b/cypress/support/scenarios/backoffice/index.ts @@ -14,3 +14,4 @@ export * from './assign-store-to-default-shipment-types-scenario'; export * from './assign-store-to-default-warehouse-scenario'; export * from './enable-cms-block-for-all-stores-scenario'; export * from './assign-store-to-merchant-scenario'; +export * from './setup-default-store-relations-scenario'; diff --git a/cypress/support/scenarios/backoffice/setup-default-store-relations-scenario.ts b/cypress/support/scenarios/backoffice/setup-default-store-relations-scenario.ts new file mode 100644 index 00000000..1b689fbe --- /dev/null +++ b/cypress/support/scenarios/backoffice/setup-default-store-relations-scenario.ts @@ -0,0 +1,61 @@ +import { autoWired } from '@utils'; +import { inject, injectable } from 'inversify'; +import { AssignStoreToDefaultShipmentMethodsScenario } from './assign-store-to-default-shipment-methods-scenario'; +import { AssignStoreToPaymentMethodsScenario } from './assign-store-to-default-payment-methods-scenario'; +import { AssignStoreToDefaultShipmentTypesScenario } from './assign-store-to-default-shipment-types-scenario'; +import { AssignStoreToDefaultWarehouseScenario } from './assign-store-to-default-warehouse-scenario'; + +@injectable() +@autoWired +export class SetupDefaultStoreRelationsScenario { + @inject(AssignStoreToDefaultWarehouseScenario) + private assignStoreToDefaultWarehouseScenario: AssignStoreToDefaultWarehouseScenario; + @inject(AssignStoreToDefaultShipmentMethodsScenario) + private assignStoreToDefaultShipmentMethodsScenario: AssignStoreToDefaultShipmentMethodsScenario; + @inject(AssignStoreToPaymentMethodsScenario) + private assignStoreToPaymentMethodsScenario: AssignStoreToPaymentMethodsScenario; + @inject(AssignStoreToDefaultShipmentTypesScenario) + private assignStoreToDefaultShipmentTypesScenario: AssignStoreToDefaultShipmentTypesScenario; + + execute = (params: ExecuteParams): void => { + this.assignStoreToDefaultWarehouseScenario.execute({ + storeName: params.storeName, + shouldTriggerPublishAndSync: true, + }); + + this.assignStoreToDefaultShipmentMethodsScenario.execute({ + storeName: params.storeName, + shouldTriggerPublishAndSync: true, + }); + + this.assignStoreToPaymentMethodsScenario.execute({ + storeName: params.storeName, + shouldTriggerPublishAndSync: true, + paymentMethods: params.paymentMethods, + }); + + if (['suite'].includes(Cypress.env('repositoryId'))) { + this.assignStoreToDefaultShipmentTypesScenario.execute({ + store: params.storeName, + username: params.rootUser.username, + password: params.rootUser.password, + }); + } + }; +} + +interface ExecuteParams { + storeName: string; + paymentMethods: PaymentMethod[]; + rootUser: User; +} + +interface PaymentMethod { + key: string; + name: string; +} + +interface User { + username: string; + password: string; +} diff --git a/cypress/support/types/backoffice/order-management.ts b/cypress/support/types/backoffice/order-management.ts index 82750a1c..9cd238b3 100644 --- a/cypress/support/types/backoffice/order-management.ts +++ b/cypress/support/types/backoffice/order-management.ts @@ -1,4 +1,4 @@ -import { Address, Customer, Product, User } from './shared'; +import { Address, Customer, PaymentMethod, Product, Store, User } from './shared'; export interface OrderCreationDynamicFixtures { customer: Customer; @@ -20,3 +20,16 @@ export interface CustomOrderReferenceManagementStaticFixtures { defaultPassword: string; orderReference: string; } + +export interface OrderCreationDmsDynamicFixtures { + customer: Customer; + address: Address; + product: Product; + rootUser: User; +} + +export interface OrderManagementDmsStaticFixtures { + defaultPassword: string; + store: Store; + paymentMethods: PaymentMethod[]; +} diff --git a/cypress/support/types/backoffice/shared/index.ts b/cypress/support/types/backoffice/shared/index.ts index d3fae889..bc3ab901 100644 --- a/cypress/support/types/backoffice/shared/index.ts +++ b/cypress/support/types/backoffice/shared/index.ts @@ -12,3 +12,4 @@ export * from './merchant'; export * from './merchant-relation-request'; export * from './store'; export * from './url'; +export * from './payment-method'; diff --git a/cypress/support/types/backoffice/shared/payment-method.ts b/cypress/support/types/backoffice/shared/payment-method.ts new file mode 100644 index 00000000..18680081 --- /dev/null +++ b/cypress/support/types/backoffice/shared/payment-method.ts @@ -0,0 +1,4 @@ +export interface PaymentMethod { + key: string; + name: string; +} From 8ae14e0d7da7a0135698c52f0c98b41296c0325b Mon Sep 17 00:00:00 2001 From: Dmytro Asieiev Date: Tue, 10 Dec 2024 17:51:35 +0300 Subject: [PATCH 3/4] Added fixtures for all demo shops. --- .../order-creation-dms.cy.ts | 18 +- .../order-creation.cy.ts | 18 +- .../dynamic-order-creation-dms.json | 262 ++++++++++++++++++ .../dynamic-order-creation.json | 262 ++++++++++++++++++ .../static-order-creation-dms.json | 16 ++ .../static-order-creation.json | 3 + .../dynamic-order-creation-dms.json | 172 ++++++++++++ .../static-order-creation-dms.json | 16 ++ .../dynamic-order-creation-dms.json | 193 +++++++++++++ .../dynamic-order-creation.json | 193 +++++++++++++ .../static-order-creation-dms.json | 16 ++ .../static-order-creation.json | 3 + .../dynamic-order-creation-dms.json | 103 +++++++ .../static-order-creation-dms.json | 16 ++ .../setup-default-store-relations-scenario.ts | 2 +- 15 files changed, 1274 insertions(+), 19 deletions(-) create mode 100644 cypress/fixtures/b2b-mp/mp/marketplace-order-management/dynamic-order-creation-dms.json create mode 100644 cypress/fixtures/b2b-mp/mp/marketplace-order-management/dynamic-order-creation.json create mode 100644 cypress/fixtures/b2b-mp/mp/marketplace-order-management/static-order-creation-dms.json create mode 100644 cypress/fixtures/b2b-mp/mp/marketplace-order-management/static-order-creation.json create mode 100644 cypress/fixtures/b2b/backoffice/order-management/dynamic-order-creation-dms.json create mode 100644 cypress/fixtures/b2b/backoffice/order-management/static-order-creation-dms.json create mode 100644 cypress/fixtures/b2c-mp/mp/marketplace-order-management/dynamic-order-creation-dms.json create mode 100644 cypress/fixtures/b2c-mp/mp/marketplace-order-management/dynamic-order-creation.json create mode 100644 cypress/fixtures/b2c-mp/mp/marketplace-order-management/static-order-creation-dms.json create mode 100644 cypress/fixtures/b2c-mp/mp/marketplace-order-management/static-order-creation.json create mode 100644 cypress/fixtures/b2c/backoffice/order-management/dynamic-order-creation-dms.json create mode 100644 cypress/fixtures/b2c/backoffice/order-management/static-order-creation-dms.json diff --git a/cypress/e2e/mp/marketplace-order-management/order-creation-dms.cy.ts b/cypress/e2e/mp/marketplace-order-management/order-creation-dms.cy.ts index feb24fd2..4a8dbdb7 100644 --- a/cypress/e2e/mp/marketplace-order-management/order-creation-dms.cy.ts +++ b/cypress/e2e/mp/marketplace-order-management/order-creation-dms.cy.ts @@ -51,7 +51,7 @@ describeDmsSuiteAndMp('order creation dms', { tags: ['@mp', '@marketplace-order- selectStoreScenario.execute(staticFixtures.store.name); }); - it('merchant user should be able close an order from guest', (): void => { + skipB2BIt('merchant user should be able close an order from guest', (): void => { addOneProductToCart(); checkoutMpScenario.execute({ isGuest: true, shouldTriggerOmsInCli: true }); @@ -104,20 +104,16 @@ describeDmsSuiteAndMp('order creation dms', { tags: ['@mp', '@marketplace-order- password: staticFixtures.defaultPassword, }); + if (['b2b-mp'].includes(Cypress.env('repositoryId'))) { + cy.runCliCommands(['console oms:check-condition', 'console oms:check-timeout']); + } + closeOrderFromMerchantPortal(orderReference); closeOrderFromBackoffice(); }); } function closeOrderFromMerchantPortal(orderReference: string): void { - if (!['b2b-mp', 'suite'].includes(Cypress.env('repositoryId'))) { - salesOrdersPage.visit(); - salesOrdersPage.update({ query: orderReference, action: ActionEnum.sendToDistribution }); - - salesOrdersPage.visit(); - salesOrdersPage.update({ query: orderReference, action: ActionEnum.confirmAtCenter }); - } - salesOrdersPage.visit(); salesOrdersPage.update({ query: orderReference, action: ActionEnum.ship }); @@ -163,6 +159,10 @@ describeDmsSuiteAndMp('order creation dms', { tags: ['@mp', '@marketplace-order- }, }); } + + function skipB2BIt(description: string, testFn: () => void): void { + (['b2b-mp'].includes(Cypress.env('repositoryId')) ? it.skip : it)(description, testFn); + } }); function describeDmsSuiteAndMp(title: string, options: { tags: string[] }, fn: () => void): void { diff --git a/cypress/e2e/mp/marketplace-order-management/order-creation.cy.ts b/cypress/e2e/mp/marketplace-order-management/order-creation.cy.ts index f62c12b2..32a40347 100644 --- a/cypress/e2e/mp/marketplace-order-management/order-creation.cy.ts +++ b/cypress/e2e/mp/marketplace-order-management/order-creation.cy.ts @@ -25,7 +25,7 @@ describeSuiteAndMp('order creation', { tags: ['@mp', '@marketplace-order-managem ({ staticFixtures, dynamicFixtures } = Cypress.env()); }); - it('merchant user should be able close an order from guest', (): void => { + skipB2BIt('merchant user should be able close an order from guest', (): void => { addOneProductToCart(); checkoutMpScenario.execute({ isGuest: true, shouldTriggerOmsInCli: true }); @@ -76,20 +76,16 @@ describeSuiteAndMp('order creation', { tags: ['@mp', '@marketplace-order-managem password: staticFixtures.defaultPassword, }); + if (['b2b-mp'].includes(Cypress.env('repositoryId'))) { + cy.runCliCommands(['console oms:check-condition', 'console oms:check-timeout']); + } + closeOrderFromMerchantPortal(orderReference); closeOrderFromBackoffice(); }); } function closeOrderFromMerchantPortal(orderReference: string): void { - if (!['b2b-mp', 'suite'].includes(Cypress.env('repositoryId'))) { - salesOrdersPage.visit(); - salesOrdersPage.update({ query: orderReference, action: ActionEnum.sendToDistribution }); - - salesOrdersPage.visit(); - salesOrdersPage.update({ query: orderReference, action: ActionEnum.confirmAtCenter }); - } - salesOrdersPage.visit(); salesOrdersPage.update({ query: orderReference, action: ActionEnum.ship }); @@ -108,6 +104,10 @@ describeSuiteAndMp('order creation', { tags: ['@mp', '@marketplace-order-managem salesDetailPage.triggerOms({ state: 'Close' }); } + + function skipB2BIt(description: string, testFn: () => void): void { + (['b2b-mp'].includes(Cypress.env('repositoryId')) ? it.skip : it)(description, testFn); + } }); function describeSuiteAndMp(title: string, options: { tags: string[] }, fn: () => void): void { diff --git a/cypress/fixtures/b2b-mp/mp/marketplace-order-management/dynamic-order-creation-dms.json b/cypress/fixtures/b2b-mp/mp/marketplace-order-management/dynamic-order-creation-dms.json new file mode 100644 index 00000000..2dcb85bd --- /dev/null +++ b/cypress/fixtures/b2b-mp/mp/marketplace-order-management/dynamic-order-creation-dms.json @@ -0,0 +1,262 @@ +{ + "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": "helper", + "name": "haveCountry", + "key": "country" + }, + { + "type": "helper", + "name": "haveUser", + "key": "rootUser", + "arguments": [{ "password": "change123" }] + }, + { + "type": "helper", + "name": "addUserToGroup", + "arguments": ["#rootUser.id_user", 1] + }, + { + "type": "helper", + "name": "haveCustomer", + "key": "customer", + "arguments": [{ "locale": "#localeEN", "password": "change123" }] + }, + { + "type": "helper", + "name": "haveCustomerAddress", + "key": "address", + "arguments": [{ "fkCustomer": "#customer.id_customer", "fkCountry": "#country.id_country" }] + }, + { + "type": "helper", + "name": "confirmCustomer", + "key": "confirmedCustomer", + "arguments": ["#customer"] + }, + { + "type": "helper", + "name": "haveCompany", + "key": "company", + "arguments": [{ "isActive": true, "status": "approved" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit", + "arguments": [{ "fkCompany": "#company.id_company" }] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission1", + "arguments": ["AddCartItemPermissionPlugin"] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission2", + "arguments": ["ChangeCartItemPermissionPlugin"] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission3", + "arguments": ["RemoveCartItemPermissionPlugin"] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission4", + "arguments": ["PlaceOrderWithAmountUpToPermissionPlugin"] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission5", + "arguments": ["PlaceOrderPermissionPlugin"] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission6", + "arguments": ["SeeBusinessUnitOrdersPermissionPlugin"] + }, + { + "type": "helper", + "name": "haveCompanyRoleWithPermissions", + "arguments": [ + { "isDefault": true, "fkCompany": "#company.id_company" }, + ["#permission1", "#permission2", "#permission3", "#permission4", "#permission5", "#permission6"] + ] + }, + { + "type": "helper", + "name": "haveCompanyUser", + "key": "companyUser", + "arguments": [ + { + "customer": "#customer", + "fkCustomer": "#customer.id_customer", + "fkCompany": "#company.id_company", + "fkCompanyBusinessUnit": "#businessUnit.id_company_business_unit" + } + ] + }, + { + "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": "merchantUser", + "arguments": [{ "password": "change123" }] + }, + { + "type": "builder", + "name": "MerchantProfileBuilder", + "key": "merchantProfile" + }, + { + "type": "helper", + "name": "haveMerchant", + "key": "merchant", + "arguments": [ + { + "merchantProfile": "#merchantProfile", + "isActive": true, + "isOpenForRelationRequest": true, + "status": "approved", + "storeRelation": { + "idStores": ["#store.id_store"] + } + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "key": "merchantUrl1", + "arguments": [ + { + "fkLocale": "#localeEN.id_locale", + "fkResourceMerchant": "#merchant.id_merchant", + "urlPrefix": "/en/merchant/dummy-en-prefix-", + "url": "#merchant.name" + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "arguments": [ + { + "fkLocale": "#localeDE.id_locale", + "fkResourceMerchant": "#merchant.id_merchant", + "urlPrefix": "/de/merchant/dummy-de-prefix-", + "url": "#merchant.name" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantUserWithAclEntities", + "arguments": ["#merchant", "#merchantUser"] + }, + { + "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": "merchantProduct", + "arguments": [ + {}, + { + "idTaxSet": 1, + "localizedAttributes": [ + { "locale": "#localeEN", "name": "#localizedAttribute.name" }, + { "locale": "#localeDE", "name": "#localizedAttribute.name" } + ] + } + ] + }, + { + "type": "helper", + "name": "haveProductImageSet", + "arguments": [ + { + "name": "default", + "idProduct": "#merchantProduct.id_product_concrete", + "idProductAbstract": "#merchantProduct.fk_product_abstract", + "productImages": ["#productImage"] + } + ] + }, + { + "type": "helper", + "name": "havePriceProduct", + "arguments": [ + { + "skuProductAbstract": "#merchantProduct.abstract_sku", + "skuProduct": "#merchantProduct.sku", + "moneyValue": { "netAmount": 50000, "grossAmount": 50000 } + } + ] + }, + { + "type": "helper", + "name": "haveProductInStock", + "arguments": [ + { "sku": "#merchantProduct.sku", "isNeverOutOfStock": "1", "fkStock": 1, "stockType": "Warehouse1" } + ] + }, + { + "type": "helper", + "name": "haveMerchantProduct", + "arguments": [ + { + "idProductAbstract": "#merchantProduct.fk_product_abstract", + "idMerchant": "#merchant.id_merchant" + } + ] + } + ] + } + } +} diff --git a/cypress/fixtures/b2b-mp/mp/marketplace-order-management/dynamic-order-creation.json b/cypress/fixtures/b2b-mp/mp/marketplace-order-management/dynamic-order-creation.json new file mode 100644 index 00000000..2dcb85bd --- /dev/null +++ b/cypress/fixtures/b2b-mp/mp/marketplace-order-management/dynamic-order-creation.json @@ -0,0 +1,262 @@ +{ + "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": "helper", + "name": "haveCountry", + "key": "country" + }, + { + "type": "helper", + "name": "haveUser", + "key": "rootUser", + "arguments": [{ "password": "change123" }] + }, + { + "type": "helper", + "name": "addUserToGroup", + "arguments": ["#rootUser.id_user", 1] + }, + { + "type": "helper", + "name": "haveCustomer", + "key": "customer", + "arguments": [{ "locale": "#localeEN", "password": "change123" }] + }, + { + "type": "helper", + "name": "haveCustomerAddress", + "key": "address", + "arguments": [{ "fkCustomer": "#customer.id_customer", "fkCountry": "#country.id_country" }] + }, + { + "type": "helper", + "name": "confirmCustomer", + "key": "confirmedCustomer", + "arguments": ["#customer"] + }, + { + "type": "helper", + "name": "haveCompany", + "key": "company", + "arguments": [{ "isActive": true, "status": "approved" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit", + "arguments": [{ "fkCompany": "#company.id_company" }] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission1", + "arguments": ["AddCartItemPermissionPlugin"] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission2", + "arguments": ["ChangeCartItemPermissionPlugin"] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission3", + "arguments": ["RemoveCartItemPermissionPlugin"] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission4", + "arguments": ["PlaceOrderWithAmountUpToPermissionPlugin"] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission5", + "arguments": ["PlaceOrderPermissionPlugin"] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission6", + "arguments": ["SeeBusinessUnitOrdersPermissionPlugin"] + }, + { + "type": "helper", + "name": "haveCompanyRoleWithPermissions", + "arguments": [ + { "isDefault": true, "fkCompany": "#company.id_company" }, + ["#permission1", "#permission2", "#permission3", "#permission4", "#permission5", "#permission6"] + ] + }, + { + "type": "helper", + "name": "haveCompanyUser", + "key": "companyUser", + "arguments": [ + { + "customer": "#customer", + "fkCustomer": "#customer.id_customer", + "fkCompany": "#company.id_company", + "fkCompanyBusinessUnit": "#businessUnit.id_company_business_unit" + } + ] + }, + { + "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": "merchantUser", + "arguments": [{ "password": "change123" }] + }, + { + "type": "builder", + "name": "MerchantProfileBuilder", + "key": "merchantProfile" + }, + { + "type": "helper", + "name": "haveMerchant", + "key": "merchant", + "arguments": [ + { + "merchantProfile": "#merchantProfile", + "isActive": true, + "isOpenForRelationRequest": true, + "status": "approved", + "storeRelation": { + "idStores": ["#store.id_store"] + } + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "key": "merchantUrl1", + "arguments": [ + { + "fkLocale": "#localeEN.id_locale", + "fkResourceMerchant": "#merchant.id_merchant", + "urlPrefix": "/en/merchant/dummy-en-prefix-", + "url": "#merchant.name" + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "arguments": [ + { + "fkLocale": "#localeDE.id_locale", + "fkResourceMerchant": "#merchant.id_merchant", + "urlPrefix": "/de/merchant/dummy-de-prefix-", + "url": "#merchant.name" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantUserWithAclEntities", + "arguments": ["#merchant", "#merchantUser"] + }, + { + "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": "merchantProduct", + "arguments": [ + {}, + { + "idTaxSet": 1, + "localizedAttributes": [ + { "locale": "#localeEN", "name": "#localizedAttribute.name" }, + { "locale": "#localeDE", "name": "#localizedAttribute.name" } + ] + } + ] + }, + { + "type": "helper", + "name": "haveProductImageSet", + "arguments": [ + { + "name": "default", + "idProduct": "#merchantProduct.id_product_concrete", + "idProductAbstract": "#merchantProduct.fk_product_abstract", + "productImages": ["#productImage"] + } + ] + }, + { + "type": "helper", + "name": "havePriceProduct", + "arguments": [ + { + "skuProductAbstract": "#merchantProduct.abstract_sku", + "skuProduct": "#merchantProduct.sku", + "moneyValue": { "netAmount": 50000, "grossAmount": 50000 } + } + ] + }, + { + "type": "helper", + "name": "haveProductInStock", + "arguments": [ + { "sku": "#merchantProduct.sku", "isNeverOutOfStock": "1", "fkStock": 1, "stockType": "Warehouse1" } + ] + }, + { + "type": "helper", + "name": "haveMerchantProduct", + "arguments": [ + { + "idProductAbstract": "#merchantProduct.fk_product_abstract", + "idMerchant": "#merchant.id_merchant" + } + ] + } + ] + } + } +} diff --git a/cypress/fixtures/b2b-mp/mp/marketplace-order-management/static-order-creation-dms.json b/cypress/fixtures/b2b-mp/mp/marketplace-order-management/static-order-creation-dms.json new file mode 100644 index 00000000..10ee0ed9 --- /dev/null +++ b/cypress/fixtures/b2b-mp/mp/marketplace-order-management/static-order-creation-dms.json @@ -0,0 +1,16 @@ +{ + "defaultPassword": "change123", + "store": { + "name": "TEST_STORE", + "currency": "EUR", + "locale": "en_US", + "country": "DE", + "timezone": "Europe/Berlin" + }, + "paymentMethods": [ + { + "key": "dummyMarketplacePaymentInvoice", + "name": "Dummy Marketplace Payment" + } + ] +} diff --git a/cypress/fixtures/b2b-mp/mp/marketplace-order-management/static-order-creation.json b/cypress/fixtures/b2b-mp/mp/marketplace-order-management/static-order-creation.json new file mode 100644 index 00000000..ba4339e8 --- /dev/null +++ b/cypress/fixtures/b2b-mp/mp/marketplace-order-management/static-order-creation.json @@ -0,0 +1,3 @@ +{ + "defaultPassword": "change123" +} diff --git a/cypress/fixtures/b2b/backoffice/order-management/dynamic-order-creation-dms.json b/cypress/fixtures/b2b/backoffice/order-management/dynamic-order-creation-dms.json new file mode 100644 index 00000000..9db84a21 --- /dev/null +++ b/cypress/fixtures/b2b/backoffice/order-management/dynamic-order-creation-dms.json @@ -0,0 +1,172 @@ +{ + "data": { + "type": "dynamic-fixtures", + "attributes": { + "synchronize": true, + "operations": [ + { + "type": "transfer", + "name": "StoreTransfer", + "key": "store", + "arguments": { "id_store": 1 } + }, + { + "type": "transfer", + "name": "LocaleTransfer", + "key": "locale", + "arguments": { "id_locale": 66, "locale_name": "en_US" } + }, + { + "type": "helper", + "name": "haveCountry", + "key": "country" + }, + { + "type": "helper", + "name": "haveCustomer", + "key": "customer", + "arguments": [{ "locale": "#locale", "password": "change123" }] + }, + { + "type": "helper", + "name": "haveCustomerAddress", + "key": "address", + "arguments": [{ "fkCustomer": "#customer.id_customer", "fkCountry": "#country.id_country" }] + }, + { + "type": "helper", + "name": "confirmCustomer", + "key": "confirmedCustomer", + "arguments": ["#customer"] + }, + { + "type": "helper", + "name": "haveCompany", + "key": "company", + "arguments": [{ "isActive": true, "status": "approved" }] + }, + { + "type": "helper", + "name": "haveCompanyBusinessUnit", + "key": "businessUnit", + "arguments": [{ "fkCompany": "#company.id_company" }] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission1", + "arguments": ["AddCartItemPermissionPlugin"] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission2", + "arguments": ["ChangeCartItemPermissionPlugin"] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission3", + "arguments": ["RemoveCartItemPermissionPlugin"] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission4", + "arguments": ["PlaceOrderWithAmountUpToPermissionPlugin"] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission5", + "arguments": ["PlaceOrderPermissionPlugin"] + }, + { + "type": "helper", + "name": "havePermissionByKey", + "key": "permission6", + "arguments": ["SeeBusinessUnitOrdersPermissionPlugin"] + }, + { + "type": "helper", + "name": "haveCompanyRoleWithPermissions", + "arguments": [ + { "isDefault": true, "fkCompany": "#company.id_company" }, + ["#permission1", "#permission2", "#permission3", "#permission4", "#permission5", "#permission6"] + ] + }, + { + "type": "helper", + "name": "haveCompanyUser", + "key": "companyUser", + "arguments": [ + { + "customer": "#customer", + "fkCustomer": "#customer.id_customer", + "fkCompany": "#company.id_company", + "fkCompanyBusinessUnit": "#businessUnit.id_company_business_unit" + } + ] + }, + { + "type": "helper", + "name": "haveFullProduct", + "key": "product", + "arguments": [{}, { "idTaxSet": 1 }] + }, + { + "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": "haveProductImageSet", + "arguments": [ + { + "name": "default", + "idProduct": "#product.id_product_concrete", + "idProductAbstract": "#product.fk_product_abstract", + "productImages": ["#productImage"] + } + ] + }, + { + "type": "helper", + "name": "havePriceProduct", + "key": "productWithPrice", + "arguments": [ + { + "skuProductAbstract": "#product.abstract_sku", + "skuProduct": "#product.sku", + "moneyValue": { + "netAmount": 50000, + "grossAmount": 50000 + } + } + ] + }, + { + "type": "helper", + "name": "haveProductInStock", + "arguments": [{ "sku": "#product.sku", "isNeverOutOfStock": "1", "fkStock": 1, "stockType": "Warehouse1" }] + }, + { + "type": "helper", + "name": "haveUser", + "key": "rootUser", + "arguments": [{ "password": "change123" }] + }, + { + "type": "helper", + "name": "addUserToGroup", + "arguments": ["#rootUser.id_user", 1] + } + ] + } + } +} diff --git a/cypress/fixtures/b2b/backoffice/order-management/static-order-creation-dms.json b/cypress/fixtures/b2b/backoffice/order-management/static-order-creation-dms.json new file mode 100644 index 00000000..c195d51c --- /dev/null +++ b/cypress/fixtures/b2b/backoffice/order-management/static-order-creation-dms.json @@ -0,0 +1,16 @@ +{ + "defaultPassword": "change123", + "store": { + "name": "TEST_STORE", + "currency": "EUR", + "locale": "en_US", + "country": "DE", + "timezone": "Europe/Berlin" + }, + "paymentMethods": [ + { + "key": "dummyPaymentInvoice", + "name": "Invoice" + } + ] +} diff --git a/cypress/fixtures/b2c-mp/mp/marketplace-order-management/dynamic-order-creation-dms.json b/cypress/fixtures/b2c-mp/mp/marketplace-order-management/dynamic-order-creation-dms.json new file mode 100644 index 00000000..592bceac --- /dev/null +++ b/cypress/fixtures/b2c-mp/mp/marketplace-order-management/dynamic-order-creation-dms.json @@ -0,0 +1,193 @@ +{ + "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": "helper", + "name": "haveCountry", + "key": "country" + }, + { + "type": "helper", + "name": "haveUser", + "key": "rootUser", + "arguments": [{ "password": "change123" }] + }, + { + "type": "helper", + "name": "addUserToGroup", + "arguments": ["#rootUser.id_user", 1] + }, + { + "type": "helper", + "name": "haveCustomer", + "key": "customer", + "arguments": [{ "locale": "#localeEN", "password": "change123" }] + }, + { + "type": "helper", + "name": "haveCustomerAddress", + "key": "address", + "arguments": [{ "fkCustomer": "#customer.id_customer", "fkCountry": "#country.id_country" }] + }, + { + "type": "helper", + "name": "confirmCustomer", + "key": "confirmedCustomer", + "arguments": ["#customer"] + }, + { + "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": "merchantUser", + "arguments": [{ "password": "change123" }] + }, + { + "type": "builder", + "name": "MerchantProfileBuilder", + "key": "merchantProfile" + }, + { + "type": "helper", + "name": "haveMerchant", + "key": "merchant", + "arguments": [ + { + "merchantProfile": "#merchantProfile", + "isActive": true, + "isOpenForRelationRequest": true, + "status": "approved", + "storeRelation": { + "idStores": ["#store.id_store"] + } + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "key": "merchantUrl1", + "arguments": [ + { + "fkLocale": "#localeEN.id_locale", + "fkResourceMerchant": "#merchant.id_merchant", + "urlPrefix": "/en/merchant/dummy-en-prefix-", + "url": "#merchant.name" + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "arguments": [ + { + "fkLocale": "#localeDE.id_locale", + "fkResourceMerchant": "#merchant.id_merchant", + "urlPrefix": "/de/merchant/dummy-de-prefix-", + "url": "#merchant.name" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantUserWithAclEntities", + "arguments": ["#merchant", "#merchantUser"] + }, + { + "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": "merchantProduct", + "arguments": [ + {}, + { + "idTaxSet": 1, + "localizedAttributes": [ + { "locale": "#localeEN", "name": "#localizedAttribute.name" }, + { "locale": "#localeDE", "name": "#localizedAttribute.name" } + ] + } + ] + }, + { + "type": "helper", + "name": "haveProductImageSet", + "arguments": [ + { + "name": "default", + "idProduct": "#merchantProduct.id_product_concrete", + "idProductAbstract": "#merchantProduct.fk_product_abstract", + "productImages": ["#productImage"] + } + ] + }, + { + "type": "helper", + "name": "havePriceProduct", + "arguments": [ + { + "skuProductAbstract": "#merchantProduct.abstract_sku", + "skuProduct": "#merchantProduct.sku", + "moneyValue": { "netAmount": 50000, "grossAmount": 50000 } + } + ] + }, + { + "type": "helper", + "name": "haveProductInStock", + "arguments": [ + { "sku": "#merchantProduct.sku", "isNeverOutOfStock": "1", "fkStock": 1, "stockType": "Warehouse1" } + ] + }, + { + "type": "helper", + "name": "haveMerchantProduct", + "arguments": [ + { + "idProductAbstract": "#merchantProduct.fk_product_abstract", + "idMerchant": "#merchant.id_merchant" + } + ] + } + ] + } + } +} diff --git a/cypress/fixtures/b2c-mp/mp/marketplace-order-management/dynamic-order-creation.json b/cypress/fixtures/b2c-mp/mp/marketplace-order-management/dynamic-order-creation.json new file mode 100644 index 00000000..592bceac --- /dev/null +++ b/cypress/fixtures/b2c-mp/mp/marketplace-order-management/dynamic-order-creation.json @@ -0,0 +1,193 @@ +{ + "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": "helper", + "name": "haveCountry", + "key": "country" + }, + { + "type": "helper", + "name": "haveUser", + "key": "rootUser", + "arguments": [{ "password": "change123" }] + }, + { + "type": "helper", + "name": "addUserToGroup", + "arguments": ["#rootUser.id_user", 1] + }, + { + "type": "helper", + "name": "haveCustomer", + "key": "customer", + "arguments": [{ "locale": "#localeEN", "password": "change123" }] + }, + { + "type": "helper", + "name": "haveCustomerAddress", + "key": "address", + "arguments": [{ "fkCustomer": "#customer.id_customer", "fkCountry": "#country.id_country" }] + }, + { + "type": "helper", + "name": "confirmCustomer", + "key": "confirmedCustomer", + "arguments": ["#customer"] + }, + { + "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": "merchantUser", + "arguments": [{ "password": "change123" }] + }, + { + "type": "builder", + "name": "MerchantProfileBuilder", + "key": "merchantProfile" + }, + { + "type": "helper", + "name": "haveMerchant", + "key": "merchant", + "arguments": [ + { + "merchantProfile": "#merchantProfile", + "isActive": true, + "isOpenForRelationRequest": true, + "status": "approved", + "storeRelation": { + "idStores": ["#store.id_store"] + } + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "key": "merchantUrl1", + "arguments": [ + { + "fkLocale": "#localeEN.id_locale", + "fkResourceMerchant": "#merchant.id_merchant", + "urlPrefix": "/en/merchant/dummy-en-prefix-", + "url": "#merchant.name" + } + ] + }, + { + "type": "helper", + "name": "haveUrl", + "arguments": [ + { + "fkLocale": "#localeDE.id_locale", + "fkResourceMerchant": "#merchant.id_merchant", + "urlPrefix": "/de/merchant/dummy-de-prefix-", + "url": "#merchant.name" + } + ] + }, + { + "type": "helper", + "name": "haveMerchantUserWithAclEntities", + "arguments": ["#merchant", "#merchantUser"] + }, + { + "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": "merchantProduct", + "arguments": [ + {}, + { + "idTaxSet": 1, + "localizedAttributes": [ + { "locale": "#localeEN", "name": "#localizedAttribute.name" }, + { "locale": "#localeDE", "name": "#localizedAttribute.name" } + ] + } + ] + }, + { + "type": "helper", + "name": "haveProductImageSet", + "arguments": [ + { + "name": "default", + "idProduct": "#merchantProduct.id_product_concrete", + "idProductAbstract": "#merchantProduct.fk_product_abstract", + "productImages": ["#productImage"] + } + ] + }, + { + "type": "helper", + "name": "havePriceProduct", + "arguments": [ + { + "skuProductAbstract": "#merchantProduct.abstract_sku", + "skuProduct": "#merchantProduct.sku", + "moneyValue": { "netAmount": 50000, "grossAmount": 50000 } + } + ] + }, + { + "type": "helper", + "name": "haveProductInStock", + "arguments": [ + { "sku": "#merchantProduct.sku", "isNeverOutOfStock": "1", "fkStock": 1, "stockType": "Warehouse1" } + ] + }, + { + "type": "helper", + "name": "haveMerchantProduct", + "arguments": [ + { + "idProductAbstract": "#merchantProduct.fk_product_abstract", + "idMerchant": "#merchant.id_merchant" + } + ] + } + ] + } + } +} diff --git a/cypress/fixtures/b2c-mp/mp/marketplace-order-management/static-order-creation-dms.json b/cypress/fixtures/b2c-mp/mp/marketplace-order-management/static-order-creation-dms.json new file mode 100644 index 00000000..10ee0ed9 --- /dev/null +++ b/cypress/fixtures/b2c-mp/mp/marketplace-order-management/static-order-creation-dms.json @@ -0,0 +1,16 @@ +{ + "defaultPassword": "change123", + "store": { + "name": "TEST_STORE", + "currency": "EUR", + "locale": "en_US", + "country": "DE", + "timezone": "Europe/Berlin" + }, + "paymentMethods": [ + { + "key": "dummyMarketplacePaymentInvoice", + "name": "Dummy Marketplace Payment" + } + ] +} diff --git a/cypress/fixtures/b2c-mp/mp/marketplace-order-management/static-order-creation.json b/cypress/fixtures/b2c-mp/mp/marketplace-order-management/static-order-creation.json new file mode 100644 index 00000000..ba4339e8 --- /dev/null +++ b/cypress/fixtures/b2c-mp/mp/marketplace-order-management/static-order-creation.json @@ -0,0 +1,3 @@ +{ + "defaultPassword": "change123" +} diff --git a/cypress/fixtures/b2c/backoffice/order-management/dynamic-order-creation-dms.json b/cypress/fixtures/b2c/backoffice/order-management/dynamic-order-creation-dms.json new file mode 100644 index 00000000..ecda2ee0 --- /dev/null +++ b/cypress/fixtures/b2c/backoffice/order-management/dynamic-order-creation-dms.json @@ -0,0 +1,103 @@ +{ + "data": { + "type": "dynamic-fixtures", + "attributes": { + "synchronize": true, + "operations": [ + { + "type": "transfer", + "name": "StoreTransfer", + "key": "store", + "arguments": { "id_store": 1 } + }, + { + "type": "transfer", + "name": "LocaleTransfer", + "key": "locale", + "arguments": { "id_locale": 66, "locale_name": "en_US" } + }, + { + "type": "helper", + "name": "haveCountry", + "key": "country" + }, + { + "type": "helper", + "name": "haveCustomer", + "key": "customer", + "arguments": [{ "locale": "#locale", "password": "change123" }] + }, + { + "type": "helper", + "name": "haveCustomerAddress", + "key": "address", + "arguments": [{ "fkCustomer": "#customer.id_customer", "fkCountry": "#country.id_country" }] + }, + { + "type": "helper", + "name": "confirmCustomer", + "key": "confirmedCustomer", + "arguments": ["#customer"] + }, + { + "type": "helper", + "name": "haveFullProduct", + "key": "product", + "arguments": [{}, { "idTaxSet": 1 }] + }, + { + "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": "haveProductImageSet", + "arguments": [ + { + "name": "default", + "idProduct": "#product.id_product_concrete", + "idProductAbstract": "#product.fk_product_abstract", + "productImages": ["#productImage"] + } + ] + }, + { + "type": "helper", + "name": "havePriceProduct", + "key": "productWithPrice", + "arguments": [ + { + "skuProductAbstract": "#product.abstract_sku", + "skuProduct": "#product.sku", + "moneyValue": { + "netAmount": 50000, + "grossAmount": 50000 + } + } + ] + }, + { + "type": "helper", + "name": "haveProductInStock", + "arguments": [{ "sku": "#product.sku", "isNeverOutOfStock": "1", "fkStock": 1, "stockType": "Warehouse1" }] + }, + { + "type": "helper", + "name": "haveUser", + "key": "rootUser", + "arguments": [{ "password": "change123" }] + }, + { + "type": "helper", + "name": "addUserToGroup", + "arguments": ["#rootUser.id_user", 1] + } + ] + } + } +} diff --git a/cypress/fixtures/b2c/backoffice/order-management/static-order-creation-dms.json b/cypress/fixtures/b2c/backoffice/order-management/static-order-creation-dms.json new file mode 100644 index 00000000..c195d51c --- /dev/null +++ b/cypress/fixtures/b2c/backoffice/order-management/static-order-creation-dms.json @@ -0,0 +1,16 @@ +{ + "defaultPassword": "change123", + "store": { + "name": "TEST_STORE", + "currency": "EUR", + "locale": "en_US", + "country": "DE", + "timezone": "Europe/Berlin" + }, + "paymentMethods": [ + { + "key": "dummyPaymentInvoice", + "name": "Invoice" + } + ] +} diff --git a/cypress/support/scenarios/backoffice/setup-default-store-relations-scenario.ts b/cypress/support/scenarios/backoffice/setup-default-store-relations-scenario.ts index 1b689fbe..a1015afe 100644 --- a/cypress/support/scenarios/backoffice/setup-default-store-relations-scenario.ts +++ b/cypress/support/scenarios/backoffice/setup-default-store-relations-scenario.ts @@ -34,7 +34,7 @@ export class SetupDefaultStoreRelationsScenario { paymentMethods: params.paymentMethods, }); - if (['suite'].includes(Cypress.env('repositoryId'))) { + if (['suite', 'b2c-mp'].includes(Cypress.env('repositoryId'))) { this.assignStoreToDefaultShipmentTypesScenario.execute({ store: params.storeName, username: params.rootUser.username, From c4377bbcb594f088a89f9ed52ebb44dfaec6137b Mon Sep 17 00:00:00 2001 From: Dmytro Asieiev Date: Wed, 11 Dec 2024 09:17:47 +0300 Subject: [PATCH 4/4] Added retry to before hook to fix flaky tests. --- .../order-management/order-creation-dms.cy.ts | 3 ++- cypress/support/e2e.ts | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/backoffice/order-management/order-creation-dms.cy.ts b/cypress/e2e/backoffice/order-management/order-creation-dms.cy.ts index 94c405f5..7f1f51ae 100644 --- a/cypress/e2e/backoffice/order-management/order-creation-dms.cy.ts +++ b/cypress/e2e/backoffice/order-management/order-creation-dms.cy.ts @@ -10,6 +10,7 @@ import { SetupDefaultStoreRelationsScenario, } from '@scenarios/backoffice'; import { SalesDetailPage, SalesIndexPage } from '@pages/backoffice'; +import { retryableBefore } from '../../../support/e2e'; describeIfDynamicStoreEnabled( 'order creation dms', @@ -32,7 +33,7 @@ describeIfDynamicStoreEnabled( let staticFixtures: OrderManagementDmsStaticFixtures; let dynamicFixtures: OrderCreationDmsDynamicFixtures; - before((): void => { + retryableBefore((): void => { ({ staticFixtures, dynamicFixtures } = Cypress.env()); userLoginScenario.execute({ diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts index 3393a158..9341bb3a 100644 --- a/cypress/support/e2e.ts +++ b/cypress/support/e2e.ts @@ -26,6 +26,25 @@ before(() => { loadFixture(); }); +// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-function-return-type +export const retryableBefore = (fn: any) => { + let shouldRun = true; + + beforeEach(() => { + if (!shouldRun) return; + shouldRun = false; + fn(); + }); + + Cypress.on('test:after:run', (result) => { + if (result.state === 'failed') { + if (result.currentRetry < result.retries) { + shouldRun = true; + } + } + }); +}; + const loadFixture = (): void => { const currentSuite = Cypress.mocha.getRunner().suite.suites[0]; if (currentSuite.title.includes('[skip]')) {