diff --git a/.eslintrc.json b/.eslintrc.json index 31ecec4f6..5bbfa7344 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -11,7 +11,6 @@ { "allowCircularSelfDependency": true, "enforceBuildableLibDependency": true, - "allow": ["fulfillment"], "depConstraints": [ { "sourceTag": "layer:domain", diff --git a/apps/fulfillment-e2e/.env.template b/apps/fulfillment-e2e/.env.template deleted file mode 100644 index e69de29bb..000000000 diff --git a/apps/fulfillment-e2e/.eslintrc.json b/apps/fulfillment-e2e/.eslintrc.json deleted file mode 100644 index 8be4d9dfb..000000000 --- a/apps/fulfillment-e2e/.eslintrc.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": ["../../.eslintrc.e2e.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - } - ] -} diff --git a/apps/fulfillment-e2e/cypress.ci.config.js b/apps/fulfillment-e2e/cypress.ci.config.js deleted file mode 100644 index da84e7241..000000000 --- a/apps/fulfillment-e2e/cypress.ci.config.js +++ /dev/null @@ -1,8 +0,0 @@ -const { defineConfig } = require('cypress'); -const config = require('./cypress.config'); - -module.exports = defineConfig({ - ...config, - projectId: 'bxiyv4', - retries: 1, -}); diff --git a/apps/fulfillment-e2e/cypress.config.js b/apps/fulfillment-e2e/cypress.config.js deleted file mode 100644 index e19fa8c17..000000000 --- a/apps/fulfillment-e2e/cypress.config.js +++ /dev/null @@ -1,30 +0,0 @@ -const { defineConfig } = require('cypress'); -require('dotenv').config(); - -module.exports = defineConfig({ - fileServerFolder: '.', - fixturesFolder: './src/fixtures', - modifyObstructiveCode: false, - watchForFileChanges: false, - video: true, - videosFolder: '../../dist/cypress/apps/fulfillment-e2e/videos', - screenshotsFolder: '../../dist/cypress/apps/fulfillment-e2e/screenshots', - chromeWebSecurity: false, - includeShadowDom: true, - pageLoadTimeout: 180000, - viewportWidth: 414, - viewportHeight: 844, - redirectionLimit: 100, - e2e: { - baseUrl: 'http://localhost:4200', - specPattern: './src/integration/*.cy.{js,jsx,ts,tsx}', - supportFile: './src/support/index.ts', - experimentalOriginDependencies: true, - }, - env: { - glueApiUrl: 'https://api.de.demo-picking-app.cloud.spryker.toys', - backofficeUrl: 'https://backoffice.de.demo-picking-app.cloud.spryker.toys', - backofficeApiUrl: - 'https://backend-api.de.demo-picking-app.cloud.spryker.toys', - }, -}); diff --git a/apps/fulfillment-e2e/project.json b/apps/fulfillment-e2e/project.json deleted file mode 100644 index 30604ddd4..000000000 --- a/apps/fulfillment-e2e/project.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "fulfillment-e2e", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "apps/fulfillment-e2e/src", - "projectType": "application", - "targets": { - "e2e": { - "executor": "@nrwl/cypress:cypress", - "options": { - "browser": "chrome", - "cypressConfig": "apps/fulfillment-e2e/cypress.config.js", - "watch": true, - "testingType": "e2e" - }, - "configurations": { - "headless": { - "watch": false - }, - "headless-ci": { - "cypressConfig": "apps/fulfillment-e2e/cypress.ci.config.js", - "watch": false, - "record": true, - "group": "fa-regression" - } - } - }, - "lint": { - "executor": "@nrwl/linter:eslint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["apps/fulfillment-e2e/**/*.{js,ts}"] - } - } - }, - "tags": ["root"], - "implicitDependencies": ["fulfillment"] -} diff --git a/apps/fulfillment-e2e/readme.md b/apps/fulfillment-e2e/readme.md deleted file mode 100644 index b40b48770..000000000 --- a/apps/fulfillment-e2e/readme.md +++ /dev/null @@ -1,11 +0,0 @@ -## First run - -To run E2E tests locally you have to create `.env.local` file first. -Use `.env.template` as an example. - -## Fulfillment E2E tests commands - -1. `npm run fa:e2e:open` - opens Cypress runner; useful for E2E tests development and debug -2. `npm run fa:e2e:headless` - runs tests locally in headless mode -3. `npm run fa:e2e:headless:ci` - runs tests on CI in headless mode (won't work locally, because it uses Cypress Cloud which is available only on CI servers) -4. `npm run fa:e2e:headless:ci:affected` - used for CI optimization. Will run tests only if fulfillment or fulfillment-e2e project were affected in PR diff --git a/apps/fulfillment-e2e/src/component/customer-note.cy.ts b/apps/fulfillment-e2e/src/component/customer-note.cy.ts deleted file mode 100644 index 9efb51409..000000000 --- a/apps/fulfillment-e2e/src/component/customer-note.cy.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { CustomerNoteModalFragment } from '../support/page_fragments/customer-note-modal.fragment'; -import { ListsFragment } from '../support/page_fragments/lists.fragment'; - -const listsFragment = new ListsFragment(); -const customerNoteFragment = new CustomerNoteModalFragment(); - -// TODO: this is not E2E, these are component tests -xdescribe('Customer note suite', () => { - beforeEach(() => { - cy.clearIndexedDB(); - cy.login(); - }); - - // TODO: test requires an order with customer note which is not supported by Glue - it('should show and hide the customer note modal', () => { - // open - listsFragment.getCustomerNoteButtons().click(); - customerNoteFragment.getModal().should('be.visible'); - - // close - customerNoteFragment.getCloseButton().click(); - customerNoteFragment.getModal().should('not.be.visible'); - }); -}); diff --git a/apps/fulfillment-e2e/src/component/filters.cy.ts b/apps/fulfillment-e2e/src/component/filters.cy.ts deleted file mode 100644 index 25818bc50..000000000 --- a/apps/fulfillment-e2e/src/component/filters.cy.ts +++ /dev/null @@ -1,116 +0,0 @@ -import { FiltersFragment } from '../support/page_fragments/filters.fragment'; - -const filtersFragment = new FiltersFragment(); - -// TODO: this is not E2E, these are component tests -xdescribe('When user interacts with the filters', () => { - beforeEach(() => { - cy.clearIndexedDB(); - cy.login(); - cy.cleanupPickings(); - - // create picking #1 - cy.createPicking().then((orderId) => { - cy.receiveData(); - cy.waitForPickingToAppear(orderId); - }); - - // create picking #2 - cy.createPicking().then((orderId) => { - cy.receiveData(); - cy.waitForPickingToAppear(orderId); - }); - }); - - describe('And filters is closed', () => { - // TODO: it is very hard to understand what is being tested here - // it is not an e2e test but a component test - // it this test fails in CI - you will never know what caused the failure - it('should reset unapplied changes', () => { - //check whether default configuration is applied - filtersFragment.getFilterButtonTrigger().should('not.be.checked'); - - // TODO: refactor methods with boolean flags that change behavior - // https://softwareengineering.stackexchange.com/questions/147977/is-it-wrong-to-use-a-boolean-parameter-to-determine-behavior - filtersFragment.shouldChangePickingListsOrder(false); - - filtersFragment.getFilterButtonTrigger().click(); - - //should open the filters modal - filtersFragment.getFiltersModal().should('be.visible'); - //should have default selected sorting option - filtersFragment.getSortingOption(0).should('be.checked'); - - //When close button is clicked - filtersFragment.getSortingOption(1).click(); - filtersFragment.getSortingOption(1).should('be.checked'); - - filtersFragment.getFiltersCloseButton().click(); - - //should close the modal - filtersFragment.getFiltersModal().should('not.be.visible'); - - //should not make sort button active - filtersFragment.getFilterButtonTrigger().should('not.be.checked'); - - //should reset the form - filtersFragment.getSortingOption(0).should('be.checked'); - - //should not change the order - filtersFragment.shouldChangePickingListsOrder(false); - }); - }); - - // TODO: it is not an e2e test but a component test - describe('And filters are applied', () => { - [ - { option: 'Latest pickup time', shouldChangesTheOrder: true }, - { option: 'Largest order size', shouldChangesTheOrder: false }, - { option: 'Smallest order size', shouldChangesTheOrder: true }, - ].forEach(({ option, shouldChangesTheOrder }, index) => { - it(`should sort by: ${option}`, () => { - filtersFragment.getFilterButtonTrigger().click(); - - filtersFragment.getSortingOption(index + 1).click(); - - filtersFragment.getFiltersApplyButton().click(); - - //should close the modal - filtersFragment.getFiltersModal().should('not.be.visible'); - - //should apply sorting order - // TODO: method name is confusing + boolean param again - filtersFragment.shouldChangePickingListsOrder(shouldChangesTheOrder); - - //should make sort button active - filtersFragment.getFilterButtonTrigger().should('be.checked'); - }); - }); - }); - - // TODO: it is not an e2e test but a component test - describe('And preselected filters are reset', () => { - it('should restore default sorting configuration', () => { - filtersFragment.getFilterButtonTrigger().click(); - - //preselects second sorting option - filtersFragment.getSortingOption(1).click(); - filtersFragment.getFiltersApplyButton().click(); - filtersFragment.getFilterButtonTrigger().click(); - - filtersFragment.getFiltersResetButton().click(); - - //should close the modal - filtersFragment.getFiltersModal().should('not.be.visible'); - - //should not make sort button active - filtersFragment.getFilterButtonTrigger().should('not.be.checked'); - - //should reset the form - filtersFragment.getSortingOption(0).should('be.checked'); - - //should not change the order - filtersFragment.shouldChangePickingListsOrder(false); - }); - }); -}); diff --git a/apps/fulfillment-e2e/src/component/header-no-customer-note.cy.ts b/apps/fulfillment-e2e/src/component/header-no-customer-note.cy.ts deleted file mode 100644 index 8e5f77a08..000000000 --- a/apps/fulfillment-e2e/src/component/header-no-customer-note.cy.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { PickerHeaderFragment } from '../support/page_fragments/picker-header.fragment'; -import { PickingPage } from '../support/page_objects/picking.page'; - -// TODO: hardcoded values from removed mock server -const pickingListId = 'd5bf20f1-7f36-568d-85b5-e4502acbcc82'; -const pickerPage = new PickingPage(pickingListId); -const pickerHeaderFragment = new PickerHeaderFragment(); - -// TODO: this is not E2E, these are component tests -xdescribe('picking header with no customer note', () => { - beforeEach(() => { - cy.clearIndexedDB(); - cy.login(); - - pickerPage.visit(); - }); - - it('should not display customer note icon', () => { - pickerHeaderFragment.getCustomerNoteIcon().should('not.exist'); - }); -}); diff --git a/apps/fulfillment-e2e/src/component/lists-search.cy.ts b/apps/fulfillment-e2e/src/component/lists-search.cy.ts deleted file mode 100644 index a2327ce48..000000000 --- a/apps/fulfillment-e2e/src/component/lists-search.cy.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { HeaderFragment } from '../support/page_fragments/lists-header.fragment'; -import { ListsFragment } from '../support/page_fragments/lists.fragment'; -import { UserProfileModal } from '../support/page_fragments/user-profile-modal.fragment'; - -const listsFragment = new ListsFragment(); -const headerFragment = new HeaderFragment(); -const userProfileFragment = new UserProfileModal(); - -// TODO: this is a component (unit) test, not E2E -// search is purely FE-based feature -xdescribe('Picking Lists Search', () => { - beforeEach(() => { - cy.clearIndexedDB(); - cy.login(); - cy.cleanupPickings(); - cy.createPicking().then((orderId) => { - cy.receiveData(); - cy.waitForPickingToAppear(orderId); - }); - - headerFragment.openSearch(); - }); - - it('should show correct picking items after search', () => { - verifyDefaultState(); - verifyStateAfterInput(); - vefiryStateAfterCleanup(); - vefifyInvalidSearch(); - verifySearchBackButton(); - vefityUserProfileButton(); - }); -}); - -function verifyDefaultState() { - listsFragment.getWrapper().should('be.visible'); - headerFragment.getSearchInput().should('be.visible'); - listsFragment.getNoItemsFallbackHeading().should('be.visible'); - listsFragment.getStartSearchingFallbackImage().should('be.visible'); -} - -function verifyStateAfterInput() { - // first letter -> no search performed - headerFragment.getSearchInput().type('D', { force: true }); - listsFragment.getNoItemsFallbackHeading().should('be.visible'); - listsFragment.getStartSearchingFallbackImage().should('be.visible'); - - // second letter -> searching... - headerFragment.getSearchInput().type('E', { force: true }); - listsFragment.getPickingListsItems().should('have.length.at.least', 1); -} - -function vefiryStateAfterCleanup() { - headerFragment.getSearchClearButton().click(); - listsFragment.getNoItemsFallbackHeading().should('be.visible'); - listsFragment.getStartSearchingFallbackImage().should('be.visible'); -} - -function vefifyInvalidSearch() { - headerFragment.getSearchInput().type('something', { force: true }); - listsFragment.getNoItemsFallbackHeading().should('be.visible'); - listsFragment.getNoPickingResultsFallbackImage().should('be.visible'); -} - -function verifySearchBackButton() { - headerFragment.getSearchBackButton().click(); - listsFragment.getNoItemsFallback().should('not.exist'); - headerFragment.getTitle().should('be.visible'); - listsFragment.getPickingListsItems().should('have.length.at.least', 1); -} - -function vefityUserProfileButton() { - headerFragment.getUserIcon().should('be.visible').click(); - userProfileFragment.getWrapper().should('be.visible'); -} diff --git a/apps/fulfillment-e2e/src/component/start-picking-list-in-progress.cy.ts b/apps/fulfillment-e2e/src/component/start-picking-list-in-progress.cy.ts deleted file mode 100644 index 21d2de857..000000000 --- a/apps/fulfillment-e2e/src/component/start-picking-list-in-progress.cy.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { CustomerNoteFragment } from '../support/page_fragments/customer-note.fragment'; -import { ListsFragment } from '../support/page_fragments/lists.fragment'; - -const listsFragment = new ListsFragment(); -const customerNoteFragment = new CustomerNoteFragment(); - -// TODO: this is not E2E, these are component tests -xdescribe('pick a picking list in progress', () => { - beforeEach(() => { - cy.login(); - - // TODO: remove mock - cy.mockPickingInProgress(); - - // open first picking which is mocked as In Progress - listsFragment.getStartPickingButtons().eq(0).click(); - // safe the url - cy.location('pathname').as('openedPickingUrl'); - // wait for event handlers initialization - // we can't remove this wait in current implementation because we can't detect - // if handler was set successfully - // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(500); - // open Picking in progress modal - customerNoteFragment.getProceedToPickingButton().click(); - }); - - it('should stay on the same page and show modal', () => { - cy.get('@openedPickingUrl').then((url) => { - cy.location('pathname').should('be.equal', url); - }); - - listsFragment.pickingInProgressModal.getModal().should('be.visible'); - }); - - describe('and picking in progress modal is closed', () => { - beforeEach(() => { - listsFragment.pickingInProgressModal.getCloseButton().click(); - }); - - it('should hide modal and navigate back to the picking list', () => { - listsFragment.pickingInProgressModal.getModal().should('not.be.visible'); - - cy.location('pathname').should('be.equal', '/'); - listsFragment.getPickingListsItems().should('be.visible'); - }); - }); -}); diff --git a/apps/fulfillment-e2e/src/component/start-picking-list-with-customer-note.cy.ts b/apps/fulfillment-e2e/src/component/start-picking-list-with-customer-note.cy.ts deleted file mode 100644 index d6411f668..000000000 --- a/apps/fulfillment-e2e/src/component/start-picking-list-with-customer-note.cy.ts +++ /dev/null @@ -1,169 +0,0 @@ -import { CustomerNoteFragment } from '../support/page_fragments/customer-note.fragment'; -import { DiscardModalFragment } from '../support/page_fragments/discard-modal.fragment'; -import { ListsFragment } from '../support/page_fragments/lists.fragment'; -import { PickerHeaderFragment } from '../support/page_fragments/picker-header.fragment'; -import { PickerFragment } from '../support/page_fragments/picker.fragment'; - -const listsFragment = new ListsFragment(); -const customerNoteFragment = new CustomerNoteFragment(); -const pickerHeaderFragment = new PickerHeaderFragment(); -const discardModalFragment = new DiscardModalFragment(); - -// TODO: this is not E2E, these are component tests -describe('Start picking a picklist with customer note', () => { - beforeEach(() => { - cy.clearIndexedDB(); - cy.login(); - - listsFragment.getStartPickingButtons().eq(0).click(); - }); - - it('check Customer Note page', () => { - // should display customer note - customerNoteFragment - .getNote() - .should('be.visible') - // TODO: hardcoded data - .and('contain', 'Some cart note'); - - // should display “Customer note” headline - customerNoteFragment.getHeadline().should('contain', 'Customer note'); - - // should display illustration - customerNoteFragment - .getIllustration() - .should('be.visible') - .and('have.attr', 'resource', 'user-note'); - - // should display “Proceed to picking” button - customerNoteFragment.getProceedToPickingButton().should('be.visible'); - - // should display back button - customerNoteFragment.getNavigateBackButton().should('be.visible'); - - //should navigate to Picking Lists page - customerNoteFragment.getNavigateBackButton().click(); - cy.location('pathname').should('be.eq', `/`); - }); - - describe('and “Proceed to picking” button is clicked', () => { - const pickingFragment = new PickerFragment(); - beforeEach(() => { - customerNoteFragment.getProceedToPickingButton().should('be.visible'); - // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(1000); - customerNoteFragment.getProceedToPickingButton().click(); - }); - - // TODO: this test checks too many areas of the application - // everything here should be covered by component tests - it('check Picking page', () => { - // should display tabs - pickingFragment.getTabs().should('be.visible'); - - // should display three tabs - pickingFragment.getTabsList().should('have.length', 3); - pickingFragment.getTabsList().eq(0).should('contain.text', 'Not Picked'); - pickingFragment.getTabsList().eq(1).should('contain.text', 'Picked'); - pickingFragment.getTabsList().eq(2).should('contain.text', 'Not Found'); - - // See discard modal by clicking on back button - // Due to a cypress bug https://github.com/cypress-io/cypress/issues/26905, - // the only meaningful way to check visibility is in the slots. - discardModalFragment.getContent().should('not.be.visible'); - pickerHeaderFragment.getBackButton().click(); - discardModalFragment.getContent().should('be.visible'); - - // should hide discard modal - discardModalFragment.getCancelButton().click(); - discardModalFragment.getContent().should('not.be.visible'); - cy.location('pathname').should('to.match', /^\/picking-list/); - - // should navigate back - pickerHeaderFragment.getBackButton().click(); - discardModalFragment.getDiscardButton().click(); - cy.location('pathname').should('to.match', /^\/customer-note-info/); - - // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(1000); - customerNoteFragment.getProceedToPickingButton().click(); - - // See discard modal by clicking on browser back button - discardModalFragment.getContent().should('not.be.visible'); - cy.go('back'); - discardModalFragment.getContent().should('be.visible'); - - // should hide discard modal - discardModalFragment.getCancelButton().click(); - discardModalFragment.getContent().should('not.be.visible'); - cy.location('pathname').should('to.match', /^\/picking-list/); - - // should navigate back - cy.go('back'); - discardModalFragment.getDiscardButton().click(); - cy.location('pathname').should('to.match', /^\/customer-note-info/); - - // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(1000); - customerNoteFragment.getProceedToPickingButton().click(); - - // should display "Not picked" as selected - pickingFragment.getTabsList().eq(0).should('have.attr', 'selected'); - - // should display correct products number in chip - pickingFragment.getProducts().then((products) => { - pickingFragment - .getTabCounter(pickingFragment.getTabsList().eq(0)) - .should('contain.text', products.length); - }); - - // should display at least one product for picking - pickingFragment.getProducts().should('have.length.at.least', 1); - }); - }); - - describe('and picking is already in progress', () => { - beforeEach(() => { - // TODO: remove mock - cy.mockPickingInProgress(); - - customerNoteFragment.getProceedToPickingButton().should('be.visible'); - // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(1000); - customerNoteFragment.getProceedToPickingButton().click(); - }); - - // TODO: component test - it('should show modal and stay on the same page', () => { - cy.location('pathname').should('to.match', /^\/customer-note-info/); - customerNoteFragment.pickingInProgressModal - .getModal() - .should('have.attr', 'open'); - customerNoteFragment.pickingInProgressModal - .getModal() - .should('contain.text', 'Already in progress'); - }); - - // TODO: component test - describe('and modal is dismissed', () => { - beforeEach(() => { - customerNoteFragment.pickingInProgressModal.getOverlay().click(); - }); - - it('should stay on the same page', () => { - cy.location('pathname').should('to.match', /^\/customer-note-info/); - }); - }); - - // TODO: unit test - describe('and picking in progress modal is closed', () => { - beforeEach(() => { - customerNoteFragment.pickingInProgressModal.getCloseButton().click(); - }); - - it('should redirect to picking list page', () => { - cy.location('pathname').should('be.equal', '/'); - }); - }); - }); -}); diff --git a/apps/fulfillment-e2e/src/component/user-profile.cy.ts b/apps/fulfillment-e2e/src/component/user-profile.cy.ts deleted file mode 100644 index 2012e5e9d..000000000 --- a/apps/fulfillment-e2e/src/component/user-profile.cy.ts +++ /dev/null @@ -1,124 +0,0 @@ -// TODO: Turned off because there are errors in imports -// In any case - the whole file should be rewritten - -// import { ListsHeaderFragment } from '../support/page_fragments/lists-header.fragment'; -// import { ListsFragment } from '../support/page_fragments/lists.fragment'; -// import { PickerHeaderFragment } from '../support/page_fragments/picker-header.fragment'; -// import { UserProfileFragment } from '../support/page_fragments/user-profile-modal.fragment'; -// import { LoginPage } from '../support/page_objects/login.page'; - -// const listsFragment = new ListsFragment(); -// const userProfileFragment = new UserProfileFragment(); -// const loginPage = new LoginPage(); -// const pickerHeaderFragment = new PickerHeaderFragment(); -// const listsHeaderFragment = new ListsHeaderFragment(); - -// // TODO: this is not E2E, these are component tests -// xdescribe('When a user opens the user profile modal', () => { -// beforeEach(() => { -// cy.clearIndexedDB(); -// cy.login(); -// listsHeaderFragment.getUserIcon().click(); -// }); - -// it('should display modal', () => { -// userProfileFragment.getWrapper().should('be.visible'); -// userProfileFragment.getLogOutButton().should('be.visible'); -// userProfileFragment.getNotification().should('not.exist'); -// }); - -// describe('and sync is pending', () => { -// beforeEach(() => { -// cy.mockSyncPending(); -// cy.visit('/'); - -// listsHeaderFragment.getUserIcon().click(); -// }); - -// it('should show message and disable log out button', () => { -// userProfileFragment.getLogOutButton().should('have.attr', 'disabled'); -// userProfileFragment.getNotification().should('be.visible'); -// userProfileFragment -// .getNotification() -// .should( -// 'contain.text', -// `You can't log out because of a pending synchronization` -// ); -// }); -// }); - -// describe('and picking is in progress', () => { -// beforeEach(() => { -// cy.createPicking().then((orderId) => { -// cy.visit('/'); -// cy.waitForPickingToAppear(orderId); -// }); - -// userProfileFragment.getCloseButton().click(); -// listsFragment.getStartPickingButtons().eq(0).click(); - -// pickerHeaderFragment.getUserIcon().click(); -// }); - -// it('should show message and disable log out button', () => { -// userProfileFragment.getLogOutButton().should('have.attr', 'disabled'); -// userProfileFragment.getNotification().should('be.visible'); -// userProfileFragment -// .getNotification() -// .should( -// 'contain.text', -// `You can't log out because picking is in progress` -// ); -// userProfileFragment.getReceiveDataButton().should('not.exist'); -// }); -// }); - -// describe.only('and sync is pending and picking is in progress', () => { -// beforeEach(() => { -// cy.createPicking().then((orderId) => { -// cy.mockSyncPending(); -// cy.visit('/'); -// cy.waitForPickingToAppear(orderId); - -// listsFragment.getStartPickingButtons().eq(0).click(); -// pickerHeaderFragment.getUserIcon().click(); -// }); -// }); - -// it('should show picking in progress message and disable log out button', () => { -// userProfileFragment.getLogOutButton().should('have.attr', 'disabled'); -// userProfileFragment.getNotification().should('be.visible'); -// userProfileFragment -// .getNotification() -// .should( -// 'contain.text', -// `You can't log out because picking is in progress` -// ); -// userProfileFragment.getReceiveDataButton().should('not.exist'); -// }); -// }); - -// describe('when receive data button is clicked', () => { -// beforeEach(() => { -// cy.intercept('POST', /.+\/picking-lists\/.+\/start-picking$/).as( -// 'startPicking' -// ); - -// userProfileFragment.getCloseButton().click(); -// listsFragment.getStartPickingButtons().eq(1).click(); -// cy.wait('@startPicking', { timeout: 30000 }); -// cy.visit('/'); -// listsFragment.getPickingListsItems().should('have.length', 1); -// listsHeaderFragment.getUserIcon().click(); -// userProfileFragment.getWrapper().should('be.visible'); -// userProfileFragment.getReceiveDataButton().click(); -// }); - -// it('should receive data', () => { -// userProfileFragment.getWrapper().should('not.be.visible'); -// cy.location('pathname').should('not.to.match', /^\/login/); -// loginPage.getWrapper().should('not.exist'); -// listsFragment.getPickingListsItems().should('have.length', 2); -// }); -// }); -// }); diff --git a/apps/fulfillment-e2e/src/component/warehouse-selection.cy.ts b/apps/fulfillment-e2e/src/component/warehouse-selection.cy.ts deleted file mode 100644 index da02d0935..000000000 --- a/apps/fulfillment-e2e/src/component/warehouse-selection.cy.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { PickingListPage } from '../support/page_objects/picking-list.page'; -import { WarehouseSelectionPage } from '../support/page_objects/warehouse-selection.page'; - -let whSelectionPage: WarehouseSelectionPage; - -// TODO: this is not E2E, these are component tests -xdescribe('Warehouse selection suite', () => { - beforeEach(() => { - whSelectionPage = new WarehouseSelectionPage(); - - cy.clearIndexedDB(); - cy.login(); - whSelectionPage.visit(); - }); - - // TODO: this check is covered already in Auth flows, we don't need to have it in E2Es - // but we can have it in component tests - it('should navigate to picking lists after warehouse selection', () => { - verifyWarehouseListVisibility(); - - const pickListsPage = new PickingListPage(); - - whSelectionPage.selectByEq(0); - pickListsPage.waitForLoaded(); - }); -}); - -function verifyWarehouseListVisibility() { - whSelectionPage.getWrapper().should('be.visible'); - whSelectionPage.getNames().should('have.length.gt', 0); - whSelectionPage.getSelectBtns().should('have.length.gt', 0); -} diff --git a/apps/fulfillment-e2e/src/integration/auth.cy.ts b/apps/fulfillment-e2e/src/integration/auth.cy.ts deleted file mode 100644 index 70ab1b52b..000000000 --- a/apps/fulfillment-e2e/src/integration/auth.cy.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { defaultUser } from '../support/commands'; -import { HeaderFragment } from '../support/page_fragments/lists-header.fragment'; -import { LoadingPage } from '../support/page_objects/loading.page'; -import { LoginPage } from '../support/page_objects/login.page'; -import { PickingListPage } from '../support/page_objects/picking-list.page'; -import { WarehouseSelectionPage } from '../support/page_objects/warehouse-selection.page'; - -const loginPage = new LoginPage(); -const oauthPage = new LoadingPage(); -const header = new HeaderFragment(); - -describe('Login Suite', () => { - beforeEach(() => { - cy.clearIndexedDB(); - }); - - it('should redirect to login page, login and logout successfully', () => { - const warehouseSelectionPage = new WarehouseSelectionPage(); - const pickingListPage = new PickingListPage(); - - // redirect - cy.visit('/'); - verifyLoginPageRedirect(); - - // login - loginPage.login(defaultUser); - verifyOauthPageRedirect(); - warehouseSelectionPage.waitForLoaded(); - warehouseSelectionPage.selectByEq(0); - pickingListPage.waitForLoaded(); - - // logout - header.openUserProfileModal(); - header.getUserProfileModal().logout(); - verifyLoginPageRedirect(); - }); - - it('should display error notification when credentials are not valid', () => { - loginPage.visit(); - loginPage.loginForm.login({ - email: 'admin@spryker.com', - password: '123abc', - warehouseName: '123', - }); - - cy.location('pathname').should('match', /^\/login/); - loginPage.getErrorNotification().should('be.visible'); - }); -}); - -function verifyLoginPageRedirect() { - cy.location('pathname').should('to.match', /^\/login/); - loginPage.getWrapper().should('be.visible'); -} - -function verifyOauthPageRedirect() { - cy.location('pathname').should('match', /^\/oauth/); - oauthPage.getWrapper().should('be.visible'); -} diff --git a/apps/fulfillment-e2e/src/integration/full-picking.cy.ts b/apps/fulfillment-e2e/src/integration/full-picking.cy.ts deleted file mode 100644 index 242c22212..000000000 --- a/apps/fulfillment-e2e/src/integration/full-picking.cy.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { PickingListPage } from '../support/page_objects/picking-list.page'; -import { PickingPage } from '../support/page_objects/picking.page'; - -let pickingListPage; - -describe('Fully pick a picking list', () => { - beforeEach(() => { - pickingListPage = new PickingListPage(); - - cy.clearIndexedDB(); - cy.login(); - cy.cleanupPickings(); - cy.createPicking().then((orderId) => { - cy.receiveData(); - cy.waitForPickingToAppear(orderId); - - pickingListPage.startPickingByEq(0); - }); - }); - - it('must pick all products successfully', () => { - const pickingPage = new PickingPage(); - - pickingPage.pickAllProducts(); - pickingPage.finishPicking(); - - cy.location('pathname').should('be.eq', `/`); - pickingListPage.getPickingListItems().should('have.length', 0); - }); -}); diff --git a/apps/fulfillment-e2e/src/integration/partial-picking.cy.ts b/apps/fulfillment-e2e/src/integration/partial-picking.cy.ts deleted file mode 100644 index 65bd4fb33..000000000 --- a/apps/fulfillment-e2e/src/integration/partial-picking.cy.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { PickingListPage } from '../support/page_objects/picking-list.page'; -import { PickingPage } from '../support/page_objects/picking.page'; - -let pickingListPage; - -describe('Partial pick a picking list', () => { - beforeEach(() => { - pickingListPage = new PickingListPage(); - - cy.clearIndexedDB(); - cy.login(); - cy.cleanupPickings(); - cy.createPicking(2).then((orderId) => { - cy.receiveData(); - cy.waitForPickingToAppear(orderId); - - pickingListPage.startPickingByEq(0); - }); - }); - - it('must pick all products successfully', () => { - const pickingPage = new PickingPage(); - - pickingPage.pickAllProducts(); - pickingPage.finishPicking(); - - cy.location('pathname').should('be.eq', `/`); - pickingListPage.getPickingListItems().should('have.length', 0); - }); -}); diff --git a/apps/fulfillment-e2e/src/integration/picking-lists.cy.ts b/apps/fulfillment-e2e/src/integration/picking-lists.cy.ts deleted file mode 100644 index a86a8a3a0..000000000 --- a/apps/fulfillment-e2e/src/integration/picking-lists.cy.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { Interception } from 'node_modules/cypress/types/net-stubbing'; -import { HeaderFragment } from '../support/page_fragments/lists-header.fragment'; -import { ListsFragment } from '../support/page_fragments/lists.fragment'; - -const listsFragment = new ListsFragment(); -const headerFragment = new HeaderFragment(); - -describe('Picking Lists', () => { - beforeEach(() => { - cy.clearIndexedDB(); - cy.login(); - - cy.get('@picking-lists').then( - (interception: Interception) => { - const pickings = interception.response.body.data; - const visiblePickings = pickings.filter( - (picking) => picking.attributes.status === 'ready-for-picking' - ); - - if (!visiblePickings.length) { - cy.createPicking().then((orderId) => { - cy.receiveData(); - cy.waitForPickingToAppear(orderId); - }); - } - } - ); - }); - - it('should display picking lists', () => { - headerFragment.getSearchIcon().should('be.visible'); - headerFragment.getUserIcon().should('be.visible'); - - listsFragment.getSortButton().should('be.visible'); - listsFragment.getWrapper().should('be.visible'); - - listsFragment.getPickingListsItems().should('be.visible'); - }); -}); diff --git a/apps/fulfillment-e2e/src/support/backoffice-api/backoffice.api.ts b/apps/fulfillment-e2e/src/support/backoffice-api/backoffice.api.ts deleted file mode 100644 index 5da18a085..000000000 --- a/apps/fulfillment-e2e/src/support/backoffice-api/backoffice.api.ts +++ /dev/null @@ -1,27 +0,0 @@ -export class BackofficeApi { - baseUrl = Cypress.env('backofficeApiUrl'); - - private _accessToken: string; - - public get accessToken(): string { - return this._accessToken; - } - - public set accessToken(value: string) { - this._accessToken = value; - } - - getHeaders() { - let headers = { - 'Content-Type': 'application/vnd.api+json', - }; - - if (this.accessToken) { - headers = Object.assign(headers, { - Authorization: `${this.accessToken}`, - }); - } - - return headers; - } -} diff --git a/apps/fulfillment-e2e/src/support/backoffice-api/picking.api.ts b/apps/fulfillment-e2e/src/support/backoffice-api/picking.api.ts deleted file mode 100644 index bef73d719..000000000 --- a/apps/fulfillment-e2e/src/support/backoffice-api/picking.api.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { BackofficeApi } from './backoffice.api'; - -export class PickingApi extends BackofficeApi { - startPicking = (pickingId: string) => { - return cy.request({ - method: 'POST', - url: `${this.baseUrl}/picking-lists/${pickingId}/start-picking`, - headers: this.getHeaders(), - body: {}, - }); - }; -} diff --git a/apps/fulfillment-e2e/src/support/backoffice/commands.ts b/apps/fulfillment-e2e/src/support/backoffice/commands.ts deleted file mode 100644 index 640d780ef..000000000 --- a/apps/fulfillment-e2e/src/support/backoffice/commands.ts +++ /dev/null @@ -1,73 +0,0 @@ -import 'cypress-wait-until'; -import { LoginPage } from './page-objects/login.page'; -import { OrderPage } from './page-objects/order.page'; - -export {}; - -declare global { - namespace Cypress { - interface Chainable { - backofficeLogin(email?: string, password?: string): void; - backofficeMakeOrderReadyForPicking(orderId: string): Chainable; - backofficeMoveOrderInReadyForPicking(orderId: string): void; - } - } -} - -Cypress.Commands.add( - 'backofficeLogin', - (email = 'admin@spryker.com', password = 'change123') => { - const loginPage = new LoginPage(); - - loginPage.visit(); - loginPage.login(email, password); - } -); - -Cypress.Commands.add( - 'backofficeMakeOrderReadyForPicking', - (orderId: string) => { - cy.origin( - Cypress.env('backofficeUrl'), - { args: { orderId } }, - ({ orderId }) => { - // enables cypress actions usage inside origin calls - Cypress.require(__dirname + '/commands'); - // ignore all zed UI JS errors - Cypress.on('uncaught:exception', () => false); - - cy.backofficeLogin(); - cy.backofficeMoveOrderInReadyForPicking(orderId); - cy.clearAllLocalStorage(); - } - ); - - // back to FA - cy.visit('/'); - - return cy.wrap(orderId); - } -); - -Cypress.Commands.add( - 'backofficeMoveOrderInReadyForPicking', - (orderId: string) => { - const orderPage = new OrderPage(orderId); - - orderPage.visit(); - - cy.waitUntil( - () => { - return cy - .reload() - .then(() => Cypress.$('[action*="?event=pay"]').length); - }, - { timeout: 180000, interval: 5000 } - ); - - orderPage.payForOrder(); - orderPage.skipTimeout(); - orderPage.pickingListGenerationSchedule(); - orderPage.prepareForPicking(); - } -); diff --git a/apps/fulfillment-e2e/src/support/backoffice/page-objects/abstract-backoffice.page.ts b/apps/fulfillment-e2e/src/support/backoffice/page-objects/abstract-backoffice.page.ts deleted file mode 100644 index b018e0f3e..000000000 --- a/apps/fulfillment-e2e/src/support/backoffice/page-objects/abstract-backoffice.page.ts +++ /dev/null @@ -1,7 +0,0 @@ -export abstract class ABackofficePage { - abstract url: string; - - visit = () => { - cy.visit(`${Cypress.env('backofficeUrl')}${this.url}`); - }; -} diff --git a/apps/fulfillment-e2e/src/support/backoffice/page-objects/login.page.ts b/apps/fulfillment-e2e/src/support/backoffice/page-objects/login.page.ts deleted file mode 100644 index 1f7ca5905..000000000 --- a/apps/fulfillment-e2e/src/support/backoffice/page-objects/login.page.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { ABackofficePage } from './abstract-backoffice.page'; - -export class LoginPage extends ABackofficePage { - url = '/security-gui/login'; - - getEmailInput = () => cy.get('#auth_username'); - getPasswordInput = () => cy.get('#auth_password'); - getSubmitBtn = () => cy.contains('.btn', 'Login'); - - login = (email: string, password: string) => { - // IDK why this is needed but login works only after reload - cy.reload(); - // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(1000); - - this.getEmailInput().type(email); - this.getPasswordInput().type(password); - this.getSubmitBtn().click(); - }; -} diff --git a/apps/fulfillment-e2e/src/support/backoffice/page-objects/order.page.ts b/apps/fulfillment-e2e/src/support/backoffice/page-objects/order.page.ts deleted file mode 100644 index fb15e201a..000000000 --- a/apps/fulfillment-e2e/src/support/backoffice/page-objects/order.page.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { ABackofficePage } from './abstract-backoffice.page'; - -export class OrderPage extends ABackofficePage { - url = '/sales/detail'; - orderId: string; - - constructor(orderId?: string) { - super(); - - if (orderId) { - this.orderId = orderId; - // don't ask me why replace is needed here... - this.url += `?id-sales-order=${orderId.replace('DE--', '')}`; - } - } - - getOMSButtonByText = (text: string) => cy.contains('button', text); - - payForOrder = () => this.getOMSButtonByText('Pay').click(); - - skipTimeout = () => this.getOMSButtonByText('Skip timeout').click(); - - pickingListGenerationSchedule = () => - this.getOMSButtonByText('picking list generation schedule').click(); - - prepareForPicking = () => - this.getOMSButtonByText('prepare for picking').click(); -} diff --git a/apps/fulfillment-e2e/src/support/commands.ts b/apps/fulfillment-e2e/src/support/commands.ts deleted file mode 100644 index bdc203daa..000000000 --- a/apps/fulfillment-e2e/src/support/commands.ts +++ /dev/null @@ -1,265 +0,0 @@ -import { Interception } from 'node_modules/cypress/types/net-stubbing'; -import { TestUserData } from '../types/user.type'; -import { PickingApi } from './backoffice-api/picking.api'; -import './backoffice/commands'; -import { CheckoutApi } from './glue-api/checkout.api'; -import { GuestCartsItemsApi } from './glue-api/guest-carts-items.api'; -import { GuestCartsApi } from './glue-api/guest-carts.api'; -import { HeaderFragment } from './page_fragments/lists-header.fragment'; -import { ListsFragment } from './page_fragments/lists.fragment'; -import { UserProfileModal } from './page_fragments/user-profile-modal.fragment'; -import { LoginPage } from './page_objects/login.page'; -import { PickingListPage } from './page_objects/picking-list.page'; -import { WarehouseSelectionPage } from './page_objects/warehouse-selection.page'; -export {}; - -declare global { - namespace Cypress { - interface Chainable { - login(user?: TestUserData): void; - clearIndexedDB(): void; - waitForIndexedDB(): void; - mockPickingInProgress(): void; - mockSyncPending(): void; - receiveData(): Chainable; - createPicking(numberOfItems?: number): Chainable; - cleanupPickings(): void; - glueApiCreateOrder(numberOfItems?: number): Chainable; - waitForPickingToAppear(orderId: string): Chainable; - } - } -} - -const indexedDBName = 'fulfillment-app-db'; -const indexedDBStorageName = 'oryx-local-db-storage'; -export const defaultUser = { - email: 'harald@spryker.com', - password: 'change123', - warehouseName: 'Warehouse1', -}; - -Cypress.Commands.add('login', (user = defaultUser) => { - const loginPage = new LoginPage(); - const warehouseSelectionPage = new WarehouseSelectionPage(); - const pickListsPage = new PickingListPage(); - - loginPage.visit(); - loginPage.login(user); - warehouseSelectionPage.waitForLoaded(); - warehouseSelectionPage.selectByName(user.warehouseName); - pickListsPage.waitForLoaded(); -}); - -Cypress.Commands.add('createPicking', (numberOfItems = 1) => { - // initializes FA as a base domain - cy.visit('/'); - - return cy - .glueApiCreateOrder(numberOfItems) - .then((orderId) => cy.backofficeMakeOrderReadyForPicking(orderId)); -}); - -Cypress.Commands.add('cleanupPickings', () => { - const api = new PickingApi(); - - // picking list requests should already be intercepted and available in this place - cy.get('@picking-lists').then((interception: Interception) => { - api.accessToken = interception.request.headers.authorization as string; - - interception.response.body.data - .filter((picking) => picking.attributes.status === 'ready-for-picking') - .map((picking) => picking.id) - .map((pickingId) => api.startPicking(pickingId)); - }); -}); - -Cypress.Commands.add('receiveData', () => { - const header = new HeaderFragment(); - const profile = new UserProfileModal(); - - cy.intercept('GET', '**/picking-lists?include*').as('picking-lists-update'); - - header.getUserIcon().should('be.visible').click(); - profile.getSyncDataButton().should('be.visible').click(); - - cy.wait('@picking-lists-update'); - - return cy.wrap(null); -}); - -Cypress.Commands.add('glueApiCreateOrder', (numberOfItems = 1) => { - const customerUniqueId = Math.random(); - const guestCartsApi = new GuestCartsApi(); - const guestCartsItemsApi = new GuestCartsItemsApi(); - const checkoutApi = new CheckoutApi(); - - guestCartsApi.customerUniqueId = customerUniqueId; - guestCartsItemsApi.customerUniqueId = customerUniqueId; - checkoutApi.customerUniqueId = customerUniqueId; - - return ( - guestCartsItemsApi - // add product that is always available in the stock - // 086_30521602 adjusted manually in backoffice, we have to - // find another product to use here later - .postGuestCartsItems('141_29380410', numberOfItems) - .then(() => guestCartsApi.getGuestCarts()) - .then((res) => res.body.data[0].id) - .then((idCart) => checkoutApi.checkout(idCart)) - .then((res) => res.body.data.attributes.orderReference) - ); -}); - -Cypress.Commands.add('waitForPickingToAppear', (orderId: string) => { - const list = new ListsFragment(); - - list.getPickingListsItems().should('have.length', 1); - list.getPickingListItemByOrderId(orderId).should('be.visible'); - - return cy.wrap(orderId); -}); - -Cypress.Commands.add('clearIndexedDB', () => { - new Cypress.Promise((resolve, reject) => { - cy.window().then(async (win) => { - try { - await Promise.all([ - clearIndexedDb(win, indexedDBName), - clearIndexedDb(win, indexedDBStorageName), - ]); - resolve(); - } catch { - reject(); - } - }); - }); -}); - -Cypress.Commands.add('waitForIndexedDB', () => { - cy.log('Wait for IndexedDB existance...'); - - const checkIndexedDBExistence = () => { - return new Cypress.Promise(async (resolve, reject) => { - try { - await Promise.all([ - indexedDbExists(indexedDBName), - indexedDbExists(indexedDBStorageName), - ]); - resolve(); - } catch { - reject(); - } - }); - }; - - return cy.wrap(null).then(() => { - const checkInterval = 200; - const maxAttempts = 30; - let attempts = 0; - - const checkExistenceLoop = () => { - return checkIndexedDBExistence().catch((error) => { - attempts++; - if (attempts >= maxAttempts) { - throw error; - } else { - // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(checkInterval).then(checkExistenceLoop); - } - }); - }; - - return checkExistenceLoop(); - }); -}); - -Cypress.Commands.add('mockSyncPending', () => { - new Cypress.Promise((resolve, reject) => { - cy.window().then(async (win) => { - try { - await mockSyncPending(win); - resolve(); - } catch { - reject(); - } - }); - }); -}); - -Cypress.Commands.add('mockPickingInProgress', () => { - cy.intercept('POST', /.+\/picking-lists\/.+\/start-picking$/, { - statusCode: 409, - body: { - errors: [ - { - message: 'Picklist is already being picked by another user.', - status: 409, - code: '5310', - }, - ], - }, - }); -}); - -async function indexedDbExists(dbName) { - const dbs = await indexedDB.databases(); - if (!dbs.map((db) => db.name).includes(dbName)) { - throw `DB "${dbName}" not found`; - } - - console.log(`DB "${dbName}" exists`); -} - -function clearIndexedDb(win, dbName) { - return new Promise((resolve, reject) => { - const deleteRequest = win.indexedDB.deleteDatabase(dbName); - - deleteRequest.onsuccess = function () { - console.log(`"${dbName}" database deleted successfully`); - resolve(); - }; - - deleteRequest.onerror = function () { - console.log(`Couldn't delete database "${dbName}"`); - reject(); - }; - - deleteRequest.onblocked = function () { - console.warn( - `Couldn't delete database "${dbName}" due to the operation being blocked` - ); - reject(); - }; - }); -} - -function mockSyncPending(win) { - return new Promise((resolve, reject) => { - const request = win.indexedDB.open(indexedDBName); - - request.onsuccess = function () { - const db = request.result; - - const store = db - .transaction('oryx.syncs', 'readwrite') - .objectStore('oryx.syncs'); - - const transaction = store.add({ status: 'processing' }); - - transaction.onsuccess = function () { - console.log('pending sync added'); - resolve(); - }; - - transaction.onerror = function () { - console.log('could not add pending sync'); - reject(); - }; - }; - - request.onerror = function () { - console.log('could not access database'); - reject(); - }; - }); -} diff --git a/apps/fulfillment-e2e/src/support/glue-api/checkout.api.ts b/apps/fulfillment-e2e/src/support/glue-api/checkout.api.ts deleted file mode 100644 index c0832a69c..000000000 --- a/apps/fulfillment-e2e/src/support/glue-api/checkout.api.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { GlueApi } from './glue.api'; - -export class CheckoutApi extends GlueApi { - checkout = (idCart: string) => { - return cy.request({ - method: 'POST', - url: `${this.baseUrl}/checkout?include=orders`, - headers: this.getHeaders(), - body: { - data: { - type: 'checkout', - attributes: { - shippingAddress: { - iso2Code: 'AT', - salutation: 'Mr', - firstName: 'Sonia', - lastName: 'Test', - company: 'Test company', - address1: 'Addr 1', - address2: 'addr 2', - zipCode: 'Zip123', - city: 'Test city', - phone: '1234567890', - }, - shipment: { - idShipmentMethod: '1', - }, - customer: { - email: 'spencor.hopkin@spryker.com', - salutation: 'Mr', - firstName: 'Sonia', - lastName: 'Test', - }, - billingAddress: { - iso2Code: 'AT', - salutation: 'Mr', - firstName: 'Sonia', - lastName: 'Test', - company: 'Test company', - address1: 'Addr 1', - address2: 'addr 2', - zipCode: 'Zip123', - city: 'Test city', - phone: '1234567890', - }, - idCart: idCart, - payments: [ - { - priority: 1, - requiredRequestData: [ - 'paymentMethod', - 'paymentProvider', - 'dummyPaymentInvoice.dateOfBirth', - ], - id: '1', - paymentMethodName: 'Invoice', - paymentProviderName: 'DummyPayment', - }, - ], - }, - }, - }, - failOnStatusCode: false, - }); - }; -} diff --git a/apps/fulfillment-e2e/src/support/glue-api/glue.api.ts b/apps/fulfillment-e2e/src/support/glue-api/glue.api.ts deleted file mode 100644 index f755a4e5c..000000000 --- a/apps/fulfillment-e2e/src/support/glue-api/glue.api.ts +++ /dev/null @@ -1,45 +0,0 @@ -export class GlueApi { - baseUrl = Cypress.env('glueApiUrl'); - - private _customerUniqueId: number = Math.random(); - - public get customerUniqueId(): number { - return this._customerUniqueId; - } - - public set customerUniqueId(value: number) { - this._customerUniqueId = value; - } - - private _accessToken: string; - - public get accessToken(): string { - return this._accessToken; - } - - public set accessToken(value: string) { - this._accessToken = value; - // if accessToken is set -> user can't be anonymous anymore - this.isAnonymousUser = false; - } - - isAnonymousUser = true; - - getHeaders() { - let headers = {}; - - if (this.isAnonymousUser) { - headers = Object.assign(headers, { - 'X-Anonymous-Customer-Unique-Id': this.customerUniqueId, - }); - } - - if (this.accessToken) { - headers = Object.assign(headers, { - Authorization: `Bearer ${this.accessToken}`, - }); - } - - return headers; - } -} diff --git a/apps/fulfillment-e2e/src/support/glue-api/guest-carts-items.api.ts b/apps/fulfillment-e2e/src/support/glue-api/guest-carts-items.api.ts deleted file mode 100644 index 26ce8ffcb..000000000 --- a/apps/fulfillment-e2e/src/support/glue-api/guest-carts-items.api.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { GlueApi } from './glue.api'; - -export class GuestCartsItemsApi extends GlueApi { - postGuestCartsItems = (sku: string | undefined, quantity: number) => { - return cy.request({ - method: 'POST', - url: `${this.baseUrl}/guest-cart-items`, - headers: this.getHeaders(), - body: { - data: { - type: 'guest-cart-items', - attributes: { - sku, - quantity, - }, - }, - }, - failOnStatusCode: false, - }); - }; -} diff --git a/apps/fulfillment-e2e/src/support/glue-api/guest-carts.api.ts b/apps/fulfillment-e2e/src/support/glue-api/guest-carts.api.ts deleted file mode 100644 index 5c65e4956..000000000 --- a/apps/fulfillment-e2e/src/support/glue-api/guest-carts.api.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { GlueApi } from './glue.api'; - -export class GuestCartsApi extends GlueApi { - getGuestCarts = () => { - return cy.request({ - method: 'GET', - url: `${this.baseUrl}/guest-carts`, - headers: this.getHeaders(), - failOnStatusCode: false, - }); - }; -} diff --git a/apps/fulfillment-e2e/src/support/index.ts b/apps/fulfillment-e2e/src/support/index.ts deleted file mode 100644 index abb4d767c..000000000 --- a/apps/fulfillment-e2e/src/support/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -import './commands'; - -Cypress.on('uncaught:exception', (err) => { - const ignoreErrors = [ - // fa error - 'Registration failed - push service not available', - 'Background Sync is disabled', - // zed order page error - "Cannot read properties of undefined (reading 'scrollHeight')", - ]; - - if (ignoreErrors.some((ignoreError) => err.message.includes(ignoreError))) { - return false; - } -}); diff --git a/apps/fulfillment-e2e/src/support/page_fragments/customer-note-modal.fragment.ts b/apps/fulfillment-e2e/src/support/page_fragments/customer-note-modal.fragment.ts deleted file mode 100644 index d9f69f9fb..000000000 --- a/apps/fulfillment-e2e/src/support/page_fragments/customer-note-modal.fragment.ts +++ /dev/null @@ -1,6 +0,0 @@ -export class CustomerNoteModalFragment { - getWrapper = () => cy.get('oryx-picking-customer-note-modal'); - - getModal = () => this.getWrapper().find('dialog'); - getCloseButton = () => this.getWrapper().find('oryx-button').eq(0); -} diff --git a/apps/fulfillment-e2e/src/support/page_fragments/customer-note.fragment.ts b/apps/fulfillment-e2e/src/support/page_fragments/customer-note.fragment.ts deleted file mode 100644 index 75485f227..000000000 --- a/apps/fulfillment-e2e/src/support/page_fragments/customer-note.fragment.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { PickingInProgressModalFragment } from './picking-in-progress-modal.fragment'; - -export class CustomerNoteFragment { - getWrapper = () => cy.get('oryx-picking-customer-note'); - getHeadline = () => this.getWrapper().find('oryx-heading'); - getIllustration = () => this.getWrapper().find('oryx-image'); - getNavigateBackButton = () => this.getWrapper().find('oryx-button').eq(0); - getNote = () => this.getWrapper().find('p'); - getProceedToPickingButton = () => this.getWrapper().find('oryx-button').eq(1); - pickingInProgressModal = new PickingInProgressModalFragment(); -} diff --git a/apps/fulfillment-e2e/src/support/page_fragments/discard-modal.fragment.ts b/apps/fulfillment-e2e/src/support/page_fragments/discard-modal.fragment.ts deleted file mode 100644 index f16ec5fc0..000000000 --- a/apps/fulfillment-e2e/src/support/page_fragments/discard-modal.fragment.ts +++ /dev/null @@ -1,6 +0,0 @@ -export class DiscardModalFragment { - getWrapper = () => cy.get('oryx-picking-discard-modal'); - getContent = () => this.getWrapper().shadow().find('slot[part="body"]'); - getCancelButton = () => this.getWrapper().find('oryx-button').eq(0); - getDiscardButton = () => this.getWrapper().find('oryx-button').eq(1); -} diff --git a/apps/fulfillment-e2e/src/support/page_fragments/filters.fragment.ts b/apps/fulfillment-e2e/src/support/page_fragments/filters.fragment.ts deleted file mode 100644 index 59fd431ac..000000000 --- a/apps/fulfillment-e2e/src/support/page_fragments/filters.fragment.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { ListsFragment } from './lists.fragment'; - -const listsFragment = new ListsFragment(); - -export class FiltersFragment { - getFilterButton = () => cy.get('oryx-picking-filter-button'); - getFilterButtonTrigger = () => - this.getFilterButton().find('oryx-toggle-icon input'); - getFiltersModal = () => - this.getFilterButton().find('oryx-picking-filters').find('oryx-modal'); - getFiltersResetButton = () => - this.getFilterButton() - .find('oryx-picking-filters') - .find('[slot="navigate-back"]'); - getFiltersCloseButton = () => - this.getFiltersModal().find('header oryx-button').eq(1); - getFiltersApplyButton = () => - this.getFilterButton() - .find('oryx-picking-filters') - .find('oryx-button[slot="footer"]'); - getSortingOption = (eq: number) => - this.getFiltersModal().find('input').eq(eq); - shouldChangePickingListsOrder = (isChange: boolean) => - listsFragment - .getPickingListsItems() - .eq(0) - .find('.total oryx-button') - .should(!isChange ? 'exist' : 'not.exist'); -} diff --git a/apps/fulfillment-e2e/src/support/page_fragments/header.fragment.ts b/apps/fulfillment-e2e/src/support/page_fragments/header.fragment.ts deleted file mode 100644 index 32aa1a9f8..000000000 --- a/apps/fulfillment-e2e/src/support/page_fragments/header.fragment.ts +++ /dev/null @@ -1,5 +0,0 @@ -export class HeaderFragment { - getWrapper = () => cy.get('oryx-picking-header'); - - getUserIcon = () => this.getWrapper().find('oryx-site-navigation-item'); -} diff --git a/apps/fulfillment-e2e/src/support/page_fragments/lists-header.fragment.ts b/apps/fulfillment-e2e/src/support/page_fragments/lists-header.fragment.ts deleted file mode 100644 index 31bfcc3c4..000000000 --- a/apps/fulfillment-e2e/src/support/page_fragments/lists-header.fragment.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { UserProfileModal } from './user-profile-modal.fragment'; - -export class HeaderFragment { - getWrapper = () => cy.get('[uid="header-picking-lists"]'); - getSearch = () => this.getWrapper().find('oryx-search'); - getHeadline = () => this.getWrapper().find('oryx-heading'); - getSearchIcon = () => this.getSearch().find('oryx-icon[type="search"]'); - getSearchInput = () => this.getSearch().find('input[placeholder="Order ID"]'); - getSearchBackButton = () => this.getSearch().find('.back-button'); - getSearchClearButton = () => this.getSearch().find('.clear-button'); - getUserIcon = () => this.getWrapper().find('oryx-site-navigation-item'); - getTitle = () => this.getWrapper().find('oryx-heading'); - - getUserProfileModal = () => new UserProfileModal(); - - openUserProfileModal = () => this.getUserIcon().click(); - - openSearch = () => this.getSearch().click(); -} diff --git a/apps/fulfillment-e2e/src/support/page_fragments/lists.fragment.ts b/apps/fulfillment-e2e/src/support/page_fragments/lists.fragment.ts deleted file mode 100644 index 74ece57f1..000000000 --- a/apps/fulfillment-e2e/src/support/page_fragments/lists.fragment.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { PickingInProgressModalFragment } from './picking-in-progress-modal.fragment'; - -export class ListsFragment { - getWrapper = () => cy.get('oryx-picking-lists'); - getSortButton = () => this.getWrapper().find('oryx-picking-filter-button'); - getNoItemsFallback = () => cy.get('.no-items-fallback'); - getNoItemsFallbackHeading = () => - this.getNoItemsFallback().find('oryx-heading'); - getStartSearchingFallbackImage = () => - this.getNoItemsFallback().find('oryx-image[resource="searching"]'); - getNoPickingResultsFallbackImage = () => - this.getNoItemsFallback().find('oryx-image[resource="no-search-results"]'); - getPickingListsItems = () => this.getWrapper().find('oryx-picking-list-item'); - getCustomerNoteButtons = () => - this.getPickingListsItems().find('.total oryx-button'); - getStartPickingButtons = () => - this.getPickingListsItems().find('oryx-button[slot="footer"]'); - getPickingListItemId = (eq: number) => - this.getPickingListsItems() - .eq(eq) - .find('.identifier') - .should('be.visible') - .invoke('text'); - getPickingListItemByOrderId = (orderId: string) => { - return this.getPickingListsItems().contains('.identifier', orderId); - }; - pickingInProgressModal = new PickingInProgressModalFragment(); - - startPickingByEq = (eq: number) => { - this.getStartPickingButtons().eq(eq).click(); - }; -} diff --git a/apps/fulfillment-e2e/src/support/page_fragments/login.fragment.ts b/apps/fulfillment-e2e/src/support/page_fragments/login.fragment.ts deleted file mode 100644 index 809c0130c..000000000 --- a/apps/fulfillment-e2e/src/support/page_fragments/login.fragment.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { TestUserData } from '../../types/user.type'; - -export class LoginFragment { - url = '/'; - - getWrapper = () => cy.get('oryx-auth-login'); - getEmailInput = () => this.getWrapper().find('[name="email"]'); - getPasswordInput = () => this.getWrapper().find('[name="password"]'); - getLoginButton = () => this.getWrapper().contains('button', 'Log in'); - getBEValidationError = () => this.getWrapper().find('oryx-notification'); - getLabelSlot = () => this.getWrapper().find('slot[name="label"]'); - - login = (user: TestUserData) => { - this.getEmailInput().focus(); - this.getEmailInput().type(user.email, { delay: 10, force: true }); - this.getPasswordInput().type(user.password, { delay: 10, force: true }); - this.getLoginButton().click(); - }; -} diff --git a/apps/fulfillment-e2e/src/support/page_fragments/picker-header.fragment.ts b/apps/fulfillment-e2e/src/support/page_fragments/picker-header.fragment.ts deleted file mode 100644 index 95b257208..000000000 --- a/apps/fulfillment-e2e/src/support/page_fragments/picker-header.fragment.ts +++ /dev/null @@ -1,9 +0,0 @@ -export class PickerHeaderFragment { - getWrapper = () => cy.get('oryx-picking-picker-header'); - - getCustomerNoteIcon = () => - this.getWrapper().find('button[aria-label="Customer note"]'); - getUserIcon = () => this.getWrapper().find('oryx-site-navigation-item'); - getPickingListsTitle = () => this.getWrapper().find('.title'); - getBackButton = () => this.getWrapper().find('oryx-button').eq(0); -} diff --git a/apps/fulfillment-e2e/src/support/page_fragments/picker.fragment.ts b/apps/fulfillment-e2e/src/support/page_fragments/picker.fragment.ts deleted file mode 100644 index 336dc76d2..000000000 --- a/apps/fulfillment-e2e/src/support/page_fragments/picker.fragment.ts +++ /dev/null @@ -1,24 +0,0 @@ -export class PickerFragment { - getWrapper = () => cy.get('oryx-picking-picker'); - getTabs = () => this.getWrapper().find('oryx-tabs'); - getTabsList = () => this.getWrapper().find('oryx-tab'); - getTabById = (id) => this.getWrapper().find(`oryx-tab[for="${id}"]`); - getTabCounter = (tab) => tab.find('oryx-chip'); - getProducts = () => this.getWrapper().find('oryx-picking-product-card'); - getTabContentById = (tabId) => this.getWrapper().find(`[id="${tabId}"]`); - getPartialPickingDialog = () => this.getWrapper().find('oryx-modal'); - getPartialPickingConfirmButton = () => - this.getPartialPickingDialog().find('oryx-button').contains('Confirm'); - getPartialPickingCancelButton = () => - this.getPartialPickingDialog().find('oryx-button').contains('Cancel'); - getPickingCompleteImage = () => - cy - .get('section oryx-image[resource="picking-items-processed"]') - .shadow() - .find('svg'); - getPickingCompleteTitle = () => cy.get('section h1'); - getPickingCompleteText = () => cy.get('section span'); - getNoItemsTitle = () => cy.get('section h2'); - getNoItemsImage = () => cy.get('section oryx-image[resource="no-orders"]'); - getFinishPickingButton = () => cy.get('.submit-wrapper oryx-button'); -} diff --git a/apps/fulfillment-e2e/src/support/page_fragments/picking-in-progress-modal.fragment.ts b/apps/fulfillment-e2e/src/support/page_fragments/picking-in-progress-modal.fragment.ts deleted file mode 100644 index 419d9c74c..000000000 --- a/apps/fulfillment-e2e/src/support/page_fragments/picking-in-progress-modal.fragment.ts +++ /dev/null @@ -1,6 +0,0 @@ -export class PickingInProgressModalFragment { - getWrapper = () => cy.get('oryx-picking-in-progress-modal'); - getModal = () => this.getWrapper().find('oryx-modal'); - getCloseButton = () => this.getWrapper().find('oryx-button').eq(0); - getOverlay = () => this.getModal().find('dialog'); -} diff --git a/apps/fulfillment-e2e/src/support/page_fragments/product-card.fragment.ts b/apps/fulfillment-e2e/src/support/page_fragments/product-card.fragment.ts deleted file mode 100644 index c42544460..000000000 --- a/apps/fulfillment-e2e/src/support/page_fragments/product-card.fragment.ts +++ /dev/null @@ -1,25 +0,0 @@ -export class ProductCardFragment { - constructor(protected element: JQuery) {} - - getWrapper = () => cy.wrap(this.element); - getDoneBtn = () => this.getWrapper().find('oryx-button'); - getIncreaseBtn = () => this.getWrapper().find('button[part="increase"]'); - getNumberOfItems = () => this.getWrapper().find('form div'); - - pickAllItems = () => { - this.getNumberOfItems().then((el) => { - const number = parseInt(el.text().match(/\d+/)[0]); - - Cypress._.times(number, () => { - this.getIncreaseBtn().click({ force: true }); - }); - }); - - this.getDoneBtn().click(); - }; - - pickOneItem = () => { - this.getIncreaseBtn().click({ force: true }); - this.getDoneBtn().click(); - }; -} diff --git a/apps/fulfillment-e2e/src/support/page_fragments/product.fragment.ts b/apps/fulfillment-e2e/src/support/page_fragments/product.fragment.ts deleted file mode 100644 index f12d34c0b..000000000 --- a/apps/fulfillment-e2e/src/support/page_fragments/product.fragment.ts +++ /dev/null @@ -1,24 +0,0 @@ -export class ProductFragment { - getProducts = () => cy.get('oryx-picking-product-card', { timeout: 10000 }); - getQuantityInput = () => this.getProducts().find('oryx-cart-quantity-input'); - getQuantityInputField = () => - cy - .get('oryx-cart-quantity-input') - .find('oryx-input') - .find('input[type="number"]'); - getQuantityInputMinusButton = () => cy.get('button[aria-label="Decrease"]'); - getQuantityInputPlusButton = () => cy.get('button[aria-label="Increase"]'); - getSubmitButton = () => cy.get('oryx-button'); - - pickAllProductItems = () => { - this.getQuantityInputPlusButton().then(($button) => { - // click button while it is active - if ($button.attr('disabled')) { - return; - } - - cy.wrap($button).click(); - this.pickAllProductItems(); - }); - }; -} diff --git a/apps/fulfillment-e2e/src/support/page_fragments/user-profile-modal.fragment.ts b/apps/fulfillment-e2e/src/support/page_fragments/user-profile-modal.fragment.ts deleted file mode 100644 index 9d5307349..000000000 --- a/apps/fulfillment-e2e/src/support/page_fragments/user-profile-modal.fragment.ts +++ /dev/null @@ -1,11 +0,0 @@ -export class UserProfileModal { - getWrapper = () => cy.get('oryx-picking-user-profile'); - - getNotification = () => this.getWrapper().find('oryx-notification'); - getLogOutButton = () => this.getWrapper().find('.logout-button'); - getSyncDataButton = () => this.getWrapper().find('.sync-data'); - getCloseButton = () => - cy.get('oryx-site-navigation-item').find('dialog oryx-button'); - - logout = () => this.getLogOutButton().click(); -} diff --git a/apps/fulfillment-e2e/src/support/page_objects/abstract-fa.page.ts b/apps/fulfillment-e2e/src/support/page_objects/abstract-fa.page.ts deleted file mode 100644 index 9ae794198..000000000 --- a/apps/fulfillment-e2e/src/support/page_objects/abstract-fa.page.ts +++ /dev/null @@ -1,7 +0,0 @@ -export class AFAPage { - url: string; - - visit(): void { - cy.visit(this.url); - } -} diff --git a/apps/fulfillment-e2e/src/support/page_objects/loading.page.ts b/apps/fulfillment-e2e/src/support/page_objects/loading.page.ts deleted file mode 100644 index 50b2fbdb9..000000000 --- a/apps/fulfillment-e2e/src/support/page_objects/loading.page.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { AFAPage } from './abstract-fa.page'; - -export class LoadingPage extends AFAPage { - url = '/oauth'; - - getWrapper = () => cy.get('oryx-auth-oauth-handler'); - getLogo = () => this.getWrapper().find('oryx-image[resource="logo"]'); - getTitle = () => this.getWrapper().find('oryx-heading'); - getSpinner = () => this.getWrapper().find('oryx-spinner'); -} diff --git a/apps/fulfillment-e2e/src/support/page_objects/login.page.ts b/apps/fulfillment-e2e/src/support/page_objects/login.page.ts deleted file mode 100644 index b505bf12f..000000000 --- a/apps/fulfillment-e2e/src/support/page_objects/login.page.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { TestUserData } from '../../types/user.type'; -import { LoginFragment } from '../page_fragments/login.fragment'; -import { AFAPage } from './abstract-fa.page'; - -export class LoginPage extends AFAPage { - url = '/'; - - loginForm = new LoginFragment(); - - getWrapper = () => cy.get('oryx-auth-login'); - getLogo = () => this.getWrapper().find('oryx-image[resource="logo"]'); - getTitle = () => this.getWrapper().find('oryx-heading'); - getErrorNotification = () => - this.getWrapper().find('oryx-notification[type="error"]'); - - login = (user: TestUserData) => { - cy.intercept('POST', '**/token').as('token'); - this.loginForm.login(user); - cy.wait('@token'); - }; -} diff --git a/apps/fulfillment-e2e/src/support/page_objects/picking-list.page.ts b/apps/fulfillment-e2e/src/support/page_objects/picking-list.page.ts deleted file mode 100644 index 5b95012df..000000000 --- a/apps/fulfillment-e2e/src/support/page_objects/picking-list.page.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { AFAPage } from './abstract-fa.page'; -import { WarehouseSelectionPage } from './warehouse-selection.page'; - -export class PickingListPage extends AFAPage { - url = '/'; - - constructor() { - super(); - cy.intercept('GET', '**/picking-lists?include*').as('picking-lists'); - } - - warehousesList = new WarehouseSelectionPage(); - - waitForLoaded = () => { - cy.wait('@picking-lists'); - cy.waitForIndexedDB(); - // this wait is needed to populate the DB with data - // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(800); - }; - - getPickingListItems = () => cy.get('oryx-picking-list-item'); - - startPickingByEq = (eq = 0) => { - this.getPickingListItems().eq(eq).find('.start-picking').click(); - }; -} diff --git a/apps/fulfillment-e2e/src/support/page_objects/picking.page.ts b/apps/fulfillment-e2e/src/support/page_objects/picking.page.ts deleted file mode 100644 index 1bb358b55..000000000 --- a/apps/fulfillment-e2e/src/support/page_objects/picking.page.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { PickerFragment } from '../page_fragments/picker.fragment'; -import { ProductCardFragment } from '../page_fragments/product-card.fragment'; -import { ProductFragment } from '../page_fragments/product.fragment'; -import { AFAPage } from './abstract-fa.page'; - -export class PickingPage extends AFAPage { - url = '/picking-list/picking'; - - constructor(protected id?: string) { - super(); - - if (id) { - this.url += `/${this.id}`; - } - } - - waitForLoaded = () => { - this.getProducts().should('have.length.gt', 0); - }; - - pickerFragment = new PickerFragment(); - productFragment = new ProductFragment(); - - getNotPickedTab = () => this.pickerFragment.getTabsList().eq(0); - getPickedTab = () => this.pickerFragment.getTabsList().eq(1); - getNotFoundTab = () => this.pickerFragment.getTabsList().eq(2); - - getNotPickedProductsNumber = () => - cy.wrap(this.getProductsNumber(this.getNotPickedTab())); - getPickedProductsNumber = () => - cy.wrap(this.getProductsNumber(this.getPickedTab())); - getNotFoundProductsNumber = () => - cy.wrap(this.getProductsNumber(this.getNotFoundTab())); - - getProductsNumber(tab) { - return new Promise((resolve) => { - this.insideTabContent(tab, ($tabContent) => { - resolve($tabContent.find('oryx-picking-product-card').length); - }); - }); - } - - // IDK why do we have 3 (!) finish picking buttons - // a separate button per tab - getFinishPickingBtn = () => cy.get('.submit-wrapper oryx-button').eq(0); - getProducts = () => cy.get('oryx-picking-product-card'); - - pickAllProducts = () => { - this.getProducts().each((el) => { - const product = new ProductCardFragment(el); - - product.pickAllItems(); - }); - }; - - pickSomeProducts = () => { - this.getProducts().each((el) => { - const product = new ProductCardFragment(el); - - product.pickOneItem(); - }); - }; - - finishPicking = () => { - this.getFinishPickingBtn().click(); - }; - - pickProduct(product, itemsNumber) { - product.within(() => { - // type items number into field - this.productFragment.getQuantityInputField().clear().type(itemsNumber); - - // click submit button - this.productFragment.getSubmitButton().click(); - }); - } - - insideTabContent(tab, callback) { - tab.invoke('attr', 'for').then((tabId) => { - this.pickerFragment.getTabById(tabId).click(); - - this.pickerFragment.getTabContentById(tabId).within((scopeEl) => { - callback(scopeEl); - }); - }); - } -} diff --git a/apps/fulfillment-e2e/src/support/page_objects/warehouse-selection.page.ts b/apps/fulfillment-e2e/src/support/page_objects/warehouse-selection.page.ts deleted file mode 100644 index 6b11a6674..000000000 --- a/apps/fulfillment-e2e/src/support/page_objects/warehouse-selection.page.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { AFAPage } from './abstract-fa.page'; - -export class WarehouseSelectionPage extends AFAPage { - url = '/warehouse-selection'; - - constructor() { - super(); - cy.intercept('GET', '**/warehouse-user-assignments').as( - 'warehouse-user-assignments' - ); - } - - waitForLoaded = () => { - cy.wait('@warehouse-user-assignments'); - }; - - getWrapper = () => cy.get('.warehouses-list'); - getTitle = () => this.getWrapper().find('oryx-heading').eq(0); - getNames = () => this.getWrapper().find('oryx-heading'); - getSelectBtns = () => this.getWrapper().find('oryx-button'); - - selectByEq = (eq: number) => { - this.getSelectBtns().eq(eq).click(); - }; - - selectByName = (name: string) => { - this.getNames().contains(name).next('oryx-button').click(); - }; -} diff --git a/apps/fulfillment-e2e/src/types/user.type.ts b/apps/fulfillment-e2e/src/types/user.type.ts deleted file mode 100644 index 5cb3cdd83..000000000 --- a/apps/fulfillment-e2e/src/types/user.type.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type TestUserData = { - email: string; - password: string; - warehouseName: string; -}; diff --git a/apps/fulfillment-e2e/tsconfig.json b/apps/fulfillment-e2e/tsconfig.json deleted file mode 100644 index 057da7ec5..000000000 --- a/apps/fulfillment-e2e/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "sourceMap": false, - "outDir": "../../dist/out-tsc", - "allowJs": true, - "types": ["cypress", "node", "cypress-wait-until"] - }, - "include": ["src/**/*.ts", "src/**/*.js"] -} diff --git a/apps/fulfillment/.env.template b/apps/fulfillment/.env.template deleted file mode 100644 index 0fd179a96..000000000 --- a/apps/fulfillment/.env.template +++ /dev/null @@ -1,11 +0,0 @@ -# The url where the backend is hosted. -ORYX_FULFILLMENT_BACKEND_URL= - -# The public VAPID key to make the application able to subscribe push notifications. -ORYX_FULFILLMENT_PUBLIC_VAPID_KEY= - -# Used to set a feature level, available options: latest, 1.0, 1.1, etc. Only major and minor versions should be used. -ORYX_FEATURE_VERSION= - -# The client id for the OAuth flow. -ORYX_FULFILLMENT_CLIENT_ID= diff --git a/apps/fulfillment/.eslintrc.json b/apps/fulfillment/.eslintrc.json deleted file mode 100644 index 9d9c0db55..000000000 --- a/apps/fulfillment/.eslintrc.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.ts", "*.tsx"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "rules": {} - } - ] -} diff --git a/apps/fulfillment/browserslist b/apps/fulfillment/browserslist deleted file mode 100644 index 8d6179367..000000000 --- a/apps/fulfillment/browserslist +++ /dev/null @@ -1,13 +0,0 @@ -# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers -# For additional information regarding the format and rule options, please see: -# https://github.com/browserslist/browserslist#queries -# -# If you need to support different browsers in production, you may tweak the list below. - -last 1 Chrome version -last 1 Firefox version -last 2 Edge major versions -last 2 Safari major version -last 2 iOS major versions -Firefox ESR -not IE 9-11 # For IE 9-11 support, remove 'not'. \ No newline at end of file diff --git a/apps/fulfillment/dependencies.sh b/apps/fulfillment/dependencies.sh deleted file mode 100644 index a793d50f6..000000000 --- a/apps/fulfillment/dependencies.sh +++ /dev/null @@ -1 +0,0 @@ -DEPENDENCIES="apps/fulfillment/* libs/base/di/* libs/base/ui/* libs/base/utilities/* libs/domain/cart/* libs/domain/checkout/* libs/domain/content/* libs/domain/order/* libs/domain/picking/* libs/domain/product/* libs/domain/search/* libs/domain/site/* libs/domain/user/* libs/platform/auth/* libs/platform/core/* libs/platform/experience/* libs/platform/form/* libs/platform/i18n/* libs/platform/indexed-db/* libs/platform/offline/* libs/platform/push-notification/* libs/platform/router/* libs/template/application/* libs/template/labs/* libs/template/presets/* libs/template/resources/* libs/template/themes/*" \ No newline at end of file diff --git a/apps/fulfillment/netlify.toml b/apps/fulfillment/netlify.toml deleted file mode 100644 index 328ea59f3..000000000 --- a/apps/fulfillment/netlify.toml +++ /dev/null @@ -1,7 +0,0 @@ -[build] - ignore = "cd ../../ && bash ./should-ignore-build.sh ${PROJECT_NAME}" - -[[redirects]] - from = "/*" - to = "index.html" - status = 200 diff --git a/apps/fulfillment/package.json b/apps/fulfillment/package.json deleted file mode 100644 index e8647e672..000000000 --- a/apps/fulfillment/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "fulfillment", - "version": "0.0.1", - "private": true, - "license": "Spryker", - "scripts": {}, - "dependencies": { - "dexie": "^3.2.2" - }, - "devDependencies": { - "dotenv": "^16.0.3" - } -} diff --git a/apps/fulfillment/project.json b/apps/fulfillment/project.json deleted file mode 100644 index f47eb3eed..000000000 --- a/apps/fulfillment/project.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "name": "fulfillment", - "projectType": "application", - "sourceRoot": "apps/fulfillment/src", - "tags": ["type:app", "root"], - "targets": { - "build": { - "executor": "nx:run-commands", - "outputs": ["dist/apps/fulfillment"], - "options": { - "command": "npx vite build", - "cwd": "apps/fulfillment" - }, - "dependsOn": ["build-sw"] - }, - "build-sw": { - "executor": "nx:run-commands", - "outputs": ["apps/fulfillment/dev-dist/sw"], - "options": { - "commands": [ - "rm -rf dev-dist/sw", - "npx vite build --config vite.config.sw.ts" - ], - "parallel": false, - "cwd": "apps/fulfillment" - }, - "configurations": { - "watch": { - "commands": [ - "rm -rf dev-dist/sw", - "npx vite build --config vite.config.sw.ts --watch" - ] - } - } - }, - "build-netlify": { - "executor": "nx:run-commands", - "outputs": ["dist/apps/fulfillment"], - "options": { - "commands": [ - "npx nx run fulfillment:init-env:netlify-test", - "npx nx build fulfillment" - ], - "parallel": false - } - }, - "init-env": { - "executor": "nx:run-commands", - "options": { - "command": "cp .env.template .env", - "cwd": "apps/fulfillment" - }, - "configurations": { - "netlify-test": { - "command": "cp .env.template .env", - "cwd": "apps/fulfillment" - } - } - }, - "serve": { - "executor": "nx:run-commands", - "options": { - "commands": ["npx vite", "npx nx run fulfillment:build-sw:watch"], - "parallel": true, - "cwd": "apps/fulfillment" - }, - "configurations": { - "no-sw": { - "command": "NO_SW=true npx vite" - } - } - }, - "preview": { - "executor": "nx:run-commands", - "options": { - "command": "npx vite preview --port 4200", - "cwd": "apps/fulfillment" - } - }, - "lint": { - "executor": "@nrwl/linter:eslint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["apps/fulfillment/**/*.ts"] - } - }, - "deps": { - "executor": "./tools/executors/dependency-tree:deps", - "configurations": { - "update": { - "update": true - } - } - } - } -} diff --git a/apps/fulfillment/readme.md b/apps/fulfillment/readme.md deleted file mode 100644 index 2d39b3a6e..000000000 --- a/apps/fulfillment/readme.md +++ /dev/null @@ -1,11 +0,0 @@ -# Fulfillment app - -## App - -1. Set environment variables for Fulfillment App. - Variables description: - - `ORYX_FULFILLMENT_BACKEND_URL` - the url where the backend is hosted. - - `ORYX_FULFILLMENT_PUBLIC_VAPID_KEY` - the public VAPID key to make the application able to subscribe push notifications. - - `ORYX_LABS` - the boolean indicator to let Fulfillment app know if it should use `labs` features - - `ORYX_FULFILLMENT_CLIENT_ID` - the client id for the OAuth flow -2. Run `nx run fulfillment:serve` to start the app in development mode. diff --git a/apps/fulfillment/src/app.ts b/apps/fulfillment/src/app.ts deleted file mode 100644 index d2ced2246..000000000 --- a/apps/fulfillment/src/app.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { appBuilder } from '@spryker-oryx/application'; -import { labsFeatures } from '@spryker-oryx/labs'; -import { fulfillmentFeatures } from '@spryker-oryx/presets/fulfillment'; -import { fulfillmentTheme } from '@spryker-oryx/themes'; - -const env = import.meta.env; - -const features = [ - ...fulfillmentFeatures({ - picking: { - appVersion: env.ORYX_APP_VERSION, - }, - }), - ...(env.ORYX_LABS ? labsFeatures : []), -]; - -appBuilder() - .withEnvironment(env) - .withFeature(features) - .withTheme(fulfillmentTheme) - .create(); diff --git a/apps/fulfillment/src/index.html b/apps/fulfillment/src/index.html deleted file mode 100644 index e9b4baeab..000000000 --- a/apps/fulfillment/src/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/apps/fulfillment/src/public/_redirects b/apps/fulfillment/src/public/_redirects deleted file mode 100644 index c7ccf35d4..000000000 --- a/apps/fulfillment/src/public/_redirects +++ /dev/null @@ -1 +0,0 @@ -/* /index.html 200 diff --git a/apps/fulfillment/src/public/icon.svg b/apps/fulfillment/src/public/icon.svg deleted file mode 100644 index aa80f239f..000000000 --- a/apps/fulfillment/src/public/icon.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - diff --git a/apps/fulfillment/src/styles.css b/apps/fulfillment/src/styles.css deleted file mode 100644 index 90d4ee007..000000000 --- a/apps/fulfillment/src/styles.css +++ /dev/null @@ -1 +0,0 @@ -/* You can add global styles to this file, and also import other style files */ diff --git a/apps/fulfillment/sw/app.ts b/apps/fulfillment/sw/app.ts deleted file mode 100644 index b3b5a75af..000000000 --- a/apps/fulfillment/sw/app.ts +++ /dev/null @@ -1,15 +0,0 @@ -// organize-imports-ignore -import { - bootstrap, - appBuilder, -} from '@spryker-oryx/application/service-worker'; -import { offlineServiceWorkerFulfillmentFeatures } from '@spryker-oryx/presets/fulfillment-sw'; - -appBuilder() - .withEnvironment(process.env) - .withFeature(offlineServiceWorkerFulfillmentFeatures()) - .create() - .then(() => console.debug('Service worker app started!')) - .catch(console.error); - -bootstrap(); diff --git a/apps/fulfillment/tsconfig.app.json b/apps/fulfillment/tsconfig.app.json deleted file mode 100644 index 833847721..000000000 --- a/apps/fulfillment/tsconfig.app.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "types": ["vite/client", "vite-plugin-pwa/client", "node", "web"], - "moduleResolution": "node" - }, - "exclude": ["**/*.spec.ts"], - "include": ["src/**/*.ts"] -} diff --git a/apps/fulfillment/tsconfig.json b/apps/fulfillment/tsconfig.json deleted file mode 100644 index 3ba5c5b24..000000000 --- a/apps/fulfillment/tsconfig.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "files": [], - "include": ["src"], - "references": [ - { - "path": "./tsconfig.app.json" - }, - { - "path": "./tsconfig.sw.json" - }, - { - "path": "./tsconfig.spec.json" - } - ], - "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "types": ["vite/client", "vite-plugin-pwa/client", "vitest", "web", "node"], - "lib": ["ESNext", "DOM", "DOM.Iterable", "WebWorker"], - "noEmit": true, - "strict": true, - "isolatedModules": true, - "experimentalDecorators": true, - "emitDecoratorMetadata": false, - "resolveJsonModule": true, - "useDefineForClassFields": false - } -} diff --git a/apps/fulfillment/tsconfig.spec.json b/apps/fulfillment/tsconfig.spec.json deleted file mode 100644 index 468a009d8..000000000 --- a/apps/fulfillment/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "types": ["vitest/globals", "node"] - }, - "include": ["vite.config.ts", "src/**/*.spec.ts", "src/**/*.d.ts"] -} diff --git a/apps/fulfillment/tsconfig.sw.json b/apps/fulfillment/tsconfig.sw.json deleted file mode 100644 index 4a0021276..000000000 --- a/apps/fulfillment/tsconfig.sw.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "types": ["vite/client", "vite-plugin-pwa/client", "node", "web"], - "sourceMap": true - }, - "exclude": ["src/**/*.ts", "**/*.spec.ts"], - "include": ["sw/**/*.ts"] -} diff --git a/apps/fulfillment/vite.config.sw.ts b/apps/fulfillment/vite.config.sw.ts deleted file mode 100644 index fcc9e4ef7..000000000 --- a/apps/fulfillment/vite.config.sw.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { defineConfig } from 'vite'; -import tsconfigPaths from 'vite-tsconfig-paths'; - -const production = !process.argv.includes('--watch'); - -export default defineConfig(() => { - return { - build: { - outDir: 'dev-dist/sw', - lib: { - entry: 'sw/app.ts', - formats: ['es'], - fileName: (format, entryName) => `${entryName}.js`, - }, - }, - define: { - 'process.env.NODE_ENV': JSON.stringify( - production ? '"production"' : '"development"' - ), - 'process.env.PROD': JSON.stringify(production), - 'process.env.DEV': JSON.stringify(!production), - 'process.env': JSON.stringify(process.env ?? {}), - }, - plugins: [tsconfigPaths({ root: '../../' })], - }; -}); diff --git a/apps/fulfillment/vite.config.ts b/apps/fulfillment/vite.config.ts deleted file mode 100644 index 41f171c24..000000000 --- a/apps/fulfillment/vite.config.ts +++ /dev/null @@ -1,111 +0,0 @@ -import { defineConfig } from 'vite'; -import checker from 'vite-plugin-checker'; -import { VitePWA } from 'vite-plugin-pwa'; -import tsconfigPaths from 'vite-tsconfig-paths'; -import { version } from './package.json'; - -const skipSw = !!process.env.NO_SW; - -export default defineConfig({ - root: './src', - envPrefix: 'ORYX_', - - build: { - outDir: '../dist', - emptyOutDir: true, - sourcemap: true, - }, - define: { - 'import.meta.env.ORYX_APP_VERSION': JSON.stringify(version), - __ORYX_FEATURE_VERSION__: `"${process.env.ORYX_FEATURE_VERSION ?? ''}"`, - }, - - server: { - port: 4200, - host: 'localhost', - }, - - plugins: [ - VitePWA({ - devOptions: { enabled: !skipSw, type: 'module' }, - registerType: 'prompt', - injectRegister: 'auto', - strategies: 'injectManifest', - srcDir: '../dev-dist/sw', - filename: 'app.js', - manifest: { - name: 'Fulfillment App', - short_name: 'Fulfillment App', - theme_color: '#ffffff', - orientation: 'portrait-primary', - icons: [ - { - src: '/icon.svg', - sizes: '192x192 512x512', - type: 'image/svg+xml', - purpose: 'any', - }, - ], - }, - workbox: { - navigateFallback: '/index.html', - clientsClaim: true, - cleanupOutdatedCaches: true, - runtimeCaching: [ - { - urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i, - handler: 'CacheFirst', - options: { - cacheName: 'google-fonts-cache', - expiration: { - maxEntries: 10, - maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days - }, - cacheableResponse: { - statuses: [0, 200], - }, - }, - }, - { - urlPattern: /^https:\/\/fonts\.gstatic\.com\/.*/i, - handler: 'CacheFirst', - options: { - cacheName: 'gstatic-fonts-cache', - expiration: { - maxEntries: 10, - maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days - }, - cacheableResponse: { - statuses: [0, 200], - }, - }, - }, - ], - }, - injectManifest: { - globPatterns: ['**/*.{js,css,html,ico,png,svg,ttf,otf}'], - }, - }), - tsconfigPaths({ root: '../../../' }), - checker({ - typescript: { - tsconfigPath: 'tsconfig.app.json', - }, - }), - ], - - // Uncomment this if you are using WebWorkers - // worker: { - // format: 'es', - // plugins: [tsconfigPaths({ root: '../../' })], - // }, - - test: { - globals: true, - cache: { - dir: '../../node_modules/.vitest', - }, - environment: 'jsdom', - include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], - }, -}); diff --git a/apps/storefront/dependencies.sh b/apps/storefront/dependencies.sh index cad5df495..0a49cdab9 100644 --- a/apps/storefront/dependencies.sh +++ b/apps/storefront/dependencies.sh @@ -1 +1 @@ -DEPENDENCIES="apps/storefront/* libs/base/di/* libs/base/ui/* libs/base/utilities/* libs/domain/cart/* libs/domain/checkout/* libs/domain/content/* libs/domain/merchant/* libs/domain/order/* libs/domain/picking/* libs/domain/product/* libs/domain/search/* libs/domain/site/* libs/domain/user/* libs/platform/auth/* libs/platform/core/* libs/platform/experience/* libs/platform/form/* libs/platform/i18n/* libs/platform/indexed-db/* libs/platform/offline/* libs/platform/push-notification/* libs/platform/router/* libs/template/application/* libs/template/labs/* libs/template/presets/* libs/template/resources/* libs/template/themes/*" \ No newline at end of file +DEPENDENCIES="apps/storefront/* libs/base/di/* libs/base/ui/* libs/base/utilities/* libs/domain/cart/* libs/domain/checkout/* libs/domain/content/* libs/domain/merchant/* libs/domain/order/* libs/domain/product/* libs/domain/search/* libs/domain/site/* libs/domain/user/* libs/platform/auth/* libs/platform/core/* libs/platform/experience/* libs/platform/form/* libs/platform/i18n/* libs/platform/indexed-db/* libs/platform/offline/* libs/platform/push-notification/* libs/platform/router/* libs/template/application/* libs/template/labs/* libs/template/presets/* libs/template/resources/* libs/template/themes/*" diff --git a/apps/storybook/.storybook/app/build.ts b/apps/storybook/.storybook/app/build.ts index bb3abf6e2..4be9eb0d0 100644 --- a/apps/storybook/.storybook/app/build.ts +++ b/apps/storybook/.storybook/app/build.ts @@ -11,7 +11,6 @@ import { I18nFeature } from '@spryker-oryx/i18n'; import { mockMerchantFeature } from '@spryker-oryx/merchant/mocks'; import { mockOfflineFeature } from '@spryker-oryx/offline/mocks'; import { mockOrderFeature } from '@spryker-oryx/order/mocks'; -import { mockPickingFeature } from '@spryker-oryx/picking/mocks'; import { mockProductFeature } from '@spryker-oryx/product/mocks'; import { mockSearchFeature } from '@spryker-oryx/search/mocks'; import { mockSiteFeature } from '@spryker-oryx/site/mocks'; @@ -50,7 +49,6 @@ const builder = appBuilder() .withFeature(multiCartFeature) .withFeature(mockCheckoutFeature) .withFeature(mockOrderFeature) - .withFeature(mockPickingFeature) .withFeature(contentFeature) .withFeature(mockOfflineFeature) .withFeature(mockProductFeature) diff --git a/apps/storybook/.storybook/app/data.ts b/apps/storybook/.storybook/app/data.ts index 0f27d11ed..f665115eb 100644 --- a/apps/storybook/.storybook/app/data.ts +++ b/apps/storybook/.storybook/app/data.ts @@ -1,11 +1,9 @@ import { backofficeResources } from '@spryker-oryx/presets/backoffice'; import { fesResources } from '@spryker-oryx/presets/fes'; -import { fulfillmentResources } from '@spryker-oryx/presets/fulfillment'; import { storefrontResources } from '@spryker-oryx/presets/storefront'; import { backofficeTheme, fesTheme, - fulfillmentTheme, storefrontTheme, } from '@spryker-oryx/themes'; @@ -14,7 +12,6 @@ export const theme = { list: { storefront: [storefrontTheme], backoffice: [backofficeTheme], - fulfillment: [fulfillmentTheme], fes: [fesTheme], }, }; @@ -24,7 +21,6 @@ export const resource = { list: { storefront: storefrontResources, backoffice: backofficeResources, - fulfillment: fulfillmentResources, fes: fesResources, }, }; diff --git a/apps/storybook/dependencies.sh b/apps/storybook/dependencies.sh index 09a4c84d7..4aab638df 100644 --- a/apps/storybook/dependencies.sh +++ b/apps/storybook/dependencies.sh @@ -1 +1 @@ -DEPENDENCIES="apps/storybook/* libs/base/di/* libs/base/ui/* libs/base/utilities/* libs/domain/cart/* libs/domain/checkout/* libs/domain/content/* libs/domain/merchant/* libs/domain/order/* libs/domain/picking/* libs/domain/product/* libs/domain/search/* libs/domain/site/* libs/domain/user/* libs/platform/auth/* libs/platform/core/* libs/platform/experience/* libs/platform/form/* libs/platform/i18n/* libs/platform/indexed-db/* libs/platform/offline/* libs/platform/push-notification/* libs/platform/router/* libs/template/application/* libs/template/presets/* libs/template/resources/* libs/template/themes/*" \ No newline at end of file +DEPENDENCIES="apps/storybook/* libs/base/di/* libs/base/ui/* libs/base/utilities/* libs/domain/cart/* libs/domain/checkout/* libs/domain/content/* libs/domain/merchant/* libs/domain/order/* libs/domain/product/* libs/domain/search/* libs/domain/site/* libs/domain/user/* libs/platform/auth/* libs/platform/core/* libs/platform/experience/* libs/platform/form/* libs/platform/i18n/* libs/platform/indexed-db/* libs/platform/offline/* libs/platform/push-notification/* libs/platform/router/* libs/template/application/* libs/template/presets/* libs/template/resources/* libs/template/themes/*" diff --git a/libs/domain/picking/.constants.ts b/libs/domain/picking/.constants.ts deleted file mode 100644 index a2e255569..000000000 --- a/libs/domain/picking/.constants.ts +++ /dev/null @@ -1 +0,0 @@ -export const storybookPrefix = 'Picking'; diff --git a/libs/domain/picking/CHANGELOG.md b/libs/domain/picking/CHANGELOG.md deleted file mode 100644 index 0ff3d65e2..000000000 --- a/libs/domain/picking/CHANGELOG.md +++ /dev/null @@ -1,125 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -# 1.4.0 (2024-01-16) - - -### Features - -* picking lists filter by ready-for-picking status ([#1056](https://github.com/spryker/oryx/issues/1056)) ([333f52d](https://github.com/spryker/oryx/commit/333f52dde6dcc9534a0fa321af52649ce5c22925)) - - - - - -# 1.3.0 (2023-11-22) - - -### Features - -* add content and logic on user profile ([#422](https://github.com/spryker/oryx/issues/422)) ([d41191a](https://github.com/spryker/oryx/commit/d41191a65cf4ef332836085663a7674e92cc8f09)) -* add e2e tests for picking lists search functionality ([#349](https://github.com/spryker/oryx/issues/349)) ([4f34781](https://github.com/spryker/oryx/commit/4f34781edf4b9f536d71484ba371eebfccc28f8e)) -* add finish button when all pickings are done ([3d976ce](https://github.com/spryker/oryx/commit/3d976ceec091abbabd3f300d6f34495d5b990d6c)) -* add stories for fulfillment user profile component ([#488](https://github.com/spryker/oryx/issues/488)) ([decea5c](https://github.com/spryker/oryx/commit/decea5c904be50687fe9ac81f885c13f27d3814b)) -* adjust header and user modal ([#603](https://github.com/spryker/oryx/issues/603)) ([cdb9182](https://github.com/spryker/oryx/commit/cdb9182643df79389ad9f694ab4d89d80561095c)) -* clean up old online entities in fulfillment app ([#229](https://github.com/spryker/oryx/issues/229)) ([94ab810](https://github.com/spryker/oryx/commit/94ab8100188913353b2efd43e31b7fcc69ec71e9)) -* customer note migration ([#182](https://github.com/spryker/oryx/issues/182)) ([7151846](https://github.com/spryker/oryx/commit/71518467f5cda4c7f153754d161a54288be1e549)) -* disable dev check demo data ([#116](https://github.com/spryker/oryx/issues/116)) ([8505167](https://github.com/spryker/oryx/commit/850516723d48a8b7c6d66bc25e67401ec669c79c)) -* expand fulfillment login e2e tests ([#318](https://github.com/spryker/oryx/issues/318)) ([8d654be](https://github.com/spryker/oryx/commit/8d654be4fb133b33de3e812e21854968bea5a031)), closes [#320](https://github.com/spryker/oryx/issues/320) -* extract customer note modal in separate component ([#406](https://github.com/spryker/oryx/issues/406)) ([6208020](https://github.com/spryker/oryx/commit/62080203342eba6bb9fffde84f4613e3310db99a)) -* FA filters ([#331](https://github.com/spryker/oryx/issues/331)) ([ac8a68d](https://github.com/spryker/oryx/commit/ac8a68d39b1e18f6b7e52cacaea62622634ccdd2)) -* fa filters e2es ([#372](https://github.com/spryker/oryx/issues/372)) ([fda417f](https://github.com/spryker/oryx/commit/fda417fd0d94784840e953eeb7d9d5b51280a080)) -* FA filters unit tests ([#348](https://github.com/spryker/oryx/issues/348)) ([615ad25](https://github.com/spryker/oryx/commit/615ad2560cf7997bd602b46f291df8dd340ab5d5)) -* fulfillment app boilerplate improvements ([#790](https://github.com/spryker/oryx/issues/790)) ([055ca1b](https://github.com/spryker/oryx/commit/055ca1bff348fb82beb896d7f9442ae2fced814b)) -* **fulfillment:** notify user about push notification support and permission ([#914](https://github.com/spryker/oryx/issues/914)) ([ce6bfdb](https://github.com/spryker/oryx/commit/ce6bfdb27cc703762b5ee4b1daeee7308c25e234)) -* fullscreen modal size on small screen ([#496](https://github.com/spryker/oryx/issues/496)) ([a60bd1c](https://github.com/spryker/oryx/commit/a60bd1c9f5e0678b16ebed6fd5fb4178c5ddd677)) -* **graphical:** icon directionality ([#857](https://github.com/spryker/oryx/issues/857)) ([764ee63](https://github.com/spryker/oryx/commit/764ee634f7764c931b1ee1cd1018acd055b7f385)) -* implement discard modal ([#398](https://github.com/spryker/oryx/issues/398)) ([d4a7c2d](https://github.com/spryker/oryx/commit/d4a7c2d3eb56ed694d33f550fa87d450b2cb22fe)) -* implement fulfillment login page ([#213](https://github.com/spryker/oryx/issues/213)) ([179670d](https://github.com/spryker/oryx/commit/179670d88338241e26cedc05bbe73c52565a020a)), closes [#234](https://github.com/spryker/oryx/issues/234) -* implement fulfillment offline unit tests ([#289](https://github.com/spryker/oryx/issues/289)) ([4e305fa](https://github.com/spryker/oryx/commit/4e305facf1cffb3ce3e98b1a2143d631c7be03d0)) -* implement fulfillment user navigation item ([#408](https://github.com/spryker/oryx/issues/408)) ([b6656d8](https://github.com/spryker/oryx/commit/b6656d85c620982294f51a6195e9c5bab40401a0)) -* implement picking header ([#392](https://github.com/spryker/oryx/issues/392)) ([ea10272](https://github.com/spryker/oryx/commit/ea102729b65af86c0791b7fc56bfa5ae6ec6d365)) -* implement picking in progress modal ([#328](https://github.com/spryker/oryx/issues/328)) ([334336d](https://github.com/spryker/oryx/commit/334336d2a13240fd5a01423382b1ea232d9f810f)), closes [#343](https://github.com/spryker/oryx/issues/343) -* implement product card and picking logic ([83bb92b](https://github.com/spryker/oryx/commit/83bb92b34ee8d6638e0370d5836ebdc3fdccbd3a)) -* implement push notification handling ([#358](https://github.com/spryker/oryx/issues/358)) ([47bd6c5](https://github.com/spryker/oryx/commit/47bd6c566b897f3bd8b70877246549d49bbe36f2)) -* implement unit tests for fulfillment user profile component ([#497](https://github.com/spryker/oryx/issues/497)) ([2ac46d7](https://github.com/spryker/oryx/commit/2ac46d7228f26392d523d0be4b12a5329e56718f)) -* implement warehouse selection page ([#571](https://github.com/spryker/oryx/issues/571)) ([2aed70d](https://github.com/spryker/oryx/commit/2aed70d0b4df462946128cda9ce762c046c3d04f)) -* migate picking-lists to picking domain ([#111](https://github.com/spryker/oryx/issues/111)) ([0e9d9fa](https://github.com/spryker/oryx/commit/0e9d9fae5a265e940397c1b1b2e9ac440f46f33b)), closes [#171](https://github.com/spryker/oryx/issues/171) [#157](https://github.com/spryker/oryx/issues/157) -* migrate productV2 -> product entity ([#160](https://github.com/spryker/oryx/issues/160)) ([921d1e8](https://github.com/spryker/oryx/commit/921d1e85b9157899986971e44ef93bbf027d68bf)) -* modal full width footer button ([#179](https://github.com/spryker/oryx/issues/179)) ([6c21d01](https://github.com/spryker/oryx/commit/6c21d014fb359d352c3c6eb115343f1eeabdb9b5)) -* move picking fulfillment libs to oryx ([#101](https://github.com/spryker/oryx/issues/101)) ([11720c4](https://github.com/spryker/oryx/commit/11720c4f06004ed71606d19a8be44921f4da8119)) -* picking header back button logic ([#417](https://github.com/spryker/oryx/issues/417)) ([3e4fd00](https://github.com/spryker/oryx/commit/3e4fd007327fb5359c662c290a6bac3e0459ef32)) -* picking lists header ([#307](https://github.com/spryker/oryx/issues/307)) ([d81f757](https://github.com/spryker/oryx/commit/d81f757b9a673aa5da773dc013060ffcd0cc9ef0)) -* **picking:** drop headers components ([#924](https://github.com/spryker/oryx/issues/924)) ([e65e9f8](https://github.com/spryker/oryx/commit/e65e9f8a0270a7e4ac68d23e9a904ce962e9a6de)) -* **picking:** implement picking lists component loading indicator ([#691](https://github.com/spryker/oryx/issues/691)) ([aa9dd36](https://github.com/spryker/oryx/commit/aa9dd36ff2eb13501c7fb5ffa2d75624330a4fa2)) -* replace hardcoded time formatting method ([#206](https://github.com/spryker/oryx/issues/206)) ([77e8cb8](https://github.com/spryker/oryx/commit/77e8cb80d21e9dc0d1091c006061aefa5ec63c91)) -* set placeholder when there is no picking lists ([#285](https://github.com/spryker/oryx/issues/285)) ([c6e27ac](https://github.com/spryker/oryx/commit/c6e27ac3e7d78034554556c728f87c7a5479d25f)) -* storage service strategies ([#855](https://github.com/spryker/oryx/issues/855)) ([38bca16](https://github.com/spryker/oryx/commit/38bca16c8bd2cf8b807e7d22ad5a97e671875500)) -* style fulfillment login page ([#313](https://github.com/spryker/oryx/issues/313)) ([dcae0ad](https://github.com/spryker/oryx/commit/dcae0ad9139eaab935d4c04498e8f3c12ce28fb9)) -* support for equality function in signals ([#409](https://github.com/spryker/oryx/issues/409)) ([7db88d7](https://github.com/spryker/oryx/commit/7db88d70a2ba3adc50221d89ca73590c510f29f7)) -* update adapter to support search ([#309](https://github.com/spryker/oryx/issues/309)) ([338caee](https://github.com/spryker/oryx/commit/338caee85311e0bc4863e3a76f99c4b5391fcda8)) - - -### Bug Fixes - -* hydration issues ([#211](https://github.com/spryker/oryx/issues/211)) ([64b9426](https://github.com/spryker/oryx/commit/64b94261bd394371210968fde748e964a349b00b)) -* add missing grey background to picking empty tab contents ([#660](https://github.com/spryker/oryx/issues/660)) ([1b071a8](https://github.com/spryker/oryx/commit/1b071a8e176cf1c37ebb26c0dfc61375655bfda7)) -* adjust selected tab chip color ([#243](https://github.com/spryker/oryx/issues/243)) ([55a39a4](https://github.com/spryker/oryx/commit/55a39a49abae746099555d2f6735f3b81d975e4c)) -* avoid user id when unknown ([#906](https://github.com/spryker/oryx/issues/906)) ([366293c](https://github.com/spryker/oryx/commit/366293c8df74ca0b914ec1dcbd2a1c2d7848a936)) -* back button does not return user to Picking Lists page ([#481](https://github.com/spryker/oryx/issues/481)) ([2dbecb4](https://github.com/spryker/oryx/commit/2dbecb40a4d54a68da02c8672c349614be727e67)) -* center picking login text on small screens ([#462](https://github.com/spryker/oryx/issues/462)) ([e6f2601](https://github.com/spryker/oryx/commit/e6f26015c3eeb7c632210d45931bb70a9ebfaae8)) -* change reset button color ([8b68fab](https://github.com/spryker/oryx/commit/8b68fab34af823f75ac3cbef3a7a68f07ad681b2)) -* correct sorting order ([#353](https://github.com/spryker/oryx/issues/353)) ([79a9725](https://github.com/spryker/oryx/commit/79a9725cd70af6be6315bb997b406f3388b432f4)) -* don't load offline data plugin in service worker ([#347](https://github.com/spryker/oryx/issues/347)) ([5f337d3](https://github.com/spryker/oryx/commit/5f337d3a65f1948d59665db9dcc6242d033dd4b3)) -* don't navigate when clicking picking in progress modal overlay on customer note page ([#396](https://github.com/spryker/oryx/issues/396)) ([f0b012e](https://github.com/spryker/oryx/commit/f0b012e9ac66da65dc4cbdc1f6c57b58e329529f)) -* esmodule issue for json-serializer ([#304](https://github.com/spryker/oryx/issues/304)) ([4a649fb](https://github.com/spryker/oryx/commit/4a649fbb43f15ad73366793ef80afc7ddfb0ee6e)) -* fa filters feature paddings ([#379](https://github.com/spryker/oryx/issues/379)) ([5d7fdaf](https://github.com/spryker/oryx/commit/5d7fdaff9773689b93e1c04a1e10f63b779bf907)) -* FA sw auth ([#367](https://github.com/spryker/oryx/issues/367)) ([1cd7970](https://github.com/spryker/oryx/commit/1cd79701d9c60a4188b3496e9397a622fc2e6eb2)) -* **fa:** fix start picking response handling ([#232](https://github.com/spryker/oryx/issues/232)) ([f02a62b](https://github.com/spryker/oryx/commit/f02a62bce683aa3a46086f1a3625aad1a5e024d2)) -* **fa:** update picking lists api request relationships ([#245](https://github.com/spryker/oryx/issues/245)) ([bf4fc02](https://github.com/spryker/oryx/commit/bf4fc02235495bfd02fc69b06f8aa3e4be8205d7)) -* fix missing picking header title ([#649](https://github.com/spryker/oryx/issues/649)) ([b484727](https://github.com/spryker/oryx/commit/b48472700318a47353dc03d88559902c8670dac6)) -* Fixed wrong imports and dependencies to make dev SSR build working ([#299](https://github.com/spryker/oryx/issues/299)) ([1ca1fab](https://github.com/spryker/oryx/commit/1ca1fabc034a435f089f977dc05189bd11d409ac)) -* **fulfillment:** override sapi locale adapter with default one ([#805](https://github.com/spryker/oryx/issues/805)) ([fea8565](https://github.com/spryker/oryx/commit/fea8565d40b3c9da06950a7f30a78b008179c987)) -* grey backgrounds for picking and picking list pages ([#468](https://github.com/spryker/oryx/issues/468)) ([5051a5f](https://github.com/spryker/oryx/commit/5051a5f8d783c4f9772517f8f9de71fc6b8ceaac)) -* HRZ-2278 2nd part of fixes for release ([#118](https://github.com/spryker/oryx/issues/118)) ([992c587](https://github.com/spryker/oryx/commit/992c58714eed594fe900d2645bba4a9a59c0fee2)) -* log out button displays loading indicator when clicked ([#565](https://github.com/spryker/oryx/issues/565)) ([e816bc5](https://github.com/spryker/oryx/commit/e816bc53621efcadfc5b3c397bc1bf68a8b5b23d)) -* min height for fulfillment app & sticky button on picking page ([#231](https://github.com/spryker/oryx/issues/231)) ([42d7301](https://github.com/spryker/oryx/commit/42d7301c72a8c1c4d6809dd688c98808c74f4f42)) -* missed loading states on "Start picking" and "Proceed to picking" ([#223](https://github.com/spryker/oryx/issues/223)) ([9aea256](https://github.com/spryker/oryx/commit/9aea256047dfa31c6bd30b7620fd0f3a1e0f3f6b)) -* move locale into i18n package ([#181](https://github.com/spryker/oryx/issues/181)) ([eb20c5d](https://github.com/spryker/oryx/commit/eb20c5dbf5bbb35e829b9faa1c1ada8bdc34203a)) -* no fallback image and text on picking ([#503](https://github.com/spryker/oryx/issues/503)) ([6e07ca1](https://github.com/spryker/oryx/commit/6e07ca121a038ee3ceb63b596cebde3607ef301f)) -* passing invalid Date object ([#509](https://github.com/spryker/oryx/issues/509)) ([b5c77ca](https://github.com/spryker/oryx/commit/b5c77ca43d1544a4699561b1645edc7682286791)) -* picking app styling issues ([#227](https://github.com/spryker/oryx/issues/227)) ([e1f9f6b](https://github.com/spryker/oryx/commit/e1f9f6ba9e6b24dd5d18741b7f829925631fc8b1)) -* picking list card shows wrong order ID and pick up time ([#317](https://github.com/spryker/oryx/issues/317)) ([32b0ccc](https://github.com/spryker/oryx/commit/32b0ccca0ee9dfd9f3a9251a0db96fe611f438b7)) -* picking list demo story flaky date ([#421](https://github.com/spryker/oryx/issues/421)) ([debcca1](https://github.com/spryker/oryx/commit/debcca144c73136a1b15205062e05c37bf13028e)) -* **picking:** change start picking endpoint ([#801](https://github.com/spryker/oryx/issues/801)) ([e92f1dc](https://github.com/spryker/oryx/commit/e92f1dcc59ecff74e21cd9351359c10735c08b77)) -* **picking:** do not redirect after clicking receiving data in UserProfileComponent ([#688](https://github.com/spryker/oryx/issues/688)) ([ce931a6](https://github.com/spryker/oryx/commit/ce931a68d6f921309d3187a4810664d6844453b5)) -* **picking:** fix finish picking button width in picking component ([#694](https://github.com/spryker/oryx/issues/694)) ([9c77dda](https://github.com/spryker/oryx/commit/9c77ddae61b17e0b3044506f8e3632f07c1dc144)) -* **picking:** fix z-index for picking lists header in `pickingListsComponent` ([#689](https://github.com/spryker/oryx/issues/689)) ([48a491e](https://github.com/spryker/oryx/commit/48a491ed568cb275059ef2eae1b9fbfb58b540e9)) -* **picking:** keep old styles for picking login ([#793](https://github.com/spryker/oryx/issues/793)) ([a161b43](https://github.com/spryker/oryx/commit/a161b43392e4e7aec084505b5ef16147ba1dd231)) -* **picking:** picking lists page clear search behaviour ([#932](https://github.com/spryker/oryx/issues/932)) ([41de6f4](https://github.com/spryker/oryx/commit/41de6f49dd8e309177b12109fad9d4b14ee201c3)) -* **picking:** push permissions earlier check ([#915](https://github.com/spryker/oryx/issues/915)) ([d57996c](https://github.com/spryker/oryx/commit/d57996cbd131a7c33b46d3482eb40dc98fa6b844)) -* **picking:** receiving picking lists with previously unknown products ([#836](https://github.com/spryker/oryx/issues/836)) ([4577427](https://github.com/spryker/oryx/commit/4577427ac25aed80fdd94f2296537b8d2dbb3f7f)) -* **picking:** redirect to main page from `WarehouseAssignmentComponent` if there is only one warehouse ([f0e9600](https://github.com/spryker/oryx/commit/f0e9600f929c642577e9eeadabd0e52a5051ac08)) -* **picking:** return null in PickingListDefaultAdapter if concrete product image set is missing ([#683](https://github.com/spryker/oryx/issues/683)) ([88d23e3](https://github.com/spryker/oryx/commit/88d23e3f5b83926b8a3a362449fb66fbf1bab9c6)) -* **picking:** use item id instead of order item id in finish picking request ([#797](https://github.com/spryker/oryx/issues/797)) ([99c59a3](https://github.com/spryker/oryx/commit/99c59a3dc0cbac0d1eee28125f9771cd763986fa)) -* **picking:** wrong number of picked items ([#831](https://github.com/spryker/oryx/issues/831)) ([2fbb53a](https://github.com/spryker/oryx/commit/2fbb53a67537ef4daae26188dfc8e222742d916f)) -* **picking:** wrong status merging ([#833](https://github.com/spryker/oryx/issues/833)) ([98775f8](https://github.com/spryker/oryx/commit/98775f8cb4fc406f9ceb1b140d32c9884fe1b3a6)) -* product card edit on picking page ([#248](https://github.com/spryker/oryx/issues/248)) ([5133f6b](https://github.com/spryker/oryx/commit/5133f6b2fc1f2639b9b003f7c57e0606fa03eca6)) -* release preparation ([#150](https://github.com/spryker/oryx/issues/150)) ([1225f74](https://github.com/spryker/oryx/commit/1225f74b48928d61d0574a9dc275999c1f0602ac)) -* Release/v0.2.0 ([#131](https://github.com/spryker/oryx/issues/131)) ([f7b7ba9](https://github.com/spryker/oryx/commit/f7b7ba9b8dba11e407269fb14b120792b664ab9d)) -* **search:** search box on small screens ([#754](https://github.com/spryker/oryx/issues/754)) ([e18028d](https://github.com/spryker/oryx/commit/e18028d5d85ab8f5ebe14d9a074ff5612c9ec36c)) -* set correct picking item id instead of product id ([5ec32b5](https://github.com/spryker/oryx/commit/5ec32b5f3aa8db9b33f2294e3a49f3450d967bf4)) -* show correct id in picking header ([#467](https://github.com/spryker/oryx/issues/467)) ([3241630](https://github.com/spryker/oryx/commit/324163025749ac7db932af14dfac4701a8ac0cef)) -* show picking lists header above page contents ([#354](https://github.com/spryker/oryx/issues/354)) ([afbe66a](https://github.com/spryker/oryx/commit/afbe66a982e73bfa9fff9b2eb9bfe2ee4bad8d32)) -* simplify picking service ([#242](https://github.com/spryker/oryx/issues/242)) ([220c60a](https://github.com/spryker/oryx/commit/220c60a38d0cca207e60ec558b981ea91b424e05)) -* sorting form is not confirming by "Enter" key ([#510](https://github.com/spryker/oryx/issues/510)) ([52dff55](https://github.com/spryker/oryx/commit/52dff55e41edd2f0e69cdba590f7b7ad28b247cf)) -* sticky tabs for picking ([#247](https://github.com/spryker/oryx/issues/247)) ([25581d9](https://github.com/spryker/oryx/commit/25581d9671b7e62bda0e2b43edfa4de6a74f502b)) -* switch fulfillment icons to material designs ([#480](https://github.com/spryker/oryx/issues/480)) ([3cd22a2](https://github.com/spryker/oryx/commit/3cd22a2e86c8f183895028ad53b6308575b825c7)) -* sync picking lists ([#520](https://github.com/spryker/oryx/issues/520)) ([8e46f86](https://github.com/spryker/oryx/commit/8e46f8626815a5e8af9c4b8b3f5b9d90111be3ec)) -* translation pluralization ([#500](https://github.com/spryker/oryx/issues/500)) ([56fefa7](https://github.com/spryker/oryx/commit/56fefa71cbd01891a574edf04959f622a2a4d6a9)) -* typos and capitalization ([#501](https://github.com/spryker/oryx/issues/501)) ([39930e6](https://github.com/spryker/oryx/commit/39930e69e65a3a0815491d32cc985c6d769ee87f)) -* update fulfillment login title margins ([#653](https://github.com/spryker/oryx/issues/653)) ([0fd82da](https://github.com/spryker/oryx/commit/0fd82da718a10a28a21b5767c2e3f3523cda41a1)) -* use content-type application/vnd.api+json ([#305](https://github.com/spryker/oryx/issues/305)) ([4224ab0](https://github.com/spryker/oryx/commit/4224ab088d9a93d02324d8c00fff90e1aba39e52)) -* wrong text in customer note ([#314](https://github.com/spryker/oryx/issues/314)) ([1a7c31b](https://github.com/spryker/oryx/commit/1a7c31b38d72bff09f54b2b5b59f8d87da28dda0)) diff --git a/libs/domain/picking/README.md b/libs/domain/picking/README.md deleted file mode 100644 index 67ecb4627..000000000 --- a/libs/domain/picking/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# picking - -This library was generated with [Nx](https://nx.dev). - -## Running lint - -Run `nx lint picking` to execute the lint via [ESLint](https://eslint.org/). diff --git a/libs/domain/picking/customer-note-modal/customer-note-modal.component.spec.ts b/libs/domain/picking/customer-note-modal/customer-note-modal.component.spec.ts deleted file mode 100644 index 8f9cff8fe..000000000 --- a/libs/domain/picking/customer-note-modal/customer-note-modal.component.spec.ts +++ /dev/null @@ -1,151 +0,0 @@ -import { fixture } from '@open-wc/testing-helpers'; -import { createInjector, destroyInjector } from '@spryker-oryx/di'; -import { mockPickingListData } from '@spryker-oryx/picking/mocks'; -import { PickingListService } from '@spryker-oryx/picking/services'; -import { ButtonColor, ButtonSize, ButtonType } from '@spryker-oryx/ui/button'; -import { IconTypes } from '@spryker-oryx/ui/icon'; -import { i18n, useComponent } from '@spryker-oryx/utilities'; -import { html } from 'lit'; -import { of } from 'rxjs'; -import { afterEach, beforeAll, beforeEach } from 'vitest'; -import { PickingCustomerNoteModalComponent } from './customer-note-modal.component'; -import { pickingCustomerNoteModalComponent } from './customer-note-modal.def'; - -class MockPickingListService implements Partial { - getList = vi.fn().mockReturnValue(of(mockPickingListData[0])); - getUpcomingPickingListId = vi.fn().mockReturnValue(of(null)); -} - -const note = mockPickingListData[0].cartNote; -const id = mockPickingListData[0].id; - -describe('PickingCustomerNoteModal', () => { - let element: PickingCustomerNoteModalComponent; - let service: MockPickingListService; - - beforeAll(async () => { - await useComponent([pickingCustomerNoteModalComponent]); - }); - - beforeEach(async () => { - const testInjector = createInjector({ - providers: [ - { - provide: PickingListService, - useClass: MockPickingListService, - }, - ], - }); - - service = testInjector.inject(PickingListService); - - element = await fixture( - html`` - ); - }); - - afterEach(() => { - vi.clearAllMocks(); - destroyInjector(); - }); - - it('passes the a11y audit', async () => { - await expect(element).shadowDom.to.be.accessible(); - }); - - it('should render order`s cart note', () => { - expect(element?.renderRoot.textContent?.trim()).toContain(note); - }); - - it('should render the trigger with proper attributes', () => { - const button = element.renderRoot.querySelector('oryx-button'); - expect(button).not.toBe(null); - expect(button?.getAttribute('type')).toBe(ButtonType.Icon); - expect(button?.getAttribute('label')).toBe( - i18n('oryx.picking.customer-note') - ); - expect(button?.getAttribute('icon')).toBe(IconTypes.Info); - }); - - it('should render the modal', () => { - expect(element).toContainElement( - 'oryx-modal[enableFooter][footerButtonFullWidth][minimal]' - ); - }); - - it('should render the header', () => { - expect(element).toContainElement('oryx-heading h2'); - expect( - element.renderRoot.querySelector('oryx-heading h2')?.textContent - ).toContain(i18n('picking-lists.customer-note.customer-note')); - }); - - it('should render the modal`s button with proper attributes', () => { - const button = element.renderRoot.querySelector( - 'oryx-button[slot="footer"]' - ); - expect(button).not.toBe(null); - expect(button?.getAttribute('color')).toBe(ButtonColor.Primary); - expect(button?.getAttribute('size')).toBe(ButtonSize.Md); - expect(button?.getAttribute('icon')).toBe(IconTypes.Check); - expect(button?.getAttribute('text')).toBe( - i18n('picking-lists.customer-note.got-it') - ); - }); - - describe('and trigger is clicked', () => { - beforeEach(() => { - element.renderRoot - .querySelector('oryx-button') - ?.dispatchEvent(new MouseEvent('click')); - }); - - it('should open the modal', () => { - expect(element).toContainElement('oryx-modal[open]'); - }); - - describe('and modal`s button is clicked', () => { - beforeEach(() => { - element.renderRoot - .querySelector('oryx-button[slot]') - ?.dispatchEvent(new MouseEvent('click')); - }); - - it('should closes the modal', () => { - expect(element).toContainElement('oryx-modal:not([open])'); - }); - }); - }); - - describe('when trigger is hidden', () => { - beforeEach(async () => { - element = await fixture( - html`` - ); - }); - - it('should not render the trigger', () => { - expect(element).not.toContainElement('oryx-button:not([slot])'); - }); - }); - - describe('when order does not contain cart note', () => { - beforeEach(async () => { - service.getList = vi.fn().mockReturnValue(of(mockPickingListData[1])); - element = await fixture( - html`` - ); - }); - - it('should not render the content', () => { - expect(element).not.toContainElement('oryx-modal, oryx-button'); - }); - }); -}); diff --git a/libs/domain/picking/customer-note-modal/customer-note-modal.component.ts b/libs/domain/picking/customer-note-modal/customer-note-modal.component.ts deleted file mode 100644 index 7c4b03c5c..000000000 --- a/libs/domain/picking/customer-note-modal/customer-note-modal.component.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { PickingListMixin } from '@spryker-oryx/picking'; -import { ButtonColor, ButtonSize, ButtonType } from '@spryker-oryx/ui/button'; -import { HeadingTag } from '@spryker-oryx/ui/heading'; -import { IconTypes } from '@spryker-oryx/ui/icon'; -import { I18nMixin, computed, featureVersion } from '@spryker-oryx/utilities'; -import { LitElement, TemplateResult, html } from 'lit'; -import { property } from 'lit/decorators.js'; -import { when } from 'lit/directives/when.js'; -import { PickingCustomerNoteComponentProperties } from './customer-note-modal.model'; - -export class PickingCustomerNoteModalComponent - extends I18nMixin(PickingListMixin(LitElement)) - implements PickingCustomerNoteComponentProperties -{ - @property({ type: Boolean }) open?: boolean; - @property({ type: Boolean }) hideTrigger?: boolean; - - protected $cartNote = computed(() => this.$pickingList()?.cartNote); - - protected override render(): TemplateResult | void { - if (!this.$cartNote()) return; - - return html` - ${when( - !this.hideTrigger, - () => html` (this.open = true)} - > ` - )} - - - ${this.__renderHeading()}${this.$cartNote()} - - (this.open = false)} - > - - `; - } - - // temporary implementation for backwards compatibility - private __renderHeading(): TemplateResult { - const text = this.i18n('picking-lists.customer-note.customer-note'); - if (featureVersion >= '1.4') { - return html` - ${text} - `; - } else { - return html` -

${text}

-
`; - } - } -} diff --git a/libs/domain/picking/customer-note-modal/customer-note-modal.def.ts b/libs/domain/picking/customer-note-modal/customer-note-modal.def.ts deleted file mode 100644 index b03f3de40..000000000 --- a/libs/domain/picking/customer-note-modal/customer-note-modal.def.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { componentDef } from '@spryker-oryx/utilities'; - -export const pickingCustomerNoteModalComponent = componentDef({ - name: 'oryx-picking-customer-note-modal', - impl: () => - import('./customer-note-modal.component').then( - (m) => m.PickingCustomerNoteModalComponent - ), -}); diff --git a/libs/domain/picking/customer-note-modal/customer-note-modal.model.ts b/libs/domain/picking/customer-note-modal/customer-note-modal.model.ts deleted file mode 100644 index 46cc2f732..000000000 --- a/libs/domain/picking/customer-note-modal/customer-note-modal.model.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface PickingCustomerNoteComponentProperties { - open?: boolean; - hideTrigger?: boolean; -} diff --git a/libs/domain/picking/customer-note-modal/index.ts b/libs/domain/picking/customer-note-modal/index.ts deleted file mode 100644 index fe1755288..000000000 --- a/libs/domain/picking/customer-note-modal/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './customer-note-modal.component'; -export * from './customer-note-modal.model'; diff --git a/libs/domain/picking/customer-note/customer-note.component.spec.ts b/libs/domain/picking/customer-note/customer-note.component.spec.ts deleted file mode 100644 index 4902179ef..000000000 --- a/libs/domain/picking/customer-note/customer-note.component.spec.ts +++ /dev/null @@ -1,169 +0,0 @@ -import { fixture } from '@open-wc/testing-helpers'; -import { createInjector, destroyInjector } from '@spryker-oryx/di'; -import { pickingInProgressModalComponent } from '@spryker-oryx/picking'; -import { mockPickingListData } from '@spryker-oryx/picking/mocks'; -import { PickingInProgressModalComponent } from '@spryker-oryx/picking/picking-in-progress'; -import { - PickingListError, - PickingListService, -} from '@spryker-oryx/picking/services'; -import { RouterService } from '@spryker-oryx/router'; -import { modalComponent } from '@spryker-oryx/ui'; -import { useComponent } from '@spryker-oryx/utilities'; -import { html } from 'lit'; -import { of, throwError } from 'rxjs'; -import { PickingCustomerNoteComponent } from './customer-note.component'; -import { pickingCustomerNoteComponent } from './customer-note.def'; - -class MockRouterService implements Partial { - navigate = vi.fn(); -} - -class MockPickingListService implements Partial { - getList = vi.fn().mockReturnValue(of(mockPickingListData[0])); - startPicking = vi.fn().mockReturnValue(of(mockPickingListData[0])); - getUpcomingPickingListId = vi.fn().mockReturnValue(of(null)); -} - -describe('PickingCustomerNoteComponent', () => { - let element: PickingCustomerNoteComponent; - let service: MockPickingListService; - let routerService: MockRouterService; - - const getPickingInProgressModal = () => { - return element.renderRoot.querySelector( - 'oryx-picking-in-progress-modal' - ) as PickingInProgressModalComponent; - }; - - beforeAll(async () => { - await useComponent([ - pickingCustomerNoteComponent, - pickingInProgressModalComponent, - modalComponent, - ]); - }); - - beforeEach(async () => { - const testInjector = createInjector({ - providers: [ - { - provide: RouterService, - useClass: MockRouterService, - }, - { - provide: PickingListService, - useClass: MockPickingListService, - }, - ], - }); - service = testInjector.inject( - PickingListService - ) as unknown as MockPickingListService; - routerService = testInjector.inject( - RouterService - ) as unknown as MockRouterService; - - element = await fixture( - html`` - ); - }); - - afterEach(() => { - destroyInjector(); - vi.clearAllMocks(); - }); - - it('passes the a11y audit', async () => { - await expect(element).shadowDom.to.be.accessible(); - }); - - it('should render customer note', () => { - const customerNote = element.renderRoot.querySelector('p'); - expect(customerNote?.textContent).toContain( - mockPickingListData[0].cartNote - ); - }); - - describe('when picking is proceed', () => { - beforeEach(() => { - element.renderRoot - .querySelectorAll('oryx-button')?.[1] - ?.click(); - }); - - it('should start picking with current picking list', () => { - expect(service.startPicking).toHaveBeenCalledWith(mockPickingListData[0]); - }); - - it('should navigate by route with picking list id', () => { - expect(routerService.navigate).toHaveBeenCalledWith( - expect.stringContaining(mockPickingListData[0].id) - ); - }); - - describe('and picking is already in progress', () => { - beforeEach(async () => { - routerService.navigate.mockClear(); - service.startPicking = vi.fn().mockReturnValue( - throwError(() => { - const error = new Error('mock') as PickingListError; - error.status = 409; - return error; - }) - ); - - element = await fixture( - html`` - ); - - element.renderRoot - .querySelectorAll('oryx-button')[1] - ?.click(); - }); - - it('should not navigate route', () => { - expect(routerService.navigate).not.toHaveBeenCalledWith( - '/picking-list/picking/withCartNote' - ); - }); - - it('should open picking in progress modal', () => { - expect(getPickingInProgressModal().open).toBe(true); - }); - - describe('and picking in progress modal is dismissed', () => { - beforeEach(() => { - getPickingInProgressModal() - .shadowRoot?.querySelector('oryx-modal') - ?.shadowRoot?.querySelector('dialog') - ?.click(); - }); - - it('should not navigate to picking lists', () => { - expect(routerService.navigate).not.toHaveBeenCalledWith('/'); - }); - - it('should close modal', () => { - expect(getPickingInProgressModal().open).toBe(false); - }); - }); - - describe('and back to pick lists button is clicked', () => { - beforeEach(() => { - getPickingInProgressModal() - .shadowRoot?.querySelector('oryx-button') - ?.click(); - }); - - it('should navigate to picking lists', () => { - expect(routerService.navigate).toHaveBeenCalledWith('/'); - }); - }); - }); - }); -}); diff --git a/libs/domain/picking/customer-note/customer-note.component.ts b/libs/domain/picking/customer-note/customer-note.component.ts deleted file mode 100644 index 1d74fa5c7..000000000 --- a/libs/domain/picking/customer-note/customer-note.component.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { resolve } from '@spryker-oryx/di'; -import { PickingListMixin } from '@spryker-oryx/picking'; -import { PickingInProgressModalComponent } from '@spryker-oryx/picking/picking-in-progress'; -import { RouterService } from '@spryker-oryx/router'; -import { ButtonColor, ButtonSize, ButtonType } from '@spryker-oryx/ui/button'; -import { HeadingTag } from '@spryker-oryx/ui/heading'; -import { IconTypes } from '@spryker-oryx/ui/icon'; -import { I18nMixin, featureVersion } from '@spryker-oryx/utilities'; -import { LitElement, TemplateResult, html } from 'lit'; -import { query } from 'lit/decorators.js'; -import { catchError, of, tap } from 'rxjs'; -import { customerNoteComponentStyles } from './customer-note.styles'; - -export class PickingCustomerNoteComponent extends I18nMixin( - PickingListMixin(LitElement) -) { - static styles = customerNoteComponentStyles; - - protected routerService = resolve(RouterService); - - @query('oryx-picking-in-progress-modal') - protected pickingInProgressModal!: PickingInProgressModalComponent; - - protected onProceed(): void { - //TODO: provide more complex validation - if (!this.$pickingList()) { - return; - } - - this.pickingListService - .startPicking(this.$pickingList()) - .pipe( - tap(() => - this.routerService.navigate( - `/picking-list/picking/${this.$pickingList().id}` - ) - ), - catchError((e) => { - if (e.status === 409) { - this.pickingInProgressModal.open = true; - } - return of(undefined); - }) - ) - .subscribe(); - } - - protected override render(): TemplateResult { - return html` -
- - - ${this.__renderHeading()} -
- -

${this.$pickingList()?.cartNote}

- - - - - `; - } - - // temporary implementation for backwards compatibility - private __renderHeading(): TemplateResult { - const text = this.i18n('picking.customer-note'); - if (featureVersion >= '1.4') { - return html` - ${text} - `; - } else { - return html` -

${text}

-
`; - } - } - - protected closePickingInProgressModal(): void { - this.routerService.navigate('/'); - } -} diff --git a/libs/domain/picking/customer-note/customer-note.def.ts b/libs/domain/picking/customer-note/customer-note.def.ts deleted file mode 100644 index 4a88217ae..000000000 --- a/libs/domain/picking/customer-note/customer-note.def.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { componentDef } from '@spryker-oryx/utilities'; - -export const pickingCustomerNoteComponent = componentDef({ - name: 'oryx-picking-customer-note', - impl: () => - import('./customer-note.component').then( - (m) => m.PickingCustomerNoteComponent - ), -}); diff --git a/libs/domain/picking/customer-note/customer-note.styles.ts b/libs/domain/picking/customer-note/customer-note.styles.ts deleted file mode 100644 index 84fff271e..000000000 --- a/libs/domain/picking/customer-note/customer-note.styles.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { css } from 'lit'; - -export const customerNoteComponentStyles = css` - :host { - padding: 30px; - display: flex; - flex-direction: column; - min-height: 100vh; - box-sizing: border-box; - } - - section { - position: sticky; - inset-block-start: 30px; - width: 100%; - display: flex; - flex-direction: column; - } - - section oryx-button { - align-self: flex-start; - margin-block-end: 40px; - } - - oryx-image { - max-width: 250px; - max-height: 250px; - display: block; - margin: 0 auto; - } - - oryx-heading { - margin: 50px 0 20px; - } - - p { - flex-grow: 1; - overflow-y: auto; - margin: 0 0 30px; - } - - oryx-button { - position: sticky; - inset-block-end: 30px; - } - - oryx-modal oryx-heading { - margin: 0; - } -`; diff --git a/libs/domain/picking/customer-note/index.ts b/libs/domain/picking/customer-note/index.ts deleted file mode 100644 index f3b3df6e7..000000000 --- a/libs/domain/picking/customer-note/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './customer-note.component'; -export * from './customer-note.styles'; diff --git a/libs/domain/picking/customer-note/stories/demo.stories.ts b/libs/domain/picking/customer-note/stories/demo.stories.ts deleted file mode 100644 index 81c67ec20..000000000 --- a/libs/domain/picking/customer-note/stories/demo.stories.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { storybookDefaultViewports } from '@/tools/storybook'; -import { Meta, Story } from '@storybook/web-components'; -import { TemplateResult, html } from 'lit'; -import { storybookPrefix } from '../../.constants'; - -export default { - title: `${storybookPrefix}/Customer note`, - parameters: { - chromatic: { - viewports: [storybookDefaultViewports.mobile.min], - }, - }, -} as Meta; - -const Template: Story = (): TemplateResult => { - return html` - - `; -}; - -export const Demo = Template.bind({}); diff --git a/libs/domain/picking/discard-modal/discard-modal.component.spec.ts b/libs/domain/picking/discard-modal/discard-modal.component.spec.ts deleted file mode 100644 index b6101bc3e..000000000 --- a/libs/domain/picking/discard-modal/discard-modal.component.spec.ts +++ /dev/null @@ -1,136 +0,0 @@ -import { fixture } from '@open-wc/testing-helpers'; -import { createInjector, destroyInjector } from '@spryker-oryx/di'; -import { PickingGuardService } from '@spryker-oryx/picking'; -import { RouterService } from '@spryker-oryx/router'; -import { useComponent } from '@spryker-oryx/utilities'; -import { html } from 'lit'; -import { of } from 'rxjs'; -import { PickingDiscardModalComponent } from './discard-modal.component'; -import { pickingDiscardModalComponent } from './discard-modal.def'; - -class MockPickingGuardService implements Partial { - allow = vi.fn(); - isProtected = vi.fn().mockReturnValue(of(true)); -} - -class MockRouterService implements Partial { - back = vi.fn(); -} - -describe('PickingDiscardModalComponent', () => { - let element: PickingDiscardModalComponent; - let routerService: MockRouterService; - let guardService: MockPickingGuardService; - - beforeAll(async () => { - await useComponent(pickingDiscardModalComponent); - }); - - beforeEach(async () => { - const testInjector = createInjector({ - providers: [ - { - provide: RouterService, - useClass: MockRouterService, - }, - { - provide: PickingGuardService, - useClass: MockPickingGuardService, - }, - ], - }); - - routerService = testInjector.inject(RouterService); - guardService = - testInjector.inject(PickingGuardService); - - element = await fixture( - html`` - ); - }); - - afterEach(() => { - vi.clearAllMocks(); - destroyInjector(); - }); - - it('passes the a11y audit', async () => { - await expect(element).shadowDom.to.be.accessible(); - }); - - it('should render the trigger', () => { - expect(element).toContainElement('oryx-button:not([slot])'); - }); - - it('should render modal', () => { - expect(element).toContainElement('oryx-modal'); - }); - - describe('when trigger is clicked', () => { - beforeEach(() => { - element.renderRoot - .querySelector('oryx-button:not([slot])') - ?.dispatchEvent(new MouseEvent('click')); - }); - - it('should open the modal', () => { - expect(element).toContainElement('oryx-modal[open]'); - }); - - describe('and cancel button is clicked', () => { - beforeEach(() => { - element.renderRoot - .querySelectorAll('oryx-button[slot]')[0] - ?.dispatchEvent(new MouseEvent('click')); - }); - - it('should close the modal', () => { - expect(element).not.toContainElement('oryx-modal[open]'); - }); - - it('should not call the services', () => { - expect(routerService.back).not.toHaveBeenCalled(); - expect(guardService.allow).not.toHaveBeenCalled(); - }); - }); - - describe('and discard button is clicked', () => { - beforeEach(() => { - element.renderRoot - .querySelectorAll('oryx-button[slot]')[1] - ?.dispatchEvent(new MouseEvent('click')); - }); - - it('should close the modal', () => { - expect(element).not.toContainElement('oryx-modal[open]'); - }); - - it('should call the services', () => { - expect(routerService.back).toHaveBeenCalled(); - expect(guardService.allow).toHaveBeenCalled(); - }); - }); - - describe('and guard is not active', () => { - beforeEach(async () => { - guardService.isProtected = vi.fn().mockReturnValue(of(false)); - - element = await fixture( - html`` - ); - - element.renderRoot - .querySelector('oryx-button:not([slot])') - ?.dispatchEvent(new MouseEvent('click')); - }); - - it('should not open the modal', () => { - expect(element).not.toContainElement('oryx-modal[open]'); - }); - - it('should navigate back', () => { - expect(routerService.back).toHaveBeenCalled(); - }); - }); - }); -}); diff --git a/libs/domain/picking/discard-modal/discard-modal.component.ts b/libs/domain/picking/discard-modal/discard-modal.component.ts deleted file mode 100644 index 20ce9541f..000000000 --- a/libs/domain/picking/discard-modal/discard-modal.component.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { resolve } from '@spryker-oryx/di'; -import { PickingGuardService } from '@spryker-oryx/picking'; -import { RouterService } from '@spryker-oryx/router'; -import { ButtonColor, ButtonSize, ButtonType } from '@spryker-oryx/ui/button'; -import { HeadingTag } from '@spryker-oryx/ui/heading'; -import { IconTypes } from '@spryker-oryx/ui/icon'; -import { I18nMixin, featureVersion, signal } from '@spryker-oryx/utilities'; -import { LitElement, TemplateResult, html } from 'lit'; -import { property } from 'lit/decorators.js'; -import { discardModalStyles } from './discard-modal.styles'; - -export class PickingDiscardModalComponent extends I18nMixin(LitElement) { - static styles = discardModalStyles; - - @property({ type: Boolean, reflect: true }) open?: boolean; - - protected pickingGuardService = resolve(PickingGuardService); - protected routerService = resolve(RouterService); - - protected $isProtected = signal(this.pickingGuardService.isProtected()); - - protected override render(): TemplateResult { - return html` - - - - ${this.__renderHeading()}${this.i18n('picking.discard.stop-picking')} - ${this.i18n('picking.discard.warning')} - - - ${this.i18n('picking-lists.cancel')} - - - - ${this.i18n('picking-lists.discard')} - - - `; - } - - // temporary implementation for backwards compatibility - private __renderHeading(): TemplateResult { - const text = this.i18n('picking.discard.pick-list'); - if (featureVersion >= '1.4') { - return html` - ${text} - `; - } else { - return html` -

${text}

-
`; - } - } - - protected onBack(): void { - if (!this.$isProtected()) { - this.routerService.back(); - } else { - this.open = true; - } - } - - protected cancel(): void { - this.open = false; - } - - protected discard(): void { - this.pickingGuardService.allow(); - this.routerService.back(); - this.open = false; - } -} diff --git a/libs/domain/picking/discard-modal/discard-modal.def.ts b/libs/domain/picking/discard-modal/discard-modal.def.ts deleted file mode 100644 index e025c284f..000000000 --- a/libs/domain/picking/discard-modal/discard-modal.def.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { componentDef } from '@spryker-oryx/utilities'; - -export const pickingDiscardModalComponent = componentDef({ - name: 'oryx-picking-discard-modal', - impl: () => - import('./discard-modal.component').then( - (m) => m.PickingDiscardModalComponent - ), -}); diff --git a/libs/domain/picking/discard-modal/discard-modal.styles.ts b/libs/domain/picking/discard-modal/discard-modal.styles.ts deleted file mode 100644 index c9424c394..000000000 --- a/libs/domain/picking/discard-modal/discard-modal.styles.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { css } from 'lit'; - -export const discardModalStyles = css` - .additional-text { - font-weight: 700; - margin-block-start: 5px; - } -`; diff --git a/libs/domain/picking/discard-modal/index.ts b/libs/domain/picking/discard-modal/index.ts deleted file mode 100644 index 45ca1ee01..000000000 --- a/libs/domain/picking/discard-modal/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './discard-modal.component'; diff --git a/libs/domain/picking/discard-modal/stories/demo.stories.ts b/libs/domain/picking/discard-modal/stories/demo.stories.ts deleted file mode 100644 index 8f4dd873d..000000000 --- a/libs/domain/picking/discard-modal/stories/demo.stories.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { - OverlaysDecorator, - storybookDefaultViewports, -} from '@/tools/storybook'; -import { Meta, Story } from '@storybook/web-components'; -import { TemplateResult, html } from 'lit'; -import { storybookPrefix } from '../../.constants'; - -export default { - title: `${storybookPrefix}/Discard modal`, - decorators: [OverlaysDecorator(320, 568)], - parameters: { - chromatic: { - viewports: [storybookDefaultViewports.mobile.min], - }, - }, -} as Meta; - -const Template: Story = (): TemplateResult => { - return html` `; -}; - -export const Demo = Template.bind({}); diff --git a/libs/domain/picking/filter-button/filter-button.component.spec.ts b/libs/domain/picking/filter-button/filter-button.component.spec.ts deleted file mode 100644 index c69729091..000000000 --- a/libs/domain/picking/filter-button/filter-button.component.spec.ts +++ /dev/null @@ -1,119 +0,0 @@ -import { fixture } from '@open-wc/testing-helpers'; -import { createInjector, destroyInjector } from '@spryker-oryx/di'; -import { - PickingListService, - defaultQualifier, -} from '@spryker-oryx/picking/services'; -import { useComponent } from '@spryker-oryx/utilities'; -import { html } from 'lit'; -import { of } from 'rxjs'; -import { SpyInstance } from 'vitest'; -import { PickingFilterButtonComponent } from './filter-button.component'; -import { pickingFilterButtonComponent } from './filter-button.def'; - -class MockPickingListService implements Partial { - getQualifier = vi.fn().mockReturnValue(of(defaultQualifier)); -} - -describe('PickingFilterButtonComponent', () => { - let element: PickingFilterButtonComponent; - let service: MockPickingListService; - - beforeAll(async () => { - await useComponent(pickingFilterButtonComponent); - }); - - beforeEach(async () => { - const testInjector = createInjector({ - providers: [ - { - provide: PickingListService, - useClass: MockPickingListService, - }, - ], - }); - service = testInjector.inject( - PickingListService - ) as unknown as MockPickingListService; - element = await fixture( - html`` - ); - }); - - afterEach(() => { - destroyInjector(); - vi.clearAllMocks(); - }); - - it('passes the a11y audit', async () => { - await expect(element).shadowDom.to.be.accessible(); - }); - - it('should not check the input', () => { - expect(element).not.toContainElement('input:checked, input[checked]'); - }); - - describe('when selected sort by method is not default', () => { - beforeEach(async () => { - vi.useFakeTimers(); - service.getQualifier = vi.fn().mockReturnValue( - of({ - ...defaultQualifier, - sortBy: 'test', - }) - ); - element = await fixture( - html`` - ); - vi.advanceTimersByTime(1); - }); - - afterEach(() => { - vi.clearAllTimers(); - }); - - it('should check the input', () => { - expect(element).toContainElement('input[checked]:checked'); - }); - }); - - describe('when selected sorting order is not default', () => { - beforeEach(async () => { - service.getQualifier = vi.fn().mockReturnValue( - of({ - ...defaultQualifier, - sortDesc: true, - }) - ); - element = await fixture( - html`` - ); - }); - - it('should check the input', () => { - expect(element).toContainElement('input[checked]:checked'); - }); - }); - - describe('when input clicked', () => { - let prevented: SpyInstance; - - beforeEach(async () => { - element = await fixture( - html`` - ); - - const event = new MouseEvent('click'); - prevented = vi.spyOn(event, 'preventDefault'); - element.renderRoot.querySelector('input')?.dispatchEvent(event); - }); - - it('should be prevented', () => { - expect(prevented).toHaveBeenCalledOnce(); - }); - - it('should open the filters', () => { - expect(element).toContainElement('oryx-picking-filters[open]'); - }); - }); -}); diff --git a/libs/domain/picking/filter-button/filter-button.component.ts b/libs/domain/picking/filter-button/filter-button.component.ts deleted file mode 100644 index 45b1f9244..000000000 --- a/libs/domain/picking/filter-button/filter-button.component.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { resolve } from '@spryker-oryx/di'; -import { - defaultQualifier, - PickingListQualifierSortBy, - PickingListService, - SortableQualifier, -} from '@spryker-oryx/picking/services'; -import { IconTypes } from '@spryker-oryx/ui/icon'; -import { I18nMixin, signal, signalAware, Size } from '@spryker-oryx/utilities'; -import { html, LitElement, TemplateResult } from 'lit'; -import { query } from 'lit/decorators.js'; -import { map, tap } from 'rxjs'; - -@signalAware() -export class PickingFilterButtonComponent extends I18nMixin(LitElement) { - protected pickingListService = resolve(PickingListService); - - @query('oryx-picking-filters') protected filters?: HTMLElement; - @query('input') protected input?: HTMLInputElement; - - protected $selectedFilters = signal( - this.pickingListService.getQualifier().pipe( - map(this.hasSelectedFilter), - tap((hasSelected) => { - if (this.input) { - this.input.checked = hasSelected; - } - }) - ) - ); - - protected override render(): TemplateResult { - return html` - - this.onClick(e)} - /> - - ${this.i18n('picking.filter.sort')} - - - - `; - } - - protected onClick(e: Event): void { - e.preventDefault(); - - this.filters?.toggleAttribute('open'); - } - - protected hasSelectedFilter( - selectedFilters: SortableQualifier - ): boolean { - return ( - selectedFilters.sortBy !== defaultQualifier.sortBy || - selectedFilters.sortDesc !== defaultQualifier.sortDesc - ); - } -} diff --git a/libs/domain/picking/filter-button/filter-button.def.ts b/libs/domain/picking/filter-button/filter-button.def.ts deleted file mode 100644 index 5150721d6..000000000 --- a/libs/domain/picking/filter-button/filter-button.def.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { componentDef } from '@spryker-oryx/utilities'; - -export const pickingFilterButtonComponent = componentDef({ - name: 'oryx-picking-filter-button', - impl: () => - import('./filter-button.component').then( - (m) => m.PickingFilterButtonComponent - ), - schema: () => - import('./filter-button.schema').then( - (m) => m.pickingFilterButtonComponentSchema - ), -}); diff --git a/libs/domain/picking/filter-button/filter-button.schema.ts b/libs/domain/picking/filter-button/filter-button.schema.ts deleted file mode 100644 index 3cc3d987d..000000000 --- a/libs/domain/picking/filter-button/filter-button.schema.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ContentComponentSchema } from '@spryker-oryx/experience'; -import { PickingFilterButtonComponent } from './filter-button.component'; - -export const pickingFilterButtonComponentSchema: ContentComponentSchema = - { - name: 'Filters', - group: 'Picking', - }; diff --git a/libs/domain/picking/filter-button/index.ts b/libs/domain/picking/filter-button/index.ts deleted file mode 100644 index 3b6706fec..000000000 --- a/libs/domain/picking/filter-button/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './filter-button.component'; diff --git a/libs/domain/picking/filters/filters.component.spec.ts b/libs/domain/picking/filters/filters.component.spec.ts deleted file mode 100644 index bc1d8e132..000000000 --- a/libs/domain/picking/filters/filters.component.spec.ts +++ /dev/null @@ -1,216 +0,0 @@ -import { fixture } from '@open-wc/testing-helpers'; -import { createInjector, destroyInjector } from '@spryker-oryx/di'; -import { FormRenderer } from '@spryker-oryx/form'; -import { - PickingListService, - defaultQualifier, -} from '@spryker-oryx/picking/services'; -import { useComponent } from '@spryker-oryx/utilities'; -import { html } from 'lit'; -import { of } from 'rxjs'; -import { SpyInstance } from 'vitest'; -import { PickingFiltersComponent } from './filters.component'; -import { pickingFiltersComponent } from './filters.def'; -import { getFilterFields } from './filters.model'; - -class MockPickingListService implements Partial { - getQualifier = vi.fn().mockReturnValue(of(defaultQualifier)); - setQualifier = vi.fn(); -} - -class MockFormRenderer implements Partial { - buildForm = vi.fn().mockReturnValue(html``); -} - -describe('PickingFiltersComponent', () => { - let element: PickingFiltersComponent; - let service: MockPickingListService; - let renderer: MockFormRenderer; - - beforeAll(async () => { - await useComponent(pickingFiltersComponent); - }); - - beforeEach(async () => { - const testInjector = createInjector({ - providers: [ - { - provide: FormRenderer, - useClass: MockFormRenderer, - }, - { - provide: PickingListService, - useClass: MockPickingListService, - }, - ], - }); - renderer = testInjector.inject(FormRenderer) as unknown as MockFormRenderer; - service = testInjector.inject( - PickingListService - ) as unknown as MockPickingListService; - element = await fixture( - html`` - ); - }); - - afterEach(() => { - destroyInjector(); - vi.clearAllMocks(); - }); - - it('passes the a11y audit', async () => { - await expect(element).shadowDom.to.be.accessible(); - }); - - it('should build the form', () => { - expect(renderer.buildForm).toHaveBeenCalledWith(getFilterFields(), { - sortBy: 'deliveryDate.asc', - }); - }); - - describe('when qualifier changes', () => { - beforeEach(async () => { - service.getQualifier = vi.fn().mockReturnValue( - of({ - ...defaultQualifier, - sortDesc: false, - }) - ); - element = await fixture( - html`` - ); - }); - - it('should format the correct value', () => { - expect(renderer.buildForm).toHaveBeenCalledWith(getFilterFields(), { - sortBy: 'deliveryDate.asc', - }); - }); - }); - - describe('when filters are opened', () => { - beforeEach(async () => { - element = await fixture( - html`` - ); - }); - - it('should open the modal', () => { - expect(element).toContainElement('oryx-modal[open]'); - }); - - describe('and modal is closed', () => { - let reset: SpyInstance; - - beforeEach(() => { - const form = element.renderRoot.querySelector('form')!; - reset = vi.spyOn(form, 'reset'); - element.renderRoot - .querySelector('oryx-modal') - ?.dispatchEvent(new CustomEvent('oryx.close')); - }); - - it('should close the modal', () => { - expect(element).not.toContainElement('oryx-modal[open]'); - }); - - it('should reset the form', () => { - expect(reset).toHaveBeenCalled(); - }); - }); - - describe('and modal is reset', () => { - let reset: SpyInstance; - - beforeEach(() => { - const form = element.renderRoot.querySelector('form')!; - reset = vi.spyOn(form, 'reset'); - element.renderRoot - .querySelector('oryx-modal') - ?.dispatchEvent(new CustomEvent('oryx.back')); - }); - - it('should set default qualifiers', () => { - expect(service.setQualifier).toHaveBeenCalledWith(defaultQualifier); - }); - - it('should close the modal', () => { - expect(element).not.toContainElement('oryx-modal[open]'); - }); - - it('should reset the form', () => { - expect(reset).toHaveBeenCalled(); - }); - }); - - describe('and filters are applied', () => { - let request: SpyInstance; - const sortBy = 'sortBy'; - const sortDesc = 'desc'; - - beforeEach(async () => { - renderer.buildForm = vi.fn().mockReturnValue(html` - - `); - element = await fixture( - html`` - ); - const form = element.renderRoot.querySelector('form')!; - request = vi.spyOn(form, 'requestSubmit'); - element.renderRoot - .querySelector('oryx-button[slot="footer"]') - ?.click(); - }); - - it('should request submit of the form', () => { - expect(request).toHaveBeenCalled(); - }); - - it('should update the qualifier', () => { - expect(service.setQualifier).toHaveBeenCalledWith({ - sortBy, - sortDesc: true, - }); - }); - }); - - describe('when Enter key is pressed in the form', () => { - let event: KeyboardEvent; - let request: SpyInstance; - const sortBy = 'sortBy'; - const sortDesc = 'desc'; - - beforeEach(async () => { - renderer.buildForm = vi.fn().mockReturnValue(html` - - `); - element = await fixture( - html` ` - ); - - const form = element.renderRoot.querySelector('form')!; - request = vi.spyOn(form, 'requestSubmit'); - - event = new KeyboardEvent('keydown', { key: 'Enter' }); - event.preventDefault = vi.fn(); - - form.dispatchEvent(event); - }); - - it('should prevent default form submission', () => { - expect(event.preventDefault).toHaveBeenCalled(); - }); - - it('should request submit of the form', () => { - expect(request).toHaveBeenCalled(); - }); - - it('should update the qualifier', () => { - expect(service.setQualifier).toHaveBeenCalledWith({ - sortBy, - sortDesc: true, - }); - }); - }); - }); -}); diff --git a/libs/domain/picking/filters/filters.component.ts b/libs/domain/picking/filters/filters.component.ts deleted file mode 100644 index 70ff8a6a1..000000000 --- a/libs/domain/picking/filters/filters.component.ts +++ /dev/null @@ -1,133 +0,0 @@ -import { resolve } from '@spryker-oryx/di'; -import { FormRenderer } from '@spryker-oryx/form'; -import { - defaultQualifier, - PickingListQualifierSortBy, - PickingListService, - SortableQualifier, -} from '@spryker-oryx/picking/services'; -import { ButtonColor, ButtonType } from '@spryker-oryx/ui/button'; -import { HeadingTag } from '@spryker-oryx/ui/heading'; -import { featureVersion, I18nMixin, signal } from '@spryker-oryx/utilities'; -import { html, LitElement, TemplateResult } from 'lit'; -import { property, query } from 'lit/decorators.js'; -import { map } from 'rxjs'; -import { getFilterFields } from './filters.model'; -import { filtersComponentStyles } from './filters.styles'; - -export class PickingFiltersComponent extends I18nMixin(LitElement) { - static styles = filtersComponentStyles; - - @property({ type: Boolean, reflect: true }) open = false; - - @query('form') - protected form?: HTMLFormElement; - - protected fieldRenderer = resolve(FormRenderer); - protected pickingListService = resolve(PickingListService); - - protected $selectedSortingValue = signal( - this.pickingListService.getQualifier().pipe(map(this.formatValue)), - { initialValue: this.formatValue(defaultQualifier) } - ); - - protected formatValue( - quantifier: SortableQualifier - ): string { - return `${quantifier.sortBy}.${quantifier.sortDesc ? 'desc' : 'asc'}`; - } - - protected onSubmit(e: Event): void { - e.preventDefault(); - - const { sortBy: _sortBy } = Object.fromEntries( - new FormData(e.target as HTMLFormElement).entries() - ); - const [sortBy, sort] = (_sortBy as string).split('.'); - - this.pickingListService.setQualifier({ - sortBy: sortBy as PickingListQualifierSortBy, - sortDesc: sort !== 'asc', - }); - - this.open = false; - } - - protected onReset(): void { - this.pickingListService.setQualifier(defaultQualifier); - - this.onClose(); - } - - protected onClose(): void { - this.open = false; - this.form?.reset(); - } - - protected onApply(event: Event): void { - if (event instanceof KeyboardEvent && event.key !== 'Enter') return; - event.preventDefault(); - - //For safari 15- and other old browsers - if (!this.form?.requestSubmit) { - this.form?.submit(); - return; - } - - this.form.requestSubmit(); - } - - protected override render(): TemplateResult { - return html` - - ${this.__renderHeading()} - - - -
- ${this.fieldRenderer.buildForm(getFilterFields(), { - sortBy: this.$selectedSortingValue(), - })} -
- - -
- `; - } - - // temporary implementation for backwards compatibility - private __renderHeading(): TemplateResult { - const text = this.i18n('picking.filter.sort'); - if (featureVersion >= '1.4') { - return html` - ${text} - `; - } else { - return html` -

${text}

-
`; - } - } -} diff --git a/libs/domain/picking/filters/filters.def.ts b/libs/domain/picking/filters/filters.def.ts deleted file mode 100644 index 9185acf0f..000000000 --- a/libs/domain/picking/filters/filters.def.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { componentDef } from '@spryker-oryx/utilities'; - -export const pickingFiltersComponent = componentDef({ - name: 'oryx-picking-filters', - impl: () => - import('./filters.component').then((m) => m.PickingFiltersComponent), -}); diff --git a/libs/domain/picking/filters/filters.model.ts b/libs/domain/picking/filters/filters.model.ts deleted file mode 100644 index b887e81ef..000000000 --- a/libs/domain/picking/filters/filters.model.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { FormFieldDefinition, FormFieldType } from '@spryker-oryx/form'; -import { i18n } from '@spryker-oryx/utilities'; - -export interface PickingFiltersAttributes { - open?: boolean; -} - -export function getFilterFields(): FormFieldDefinition[] { - return [ - { - id: 'sortBy', - type: FormFieldType.RadioList, - label: i18n('picking.filter.sort-by'), - attributes: { direction: 'vertical' }, - options: [ - { - value: 'deliveryDate.asc', - text: i18n('picking.filter.earliest-pickup-time'), - }, - { - value: 'deliveryDate.desc', - text: i18n('picking.filter.latest-pickup-time'), - }, - { - value: 'orderSize.desc', - text: i18n('picking.filter.largest-order-size'), - }, - { - value: 'orderSize.asc', - text: i18n('picking.filter.smallest-order-size'), - }, - ], - }, - ]; -} diff --git a/libs/domain/picking/filters/filters.styles.ts b/libs/domain/picking/filters/filters.styles.ts deleted file mode 100644 index c71b213f8..000000000 --- a/libs/domain/picking/filters/filters.styles.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { css } from 'lit'; - -export const filtersComponentStyles = css` - oryx-heading { - flex-grow: 1; - text-align: center; - font-weight: 600; - } - - [slot='footer'] { - flex-grow: 1; - } -`; diff --git a/libs/domain/picking/filters/index.ts b/libs/domain/picking/filters/index.ts deleted file mode 100644 index 73ea1f988..000000000 --- a/libs/domain/picking/filters/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './filters.component'; -export * from './filters.model'; -export * from './filters.styles'; diff --git a/libs/domain/picking/filters/stories/demo.stories.ts b/libs/domain/picking/filters/stories/demo.stories.ts deleted file mode 100644 index b8c2167db..000000000 --- a/libs/domain/picking/filters/stories/demo.stories.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { - OverlaysDecorator, - storybookDefaultViewports, -} from '@/tools/storybook'; -import { Meta, Story } from '@storybook/web-components'; -import { TemplateResult, html } from 'lit'; -import { storybookPrefix } from '../../.constants'; - -export default { - title: `${storybookPrefix}/Filters`, - //900px height is set to be sure that all content fit to the chromatic viewport - //that has non-configurable 900px height by default - decorators: [OverlaysDecorator(320, 900)], - parameters: { - layout: 'fullscreen', - chromatic: { - viewports: [storybookDefaultViewports.mobile.min], - }, - }, -} as Meta; - -const Template: Story = (): TemplateResult => { - return html` `; -}; - -export const Demo = Template.bind({}); diff --git a/libs/domain/picking/list-item/index.ts b/libs/domain/picking/list-item/index.ts deleted file mode 100644 index 2e0735a9c..000000000 --- a/libs/domain/picking/list-item/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './list-item.component'; -export * from './list-item.model'; -export * from './list-item.styles'; diff --git a/libs/domain/picking/list-item/list-item.component.spec.ts b/libs/domain/picking/list-item/list-item.component.spec.ts deleted file mode 100644 index a78ce3e1b..000000000 --- a/libs/domain/picking/list-item/list-item.component.spec.ts +++ /dev/null @@ -1,201 +0,0 @@ -import { fixture } from '@open-wc/testing-helpers'; -import { createInjector, destroyInjector } from '@spryker-oryx/di'; -import { LocaleService } from '@spryker-oryx/i18n'; -import { mockPickingListData } from '@spryker-oryx/picking/mocks'; -import { - PickingListError, - PickingListService, -} from '@spryker-oryx/picking/services'; -import { RouterService } from '@spryker-oryx/router'; -import { i18n, useComponent } from '@spryker-oryx/utilities'; -import { html } from 'lit'; -import { of, throwError } from 'rxjs'; -import { afterEach } from 'vitest'; -import { PickingListItemComponent } from './list-item.component'; -import { pickingListItemComponent } from './list-item.def'; -class MockRouterService implements Partial { - navigate = vi.fn(); -} - -class MockPickingListService implements Partial { - getList = vi.fn().mockReturnValue(of(mockPickingListData[0])); - startPicking = vi.fn().mockReturnValue(of(mockPickingListData[0])); - getUpcomingPickingListId = vi.fn().mockReturnValue(of(null)); -} - -class MockLocaleService implements Partial { - formatTime = vi.fn().mockReturnValue(of('01:23')); -} - -describe('PickingListItemComponent', () => { - let element: PickingListItemComponent; - let service: MockPickingListService; - let routerService: MockRouterService; - let localeService: MockLocaleService; - - beforeAll(async () => { - await useComponent(pickingListItemComponent); - }); - - beforeEach(() => { - const testInjector = createInjector({ - providers: [ - { - provide: PickingListService, - useClass: MockPickingListService, - }, - { - provide: RouterService, - useClass: MockRouterService, - }, - { - provide: LocaleService, - useClass: MockLocaleService, - }, - ], - }); - service = testInjector.inject( - PickingListService - ) as unknown as MockPickingListService; - routerService = testInjector.inject( - RouterService - ) as unknown as MockRouterService; - localeService = testInjector.inject( - LocaleService - ) as unknown as MockLocaleService; - }); - - afterEach(() => { - vi.clearAllMocks(); - destroyInjector(); - }); - - describe('when cart note is provided', () => { - beforeEach(async () => { - element = await fixture( - html`` - ); - }); - - it('passes the a11y audit', async () => { - await expect(element).shadowDom.to.be.accessible(); - }); - - it('should perform time formatting', () => { - expect(localeService.formatTime).toHaveBeenCalledWith( - mockPickingListData[0].requestedDeliveryDate - ); - }); - - it('should render time', () => { - expect(element.renderRoot.querySelector('h3')?.textContent?.trim()).toBe( - '01:23' - ); - }); - - it('should render order reference as id', () => { - expect(element.renderRoot.querySelector('.identifier')?.textContent).toBe( - mockPickingListData[0].orderReferences[0] - ); - }); - - it('should render items number', () => { - expect( - element.renderRoot.querySelector('.total')?.textContent?.trim() - ).toBe( - i18n('picking.picking-list-item.-items', { - count: mockPickingListData[0].itemsCount, - }) - ); - }); - - it('should emit showCustomerNote event when the customer note button is clicked', () => { - const event = vi.fn(); - element.addEventListener('oryx.show-note', event); - element.renderRoot.querySelector('oryx-button')?.click(); - expect(event).toHaveBeenCalled(); - }); - - describe('and picking is proceed', () => { - beforeEach(() => { - element.renderRoot - .querySelector('oryx-button.start-picking') - ?.click(); - }); - - it('should perform redirect', () => { - expect(routerService.navigate).toHaveBeenCalledWith( - `/customer-note-info/${mockPickingListData[0].id}` - ); - }); - }); - }); - - describe('when cart note is not provided', () => { - beforeEach(async () => { - service.getList = vi.fn().mockReturnValue(of(mockPickingListData[1])); - service.startPicking = vi - .fn() - .mockReturnValue(of(mockPickingListData[1])); - - element = await fixture( - html`` - ); - }); - - it('should not render show-customer button', () => { - expect(element).not.toContainElement('oryx-button.show-customer'); - }); - - describe('and picking is proceed', () => { - beforeEach(() => { - element.renderRoot.querySelector('oryx-button')?.click(); - }); - - it('should start picking', () => { - expect(service.startPicking).toHaveBeenCalledWith( - mockPickingListData[1] - ); - }); - - it('should perform redirect', () => { - expect(routerService.navigate).toHaveBeenCalledWith( - `/picking-list/picking/${mockPickingListData[1].id}` - ); - }); - - describe('and picking is already in progress', () => { - const event = vi.fn(); - beforeEach(async () => { - routerService.navigate.mockClear(); - service.startPicking = vi.fn().mockReturnValue( - throwError(() => { - const error = new Error('mock') as PickingListError; - error.status = 409; - return error; - }) - ); - element = await fixture( - html`` - ); - element.addEventListener('oryx.show-picking-in-progress', event); - element.renderRoot.querySelector('oryx-button')?.click(); - }); - - it('should emit showPickingInProgress event', () => { - expect(event).toHaveBeenCalled(); - }); - - it('should not perform redirect', () => { - expect(routerService.navigate).not.toHaveBeenCalled(); - }); - }); - }); - }); -}); diff --git a/libs/domain/picking/list-item/list-item.component.ts b/libs/domain/picking/list-item/list-item.component.ts deleted file mode 100644 index d2ffb9601..000000000 --- a/libs/domain/picking/list-item/list-item.component.ts +++ /dev/null @@ -1,118 +0,0 @@ -import { resolve } from '@spryker-oryx/di'; -import { LocaleService } from '@spryker-oryx/i18n'; -import { PickingListMixin } from '@spryker-oryx/picking'; -import { RouterService } from '@spryker-oryx/router'; -import { ButtonColor, ButtonSize, ButtonType } from '@spryker-oryx/ui/button'; -import { IconTypes } from '@spryker-oryx/ui/icon'; -import { I18nMixin, computed } from '@spryker-oryx/utilities'; -import { LitElement, TemplateResult, html } from 'lit'; -import { when } from 'lit/directives/when.js'; -import { catchError, of, tap } from 'rxjs'; -import { PickingListItemAttributes } from './list-item.model'; -import { pickingListItemComponentStyles } from './list-item.styles'; - -export class PickingListItemComponent - extends I18nMixin(PickingListMixin(LitElement)) - implements PickingListItemAttributes -{ - static styles = pickingListItemComponentStyles; - - protected routerService = resolve(RouterService); - protected localeService = resolve(LocaleService); - - protected $requestedDeliveryDate = computed(() => { - if (!isNaN(this.$pickingList()?.requestedDeliveryDate.getTime())) { - return this.localeService.formatTime( - this.$pickingList()?.requestedDeliveryDate - ); - } - return ''; - }); - - protected startPicking(): void { - if (this.$pickingList()?.cartNote) { - this.routerService.navigate( - `/customer-note-info/${this.$pickingList().id}` - ); - return; - } - - this.pickingListService - .startPicking(this.$pickingList()) - .pipe( - tap(() => { - this.routerService.navigate( - `/picking-list/picking/${this.$pickingList().id}` - ); - }), - catchError((e) => { - if (e.status === 409) { - this.dispatchEvent( - new CustomEvent('oryx.show-picking-in-progress') - ); - } - return of(undefined); - }) - ) - .subscribe(); - } - - protected showCustomerNote(): void { - this.dispatchEvent( - new CustomEvent('oryx.show-note', { - detail: { - id: this.$pickingList().id, - }, - }) - ); - } - - protected override render(): TemplateResult | void { - if (!this.$pickingList()) return; - - return html` - - ${when( - this.$pickingList()?.createdAt, - () => html`

${this.$requestedDeliveryDate()}

` - )} - ${this.$pickingList().orderReferences[0]} - -
- - ${this.i18n('picking.list-item.-items', { - count: this.$pickingList()?.itemsCount, - })} - ${when( - this.$pickingList()?.cartNote, - () => html` - - ` - )} -
- - -
- `; - } -} diff --git a/libs/domain/picking/list-item/list-item.def.ts b/libs/domain/picking/list-item/list-item.def.ts deleted file mode 100644 index 50dc8150a..000000000 --- a/libs/domain/picking/list-item/list-item.def.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { componentDef } from '@spryker-oryx/utilities'; - -export const pickingListItemComponent = componentDef({ - name: 'oryx-picking-list-item', - impl: () => - import('./list-item.component').then((m) => m.PickingListItemComponent), - schema: () => - import('./list-item.schema').then((m) => m.pickingListItemComponentSchema), -}); diff --git a/libs/domain/picking/list-item/list-item.model.ts b/libs/domain/picking/list-item/list-item.model.ts deleted file mode 100644 index e146e8f62..000000000 --- a/libs/domain/picking/list-item/list-item.model.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface PickingListItemAttributes { - pickingListId?: string; -} diff --git a/libs/domain/picking/list-item/list-item.schema.ts b/libs/domain/picking/list-item/list-item.schema.ts deleted file mode 100644 index 831793b25..000000000 --- a/libs/domain/picking/list-item/list-item.schema.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ContentComponentSchema } from '@spryker-oryx/experience'; -import { PickingListItemComponent } from './list-item.component'; - -export const pickingListItemComponentSchema: ContentComponentSchema = - { - name: 'List Item', - group: 'Picking', - }; diff --git a/libs/domain/picking/list-item/list-item.styles.ts b/libs/domain/picking/list-item/list-item.styles.ts deleted file mode 100644 index 9f3943c01..000000000 --- a/libs/domain/picking/list-item/list-item.styles.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { HeadingTag, headingUtil } from '@spryker-oryx/ui/heading'; -import { css } from 'lit'; - -export const pickingListItemComponentStyles = css` - oryx-heading { - justify-content: space-between; - align-items: center; - display: flex; - width: 100%; - } - - h3 { - ${headingUtil(HeadingTag.H3)} - } - - span.identifier { - ${headingUtil(HeadingTag.H6)} - - color: var(--oryx-color-neutral-darker); - margin-inline-start: auto; - } - - ::part(body) { - font-weight: 500; - font-size: 14px; - line-height: 24px; - letter-spacing: 0.005em; - display: flex; - justify-content: space-between; - min-height: 38px; - } - - .total { - color: var(--oryx-color-neutral-darker); - display: flex; - align-items: center; - gap: 8px; - height: 24px; - width: 100%; - } - - .show-customer { - margin-inline-start: auto; - } - - .start-picking { - margin-block: 0; - width: 100%; - } -`; diff --git a/libs/domain/picking/list-item/stories/demo.stories.ts b/libs/domain/picking/list-item/stories/demo.stories.ts deleted file mode 100644 index 4edafaa84..000000000 --- a/libs/domain/picking/list-item/stories/demo.stories.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { mockPickingListData } from '@spryker-oryx/picking/mocks'; -import { Meta, Story } from '@storybook/web-components'; -import { html } from 'lit'; -import { TemplateResult } from 'lit/development'; -import { storybookPrefix } from '../../.constants'; -import { ListItemAttributes } from '../list-item.model'; - -const pickingListIds = mockPickingListData.map(({ id }) => id); - -export default { - title: `${storybookPrefix}/List item`, - args: { - pickingListId: pickingListIds[0], - }, - argTypes: { - pickingListId: { - options: pickingListIds, - control: { type: 'select' }, - }, - }, - parameters: { - chromatic: { - disableSnapshot: true, - }, - }, -} as Meta; - -const Template: Story = ({ - pickingListId, -}): TemplateResult => { - return html` - - `; -}; - -export const Demo = Template.bind({}); diff --git a/libs/domain/picking/list-item/stories/static/variants.stories.ts b/libs/domain/picking/list-item/stories/static/variants.stories.ts deleted file mode 100644 index 1e9354335..000000000 --- a/libs/domain/picking/list-item/stories/static/variants.stories.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { storybookDefaultViewports } from '@/tools/storybook'; -import { Meta, Story } from '@storybook/web-components'; -import { TemplateResult, html } from 'lit'; -import { storybookPrefix } from '../../../.constants'; - -export default { - title: `${storybookPrefix}/List item/Static`, - parameters: { - chromatic: { - viewports: [storybookDefaultViewports.mobile.min], - }, - }, -} as Meta; - -const Template: Story = (): TemplateResult => { - return html` -

With cart note

- - -

Without cart note

- - `; -}; - -export const Variants = Template.bind({}); diff --git a/libs/domain/picking/lists/index.ts b/libs/domain/picking/lists/index.ts deleted file mode 100644 index 93ff3e52e..000000000 --- a/libs/domain/picking/lists/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './lists.component'; -export * from './lists.styles'; diff --git a/libs/domain/picking/lists/lists.component.spec.ts b/libs/domain/picking/lists/lists.component.spec.ts deleted file mode 100644 index 66964b74b..000000000 --- a/libs/domain/picking/lists/lists.component.spec.ts +++ /dev/null @@ -1,295 +0,0 @@ -import { fixture } from '@open-wc/testing-helpers'; -import { App, AppRef } from '@spryker-oryx/core'; -import { createInjector, destroyInjector } from '@spryker-oryx/di'; -import { PickingCustomerNoteModalComponent } from '@spryker-oryx/picking/customer-note-modal'; -import { mockPickingListData } from '@spryker-oryx/picking/mocks'; -import { PickingSyncActionHandlerService } from '@spryker-oryx/picking/offline'; -import { PickingListService } from '@spryker-oryx/picking/services'; -import { CLOSE_EVENT, ModalComponent } from '@spryker-oryx/ui/modal'; -import { i18n, useComponent } from '@spryker-oryx/utilities'; -import { html } from 'lit'; -import { of } from 'rxjs'; -import { afterEach, beforeAll, beforeEach } from 'vitest'; -import { PickingListsComponent } from './lists.component'; -import { pickingListsComponent } from './lists.def'; - -const mockOfflineDataPlugin = { - isRefreshing: vi.fn().mockReturnValue(of(false)), -}; - -class MockPickingSyncActionHandlerService - implements Partial -{ - isSyncing = vi.fn().mockReturnValue(of(false)); -} - -class MockApp implements Partial { - requirePlugin = vi.fn().mockReturnValue(mockOfflineDataPlugin); -} - -class MockPickingListService implements Partial { - get = vi.fn().mockReturnValue(of(mockPickingListData)); - isRefreshing = vi.fn().mockReturnValue(of(false)); - isActiveSearch = vi.fn().mockReturnValue(of(false)); - getQualifier = vi.fn().mockReturnValue(of({})); -} - -describe('PickingListsComponent', () => { - let element: PickingListsComponent; - let service: MockPickingListService; - let syncService: MockPickingSyncActionHandlerService; - - beforeAll(async () => { - await useComponent([pickingListsComponent]); - }); - - beforeEach(async () => { - const testInjector = createInjector({ - providers: [ - { - provide: PickingListService, - useClass: MockPickingListService, - }, - { - provide: PickingSyncActionHandlerService, - useClass: MockPickingSyncActionHandlerService, - }, - { - provide: AppRef, - useClass: MockApp, - }, - ], - }); - - service = testInjector.inject( - PickingListService - ) as unknown as MockPickingListService; - syncService = testInjector.inject( - PickingSyncActionHandlerService - ) as unknown as MockPickingSyncActionHandlerService; - element = await fixture(html``); - }); - - afterEach(() => { - vi.clearAllMocks(); - destroyInjector(); - }); - - describe('when not retrieving data', () => { - it('should not show loading indicator', () => { - expect(element.renderRoot.querySelector('.loading')).toBeNull(); - }); - - it('should not show sync indicator', () => { - expect(element.renderRoot.querySelector('.sync')).toBeNull(); - }); - }); - - describe('when retrieving data', () => { - beforeEach(async () => { - mockOfflineDataPlugin.isRefreshing.mockReturnValue(of(true)); - element = await fixture(html``); - }); - - it('should show loading indicator', () => { - expect(element.renderRoot.querySelector('.loading')).not.toBeNull(); - }); - - afterEach(() => { - mockOfflineDataPlugin.isRefreshing.mockReturnValue(of(false)); - }); - }); - - describe('when receiving push notifications', () => { - beforeEach(async () => { - syncService.isSyncing.mockReturnValue(of(true)); - element = await fixture(html``); - }); - - it('should show loading indicator', () => { - expect(element.renderRoot.querySelector('.sync')).not.toBeNull(); - }); - }); - - describe('when picking lists is not empty', () => { - const getCustomerNoteModal = (): PickingCustomerNoteModalComponent | null => - element.renderRoot.querySelector('oryx-picking-customer-note-modal'); - - const getPickingInProgressModal = (): ModalComponent | null => - element.renderRoot.querySelector( - 'oryx-picking-picking-in-progress-modal' - ); - - it('passes the a11y audit', async () => { - await expect(element).shadowDom.to.be.accessible(); - }); - - it(`should render ${mockPickingListData.length} picking lists`, () => { - expect( - element.renderRoot.querySelectorAll('oryx-picking-list-item').length - ).toBe(mockPickingListData.length); - }); - - it(`should render ${mockPickingListData.length} in filters counter`, () => { - expect( - element.renderRoot.querySelector('.filters span')?.textContent - ).toContain(mockPickingListData.length); - }); - - it('should open picking in progress modal', () => { - const pickingListCard = element.renderRoot.querySelector( - 'oryx-picking-list-item' - ); - - element.addEventListener('oryx.show-picking-in-progress', () => { - const pickingInProgressModal = getPickingInProgressModal(); - expect(pickingInProgressModal?.open).toBe(true); - }); - - pickingListCard?.dispatchEvent( - new CustomEvent('oryx.show-picking-in-progress') - ); - }); - - describe('when customer note modal is opened', () => { - const id = 'id'; - - beforeEach(() => { - const pickingListCard = element.renderRoot.querySelector( - 'oryx-picking-list-item' - ); - - pickingListCard?.dispatchEvent( - new CustomEvent('oryx.show-note', { - detail: { id }, - }) - ); - }); - - it('should show customer note modal', () => { - element.addEventListener('oryx.show-note', () => { - expect(getCustomerNoteModal()?.open).toBe(true); - }); - }); - - it(`should close modal when it emits ${CLOSE_EVENT} event`, () => { - element.addEventListener('oryx.show-note', () => { - getCustomerNoteModal()?.dispatchEvent(new CustomEvent(CLOSE_EVENT)); - expect(getCustomerNoteModal()?.hasAttribute('open')).toBe(false); - }); - }); - }); - - it('should open and close picking in progress modal', async () => { - const pickingListCard = element.renderRoot.querySelector( - 'oryx-picking-list-item' - ); - - element.addEventListener('oryx.show-picking-in-progress', () => { - const pickingInProgressModal = getPickingInProgressModal(); - expect(pickingInProgressModal?.hasAttribute('open')).toBe(true); - - pickingInProgressModal?.dispatchEvent(new CustomEvent('oryx.close')); - expect(pickingInProgressModal?.hasAttribute('open')).toBe(false); - }); - - pickingListCard?.dispatchEvent( - new CustomEvent('oryx.show-picking-in-progress') - ); - }); - }); - - describe('when picking lists list is empty', () => { - beforeEach(async () => { - service.get = vi.fn().mockReturnValue(of([])); - element = await fixture(html``); - }); - - it('passes the a11y audit', async () => { - await expect(element).shadowDom.to.be.accessible(); - }); - - it(`should render fallback text`, () => { - expect( - element.renderRoot.querySelector('oryx-heading')?.textContent?.trim() - ).toBe(i18n('picking.no-results-found')); - }); - - it(`should render 0 in filters counter`, () => { - expect( - element.renderRoot.querySelector('.filters span')?.textContent - ).toContain('0'); - }); - }); - - describe('when the list is not provided', () => { - beforeEach(async () => { - service.get = vi.fn().mockReturnValue(of(null)); - element = await fixture(html``); - }); - - it(`should render fallback text`, () => { - expect( - element.renderRoot.querySelector('oryx-heading')?.textContent?.trim() - ).toBe(i18n('picking.no-results-found')); - }); - - it(`should render 0 in filters counter`, () => { - expect( - element.renderRoot.querySelector('.filters span')?.textContent - ).toContain('0'); - }); - }); - - describe('when start searching', () => { - beforeEach(async () => { - service.isActiveSearch = vi.fn().mockReturnValue(of(true)); - element = await fixture(html``); - }); - - it('should render a fallback', () => { - expect( - element.renderRoot.querySelector('.no-items-fallback') - ).not.toBeNull(); - - expect( - element.renderRoot.querySelector('.no-items-fallback oryx-heading') - ?.textContent - ).toContain(i18n('picking.list.search-by-order-ID')); - - expect( - element.renderRoot - .querySelector('.no-items-fallback oryx-image') - ?.getAttribute('resource') - ).toBe('searching'); - }); - }); - - describe('when there is no results while searching', () => { - beforeEach(async () => { - service.get = vi.fn().mockReturnValue(of([])); - service.isActiveSearch = vi.fn().mockReturnValue(of(true)); - service.getQualifier = vi - .fn() - .mockReturnValue(of({ searchOrderReference: 'test' })); - element = await fixture(html``); - }); - - it('should render a fallback', () => { - expect( - element.renderRoot.querySelector('.no-items-fallback') - ).not.toBeNull(); - - expect( - element.renderRoot.querySelector('.no-items-fallback oryx-heading') - ?.textContent - ).toContain(i18n('picking-lists.no-picking-results')); - - expect( - element.renderRoot - .querySelector('.no-items-fallback oryx-image') - ?.getAttribute('resource') - ).toBe('no-search-results'); - }); - }); -}); diff --git a/libs/domain/picking/lists/lists.component.ts b/libs/domain/picking/lists/lists.component.ts deleted file mode 100644 index aa891f20c..000000000 --- a/libs/domain/picking/lists/lists.component.ts +++ /dev/null @@ -1,188 +0,0 @@ -import { AppRef } from '@spryker-oryx/core'; -import { resolve } from '@spryker-oryx/di'; -import { FallbackType } from '@spryker-oryx/picking'; -import { - OfflineDataPlugin, - PickingSyncActionHandlerService, -} from '@spryker-oryx/picking/offline'; -import { PickingInProgressModalComponent } from '@spryker-oryx/picking/picking-in-progress'; -import { PickingListService } from '@spryker-oryx/picking/services'; -import { HeadingTag } from '@spryker-oryx/ui/heading'; -import { - I18nMixin, - featureVersion, - i18n, - signal, - signalAware, -} from '@spryker-oryx/utilities'; -import { LitElement, TemplateResult, html } from 'lit'; -import { query, state } from 'lit/decorators.js'; -import { repeat } from 'lit/directives/repeat.js'; -import { when } from 'lit/directives/when.js'; -import { pickingListsComponentStyles } from './lists.styles'; - -@signalAware() -export class PickingListsComponent extends I18nMixin(LitElement) { - static styles = pickingListsComponentStyles; - - protected pickingListService = resolve(PickingListService); - protected pickingSyncHandler = resolve(PickingSyncActionHandlerService); - - protected $isActiveSearch = signal(this.pickingListService.isActiveSearch()); - protected $qualifier = signal(this.pickingListService.getQualifier()); - - @state() - protected customerNoteOrderId?: string; - - @query('oryx-picking-in-progress-modal') - protected pickingInProgressModal!: PickingInProgressModalComponent; - - protected injectorDataPlugin = - resolve(AppRef).requirePlugin(OfflineDataPlugin); - - protected $syncing = signal(this.pickingSyncHandler.isSyncing()); - protected $refreshing = signal(this.injectorDataPlugin.isRefreshing()); - - protected $pickingLists = signal(this.pickingListService.get()); - - protected override render(): TemplateResult { - return html` ${this.renderPickingLists()} - - - - `; - } - - protected renderPickingLists(): TemplateResult { - const noValueSearchProvided = - this.$isActiveSearch() && !this.$qualifier().searchOrderReference; - return html` ${this.renderFilters()} - ${when( - this.$refreshing(), - () => this.renderLoading(), - () => - html`${when( - !this.$pickingLists()?.length, - () => this.renderResultsFallback(), - () => html` - ${when( - noValueSearchProvided, - () => this.renderSearchFallback(), - () => html` -
- ${when(this.$isActiveSearch(), () => this.__renderHeading())} - ${repeat( - this.$pickingLists(), - (pl) => pl.id, - (pl) => - html`` - )} -
- ` - )} - ` - )}` - )}`; - } - - // temporary implementation for backwards compatibility - private __renderHeading(): TemplateResult { - const text = this.i18n('picking-lists.search-results-for-picking'); - if (featureVersion >= '1.4') { - return html` ${text} `; - } else { - return html` -

${text}

-
`; - } - } - - protected renderResultsFallback(): TemplateResult { - const fallbackType = !this.$isActiveSearch() - ? FallbackType.noResults - : FallbackType.noSearchingResults; - - const fallbackTitle = this.getFallbackTitle(fallbackType); - - return html` -
- - ${fallbackTitle} - - -
- `; - } - - protected renderFilters(): TemplateResult { - return html`
- ${when( - this.$syncing(), - () => html` - ${i18n('picking.loading-data')} - - `, - () => - html`${this.i18n('picking.filter.-open-pick-lists', { - count: this.$pickingLists()?.length ?? 0, - })}` - )} - -
`; - } - - protected renderLoading(): TemplateResult { - return html`
- ${i18n('picking.loading-data')} - -
`; - } - - protected renderSearchFallback(): TemplateResult { - const fallbackTitle = this.getFallbackTitle(FallbackType.noValueProvided); - - return html` -
- ${fallbackTitle} - -
- `; - } - - protected openCustomerNoteModal(event: CustomEvent): void { - this.customerNoteOrderId = event.detail.id; - } - - protected closeCustomerNoteModal(): void { - this.customerNoteOrderId = undefined; - } - - protected openPickingInProgressModal(): void { - this.pickingInProgressModal.open = true; - } - - private getFallbackTitle(fallbackType: FallbackType) { - switch (fallbackType) { - case FallbackType.noResults: - return this.i18n('picking.list.no-results-found'); - case FallbackType.noSearchingResults: - return this.i18n('picking.list.no-picking-results'); - case FallbackType.noValueProvided: - return this.i18n('picking.list.search-by-order-ID'); - default: - return ''; - } - } -} diff --git a/libs/domain/picking/lists/lists.def.ts b/libs/domain/picking/lists/lists.def.ts deleted file mode 100644 index b0915d1c2..000000000 --- a/libs/domain/picking/lists/lists.def.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { componentDef } from '@spryker-oryx/utilities'; - -export const pickingListsComponent = componentDef({ - name: 'oryx-picking-lists', - impl: () => import('./lists.component').then((m) => m.PickingListsComponent), - schema: () => - import('./lists.schema').then((m) => m.pickingListsComponentSchema), -}); diff --git a/libs/domain/picking/lists/lists.schema.ts b/libs/domain/picking/lists/lists.schema.ts deleted file mode 100644 index 09ddb36c9..000000000 --- a/libs/domain/picking/lists/lists.schema.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ContentComponentSchema } from '@spryker-oryx/experience'; -import { PickingListsComponent } from './lists.component'; - -export const pickingListsComponentSchema: ContentComponentSchema = - { - name: 'Lists', - group: 'Picking', - }; diff --git a/libs/domain/picking/lists/lists.styles.ts b/libs/domain/picking/lists/lists.styles.ts deleted file mode 100644 index 918976cb1..000000000 --- a/libs/domain/picking/lists/lists.styles.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { css } from 'lit'; - -export const pickingListsComponentStyles = css` - :host { - display: flex; - flex-direction: column; - gap: 20px; - padding-block-start: 20px; - background-color: var(--oryx-color-neutral-3); - } - - section { - display: grid; - gap: 25px; - } - - .no-items-fallback { - display: flex; - flex-direction: column; - align-items: center; - height: 100%; - margin: 45px; - gap: 16px; - } - - oryx-image { - margin-inline: 40px; - display: block; - } - - .filters { - display: flex; - align-items: center; - justify-content: space-between; - } - - section, - .filters { - padding: 0 20px; - } - - .sync { - display: flex; - align-items: center; - gap: 10px; - } - - .loading { - display: flex; - justify-content: center; - align-items: center; - gap: 10px; - margin-block-start: 34px; - } - - .loading span { - font-weight: 600; - } -`; diff --git a/libs/domain/picking/lists/stories/demo.stories.ts b/libs/domain/picking/lists/stories/demo.stories.ts deleted file mode 100644 index a8164fbc7..000000000 --- a/libs/domain/picking/lists/stories/demo.stories.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { - MockDateDecorator, - storybookDefaultViewports, -} from '@/tools/storybook'; -import { Meta, Story } from '@storybook/web-components'; -import { html } from 'lit'; -import { TemplateResult } from 'lit/development'; -import { storybookPrefix } from '../../.constants'; - -export default { - title: `${storybookPrefix}/Lists`, - parameters: { - layout: 'fullscreen', - chromatic: { - viewports: [storybookDefaultViewports.mobile.min], - }, - }, - decorators: [MockDateDecorator()], -} as Meta; - -const Template: Story = (): TemplateResult => { - return html` `; -}; - -export const Demo = Template.bind({}); diff --git a/libs/domain/picking/lists/stories/static/data.stories.ts b/libs/domain/picking/lists/stories/static/data.stories.ts deleted file mode 100644 index 83611d1f0..000000000 --- a/libs/domain/picking/lists/stories/static/data.stories.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { - MockDateDecorator, - storybookDefaultViewports, -} from '@/tools/storybook'; -import { resolve } from '@spryker-oryx/di'; -import { MockPickingListService } from '@spryker-oryx/picking/mocks'; -import { PickingListService } from '@spryker-oryx/picking/services'; -import { Meta, Story } from '@storybook/web-components'; -import { TemplateResult, html } from 'lit'; -import { storybookPrefix } from '../../../.constants'; - -export default { - title: `${storybookPrefix}/Lists/Static`, - parameters: { - layout: 'fullscreen', - chromatic: { - viewports: [storybookDefaultViewports.mobile.min], - }, - }, - decorators: [MockDateDecorator()], -} as Meta; - -const Template: Story = (): TemplateResult => { - resolve(PickingListService).setEmptyList(false); - return html` `; -}; - -export const Data = Template.bind({}); diff --git a/libs/domain/picking/lists/stories/static/empty.stories.ts b/libs/domain/picking/lists/stories/static/empty.stories.ts deleted file mode 100644 index 1a4fe840c..000000000 --- a/libs/domain/picking/lists/stories/static/empty.stories.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { - MockDateDecorator, - storybookDefaultViewports, -} from '@/tools/storybook'; -import { resolve } from '@spryker-oryx/di'; -import { MockPickingListService } from '@spryker-oryx/picking/mocks'; -import { PickingListService } from '@spryker-oryx/picking/services'; -import { Meta, Story } from '@storybook/web-components'; -import { TemplateResult, html } from 'lit'; -import { storybookPrefix } from '../../../.constants'; - -export default { - title: `${storybookPrefix}/Lists/Static`, - parameters: { - layout: 'fullscreen', - chromatic: { - viewports: [storybookDefaultViewports.mobile.min], - }, - }, - decorators: [MockDateDecorator()], -} as Meta; - -const Template: Story = (): TemplateResult => { - resolve(PickingListService).setEmptyList(true); - return html` `; -}; - -export const Empty = Template.bind({}); diff --git a/libs/domain/picking/mocks/feature.ts b/libs/domain/picking/mocks/feature.ts deleted file mode 100644 index 05f54e3ba..000000000 --- a/libs/domain/picking/mocks/feature.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { AppFeature } from '@spryker-oryx/core'; -import { pickingComponents } from '@spryker-oryx/picking'; -import { - mockPickingListProviders, - mockWarehouseUserAssignmentsProviders, -} from './src'; -import { MockOfflineDataPlugin } from './src/mock-offline-data-plugin'; - -export const mockPickingFeature: AppFeature = { - components: pickingComponents, - providers: [ - ...mockPickingListProviders, - ...mockWarehouseUserAssignmentsProviders, - ], - plugins: [new MockOfflineDataPlugin()], -}; diff --git a/libs/domain/picking/mocks/index.ts b/libs/domain/picking/mocks/index.ts deleted file mode 100644 index ab8b7b35a..000000000 --- a/libs/domain/picking/mocks/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './feature'; -export * from './src'; diff --git a/libs/domain/picking/mocks/src/index.ts b/libs/domain/picking/mocks/src/index.ts deleted file mode 100644 index 3f0b5e36d..000000000 --- a/libs/domain/picking/mocks/src/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -export * from './mock-offline-data-plugin'; -export * from './mock-picking-guard.service'; -export * from './mock-picking-list'; -export * from './mock-picking-list.providers'; -export * from './mock-picking-list.service'; -export * from './mock-sync-action-handler.service'; -export * from './mock-warehouse-user-assignments'; -export * from './mock-warehouse-user-assignments.providers'; -export * from './mock-warehouse-user-assignments.service'; diff --git a/libs/domain/picking/mocks/src/mock-offline-data-plugin.ts b/libs/domain/picking/mocks/src/mock-offline-data-plugin.ts deleted file mode 100644 index 89bba98c8..000000000 --- a/libs/domain/picking/mocks/src/mock-offline-data-plugin.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { OfflineDataPlugin } from '@spryker-oryx/picking/offline'; -import { Observable, of } from 'rxjs'; - -export class MockOfflineDataPlugin extends OfflineDataPlugin { - apply(): void | Promise { - //mock - } - - syncData(): Observable { - return of(undefined); - } -} diff --git a/libs/domain/picking/mocks/src/mock-picking-guard.service.ts b/libs/domain/picking/mocks/src/mock-picking-guard.service.ts deleted file mode 100644 index 88596a615..000000000 --- a/libs/domain/picking/mocks/src/mock-picking-guard.service.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { PickingGuardService } from '@spryker-oryx/picking'; -import { Observable, of } from 'rxjs'; - -export class MockPickingGuardService implements PickingGuardService { - guard(): Observable { - return of(); - } - - allow(): Observable { - return of(); - } - - isProtected(): Observable { - return of(false); - } -} diff --git a/libs/domain/picking/mocks/src/mock-picking-list.providers.ts b/libs/domain/picking/mocks/src/mock-picking-list.providers.ts deleted file mode 100644 index fa6a4f8aa..000000000 --- a/libs/domain/picking/mocks/src/mock-picking-list.providers.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Provider } from '@spryker-oryx/di'; -import { - NetworkStateDefaultService, - NetworkStateService, -} from '@spryker-oryx/offline'; -import { PickingGuardService } from '@spryker-oryx/picking'; -import { PickingSyncActionHandlerService } from '@spryker-oryx/picking/offline'; -import { PickingListService } from '@spryker-oryx/picking/services'; -import { MockPickingGuardService } from './mock-picking-guard.service'; -import { MockPickingListService } from './mock-picking-list.service'; -import { MockPickingSyncActionHandlerService } from './mock-sync-action-handler.service'; - -export const mockPickingListProviders: Provider[] = [ - { - provide: PickingListService, - useClass: MockPickingListService, - }, - { - provide: PickingGuardService, - useClass: MockPickingGuardService, - }, - { - provide: PickingSyncActionHandlerService, - useClass: MockPickingSyncActionHandlerService, - }, - { - provide: NetworkStateService, - useClass: NetworkStateDefaultService, - }, -]; diff --git a/libs/domain/picking/mocks/src/mock-picking-list.service.ts b/libs/domain/picking/mocks/src/mock-picking-list.service.ts deleted file mode 100644 index 8a6bddfcc..000000000 --- a/libs/domain/picking/mocks/src/mock-picking-list.service.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { - defaultQualifier, - PickingList, - PickingListQualifier, - PickingListService, -} from '@spryker-oryx/picking/services'; -import { BehaviorSubject, Observable, of } from 'rxjs'; -import { mockPickingListData } from './mock-picking-list'; - -export class MockPickingListService implements Partial { - protected isEmpty = false; - - protected activeSearch$ = new BehaviorSubject(false); - - isActiveSearch(): Observable { - return this.activeSearch$; - } - - toggleActiveSearch(state: boolean): void { - this.activeSearch$.next(state); - } - - protected _qualifier: PickingListQualifier = defaultQualifier; - protected qualifier$ = new BehaviorSubject( - this._qualifier - ); - - protected searchQualifier$ = new BehaviorSubject(''); - - getQualifier(): Observable { - return this.qualifier$; - } - - setQualifier(qualifier: PickingListQualifier): void { - this._qualifier = { ...this._qualifier, ...qualifier }; - this.qualifier$.next(this._qualifier); - } - - setEmptyList(value: boolean): void { - this.isEmpty = value; - } - - get(): Observable { - if (this.isEmpty) { - return of([]); - } - const { ids: qIds, status: qStatus } = this._qualifier ?? {}; - const filteredData = mockPickingListData.filter(({ id, status }) => { - return (!qIds || qIds?.includes(id)) && (!qStatus || status === qStatus); - }); - return of(filteredData); - } - - getList(_id: string): Observable { - const list = mockPickingListData.find(({ id }) => id === _id) ?? null; - return of(list); - } - - startPicking(pickingList: PickingList): Observable { - return of(pickingList); - } - - updatePickingItems(pickingList: PickingList): Observable { - return of(pickingList); - } - - finishPicking(pickingList: PickingList): Observable { - return of(pickingList); - } - - getUpcomingPickingListId(): Observable { - return of(null); - } -} diff --git a/libs/domain/picking/mocks/src/mock-picking-list.ts b/libs/domain/picking/mocks/src/mock-picking-list.ts deleted file mode 100644 index 92f543587..000000000 --- a/libs/domain/picking/mocks/src/mock-picking-list.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { - ItemsFilters, - PickingList, - PickingListStatus, -} from '@spryker-oryx/picking/services'; - -export const mockPickingListData: PickingList[] = [ - { - id: 'withCartNote', - status: PickingListStatus.ReadyForPicking, - createdAt: new Date('2023-03-01'), - updatedAt: new Date('2023-03-01'), - requestedDeliveryDate: new Date('March 20, 2020 20:00:00'), - orderReferences: ['mockOrderReference'], - cartNote: 'Mock cart note', - items: [ - { - id: 'item1', - numberOfNotPicked: 1, - numberOfPicked: 1, - quantity: 2, - orderItem: { - quantity: 2, - amount: '2', - idSalesOrderItem: 1, - uuid: '1', - name: 'name', - sku: 'sku', - }, - product: { - productName: 'productName', - id: '1', - sku: '111', - image: '/image/test.jpg', - imageLarge: '', - }, - status: ItemsFilters.NotPicked, - }, - ], - itemsCount: 2, - }, - { - id: 'withoutCartNote', - status: PickingListStatus.PickingStarted, - createdAt: new Date('2023-03-01'), - updatedAt: new Date('2023-03-01'), - requestedDeliveryDate: new Date('March 20, 2020 20:00:00'), - orderReferences: ['mockOrderReference'], - items: [ - { - id: 'item2', - numberOfNotPicked: 0, - numberOfPicked: 2, - quantity: 2, - orderItem: { - quantity: 2, - amount: '2', - idSalesOrderItem: 1, - uuid: '1', - name: 'name', - sku: 'sku', - }, - product: { - productName: 'productName', - id: '1', - sku: '111', - image: '', - imageLarge: '', - }, - status: ItemsFilters.Picked, - }, - ], - itemsCount: 2, - }, -]; diff --git a/libs/domain/picking/mocks/src/mock-sync-action-handler.service.ts b/libs/domain/picking/mocks/src/mock-sync-action-handler.service.ts deleted file mode 100644 index 07fbeb9c9..000000000 --- a/libs/domain/picking/mocks/src/mock-sync-action-handler.service.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { PickingSyncActionHandlerService } from '@spryker-oryx/picking/offline'; -import { Observable, of } from 'rxjs'; - -export class MockPickingSyncActionHandlerService - implements Partial -{ - isSyncing(): Observable { - return of(false); - } -} diff --git a/libs/domain/picking/mocks/src/mock-warehouse-user-assignments.providers.ts b/libs/domain/picking/mocks/src/mock-warehouse-user-assignments.providers.ts deleted file mode 100644 index 0f541c69d..000000000 --- a/libs/domain/picking/mocks/src/mock-warehouse-user-assignments.providers.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Provider } from '@spryker-oryx/di'; -import { WarehouseUserAssignmentsService } from '@spryker-oryx/picking/services'; -import { MockWarehouseUserAssignmentsService } from './mock-warehouse-user-assignments.service'; - -export const mockWarehouseUserAssignmentsProviders: Provider[] = [ - { - provide: WarehouseUserAssignmentsService, - useClass: MockWarehouseUserAssignmentsService, - }, -]; diff --git a/libs/domain/picking/mocks/src/mock-warehouse-user-assignments.service.ts b/libs/domain/picking/mocks/src/mock-warehouse-user-assignments.service.ts deleted file mode 100644 index bf2668819..000000000 --- a/libs/domain/picking/mocks/src/mock-warehouse-user-assignments.service.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { - WarehouseUserAssignment, - WarehouseUserAssignmentsService, -} from '@spryker-oryx/picking/services'; -import { Observable, of } from 'rxjs'; -import { mockWarehouseUserAssignments } from './mock-warehouse-user-assignments'; - -export class MockWarehouseUserAssignmentsService - implements Partial -{ - getList(): Observable { - return of(mockWarehouseUserAssignments); - } - - activateAssignment( - assignmentId: string - ): Observable { - return of({ - id: assignmentId, - isActive: true, - userUuid: `userUuid${assignmentId}`, - warehouse: { - uuid: `warehouseUuid${assignmentId}`, - name: `warehouse${assignmentId}`, - isActive: true, - }, - }); - } -} diff --git a/libs/domain/picking/mocks/src/mock-warehouse-user-assignments.ts b/libs/domain/picking/mocks/src/mock-warehouse-user-assignments.ts deleted file mode 100644 index 183b0ce84..000000000 --- a/libs/domain/picking/mocks/src/mock-warehouse-user-assignments.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { WarehouseUserAssignment } from '@spryker-oryx/picking/services'; - -export const mockWarehouseUserAssignments: WarehouseUserAssignment[] = [ - { - id: '1', - isActive: true, - userUuid: 'userUuid1', - warehouse: { - uuid: 'warehouseUuid1', - name: 'warehouse1', - isActive: true, - }, - }, - { - id: '2', - isActive: false, - userUuid: 'userUuid1', - warehouse: { - uuid: 'warehouseUuid2', - name: 'warehouse2', - isActive: true, - }, - }, - { - id: '3', - isActive: false, - userUuid: 'userUuid1', - warehouse: { - uuid: 'warehouseUuid3', - name: 'warehouse3', - isActive: true, - }, - }, -]; diff --git a/libs/domain/picking/offline/data-plugin.ts b/libs/domain/picking/offline/data-plugin.ts deleted file mode 100644 index c58224d23..000000000 --- a/libs/domain/picking/offline/data-plugin.ts +++ /dev/null @@ -1,149 +0,0 @@ -import { OauthService, OauthServiceConfig } from '@spryker-oryx/auth'; -import { App, AppPlugin, InjectionPlugin } from '@spryker-oryx/core'; -import { Injector } from '@spryker-oryx/di'; -import { DexieIndexedDbService } from '@spryker-oryx/indexed-db'; -import { PickingListStatus } from '@spryker-oryx/picking/services'; -import { RouterService } from '@spryker-oryx/router'; -import { featureVersion } from '@spryker-oryx/utilities'; -import { - BehaviorSubject, - Observable, - Subscription, - combineLatest, - map, - of, - switchMap, - tap, - withLatestFrom, -} from 'rxjs'; -import { PickingListEntity, PickingProductEntity } from './entities'; -import { PickingListOnlineAdapter } from './services'; - -export class OfflineDataPlugin implements AppPlugin { - protected subscription?: Subscription; - protected refreshing$ = new BehaviorSubject(false); - - getName(): string { - return 'oryx.pickingOfflineData'; - } - - apply(app: App): void | Promise { - const injector = app!.requirePlugin(InjectionPlugin).getInjector(); - - const authService = injector.inject(OauthService); - const routerService = injector.inject(RouterService); - const oauthConfig = injector.inject(OauthServiceConfig); - - this.subscription = routerService - .route() - .pipe( - switchMap((currentRoute) => { - const redirectUrl = new URL( - oauthConfig.providers[0].redirectUrl as string - ); - if (currentRoute.startsWith(redirectUrl.pathname)) { - return authService.isAuthenticated(); - } - return of(undefined); - }), - switchMap((authenticated) => { - if (authenticated) { - return this.clearDb(injector).pipe( - tap(() => routerService.navigate('/warehouse-selection')) - ); - } - return of(undefined); - }) - ) - .subscribe(); - } - - destroy(): void { - this.subscription?.unsubscribe(); - } - - syncData(injector: Injector): Observable { - this.refreshing$.next(true); - return this.populateData(injector).pipe( - tap(() => this.refreshing$.next(false)) - ); - } - - isRefreshing(): Observable { - return this.refreshing$; - } - - protected clearDb(injector: Injector): Observable { - const dexieIdbService = injector.inject(DexieIndexedDbService); - - return combineLatest([ - dexieIdbService.getStore(PickingListEntity), - dexieIdbService.getStore(PickingProductEntity), - ]).pipe( - switchMap(async ([pickingStore, productStore]) => { - await pickingStore.clear(); - await productStore.clear(); - return undefined; - }) - ); - } - - protected populateDb(injector: Injector): Observable { - const onlineAdapter = injector.inject(PickingListOnlineAdapter); - const dexieIdbService = injector.inject(DexieIndexedDbService); - - return onlineAdapter - .get( - featureVersion >= '1.4' - ? { status: PickingListStatus.ReadyForPicking } - : {} - ) - .pipe( - map((pl) => { - const productIds = new Set(); - return { - pickingLists: pl, - products: pl - .map((pickingList) => - pickingList.items.map((item) => item.product) - ) - .flat() - .filter((product) => { - if (productIds.has(product.id)) return false; - productIds.add(product.id); - - return true; - }), - }; - }), - withLatestFrom( - dexieIdbService.getStore(PickingListEntity), - dexieIdbService.getStore(PickingProductEntity), - dexieIdbService.getDb() - ), - switchMap( - ([ - { pickingLists, products }, - pickingListsStore, - productStore, - db, - ]) => { - return db.transaction( - 'readwrite', - [pickingListsStore, productStore], - () => { - pickingListsStore.bulkAdd(pickingLists); - productStore.bulkAdd(products); - } - ); - } - ) - ); - } - - protected populateData(injector: Injector): Observable { - return this.clearDb(injector).pipe( - switchMap(() => this.populateDb(injector)) - ); - } -} diff --git a/libs/domain/picking/offline/entities/index.ts b/libs/domain/picking/offline/entities/index.ts deleted file mode 100644 index 3e0f843f6..000000000 --- a/libs/domain/picking/offline/entities/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './picking-list.entity'; -export * from './picking-product.entity'; diff --git a/libs/domain/picking/offline/entities/picking-list.entity.ts b/libs/domain/picking/offline/entities/picking-list.entity.ts deleted file mode 100644 index 70647d1f9..000000000 --- a/libs/domain/picking/offline/entities/picking-list.entity.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { - indexedDbEntity, - indexedDbForeignKey, - indexedDbIndex, - indexedDbPrimaryKey, -} from '@spryker-oryx/indexed-db'; -import { - PickingList, - PickingListItem, - PickingListQualifierSortBy, - PickingListStatus, -} from '@spryker-oryx/picking/services'; -import { Type } from '@spryker-oryx/utilities'; -import { Table } from 'dexie'; -import { PickingProductEntity } from './picking-product.entity'; - -declare global { - interface OryxDexieDb { - 'oryx.picking-lists': Table; - } - - interface IndexedDbEntityMap { - 'oryx.picking-lists': { - entity: typeof PickingListEntity; - mapTo: Type; - }; - } -} - -@indexedDbEntity({ storeName: 'oryx.picking-lists' }) -export class PickingListEntity implements PickingListOffline { - @indexedDbPrimaryKey() - declare id: string; - @indexedDbIndex() - declare status: PickingListStatus; - @indexedDbForeignKey({ - key: 'items.productId', - foreignEntity: PickingProductEntity, - propPath: 'items.product', - }) - declare items: PickingListItemOffline[]; - @indexedDbIndex() - declare cartNote?: string; - declare createdAt: Date; - declare updatedAt: Date; - @indexedDbIndex() - declare itemsCount: number; - @indexedDbIndex({ multiEntry: true }) - declare orderReferences: string[]; - @indexedDbIndex({ multiEntry: true }) - declare productSkus: string[]; - @indexedDbIndex() - declare requestedDeliveryDate: Date; - @indexedDbIndex() - declare localStatus: PickingListStatus; - - constructor(data: PickingListOffline) { - Object.assign(this, data); - - this.items = this.items.map((item) => { - const newItem = { ...item }; - const productKey: keyof PickingListItemOffline = 'product'; - - // Hide `product` prop so it's not stored in DB - Object.defineProperty(newItem, productKey, { enumerable: false }); - - return newItem; - }); - } -} - -export interface PickingListOffline extends PickingList { - items: PickingListItemOffline[]; - productSkus: string[]; - localStatus: PickingListStatus; -} - -export interface PickingListItemOffline extends PickingListItem { - productId: string; - product: PickingProductEntity; -} - -export interface PickingListSerialized - extends Omit { - items: PickingListItemSerialized[]; -} - -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface PickingListItemSerialized - extends Omit {} - -export type MappedQualifier = PickingListQualifierSortBy; - -export type QualifiersMapping = Record< - MappedQualifier, - keyof PickingListOffline ->; diff --git a/libs/domain/picking/offline/entities/picking-product.entity.ts b/libs/domain/picking/offline/entities/picking-product.entity.ts deleted file mode 100644 index 1db6e7dab..000000000 --- a/libs/domain/picking/offline/entities/picking-product.entity.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { - indexedDbEntity, - indexedDbIndex, - indexedDbPrimaryKey, -} from '@spryker-oryx/indexed-db'; -import { PickingProduct } from '@spryker-oryx/picking/services'; -import { Table } from 'dexie'; - -declare global { - interface OryxDexieDb { - 'oryx.picking-products': Table; - } -} - -@indexedDbEntity({ storeName: 'oryx.picking-products' }) -export class PickingProductEntity implements PickingProductOffline { - @indexedDbPrimaryKey() - declare id: string; - @indexedDbIndex() - declare sku: string; - @indexedDbIndex() - declare productName: string; - declare image: string | null; - declare imageLarge: string | null; - - constructor(data: PickingProductOffline) { - Object.assign(this, data); - } -} - -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface PickingProductOffline extends PickingProduct {} diff --git a/libs/domain/picking/offline/feature.ts b/libs/domain/picking/offline/feature.ts deleted file mode 100644 index f4d3023d5..000000000 --- a/libs/domain/picking/offline/feature.ts +++ /dev/null @@ -1,82 +0,0 @@ -import { - AppFeature, - AppPlugin, - DefaultStorageService, - injectEnv, - StorageService, -} from '@spryker-oryx/core'; -import { Provider } from '@spryker-oryx/di'; -import { - IndexedDbStorageMethod, - provideIndexedDbEntities, -} from '@spryker-oryx/indexed-db'; -import { provideSyncActionsHandler } from '@spryker-oryx/offline/sync'; -import { - PickingHttpDefaultService, - PickingHttpService, - PickingListAdapter, - PickingListDefaultService, - PickingListService, -} from '@spryker-oryx/picking/services'; -import { PushProvider } from '@spryker-oryx/push-notification'; -import { WebPushProvider } from '@spryker-oryx/push-notification/web'; -import { OfflineDataPlugin } from './data-plugin'; -import { PickingListEntity, PickingProductEntity } from './entities'; -import { PushNotificationPlugin } from './push-notification-plugin'; -import { - BapiPushNotificationAdapter, - BapiPushNotificationDefaultAdapter, - BapiPushNotificationDefaultService, - BapiPushNotificationService, - PickingListOfflineAdapter, - PickingListOnlineAdapter, - PickingListOnlineDefaultAdapter, - PickingSyncAction, - PickingSyncActionHandlerService, -} from './services'; - -export class OfflinePickingFeature implements AppFeature { - providers: Provider[] = this.getProviders(); - plugins: AppPlugin[] = [ - new OfflineDataPlugin(), - new PushNotificationPlugin(), - ]; - - protected getProviders(): Provider[] { - return [ - ...provideIndexedDbEntities([PickingListEntity, PickingProductEntity]), - ...provideSyncActionsHandler( - PickingSyncAction, - PickingSyncActionHandlerService - ), - { - provide: PushProvider, - useFactory: () => - new WebPushProvider({ - applicationServerKey: injectEnv( - 'ORYX_FULFILLMENT_PUBLIC_VAPID_KEY' - ), - }), - }, - { - provide: BapiPushNotificationService, - useClass: BapiPushNotificationDefaultService, - }, - { - provide: BapiPushNotificationAdapter, - useClass: BapiPushNotificationDefaultAdapter, - }, - { provide: PickingListService, useClass: PickingListDefaultService }, - { provide: PickingListAdapter, useClass: PickingListOfflineAdapter }, - { - provide: PickingListOnlineAdapter, - useClass: PickingListOnlineDefaultAdapter, - }, - { provide: PickingHttpService, useClass: PickingHttpDefaultService }, - { - provide: StorageService, - useFactory: () => new DefaultStorageService(IndexedDbStorageMethod), - }, - ]; - } -} diff --git a/libs/domain/picking/offline/index.ts b/libs/domain/picking/offline/index.ts deleted file mode 100644 index 04319ef78..000000000 --- a/libs/domain/picking/offline/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './data-plugin'; -export * from './entities'; -export * from './feature'; -export * from './services'; diff --git a/libs/domain/picking/offline/push-notification-plugin.ts b/libs/domain/picking/offline/push-notification-plugin.ts deleted file mode 100644 index 24b9c9090..000000000 --- a/libs/domain/picking/offline/push-notification-plugin.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { OauthService } from '@spryker-oryx/auth'; -import { ExecPlugin, InjectionPlugin } from '@spryker-oryx/core'; -import { WarehouseUserAssignmentsService } from '@spryker-oryx/picking/services'; -import { BapiPushNotificationService } from './services'; - -export class PushNotificationPlugin extends ExecPlugin { - constructor() { - super((app) => { - const injector = app!.requirePlugin(InjectionPlugin).getInjector(); - - const authService = injector.inject(OauthService); - const pushNotificationService = injector.inject( - BapiPushNotificationService - ); - const isUserAssigned = injector.inject(WarehouseUserAssignmentsService); - - isUserAssigned.getUserAssignment().subscribe((userAssignment) => { - if (userAssignment) { - pushNotificationService.initSubscription().subscribe(); - } - }); - - authService.isAuthenticated().subscribe((isAuthenticated) => { - if (!isAuthenticated) { - pushNotificationService.unsubscribe().subscribe(); - } - }); - }); - } -} diff --git a/libs/domain/picking/offline/services/adapter/bapi-push-notification-default.adapter.spec.ts b/libs/domain/picking/offline/services/adapter/bapi-push-notification-default.adapter.spec.ts deleted file mode 100644 index c3a4c925a..000000000 --- a/libs/domain/picking/offline/services/adapter/bapi-push-notification-default.adapter.spec.ts +++ /dev/null @@ -1,132 +0,0 @@ -import { createInjector, destroyInjector } from '@spryker-oryx/di'; -import { - PickingHttpService, - WarehouseUserAssignmentsService, -} from '@spryker-oryx/picking/services'; -import { of } from 'rxjs'; -import { beforeEach } from 'vitest'; -import { BapiPushNotificationDefaultAdapter } from './bapi-push-notification-default.adapter'; -import { BapiPushNotificationAdapter } from './bapi-push-notification.adapter'; - -class MockPickingHttpService implements Partial { - post = vi.fn().mockImplementation(() => of(null)); -} - -const warehouseUuid = 'warehouseUuid'; - -class MockWarehouseUserAssignmentsService - implements Partial -{ - getUserAssignment = vi.fn().mockReturnValue( - of({ - warehouse: { - uuid: warehouseUuid, - }, - }) - ); -} - -describe('BapiPushNotificationDefaultAdapter', () => { - let adapter: BapiPushNotificationAdapter; - let http: PickingHttpService; - let warehouseUserAssignmentsService: WarehouseUserAssignmentsService; - - beforeEach(() => { - const testInjector = createInjector({ - providers: [ - { - provide: BapiPushNotificationAdapter, - useClass: BapiPushNotificationDefaultAdapter, - }, - { - provide: PickingHttpService, - useClass: MockPickingHttpService, - }, - { - provide: WarehouseUserAssignmentsService, - useClass: MockWarehouseUserAssignmentsService, - }, - ], - }); - - adapter = testInjector.inject(BapiPushNotificationAdapter); - http = testInjector.inject(PickingHttpService); - warehouseUserAssignmentsService = testInjector.inject( - WarehouseUserAssignmentsService - ); - }); - - afterEach(() => { - vi.clearAllMocks(); - destroyInjector(); - }); - - it('should be provided', () => { - expect(adapter).toBeInstanceOf(BapiPushNotificationDefaultAdapter); - }); - - describe('when "sendSubscription" is called', () => { - const callback = vi.fn(); - const mockSubscription = 'mockSubscription'; - - beforeEach(() => { - adapter.sendSubscription(mockSubscription).subscribe(callback); - }); - - it('should call the getUserAssignment method of WarehouseUserAssignmentsService', () => { - expect( - warehouseUserAssignmentsService.getUserAssignment - ).toHaveBeenCalled(); - }); - - it('should call the post method of PickingHttpService with correct arguments', () => { - expect(http.post).toHaveBeenCalledWith( - '/push-notification-subscriptions', - { - data: { - type: 'push-notification-subscriptions', - attributes: { - providerName: 'web-push-php', - group: { - name: 'warehouse', - identifier: warehouseUuid, - }, - payload: mockSubscription, - }, - }, - } - ); - }); - }); - - describe('when "sendSubscription" is called with no user assignment', () => { - const mockSubscription = 'mockSubscription'; - const errorCallback = vi.fn(); - - beforeEach(() => { - warehouseUserAssignmentsService.getUserAssignment = vi - .fn() - .mockReturnValue(of(null)); - - adapter.sendSubscription(mockSubscription).subscribe({ - error: errorCallback, - }); - }); - - it('should call the getUserAssignment method of WarehouseUserAssignmentsService', () => { - expect( - warehouseUserAssignmentsService.getUserAssignment - ).toHaveBeenCalled(); - }); - - it('should not call the post method of PickingHttpService', () => { - expect(http.post).not.toHaveBeenCalled(); - }); - - it('should call the error callback', () => { - expect(errorCallback).toHaveBeenCalledWith( - new Error('No warehouse user assignment found!') - ); - }); - }); -}); diff --git a/libs/domain/picking/offline/services/adapter/bapi-push-notification-default.adapter.ts b/libs/domain/picking/offline/services/adapter/bapi-push-notification-default.adapter.ts deleted file mode 100644 index a86d21425..000000000 --- a/libs/domain/picking/offline/services/adapter/bapi-push-notification-default.adapter.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { inject } from '@spryker-oryx/di'; -import { - PickingHttpService, - WarehouseUserAssignmentsService, -} from '@spryker-oryx/picking/services'; -import { Observable, switchMap } from 'rxjs'; -import { BapiPushNotificationAdapter } from './bapi-push-notification.adapter'; - -export class BapiPushNotificationDefaultAdapter - implements BapiPushNotificationAdapter -{ - constructor( - protected pickingHttpService = inject(PickingHttpService), - protected warehouseUserAssignmentsService = inject( - WarehouseUserAssignmentsService - ) - ) {} - sendSubscription(subscription: PushSubscriptionJSON): Observable { - return this.warehouseUserAssignmentsService.getUserAssignment().pipe( - switchMap((userAssignment) => { - if (!userAssignment?.warehouse.uuid) { - throw new Error('No warehouse user assignment found!'); - } - - return this.pickingHttpService.post( - '/push-notification-subscriptions', - { - data: { - type: 'push-notification-subscriptions', - attributes: { - providerName: 'web-push-php', - group: { - name: 'warehouse', - identifier: userAssignment.warehouse.uuid, - }, - payload: subscription, - }, - }, - } - ); - }) - ) as Observable; - } -} diff --git a/libs/domain/picking/offline/services/adapter/bapi-push-notification.adapter.ts b/libs/domain/picking/offline/services/adapter/bapi-push-notification.adapter.ts deleted file mode 100644 index 977bd06db..000000000 --- a/libs/domain/picking/offline/services/adapter/bapi-push-notification.adapter.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Observable } from 'rxjs'; - -export interface BapiPushNotificationAdapter { - sendSubscription(subscription: unknown): Observable; -} - -export const BapiPushNotificationAdapter = 'oryx.BapiPushNotificationAdapter'; - -declare global { - interface InjectionTokensContractMap { - [BapiPushNotificationAdapter]: BapiPushNotificationAdapter; - } -} diff --git a/libs/domain/picking/offline/services/adapter/index.ts b/libs/domain/picking/offline/services/adapter/index.ts deleted file mode 100644 index a768e26a4..000000000 --- a/libs/domain/picking/offline/services/adapter/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './bapi-push-notification-default.adapter'; -export * from './bapi-push-notification.adapter'; -export * from './picking-list-offline.adapter'; -export * from './picking-list-online-default.adapter'; -export * from './picking-list-online.adapter'; diff --git a/libs/domain/picking/offline/services/adapter/picking-list-offline.adapter.spec.ts b/libs/domain/picking/offline/services/adapter/picking-list-offline.adapter.spec.ts deleted file mode 100644 index 73e0b72c0..000000000 --- a/libs/domain/picking/offline/services/adapter/picking-list-offline.adapter.spec.ts +++ /dev/null @@ -1,348 +0,0 @@ -import { createInjector, destroyInjector } from '@spryker-oryx/di'; -import { IndexedDbService } from '@spryker-oryx/indexed-db'; -import { SyncSchedulerService } from '@spryker-oryx/offline/sync'; -import { mockPickingListData } from '@spryker-oryx/picking/mocks'; -import { - PickingListAdapter, - PickingListQualifierSortBy, - PickingListStatus, -} from '@spryker-oryx/picking/services'; -import { nextTick } from '@spryker-oryx/utilities'; -import { Collection, Table } from 'dexie'; -import { of } from 'rxjs'; -import { PickingListEntity, PickingProductEntity } from '../../entities'; -import { PickingSyncAction } from '../picking-sync-action-handler.service'; -import { PickingListOfflineAdapter } from './picking-list-offline.adapter'; -import { PickingListOnlineAdapter } from './picking-list-online.adapter'; - -vi.mock('dexie', () => { - const liveQuery = vi.fn().mockImplementation((fn: any) => fn()); - return { liveQuery }; -}); - -class MockIndexedDbService implements Partial { - getStore = vi.fn().mockImplementation(() => of(mockTable)); - getDb = vi.fn().mockReturnValue(of(mockDb)); -} - -class MockSyncSchedulerService implements Partial { - schedule = vi.fn().mockReturnValue(of(undefined)); -} - -class MockPickingListOnlineAdapter - implements Partial -{ - startPicking = vi.fn().mockReturnValue(of({ status: 'mock' })); -} - -const mockContent = { items: [] }; - -class MockCollection implements Partial { - toArray = vi.fn().mockReturnValue([]); - equals = vi.fn().mockReturnValue(this); - startsWithAnyOfIgnoreCase = vi.fn().mockReturnValue(this); - distinct = vi.fn().mockReturnValue(this); - offset = vi.fn().mockReturnValue(this); - limit = vi.fn().mockReturnValue(this); - reverse = vi.fn().mockReturnValue(this); - sortBy = vi.fn().mockReturnValue([]); -} - -const mockCollection = new MockCollection(); - -class MockDb implements Partial { - transaction = vi.fn().mockImplementation((mode, tables, fn) => fn()); -} - -class MockTable implements Partial { - get = vi.fn().mockReturnValue(mockContent); - where = vi.fn().mockReturnValue(mockCollection); - toCollection = vi.fn().mockReturnValue(mockCollection); - bulkGet = vi.fn().mockReturnValue([mockContent]); - update = vi.fn().mockReturnValue(mockContent); -} - -const mockTable = new MockTable(); -const mockDb = new MockDb(); - -describe('PickingListOfflineAdapter', () => { - let adapter: PickingListAdapter; - let indexeddb: MockIndexedDbService; - let onlineAdapter: MockPickingListOnlineAdapter; - let syncScheduler: MockSyncSchedulerService; - - beforeEach(() => { - const testInjector = createInjector({ - providers: [ - { - provide: PickingListAdapter, - useClass: PickingListOfflineAdapter, - }, - { - provide: IndexedDbService, - useClass: MockIndexedDbService, - }, - { - provide: SyncSchedulerService, - useClass: MockSyncSchedulerService, - }, - { - provide: PickingListOnlineAdapter, - useClass: MockPickingListOnlineAdapter, - }, - ], - }); - adapter = testInjector.inject(PickingListAdapter); - indexeddb = testInjector.inject( - IndexedDbService - ) as unknown as MockIndexedDbService; - onlineAdapter = testInjector.inject( - PickingListOnlineAdapter - ) as unknown as MockPickingListOnlineAdapter; - syncScheduler = testInjector.inject( - SyncSchedulerService - ) as unknown as MockSyncSchedulerService; - }); - - afterEach(() => { - vi.clearAllMocks(); - destroyInjector(); - }); - - it('should be provided', () => { - expect(adapter).toBeInstanceOf(PickingListOfflineAdapter); - }); - - describe('when get is called', () => { - const callback = vi.fn(); - beforeEach(() => { - adapter.get({}).subscribe(callback); - }); - it('should complete observable', async () => { - await nextTick(4); - expect(callback).toHaveBeenCalled(); - }); - - it('should call indexed DB getDb', () => { - expect(indexeddb.getDb).toHaveBeenCalled(); - }); - - it('should call indexed DB getStore', () => { - expect(indexeddb.getStore).toHaveBeenCalledWith(PickingListEntity); - expect(indexeddb.getStore).toHaveBeenCalledWith(PickingProductEntity); - }); - - it('should call DB transaction', () => { - expect(mockDb.transaction).toHaveBeenCalledWith( - 'readonly', - [mockTable, mockTable], - expect.any(Function) - ); - }); - - describe('and qualifier has an id', () => { - it('should get picking list store by id', () => { - adapter.get({ ids: ['mockid'] }).subscribe(); - - expect(mockTable.bulkGet).toHaveBeenCalledWith(['mockid']); - }); - - describe('and store is empty', () => { - beforeEach(() => { - mockTable.get.mockReturnValue(undefined); - adapter.get({ ids: ['mockid'] }).subscribe(callback); - }); - - it('should return empty array', async () => { - await nextTick(4); - - expect(callback).toHaveBeenCalledWith([]); - }); - - afterEach(() => { - mockTable.get.mockReturnValue(mockContent); - }); - }); - }); - - describe('and qualifier has a status', () => { - it('should filter store', () => { - adapter.get({ status: PickingListStatus.PickingStarted }).subscribe(); - - expect(mockTable.where).toHaveBeenCalledWith('localStatus'); - expect(mockCollection.equals).toHaveBeenCalledWith( - PickingListStatus.PickingStarted - ); - }); - }); - - describe('and qualifier has order references', () => { - it('should filter store', () => { - adapter.get({ searchOrderReference: 'mockOrderReference' }).subscribe(); - - expect(mockTable.where).toHaveBeenCalledWith('orderReferences'); - expect(mockCollection.startsWithAnyOfIgnoreCase).toHaveBeenCalledWith( - 'mockOrderReference' - ); - expect(mockCollection.distinct).toHaveBeenCalled(); - }); - }); - - describe('and qualifier has offset', () => { - it('should filter store', () => { - adapter.get({ offset: 1 }).subscribe(); - - expect(mockCollection.offset).toHaveBeenCalledWith(1); - }); - }); - - describe('and qualifier has limit', () => { - it('should filter store', () => { - adapter.get({ limit: 1 }).subscribe(); - - expect(mockCollection.limit).toHaveBeenCalledWith(1); - }); - }); - - describe('and qualifier has sortDesc', () => { - it('should filter store', () => { - adapter.get({ sortDesc: true }).subscribe(); - - expect(mockCollection.reverse).toHaveBeenCalled(); - }); - }); - - describe('and qualifier has sortBy', () => { - it('should map the qualifier and filter store', () => { - adapter - .get({ sortBy: PickingListQualifierSortBy.DeliveryDate }) - .subscribe(); - - expect(mockCollection.sortBy).toHaveBeenCalledWith( - 'requestedDeliveryDate' - ); - }); - }); - }); - - describe('when startPicking is called', () => { - const callback = vi.fn(); - beforeEach(() => { - adapter.startPicking(mockPickingListData[0]).subscribe(callback); - }); - it('should complete observable', async () => { - await nextTick(3); - - expect(callback).toHaveBeenCalled(); - }); - - it('should call indexed DB getDb', () => { - expect(indexeddb.getDb).toHaveBeenCalled(); - }); - - it('should call indexed DB getStore', () => { - expect(indexeddb.getStore).toHaveBeenCalledWith(PickingListEntity); - expect(indexeddb.getStore).toHaveBeenCalledWith(PickingProductEntity); - }); - - it('should call DB transaction', () => { - expect(mockDb.transaction).toHaveBeenCalledWith( - 'readwrite', - [mockTable, mockTable], - expect.any(Function) - ); - }); - - it('should call online adapter startPicking', () => { - expect(onlineAdapter.startPicking).toHaveBeenCalledWith( - mockPickingListData[0] - ); - }); - - it('should call store update', () => { - expect(mockTable.update).toHaveBeenCalledWith(mockPickingListData[0].id, { - status: 'mock', - localStatus: 'mock', - }); - }); - }); - - describe('when updatePickingItems is called', () => { - const callback = vi.fn(); - beforeEach(() => { - adapter.updatePickingItems(mockPickingListData[0]).subscribe(callback); - }); - it('should complete observable', async () => { - await nextTick(3); - expect(callback).toHaveBeenCalled(); - }); - - it('should call indexed DB getDb', () => { - expect(indexeddb.getDb).toHaveBeenCalled(); - }); - - it('should call indexed DB getStore', () => { - expect(indexeddb.getStore).toHaveBeenCalledWith(PickingListEntity); - expect(indexeddb.getStore).toHaveBeenCalledWith(PickingProductEntity); - }); - - it('should call DB transaction', () => { - expect(mockDb.transaction).toHaveBeenCalledWith( - 'readwrite', - [mockTable, mockTable], - expect.any(Function) - ); - }); - - it('should call store', () => { - expect(mockTable.update).toHaveBeenCalledWith(mockPickingListData[0].id, { - items: mockPickingListData[0].items, - }); - expect(mockTable.get).toHaveBeenCalledWith(mockPickingListData[0].id); - }); - }); - - describe('when finishPicking is called', () => { - const callback = vi.fn(); - beforeEach(() => { - adapter.finishPicking(mockPickingListData[0]).subscribe(callback); - }); - it('should complete observable', async () => { - await nextTick(3); - expect(callback).toHaveBeenCalled(); - }); - - it('should call indexed DB getDb', () => { - expect(indexeddb.getDb).toHaveBeenCalled(); - }); - - it('should call indexed DB getStore', () => { - expect(indexeddb.getStore).toHaveBeenCalledWith(PickingListEntity); - expect(indexeddb.getStore).toHaveBeenCalledWith(PickingProductEntity); - }); - - it('should call DB transaction', () => { - expect(mockDb.transaction).toHaveBeenCalledWith( - 'readwrite', - [mockTable, mockTable], - expect.any(Function) - ); - }); - - it('should call store', () => { - expect(mockTable.update).toHaveBeenCalledWith(mockPickingListData[0].id, { - localStatus: PickingListStatus.PickingFinished, - items: mockPickingListData[0].items, - }); - expect(mockTable.get).toHaveBeenCalledWith(mockPickingListData[0].id); - }); - - it('should call SyncSchedulerService schedule', async () => { - await nextTick(3); - expect(syncScheduler.schedule).toHaveBeenCalledWith({ - action: PickingSyncAction.FinishPicking, - payload: mockContent, - }); - }); - }); -}); diff --git a/libs/domain/picking/offline/services/adapter/picking-list-offline.adapter.ts b/libs/domain/picking/offline/services/adapter/picking-list-offline.adapter.ts deleted file mode 100644 index 74d4c1c57..000000000 --- a/libs/domain/picking/offline/services/adapter/picking-list-offline.adapter.ts +++ /dev/null @@ -1,297 +0,0 @@ -import { inject } from '@spryker-oryx/di'; -import { IndexedDbService } from '@spryker-oryx/indexed-db'; -import { SyncSchedulerService } from '@spryker-oryx/offline/sync'; -import { - PickingListAdapter, - PickingListQualifier, - PickingListQualifierSortBy, - PickingListStatus, -} from '@spryker-oryx/picking/services'; -import { intersectArrays } from '@spryker-oryx/utilities'; -import { Collection, Table, liveQuery } from 'dexie'; -import { Observable, combineLatestWith, map, switchMap } from 'rxjs'; -import { - MappedQualifier, - PickingListEntity, - PickingListOffline, - PickingListSerialized, - PickingProductEntity, - QualifiersMapping, -} from '../../entities'; -import { PickingSyncAction } from '../picking-sync-action-handler.service'; -import { PickingListOnlineAdapter } from './picking-list-online.adapter'; - -export class PickingListOfflineAdapter implements PickingListAdapter { - constructor( - protected indexedDbService = inject(IndexedDbService), - protected syncSchedulerService = inject(SyncSchedulerService), - protected onlineAdapter = inject(PickingListOnlineAdapter) - ) {} - - protected qualifiersMapping: QualifiersMapping = { - [PickingListQualifierSortBy.DeliveryDate]: 'requestedDeliveryDate', - [PickingListQualifierSortBy.OrderSize]: 'itemsCount', - }; - - get(qualifier: PickingListQualifier): Observable { - return this.indexedDbService.getDb().pipe( - combineLatestWith( - this.indexedDbService.getStore(PickingListEntity), - this.indexedDbService.getStore(PickingProductEntity) - ), - switchMap(([db, pickingListStore, productStore]) => { - return liveQuery(() => - db.transaction( - 'readonly', - [pickingListStore, productStore], - async () => { - if (qualifier.ids?.length) { - const data = await pickingListStore.bulkGet(qualifier.ids); - const filteredData = data.filter( - (pl) => !!pl - ) as PickingListSerialized[]; - - return this.deserializePickingLists(filteredData, productStore); - } - - const andCollections: Collection[] = []; - - if ( - qualifier.searchOrderReference && - qualifier.searchOrderReference.length >= 2 - ) { - andCollections.push( - pickingListStore - .where('orderReferences') - .startsWithAnyOfIgnoreCase(qualifier.searchOrderReference) - .distinct() - ); - } - - if (qualifier.status) { - andCollections.push( - pickingListStore.where('localStatus').equals(qualifier.status) - ); - } - - if (andCollections.length === 0) { - andCollections.push(pickingListStore.toCollection()); - } - - const andGroups = await Promise.all( - andCollections.map((collection) => { - if (qualifier.offset) { - collection = collection.offset(qualifier.offset); - } - - if (qualifier.limit) { - collection = collection.limit(qualifier.limit); - } - - if (qualifier.sortDesc) { - collection = collection.reverse(); - } - - if (qualifier.sortBy) { - return collection.sortBy( - this.mapQualifier(qualifier.sortBy) - ); - } - - return collection.toArray(); - }) - ); - - let data = intersectArrays((item) => item.id, ...andGroups); - - // Drop any excess data after merging groups - if (qualifier.limit) { - data = data.slice(0, qualifier.limit); - } - - return await this.deserializePickingLists(data, productStore); - } - ) - ); - }) - ); - } - - startPicking(pickingList: PickingListEntity): Observable { - return this.indexedDbService.getDb().pipe( - combineLatestWith( - this.indexedDbService.getStore(PickingListEntity), - this.indexedDbService.getStore(PickingProductEntity), - this.onlineAdapter.startPicking(pickingList) - ), - switchMap(([db, pickingListStore, productStore, updatedPickingList]) => - db.transaction( - 'readwrite', - [pickingListStore, productStore], - async () => { - const updatedObjects = await pickingListStore.update( - pickingList.id, - { - ...updatedPickingList, - localStatus: updatedPickingList.status, - } - ); - - const pickingListData = await pickingListStore.get(pickingList.id); - - if (updatedObjects === 0 || !pickingListData) { - throw new PickingListNotFoundError( - pickingList.id, - 'Cannot start picking' - ); - } - - return this.deserializePickingList(pickingListData, productStore); - } - ) - ) - ); - } - - updatePickingItems( - pickingList: PickingListEntity - ): Observable { - return this.indexedDbService.getDb().pipe( - combineLatestWith( - this.indexedDbService.getStore(PickingListEntity), - this.indexedDbService.getStore(PickingProductEntity) - ), - switchMap(([db, pickingListStore, productStore]) => - db.transaction( - 'readwrite', - [pickingListStore, productStore], - async () => { - const updatedObjects = await pickingListStore.update( - pickingList.id, - { - items: pickingList.items, - } - ); - - const pickingListData = await pickingListStore.get(pickingList.id); - - if (updatedObjects === 0 || !pickingListData) { - throw new PickingListNotFoundError( - pickingList.id, - 'Cannot update picking' - ); - } - - return this.deserializePickingList(pickingListData, productStore); - } - ) - ) - ); - } - - finishPicking(pickingList: PickingListEntity): Observable { - return this.indexedDbService.getDb().pipe( - combineLatestWith( - this.indexedDbService.getStore(PickingListEntity), - this.indexedDbService.getStore(PickingProductEntity) - ), - switchMap(([db, pickingListStore, productStore]) => - db.transaction( - 'readwrite', - [pickingListStore, productStore], - async () => { - const updatedObjects = await pickingListStore.update( - pickingList.id, - { - localStatus: PickingListStatus.PickingFinished, - items: pickingList.items, - } - ); - - const pickingListData = await pickingListStore.get(pickingList.id); - - if (updatedObjects === 0 || !pickingListData) { - throw new PickingListNotFoundError( - pickingList.id, - 'Cannot finish picking' - ); - } - - return this.deserializePickingList(pickingListData, productStore); - } - ) - ), - switchMap((pickingList) => - this.syncSchedulerService - .schedule({ - action: PickingSyncAction.FinishPicking, - payload: pickingList, - }) - .pipe(map(() => pickingList)) - ) - ); - } - - protected async deserializePickingList( - pickingList: PickingListSerialized, - productStore: Table - ): Promise { - const lists = await this.deserializePickingLists( - [pickingList], - productStore - ); - - return lists[0]; - } - - protected async deserializePickingLists( - pickingLists: PickingListSerialized[], - productStore: Table - ): Promise { - const productIds = pickingLists - .map((pickingList) => pickingList.items.map((item) => item.productId)) - .flat(); - - const productsData = await productStore.bulkGet(productIds); - - const productMap = Object.fromEntries( - productIds.map((productId) => { - const productData = productsData.find((d) => d?.id === productId); - - if (!productData) { - throw new Error( - `PickingListOfflineAdapter: Foreign key` + - ` ${PickingProductEntity.name}(${productId})` + - ` cannot be found when resolving ${PickingListEntity.name}!` - ); - } - - return [productData.id, new PickingProductEntity(productData)]; - }) - ); - - const fullData: PickingListOffline[] = pickingLists.map((pickingList) => ({ - ...pickingList, - items: pickingList.items.map((item) => ({ - ...item, - product: productMap[item.productId], - })), - })); - - return fullData.map((data) => new PickingListEntity(data)); - } - - protected mapQualifier(qualifier: MappedQualifier): keyof PickingListOffline { - return this.qualifiersMapping[qualifier]; - } -} - -export class PickingListNotFoundError extends Error { - constructor(pickingListId: string, errorDesc?: string) { - super( - `${ - errorDesc ? `${errorDesc} because ` : '' - }PickingList(${pickingListId}) was not found!` - ); - } -} diff --git a/libs/domain/picking/offline/services/adapter/picking-list-online-default.adapter.spec.ts b/libs/domain/picking/offline/services/adapter/picking-list-online-default.adapter.spec.ts deleted file mode 100644 index 1074cf35f..000000000 --- a/libs/domain/picking/offline/services/adapter/picking-list-online-default.adapter.spec.ts +++ /dev/null @@ -1,193 +0,0 @@ -import { HttpTestService } from '@spryker-oryx/core/testing'; -import { createInjector, destroyInjector } from '@spryker-oryx/di'; -import { IndexedDbService } from '@spryker-oryx/indexed-db'; -import { mockPickingListData } from '@spryker-oryx/picking/mocks'; -import { - ItemsFilters, - PickingHttpService, - PickingListDefaultAdapter, - PickingListStatus, -} from '@spryker-oryx/picking/services'; -import { nextTick } from '@spryker-oryx/utilities'; -import { Table } from 'dexie'; -import { of } from 'rxjs'; -import { PickingListEntity } from '../../entities'; -import { PickingListOnlineDefaultAdapter } from './picking-list-online-default.adapter'; -import { PickingListOnlineAdapter } from './picking-list-online.adapter'; - -const mockPickingListEntity = new PickingListEntity({ - ...mockPickingListData[0], - itemsCount: 1, - productSkus: [], - requestedDeliveryDate: new Date(), - localStatus: PickingListStatus.ReadyForPicking, - items: [], -}); - -const mockPickingListDataResponse = { - data: [ - { - attributes: { - id: 'mock-id', - uuid: 'mock-uuid', - status: 'mock-status', - pickingListItems: [ - { - id: 'mock-item-id', - concreteProducts: [ - { - id: 'mock-product-id', - sku: 'mock-sku', - name: 'mock-name', - concreteProductImageSets: [ - { - imageSets: [ - { - images: [ - { externalUrlSmall: '', externalUrlLarge: '' }, - ], - }, - ], - }, - ], - }, - ], - orderItem: { uuid: 'mock-order-uuid' }, - salesShipments: [{ requestedDeliveryDate: 123 }], - salesOrders: [ - { cartNote: 'mock-note', orderReference: 'mockOrderReference' }, - ], - quantity: 1, - }, - ], - createdAt: '', - updatedAt: '', - }, - }, - ], - included: [{ pickingListItems: [] }], - links: { self: 'mocklink' }, -}; - -class MockIndexedDbService implements Partial { - getStore = vi.fn().mockImplementation(() => of(mockTable)); -} - -class MockTable implements Partial
{ - bulkGet = vi.fn().mockReturnValue(new Promise((resolve) => resolve([]))); -} - -const mockTable = new MockTable(); - -describe('PickingListOnlineAdapter', () => { - let adapter: PickingListOnlineAdapter; - let indexeddb: MockIndexedDbService; - let http: HttpTestService; - - beforeEach(() => { - const testInjector = createInjector({ - providers: [ - { - provide: PickingListOnlineAdapter, - useClass: PickingListOnlineDefaultAdapter, - }, - { - provide: IndexedDbService, - useClass: MockIndexedDbService, - }, - { - provide: PickingHttpService, - useClass: HttpTestService, - }, - ], - }); - adapter = testInjector.inject(PickingListOnlineAdapter); - indexeddb = testInjector.inject( - IndexedDbService - ) as unknown as MockIndexedDbService; - http = testInjector.inject( - PickingHttpService - ) as unknown as HttpTestService; - - http.flush(mockPickingListDataResponse); - }); - - afterEach(() => { - vi.clearAllMocks(); - destroyInjector(); - }); - - it('should be provided', () => { - expect(adapter).toBeInstanceOf(PickingListOnlineDefaultAdapter); - }); - - describe('when get is called', () => { - const callback = vi.fn(); - const spy = vi.spyOn(PickingListDefaultAdapter.prototype, 'get'); - beforeEach(() => { - adapter.get({}).subscribe(callback); - }); - it('should parse picking lists', async () => { - await nextTick(7); - - expect(callback).toHaveBeenCalledWith([ - expect.objectContaining({ - items: [ - { - id: 'mock-item-id', - orderItem: { uuid: 'mock-order-uuid' }, - type: 'picking-list-items', - status: ItemsFilters.NotPicked, - productId: 'mock-product-id', - quantity: 1, - }, - ], - itemsCount: 1, - orderReferences: ['mockOrderReference'], - requestedDeliveryDate: new Date(123), - localStatus: 'mock-status', - productSkus: ['mock-sku'], - }), - ]); - expect(indexeddb.getStore).toHaveBeenCalledWith(PickingListEntity); - expect(mockTable.bulkGet).toHaveBeenCalledWith(['mock-id']); - }); - - it('should call super', () => { - expect(spy).toHaveBeenCalledWith({}); - }); - }); - - describe('when startPicking is called', () => { - it('should call super', () => { - const spy = vi.spyOn(PickingListDefaultAdapter.prototype, 'startPicking'); - adapter.startPicking(mockPickingListEntity).subscribe(); - - expect(spy).toHaveBeenCalledWith(mockPickingListEntity); - }); - }); - - describe('when updatePickingItems is called', () => { - it('should call super', () => { - const spy = vi.spyOn( - PickingListDefaultAdapter.prototype, - 'updatePickingItems' - ); - adapter.updatePickingItems(mockPickingListEntity).subscribe(); - - expect(spy).toHaveBeenCalledWith(mockPickingListEntity); - }); - }); - - describe('when finishPicking is called', () => { - it('should call super', () => { - const spy = vi.spyOn( - PickingListDefaultAdapter.prototype, - 'finishPicking' - ); - adapter.finishPicking(mockPickingListEntity).subscribe(); - - expect(spy).toHaveBeenCalledWith(mockPickingListEntity); - }); - }); -}); diff --git a/libs/domain/picking/offline/services/adapter/picking-list-online-default.adapter.ts b/libs/domain/picking/offline/services/adapter/picking-list-online-default.adapter.ts deleted file mode 100644 index 7672aed9b..000000000 --- a/libs/domain/picking/offline/services/adapter/picking-list-online-default.adapter.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { inject } from '@spryker-oryx/di'; -import { IndexedDbService } from '@spryker-oryx/indexed-db'; -import { - GetPickingListResponse, - PickingHttpService, - PickingList, - PickingListDefaultAdapter, - PickingListQualifier, -} from '@spryker-oryx/picking/services'; -import { isDefined } from '@spryker-oryx/utilities'; -// Add full import because of issue with naming exports from cjs. -import * as jsonapi from 'jsonapi-serializer'; -import { firstValueFrom, Observable } from 'rxjs'; -import { - PickingListEntity, - PickingListItemOffline, - PickingListSerialized, - PickingProductEntity, -} from '../../entities'; -import { PickingListOnlineAdapter } from './picking-list-online.adapter'; - -export class PickingListOnlineDefaultAdapter - extends PickingListDefaultAdapter - implements PickingListOnlineAdapter -{ - constructor( - pickingHttpSerivce = inject(PickingHttpService), - deserializer = new jsonapi.Deserializer({ - keyForAttribute: 'camelCase', - }), - protected indexedDbService = inject(IndexedDbService) - ) { - super(pickingHttpSerivce, deserializer); - } - - get(qualifier: PickingListQualifier): Observable { - return super.get(qualifier) as Observable; - } - - startPicking(pickingList: PickingListEntity): Observable { - return super.startPicking(pickingList) as Observable; - } - - updatePickingItems( - pickingList: PickingListEntity - ): Observable { - return super.updatePickingItems( - pickingList - ) as Observable; - } - - finishPicking(pickingList: PickingListEntity): Observable { - return super.finishPicking(pickingList) as Observable; - } - - protected override async parsePickingLists( - response: GetPickingListResponse - ): Promise { - const basePickingLists = await super.parsePickingLists(response); - const pickingListStore = await firstValueFrom( - this.indexedDbService.getStore(PickingListEntity) - ); - const existingPickingLists = await pickingListStore - .bulkGet(basePickingLists.map((pl) => pl.id)) - .then((pickingLists) => pickingLists.filter(isDefined)); - - return this.pickingListsToEntity(basePickingLists, existingPickingLists); - } - - protected pickingListsToEntity( - pickingLists: PickingList[], - existingPickingLists: PickingListSerialized[] - ): PickingListEntity[] { - return pickingLists.map((pickingList) => { - const existingPickingList = existingPickingLists.find( - (pl) => pl.id === pickingList.id - ); - - // Merge local status - const localStatus = - !existingPickingList || - pickingList.status !== existingPickingList.localStatus - ? pickingList.status - : existingPickingList.localStatus; - - const productSkus = pickingList.items.map((item) => item.product.sku); - - const items: PickingListItemOffline[] = pickingList.items.map((item) => ({ - ...item, - productId: item.product.id, - product: new PickingProductEntity(item.product), - })); - - return new PickingListEntity({ - ...pickingList, - items, - productSkus, - localStatus, - }); - }); - } -} diff --git a/libs/domain/picking/offline/services/adapter/picking-list-online.adapter.ts b/libs/domain/picking/offline/services/adapter/picking-list-online.adapter.ts deleted file mode 100644 index bea78d008..000000000 --- a/libs/domain/picking/offline/services/adapter/picking-list-online.adapter.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { - PickingListAdapter, - PickingListQualifier, -} from '@spryker-oryx/picking/services'; -import { Observable } from 'rxjs'; -import { PickingListEntity } from '../../entities'; - -export interface PickingListOnlineAdapter extends PickingListAdapter { - get(qualifier?: PickingListQualifier): Observable; - startPicking(pickingList: PickingListEntity): Observable; - updatePickingItems( - pickingList: PickingListEntity - ): Observable; - finishPicking(pickingList: PickingListEntity): Observable; -} - -export const PickingListOnlineAdapter = 'oryx.PickingListOnlineAdapter'; - -declare global { - interface InjectionTokensContractMap { - [PickingListOnlineAdapter]: PickingListOnlineAdapter; - } -} diff --git a/libs/domain/picking/offline/services/bapi-push-notification-default.service.spec.ts b/libs/domain/picking/offline/services/bapi-push-notification-default.service.spec.ts deleted file mode 100644 index 685d67f71..000000000 --- a/libs/domain/picking/offline/services/bapi-push-notification-default.service.spec.ts +++ /dev/null @@ -1,225 +0,0 @@ -import { StorageService } from '@spryker-oryx/core'; -import { createInjector, destroyInjector } from '@spryker-oryx/di'; -import { PushService } from '@spryker-oryx/push-notification'; -import { Subscription, of, throwError } from 'rxjs'; -import { BapiPushNotificationAdapter } from './adapter'; -import { BapiPushNotificationDefaultService } from './bapi-push-notification-default.service'; - -class MockPushService implements Partial { - subscribe = vi.fn().mockImplementation(() => of(null)); - unsubscribe = vi.fn().mockImplementation(() => of(null)); -} - -const defaultPermissions = { - notification: 'granted', - 'background-sync': 'granted', -} as Record; - -const mockPermissions = (permissions = defaultPermissions) => ({ - query: ({ name }: { name: string }) => ({ state: permissions[name] }), -}); - -class MockBapiPushNotificationAdapter - implements Partial -{ - sendSubscription = vi.fn().mockImplementation(() => of(null)); -} - -class MockStorageService implements Partial { - get = vi.fn().mockImplementation(() => of(false)); - set = vi.fn().mockImplementation(() => of(null)); - remove = vi.fn().mockImplementation(() => of(null)); -} - -describe('BapiPushNotificationDefaultService', () => { - const subscriptionFlagKey = 'oryx.push-notification-subscription'; - - let service: BapiPushNotificationDefaultService; - let pushService: MockPushService; - let adapter: MockBapiPushNotificationAdapter; - let storage: MockStorageService; - - beforeEach(() => { - vi.stubGlobal('navigator', { - serviceWorker: {}, - permissions: mockPermissions(), - }); - vi.stubGlobal('window', { SyncManager: {} }); - - const testInjector = createInjector({ - providers: [ - { - provide: BapiPushNotificationDefaultService, - useClass: BapiPushNotificationDefaultService, - }, - { - provide: PushService, - useClass: MockPushService, - }, - { - provide: BapiPushNotificationAdapter, - useClass: MockBapiPushNotificationAdapter, - }, - { - provide: StorageService, - useClass: MockStorageService, - }, - ], - }); - - service = testInjector.inject(BapiPushNotificationDefaultService); - pushService = testInjector.inject( - PushService - ) as unknown as MockPushService; - adapter = testInjector.inject( - BapiPushNotificationAdapter - ) as unknown as MockBapiPushNotificationAdapter; - storage = testInjector.inject( - StorageService - ) as unknown as MockStorageService; - }); - - afterEach(() => { - vi.clearAllMocks(); - destroyInjector(); - }); - - it('should be provided', () => { - expect(service).toBeInstanceOf(BapiPushNotificationDefaultService); - }); - - describe('when initSubscription is called', () => { - let subscription: Subscription; - - afterEach(() => { - if (subscription) { - subscription.unsubscribe(); - } - }); - - it('should subscribe and send subscription', () => { - service.initSubscription().subscribe(() => { - expect(pushService.subscribe).toHaveBeenCalled(); - expect(adapter.sendSubscription).toHaveBeenCalled(); - expect(storage.get).toHaveBeenCalledWith(subscriptionFlagKey); - expect(storage.set).toHaveBeenCalledWith(subscriptionFlagKey, true); - }); - }); - - it('should handle error when subscription already exists', () => { - const error = { - body: { - errors: [ - { - status: 400, - code: 5003, - }, - ], - }, - }; - adapter.sendSubscription.mockImplementationOnce(() => - throwError(() => error) - ); - - const errorSubscription = service.initSubscription().subscribe({ - error: (err) => expect(err).toEqual(error), - }); - - errorSubscription.unsubscribe(); - }); - }); - - describe('when unsubscribe is called', () => { - const callback = vi.fn(); - - beforeEach(() => { - service.unsubscribe().subscribe(callback); - }); - - it('should unsubscribe and remove subscription flag', () => { - expect(callback).toHaveBeenCalled(); - expect(pushService.unsubscribe).toHaveBeenCalled(); - expect(storage.remove).toHaveBeenCalledWith(subscriptionFlagKey); - }); - }); - - describe('error handling', () => { - describe('when service-worker API is not supported', () => { - beforeEach(() => { - vi.stubGlobal('navigator', {}); - }); - - it('should throw an error', () => { - service - .initSubscription() - .subscribe({ - error: (e) => - expect(e.message).toBe( - 'Browser does not support service-worker API' - ), - }) - .unsubscribe(); - }); - }); - - describe('when syncManager API is not supported', () => { - beforeEach(() => { - vi.stubGlobal('window', {}); - }); - - it('should throw an error', () => { - service - .initSubscription() - .subscribe({ - error: (e) => - expect(e.message).toBe( - 'Browser does not support background sync API' - ), - }) - .unsubscribe(); - }); - }); - - describe('when notifications are not allowed', () => { - beforeEach(() => { - vi.stubGlobal('navigator', { - serviceWorker: {}, - permissions: mockPermissions({ notification: 'denied' }), - }); - }); - - it('should throw an error', () => { - service - .initSubscription() - .subscribe({ - error: (e) => - expect(e.message).toBe( - 'Permission to accept push notifications is not granted. Check the browser configuration or reset the permission' - ), - }) - .unsubscribe(); - }); - }); - - describe('when background sync is not allowed', () => { - beforeEach(() => { - vi.stubGlobal('navigator', { - serviceWorker: {}, - permissions: mockPermissions({ 'background-sync': 'denied' }), - }); - }); - - it('should throw an error', () => { - service - .initSubscription() - .subscribe({ - error: (e) => - expect(e.message).toBe( - 'Permission to perform background sync is not granted. Check the browser configuration or reset the permission' - ), - }) - .unsubscribe(); - }); - }); - }); -}); diff --git a/libs/domain/picking/offline/services/bapi-push-notification-default.service.ts b/libs/domain/picking/offline/services/bapi-push-notification-default.service.ts deleted file mode 100644 index ba31e36e1..000000000 --- a/libs/domain/picking/offline/services/bapi-push-notification-default.service.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { StorageService } from '@spryker-oryx/core'; -import { inject } from '@spryker-oryx/di'; -import { PushService } from '@spryker-oryx/push-notification'; -import { - catchError, - defer, - filter, - from, - Observable, - of, - switchMap, - take, - throwError, -} from 'rxjs'; -import { BapiPushNotificationAdapter } from './adapter'; -import { BapiPushNotificationService } from './bapi-push-notification.service'; - -export class BapiPushNotificationDefaultService - implements BapiPushNotificationService -{ - protected readonly subscriptionFlagKey = - 'oryx.push-notification-subscription'; - - constructor( - private pushService: PushService = inject(PushService), - private bapiPushNotificationAdapter: BapiPushNotificationAdapter = inject( - BapiPushNotificationAdapter - ), - private storageService: StorageService = inject(StorageService) - ) {} - - initSubscription(): Observable { - return this.precondition().pipe( - switchMap(() => - this.storageService.get(this.subscriptionFlagKey) - ), - filter((isSubscribed) => !isSubscribed), - switchMap(() => this.pushService.subscribe()), - switchMap((subscription) => - this.bapiPushNotificationAdapter.sendSubscription(subscription).pipe( - // catch error when subscription already exists - catchError((error: any) => { - if ( - error.body.errors[0].status === 400 && - error.body.errors[0].code === 5003 - ) { - return of(undefined); - } - - return this.unsubscribe().pipe( - switchMap(() => throwError(() => error)) - ); - }) - ) - ), - switchMap(() => this.storageService.set(this.subscriptionFlagKey, true)) - ); - } - - unsubscribe(): Observable { - return this.pushService - .unsubscribe() - .pipe( - switchMap(() => this.storageService.remove(this.subscriptionFlagKey)) - ); - } - - protected async checkSupportAndPermission(): Promise { - if (!('serviceWorker' in navigator)) { - throw new Error('Browser does not support service-worker API'); - } - - if (!('SyncManager' in window)) { - throw new Error('Browser does not support background sync API'); - } - - if (await this.permissionDenied('notifications')) { - throw new Error( - 'Permission to accept push notifications is not granted. Check the browser configuration or reset the permission' - ); - } - - if (await this.permissionDenied('background-sync')) { - throw new Error( - 'Permission to perform background sync is not granted. Check the browser configuration or reset the permission' - ); - } - } - - protected precondition(): Observable { - return defer(() => from(this.checkSupportAndPermission())).pipe(take(1)); - } - - protected async permissionDenied(name: string): Promise { - return ( - (await navigator.permissions.query({ name: name as PermissionName })) - ?.state === 'denied' - ); - } -} diff --git a/libs/domain/picking/offline/services/bapi-push-notification.service.ts b/libs/domain/picking/offline/services/bapi-push-notification.service.ts deleted file mode 100644 index 9415c5d21..000000000 --- a/libs/domain/picking/offline/services/bapi-push-notification.service.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Observable } from 'rxjs'; - -export interface BapiPushNotificationService { - initSubscription(): Observable; - unsubscribe(): Observable; -} - -export const BapiPushNotificationService = 'oryx.BapiPushNotificationService'; - -declare global { - interface InjectionTokensContractMap { - [BapiPushNotificationService]: BapiPushNotificationService; - } -} diff --git a/libs/domain/picking/offline/services/index.ts b/libs/domain/picking/offline/services/index.ts deleted file mode 100644 index 46be7b37e..000000000 --- a/libs/domain/picking/offline/services/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './adapter'; -export * from './bapi-push-notification-default.service'; -export * from './bapi-push-notification.service'; -export * from './picking-sync-action-handler.service'; diff --git a/libs/domain/picking/offline/services/picking-sync-action-handler.service.spec.ts b/libs/domain/picking/offline/services/picking-sync-action-handler.service.spec.ts deleted file mode 100644 index e380da175..000000000 --- a/libs/domain/picking/offline/services/picking-sync-action-handler.service.spec.ts +++ /dev/null @@ -1,259 +0,0 @@ -import { createInjector, destroyInjector } from '@spryker-oryx/di'; -import { IndexedDbService } from '@spryker-oryx/indexed-db'; -import { Sync, SyncStatus } from '@spryker-oryx/offline/sync'; -import { PickingListStatus } from '@spryker-oryx/picking/services'; -import { Table } from 'dexie'; -import { of } from 'rxjs'; -import { PickingListEntity } from '../entities'; -import { PickingListOnlineAdapter } from './adapter'; -import { - PickingSyncAction, - PickingSyncActionHandlerService, -} from './picking-sync-action-handler.service'; - -class MockIndexedDbService implements Partial { - getStore = vi - .fn() - .mockImplementation((entityType) => - of( - entityType === PickingListEntity - ? mockPickingListsTable - : mockProductsTable - ) - ); -} - -class MockPickingListOnlineAdapter - implements Partial -{ - get = vi - .fn() - .mockReturnValue(of([{ id: 'id1' }, { id: 'id2' }, { id: 'id3' }])); - finishPicking = vi.fn().mockReturnValue(of([])); -} - -const mockContent = { items: [] }; - -class MockTable implements Partial
{ - bulkPut = vi.fn().mockReturnValue([]); - update = vi.fn().mockReturnValue(mockContent); - bulkDelete = vi.fn(); - where = vi.fn().mockReturnValue({ - anyOf: vi.fn().mockReturnValue({ - count: vi.fn().mockResolvedValue(0), - }), - }); -} - -const mockPickingListsTable = new MockTable(); -const mockProductsTable = new MockTable(); - -const mockSync = { - action: PickingSyncAction.FinishPicking, - id: 123, - prevSyncIds: [], - status: SyncStatus.Processing, - payload: { - id: 'mock', - status: PickingListStatus.ReadyForPicking, - createdAt: new Date(), - updatedAt: new Date(), - items: [], - itemsCount: 0, - orderReferences: [], - productSkus: [], - requestedDeliveryDate: new Date(), - localStatus: PickingListStatus.ReadyForPicking, - }, - scheduledAt: new Date(), - retries: 0, - errors: [], - whenCompleted: vi.fn(), - cancel: vi.fn(), -}; - -describe('PickingSyncActionHandlerService', () => { - let service: PickingSyncActionHandlerService; - let indexeddb: MockIndexedDbService; - let adapter: MockPickingListOnlineAdapter; - - beforeEach(() => { - const testInjector = createInjector({ - providers: [ - { - provide: PickingSyncActionHandlerService, - useClass: PickingSyncActionHandlerService, - }, - { - provide: IndexedDbService, - useClass: MockIndexedDbService, - }, - { - provide: PickingListOnlineAdapter, - useClass: MockPickingListOnlineAdapter, - }, - ], - }); - - service = testInjector.inject(PickingSyncActionHandlerService); - indexeddb = testInjector.inject( - IndexedDbService - ) as unknown as MockIndexedDbService; - adapter = testInjector.inject( - PickingListOnlineAdapter - ) as unknown as MockPickingListOnlineAdapter; - }); - - afterEach(() => { - vi.clearAllMocks(); - destroyInjector(); - }); - - it('should be provided', () => { - expect(service).toBeInstanceOf(PickingSyncActionHandlerService); - }); - - const callback = vi.fn(); - - describe('when handleSync is called with an unknown action', () => { - const unknownSync = { - ...mockSync, - action: 'Unknown' as unknown as PickingSyncAction, - }; - - beforeEach(() => { - service.handleSync(unknownSync).subscribe({ error: callback }); - }); - - it('should throw error', () => { - expect(callback).toHaveBeenCalledWith( - new Error( - `PickingSyncActionHandlerService: Unable to handle unknown sync action '${unknownSync.action}'!` - ) - ); - }); - }); - - describe('when finishPicking action is handled', () => { - const callback = vi.fn(); - beforeEach(() => { - service.handleSync(mockSync).subscribe(callback); - }); - it('should call online adapter', () => { - expect(callback).toHaveBeenCalled(); - expect(adapter.finishPicking).toHaveBeenCalledWith(mockSync.payload); - expect(indexeddb.getStore).toHaveBeenCalledWith(PickingListEntity); - expect(mockPickingListsTable.update).toHaveBeenCalledWith( - mockSync.payload.id, - [] - ); - }); - - describe('and store is not updated', () => { - const callback = vi.fn(); - beforeEach(() => { - mockPickingListsTable.update.mockReturnValue(0); - - service.handleSync(mockSync).subscribe({ error: callback }); - }); - - it('should throw error', () => { - expect(callback).toHaveBeenCalledWith( - new Error( - `PickingSyncActionHandlerService: Could not update PickingList(${mockSync.payload.id}) after finishing picking!` - ) - ); - }); - }); - }); - - describe('when Push action is handled', () => { - const mockPickingLists = [ - { - id: 'id1', - items: [ - { - product: { - id: 'product-id-1', - }, - }, - { - product: { - id: 'product-id-2', - }, - }, - ], - }, - { - id: 'id2', - items: [ - { - product: { - id: 'product-id-2', - }, - }, - { - product: { - id: 'product-id-3', - }, - }, - ], - }, - ]; - - const pickingListsIdsToRemove = ['id3']; - const mockPickingListsIdsToCreate = mockPickingLists.map((pl) => pl.id); - - const mockSyncPush: Sync = { - ...mockSync, - action: PickingSyncAction.Push, - payload: { - action: 'create', - entity: 'picking-lists', - ids: [...mockPickingListsIdsToCreate, ...pickingListsIdsToRemove], - }, - }; - - const syncCallback = vi.fn(); - - beforeEach(() => { - adapter.get.mockReturnValue(of(mockPickingLists)); - mockPickingListsTable.bulkPut.mockReturnValue( - mockPickingListsIdsToCreate - ); - mockPickingListsTable.where = vi.fn().mockReturnValue({ - anyOf: vi.fn().mockReturnValue({ - count: vi.fn().mockResolvedValue(pickingListsIdsToRemove.length), - }), - }); - service.handleSync(mockSyncPush).subscribe(callback); - service.isSyncing().subscribe(syncCallback); - }); - - it('should call online adapter and update indexedDB', () => { - expect(callback).toHaveBeenCalled(); - expect(adapter.get).toHaveBeenCalledWith({ - ids: mockSyncPush.payload.ids, - }); - expect(indexeddb.getStore).toHaveBeenCalledWith(PickingListEntity); - expect(mockPickingListsTable.bulkDelete).toHaveBeenCalledWith( - pickingListsIdsToRemove - ); - expect(mockPickingListsTable.bulkPut).toHaveBeenCalledWith( - mockPickingLists, - { - allKeys: true, - } - ); - expect(mockProductsTable.bulkPut).toHaveBeenLastCalledWith([ - { id: 'product-id-1' }, - { id: 'product-id-2' }, - { id: 'product-id-3' }, - ]); - }); - it('should update syncing status', () => { - expect(syncCallback).toHaveBeenNthCalledWith(1, true); - expect(syncCallback).toHaveBeenLastCalledWith(false); - }); - }); -}); diff --git a/libs/domain/picking/offline/services/picking-sync-action-handler.service.ts b/libs/domain/picking/offline/services/picking-sync-action-handler.service.ts deleted file mode 100644 index 490b6e256..000000000 --- a/libs/domain/picking/offline/services/picking-sync-action-handler.service.ts +++ /dev/null @@ -1,130 +0,0 @@ -import { inject } from '@spryker-oryx/di'; -import { IndexedDbService } from '@spryker-oryx/indexed-db'; -import { Sync, SyncActionHandler } from '@spryker-oryx/offline/sync'; -import { - BehaviorSubject, - Observable, - combineLatestWith, - switchMap, - tap, - throwError, -} from 'rxjs'; -import { PickingListEntity, PickingProductEntity } from '../entities'; -import { PickingListOnlineAdapter } from './adapter'; - -declare global { - // eslint-disable-next-line @typescript-eslint/no-empty-interface - interface OryxSyncActions { - [PickingSyncAction.FinishPicking]: PickingListEntity; - [PickingSyncAction.Push]: PushSyncPayload; - } -} - -export enum PickingSyncAction { - FinishPicking = 'oryx.picking:finish-picking', - Push = 'oryx.picking:push', -} - -export interface PushSyncPayload { - action: 'create' | 'update'; - entity: string; - ids: string[]; -} - -export class PickingSyncActionHandlerService - implements SyncActionHandler -{ - constructor( - protected indexedDbService = inject(IndexedDbService), - protected onlineAdapter = inject(PickingListOnlineAdapter) - ) {} - - protected syncing$ = new BehaviorSubject(false); - - handleSync(sync: Sync): Observable { - switch (sync.action) { - case PickingSyncAction.FinishPicking: - return this.handleFinishPicking( - sync as Sync - ); - case PickingSyncAction.Push: - return this.handlePush(sync as Sync); - default: - return throwError( - () => - new Error( - `PickingSyncActionHandlerService: Unable to handle unknown sync action '${sync.action}'!` - ) - ); - } - } - - isSyncing(): Observable { - return this.syncing$; - } - - protected handleFinishPicking( - sync: Sync - ): Observable { - return this.onlineAdapter.finishPicking(sync.payload).pipe( - combineLatestWith(this.indexedDbService.getStore(PickingListEntity)), - switchMap(async ([updatedPickingList, store]) => { - const updatedObjects = await store.update( - sync.payload.id, - updatedPickingList - ); - - if (updatedObjects === 0) { - throw new Error( - `PickingSyncActionHandlerService: Could not update PickingList(${sync.payload.id}) after finishing picking!` - ); - } - }) - ); - } - - protected handlePush(sync: Sync): Observable { - if (sync.payload.entity !== 'picking-lists') { - return throwError( - () => - new Error( - `PickingSyncActionHandlerService: Unknown ${sync.payload.entity} entity` - ) - ); - } - - this.syncing$.next(true); - return this.onlineAdapter.get({ ids: sync.payload.ids }).pipe( - combineLatestWith( - this.indexedDbService.getStore(PickingListEntity), - this.indexedDbService.getStore(PickingProductEntity) - ), - switchMap(async ([pickingLists, pickingListsStore, productsStore]) => { - const pickingListsIdsToRemove = sync.payload.ids.filter((id) => { - return !pickingLists.find((pl) => pl.id === id); - }); - - await pickingListsStore.bulkDelete(pickingListsIdsToRemove); - - const productIds = new Set(); - const products = pickingLists - .map((pickingList) => pickingList.items.map((item) => item.product)) - .flat() - .filter((product) => { - if (productIds.has(product.id)) return false; - productIds.add(product.id); - return true; - }); - - await productsStore.bulkPut(products); - await pickingListsStore.bulkPut(pickingLists, { - allKeys: true, - }); - }), - tap({ - next: () => this.syncing$.next(false), - error: () => this.syncing$.next(false), - }) - ); - } -} diff --git a/libs/domain/picking/order-reference/index.ts b/libs/domain/picking/order-reference/index.ts deleted file mode 100644 index 5f0bde7e6..000000000 --- a/libs/domain/picking/order-reference/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './order-reference.component'; diff --git a/libs/domain/picking/order-reference/order-reference.component.spec.ts b/libs/domain/picking/order-reference/order-reference.component.spec.ts deleted file mode 100644 index 1ab3993d9..000000000 --- a/libs/domain/picking/order-reference/order-reference.component.spec.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { fixture } from '@open-wc/testing-helpers'; -import { createInjector } from '@spryker-oryx/di'; -import { mockPickingListData } from '@spryker-oryx/picking/mocks'; -import { PickingListService } from '@spryker-oryx/picking/services'; -import { useComponent } from '@spryker-oryx/utilities'; -import { html } from 'lit'; -import { of } from 'rxjs'; -import { PickingOrderReferenceComponent } from './order-reference.component'; -import { pickingOrderReferenceComponent } from './order-reference.def'; - -class MockPickingListService implements Partial { - getList = vi.fn().mockReturnValue(of(mockPickingListData[0])); - getUpcomingPickingListId = vi.fn().mockReturnValue(of(null)); -} - -describe('PickingOrderReferenceComponent', () => { - let element: PickingOrderReferenceComponent; - - beforeAll(async () => { - await useComponent(pickingOrderReferenceComponent); - }); - - beforeAll(async () => { - createInjector({ - providers: [ - { - provide: PickingListService, - useClass: MockPickingListService, - }, - ], - }); - - element = await fixture( - html`` - ); - }); - - afterEach(() => { - vi.clearAllMocks(); - }); - - it('passes the a11y audit', async () => { - await expect(element).shadowDom.to.be.accessible(); - }); - - it('should the reference', () => { - expect(element.renderRoot?.textContent).toContain( - mockPickingListData[0].orderReferences[0] - ); - }); -}); diff --git a/libs/domain/picking/order-reference/order-reference.component.ts b/libs/domain/picking/order-reference/order-reference.component.ts deleted file mode 100644 index c2e96894b..000000000 --- a/libs/domain/picking/order-reference/order-reference.component.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { PickingListMixin } from '@spryker-oryx/picking'; -import { I18nMixin, computed } from '@spryker-oryx/utilities'; -import { LitElement } from 'lit'; - -export class PickingOrderReferenceComponent extends I18nMixin( - PickingListMixin(LitElement) -) { - protected $ref = computed(() => this.$pickingList()?.orderReferences?.[0]); - - protected override render(): string | undefined { - return this.$ref(); - } -} diff --git a/libs/domain/picking/order-reference/order-reference.def.ts b/libs/domain/picking/order-reference/order-reference.def.ts deleted file mode 100644 index 18412014d..000000000 --- a/libs/domain/picking/order-reference/order-reference.def.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { componentDef } from '@spryker-oryx/utilities'; - -export const pickingOrderReferenceComponent = componentDef({ - name: 'oryx-picking-order-reference', - impl: () => - import('./order-reference.component').then( - (m) => m.PickingOrderReferenceComponent - ), -}); diff --git a/libs/domain/picking/order-reference/stories/demo.stories.ts b/libs/domain/picking/order-reference/stories/demo.stories.ts deleted file mode 100644 index 45e0f1503..000000000 --- a/libs/domain/picking/order-reference/stories/demo.stories.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { mockPickingListData } from '@spryker-oryx/picking/mocks'; -import { Meta, Story } from '@storybook/web-components'; -import { TemplateResult, html } from 'lit'; -import { storybookPrefix } from '../../.constants'; - -const pickingListIds = mockPickingListData.map(({ id }) => id); - -export default { - title: `${storybookPrefix}/Order Reference`, - parameters: { - chromatic: { - disableSnapshot: true, - }, - }, - args: { pickingListId: pickingListIds[0] }, - argTypes: { - pickingListId: { - options: pickingListIds, - control: { type: 'select' }, - }, - }, -} as Meta; - -const Template: Story<{ pickingListId: string }> = ({ - pickingListId, -}): TemplateResult => { - return html``; -}; - -export const Demo = Template.bind({}); diff --git a/libs/domain/picking/package.json b/libs/domain/picking/package.json deleted file mode 100644 index 00da01bb4..000000000 --- a/libs/domain/picking/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "@spryker-oryx/picking", - "version": "1.4.0", - "main": "./src/index.js", - "typings": "./src/index.d.ts", - "type": "module", - "author": "Spryker Sytems GmbH", - "license": "See license in LICENSE", - "description": "Picking features for Oryx applications", - "files": [ - "**/*" - ], - "dependencies": { - "@spryker-oryx/core": "1.4.0", - "@spryker-oryx/di": "1.4.0", - "@spryker-oryx/indexed-db": "1.4.0", - "@spryker-oryx/offline": "1.4.0", - "@spryker-oryx/router": "1.4.0", - "@spryker-oryx/ui": "1.4.0", - "@spryker-oryx/utilities": "1.4.0", - "jsonapi-serializer": "~3.6.7" - }, - "peerDependencies": { - "dexie": "^3.2.2", - "lit": "^2.4.0", - "rxjs": "^7.5.0", - "tslib": "^2.4.0" - }, - "publishConfig": { - "access": "public" - } -} diff --git a/libs/domain/picking/picker/index.ts b/libs/domain/picking/picker/index.ts deleted file mode 100644 index b245d0b19..000000000 --- a/libs/domain/picking/picker/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './picker.component'; -export * from './picker.styles'; diff --git a/libs/domain/picking/picker/picker.component.spec.ts b/libs/domain/picking/picker/picker.component.spec.ts deleted file mode 100644 index 042ce4118..000000000 --- a/libs/domain/picking/picker/picker.component.spec.ts +++ /dev/null @@ -1,272 +0,0 @@ -import { fixture } from '@open-wc/testing-helpers'; -import { createInjector, destroyInjector } from '@spryker-oryx/di'; -import { PickingGuardService } from '@spryker-oryx/picking'; -import { mockPickingListData } from '@spryker-oryx/picking/mocks'; -import { PickingListService } from '@spryker-oryx/picking/services'; -import { RouterService } from '@spryker-oryx/router'; -import { tabsComponent } from '@spryker-oryx/ui'; -import { TabComponent } from '@spryker-oryx/ui/tab'; -import { i18n, useComponent } from '@spryker-oryx/utilities'; -import { html } from 'lit'; -import { of } from 'rxjs'; -import { beforeEach } from 'vitest'; -import { PickingPickerComponent } from './picker.component'; -import { pickingPickerComponent } from './picker.def'; - -class MockPickingListService implements Partial { - getList = vi.fn().mockReturnValue(of(mockPickingListData[0])); - finishPicking = vi.fn().mockReturnValue(of(mockPickingListData[0])); - getUpcomingPickingListId = vi.fn().mockReturnValue(of(null)); -} - -class MockPickingGuardService implements Partial { - allow = vi.fn(); -} - -class MockRouterService implements Partial { - navigate = vi.fn(); -} - -Element.prototype.scrollIntoView = vi.fn(); - -describe('PickingPickerComponent', () => { - let element: PickingPickerComponent; - let service: MockPickingListService; - let routerService: MockRouterService; - let guardService: MockPickingGuardService; - - const getTabs = () => - element.renderRoot.querySelectorAll('oryx-tab'); - - const onTabs = ( - tabs: NodeListOf | TabComponent[], - cb: (content: HTMLElement | null) => void - ) => { - tabs.forEach((tab) => { - const tabContent = element.renderRoot.querySelector( - `#${tab.getAttribute('for')}` - ); - cb(tabContent); - }); - }; - - beforeAll(async () => { - await useComponent([pickingPickerComponent, tabsComponent]); - }); - - beforeEach(async () => { - const testInjector = createInjector({ - providers: [ - { - provide: PickingListService, - useClass: MockPickingListService, - }, - { - provide: RouterService, - useClass: MockRouterService, - }, - { - provide: PickingGuardService, - useClass: MockPickingGuardService, - }, - ], - }); - - service = testInjector.inject(PickingListService); - routerService = testInjector.inject(RouterService); - guardService = - testInjector.inject(PickingGuardService); - - element = await fixture( - html`` - ); - }); - - afterEach(() => { - vi.clearAllMocks(); - destroyInjector(); - }); - - it('passes the a11y audit', async () => { - await expect(element).shadowDom.to.be.accessible(); - }); - - it('should render tabs', () => { - expect(element.renderRoot.querySelector('oryx-tabs')).not.toBeNull(); - expect(element.renderRoot.querySelectorAll('oryx-tab').length).toBe(3); - }); - - it('should render tab contents', () => { - expect(element.renderRoot.querySelectorAll('[slot="panels"]').length).toBe( - 3 - ); - - expect(element).toContainElement( - '#tab-not_picked[slot="panels"] oryx-picking-product-card' - ); - }); - - describe('when tab is selected', () => { - it('should update chip appearance', () => { - const tab = element.renderRoot.querySelectorAll( - 'oryx-tab' - )[1] as TabComponent; - tab.click(); - expect(tab).toContainElement('oryx-chip[appearance="success"]'); - }); - }); - - describe('when there is no picking lists', () => { - beforeEach(async () => { - service.getList = vi.fn().mockReturnValue(of(null)); - - element = await fixture( - html`` - ); - }); - - it('should not render product card', () => { - onTabs(getTabs(), (tabContent) => - expect(tabContent).not.toContainElement('oryx-picking-product-card') - ); - }); - - it('should show fallback text', () => { - onTabs(getTabs(), (tabContent) => - expect(tabContent?.querySelector('section h2')?.textContent).toContain( - i18n('picking.no-items') - ) - ); - }); - - it('should show fallback image', () => { - onTabs(getTabs(), (tabContent) => - expect(tabContent).toContainElement('oryx-image[resource="no-orders"]') - ); - }); - }); - - describe('when all items are already picked', () => { - beforeEach(async () => { - service.getList = vi.fn().mockReturnValue(of(mockPickingListData[1])); - service.finishPicking = vi - .fn() - .mockReturnValue(of(mockPickingListData[1])); - - element = await fixture( - html`` - ); - }); - - it('should render finish button', () => { - onTabs(getTabs(), (tabContent) => - expect( - tabContent?.querySelector('.submit-wrapper oryx-button') - ).toHaveProperty('text', i18n('picking.finish-picking')) - ); - }); - - it('should render success message on "Not Picked" and "NotFound" tabs', () => { - onTabs([getTabs()[0], getTabs()[2]], (tabContent) => { - expect(tabContent?.querySelector('section h1')?.textContent).toContain( - i18n('picking.success') - ); - - expect( - tabContent?.querySelector('section span')?.textContent - ).toContain(i18n('picking.processed.all')); - }); - }); - - it('should render success image on "Not Picked" and "NotFound" tabs', () => { - onTabs([getTabs()[0], getTabs()[2]], (tabContent) => - expect(tabContent).toContainElement( - 'oryx-image[resource="picking-items-processed"]' - ) - ); - }); - - it('should render list of picked products on "Picked" tab', () => { - onTabs([getTabs()[1]], (tabContent) => { - expect(tabContent).toContainElement('oryx-picking-product-card'); - }); - }); - - it('should perform redirect after click', () => { - element.renderRoot - .querySelector('.submit-wrapper oryx-button') - ?.click(); - - expect(service.finishPicking).toHaveBeenCalled(); - expect(routerService.navigate).toHaveBeenCalledWith(`/`); - }); - }); - - describe('when picked all items but some of them are not found', () => { - beforeEach(async () => { - const partiallyPickedPickingList = { - ...mockPickingListData[1], - items: [ - { - ...mockPickingListData[1].items[0], - numberOfPicked: mockPickingListData[1].items[0].quantity - 1, - numberOfNotPicked: 1, - }, - ], - }; - - service.getList = vi.fn().mockReturnValue(of(partiallyPickedPickingList)); - service.finishPicking = vi - .fn() - .mockReturnValue(of(partiallyPickedPickingList)); - - element = await fixture( - html`` - ); - }); - - it('should render finish button', () => { - onTabs(getTabs(), (tabContent) => - expect( - tabContent?.querySelector('.submit-wrapper oryx-button') - ).toHaveProperty('text', i18n('picking.finish-picking')) - ); - }); - - it('should render success message on "Not Picked" tab', () => { - onTabs([getTabs()[0]], (tabContent) => { - expect(tabContent?.querySelector('section h1')?.textContent).toContain( - i18n('picking.processed.success') - ); - - expect( - tabContent?.querySelector('section span')?.textContent - ).toContain(i18n('picking.processed.all')); - }); - }); - - it('should render success image on "Not Picked" tab', () => { - onTabs([getTabs()[0]], (tabContent) => - expect(tabContent).toContainElement( - 'oryx-image[resource="picking-items-processed"]' - ) - ); - }); - - it('should render list of picked products on "Picked" and "NotFound" tabs', () => { - onTabs([getTabs()[1], getTabs()[2]], (tabContent) => - expect(tabContent).toContainElement('oryx-picking-product-card') - ); - }); - - it('should perform redirect after click', () => { - element.renderRoot - .querySelector('.submit-wrapper oryx-button') - ?.click(); - - expect(service.finishPicking).toHaveBeenCalled(); - expect(routerService.navigate).toHaveBeenCalledWith(`/`); - expect(guardService.allow).toHaveBeenCalled(); - }); - }); -}); diff --git a/libs/domain/picking/picker/picker.component.ts b/libs/domain/picking/picker/picker.component.ts deleted file mode 100644 index 52fc353a4..000000000 --- a/libs/domain/picking/picker/picker.component.ts +++ /dev/null @@ -1,404 +0,0 @@ -import { resolve } from '@spryker-oryx/di'; -import { - PartialPicking, - PickingGuardService, - PickingListMixin, - PickingTab, - ProductItemPickedEvent, -} from '@spryker-oryx/picking'; -import { PickingProductCardComponent } from '@spryker-oryx/picking/product-card'; -import { - ItemsFilters, - PickingListItem, - PickingListStatus, -} from '@spryker-oryx/picking/services'; -import { RouterService } from '@spryker-oryx/router'; -import { ButtonColor, ButtonType } from '@spryker-oryx/ui/button'; -import { ChipComponent } from '@spryker-oryx/ui/chip'; -import { HeadingTag } from '@spryker-oryx/ui/heading'; -import { TabComponent } from '@spryker-oryx/ui/tab'; -import { TabsAppearance } from '@spryker-oryx/ui/tabs'; -import { I18nMixin, computed, featureVersion } from '@spryker-oryx/utilities'; -import { LitElement, TemplateResult, html } from 'lit'; -import { state } from 'lit/decorators.js'; -import { classMap } from 'lit/directives/class-map.js'; -import { Ref, createRef, ref } from 'lit/directives/ref.js'; -import { repeat } from 'lit/directives/repeat.js'; -import { when } from 'lit/directives/when.js'; -import { catchError, of, take, tap } from 'rxjs'; -import { pickingComponentStyles } from './picker.styles'; - -export class PickingPickerComponent extends I18nMixin( - PickingListMixin(LitElement) -) { - static styles = pickingComponentStyles; - - protected routerService = resolve(RouterService); - protected pickingGuardService = resolve(PickingGuardService); - - @state() - protected partialPicking: PartialPicking | null = null; - - @state() - protected items: PickingListItem[] = []; - - protected $items = computed(() => this.$pickingList()?.items); - - protected productCardRef: Ref = createRef(); - protected notPickedTabRef: Ref = createRef(); - protected tabRefs: Ref[] = [ - this.notPickedTabRef, - createRef(), - createRef(), - ]; - - protected chipRefs: Ref[] = [ - createRef(), - createRef(), - createRef(), - ]; - - protected buildTabs(): PickingTab[] { - this.items = this.$items(); - - return [ - { - id: ItemsFilters.NotPicked, - title: 'not-Picked', - items: this.items?.filter( - (item) => item.status === ItemsFilters.NotPicked - ), - }, - { - id: ItemsFilters.Picked, - title: 'picked', - items: this.items?.filter( - (item) => item.numberOfPicked && item.status === ItemsFilters.Picked - ), - }, - { - id: ItemsFilters.NotFound, - title: 'not-Found', - items: this.items?.filter( - (item) => - item.status === ItemsFilters.Picked && - (item.numberOfNotPicked || item.numberOfPicked < item.quantity) - ), - }, - ]; - } - - protected savePickingItem(event: CustomEvent): void { - const { productId, numberOfPicked } = event.detail; - - const productIndex = this.$pickingList()?.items.findIndex( - (item) => item.id === productId - ); - - if ( - !(numberOfPicked && numberOfPicked === this.items[productIndex].quantity) - ) { - this.partialPicking = { - productId: productId, - currentNumberOfPicked: numberOfPicked, - quantity: this.items[productIndex].quantity, - }; - - return; - } - - this.updatePickingItem(productIndex, numberOfPicked); - } - - protected async editPickingItem( - event: CustomEvent - ): Promise { - const { productId } = event.detail; - - const productIndex = this.$pickingList()?.items.findIndex( - (item) => item.id === productId - ); - this.items[productIndex].status = ItemsFilters.NotPicked; - - this.items = [...this.items]; - - this.notPickedTabRef.value?.dispatchEvent( - new CustomEvent('click', { - composed: true, - bubbles: true, - }) - ); - - await this.updateComplete; - - this.productCardRef.value?.scrollIntoView({ - behavior: 'smooth', - }); - - this.productCardRef.value?.focusOnQuantityInput(); - } - - protected onModalClose(): void { - this.partialPicking = null; - } - - protected confirmPartialPicking(): void { - const productIndex = this.$pickingList()?.items.findIndex( - (item) => item.id === this.partialPicking?.productId - ); - - this.updatePickingItem( - productIndex, - this.partialPicking?.currentNumberOfPicked - ); - - this.partialPicking = null; - } - - protected finishPicking(): void { - this.$pickingList().status = PickingListStatus.PickingFinished; - - // ToDo: update this logic after Bapi is fully integrated in fulfillment app - this.pickingListService - .finishPicking(this.$pickingList()) - .pipe( - take(1), - catchError(() => of(null)), - tap(() => { - this.pickingGuardService.allow(); - this.routerService.navigate(`/`); - }) - ) - .subscribe(); - } - - protected override render(): TemplateResult { - const tabs = this.buildTabs(); - - return html` - - ${this.renderTabs(tabs)} ${this.renderTabContents(tabs)} - - ${this.renderConfirmationModal()} - `; - } - - protected renderTabs(tabs: PickingTab[]): TemplateResult { - return html` - ${repeat( - tabs, - (tab, index) => html` - - ${this.i18n(`picking.${tab.title}`)} - ${tab.items?.length ?? '0'} - - ` - )} - `; - } - - protected renderTabContents(tabs: PickingTab[]): TemplateResult { - return html` - ${repeat( - tabs, - (tab) => html` -
- ${when( - tab.items?.length, - () => html` -
- ${repeat( - tab.items, - (item) => item.id, - (item) => - html` - - ` - )} -
- ${this.renderFinishButton(true)} - `, - () => this.renderFallback() - )} -
- ` - )} - `; - } - - protected renderFinishPickingFallback(): TemplateResult { - return html` -
- - ${this.__renderFinishPickingHeading()} - ${this.i18n(`picking.processed.all`)} -
- ${this.renderFinishButton()} - `; - } - - // temporary implementation for backwards compatibility - private __renderFinishPickingHeading(): TemplateResult { - const text = this.i18n('picking.processed.success'); - if (featureVersion >= '1.4') { - return html` ${text} `; - } else { - return html` -

${text}

-
`; - } - } - - protected renderNoItemsFallback(): TemplateResult { - return html` -
- ${this.__renderNoItemsHeading()} - -
- `; - } - - // temporary implementation for backwards compatibility - private __renderNoItemsHeading(): TemplateResult { - const text = this.i18n('picking.no-items'); - if (featureVersion >= '1.4') { - return html` ${text} `; - } else { - return html` -

${text}

-
`; - } - } - - protected renderFallback(): TemplateResult { - if (!this.items?.length || !this.allItemsPicked) { - return this.renderNoItemsFallback(); - } else { - return this.renderFinishPickingFallback(); - } - } - - protected get allItemsPicked(): boolean { - return this.items?.every((item) => item.status === ItemsFilters.Picked); - } - - protected renderFinishButton(hasShadow?: boolean): TemplateResult | void { - if (!this.allItemsPicked) { - return; - } - - return html` -
-
- -
-
- `; - } - - protected renderConfirmationModal(): TemplateResult { - return html` - -
- ${this.i18n('picking.product-card.confirm-picking')} -
- - - ${this.i18n('picking.product-card.you-only-picked')} - - ${this.partialPicking?.currentNumberOfPicked} - ${this.i18n('picking.product-card.-out-of')} - ${this.partialPicking?.quantity} - - ${this.i18n('picking.product-card.items')}. - ${this.i18n( - 'picking.product-card.do-you-really-want-to-complete-the-pick?' - )} - - - - - -
- `; - } - - protected override updated(): void { - this.onTabChange(); - } - - protected async getUpdateComplete(): Promise { - await super.getUpdateComplete(); - return (await this.notPickedTabRef.value?.updateComplete) ?? false; - } - - protected onTabChange(): void { - for (let i = 0; i < this.tabRefs.length; i++) { - const tab = this.tabRefs[i].value; - if (!tab) { - continue; - } - const chip = this.chipRefs[i].value; - if (tab.selected) { - chip?.setAttribute('appearance', 'success'); - } else { - chip?.removeAttribute('appearance'); - } - } - } - - private updatePickingItem( - productIndex: number, - numberOfPicked?: number - ): void { - this.items[productIndex].numberOfPicked = numberOfPicked ?? 0; - this.items[productIndex].numberOfNotPicked = - this.items[productIndex].quantity - - this.items[productIndex].numberOfPicked; - - this.items[productIndex].status = ItemsFilters.Picked; - - this.items = [...this.items]; - } -} diff --git a/libs/domain/picking/picker/picker.def.ts b/libs/domain/picking/picker/picker.def.ts deleted file mode 100644 index 423e2dac1..000000000 --- a/libs/domain/picking/picker/picker.def.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { componentDef } from '@spryker-oryx/utilities'; - -export const pickingPickerComponent = componentDef({ - name: 'oryx-picking-picker', - impl: () => - import('./picker.component').then((m) => m.PickingPickerComponent), -}); diff --git a/libs/domain/picking/picker/picker.styles.ts b/libs/domain/picking/picker/picker.styles.ts deleted file mode 100644 index c0ac3bf9a..000000000 --- a/libs/domain/picking/picker/picker.styles.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { css } from 'lit'; - -export const pickingComponentStyles = css` - :host { - /* TODO: use pages with layout */ - display: block; - width: min( - 100%, - min( - var(--oryx-container-width), - calc(100vw - (2 * var(--oryx-container-bleed, 0px))) - ) - ); - } - - [slot='panels'] { - width: 100%; - } - - .list-container { - min-height: calc(100vh - 166px); - padding: 25px 0; - display: grid; - gap: 20px 0; - grid-auto-rows: max-content; - background-color: var(--oryx-color-neutral-3); - } - - section { - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - height: calc(100vh - 166px); - background-color: var(--oryx-color-neutral-3); - } - - section oryx-heading h1 { - margin: 30px 0 8px; - } - - section oryx-heading h2 { - margin-block-end: 10px; - } - - oryx-image { - display: flex; - } - - .picked-items-info { - font-weight: 600; - } - - .submit-wrapper { - position: sticky; - inset-block-end: 0; - padding: 20px; - background-color: var(--oryx-color-neutral-3); - animation: slide-up 0.5s ease-in-out; - } - - .submit-wrapper oryx-button { - display: flex; - } - - .scroll-shadow { - box-shadow: 0 -1px 6px var(--oryx-color-neutral-4); - } - - @keyframes slide-up { - from { - transform: translateY(50px); - } - - to { - transform: translateY(0); - } - } - - oryx-modal [slot='heading'] { - font-size: 18px; - font-weight: 600; - } -`; diff --git a/libs/domain/picking/picking-in-progress/index.ts b/libs/domain/picking/picking-in-progress/index.ts deleted file mode 100644 index 44e589a77..000000000 --- a/libs/domain/picking/picking-in-progress/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './picking-in-progress.component'; diff --git a/libs/domain/picking/picking-in-progress/picking-in-progress.component.spec.ts b/libs/domain/picking/picking-in-progress/picking-in-progress.component.spec.ts deleted file mode 100644 index 116a569b3..000000000 --- a/libs/domain/picking/picking-in-progress/picking-in-progress.component.spec.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { fixture } from '@open-wc/testing-helpers'; -import { useComponent } from '@spryker-oryx/utilities'; -import { html } from 'lit'; -import { PickingInProgressModalComponent } from './picking-in-progress.component'; -import { pickingInProgressModalComponent } from './picking-in-progress.def'; - -describe('PickingInProgressModalComponent', () => { - let element: PickingInProgressModalComponent; - - beforeAll(async () => { - await useComponent(pickingInProgressModalComponent); - }); - - beforeEach(async () => { - element = await fixture( - html`` - ); - }); - - afterEach(() => { - vi.clearAllMocks(); - }); - - it('passes the a11y audit', async () => { - await expect(element).shadowDom.to.be.accessible(); - }); - - it('should render modal', () => { - expect(element.renderRoot.querySelector('oryx-modal')).not.toBeNull(); - }); - - describe('when modal is opened', () => { - beforeEach(() => { - element.open = true; - }); - - it('modal should have opened attribute', () => { - expect( - element.renderRoot.querySelector('oryx-modal')?.hasAttribute('open') - ).toBe(true); - }); - - describe('and when modal is closed', () => { - beforeEach(() => { - element.dispatchEvent(new CustomEvent('oryx.close')); - }); - - it('should close modal when it emits oryx.close event', () => { - element.addEventListener('oryx.close', () => { - expect( - element.renderRoot.querySelector('oryx-modal')?.hasAttribute('open') - ).toBe(false); - }); - }); - - it('should close modal when close button is clicked', async () => { - element.renderRoot?.querySelector('oryx-button')?.click(); - await element.updateComplete; - - expect( - element.renderRoot.querySelector('oryx-modal')?.hasAttribute('open') - ).toBe(false); - }); - }); - }); -}); diff --git a/libs/domain/picking/picking-in-progress/picking-in-progress.component.ts b/libs/domain/picking/picking-in-progress/picking-in-progress.component.ts deleted file mode 100644 index 0a01d9e05..000000000 --- a/libs/domain/picking/picking-in-progress/picking-in-progress.component.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { ButtonColor, ButtonSize } from '@spryker-oryx/ui/button'; -import { BACK_EVENT } from '@spryker-oryx/ui/modal'; -import { I18nMixin } from '@spryker-oryx/utilities'; -import { LitElement, TemplateResult, html } from 'lit'; -import { property } from 'lit/decorators.js'; - -export class PickingInProgressModalComponent extends I18nMixin(LitElement) { - @property({ type: Boolean }) open?: boolean; - - protected override render(): TemplateResult { - return html` - - ${this.i18n('picking.list.picking-in-progress')} - - ${this.i18n('picking.list.already-in-progress')} - - `; - } - - protected close(): void { - this.open = false; - } - - protected closeButton(): void { - this.dispatchEvent( - new CustomEvent(BACK_EVENT, { bubbles: true, composed: true }) - ); - this.close(); - } -} diff --git a/libs/domain/picking/picking-in-progress/picking-in-progress.def.ts b/libs/domain/picking/picking-in-progress/picking-in-progress.def.ts deleted file mode 100644 index f2945e7c7..000000000 --- a/libs/domain/picking/picking-in-progress/picking-in-progress.def.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { componentDef } from '@spryker-oryx/utilities'; - -export const pickingInProgressModalComponent = componentDef({ - name: 'oryx-picking-in-progress-modal', - impl: () => - import('./picking-in-progress.component').then( - (m) => m.PickingInProgressModalComponent - ), -}); diff --git a/libs/domain/picking/picking-in-progress/stories/demo.stories.ts b/libs/domain/picking/picking-in-progress/stories/demo.stories.ts deleted file mode 100644 index 7a8319934..000000000 --- a/libs/domain/picking/picking-in-progress/stories/demo.stories.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Meta, Story } from '@storybook/web-components'; -import { TemplateResult, html } from 'lit'; -import { storybookPrefix } from '../../.constants'; - -export default { - title: `${storybookPrefix}/Picking in progress modal`, - parameters: { - chromatic: { - disableSnapshot: true, - }, - }, -} as Meta; - -const Template: Story = (): TemplateResult => { - return html` `; -}; - -export const Demo = Template.bind({}); diff --git a/libs/domain/picking/product-card/index.ts b/libs/domain/picking/product-card/index.ts deleted file mode 100644 index 01d504085..000000000 --- a/libs/domain/picking/product-card/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './product-card.component'; -export * from './product-card.styles'; diff --git a/libs/domain/picking/product-card/product-card.component.spec.ts b/libs/domain/picking/product-card/product-card.component.spec.ts deleted file mode 100644 index 695184339..000000000 --- a/libs/domain/picking/product-card/product-card.component.spec.ts +++ /dev/null @@ -1,223 +0,0 @@ -import { fixture } from '@open-wc/testing-helpers'; -import { mockPickingListData } from '@spryker-oryx/picking/mocks'; -import { ItemsFilters, PickingListItem } from '@spryker-oryx/picking/services'; -import { ImageComponent } from '@spryker-oryx/ui/image'; -import { QuantityInputComponent } from '@spryker-oryx/ui/quantity-input'; -import { useComponent } from '@spryker-oryx/utilities'; -import { html } from 'lit'; -import { PickingProductCardComponent } from './product-card.component'; -import { pickingProductCardComponent } from './product-card.def'; - -describe('PickingProductCardComponent', () => { - let element: PickingProductCardComponent; - const productItem: PickingListItem = mockPickingListData[0].items[0]; - - beforeAll(async () => { - await useComponent(pickingProductCardComponent); - }); - - afterEach(() => { - vi.clearAllMocks(); - }); - - describe('when a product provided with status NotPicked', () => { - beforeEach(async () => { - element = await fixture( - html` - - ` - ); - }); - - it('passes the a11y audit', async () => { - await expect(element).shadowDom.to.be.accessible(); - }); - - it('should render name and sku', () => { - expect( - element.renderRoot.querySelector("[slot='heading']")?.textContent - ).toContain(productItem.orderItem.name); - - expect(element.renderRoot.querySelector('h6')?.textContent).toContain( - productItem.orderItem.sku - ); - }); - - it('should not render oryx-image with the image-fade class', () => { - expect(element).not.toContainElement('oryx-image.image-fade'); - - expect( - (element.shadowRoot?.querySelector('oryx-image') as ImageComponent).src - ).toBe(productItem.product.image); - }); - - it('should render quantity input', () => { - expect( - ( - element.shadowRoot?.querySelector( - 'oryx-quantity-input' - ) as QuantityInputComponent - ).max - ).toBe(productItem.quantity); - - expect( - ( - element.shadowRoot?.querySelector( - 'oryx-quantity-input' - ) as QuantityInputComponent - ).value - ).toBe(productItem.numberOfPicked); - }); - - describe('when the quantity is enabled', () => { - it('should enable the button', () => { - expect(element).not.toContainElement('oryx-button button[disabled]'); - }); - - describe('and when an update is dispatched with an invalid quantity', () => { - beforeEach(() => { - const input = element.shadowRoot?.querySelector( - 'oryx-quantity-input' - ); - input?.dispatchEvent( - new CustomEvent('update', { - detail: { quantity: 30 }, - }) - ); - }); - - it('should disable the button', () => { - expect(element).toContainElement('oryx-button[disabled]'); - }); - }); - }); - - describe('when user submit a quantity', () => { - const spy = vi.fn(); - - beforeEach(async () => { - element = await fixture( - html` - - ` - ); - element.shadowRoot - ?.querySelector('oryx-button button') - ?.click(); - }); - - it('should dispatch submit event', () => { - expect(spy).toHaveBeenCalled(); - }); - }); - - describe('when user wants to edit a product', () => { - const spy = vi.fn(); - - beforeEach(async () => { - const element = await fixture( - html` - - ` - ); - - element.shadowRoot?.querySelector('oryx-button')?.click(); - }); - - it('should dispatch edit event', () => { - expect(spy).toHaveBeenCalled(); - }); - }); - - describe('when a product is not provided', () => { - beforeEach(async () => { - element = await fixture( - html` - - ` - ); - }); - - it('should not render form quantity input', () => { - expect(element).not.toContainElement('oryx-quantity-input'); - }); - }); - }); - - describe('when a product provided with status Picked', () => { - beforeEach(async () => { - element = await fixture( - html` - - ` - ); - }); - - it('should not render quantity input', () => { - expect(element).not.toContainElement('oryx-quantity-input'); - }); - - it('should render summary info', () => { - expect(element.shadowRoot?.querySelector('.summary-info')).to.exist; - }); - - it('should render edit button', () => { - expect(element.renderRoot.querySelector('oryx-button')).toHaveProperty( - 'text', - 'Edit items' - ); - }); - }); - - describe('when a product provided with status Not Found', () => { - beforeEach(async () => { - element = await fixture( - html` - - ` - ); - }); - - it('should render oryx-image with the image-fade class', () => { - expect(element).toContainElement('oryx-image.image-fade'); - - expect( - (element.shadowRoot?.querySelector('oryx-image') as ImageComponent).src - ).toBe(productItem.product.image); - }); - - it('should not render quantity input', () => { - expect(element).not.toContainElement('oryx-quantity-input'); - }); - - it('should render summary info', () => { - expect(element).toContainElement('.summary-info'); - }); - - it('should render edit button', () => { - expect(element.renderRoot.querySelector('oryx-button')).toHaveProperty( - 'text', - 'Edit items' - ); - }); - }); -}); diff --git a/libs/domain/picking/product-card/product-card.component.ts b/libs/domain/picking/product-card/product-card.component.ts deleted file mode 100644 index c59b5b962..000000000 --- a/libs/domain/picking/product-card/product-card.component.ts +++ /dev/null @@ -1,192 +0,0 @@ -import { - EVENT_EDIT, - EVENT_SUBMIT, - ProductItemPickedEvent, -} from '@spryker-oryx/picking'; -import { ItemsFilters, PickingListItem } from '@spryker-oryx/picking/services'; -import { ButtonSize } from '@spryker-oryx/ui/button'; -import { HeadingTag } from '@spryker-oryx/ui/heading'; -import { IconTypes } from '@spryker-oryx/ui/icon'; -import { QuantityInputComponent } from '@spryker-oryx/ui/quantity-input'; -import { I18nMixin, featureVersion } from '@spryker-oryx/utilities'; -import { LitElement, TemplateResult, html } from 'lit'; -import { property, state } from 'lit/decorators.js'; -import { classMap } from 'lit/directives/class-map.js'; -import { ifDefined } from 'lit/directives/if-defined.js'; -import { Ref, createRef, ref } from 'lit/directives/ref.js'; -import { when } from 'lit/directives/when.js'; -import { pickingProductCardComponentStyles } from './product-card.styles'; - -export class PickingProductCardComponent extends I18nMixin(LitElement) { - static styles = pickingProductCardComponentStyles; - - @property() productItem?: PickingListItem; - @property() status?: string; - - @state() isCorrectNumberOfPickedProvided = true; - @state() currentNumberOfPicked?: number; - - protected quantityInputRef: Ref = createRef(); - - protected onSubmit(e: SubmitEvent): void { - e.preventDefault(); - - this.currentNumberOfPicked = - this.currentNumberOfPicked ?? this.productItem?.numberOfPicked; - - this.dispatchPickingEvents(EVENT_SUBMIT, { - productId: this.productItem!.id, - numberOfPicked: this.currentNumberOfPicked, - }); - } - - protected editProductPicking(): void { - this.dispatchPickingEvents(EVENT_EDIT, { - productId: this.productItem!.id, - } as ProductItemPickedEvent); - } - - protected onChangeQuantity({ detail: { quantity } }: CustomEvent): void { - this.currentNumberOfPicked = quantity; - - if (this.productItem && this.currentNumberOfPicked) { - this.isCorrectNumberOfPickedProvided = - 0 <= this.currentNumberOfPicked && - this.currentNumberOfPicked <= this.productItem.quantity; - } - } - - protected dispatchPickingEvents( - event: string, - productItem?: ProductItemPickedEvent - ): void { - this.dispatchEvent( - new CustomEvent(event, { - bubbles: true, - composed: true, - detail: productItem, - }) - ); - } - - public focusOnQuantityInput(): void { - setTimeout(() => { - this.quantityInputRef.value?.focus(); - }, 0); - } - - protected override render(): TemplateResult { - return html`${this.renderPickingProduct()}`; - } - - protected renderPickingProduct(): TemplateResult { - if (!this.productItem) { - return html``; - } - - const quantityForm = html` -
- - -
- ${this.i18n('picking.product-card.of--items', { - count: this.productItem.quantity, - })} -
- - - - - - `; - - return html` - - - ${this.productItem.orderItem.name} - - ${this.__renderHeading()} - - - - ${when( - this.status === ItemsFilters.NotPicked, - () => quantityForm, - () => this.renderEditStatus() - )} - - `; - } - - // temporary implementation for backwards compatibility - private __renderHeading(): TemplateResult { - const text = this.productItem?.orderItem.sku; - if (featureVersion >= '1.4') { - return html` ${text} `; - } else { - return html` -
${text}
-
`; - } - } - - protected renderEditStatus(): TemplateResult { - if (!this.productItem) { - return html``; - } - - let count: number; - let label = ''; - let subtext = ''; - - const { quantity, numberOfPicked, numberOfNotPicked } = this.productItem; - - if (this.status === ItemsFilters.Picked) { - count = numberOfPicked; - - if (numberOfPicked < quantity) { - label = 'picking.product-card.items-picked'; - } else { - subtext = 'picking.product-card.all-items-picked'; - } - } else { - count = numberOfNotPicked; - - if (numberOfNotPicked < quantity) { - label = 'picking.product-card.items-not-found'; - } else { - subtext = 'picking.product-card.no-items-found'; - } - } - - return html` -
-

${count}/${quantity} ${this.i18n(label)}

- ${when(subtext, () => html`

${this.i18n(subtext)}

`)} -
- - `; - } -} diff --git a/libs/domain/picking/product-card/product-card.def.ts b/libs/domain/picking/product-card/product-card.def.ts deleted file mode 100644 index 86c88d277..000000000 --- a/libs/domain/picking/product-card/product-card.def.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { componentDef } from '@spryker-oryx/utilities'; - -export const pickingProductCardComponent = componentDef({ - name: 'oryx-picking-product-card', - impl: () => - import('./product-card.component').then( - (m) => m.PickingProductCardComponent - ), - schema: () => - import('./product-card.schema').then( - (m) => m.pickingProductCardComponentSchema - ), -}); diff --git a/libs/domain/picking/product-card/product-card.schema.ts b/libs/domain/picking/product-card/product-card.schema.ts deleted file mode 100644 index b685cc200..000000000 --- a/libs/domain/picking/product-card/product-card.schema.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ContentComponentSchema } from '@spryker-oryx/experience'; -import { PickingProductCardComponent } from './product-card.component'; - -export const pickingProductCardComponentSchema: ContentComponentSchema = - { - name: 'Product Card', - group: 'Picking', - }; diff --git a/libs/domain/picking/product-card/product-card.styles.ts b/libs/domain/picking/product-card/product-card.styles.ts deleted file mode 100644 index af4f58fdd..000000000 --- a/libs/domain/picking/product-card/product-card.styles.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { css } from 'lit'; - -export const pickingProductCardComponentStyles = css` - :host { - text-align: center; - margin: 0 20px; - } - - [slot='heading'] { - width: 100%; - text-align: center; - overflow: hidden; - /* stylelint-disable-next-line */ - display: -webkit-box; - -webkit-line-clamp: 2; - -webkit-box-orient: vertical; - } - - form { - margin-block-start: 7px; - } - - form div { - margin-block-start: 14px; - margin-block-end: 9px; - font-weight: 600; - font-size: 12px; - line-height: 16px; - letter-spacing: 0.01em; - color: var(--oryx-color-neutral-12); - } - - oryx-image { - display: block; - fill: var(--oryx-color-neutral-12); - height: 106px; - margin-block-start: 5px; - object-fit: cover; - } - - .image-fade { - opacity: 0.4; - } - - oryx-quantity-input { - --oryx-quantity-input-width: 102px; - } - - .summary-info { - margin-block-start: 12px; - margin-block-end: 14px; - font-weight: 600; - font-size: 12px; - line-height: 16px; - letter-spacing: 0.01em; - color: var(--oryx-color-neutral-12); - } - - p { - margin: 0; - } - - .bold-text { - font-weight: 600; - } - - oryx-button { - display: block; - } -`; diff --git a/libs/domain/picking/project.json b/libs/domain/picking/project.json deleted file mode 100644 index 0c4c13ae3..000000000 --- a/libs/domain/picking/project.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "$schema": "../../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "libs/domain/picking/src", - "projectType": "library", - "targets": { - "build": { - "executor": "./tools/executors/components-library:build" - }, - "paths": { - "executor": "./tools/executors/components-library:paths", - "configurations": { - "update": { - "update": true - } - } - }, - "test": { - "executor": "./tools/executors/oryx-vite:vitest", - "options": { - "passWithNoTests": true - }, - "configurations": { - "watch": { - "watch": true - } - } - }, - "lint": { - "executor": "@nrwl/linter:eslint", - "options": { - "lintFilePatterns": ["libs/domain/picking/**/*.ts"] - } - }, - "stylelint": { - "executor": "nx-stylelint:lint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": [ - "libs/domain/picking/**/*.css", - "libs/domain/picking/**/*.styles.ts" - ] - } - } - }, - "tags": ["layer:domain"] -} diff --git a/libs/domain/picking/search/index.ts b/libs/domain/picking/search/index.ts deleted file mode 100644 index 7e0ab6fbd..000000000 --- a/libs/domain/picking/search/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './search.component'; -export * from './search.schema'; -export * from './search.styles'; diff --git a/libs/domain/picking/search/search.component.spec.ts b/libs/domain/picking/search/search.component.spec.ts deleted file mode 100644 index ffeb5971b..000000000 --- a/libs/domain/picking/search/search.component.spec.ts +++ /dev/null @@ -1,132 +0,0 @@ -import { fixture } from '@open-wc/testing-helpers'; -import { createInjector, destroyInjector } from '@spryker-oryx/di'; -import { IconTypes } from '@spryker-oryx/ui/icon'; -import { i18n, useComponent } from '@spryker-oryx/utilities'; -import { html } from 'lit'; -import { PickingListService } from '../services'; -import { PickingSearchComponent } from './search.component'; -import { pickingSearchComponent } from './search.def'; - -class MockPickingListService implements Partial { - setQualifier = vi.fn(); - toggleActiveSearch = vi.fn(); -} - -describe('PickingSearchComponent', () => { - let element: PickingSearchComponent; - let service: MockPickingListService; - - beforeAll(async () => { - await useComponent(pickingSearchComponent); - }); - - beforeEach(async () => { - const testInjector = createInjector({ - providers: [ - { - provide: PickingListService, - useClass: MockPickingListService, - }, - ], - }); - - service = testInjector.inject(PickingListService); - - element = await fixture(html``); - }); - - afterEach(() => { - vi.clearAllMocks(); - destroyInjector(); - }); - - it('should render the search', () => { - expect(element).toContainElement( - `oryx-search[float][backIcon="${IconTypes.Backward}"]` - ); - }); - - it('should render the input', () => { - expect(element).toContainElement( - `input[placeholder="${i18n('picking.header.order-ID')}"]` - ); - }); - - describe('when search is opened', () => { - beforeEach(() => { - element.renderRoot - .querySelector('oryx-search') - ?.dispatchEvent(new CustomEvent('oryx.open')); - }); - - it('should set empty search qualifier', () => { - expect(service.setQualifier).toHaveBeenCalledWith( - expect.objectContaining({ - searchOrderReference: '', - }) - ); - }); - - it('should turn on active search', () => { - expect(service.toggleActiveSearch).toHaveBeenCalledWith(true); - }); - - describe('and typing is started', () => { - const searchOrderReference = 'test'; - beforeEach(() => { - const input = element.renderRoot.querySelector( - 'input' - ) as HTMLInputElement; - input.value = searchOrderReference; - input.dispatchEvent(new InputEvent('input')); - }); - - it('should set search qualifier', () => { - expect(service.setQualifier).toHaveBeenCalledWith( - expect.objectContaining({ - searchOrderReference, - }) - ); - }); - - describe('and test is to short', () => { - const searchOrderReference = 't'; - beforeEach(() => { - const input = element.renderRoot.querySelector( - 'input' - ) as HTMLInputElement; - input.value = searchOrderReference; - input.dispatchEvent(new InputEvent('input')); - }); - - it('should set empty search qualifier', () => { - expect(service.setQualifier).toHaveBeenCalledWith( - expect.objectContaining({ - searchOrderReference: '', - }) - ); - }); - }); - }); - }); - - describe('when search is closed', () => { - beforeEach(() => { - element.renderRoot - .querySelector('oryx-search') - ?.dispatchEvent(new CustomEvent('oryx.close')); - }); - - it('should set empty search qualifier', () => { - expect(service.setQualifier).toHaveBeenCalledWith( - expect.objectContaining({ - searchOrderReference: '', - }) - ); - }); - - it('should turn off active search', () => { - expect(service.toggleActiveSearch).toHaveBeenCalledWith(false); - }); - }); -}); diff --git a/libs/domain/picking/search/search.component.ts b/libs/domain/picking/search/search.component.ts deleted file mode 100644 index 863a45fde..000000000 --- a/libs/domain/picking/search/search.component.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { resolve } from '@spryker-oryx/di'; -import { PickingListService } from '@spryker-oryx/picking/services'; -import { IconTypes } from '@spryker-oryx/ui/icon'; -import { I18nMixin } from '@spryker-oryx/utilities'; -import { LitElement, TemplateResult, html } from 'lit'; -import { pickingSearchComponentStyles } from './search.styles'; - -export class PickingSearchComponent extends I18nMixin(LitElement) { - static styles = pickingSearchComponentStyles; - - protected pickingListService = resolve(PickingListService); - - protected onSearch(e: KeyboardEvent): void { - const value = (e.target as HTMLInputElement).value; - - this.pickingListService.setQualifier({ - searchOrderReference: value.length >= 2 ? value : '', - }); - } - - protected onToggleSearch(isSearch: boolean): void { - this.pickingListService.setQualifier({ - searchOrderReference: '', - }); - this.pickingListService.toggleActiveSearch(isSearch); - } - - protected override render(): TemplateResult { - return html` - this.onToggleSearch(true)} - @oryx.close=${(): void => this.onToggleSearch(false)} - > - - - `; - } -} diff --git a/libs/domain/picking/search/search.def.ts b/libs/domain/picking/search/search.def.ts deleted file mode 100644 index 94e564468..000000000 --- a/libs/domain/picking/search/search.def.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { componentDef } from '@spryker-oryx/utilities'; - -export const pickingSearchComponent = componentDef({ - name: 'oryx-picking-search', - impl: () => - import('./search.component').then((m) => m.PickingSearchComponent), - schema: () => - import('./search.schema').then((m) => m.pickingSearchComponentSchema), -}); diff --git a/libs/domain/picking/search/search.schema.ts b/libs/domain/picking/search/search.schema.ts deleted file mode 100644 index ea602256b..000000000 --- a/libs/domain/picking/search/search.schema.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ContentComponentSchema } from '@spryker-oryx/experience'; -import { PickingSearchComponent } from './search.component'; - -export const pickingSearchComponentSchema: ContentComponentSchema = - { - name: 'Search', - group: 'Picking', - }; diff --git a/libs/domain/picking/search/search.styles.ts b/libs/domain/picking/search/search.styles.ts deleted file mode 100644 index 706b6cea3..000000000 --- a/libs/domain/picking/search/search.styles.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { css } from 'lit'; - -export const pickingSearchComponentStyles = css` - oryx-search { - --floating-padding-start: 16px; - --floating-width: calc(var(--oryx-layout-container-width) - 32px); - } -`; diff --git a/libs/domain/picking/search/stories/demo.stories.ts b/libs/domain/picking/search/stories/demo.stories.ts deleted file mode 100644 index 7ed000398..000000000 --- a/libs/domain/picking/search/stories/demo.stories.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { MockDateDecorator } from '@/tools/storybook'; -import { Meta, Story } from '@storybook/web-components'; -import { TemplateResult, html } from 'lit'; -import { storybookPrefix } from '../../.constants'; - -export default { - title: `${storybookPrefix}/Search`, - parameters: { - chromatic: { - disableSnapshot: true, - }, - }, - decorators: [MockDateDecorator()], -} as Meta; - -const Template: Story = (): TemplateResult => { - return html``; -}; - -export const Demo = Template.bind({}); diff --git a/libs/domain/picking/search/stories/static/variants.stories.ts b/libs/domain/picking/search/stories/static/variants.stories.ts deleted file mode 100644 index 50ac3fd5d..000000000 --- a/libs/domain/picking/search/stories/static/variants.stories.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { - MockDateDecorator, - storybookDefaultViewports, -} from '@/tools/storybook'; -import { Meta, Story } from '@storybook/web-components'; -import { LitElement, TemplateResult, html } from 'lit'; -import { storybookPrefix } from '../../../.constants'; - -export default { - title: `${storybookPrefix}/Search/Static`, - parameters: { - chromatic: { - viewports: [storybookDefaultViewports.mobile.min], - }, - }, - decorators: [MockDateDecorator()], -} as Meta; - -const Template: Story = (): TemplateResult => { - return html` -

Default

- - -

Search opened

- - `; -}; - -export const Variants = Template.bind({}); - -Variants.play = async (obj: { - args: unknown; - canvasElement: HTMLElement; -}): Promise => { - await Promise.all([ - customElements.whenDefined('oryx-picking-search'), - customElements.whenDefined('oryx-search'), - ]); - const searchOpened = - obj.canvasElement.querySelector('#search-opened'); - - searchOpened?.renderRoot - .querySelector('oryx-search') - ?.toggleAttribute('open', true); -}; diff --git a/libs/domain/picking/service-worker/auth.feature.ts b/libs/domain/picking/service-worker/auth.feature.ts deleted file mode 100644 index 5299742a2..000000000 --- a/libs/domain/picking/service-worker/auth.feature.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { BapiAuthFeature } from '@spryker-oryx/auth'; - -export class AuthServiceWorkerFeature extends BapiAuthFeature { - override plugins = []; -} diff --git a/libs/domain/picking/service-worker/feature.ts b/libs/domain/picking/service-worker/feature.ts deleted file mode 100644 index 9628d64b5..000000000 --- a/libs/domain/picking/service-worker/feature.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { - AppFeature, - AppInitializer, - AppPlugin, - DefaultStorageService, - StorageService, -} from '@spryker-oryx/core'; -import { Provider } from '@spryker-oryx/di'; -import { - IndexedDbStorageMethod, - provideIndexedDbEntities, -} from '@spryker-oryx/indexed-db'; -import { provideSyncActionsHandler } from '@spryker-oryx/offline/sync'; -import { - BapiPushNotificationAdapter, - BapiPushNotificationDefaultAdapter, - BapiPushNotificationDefaultService, - BapiPushNotificationService, - PickingListEntity, - PickingListOfflineAdapter, - PickingListOnlineAdapter, - PickingListOnlineDefaultAdapter, - PickingProductEntity, - PickingSyncAction, - PickingSyncActionHandlerService, -} from '@spryker-oryx/picking/offline'; -import { - PickingHttpDefaultService, - PickingHttpService, - PickingListAdapter, - PickingListDefaultService, - PickingListService, -} from '@spryker-oryx/picking/services'; -import { PushInitializer } from './push.initializer'; - -export class OfflinePickingFeature implements AppFeature { - providers: Provider[] = this.getProviders(); - plugins: AppPlugin[] = []; - - protected getProviders(): Provider[] { - return [ - ...provideIndexedDbEntities([PickingListEntity, PickingProductEntity]), - ...provideSyncActionsHandler( - PickingSyncAction, - PickingSyncActionHandlerService - ), - { - provide: AppInitializer, - useClass: PushInitializer, - }, - { - provide: BapiPushNotificationService, - useClass: BapiPushNotificationDefaultService, - }, - { - provide: BapiPushNotificationAdapter, - useClass: BapiPushNotificationDefaultAdapter, - }, - { provide: PickingListService, useClass: PickingListDefaultService }, - { provide: PickingListAdapter, useClass: PickingListOfflineAdapter }, - { - provide: PickingListOnlineAdapter, - useClass: PickingListOnlineDefaultAdapter, - }, - { provide: PickingHttpService, useClass: PickingHttpDefaultService }, - { - provide: StorageService, - useFactory: () => new DefaultStorageService(IndexedDbStorageMethod), - }, - ]; - } -} diff --git a/libs/domain/picking/service-worker/index.ts b/libs/domain/picking/service-worker/index.ts deleted file mode 100644 index 445b79b25..000000000 --- a/libs/domain/picking/service-worker/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './auth.feature'; -export * from './feature'; -export * from './push.initializer'; diff --git a/libs/domain/picking/service-worker/push.initializer.ts b/libs/domain/picking/service-worker/push.initializer.ts deleted file mode 100644 index 4ae172844..000000000 --- a/libs/domain/picking/service-worker/push.initializer.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { OauthService } from '@spryker-oryx/auth'; -import { AppInitializer } from '@spryker-oryx/core'; -import { inject } from '@spryker-oryx/di'; -import { SyncSchedulerService } from '@spryker-oryx/offline/sync'; -import { - PickingSyncAction, - PushSyncPayload, -} from '@spryker-oryx/picking/offline'; -import { Observable, firstValueFrom } from 'rxjs'; - -declare let self: ServiceWorkerGlobalScope; - -export class PushInitializer implements AppInitializer { - constructor( - private syncSchedulerService = inject(SyncSchedulerService), - private authService = inject(OauthService) - ) {} - - initialize(): void | Observable | Promise { - //make subscription on auth token - this.authService.invokeStoredToken(); - - self.addEventListener('push', (event: PushEvent) => { - if (!event.data) { - throw new Error('SwPushInitializerService: No data in push event'); - } - - const payload: PushSyncPayload = event.data.json(); - - event.waitUntil( - firstValueFrom( - this.syncSchedulerService.schedule({ - action: PickingSyncAction.Push, - payload, - }) - ) - ); - }); - } -} diff --git a/libs/domain/picking/services/index.ts b/libs/domain/picking/services/index.ts deleted file mode 100644 index 8420b1093..000000000 --- a/libs/domain/picking/services/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './src'; diff --git a/libs/domain/picking/services/src/feature.ts b/libs/domain/picking/services/src/feature.ts deleted file mode 100644 index 78633a8b3..000000000 --- a/libs/domain/picking/services/src/feature.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { - AppFeature, - DefaultJsonAPITransformerService, - JsonAPITransformerService, -} from '@spryker-oryx/core'; -import { Provider } from '@spryker-oryx/di'; -import { - PickingHttpDefaultService, - PickingHttpService, - PickingListAdapter, - PickingListDefaultAdapter, - PickingListDefaultService, - PickingListService, - WarehouseUserAssignmentsAdapter, - WarehouseUserAssignmentsDefaultAdapter, - WarehouseUserAssignmentsDefaultService, - WarehouseUserAssignmentsService, - warehouseUserAssignmentNormalizer, - warehouseUserAssignmentsNormalizer, -} from './services'; - -export class PickingServicesFeature implements AppFeature { - providers = this.getProviders(); - - protected getProviders(): Provider[] { - return [ - { - provide: JsonAPITransformerService, - useClass: DefaultJsonAPITransformerService, - }, - ...warehouseUserAssignmentNormalizer, - ...warehouseUserAssignmentsNormalizer, - { provide: PickingListService, useClass: PickingListDefaultService }, - { provide: PickingListAdapter, useClass: PickingListDefaultAdapter }, - { provide: PickingHttpService, useClass: PickingHttpDefaultService }, - { - provide: WarehouseUserAssignmentsAdapter, - useClass: WarehouseUserAssignmentsDefaultAdapter, - }, - { - provide: WarehouseUserAssignmentsService, - useClass: WarehouseUserAssignmentsDefaultService, - }, - ]; - } -} diff --git a/libs/domain/picking/services/src/index.ts b/libs/domain/picking/services/src/index.ts deleted file mode 100644 index 5cb14365b..000000000 --- a/libs/domain/picking/services/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './feature'; -export * from './models'; -export * from './services'; diff --git a/libs/domain/picking/services/src/models/index.ts b/libs/domain/picking/services/src/models/index.ts deleted file mode 100644 index aedb52710..000000000 --- a/libs/domain/picking/services/src/models/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './picking-list'; -export * from './picking-list-qualifier'; -export * from './picking-product'; -export * from './warehouse-user-assignment'; -export * from './warehouse-user-assignment.api.model'; diff --git a/libs/domain/picking/services/src/models/picking-list-qualifier.ts b/libs/domain/picking/services/src/models/picking-list-qualifier.ts deleted file mode 100644 index 0b9cbcd61..000000000 --- a/libs/domain/picking/services/src/models/picking-list-qualifier.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { PickingListStatus } from './picking-list'; - -export interface SearchQualifier { - searchOrderReference?: string; -} - -export interface PageableQualifier { - limit?: number; - offset?: number; -} - -export interface SortableQualifier { - sortBy?: SortBy; - sortDesc?: boolean; -} - -export interface PickingListQualifier - extends SortableQualifier, - PageableQualifier, - SearchQualifier { - ids?: string[]; - status?: PickingListStatus; - orderReferences?: string[]; -} - -export enum PickingListQualifierSortBy { - DeliveryDate = 'deliveryDate', - OrderSize = 'orderSize', -} - -export const defaultQualifier = { - status: PickingListStatus.ReadyForPicking, - sortBy: PickingListQualifierSortBy.DeliveryDate, - sortDesc: false, -}; diff --git a/libs/domain/picking/services/src/models/picking-list.ts b/libs/domain/picking/services/src/models/picking-list.ts deleted file mode 100644 index 753535155..000000000 --- a/libs/domain/picking/services/src/models/picking-list.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { PickingProduct } from './picking-product'; - -export interface PickingList { - id: string; - orderReferences: string[]; - requestedDeliveryDate: Date; - status: PickingListStatus; - items: PickingListItem[]; - cartNote?: string; - createdAt: Date; - updatedAt: Date; - itemsCount: number; -} - -export interface PickingListError extends Error { - code: string; - status: number; -} - -export enum ItemsFilters { - NotPicked = 'not_picked', - Picked = 'picked', - NotFound = 'not_found', -} - -export enum PickingListStatus { - ReadyForPicking = 'ready-for-picking', - PickingStarted = 'picking-started', - PickingFinished = 'picking-finished', -} - -export interface PickingListItem { - id: string; - quantity: number; - numberOfPicked: number; - numberOfNotPicked: number; - orderItem: PickingOrderItem; - product: PickingProduct; - status: ItemsFilters; -} - -export interface PickingOrderItem { - idSalesOrderItem: number; - uuid: string; - name: string; - sku: string; - quantity: number; - amount: string; - amountSalesUnit?: PickingAmountSalesUnit; -} - -export interface PickingAmountSalesUnit { - conversion: number; - precision: number; - productMeasurementUnit: PickingMeasurementUnit; -} - -export interface PickingMeasurementUnit { - name: string; - code: string; -} diff --git a/libs/domain/picking/services/src/models/picking-product.ts b/libs/domain/picking/services/src/models/picking-product.ts deleted file mode 100644 index 69e866f84..000000000 --- a/libs/domain/picking/services/src/models/picking-product.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface PickingProduct { - id: string; - sku: string; - productName: string; - image: string | null; - imageLarge: string | null; -} diff --git a/libs/domain/picking/services/src/models/warehouse-user-assignment.api.model.ts b/libs/domain/picking/services/src/models/warehouse-user-assignment.api.model.ts deleted file mode 100644 index 32ec50484..000000000 --- a/libs/domain/picking/services/src/models/warehouse-user-assignment.api.model.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { LinksObject, ResourceObject } from '../services/adapter/types'; -import { Warehouse } from './warehouse-user-assignment'; - -export interface DeserializedWarehouseUserAssignment extends LinksObject { - id: string; - isActive: boolean; - userUuid: string; - warehouse: Warehouse; -} - -export interface GetWarehouseUserAssignmentsResponse { - data: WarehouseUserAssignmentsResponse[]; - links: LinksObject; -} - -export interface PatchWarehouseUserAssignmentsResponse { - data: WarehouseUserAssignmentsResponse; -} - -interface WarehouseUserAssignmentsResponse extends ResourceObject { - attributes: { - userUuid: string; - isActive: boolean; - warehouse: { - name: string; - uuid: string; - isActive: boolean; - }; - }; -} diff --git a/libs/domain/picking/services/src/models/warehouse-user-assignment.ts b/libs/domain/picking/services/src/models/warehouse-user-assignment.ts deleted file mode 100644 index 1b3d5b3f9..000000000 --- a/libs/domain/picking/services/src/models/warehouse-user-assignment.ts +++ /dev/null @@ -1,15 +0,0 @@ -export interface Warehouse { - uuid: string; - name: string; - isActive?: boolean; -} - -export interface WarehouseUserAssignment { - id: string; - isActive: boolean; - userUuid: string; - warehouse: Warehouse; -} - -export const warehouseUserAssignmentStorageKey = - 'oryx.warehouse-user-assignment'; diff --git a/libs/domain/picking/services/src/services/adapter/index.ts b/libs/domain/picking/services/src/services/adapter/index.ts deleted file mode 100644 index 81f23750c..000000000 --- a/libs/domain/picking/services/src/services/adapter/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './normalizers'; -export * from './picking-list-default.adapter'; -export * from './picking-list.adapter'; -export * from './warehouse-user-assignments-default.adapter'; -export * from './warehouse-user-assignments.adapter'; diff --git a/libs/domain/picking/services/src/services/adapter/normalizers/index.ts b/libs/domain/picking/services/src/services/adapter/normalizers/index.ts deleted file mode 100644 index ad6e11676..000000000 --- a/libs/domain/picking/services/src/services/adapter/normalizers/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './warehouse-user-assignment.normalizer'; -export * from './warehouse-user-assignments.normalizer'; diff --git a/libs/domain/picking/services/src/services/adapter/normalizers/warehouse-user-assignment.normalizer.spec.ts b/libs/domain/picking/services/src/services/adapter/normalizers/warehouse-user-assignment.normalizer.spec.ts deleted file mode 100644 index b75f0eb60..000000000 --- a/libs/domain/picking/services/src/services/adapter/normalizers/warehouse-user-assignment.normalizer.spec.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { DeserializedWarehouseUserAssignment } from '../../../models'; -import { warehouseUserAssignmentAttributeNormalizer } from './warehouse-user-assignment.normalizer'; - -const mockWarehouseUserAssignmentDeserializedData: DeserializedWarehouseUserAssignment = - { - id: '1', - isActive: true, - self: '', - userUuid: 'userUuid1', - warehouse: { - uuid: 'warehouseUuid1', - name: 'warehouse1', - isActive: true, - }, - }; - -describe('Warehouse user assignment Normalizer', () => { - it('should transform DeserializedWarehouseUserAssignment into WarehouseUserAssignment', () => { - const normalized = warehouseUserAssignmentAttributeNormalizer( - mockWarehouseUserAssignmentDeserializedData - ); - expect(normalized).toEqual({ - id: mockWarehouseUserAssignmentDeserializedData.id, - isActive: mockWarehouseUserAssignmentDeserializedData.isActive, - userUuid: mockWarehouseUserAssignmentDeserializedData.userUuid, - warehouse: mockWarehouseUserAssignmentDeserializedData.warehouse, - }); - }); -}); diff --git a/libs/domain/picking/services/src/services/adapter/normalizers/warehouse-user-assignment.normalizer.ts b/libs/domain/picking/services/src/services/adapter/normalizers/warehouse-user-assignment.normalizer.ts deleted file mode 100644 index c90100821..000000000 --- a/libs/domain/picking/services/src/services/adapter/normalizers/warehouse-user-assignment.normalizer.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Transformer } from '@spryker-oryx/core'; -import { Provider } from '@spryker-oryx/di'; -import { - DeserializedWarehouseUserAssignment, - WarehouseUserAssignment, -} from '../../../models'; - -export const WarehouseUserAssignmentNormalizer = - 'oryx.WarehouseUserAssignmentNormalizer*'; - -export function warehouseUserAssignmentAttributeNormalizer( - data: DeserializedWarehouseUserAssignment -): WarehouseUserAssignment { - return { - id: data.id, - isActive: data.isActive, - userUuid: data.userUuid, - warehouse: data.warehouse, - }; -} - -export const warehouseUserAssignmentNormalizer: Provider[] = [ - { - provide: WarehouseUserAssignmentNormalizer, - useValue: warehouseUserAssignmentAttributeNormalizer, - }, -]; - -declare global { - interface InjectionTokensContractMap { - [WarehouseUserAssignmentNormalizer]: Transformer[]; - } -} diff --git a/libs/domain/picking/services/src/services/adapter/normalizers/warehouse-user-assignments.normalizer.spec.ts b/libs/domain/picking/services/src/services/adapter/normalizers/warehouse-user-assignments.normalizer.spec.ts deleted file mode 100644 index 848571321..000000000 --- a/libs/domain/picking/services/src/services/adapter/normalizers/warehouse-user-assignments.normalizer.spec.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { of, take } from 'rxjs'; -import { DeserializedWarehouseUserAssignment } from '../../../models'; -import { WarehouseUserAssignmentNormalizer } from './warehouse-user-assignment.normalizer'; -import { warehouseUserAssignmentItemsNormalizer } from './warehouse-user-assignments.normalizer'; - -const mockWarehouseUserAssignmentsDeserializedData: DeserializedWarehouseUserAssignment[] = - [ - { - id: '1', - isActive: true, - self: '', - userUuid: 'userUuid1', - warehouse: { - uuid: 'warehouseUuid1', - name: 'warehouse1', - isActive: true, - }, - }, - ]; - -const mockTransformed = 'mockTransformed'; - -const mockTransformer = { - do: vi.fn().mockReturnValue(() => of(mockTransformed)), - transform: vi.fn().mockReturnValue(of(mockTransformed)), -}; - -describe('Warehouse user assignments Normalizer', () => { - it('should transform DeserializedWarehouseUserAssignment array into WarehouseUserAssignment array', () => { - warehouseUserAssignmentItemsNormalizer( - mockWarehouseUserAssignmentsDeserializedData, - mockTransformer - ) - .pipe(take(1)) - .subscribe((normalized) => { - expect(mockTransformer.transform).toHaveBeenCalledWith( - mockWarehouseUserAssignmentsDeserializedData[0], - WarehouseUserAssignmentNormalizer - ); - expect(normalized).toEqual([mockTransformed]); - }); - }); -}); diff --git a/libs/domain/picking/services/src/services/adapter/normalizers/warehouse-user-assignments.normalizer.ts b/libs/domain/picking/services/src/services/adapter/normalizers/warehouse-user-assignments.normalizer.ts deleted file mode 100644 index cefad249e..000000000 --- a/libs/domain/picking/services/src/services/adapter/normalizers/warehouse-user-assignments.normalizer.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { Transformer, TransformerService } from '@spryker-oryx/core'; -import { Provider } from '@spryker-oryx/di'; -import { Observable, combineLatest, of } from 'rxjs'; -import { - DeserializedWarehouseUserAssignment, - WarehouseUserAssignment, -} from '../../../models'; -import { WarehouseUserAssignmentNormalizer } from './warehouse-user-assignment.normalizer'; - -export const WarehouseUserAssignmentsNormalizer = - 'oryx.WarehouseUserAssignmentsNormalizer*'; - -export function warehouseUserAssignmentItemsNormalizer( - data: DeserializedWarehouseUserAssignment[], - transformer: TransformerService -): Observable { - return data.length - ? combineLatest( - data.map((item) => - transformer.transform(item, WarehouseUserAssignmentNormalizer) - ) - ) - : of([]); -} - -export const warehouseUserAssignmentsNormalizer: Provider[] = [ - { - provide: WarehouseUserAssignmentsNormalizer, - useValue: warehouseUserAssignmentItemsNormalizer, - }, -]; - -declare global { - interface InjectionTokensContractMap { - [WarehouseUserAssignmentsNormalizer]: Transformer< - WarehouseUserAssignment[] - >[]; - } -} diff --git a/libs/domain/picking/services/src/services/adapter/picking-list-default.adapter.ts b/libs/domain/picking/services/src/services/adapter/picking-list-default.adapter.ts deleted file mode 100644 index fdc315679..000000000 --- a/libs/domain/picking/services/src/services/adapter/picking-list-default.adapter.ts +++ /dev/null @@ -1,290 +0,0 @@ -import { inject } from '@spryker-oryx/di'; -// Add full import because of issue with naming exports from cjs. -import * as jsonapi from 'jsonapi-serializer'; -import { map, Observable, of, switchMap } from 'rxjs'; -import { - ItemsFilters, - PickingList, - PickingListError, - PickingListItem, - PickingListQualifier, - PickingListStatus, - PickingOrderItem, - PickingProduct, -} from '../../models'; -import { PickingHttpService } from '../picking-http.service'; -import { PickingListAdapter } from './picking-list.adapter'; -import { LinksObject, ResourceObject } from './types'; - -export class PickingListDefaultAdapter implements PickingListAdapter { - constructor( - protected pickingHttpService = inject(PickingHttpService), - protected deserializer = new jsonapi.Deserializer({ - keyForAttribute: 'camelCase', - }) - ) {} - - get(qualifier?: PickingListQualifier): Observable { - const query = this.getPickingListQuery(qualifier); - - return this.pickingHttpService - .get(`/picking-lists${query}`) - .pipe(switchMap((res) => this.parsePickingLists(res))); - } - - startPicking(pickingList: PickingList): Observable { - return this.pickingHttpService - .post( - `/picking-lists/${pickingList.id}/start-picking`, - {} - ) - .pipe( - map((response) => { - if (response.errors) { - const error = response.errors[0]; - const pickingListError = new Error( - error.message - ) as PickingListError; - pickingListError.status = error.status; - pickingListError.code = error.code; - throw pickingListError; - } - return { - ...pickingList, - status: response.data.status as PickingListStatus, - createdAt: new Date(response.data.createdAt), - updatedAt: new Date(response.data.updatedAt), - }; - }) - ); - } - - updatePickingItems(pickingList: PickingList): Observable { - // In online-only mode there is no request to BAPI needed - return of(pickingList); - } - - finishPicking(pickingList: PickingList): Observable { - const body = { - data: pickingList.items.map((item) => ({ - id: item.id, - type: 'picking-list-items', - status: item.status, - attributes: { - numberOfPicked: item.numberOfPicked, - numberOfNotPicked: item.numberOfNotPicked, - }, - })), - }; - - return this.pickingHttpService - .patch( - `/picking-lists/${pickingList.id}/picking-list-items`, - body - ) - .pipe( - map(({ data: [updatedPickingListData] }) => ({ - ...pickingList, - status: updatedPickingListData.status as PickingListStatus, - createdAt: new Date(updatedPickingListData.createdAt), - updatedAt: new Date(updatedPickingListData.updatedAt), - })) - ); - } - - protected getPickingListQuery(qualifier?: PickingListQualifier): string { - const params = new URLSearchParams({ - include: - 'picking-list-items,concrete-products,sales-orders,sales-shipments,concrete-product-image-sets', - }); - - qualifier?.ids?.forEach((id) => - params.append('filter[picking-lists.uuids][]', id) - ); - - if (qualifier?.status) { - params.set('filter[picking-lists.status]', qualifier.status); - } - - if ( - qualifier?.limit !== undefined || - qualifier?.offset !== undefined || - qualifier?.orderReferences !== undefined || - qualifier?.sortBy !== undefined || - qualifier?.sortDesc !== undefined - ) { - throw new Error( - `PickingListDefaultAdapter: Unsupported qualifier: ${JSON.stringify( - qualifier, - null, - 2 - )}!` - ); - } - - return `?${params.toString()}`; - } - - protected async parsePickingLists( - response: GetPickingListResponse - ): Promise { - const deserializedData: PickingListResponseData[] = - await this.deserializer.deserialize(response); - - const products = this.parseProducts(deserializedData); - - return deserializedData.map((data) => - this.parsePickingList(data, products) - ); - } - - protected parseProducts(data: PickingListResponseData[]): PickingProduct[] { - const productsDeserialize = data - .flatMap((item) => item.pickingListItems) - .flatMap((item) => item.concreteProducts); - - const products: PickingProduct[] = productsDeserialize.map((product) => ({ - id: product.id, - sku: product.sku, - productName: product.name, - image: - product.concreteProductImageSets?.[0].imageSets[0].images[0] - .externalUrlSmall, - imageLarge: - product.concreteProductImageSets?.[0].imageSets[0].images[0] - .externalUrlLarge, - })); - - return products; - } - - protected parsePickingList( - data: PickingListResponseData, - products: PickingProduct[] - ): PickingList { - const cardNote = data.pickingListItems[0].salesOrders[0].cartNote; - const orderReferences = [ - ...new Set( - data.pickingListItems - .map((item) => - item.salesOrders.map((salesOrder) => salesOrder.orderReference) - ) - .flat() - ), - ]; - const requestedDeliveryDate: string = - data.pickingListItems[0].salesShipments[0].requestedDeliveryDate; - - const parsedPickingItems: PickingListItem[] = data.pickingListItems.map( - (item) => { - // Use first element(products[0]) from products because it will be only ONE by pickinglist item - const product = products.find( - (prod) => prod.sku === item.concreteProducts[0].sku - ); - - if (!product) { - throw new Error(`Missing product for item '${item.id}'`); - } - - return { - id: item.id, - quantity: item.quantity, - numberOfPicked: item.numberOfPicked, - numberOfNotPicked: item.numberOfNotPicked, - orderItem: item.orderItem, - product: product, - type: 'picking-list-items', - status: item.numberOfPicked - ? ItemsFilters.Picked - : ItemsFilters.NotPicked, - }; - } - ); - - const pickingList: PickingList = { - id: data.id, - orderReferences, - status: data.status as PickingListStatus, - items: parsedPickingItems, - cartNote: cardNote, - createdAt: new Date(data.createdAt), - updatedAt: new Date(data.updatedAt), - requestedDeliveryDate: new Date(requestedDeliveryDate), - itemsCount: parsedPickingItems.reduce( - (count, item) => count + item.quantity, - 0 - ), - }; - - return pickingList; - } -} - -export interface GetPickingListResponse { - data: PickingListResponseData[]; - included: unknown[]; - links: LinksObject; -} - -export interface PickingListResponseData extends ResourceObject { - uuid: string; - status: string; - pickingListItems: PickingListResponseItem[]; - createdAt: string; - updatedAt: string; -} - -interface PickingListResponseItem extends ResourceObject { - numberOfPicked: number; - numberOfNotPicked: number; - orderItem: PickingOrderItem; - concreteProducts: PickingListResponseProduct[]; - quantity: number; - salesOrders: PickingListResponseOrder[]; - salesShipments: PickingListResponseShipment[]; -} - -interface PickingListResponseOrder extends ResourceObject { - orderReference: string; - cartNote: string; -} - -interface PickingListResponseShipment extends ResourceObject { - requestedDeliveryDate: string; -} - -interface PickingListResponseProduct extends ResourceObject { - sku: string; - name: string; - concreteProductImageSets: { - imageSets: PickingListResponseProductImage[]; - }[]; -} - -interface PickingListResponseProductImage extends ResourceObject { - name: string; - locale: string; - images: [ - { - externalUrlSmall: string; - externalUrlLarge: string; - } - ]; -} - -interface StartPickingListResponse { - data: PatchPickingListData; - links: LinksObject; - errors?: PickingListError[]; -} - -interface FinishPickingListResponse { - data: PatchPickingListData[]; - links: LinksObject; -} - -interface PatchPickingListData extends ResourceObject { - status: string; - updatedAt: string; - createdAt: string; -} diff --git a/libs/domain/picking/services/src/services/adapter/picking-list.adapter.ts b/libs/domain/picking/services/src/services/adapter/picking-list.adapter.ts deleted file mode 100644 index e6f3eb7b7..000000000 --- a/libs/domain/picking/services/src/services/adapter/picking-list.adapter.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Observable } from 'rxjs'; -import { PickingList, PickingListQualifier } from '../../models'; - -export interface PickingListAdapter { - get(qualifier?: PickingListQualifier): Observable; - startPicking(pickingList: PickingList): Observable; - updatePickingItems(pickingList: PickingList): Observable; - finishPicking(pickingList: PickingList): Observable; -} - -export const PickingListAdapter = 'oryx.PickingListAdapter'; - -declare global { - interface InjectionTokensContractMap { - [PickingListAdapter]: PickingListAdapter; - } -} diff --git a/libs/domain/picking/services/src/services/adapter/types.ts b/libs/domain/picking/services/src/services/adapter/types.ts deleted file mode 100644 index 2b334b50c..000000000 --- a/libs/domain/picking/services/src/services/adapter/types.ts +++ /dev/null @@ -1,8 +0,0 @@ -export interface ResourceObject { - id: string; - type: string; -} - -export interface LinksObject { - self: string; -} diff --git a/libs/domain/picking/services/src/services/adapter/warehouse-user-assignments-default.adapter.spec.ts b/libs/domain/picking/services/src/services/adapter/warehouse-user-assignments-default.adapter.spec.ts deleted file mode 100644 index 2a78f0b0f..000000000 --- a/libs/domain/picking/services/src/services/adapter/warehouse-user-assignments-default.adapter.spec.ts +++ /dev/null @@ -1,120 +0,0 @@ -import { JsonAPITransformerService } from '@spryker-oryx/core'; -import { createInjector, destroyInjector } from '@spryker-oryx/di'; -import { of } from 'rxjs'; -import { GetWarehouseUserAssignmentsResponse } from '../../models'; -import { PickingHttpService } from '../picking-http.service'; -import { WarehouseUserAssignmentsDefaultAdapter } from './warehouse-user-assignments-default.adapter'; -import { WarehouseUserAssignmentsAdapter } from './warehouse-user-assignments.adapter'; - -const mockResponseWarehouseUserAssignment = { - type: 'warehouse-user-assignments', - id: 'id1', - attributes: { - userUuid: 'userUuid1', - warehouse: { - uuid: 'warehouseUuid1', - name: 'Warehouse 1', - isActive: true, - }, - isActive: true, - }, -}; - -class MockPickingHttpService implements Partial { - get = vi.fn().mockReturnValue( - of({ - data: [mockResponseWarehouseUserAssignment], - links: { - self: '', - }, - }) - ); - patch = vi.fn().mockReturnValue( - of({ - data: mockResponseWarehouseUserAssignment, - }) - ); -} - -const mockTransformerData = 'mockTransformerData'; - -const mockTransformer = { - do: vi.fn().mockReturnValue(() => of(mockTransformerData)), -}; - -describe('WarehouseUserAssignmentsDefaultAdapter', () => { - const endpoint = '/warehouse-user-assignments'; - const callback = vi.fn(); - let adapter: WarehouseUserAssignmentsAdapter; - let http: PickingHttpService; - - beforeEach(() => { - const testInjector = createInjector({ - providers: [ - { - provide: JsonAPITransformerService, - useValue: mockTransformer, - }, - { - provide: WarehouseUserAssignmentsAdapter, - useClass: WarehouseUserAssignmentsDefaultAdapter, - }, - { - provide: PickingHttpService, - useClass: MockPickingHttpService, - }, - ], - }); - - adapter = testInjector.inject(WarehouseUserAssignmentsAdapter); - http = testInjector.inject(PickingHttpService); - }); - - afterEach(() => { - vi.clearAllMocks(); - destroyInjector(); - }); - - it('should be provided', () => { - expect(adapter).toBeInstanceOf(WarehouseUserAssignmentsDefaultAdapter); - }); - - describe('when "getList" method is called', () => { - beforeEach(() => { - adapter.getList().subscribe(callback); - }); - - it('should call the "get" method of PickingHttpService with endpoint', () => { - expect(http.get).toHaveBeenCalledWith(endpoint); - }); - - it('should return transformed data', () => { - expect(callback).toHaveBeenCalledWith(mockTransformerData); - }); - }); - - describe('when "activateAssignment" method is called', () => { - beforeEach(() => { - adapter - .activateAssignment(mockResponseWarehouseUserAssignment.id) - .subscribe(callback); - }); - - it('should call the "patch" method of PickingHttpService', () => { - expect(http.patch).toHaveBeenCalledWith( - `${endpoint}/${mockResponseWarehouseUserAssignment.id}`, - { - data: { - attributes: { - isActive: true, - }, - }, - } - ); - }); - - it('should receive updated warehouse user assignment', () => { - expect(callback).toHaveBeenCalledWith(mockTransformerData); - }); - }); -}); diff --git a/libs/domain/picking/services/src/services/adapter/warehouse-user-assignments-default.adapter.ts b/libs/domain/picking/services/src/services/adapter/warehouse-user-assignments-default.adapter.ts deleted file mode 100644 index 1acbe381a..000000000 --- a/libs/domain/picking/services/src/services/adapter/warehouse-user-assignments-default.adapter.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { JsonAPITransformerService } from '@spryker-oryx/core'; -import { inject } from '@spryker-oryx/di'; -import * as jsonapi from 'jsonapi-serializer'; -import { Observable } from 'rxjs'; -import { - GetWarehouseUserAssignmentsResponse, - PatchWarehouseUserAssignmentsResponse, -} from '../../models'; -import { WarehouseUserAssignment } from '../../models/warehouse-user-assignment'; -import { PickingHttpService } from '../picking-http.service'; -import { - WarehouseUserAssignmentNormalizer, - WarehouseUserAssignmentsNormalizer, -} from './normalizers'; -import { WarehouseUserAssignmentsAdapter } from './warehouse-user-assignments.adapter'; - -export class WarehouseUserAssignmentsDefaultAdapter - implements WarehouseUserAssignmentsAdapter -{ - constructor( - protected pickingHttpService = inject(PickingHttpService), - protected transformer = inject(JsonAPITransformerService), - protected deserializer = new jsonapi.Deserializer({ - keyForAttribute: 'camelCase', - }) - ) {} - - protected endpoint = '/warehouse-user-assignments'; - - getList(): Observable { - return this.pickingHttpService - .get(this.endpoint) - .pipe(this.transformer.do(WarehouseUserAssignmentsNormalizer)); - } - - activateAssignment( - assignmentId: string - ): Observable { - return this.pickingHttpService - .patch( - `${this.endpoint}/${assignmentId}`, - { - data: { - attributes: { - isActive: true, - }, - }, - } - ) - .pipe(this.transformer.do(WarehouseUserAssignmentNormalizer)); - } -} diff --git a/libs/domain/picking/services/src/services/adapter/warehouse-user-assignments.adapter.ts b/libs/domain/picking/services/src/services/adapter/warehouse-user-assignments.adapter.ts deleted file mode 100644 index b3f32745a..000000000 --- a/libs/domain/picking/services/src/services/adapter/warehouse-user-assignments.adapter.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Observable } from 'rxjs'; -import { WarehouseUserAssignment } from '../../models/warehouse-user-assignment'; - -export interface WarehouseUserAssignmentsAdapter { - getList(): Observable; - activateAssignment(assignmentId: string): Observable; -} - -export const WarehouseUserAssignmentsAdapter = - 'oryx.WarehouseUserAssignmentsAdapter'; - -declare global { - interface InjectionTokensContractMap { - [WarehouseUserAssignmentsAdapter]: WarehouseUserAssignmentsAdapter; - } -} diff --git a/libs/domain/picking/services/src/services/index.ts b/libs/domain/picking/services/src/services/index.ts deleted file mode 100644 index 816196cea..000000000 --- a/libs/domain/picking/services/src/services/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './adapter'; -export * from './picking-http-default.service'; -export * from './picking-http.service'; -export * from './picking-list-default.service'; -export * from './picking-list.service'; -export * from './warehouse-user-assignments-default.service'; -export * from './warehouse-user-assignments.service'; diff --git a/libs/domain/picking/services/src/services/picking-http-default.service.ts b/libs/domain/picking/services/src/services/picking-http-default.service.ts deleted file mode 100644 index 6df851bb7..000000000 --- a/libs/domain/picking/services/src/services/picking-http-default.service.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { HttpService, injectEnv, RequestOptions } from '@spryker-oryx/core'; -import { inject } from '@spryker-oryx/di'; -import { Observable } from 'rxjs'; -import { PickingHttpService } from './picking-http.service'; - -declare global { - interface AppEnvironment { - readonly ORYX_FULFILLMENT_BACKEND_URL?: string; - } -} - -export class PickingHttpDefaultService implements PickingHttpService { - constructor( - protected httpService = inject(HttpService), - protected baseUrl = injectEnv('ORYX_FULFILLMENT_BACKEND_URL', '') - ) {} - - request( - url: string, - options?: RequestOptions - ): Observable { - url = this.createFullUrl(url); - return this.httpService.request(url, options); - } - - get(url: string, options?: RequestOptions): Observable { - url = this.createFullUrl(url); - return this.httpService.get(url, this.expandContentType(options)); - } - - delete(url: string, options?: RequestOptions): Observable { - url = this.createFullUrl(url); - return this.httpService.delete(url, options); - } - - post( - url: string, - body: unknown, - options?: RequestOptions - ): Observable { - url = this.createFullUrl(url); - return this.httpService.post(url, body, this.expandContentType(options)); - } - - patch( - url: string, - body: unknown, - options?: RequestOptions - ): Observable { - url = this.createFullUrl(url); - return this.httpService.patch(url, body, this.expandContentType(options)); - } - - protected createFullUrl(url: string): string { - return `${this.baseUrl}${url}`; - } - - protected expandContentType( - options?: RequestOptions - ): RequestOptions { - const headers = new Headers(options?.headers); - headers.set('Content-Type', 'application/vnd.api+json'); - return { - ...options, - headers, - }; - } -} diff --git a/libs/domain/picking/services/src/services/picking-http.service.ts b/libs/domain/picking/services/src/services/picking-http.service.ts deleted file mode 100644 index b5df156c9..000000000 --- a/libs/domain/picking/services/src/services/picking-http.service.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { HttpService } from '@spryker-oryx/core'; - -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface PickingHttpService extends HttpService {} - -export const PickingHttpService = 'oryx.PickingHttpService'; - -declare global { - export interface InjectionTokensContractMap { - [PickingHttpService]: PickingHttpService; - } -} diff --git a/libs/domain/picking/services/src/services/picking-list-default.service.ts b/libs/domain/picking/services/src/services/picking-list-default.service.ts deleted file mode 100644 index b7e520ff4..000000000 --- a/libs/domain/picking/services/src/services/picking-list-default.service.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { inject } from '@spryker-oryx/di'; -import { - BehaviorSubject, - catchError, - map, - Observable, - switchMap, - tap, - throwError, -} from 'rxjs'; -import { defaultQualifier, PickingList, PickingListQualifier } from '../models'; -import { PickingListAdapter } from './adapter'; -import { PickingListService } from './picking-list.service'; - -export class PickingListDefaultService implements PickingListService { - constructor(protected adapter = inject(PickingListAdapter)) {} - - protected upcomingPickingListId$ = new BehaviorSubject(null); - protected allowDiscardPicking$ = new BehaviorSubject(true); - - protected activeSearch$ = new BehaviorSubject(false); - - isActiveSearch(): Observable { - return this.activeSearch$; - } - - toggleActiveSearch(state: boolean): void { - this.activeSearch$.next(state); - } - - protected _qualifier: PickingListQualifier = defaultQualifier; - protected qualifier$ = new BehaviorSubject( - this._qualifier - ); - - getQualifier(): Observable { - return this.qualifier$; - } - - setQualifier(qualifier: PickingListQualifier): void { - this._qualifier = { ...this._qualifier, ...qualifier }; - this.qualifier$.next(this._qualifier); - } - - get(): Observable { - return this.qualifier$.pipe( - switchMap((qualifier) => this.adapter.get(qualifier)) - ); - } - - getList(id: string): Observable { - return this.adapter.get({ ids: [id] }).pipe(map((list) => list[0] ?? null)); - } - - startPicking(pickingList: PickingList): Observable { - this.upcomingPickingListId$.next(pickingList.id); - return this.adapter.startPicking(pickingList).pipe( - catchError((e) => { - this.upcomingPickingListId$.next(null); - return throwError(() => e); - }), - tap(() => { - this.allowDiscardPicking$.next(false); - this.upcomingPickingListId$.next(null); - }) - ); - } - - getUpcomingPickingListId(): Observable { - return this.upcomingPickingListId$; - } - - updatePickingItems(pickingList: PickingList): Observable { - return this.adapter.updatePickingItems(pickingList); - } - - finishPicking(pickingList: PickingList): Observable { - return this.adapter - .finishPicking(pickingList) - .pipe(tap(() => this.allowDiscardPicking$.next(true))); - } - - allowDiscardPicking(): Observable { - return this.allowDiscardPicking$; - } -} diff --git a/libs/domain/picking/services/src/services/picking-list.service.ts b/libs/domain/picking/services/src/services/picking-list.service.ts deleted file mode 100644 index d1332f7a6..000000000 --- a/libs/domain/picking/services/src/services/picking-list.service.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Observable } from 'rxjs'; -import { PickingList, PickingListQualifier } from '../models'; - -export interface PickingListService { - get(): Observable; - getList(id: string): Observable; - startPicking(pickingList: PickingList): Observable; - getUpcomingPickingListId(): Observable; - updatePickingItems(pickingList: PickingList): Observable; - finishPicking(pickingList: PickingList): Observable; - getQualifier(): Observable; - setQualifier(qualifier: PickingListQualifier): void; - allowDiscardPicking(): Observable; - isActiveSearch(): Observable; - toggleActiveSearch(state: boolean): void; -} - -export const PickingListService = 'oryx.PickingListService'; - -declare global { - export interface InjectionTokensContractMap { - [PickingListService]: PickingListService; - } -} diff --git a/libs/domain/picking/services/src/services/warehouse-user-assignments-default.service.spec.ts b/libs/domain/picking/services/src/services/warehouse-user-assignments-default.service.spec.ts deleted file mode 100644 index 4224116b4..000000000 --- a/libs/domain/picking/services/src/services/warehouse-user-assignments-default.service.spec.ts +++ /dev/null @@ -1,197 +0,0 @@ -import { AuthService } from '@spryker-oryx/auth'; -import { StorageService } from '@spryker-oryx/core'; -import { - createInjector, - destroyInjector, - Injector, - Provider, -} from '@spryker-oryx/di'; -import { of } from 'rxjs'; -import { beforeEach, describe } from 'vitest'; -import { - WarehouseUserAssignment, - warehouseUserAssignmentStorageKey, -} from '../models'; -import { WarehouseUserAssignmentsAdapter } from './adapter'; -import { WarehouseUserAssignmentsDefaultService } from './warehouse-user-assignments-default.service'; -import { WarehouseUserAssignmentsService } from './warehouse-user-assignments.service'; - -const mockWarehouseUserAssignment: WarehouseUserAssignment = { - id: 'id1', - userUuid: 'userUuid1', - warehouse: { - uuid: 'warehouseUuid1', - name: 'Warehouse 1', - isActive: true, - }, - isActive: true, -}; - -class MockWarehouseUserAssignmentsAdapter - implements Partial -{ - getList = vi.fn().mockReturnValue(of([mockWarehouseUserAssignment])); - activateAssignment = vi.fn().mockReturnValue(of(mockWarehouseUserAssignment)); -} - -class MockStorageService implements Partial { - get = vi.fn().mockReturnValue(of(undefined)); - set = vi.fn().mockReturnValue(of(undefined)); - remove = vi.fn().mockReturnValue(of(undefined)); -} - -describe('WarehouseUserAssignmentsDefaultService', () => { - const callback = vi.fn(); - const commonProviders: Provider[] = [ - { - provide: WarehouseUserAssignmentsService, - useClass: WarehouseUserAssignmentsDefaultService, - }, - { - provide: WarehouseUserAssignmentsAdapter, - useClass: MockWarehouseUserAssignmentsAdapter, - }, - { - provide: StorageService, - useClass: MockStorageService, - }, - ]; - - let service: WarehouseUserAssignmentsService; - let adapter: MockWarehouseUserAssignmentsAdapter; - let storageService: MockStorageService; - let testInjector: Injector; - - const injectMocks = (providers: Provider[]) => { - testInjector = createInjector({ - providers, - }); - - service = testInjector.inject(WarehouseUserAssignmentsService); - adapter = testInjector.inject( - WarehouseUserAssignmentsAdapter - ) as MockWarehouseUserAssignmentsAdapter; - storageService = testInjector.inject(StorageService); - }; - - afterEach(() => { - vi.clearAllMocks(); - destroyInjector(); - }); - - describe('when user is not authenticated', () => { - class MockAuthService implements Partial { - isAuthenticated = vi.fn().mockReturnValue(of(false)); - } - - beforeEach(() => { - injectMocks([ - ...commonProviders, - { - provide: AuthService, - useClass: MockAuthService, - }, - ]); - }); - - it('should remove warehouse assignment from storage', () => { - expect(storageService.remove).toHaveBeenCalled(); - }); - }); - - describe('when user is authenticated', () => { - class MockAuthService implements Partial { - isAuthenticated = vi.fn().mockReturnValue(of(true)); - } - - beforeEach(() => { - injectMocks([ - ...commonProviders, - { - provide: AuthService, - useClass: MockAuthService, - }, - ]); - }); - - it('should not remove warehouse assignment from storage', () => { - expect(storageService.remove).not.toHaveBeenCalledWith( - warehouseUserAssignmentStorageKey - ); - }); - - describe('when "getList" method is called', () => { - beforeEach(() => { - service.getList().subscribe(callback); - }); - - it('should call the "getList" method of the adapter', () => { - expect(adapter.getList).toHaveBeenCalled(); - }); - - it('should get the list of warehouse user assignments', () => { - expect(callback).toHaveBeenCalledWith([mockWarehouseUserAssignment]); - }); - }); - - describe('when "getUserAssignment" method is called', () => { - beforeEach(() => { - service.getUserAssignment().subscribe(callback); - }); - - it('should call the "get" method of the storage service', () => { - expect(storageService.get).toHaveBeenCalledWith( - warehouseUserAssignmentStorageKey - ); - }); - }); - - describe('when "activateAssignment" method is called', () => { - beforeEach(() => { - service - .activateAssignment(mockWarehouseUserAssignment.id) - .subscribe(callback); - }); - - it('should call the "activateAssignment" method of the adapter', () => { - expect(adapter.activateAssignment).toHaveBeenCalledWith( - mockWarehouseUserAssignment.id - ); - }); - - it('should get updated warehouse user assignment', () => { - expect(callback).toHaveBeenCalledWith(mockWarehouseUserAssignment); - }); - - it('should set assignment in storage', () => { - expect(storageService.set).toHaveBeenCalledWith( - warehouseUserAssignmentStorageKey, - mockWarehouseUserAssignment - ); - }); - }); - - describe('when "activateAssignment" method is called with incorrect data', () => { - beforeEach(() => { - adapter.activateAssignment.mockReturnValue( - of({ - ...mockWarehouseUserAssignment, - isActive: false, - }) - ); - - service - .activateAssignment(mockWarehouseUserAssignment.id) - .subscribe({ error: callback }); - }); - - it('should throw error if warehouse is not assigned', () => { - expect(callback).toHaveBeenCalledWith( - new Error( - 'WarehouseUserAssignmentsService: Warehouse is not assigned!' - ) - ); - }); - }); - }); -}); diff --git a/libs/domain/picking/services/src/services/warehouse-user-assignments-default.service.ts b/libs/domain/picking/services/src/services/warehouse-user-assignments-default.service.ts deleted file mode 100644 index 76ad21824..000000000 --- a/libs/domain/picking/services/src/services/warehouse-user-assignments-default.service.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { AuthService } from '@spryker-oryx/auth'; -import { StorageService } from '@spryker-oryx/core'; -import { inject } from '@spryker-oryx/di'; -import { Observable, tap } from 'rxjs'; -import { - WarehouseUserAssignment, - warehouseUserAssignmentStorageKey, -} from '../models/warehouse-user-assignment'; -import { WarehouseUserAssignmentsAdapter } from './adapter'; -import { WarehouseUserAssignmentsService } from './warehouse-user-assignments.service'; - -export class WarehouseUserAssignmentsDefaultService - implements WarehouseUserAssignmentsService -{ - constructor( - protected adapter = inject(WarehouseUserAssignmentsAdapter), - protected storageService = inject(StorageService), - protected authService = inject(AuthService) - ) { - authService.isAuthenticated().subscribe((isAuthenticated) => { - if (!isAuthenticated) { - this.storageService.remove(warehouseUserAssignmentStorageKey); - } - }); - } - - getList(): Observable { - return this.adapter.getList(); - } - - getUserAssignment(): Observable { - return this.storageService.get(warehouseUserAssignmentStorageKey); - } - - activateAssignment( - assignmentId: string - ): Observable { - return this.adapter.activateAssignment(assignmentId).pipe( - tap((assignment) => { - if (!assignment.isActive) { - throw new Error( - 'WarehouseUserAssignmentsService: Warehouse is not assigned!' - ); - } - - this.storageService.set(warehouseUserAssignmentStorageKey, assignment); - }) - ); - } -} diff --git a/libs/domain/picking/services/src/services/warehouse-user-assignments.service.ts b/libs/domain/picking/services/src/services/warehouse-user-assignments.service.ts deleted file mode 100644 index 863c38692..000000000 --- a/libs/domain/picking/services/src/services/warehouse-user-assignments.service.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Observable } from 'rxjs'; -import { WarehouseUserAssignment } from '../models/warehouse-user-assignment'; - -export interface WarehouseUserAssignmentsService { - getList(): Observable; - getUserAssignment(): Observable; - activateAssignment(assignmentId: string): Observable; -} - -export const WarehouseUserAssignmentsService = - 'oryx.WarehouseUserAssignmentsService'; - -declare global { - export interface InjectionTokensContractMap { - [WarehouseUserAssignmentsService]: WarehouseUserAssignmentsService; - } -} diff --git a/libs/domain/picking/src/components.ts b/libs/domain/picking/src/components.ts deleted file mode 100644 index 7dc85038b..000000000 --- a/libs/domain/picking/src/components.ts +++ /dev/null @@ -1,14 +0,0 @@ -export * from '../customer-note-modal/customer-note-modal.def'; -export * from '../customer-note/customer-note.def'; -export * from '../discard-modal/discard-modal.def'; -export * from '../filter-button/filter-button.def'; -export * from '../filters/filters.def'; -export * from '../list-item/list-item.def'; -export * from '../lists/lists.def'; -export * from '../order-reference/order-reference.def'; -export * from '../picker/picker.def'; -export * from '../picking-in-progress/picking-in-progress.def'; -export * from '../product-card/product-card.def'; -export * from '../search/search.def'; -export * from '../user-profile/user-profile.def'; -export * from '../warehouse-assignment/warehouse-assignment.def'; diff --git a/libs/domain/picking/src/config.provider.ts b/libs/domain/picking/src/config.provider.ts deleted file mode 100644 index 640deae04..000000000 --- a/libs/domain/picking/src/config.provider.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Provider } from '@spryker-oryx/di'; - -export interface PickingConfig { - appVersion?: string; -} - -export const PickingConfig = 'oryx.PickingConfig'; - -declare global { - interface InjectionTokensContractMap { - [PickingConfig]: PickingConfig; - } -} - -export function providePickingConfig(config?: PickingConfig): Provider[] { - if (!config) { - return []; - } - - return [{ provide: PickingConfig, useValue: config }]; -} diff --git a/libs/domain/picking/src/feature.ts b/libs/domain/picking/src/feature.ts deleted file mode 100644 index 21b3cc59a..000000000 --- a/libs/domain/picking/src/feature.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { Provider } from '@spryker-oryx/di'; -import { DefaultLocaleAdapter, LocaleAdapter } from '@spryker-oryx/i18n'; -import { PickingServicesFeature } from '@spryker-oryx/picking/services'; -import { provideLitRoutes } from '@spryker-oryx/router/lit'; -import { ComponentsInfo } from '@spryker-oryx/utilities'; -import { - pickingCustomerNoteComponent, - pickingCustomerNoteModalComponent, - pickingDiscardModalComponent, - pickingFilterButtonComponent, - pickingFiltersComponent, - pickingInProgressModalComponent, - pickingListItemComponent, - pickingListsComponent, - pickingOrderReferenceComponent, - pickingPickerComponent, - pickingProductCardComponent, - pickingSearchComponent, - pickingUserProfileComponent, - pickingWarehouseAssignmentComponent, -} from './components'; -import { PickingConfig, providePickingConfig } from './config.provider'; -import { PickingListContextFallback } from './picking-list.context'; -import { defaultPickingRoutes } from './routes'; -import { PickingGuardDefaultService, PickingGuardService } from './services'; - -export const pickingComponents = [ - pickingCustomerNoteComponent, - pickingCustomerNoteModalComponent, - pickingDiscardModalComponent, - pickingFilterButtonComponent, - pickingFiltersComponent, - pickingListsComponent, - pickingSearchComponent, - pickingListItemComponent, - pickingProductCardComponent, - pickingInProgressModalComponent, - pickingPickerComponent, - pickingUserProfileComponent, - pickingWarehouseAssignmentComponent, - pickingOrderReferenceComponent, -]; - -export interface PickingFeatureConfig extends PickingConfig { - noDefaultRoutes?: boolean; -} - -export class PickingFeature extends PickingServicesFeature { - providers: Provider[]; - components: ComponentsInfo; - - constructor(config?: PickingFeatureConfig) { - super(); - this.providers = this.getProviders(config); - this.components = pickingComponents; - } - - protected override getProviders(config?: PickingFeatureConfig): Provider[] { - return [ - ...provideLitRoutes( - !config?.noDefaultRoutes ? { routes: defaultPickingRoutes } : undefined - ), - ...providePickingConfig(config), - { - provide: PickingGuardService, - useClass: PickingGuardDefaultService, - }, - //override SapiLocaleAdapter that is provided by siteFeature with default one - //to eliminate unnecessary request to the store endpoint - //was implemented in https://spryker.atlassian.net/browse/HRZ-89955 - { - provide: LocaleAdapter, - useClass: DefaultLocaleAdapter, - }, - PickingListContextFallback, - ...super.getProviders(), - ]; - } -} diff --git a/libs/domain/picking/src/index.ts b/libs/domain/picking/src/index.ts deleted file mode 100644 index a13755a2a..000000000 --- a/libs/domain/picking/src/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './components'; -export * from './config.provider'; -export * from './feature'; -export * from './mixins'; -export * from './models'; -export * from './picking-list.context'; -export * from './services'; diff --git a/libs/domain/picking/src/mixins/index.ts b/libs/domain/picking/src/mixins/index.ts deleted file mode 100644 index a83ef48a3..000000000 --- a/libs/domain/picking/src/mixins/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './picking-list.mixin'; diff --git a/libs/domain/picking/src/mixins/picking-list.mixin.ts b/libs/domain/picking/src/mixins/picking-list.mixin.ts deleted file mode 100644 index 13889392d..000000000 --- a/libs/domain/picking/src/mixins/picking-list.mixin.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { ContextController } from '@spryker-oryx/core'; -import { resolve } from '@spryker-oryx/di'; -import { PickingListContext } from '@spryker-oryx/picking'; -import { - PickingList, - PickingListService, -} from '@spryker-oryx/picking/services'; -import { - Signal, - Type, - computed, - signal, - signalAware, - signalProperty, -} from '@spryker-oryx/utilities'; -import { LitElement } from 'lit'; -import { Observable, of } from 'rxjs'; - -export declare class PickingListMixinInterface { - pickingListId?: string; - protected context: Observable; - protected pickingListService: PickingListService; - protected $pickingList: Signal; - protected $upcomingPickingListId: Signal; -} - -export const PickingListMixin = >( - superClass: T -): Type & T => { - @signalAware() - class PickingListMixinClass extends superClass { - @signalProperty({ reflect: true }) pickingListId?: string; - - protected pickingListService = resolve(PickingListService); - - protected contextController = new ContextController(this); - protected $context = signal( - this.contextController.get(PickingListContext.PickingListId) - ); - - protected $pickingList = computed(() => { - const id = this.pickingListId ?? this.$context(); - - return id ? this.pickingListService.getList(id) : of(null); - }); - - protected $upcomingPickingListId = signal( - this.pickingListService.getUpcomingPickingListId() - ); - } - - return PickingListMixinClass as unknown as Type & - T; -}; diff --git a/libs/domain/picking/src/models/index.ts b/libs/domain/picking/src/models/index.ts deleted file mode 100644 index e568bc4e1..000000000 --- a/libs/domain/picking/src/models/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './picking-component.model'; -export * from './picking.model'; diff --git a/libs/domain/picking/src/models/picking-component.model.ts b/libs/domain/picking/src/models/picking-component.model.ts deleted file mode 100644 index 09a29d7e8..000000000 --- a/libs/domain/picking/src/models/picking-component.model.ts +++ /dev/null @@ -1,11 +0,0 @@ -export interface PickingListComponentProperties { - pickingListId?: string; -} - -export interface ProductItemPickedEvent { - productId: string; - numberOfPicked?: number; -} - -export const EVENT_SUBMIT = 'oryx.submit'; -export const EVENT_EDIT = 'oryx.edit'; diff --git a/libs/domain/picking/src/models/picking.model.ts b/libs/domain/picking/src/models/picking.model.ts deleted file mode 100644 index 250290aa6..000000000 --- a/libs/domain/picking/src/models/picking.model.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { ItemsFilters, PickingListItem } from '@spryker-oryx/picking/services'; - -export interface PickingTab { - id: ItemsFilters; - title: string; - items: PickingListItem[]; -} - -export interface PartialPicking { - productId: string; - currentNumberOfPicked?: number; - quantity?: number; -} - -export enum FallbackType { - noResults = 'no-orders', - noSearchingResults = 'no-search-results', - noValueProvided = 'searching', -} diff --git a/libs/domain/picking/src/picking-list.context.ts b/libs/domain/picking/src/picking-list.context.ts deleted file mode 100644 index 5064fd6f4..000000000 --- a/libs/domain/picking/src/picking-list.context.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { ContextFallback } from '@spryker-oryx/core'; -import { inject, Provider } from '@spryker-oryx/di'; -import { RouterService } from '@spryker-oryx/router'; -import { map } from 'rxjs'; - -export const enum PickingListContext { - PickingListId = 'pickingListId', -} - -export const PickingListContextFallback: Provider = { - provide: `${ContextFallback}${PickingListContext.PickingListId}`, - useFactory: () => - inject(RouterService) - .currentParams() - .pipe(map((params) => params?.pickingListId)), -}; diff --git a/libs/domain/picking/src/routes.ts b/libs/domain/picking/src/routes.ts deleted file mode 100644 index 063e7ee08..000000000 --- a/libs/domain/picking/src/routes.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { resolve } from '@spryker-oryx/di'; -import { RouteConfig } from '@spryker-oryx/router/lit'; -import { html } from 'lit'; -import { Observable, map, of, take } from 'rxjs'; -import { PickingGuardService } from './services'; - -export const defaultPickingRoutes: RouteConfig[] = [ - { - path: '/', - render: () => - html``, - }, - { - path: '/warehouse-selection', - render: () => - html``, - }, - { - path: '/picking-list/picking/:pickingListId', - render: () => - html``, - enter: (): Observable => { - resolve(PickingGuardService).guard(); - return of(true); - }, - leave: (): Observable => { - return resolve(PickingGuardService) - .isProtected() - .pipe( - take(1), - map((isProtected) => !isProtected) - ); - }, - }, - { - path: '/customer-note-info/:pickingListId', - render: () => - html``, - }, -]; diff --git a/libs/domain/picking/src/services/index.ts b/libs/domain/picking/src/services/index.ts deleted file mode 100644 index f8b1f4312..000000000 --- a/libs/domain/picking/src/services/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './picking-guard-default.service'; -export * from './picking-guard.service'; diff --git a/libs/domain/picking/src/services/picking-guard-default.service.ts b/libs/domain/picking/src/services/picking-guard-default.service.ts deleted file mode 100644 index 6db9e16de..000000000 --- a/libs/domain/picking/src/services/picking-guard-default.service.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { BehaviorSubject, Observable } from 'rxjs'; -import { PickingGuardService } from './picking-guard.service'; - -export class PickingGuardDefaultService implements PickingGuardService { - protected guard$ = new BehaviorSubject(false); - - guard(): void { - this.guard$.next(true); - } - - isProtected(): Observable { - return this.guard$; - } - - allow(): void { - this.guard$.next(false); - } -} diff --git a/libs/domain/picking/src/services/picking-guard.service.ts b/libs/domain/picking/src/services/picking-guard.service.ts deleted file mode 100644 index ac78901d4..000000000 --- a/libs/domain/picking/src/services/picking-guard.service.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Observable } from 'rxjs'; - -export interface PickingGuardService { - guard(): void; - isProtected(): Observable; - allow(): void; -} - -export const PickingGuardService = 'oryx.PickingGuardService'; - -declare global { - export interface InjectionTokensContractMap { - [PickingGuardService]: PickingGuardService; - } -} diff --git a/libs/domain/picking/src/utilities.spec.ts b/libs/domain/picking/src/utilities.spec.ts deleted file mode 100644 index b2ff90e50..000000000 --- a/libs/domain/picking/src/utilities.spec.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { formatTime } from './utilities'; - -describe('Utilities', () => { - describe('formatTime', () => { - it('should return correct time', () => { - expect(formatTime(new Date('2023-03-21 14:31:44'))).toBe('02:31 pm'); - }); - }); -}); diff --git a/libs/domain/picking/src/utilities.ts b/libs/domain/picking/src/utilities.ts deleted file mode 100644 index 39377fcba..000000000 --- a/libs/domain/picking/src/utilities.ts +++ /dev/null @@ -1,9 +0,0 @@ -export const formatTime = (time: Date): string => { - return time - .toLocaleString('en-US', { - hour: '2-digit', - minute: '2-digit', - hour12: true, - }) - .toLowerCase(); -}; diff --git a/libs/domain/picking/tsconfig.lib.json b/libs/domain/picking/tsconfig.lib.json deleted file mode 100644 index 17f6f12f1..000000000 --- a/libs/domain/picking/tsconfig.lib.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.lib.json", - "include": ["**/*.ts"] -} diff --git a/libs/domain/picking/tsconfig.spec.json b/libs/domain/picking/tsconfig.spec.json deleted file mode 100644 index 3a00f26c7..000000000 --- a/libs/domain/picking/tsconfig.spec.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.spec.json", - "include": ["**/*.spec.ts"] -} diff --git a/libs/domain/picking/user-profile/index.ts b/libs/domain/picking/user-profile/index.ts deleted file mode 100644 index fa0cb9355..000000000 --- a/libs/domain/picking/user-profile/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './user-profile.component'; -export * from './user-profile.styles'; diff --git a/libs/domain/picking/user-profile/stories/demo.stories.ts b/libs/domain/picking/user-profile/stories/demo.stories.ts deleted file mode 100644 index 1a3e575d9..000000000 --- a/libs/domain/picking/user-profile/stories/demo.stories.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { - OverlaysDecorator, - storybookDefaultViewports, -} from '@/tools/storybook'; -import { Meta, Story } from '@storybook/web-components'; -import { TemplateResult, html } from 'lit'; -import { storybookPrefix } from '../../.constants'; - -export default { - title: `${storybookPrefix}/User Profile`, - decorators: [OverlaysDecorator(320, 568)], - parameters: { - chromatic: { - viewports: [storybookDefaultViewports.mobile.min], - }, - }, -} as Meta; - -const Template: Story = (): TemplateResult => { - return html``; -}; - -export const Demo = Template.bind({}); diff --git a/libs/domain/picking/user-profile/user-profile.component.spec.ts b/libs/domain/picking/user-profile/user-profile.component.spec.ts deleted file mode 100644 index 5edd3b057..000000000 --- a/libs/domain/picking/user-profile/user-profile.component.spec.ts +++ /dev/null @@ -1,329 +0,0 @@ -import { fixture } from '@open-wc/testing-helpers'; -import { AuthService, IdentityService } from '@spryker-oryx/auth'; -import { App, AppRef, StorageService } from '@spryker-oryx/core'; -import { createInjector, destroyInjector } from '@spryker-oryx/di'; -import { NetworkStateService } from '@spryker-oryx/offline'; -import { SyncSchedulerService } from '@spryker-oryx/offline/sync'; -import { RouterService } from '@spryker-oryx/router'; -import { i18n, nextTick, useComponent } from '@spryker-oryx/utilities'; -import { html } from 'lit'; -import { catchError, of, switchMap, throwError } from 'rxjs'; -import { PickingUserProfileComponent } from './user-profile.component'; -import { pickingUserProfileComponent } from './user-profile.def'; - -const mockOfflineDataPlugin = { - syncData: vi.fn().mockReturnValue( - of(undefined).pipe( - switchMap(async () => { - await nextTick(2); - return of(undefined); - }) - ) - ), -}; - -class MockApp implements Partial { - requirePlugin = vi.fn().mockReturnValue(mockOfflineDataPlugin); -} - -class MockSyncSchedulerService implements Partial { - hasPending = vi.fn().mockReturnValue(of(false)); -} - -class MockRouterService implements Partial { - route = vi.fn().mockReturnValue(of('')); - navigate = vi.fn(); -} - -class MockAuthService implements Partial { - logout = vi.fn().mockReturnValue(of(undefined)); -} - -class MockStorageService implements Partial { - get = vi.fn().mockReturnValue(of(undefined)); -} - -class MockNetworkStateService implements Partial { - online = vi.fn().mockReturnValue(of(true)); -} - -class MockIdentityService implements IdentityService { - get = vi.fn().mockReturnValue(of({})); -} - -describe('PickingUserProfileComponent', () => { - let element: PickingUserProfileComponent; - let routerService: MockRouterService; - let syncSchedulerService: MockSyncSchedulerService; - let authService: MockAuthService; - let storageService: MockStorageService; - let networkService: MockNetworkStateService; - - beforeAll(async () => { - await useComponent(pickingUserProfileComponent); - }); - - beforeEach(async () => { - const testInjector = createInjector({ - providers: [ - { - provide: AppRef, - useClass: MockApp, - }, - { - provide: RouterService, - useClass: MockRouterService, - }, - { - provide: SyncSchedulerService, - useClass: MockSyncSchedulerService, - }, - { - provide: AuthService, - useClass: MockAuthService, - }, - { - provide: StorageService, - useClass: MockStorageService, - }, - { - provide: NetworkStateService, - useClass: MockNetworkStateService, - }, - { - provide: IdentityService, - useClass: MockIdentityService, - }, - ], - }); - - routerService = testInjector.inject(RouterService); - syncSchedulerService = - testInjector.inject(SyncSchedulerService); - authService = testInjector.inject(AuthService); - storageService = testInjector.inject(StorageService); - networkService = - testInjector.inject(NetworkStateService); - - element = await fixture( - html`` - ); - }); - - afterEach(() => { - destroyInjector(); - vi.clearAllMocks(); - }); - - it('passes the a11y audit', async () => { - await expect(element).shadowDom.to.be.accessible(); - }); - - it('should be provided', () => { - expect(element).toBeInstanceOf(PickingUserProfileComponent); - }); - - it('should render its components', () => { - expect(element.renderRoot.querySelector('.info-block')).not.toBeNull(); - expect( - element.renderRoot.querySelector('.info-footer oryx-button') - ).not.toBeNull(); - }); - - it('should not render warehouse location', () => { - element.renderRoot.querySelectorAll('dl').forEach((item) => { - expect(item.querySelector('dt')?.textContent).not.toContain( - i18n('user.profile.location') - ); - }); - }); - - describe('when sync is pending', () => { - beforeEach(async () => { - syncSchedulerService.hasPending.mockReturnValue(of(true)); - - element = await fixture( - html`` - ); - }); - - it('should render oryx notification', () => { - const notification = - element.renderRoot.querySelector('oryx-notification')?.textContent; - expect(notification).toContain( - "You can't log out because of a pending synchronization" - ); - }); - - it('should disable log out button', () => { - const button = element.renderRoot.querySelector( - 'oryx-button.logout-button' - ); - expect(button).toHaveProperty('text', 'Log out'); - expect(button?.hasAttribute('disabled')).toBe(true); - }); - }); - - describe('when sync is not pending and picking is not in progress', () => { - it('should not disable log out button', () => { - const button = element.renderRoot.querySelector( - 'oryx-button.logout-button' - ); - expect(button).toHaveProperty('text', 'Log out'); - expect(button?.hasAttribute('disabled')).toBe(false); - }); - - describe('and when log out button is clicked', () => { - beforeEach(() => { - element.renderRoot.querySelector('oryx-button')?.click(); - }); - - it('should show loading indicator', () => { - const button = element.renderRoot.querySelector( - 'oryx-button.logout-button' - ); - expect(button).toHaveProperty('text', 'Log out'); - expect(button?.hasAttribute('loading')).toBe(true); - }); - - it('should call auth service', () => { - expect(authService.logout).toHaveBeenCalled(); - }); - - describe('and when log out fails', () => { - beforeEach(() => { - authService.logout.mockReturnValue( - throwError(() => new Error('error')) - ); - element.renderRoot - .querySelector('.logout-button') - ?.click(); - }); - - it('should not show loading indicator', () => { - const button = element.renderRoot.querySelector('.logout-button'); - expect(button).toHaveProperty('text', 'Log out'); - expect(button?.hasAttribute('loading')).toBe(false); - }); - - it('auth service should throw error', () => { - const callback = vi.fn().mockReturnValue(of('')); - authService.logout().pipe(catchError(callback)).subscribe(); - - expect(callback).toHaveBeenCalled(); - }); - }); - }); - }); - - describe('when user is on the main page', () => { - beforeEach(async () => { - routerService.route = vi.fn().mockReturnValue(of('/')); - - element = await fixture( - html`` - ); - }); - - it('should render not disabled sync data button', () => { - expect(element).toContainElement('.sync-data:not([disabled])'); - }); - - describe('and the receive data button is clicked', () => { - beforeEach(() => { - element.renderRoot.querySelector('.sync-data')?.click(); - }); - - it('should call offline data plugin', () => { - expect(mockOfflineDataPlugin.syncData).toHaveBeenCalled(); - }); - - it('should render loading indicator', async () => { - const button = element.renderRoot.querySelector('.sync-data'); - expect(button).toHaveProperty('text', 'Sync data'); - expect(button?.hasAttribute('loading')).toBe(true); - }); - - describe('and receive data completes', () => { - beforeEach(async () => { - mockOfflineDataPlugin.syncData.mockReturnValue(of(undefined)); - - element = await fixture( - html`` - ); - element.renderRoot - .querySelector('oryx-button.received-data') - ?.click(); - }); - - it('should not show loading indicator', () => { - const button = element.renderRoot.querySelector('.sync-data'); - expect(button).toHaveProperty('text', 'Sync data'); - expect(button?.hasAttribute('loading')).toBe(false); - }); - }); - }); - - describe('and network is in offline state', () => { - beforeEach(async () => { - networkService.online = vi.fn().mockReturnValue(of(false)); - - element = await fixture( - html`` - ); - }); - - it('should disable sync data button', () => { - expect(element).toContainElement('.sync-data[disabled]'); - }); - }); - }); - - describe('when picking is in progress', () => { - beforeEach(async () => { - routerService.route.mockReturnValue('/picking/'); - - element = await fixture( - html`` - ); - }); - - it('should render oryx notification', () => { - const notification = - element.renderRoot.querySelector('oryx-notification')?.textContent; - expect(notification).toContain('You can'); - expect(notification).toContain( - 't log out because picking is in progress' - ); - }); - - it('should disable log out button', () => { - const button = element.renderRoot.querySelectorAll('oryx-button')[0]; - expect(button).toHaveProperty('text', 'Log out'); - expect(button?.hasAttribute('disabled')).toBe(true); - }); - }); - - describe('when there is warehouseUserAssignment in the storage', () => { - const mockWarehouseName = 'mockWarehouseName'; - - beforeEach(async () => { - storageService.get = vi - .fn() - .mockReturnValue(of({ warehouse: { name: mockWarehouseName } })); - - element = await fixture( - html`` - ); - }); - - it('should render warehouse location', () => { - expect( - element.renderRoot.querySelectorAll('dl')[0].textContent - ).toContain(i18n('user.profile.location')); - expect( - element.renderRoot.querySelectorAll('dd')[0].textContent - ).toContain(mockWarehouseName); - }); - }); -}); diff --git a/libs/domain/picking/user-profile/user-profile.component.ts b/libs/domain/picking/user-profile/user-profile.component.ts deleted file mode 100644 index 1ebb2ac62..000000000 --- a/libs/domain/picking/user-profile/user-profile.component.ts +++ /dev/null @@ -1,158 +0,0 @@ -import { AuthService, IdentityService } from '@spryker-oryx/auth'; -import { AppRef, StorageService } from '@spryker-oryx/core'; -import { INJECTOR, resolve } from '@spryker-oryx/di'; -import { NetworkStateService } from '@spryker-oryx/offline'; -import { SyncSchedulerService } from '@spryker-oryx/offline/sync'; -import { OfflineDataPlugin } from '@spryker-oryx/picking/offline'; -import { - WarehouseUserAssignment, - warehouseUserAssignmentStorageKey, -} from '@spryker-oryx/picking/services'; -import { RouterService } from '@spryker-oryx/router'; -import { ButtonColor, ButtonType } from '@spryker-oryx/ui/button'; -import { CLOSE_EVENT, CLOSE_MODAL_EVENT } from '@spryker-oryx/ui/modal'; -import { - ConnectableSignal, - I18nMixin, - computed, - featureVersion, - signal, - signalAware, -} from '@spryker-oryx/utilities'; -import { LitElement, TemplateResult, html } from 'lit'; -import { state } from 'lit/decorators.js'; -import { when } from 'lit/directives/when.js'; -import { tap } from 'rxjs'; -import { userProfileComponentStyles } from './user-profile.styles'; - -@signalAware() -export class PickingUserProfileComponent extends I18nMixin(LitElement) { - static styles = userProfileComponentStyles; - - protected routerService = resolve(RouterService); - protected authService = resolve(AuthService); - protected storageService = resolve(StorageService); - protected identityService = resolve(IdentityService); - protected networkStateService = resolve(NetworkStateService); - - protected injector = resolve(INJECTOR); - protected injectorDataPlugin = - resolve(AppRef).requirePlugin(OfflineDataPlugin); - - @state() - protected loading: boolean | null = null; - - @state() - protected logoutLoading = false; - - protected $location: ConnectableSignal = - signal(this.storageService.get(warehouseUserAssignmentStorageKey)); - protected $route = signal(this.routerService.route()); - protected $pendingSyncs = signal(resolve(SyncSchedulerService).hasPending()); - protected $isPicking = computed(() => this.$route()?.includes('/picking/')); - protected $isMainPage = computed(() => this.$route() === '/'); - protected $pickingInProgress = computed(() => - this.i18n("user.profile.you-can't-log-out-because-picking-is-in-progress") - ); - protected $pendingSync = computed(() => - this.i18n( - "user.profile.you-can't-log-out-because-of-a-pending-synchronization" - ) - ); - protected $isOnline = signal(this.networkStateService.online()); - - protected $identity = signal(this.identityService.get()); - - protected override render(): TemplateResult { - return html` -
- ${when( - this.$location(), - () => html` -
-
${this.i18n('user.profile.location')}
-
${this.$location()?.warehouse.name}
-
- ` - )} -
-
${this.i18n('user.profile.employee-id')}
-
- ${this.$identity().userId ?? - this.i18n('user.profile.unknown-user-id')} -
-
-
- - ${when( - this.$pendingSyncs() || this.$isPicking(), - () => - html` - - ${this.$isPicking() - ? this.$pickingInProgress() - : this.$pendingSync()} - - ` - )} - - - - - `; - } - - protected onSyncData(): void { - this.loading = true; - - this.injectorDataPlugin - .syncData(this.injector) - .pipe(tap(() => (this.loading = false))) - .subscribe(() => { - const event = featureVersion >= '1.4' ? CLOSE_MODAL_EVENT : CLOSE_EVENT; - this.dispatchEvent( - new CustomEvent(event, { - bubbles: true, - composed: true, - }) - ); - }); - } - - protected onLogOut(): void { - this.logoutLoading = true; - this.authService.logout().subscribe({ - error: (e) => { - this.logoutLoading = false; - }, - }); - } -} diff --git a/libs/domain/picking/user-profile/user-profile.def.ts b/libs/domain/picking/user-profile/user-profile.def.ts deleted file mode 100644 index e2bdfe60f..000000000 --- a/libs/domain/picking/user-profile/user-profile.def.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { componentDef } from '@spryker-oryx/utilities'; - -export const pickingUserProfileComponent = componentDef({ - name: 'oryx-picking-user-profile', - impl: () => - import('./user-profile.component').then( - (m) => m.PickingUserProfileComponent - ), -}); diff --git a/libs/domain/picking/user-profile/user-profile.styles.ts b/libs/domain/picking/user-profile/user-profile.styles.ts deleted file mode 100644 index 86054fc21..000000000 --- a/libs/domain/picking/user-profile/user-profile.styles.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { css } from 'lit'; - -export const userProfileComponentStyles = css` - :host { - display: flex; - flex-direction: column; - height: 100%; - } - - .info-block { - flex-grow: 1; - } - - .info-label { - font-size: 12px; - font-weight: 400; - line-height: 16px; - text-transform: uppercase; - } - - .info-value { - margin-block-start: 6px; - margin-inline-start: 0; - font-weight: 500; - font-size: 16px; - line-height: 22px; - } - - .info-footer { - display: grid; - gap: 10px; - } - - oryx-notification { - margin-block-end: 10px; - } -`; diff --git a/libs/domain/picking/vitest.config.ts b/libs/domain/picking/vitest.config.ts deleted file mode 100644 index 9eee1bada..000000000 --- a/libs/domain/picking/vitest.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -import config from '../../vitest.config'; - -export default config; diff --git a/libs/domain/picking/warehouse-assignment/index.ts b/libs/domain/picking/warehouse-assignment/index.ts deleted file mode 100644 index e8094e56a..000000000 --- a/libs/domain/picking/warehouse-assignment/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './warehouse-assignment.component'; -export * from './warehouse-assignment.styles'; diff --git a/libs/domain/picking/warehouse-assignment/stories/demo.stories.ts b/libs/domain/picking/warehouse-assignment/stories/demo.stories.ts deleted file mode 100644 index b7db6c9a1..000000000 --- a/libs/domain/picking/warehouse-assignment/stories/demo.stories.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { storybookDefaultViewports } from '@/tools/storybook'; -import { Meta, Story } from '@storybook/web-components'; -import { html } from 'lit'; -import { TemplateResult } from 'lit/development'; -import { storybookPrefix } from '../../.constants'; - -export default { - title: `${storybookPrefix}/Warehouse assignment`, - parameters: { - layout: 'fullscreen', - chromatic: { - viewports: [storybookDefaultViewports.mobile.min], - }, - }, -} as Meta; - -const Template: Story = (): TemplateResult => { - return html` - - `; -}; - -export const Demo = Template.bind({}); diff --git a/libs/domain/picking/warehouse-assignment/warehouse-assignment.component.spec.ts b/libs/domain/picking/warehouse-assignment/warehouse-assignment.component.spec.ts deleted file mode 100644 index 73d3b349c..000000000 --- a/libs/domain/picking/warehouse-assignment/warehouse-assignment.component.spec.ts +++ /dev/null @@ -1,172 +0,0 @@ -import { fixture } from '@open-wc/testing-helpers'; -import { App, AppRef } from '@spryker-oryx/core'; -import { createInjector, destroyInjector } from '@spryker-oryx/di'; -import { pickingWarehouseAssignmentComponent } from '@spryker-oryx/picking'; -import { mockWarehouseUserAssignments } from '@spryker-oryx/picking/mocks'; -import { WarehouseUserAssignmentsService } from '@spryker-oryx/picking/services'; -import { RouterService } from '@spryker-oryx/router'; -import { ButtonComponent } from '@spryker-oryx/ui/button'; -import { i18n, nextTick, useComponent } from '@spryker-oryx/utilities'; -import { html } from 'lit'; -import { of, switchMap } from 'rxjs'; -import { beforeEach, vi } from 'vitest'; -import { PickingWarehouseAssignmentComponent } from './warehouse-assignment.component'; - -const mockOfflineDataPlugin = { - syncData: vi.fn().mockReturnValue( - of(undefined).pipe( - switchMap(async () => { - await nextTick(2); - return of(undefined); - }) - ) - ), -}; - -class MockApp implements Partial { - requirePlugin = vi.fn().mockReturnValue(mockOfflineDataPlugin); -} - -class MockWarehouseUserAssignmentsService - implements Partial -{ - getList = vi.fn(); - activateAssignment = vi - .fn() - .mockReturnValue(of(mockWarehouseUserAssignments[0])); -} - -class MockRouterService implements Partial { - navigate = vi.fn(); -} - -describe('PickingWarehouseAssignmentComponent', () => { - let el: PickingWarehouseAssignmentComponent; - - let service: MockWarehouseUserAssignmentsService; - let routerService: RouterService; - - beforeAll(async () => { - await useComponent(pickingWarehouseAssignmentComponent); - }); - - beforeEach(async () => { - const testInjector = createInjector({ - providers: [ - { - provide: AppRef, - useClass: MockApp, - }, - { - provide: WarehouseUserAssignmentsService, - useClass: MockWarehouseUserAssignmentsService, - }, - { - provide: RouterService, - useClass: MockRouterService, - }, - ], - }); - - service = testInjector.inject( - WarehouseUserAssignmentsService - ); - routerService = testInjector.inject(RouterService); - }); - - afterEach(() => { - vi.clearAllMocks(); - destroyInjector(); - }); - - describe('when there is multiple warehouses', () => { - beforeEach(async () => { - service.getList.mockReturnValue(of(mockWarehouseUserAssignments)); - el = await fixture( - html`` - ); - }); - - it('should render name of each location', () => { - const headings = el.renderRoot.querySelectorAll('h3'); - expect(headings.length).toBe(mockWarehouseUserAssignments.length); - mockWarehouseUserAssignments.forEach((item, index) => { - expect(headings[index].textContent).toBe( - mockWarehouseUserAssignments[index].warehouse.name - ); - }); - }); - - mockWarehouseUserAssignments.forEach((item, index) => { - it(`should render button (${index}) of each location`, () => { - const buttons = - el.renderRoot.querySelectorAll('oryx-button'); - expect(buttons.length).toBe(mockWarehouseUserAssignments.length); - expect(buttons[index]).toHaveProperty('text', i18n('picking.select')); - }); - }); - - it('should not call "activateAssignment" and "navigate" methods initially', () => { - expect(service.activateAssignment).not.toHaveBeenCalled(); - expect(routerService.navigate).not.toHaveBeenCalled(); - }); - - describe('when "Select" button is clicked', () => { - beforeEach(() => { - el.renderRoot.querySelector('oryx-button')?.click(); - }); - - it('should call "activateAssignment" method', () => { - expect(service.activateAssignment).toHaveBeenCalledWith( - mockWarehouseUserAssignments[0].id - ); - }); - - it('should navigate to "/" route', () => { - expect(routerService.navigate).toHaveBeenCalledWith('/'); - }); - }); - }); - - describe('when there is only one warehouse to choose', () => { - beforeEach(async () => { - service.getList.mockReturnValue( - of(mockWarehouseUserAssignments.slice(0, 1)) - ); - el = await fixture( - html`` - ); - }); - - it('should call "activateAssignment" and not render any location ', () => { - const headings = el.renderRoot.querySelectorAll('h3'); - expect(headings.length).toBe(0); - - expect(service.activateAssignment).toHaveBeenCalledWith( - mockWarehouseUserAssignments[0].id - ); - }); - - it('should navigate to "/" route', () => { - expect(routerService.navigate).toHaveBeenCalledWith('/'); - }); - }); - - describe('when the list is empty', () => { - beforeEach(async () => { - service.getList.mockReturnValue( - of(mockWarehouseUserAssignments.slice(0, 0)) - ); - el = await fixture( - html`` - ); - }); - - it('should render fallback', () => { - expect(el).toContainElement('oryx-image'); - - const image = el.renderRoot.querySelector('oryx-image'); - expect(image?.hasAttribute('resource')).toBe(true); - }); - }); -}); diff --git a/libs/domain/picking/warehouse-assignment/warehouse-assignment.component.ts b/libs/domain/picking/warehouse-assignment/warehouse-assignment.component.ts deleted file mode 100644 index f5505277c..000000000 --- a/libs/domain/picking/warehouse-assignment/warehouse-assignment.component.ts +++ /dev/null @@ -1,154 +0,0 @@ -import { AppRef } from '@spryker-oryx/core'; -import { INJECTOR, resolve } from '@spryker-oryx/di'; -import { OfflineDataPlugin } from '@spryker-oryx/picking/offline'; -import { WarehouseUserAssignmentsService } from '@spryker-oryx/picking/services'; -import { RouterService } from '@spryker-oryx/router'; -import { ButtonSize } from '@spryker-oryx/ui/button'; -import { HeadingTag } from '@spryker-oryx/ui/heading'; -import { - featureVersion, - i18n, - signal, - signalAware, -} from '@spryker-oryx/utilities'; -import { LitElement, TemplateResult, html } from 'lit'; -import { repeat } from 'lit/directives/repeat.js'; -import { when } from 'lit/directives/when.js'; -import { switchMap } from 'rxjs'; -import { styles } from './warehouse-assignment.styles'; - -@signalAware() -export class PickingWarehouseAssignmentComponent extends LitElement { - static styles = styles; - - protected warehouseUserAssignmentsService = resolve( - WarehouseUserAssignmentsService - ); - - protected injector = resolve(INJECTOR); - protected injectorDataPlugin = - resolve(AppRef).requirePlugin(OfflineDataPlugin); - - protected routerService = resolve(RouterService); - - protected $locations = signal( - this.warehouseUserAssignmentsService.getList(), - { initialValue: null } - ); - - protected override render(): TemplateResult { - return html` - ${when( - this.$locations() === null || this.$locations()?.length === 1, - () => this.renderLoading(), - () => - html`${when( - this.$locations()?.length, - () => this.renderList(), - () => this.renderFallback() - )}` - )} - `; - } - - protected selectWarehouse(assignmentId: string): void { - this.warehouseUserAssignmentsService - .activateAssignment(assignmentId) - .pipe( - switchMap(() => { - this.routerService.navigate('/'); - return this.injectorDataPlugin.syncData(this.injector); - }) - ) - .subscribe(); - } - - protected renderFallback(): TemplateResult { - return html` -
- ${this.__renderFallbackHeading()} - - -
- `; - } - - // temporary implementation for backwards compatibility - private __renderFallbackHeading(): TemplateResult { - const text = html`${i18n('picking.location.unassigned')}. - ${i18n('picking.location.help')}`; - if (featureVersion >= '1.4') { - return html`${text}`; - } else { - return html`

${text}

`; - } - } - - protected renderList(): TemplateResult { - return html` -
- ${this.__renderListHeading()} - ${repeat( - this.$locations() || [], - (item) => item.id, - (item) => html` - ${this.__renderListItemHeading(item.warehouse.name)} - this.selectWarehouse(item.id)} - > -
- ` - )} -
- `; - } - - // temporary implementation for backwards compatibility - private __renderListHeading(): TemplateResult { - const text = i18n('picking.location.select'); - if (featureVersion >= '1.4') { - return html` - ${text} - `; - } else { - return html` -

${text}

-
`; - } - } - - // temporary implementation for backwards compatibility - private __renderListItemHeading(text: string): TemplateResult { - if (featureVersion >= '1.4') { - return html`${text}`; - } else { - return html` -

${text}

-
`; - } - } - - protected renderLoading(): TemplateResult { - const locations = this.$locations(); - if (locations?.length === 1) { - this.selectWarehouse(locations[0].id); - } - - return html` -
- ${i18n('picking.location.loading')} - -
- `; - } -} diff --git a/libs/domain/picking/warehouse-assignment/warehouse-assignment.def.ts b/libs/domain/picking/warehouse-assignment/warehouse-assignment.def.ts deleted file mode 100644 index 3970ac7a5..000000000 --- a/libs/domain/picking/warehouse-assignment/warehouse-assignment.def.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { componentDef } from '@spryker-oryx/utilities'; - -export const pickingWarehouseAssignmentComponent = componentDef({ - name: 'oryx-picking-warehouse-assignment', - impl: () => - import('./warehouse-assignment.component').then( - (m) => m.PickingWarehouseAssignmentComponent - ), -}); diff --git a/libs/domain/picking/warehouse-assignment/warehouse-assignment.styles.ts b/libs/domain/picking/warehouse-assignment/warehouse-assignment.styles.ts deleted file mode 100644 index d6ca41e23..000000000 --- a/libs/domain/picking/warehouse-assignment/warehouse-assignment.styles.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { HeadingTag, headingUtil } from '@spryker-oryx/ui/heading'; -import { featureVersion } from '@spryker-oryx/utilities'; -import { css, unsafeCSS } from 'lit'; - -export const styles = css` - :host { - display: block; - background: var(--oryx-color-neutral-3); - } - - .warehouses-list { - padding: 25px 30px; - } - - ${featureVersion >= '1.4' - ? unsafeCSS(` - .warehouses-list oryx-heading:first-child { - margin-block-end: 34px; - } - - .warehouses-list oryx-heading:not(:first-child) { - font-weight: 500; - line-height: 24px; - } - - .fallback oryx-heading { - width: 268px; - } - `) - : unsafeCSS(` - .warehouses-list h1 { - ${headingUtil(HeadingTag.H2)} - - font-weight: 600; - line-height: 24px; - padding-block-end: 34px; - } - - .warehouses-list h3 { - font-weight: 500; - line-height: 24px; - } - - .fallback h1 { - width: 268px; - } - `)} - - .warehouses-list oryx-button { - margin-block-start: 16px; - } - - .warehouses-list hr { - margin: 16px -30px; - height: 1px; - background-color: var(--oryx-color-neutral-5); - border: none; - } - - .warehouses-list hr:last-child { - display: none; - } - - .fallback { - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - text-align: center; - } - - .fallback oryx-image { - display: block; - } - - .loading { - display: flex; - justify-content: center; - align-items: center; - gap: 10px; - margin-block-start: 34px; - } - - .loading span { - font-weight: 600; - } - - .loading oryx-spinner { - display: inline-flex; - } -`; diff --git a/libs/lerna.json b/libs/lerna.json index b752276b9..6e1d7546f 100644 --- a/libs/lerna.json +++ b/libs/lerna.json @@ -15,7 +15,6 @@ "template/resources", "domain/product", "domain/order", - "domain/picking", "platform/router", "platform/indexed-db", "platform/offline", diff --git a/libs/platform/auth/src/bapi/feature.ts b/libs/platform/auth/src/bapi/feature.ts index 87acaa40b..1ac874587 100644 --- a/libs/platform/auth/src/bapi/feature.ts +++ b/libs/platform/auth/src/bapi/feature.ts @@ -9,7 +9,7 @@ import { oauthHandlerComponent, } from '@spryker-oryx/auth'; import { AuthLoginStrategy } from '@spryker-oryx/auth/login'; -import { AppFeature, AppPlugin, injectEnv } from '@spryker-oryx/core'; +import { AppFeature, AppPlugin } from '@spryker-oryx/core'; import { Provider } from '@spryker-oryx/di'; import { provideLitRoutes } from '@spryker-oryx/router/lit'; import { ComponentsInfo } from '@spryker-oryx/utilities'; @@ -34,13 +34,10 @@ export class BapiAuthFeature extends OauthFeature implements AppFeature { providers: [ { id: 'spryker', - clientId: injectEnv('ORYX_FULFILLMENT_CLIENT_ID') ?? 'frontend', + clientId: 'frontend', grantType: 'authorization_code', authUrl: new URL('/login', globalThis.location.origin).toString(), - tokenUrl: urlJoin( - injectEnv('ORYX_FULFILLMENT_BACKEND_URL') ?? '', - '/token' - ), + tokenUrl: urlJoin('', '/token'), redirectUrl: new URL( '/oauth/cb/spryker', globalThis.location.origin @@ -81,10 +78,7 @@ export class BapiAuthFeature extends OauthFeature implements AppFeature { provide: CodeGrantAuthLoginStrategyConfig, useFactory: () => ({ - loginUrl: urlJoin( - injectEnv('ORYX_FULFILLMENT_BACKEND_URL') ?? '', - '/authorize' - ), + loginUrl: urlJoin('', '/authorize'), } as CodeGrantAuthLoginStrategyConfig), }, ]; diff --git a/libs/template/cli/src/commands/create.ts b/libs/template/cli/src/commands/create.ts index 3b38a39b7..463a0e728 100644 --- a/libs/template/cli/src/commands/create.ts +++ b/libs/template/cli/src/commands/create.ts @@ -183,16 +183,8 @@ interface CreateAppConfig extends Required { export interface CreateAppOptions { name?: string; - options?: OryxOption[]; } export enum OryxTemplateRef { Latest = 'latest', } - -export enum OryxOption { - Labs = 'Labs', - Ssr = 'SSR', - Sw = 'service-worker', - Fa = 'fulfillment-application', -} diff --git a/libs/template/labs/src/i18n/translations/en.ts b/libs/template/labs/src/i18n/translations/en.ts index 52e82fd2c..38f01557f 100644 --- a/libs/template/labs/src/i18n/translations/en.ts +++ b/libs/template/labs/src/i18n/translations/en.ts @@ -59,23 +59,6 @@ const user = { 'Removing this address will not remove any pending orders being dispatched to this` address', }; -const picking = { - 'picking.product-card.of--items': - 'Of {count, plural, one {{count} item} other {{count} items}}', - 'picking.filter.-open-pick-lists': - '{count} Open Pick {count, plural, one {List} other {Lists}}', - 'picking.select-your-location': 'Select your location to get started', - 'picking.discard.pick-list': 'Discard pick list?', - 'picking.discard.stop-picking': 'Stop picking and discard pick list?', - 'picking.discard.warning': 'The pick list will be lost!', - 'picking.processed.success': 'Great job!', - 'picking.processed.all': 'All items are processed!', - 'picking.location.loading': 'Loading locations', - 'picking.location.unassigned': 'You are not assigned to any locations', - 'picking.location.help': 'Please reach out to your manager', - 'picking.location.select': 'Select your location', -}; - const ui = { 'ui.password.at-least--characters': 'At least {count, plural, one {{count} character} other {{count} characters}}', @@ -108,7 +91,6 @@ export default { ...checkout, ...order, ...user, - ...picking, ...ui, ...search, ...merchant, diff --git a/libs/template/presets/fulfillment-sw/app.ts b/libs/template/presets/fulfillment-sw/app.ts deleted file mode 100644 index 10d29d618..000000000 --- a/libs/template/presets/fulfillment-sw/app.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { AppFeature, coreFeature } from '@spryker-oryx/core'; -import { - IndexedDbFeature, - IndexedDbFeatureConfig, -} from '@spryker-oryx/indexed-db'; -import { OfflineServiceWorkerFeature } from '@spryker-oryx/offline/service-worker'; -import { - AuthServiceWorkerFeature, - OfflinePickingFeature, -} from '@spryker-oryx/picking/service-worker'; -import { RouterFeature } from '@spryker-oryx/router'; - -export interface SharedOfflineFulfillmentFeaturesConfig { - indexedDb?: IndexedDbFeatureConfig; -} - -export const defaultOfflineFulfillmentConfig: SharedOfflineFulfillmentFeaturesConfig = - { - indexedDb: { dbName: 'fulfillment-app-db' }, - }; - -export function offlineServiceWorkerFulfillmentFeatures( - config?: SharedOfflineFulfillmentFeaturesConfig -): AppFeature[] { - config = { - ...defaultOfflineFulfillmentConfig, - ...config, - }; - - return [ - coreFeature, - new IndexedDbFeature(config?.indexedDb), - new RouterFeature(), - new OfflineServiceWorkerFeature(), - new AuthServiceWorkerFeature(), - new OfflinePickingFeature(), - ]; -} diff --git a/libs/template/presets/fulfillment-sw/index.ts b/libs/template/presets/fulfillment-sw/index.ts deleted file mode 100644 index 665a3d9d3..000000000 --- a/libs/template/presets/fulfillment-sw/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './app'; diff --git a/libs/template/presets/fulfillment/app.ts b/libs/template/presets/fulfillment/app.ts deleted file mode 100644 index f1dbd722c..000000000 --- a/libs/template/presets/fulfillment/app.ts +++ /dev/null @@ -1,151 +0,0 @@ -import { - applicationFeature, - ThemeMetaInitializer, -} from '@spryker-oryx/application'; -import { BapiAuthComponentsFeature, BapiAuthFeature } from '@spryker-oryx/auth'; -import { contentFeature } from '@spryker-oryx/content'; -import { AppFeature, coreFeature, FeatureOptions } from '@spryker-oryx/core'; -import { experienceFeature, Resources } from '@spryker-oryx/experience'; -import { formFeature } from '@spryker-oryx/form'; -import { I18nFeature, I18nFeatureOptions } from '@spryker-oryx/i18n'; -import { - IndexedDbFeature, - IndexedDbFeatureConfig, -} from '@spryker-oryx/indexed-db'; -import { OfflineFeature } from '@spryker-oryx/offline'; -import { PickingFeature, PickingFeatureConfig } from '@spryker-oryx/picking'; -import { OfflinePickingFeature } from '@spryker-oryx/picking/offline'; -import { WebPushNotificationFeature } from '@spryker-oryx/push-notification/web'; -import { - commonGraphics, - fulfillmentResourceGraphics, - materialDesignLink, -} from '@spryker-oryx/resources'; -import { RouterFeature } from '@spryker-oryx/router'; -import { siteFeature } from '@spryker-oryx/site'; -import { uiFeature } from '@spryker-oryx/ui'; -import { ColorMode, featureVersion } from '@spryker-oryx/utilities'; -import { StaticExperienceFeature } from './experience'; -import { - FulfillmentRootFeature, - FulfillmentRootFeatureConfig, -} from './feature'; -import { PWAThemeMetaInitializer } from './theme-meta'; - -delete applicationFeature.plugins; - -export function fulfillmentFeatures( - config?: FulfillmentFeaturesConfig -): AppFeature[] { - const onlineFeatures = [ - uiFeature, - coreFeature, - ...(featureVersion >= '1.2' - ? [siteFeature, formFeature, applicationFeature, contentFeature] - : []), - experienceFeature, - new RouterFeature(), - new I18nFeature(config?.i18n), - new WebPushNotificationFeature(), - new BapiAuthFeature(), - new BapiAuthComponentsFeature(), - { resources: fulfillmentResources }, - featureVersion >= '1.2' - ? [] - : new FulfillmentRootFeature(config?.fulfillmentRoot), - new PickingFeature(config?.picking), - StaticExperienceFeature, - featureVersion >= '1.3' - ? { - providers: [ - { - provide: ThemeMetaInitializer, - useClass: PWAThemeMetaInitializer, - }, - { - provide: FeatureOptions, - useValue: { 'oryx-app': { colorMode: ColorMode.Light } }, - }, - ], - } - : [], - ]; - - if (featureVersion >= '1.3') { - config = { - ...defaultFulfillmentConfig, - ...config, - }; - return [ - ...onlineFeatures, - new IndexedDbFeature(config?.indexedDb), - new OfflineFeature(), - new OfflinePickingFeature(), - ]; - } - - return onlineFeatures; -} - -export interface FulfillmentFeaturesConfig { - /** - * @deprecated Since version 1.2. - */ - fulfillmentRoot?: FulfillmentRootFeatureConfig; - picking?: PickingFeatureConfig; - i18n?: I18nFeatureOptions; - - /** - * @since version 1.3 - */ - indexedDb?: IndexedDbFeatureConfig; -} - -export const fulfillmentResources: Resources = { - graphics: { ...commonGraphics, ...fulfillmentResourceGraphics }, - fonts: materialDesignLink, -}; - -/** - * @deprecated Since version 1.3, indexedDb is now part of the standard fulfillmentFeatures config. - */ -export interface SharedOfflineFulfillmentFeaturesConfig { - indexedDb?: IndexedDbFeatureConfig; -} - -/** - * @deprecated Since version 1.3, use FulfillmentFeaturesConfig instead. - */ -export interface OfflineFulfillmentFeaturesConfig - extends FulfillmentFeaturesConfig, - SharedOfflineFulfillmentFeaturesConfig {} - -/** - * @deprecated Since version 1.3, use defaultFulfillmentConfig instead. - */ -export const defaultOfflineFulfillmentConfig: SharedOfflineFulfillmentFeaturesConfig = - { - indexedDb: { dbName: 'fulfillment-app-db' }, - }; - -export const defaultFulfillmentConfig: FulfillmentFeaturesConfig = - defaultOfflineFulfillmentConfig; - -/** - * @deprecated Since version 1.3, use fulfillmentFeatures instead. - */ -export function offlineFulfillmentFeatures( - config?: OfflineFulfillmentFeaturesConfig -): AppFeature[] { - config = { - ...defaultOfflineFulfillmentConfig, - ...config, - }; - - return [ - ...fulfillmentFeatures(config), - new IndexedDbFeature(config?.indexedDb), - new OfflineFeature(), - new OfflinePickingFeature(), - ]; -} diff --git a/libs/template/presets/fulfillment/components/fulfillment-root/component.def.ts b/libs/template/presets/fulfillment/components/fulfillment-root/component.def.ts deleted file mode 100644 index ac9a4c365..000000000 --- a/libs/template/presets/fulfillment/components/fulfillment-root/component.def.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { componentDef } from '@spryker-oryx/utilities'; - -export const fulfillmentRootComponent = componentDef({ - name: 'oryx-fulfillment-root', - impl: () => import('./fulfillment-root.component').then((m) => m.default), -}); diff --git a/libs/template/presets/fulfillment/components/fulfillment-root/fulfillment-root.component.ts b/libs/template/presets/fulfillment/components/fulfillment-root/fulfillment-root.component.ts deleted file mode 100644 index 324ec3cbb..000000000 --- a/libs/template/presets/fulfillment/components/fulfillment-root/fulfillment-root.component.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { LitRouter, RouteConfig } from '@spryker-oryx/router/lit'; -import { LitElement, PropertyValueMap } from 'lit'; -import { property } from 'lit/decorators.js'; -import { styles } from './fulfillment-root.styles'; - -/** - * @deprecated Since version 1.2. Use instead. - */ -export class FulfillmentRootComponent extends LitElement { - static styles = styles; - - @property({ type: Array }) declare extraRoutes?: RouteConfig[]; - - router = new LitRouter(this, this.extraRoutes ?? []); - - protected override render(): unknown { - return this.router.outlet(); - } - - protected willUpdate( - changedProps: PropertyValueMap - ): void { - if ( - changedProps.has('extraRoutes') && - changedProps.get('extraRoutes') !== this.extraRoutes && - this.extraRoutes - ) { - // Remove old routes - changedProps.get('extraRoutes')?.forEach((oldRoute) => { - const idx = this.router.routes.indexOf(oldRoute); - if (idx !== -1) { - this.router.routes.splice(idx, 1); - } - }); - - // Add new routes - this.router.routes.push(...this.extraRoutes); - } - } -} - -export default FulfillmentRootComponent; diff --git a/libs/template/presets/fulfillment/components/fulfillment-root/fulfillment-root.styles.ts b/libs/template/presets/fulfillment/components/fulfillment-root/fulfillment-root.styles.ts deleted file mode 100644 index 3ef320d56..000000000 --- a/libs/template/presets/fulfillment/components/fulfillment-root/fulfillment-root.styles.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { css } from 'lit'; - -export const styles = css` - :host { - font-family: var(--oryx-typography-body-font); - font-weight: var(--oryx-typography-body-weight); - box-sizing: border-box; - min-height: 100vh; - display: block; - max-width: var(--oryx-layout-container-width); - margin: auto; - } -`; diff --git a/libs/template/presets/fulfillment/components/index.ts b/libs/template/presets/fulfillment/components/index.ts deleted file mode 100644 index 5c42971ff..000000000 --- a/libs/template/presets/fulfillment/components/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './fulfillment-root/component.def'; diff --git a/libs/template/presets/fulfillment/experience/experience-data.ts b/libs/template/presets/fulfillment/experience/experience-data.ts deleted file mode 100644 index 4f07a825d..000000000 --- a/libs/template/presets/fulfillment/experience/experience-data.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { AppFeature } from '@spryker-oryx/core'; -import { provideExperienceData } from '@spryker-oryx/experience'; -import { - customerNotePage, - fulfillmentLoginPage, - pickingListsPage, - pickingPickerPage, - warehouseSelectionPage, -} from './pages'; -import { - HeaderPickerTemplate, - HeaderPickingListsTemplate, - HeaderTemplate, - ServiceTemplate, -} from './templates'; - -export const StaticExperienceFeature: AppFeature = { - providers: [ - provideExperienceData([ - fulfillmentLoginPage, - warehouseSelectionPage, - pickingListsPage, - customerNotePage, - pickingPickerPage, - ServiceTemplate, - HeaderTemplate, - HeaderPickingListsTemplate, - HeaderPickerTemplate, - ]), - ], -}; diff --git a/libs/template/presets/fulfillment/experience/index.ts b/libs/template/presets/fulfillment/experience/index.ts deleted file mode 100644 index 1111dba15..000000000 --- a/libs/template/presets/fulfillment/experience/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './experience-data'; -export * from './pages'; -export * from './templates'; diff --git a/libs/template/presets/fulfillment/experience/pages/customer-note-page.ts b/libs/template/presets/fulfillment/experience/pages/customer-note-page.ts deleted file mode 100644 index a984f613e..000000000 --- a/libs/template/presets/fulfillment/experience/pages/customer-note-page.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { ExperienceComponent } from '@spryker-oryx/experience'; - -export const customerNotePage: ExperienceComponent = { - id: 'customer-note', - type: 'Page', - meta: { - title: 'Customer Note', - route: '/customer-note-info/:pickingListId', - description: 'Customer Note Page Description', - }, - options: { - rules: [{ layout: 'list' }], - }, - components: [ - { - type: 'oryx-picking-customer-note', - }, - { ref: 'service' }, - ], -}; diff --git a/libs/template/presets/fulfillment/experience/pages/index.ts b/libs/template/presets/fulfillment/experience/pages/index.ts deleted file mode 100644 index 15b512591..000000000 --- a/libs/template/presets/fulfillment/experience/pages/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './customer-note-page'; -export * from './login-page'; -export * from './picking-lists-page'; -export * from './picking-picker-page'; -export * from './warehouse-selection-page'; diff --git a/libs/template/presets/fulfillment/experience/pages/login-page.ts b/libs/template/presets/fulfillment/experience/pages/login-page.ts deleted file mode 100644 index 93b412fc9..000000000 --- a/libs/template/presets/fulfillment/experience/pages/login-page.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { ExperienceComponent } from '@spryker-oryx/experience'; -import { featureVersion } from '@spryker-oryx/utilities'; - -export const fulfillmentLoginPage: ExperienceComponent = { - id: 'fulfillment-login-page', - type: 'Page', - meta: { - title: 'Login Page', - route: '/login', - description: 'Login to access the fulfillment app', - }, - options: { - rules: [ - { - layout: { - ...(featureVersion >= '1.4' - ? { type: 'list' } - : { type: 'flex', vertical: true }), - }, - gap: '30px', - height: '100vh', - width: 'min(440px, calc(100% - 16px))', - justify: 'center', - padding: '8px', - }, - ], - }, - components: [ - { - type: 'oryx-content-image', - content: { data: { graphic: 'logo' } }, - options: { rules: [{ height: '82px', align: 'center' }] }, - }, - { - type: 'oryx-content-text', - content: { - data: { text: `

Welcome! Please log in to start picking.

` }, - }, - options: { rules: [{ padding: '0 0 20px', align: 'center' }] }, - }, - { - type: 'oryx-auth-login', - options: { enableRememberMe: false }, - }, - { ref: 'service' }, - ], -}; diff --git a/libs/template/presets/fulfillment/experience/pages/picking-lists-page.ts b/libs/template/presets/fulfillment/experience/pages/picking-lists-page.ts deleted file mode 100644 index 129c89905..000000000 --- a/libs/template/presets/fulfillment/experience/pages/picking-lists-page.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { ExperienceComponent } from '@spryker-oryx/experience'; - -export const pickingListsPage: ExperienceComponent = { - id: 'picking-lists', - type: 'Page', - meta: { - title: 'Picking Lists Page', - route: '/', - description: 'Picking Lists Page Description', - }, - options: { - rules: [{ layout: 'list' }], - }, - components: [ - { ref: 'header-picking-lists' }, - { - type: 'oryx-picking-lists', - options: { - rules: [ - { - style: 'min-height: calc(100vh - 66px); box-sizing: border-box;', - }, - ], - }, - }, - { ref: 'service' }, - ], -}; diff --git a/libs/template/presets/fulfillment/experience/pages/picking-picker-page.ts b/libs/template/presets/fulfillment/experience/pages/picking-picker-page.ts deleted file mode 100644 index e1d2aa803..000000000 --- a/libs/template/presets/fulfillment/experience/pages/picking-picker-page.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { ExperienceComponent } from '@spryker-oryx/experience'; - -export const pickingPickerPage: ExperienceComponent = { - id: 'picking-picker', - type: 'Page', - meta: { - title: 'Picking Picker', - route: '/picking-list/picking/:pickingListId', - description: 'Picking Picker Page Description', - }, - options: { - rules: [ - { - layout: 'list', - style: 'min-height: calc(100vh - 66px); box-sizing: border-box;', - }, - ], - }, - components: [ - { ref: 'header-picker' }, - { - type: 'oryx-picking-picker', - options: { - rules: [ - { - style: 'min-height: calc(100vh - 66px); box-sizing: border-box;', - }, - ], - }, - }, - { ref: 'service' }, - ], -}; diff --git a/libs/template/presets/fulfillment/experience/pages/warehouse-selection-page.ts b/libs/template/presets/fulfillment/experience/pages/warehouse-selection-page.ts deleted file mode 100644 index 4ccf42e79..000000000 --- a/libs/template/presets/fulfillment/experience/pages/warehouse-selection-page.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { ExperienceComponent } from '@spryker-oryx/experience'; - -export const warehouseSelectionPage: ExperienceComponent = { - id: 'warehouse-selection', - type: 'Page', - meta: { - title: 'Warehouse Selection', - route: '/warehouse-selection', - description: 'Warehouse Selection Page Description', - }, - options: { - rules: [{ layout: 'list' }], - }, - components: [ - { ref: 'header' }, - { - type: 'oryx-picking-warehouse-assignment', - options: { - rules: [ - { - style: 'min-height: calc(100vh - 66px); box-sizing: border-box;', - }, - ], - }, - }, - { ref: 'service' }, - ], -}; diff --git a/libs/template/presets/fulfillment/experience/service.ts b/libs/template/presets/fulfillment/experience/service.ts deleted file mode 100644 index f8c72abc9..000000000 --- a/libs/template/presets/fulfillment/experience/service.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { ExperienceComponent } from '@spryker-oryx/experience'; - -export const ServiceTemplate: ExperienceComponent = { - type: 'oryx-composition', - id: 'service', - components: [{ type: 'oryx-site-notification-center' }], -}; diff --git a/libs/template/presets/fulfillment/experience/templates/header-picker.ts b/libs/template/presets/fulfillment/experience/templates/header-picker.ts deleted file mode 100644 index 3469fd4a7..000000000 --- a/libs/template/presets/fulfillment/experience/templates/header-picker.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { ExperienceComponent } from '@spryker-oryx/experience'; -import { HeaderTemplate } from './header'; - -export const HeaderPickerTemplate: ExperienceComponent = { - ...HeaderTemplate, - id: 'header-picker', - components: [ - { type: 'oryx-picking-discard-modal' }, - { - type: 'oryx-picking-order-reference', - options: { rules: [{ style: 'flex: 1 0 auto;' }] }, - }, - { type: 'oryx-picking-customer-note-modal' }, - ...(HeaderTemplate.components as ExperienceComponent[]), - ], -}; diff --git a/libs/template/presets/fulfillment/experience/templates/header-picking-lists.ts b/libs/template/presets/fulfillment/experience/templates/header-picking-lists.ts deleted file mode 100644 index 6f70235ab..000000000 --- a/libs/template/presets/fulfillment/experience/templates/header-picking-lists.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { ExperienceComponent } from '@spryker-oryx/experience'; -import { HeaderTemplate } from './header'; - -export const HeaderPickingListsTemplate: ExperienceComponent = { - ...HeaderTemplate, - id: 'header-picking-lists', - components: [ - { - type: 'oryx-content-text', - content: { - data: { - text: `

PICK LISTS

`, - }, - }, - options: { - rules: [{ margin: '0 auto 0 0' }], - }, - }, - { type: 'oryx-picking-search' }, - ...(HeaderTemplate.components as ExperienceComponent[]), - ], -}; diff --git a/libs/template/presets/fulfillment/experience/templates/header.ts b/libs/template/presets/fulfillment/experience/templates/header.ts deleted file mode 100644 index 737eb4877..000000000 --- a/libs/template/presets/fulfillment/experience/templates/header.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { ExperienceComponent, ShadowElevation } from '@spryker-oryx/experience'; -import { IconTypes } from '@spryker-oryx/ui/icon'; - -export const HeaderTemplate: ExperienceComponent = { - type: 'oryx-composition', - id: 'header', - components: [ - { - type: 'oryx-site-navigation-item', - options: { - contentBehavior: 'modal', - label: 'Account', - icon: IconTypes.User, - triggerType: 'icon', - rules: [{ style: '--oryx-icon-color: var(--oryx-color-primary-9)' }], - }, - components: [{ type: 'oryx-picking-user-profile' }], - }, - ], - options: { - rules: [ - { - layout: { - type: 'flex', - sticky: true, - zIndex: 1, - bleed: true, - }, - shadow: ShadowElevation.Hovering, - height: '66px', - background: 'var(--oryx-color-neutral-1)', - padding: '0 24px', - gap: '12px', - align: 'center', - justify: 'end', - style: 'box-sizing: border-box;', - }, - ], - }, -}; diff --git a/libs/template/presets/fulfillment/experience/templates/index.ts b/libs/template/presets/fulfillment/experience/templates/index.ts deleted file mode 100644 index 901153f68..000000000 --- a/libs/template/presets/fulfillment/experience/templates/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './header'; -export * from './header-picker'; -export * from './header-picking-lists'; -export * from './service'; diff --git a/libs/template/presets/fulfillment/experience/templates/service.ts b/libs/template/presets/fulfillment/experience/templates/service.ts deleted file mode 100644 index f8c72abc9..000000000 --- a/libs/template/presets/fulfillment/experience/templates/service.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { ExperienceComponent } from '@spryker-oryx/experience'; - -export const ServiceTemplate: ExperienceComponent = { - type: 'oryx-composition', - id: 'service', - components: [{ type: 'oryx-site-notification-center' }], -}; diff --git a/libs/template/presets/fulfillment/feature.ts b/libs/template/presets/fulfillment/feature.ts deleted file mode 100644 index 9827847a6..000000000 --- a/libs/template/presets/fulfillment/feature.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { ModularAppBuilderOptions } from '@spryker-oryx/application'; -import { AppFeature } from '@spryker-oryx/core'; -import { ComponentInfo, ComponentsInfo } from '@spryker-oryx/utilities'; -import { fulfillmentRootComponent } from './components'; - -/** - * @deprecated Since version 1.2. - */ -export interface FulfillmentRootFeatureConfig { - selector?: string; -} - -/** - * @deprecated Since version 1.2. - */ -export class FulfillmentRootFeature implements AppFeature { - options: ModularAppBuilderOptions; - components: ComponentsInfo; - - constructor(config?: FulfillmentRootFeatureConfig) { - this.options = this.getOptions(config); - this.components = this.getComponents(config); - } - - protected getOptions( - config?: FulfillmentRootFeatureConfig - ): ModularAppBuilderOptions { - return { - components: { root: this.getRootComponent(config) }, - }; - } - - protected getComponents( - config?: FulfillmentRootFeatureConfig - ): ComponentsInfo { - return [this.getRootComponent(config)]; - } - - protected getRootComponent( - config?: FulfillmentRootFeatureConfig - ): ComponentInfo { - return fulfillmentRootComponent( - config ? { name: config?.selector } : undefined - ); - } -} diff --git a/libs/template/presets/fulfillment/index.ts b/libs/template/presets/fulfillment/index.ts deleted file mode 100644 index 14b566f54..000000000 --- a/libs/template/presets/fulfillment/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './app'; -export * from './components'; -export * from './feature'; diff --git a/libs/template/presets/fulfillment/theme-meta/index.ts b/libs/template/presets/fulfillment/theme-meta/index.ts deleted file mode 100644 index 5765da3fd..000000000 --- a/libs/template/presets/fulfillment/theme-meta/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './pwa-theme-meta.initializer'; diff --git a/libs/template/presets/fulfillment/theme-meta/pwa-theme-meta.initializer.ts b/libs/template/presets/fulfillment/theme-meta/pwa-theme-meta.initializer.ts deleted file mode 100644 index 726276a26..000000000 --- a/libs/template/presets/fulfillment/theme-meta/pwa-theme-meta.initializer.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { AppInitializer, PageMetaService } from '@spryker-oryx/core'; -import { inject } from '@spryker-oryx/di'; -import { bodyStyles, fontMeta, iconMeta } from '../../src/meta'; - -export class PWAThemeMetaInitializer implements AppInitializer { - constructor(protected metaService = inject(PageMetaService, null)) {} - - initialize(): void { - this.metaService?.add([ - ...fontMeta(), - ...bodyStyles({ fontSize: '16px' }), - ...iconMeta(), - ]); - } -} diff --git a/libs/template/presets/package.json b/libs/template/presets/package.json index e20d743dc..68732bbb6 100644 --- a/libs/template/presets/package.json +++ b/libs/template/presets/package.json @@ -27,7 +27,6 @@ "@spryker-oryx/indexed-db": "1.4.0", "@spryker-oryx/offline": "1.4.0", "@spryker-oryx/order": "1.4.0", - "@spryker-oryx/picking": "1.4.0", "@spryker-oryx/product": "1.4.0", "@spryker-oryx/push-notification": "1.4.0", "@spryker-oryx/resources": "1.4.0", diff --git a/libs/template/resources/src/graphics/fulfillment/image-placeholder.ts b/libs/template/resources/src/graphics/fulfillment/image-placeholder.ts deleted file mode 100644 index 81f735213..000000000 --- a/libs/template/resources/src/graphics/fulfillment/image-placeholder.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const imagePlaceholder = ` - - - -`; diff --git a/libs/template/resources/src/graphics/fulfillment/index.ts b/libs/template/resources/src/graphics/fulfillment/index.ts deleted file mode 100644 index 921273171..000000000 --- a/libs/template/resources/src/graphics/fulfillment/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { ResourceGraphic } from '@spryker-oryx/experience'; - -export const fulfillmentResourceGraphics: ResourceGraphic = { - 'image-placeholder': { - source: () => import('./image-placeholder').then((m) => m.imagePlaceholder), - }, - 'no-orders': { - source: () => import('./no-orders').then((m) => m.noOrders), - }, - 'no-search-results': { - source: () => import('./no-search-results').then((m) => m.noSearchResults), - }, - 'picking-items-processed': { - source: () => - import('./picking-items-processed').then((m) => m.pickingItemsProcessed), - }, - searching: { - source: () => import('./searching').then((m) => m.searching), - }, - 'user-note': { - source: () => import('./user-note').then((m) => m.userNote), - }, -}; diff --git a/libs/template/resources/src/graphics/fulfillment/no-orders.ts b/libs/template/resources/src/graphics/fulfillment/no-orders.ts deleted file mode 100644 index eb20ff061..000000000 --- a/libs/template/resources/src/graphics/fulfillment/no-orders.ts +++ /dev/null @@ -1,46 +0,0 @@ -export const noOrders = ` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -`; diff --git a/libs/template/resources/src/graphics/fulfillment/no-search-results.ts b/libs/template/resources/src/graphics/fulfillment/no-search-results.ts deleted file mode 100644 index 0834a0448..000000000 --- a/libs/template/resources/src/graphics/fulfillment/no-search-results.ts +++ /dev/null @@ -1,40 +0,0 @@ -export const noSearchResults = ` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -`; diff --git a/libs/template/resources/src/graphics/fulfillment/picking-items-processed.ts b/libs/template/resources/src/graphics/fulfillment/picking-items-processed.ts deleted file mode 100644 index a9f2e4007..000000000 --- a/libs/template/resources/src/graphics/fulfillment/picking-items-processed.ts +++ /dev/null @@ -1,35 +0,0 @@ -export const pickingItemsProcessed = ` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -`; diff --git a/libs/template/resources/src/graphics/fulfillment/searching.ts b/libs/template/resources/src/graphics/fulfillment/searching.ts deleted file mode 100644 index 0a93c3577..000000000 --- a/libs/template/resources/src/graphics/fulfillment/searching.ts +++ /dev/null @@ -1,51 +0,0 @@ -export const searching = ` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -`; diff --git a/libs/template/resources/src/graphics/fulfillment/user-note.ts b/libs/template/resources/src/graphics/fulfillment/user-note.ts deleted file mode 100644 index 17f286277..000000000 --- a/libs/template/resources/src/graphics/fulfillment/user-note.ts +++ /dev/null @@ -1,52 +0,0 @@ -export const userNote = ` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -`; diff --git a/libs/template/resources/src/graphics/index.ts b/libs/template/resources/src/graphics/index.ts index 91f49fe04..de4fec44d 100644 --- a/libs/template/resources/src/graphics/index.ts +++ b/libs/template/resources/src/graphics/index.ts @@ -1,3 +1,2 @@ export { brandGraphics } from './brands'; export { commonGraphics } from './common'; -export { fulfillmentResourceGraphics } from './fulfillment'; diff --git a/libs/template/resources/src/icons/fulfillment/icons/add.ts b/libs/template/resources/src/icons/fulfillment/icons/add.ts deleted file mode 100644 index 4ee60e06d..000000000 --- a/libs/template/resources/src/icons/fulfillment/icons/add.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default ` - -`; diff --git a/libs/template/resources/src/icons/fulfillment/icons/back-arrow.ts b/libs/template/resources/src/icons/fulfillment/icons/back-arrow.ts deleted file mode 100644 index 4938ddcc4..000000000 --- a/libs/template/resources/src/icons/fulfillment/icons/back-arrow.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default ` - -`; diff --git a/libs/template/resources/src/icons/fulfillment/icons/cart.ts b/libs/template/resources/src/icons/fulfillment/icons/cart.ts deleted file mode 100644 index fdad5ebf6..000000000 --- a/libs/template/resources/src/icons/fulfillment/icons/cart.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default ` - -`; diff --git a/libs/template/resources/src/icons/fulfillment/icons/check.ts b/libs/template/resources/src/icons/fulfillment/icons/check.ts deleted file mode 100644 index 99dc11cac..000000000 --- a/libs/template/resources/src/icons/fulfillment/icons/check.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default ` - -`; diff --git a/libs/template/resources/src/icons/fulfillment/icons/close.ts b/libs/template/resources/src/icons/fulfillment/icons/close.ts deleted file mode 100644 index ba8a77f39..000000000 --- a/libs/template/resources/src/icons/fulfillment/icons/close.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default ` - -`; diff --git a/libs/template/resources/src/icons/fulfillment/icons/edit.ts b/libs/template/resources/src/icons/fulfillment/icons/edit.ts deleted file mode 100644 index 72a527962..000000000 --- a/libs/template/resources/src/icons/fulfillment/icons/edit.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default ` - -`; diff --git a/libs/template/resources/src/icons/fulfillment/icons/error.ts b/libs/template/resources/src/icons/fulfillment/icons/error.ts deleted file mode 100644 index fa2c14c0f..000000000 --- a/libs/template/resources/src/icons/fulfillment/icons/error.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default ` - -`; diff --git a/libs/template/resources/src/icons/fulfillment/icons/filter.ts b/libs/template/resources/src/icons/fulfillment/icons/filter.ts deleted file mode 100644 index 9a4c81ed0..000000000 --- a/libs/template/resources/src/icons/fulfillment/icons/filter.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default ` - -`; diff --git a/libs/template/resources/src/icons/fulfillment/icons/info.ts b/libs/template/resources/src/icons/fulfillment/icons/info.ts deleted file mode 100644 index 51fc31fb0..000000000 --- a/libs/template/resources/src/icons/fulfillment/icons/info.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default ` - -`; diff --git a/libs/template/resources/src/icons/fulfillment/icons/invisible.ts b/libs/template/resources/src/icons/fulfillment/icons/invisible.ts deleted file mode 100644 index b266f7f27..000000000 --- a/libs/template/resources/src/icons/fulfillment/icons/invisible.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default ` - -`; diff --git a/libs/template/resources/src/icons/fulfillment/icons/loader.ts b/libs/template/resources/src/icons/fulfillment/icons/loader.ts deleted file mode 100644 index 44270672d..000000000 --- a/libs/template/resources/src/icons/fulfillment/icons/loader.ts +++ /dev/null @@ -1,6 +0,0 @@ -export default ` - - - - -`; diff --git a/libs/template/resources/src/icons/fulfillment/icons/minus.ts b/libs/template/resources/src/icons/fulfillment/icons/minus.ts deleted file mode 100644 index 0fe089e16..000000000 --- a/libs/template/resources/src/icons/fulfillment/icons/minus.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default ` - -`; diff --git a/libs/template/resources/src/icons/fulfillment/icons/profile.ts b/libs/template/resources/src/icons/fulfillment/icons/profile.ts deleted file mode 100644 index 578595788..000000000 --- a/libs/template/resources/src/icons/fulfillment/icons/profile.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default ` - -`; diff --git a/libs/template/resources/src/icons/fulfillment/icons/refresh.ts b/libs/template/resources/src/icons/fulfillment/icons/refresh.ts deleted file mode 100644 index 20457dd4c..000000000 --- a/libs/template/resources/src/icons/fulfillment/icons/refresh.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default ` - -`; diff --git a/libs/template/resources/src/icons/fulfillment/icons/remove.ts b/libs/template/resources/src/icons/fulfillment/icons/remove.ts deleted file mode 100644 index cd24722a0..000000000 --- a/libs/template/resources/src/icons/fulfillment/icons/remove.ts +++ /dev/null @@ -1,4 +0,0 @@ -export default ` - - -`; diff --git a/libs/template/resources/src/icons/fulfillment/icons/search.ts b/libs/template/resources/src/icons/fulfillment/icons/search.ts deleted file mode 100644 index 4dcfe7b21..000000000 --- a/libs/template/resources/src/icons/fulfillment/icons/search.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default ` - -`; diff --git a/libs/template/resources/src/icons/fulfillment/icons/visible.ts b/libs/template/resources/src/icons/fulfillment/icons/visible.ts deleted file mode 100644 index 24ea3183a..000000000 --- a/libs/template/resources/src/icons/fulfillment/icons/visible.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default ` - -`; diff --git a/libs/template/resources/src/icons/fulfillment/index.ts b/libs/template/resources/src/icons/fulfillment/index.ts deleted file mode 100644 index b713bb4df..000000000 --- a/libs/template/resources/src/icons/fulfillment/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { IconMapper } from '@spryker-oryx/experience'; -import { IconTypes } from '@spryker-oryx/ui/icon'; - -export const fulfillmentIcons: IconMapper = { - svg: true, - mapping: { - [IconTypes.Cart]: () => import('./icons/cart').then((s) => s.default), - [IconTypes.Loader]: () => import('./icons/loader').then((s) => s.default), - [IconTypes.Remove]: () => import('./icons/remove').then((s) => s.default), - }, -}; diff --git a/libs/template/resources/src/icons/index.ts b/libs/template/resources/src/icons/index.ts index 8ec76ed09..9dd73f7b9 100644 --- a/libs/template/resources/src/icons/index.ts +++ b/libs/template/resources/src/icons/index.ts @@ -1,5 +1,4 @@ export * from './backoffice'; export * from './backoffice-ng'; export * from './fonts'; -export * from './fulfillment'; export * from './storefront'; diff --git a/libs/template/themes/src/fulfillment.theme.ts b/libs/template/themes/src/fulfillment.theme.ts deleted file mode 100644 index 8fa419a09..000000000 --- a/libs/template/themes/src/fulfillment.theme.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { Theme } from '@spryker-oryx/experience'; -import { fulfillmentIcons, materialDesignIcons } from '@spryker-oryx/resources'; -import { Size } from '@spryker-oryx/utilities'; - -export const fulfillmentTheme: Theme = { - name: 'fulfillment', - breakpoints: { - [Size.Sm]: { - max: 767, - }, - [Size.Md]: { - min: 768, - }, - }, - designTokens: () => - import('../design-tokens/src/mobile-backoffice').then( - (s) => s.mobileBackofficeTokens - ), - icons: { - resource: materialDesignIcons, - resources: [ - { - resource: fulfillmentIcons, - types: Object.keys(fulfillmentIcons.mapping ?? {}), - }, - { - resource: { - id: 'material-icons', - styles: { - fill: 1, - }, - }, - types: ['person'], - }, - ], - }, -}; diff --git a/libs/template/themes/src/index.ts b/libs/template/themes/src/index.ts index fdc8b409b..66a2a0546 100644 --- a/libs/template/themes/src/index.ts +++ b/libs/template/themes/src/index.ts @@ -1,5 +1,4 @@ export * from './backoffice-ng.theme'; export * from './backoffice.theme'; export * from './fes.theme'; -export * from './fulfillment.theme'; export * from './storefront.theme'; diff --git a/package.json b/package.json index 32ef3aaf4..f42e8a805 100644 --- a/package.json +++ b/package.json @@ -28,15 +28,6 @@ "sf:b2b:e2e:headless": "ORYX_PRESET=b2b npx concurrently --kill-others --success first \"npx nx run storefront:serve-e2e\" \"wait-on -i=2000 -c wait-on-config.json http-get://localhost:3001/ && npx nx run storefront-e2e:e2e:b2b-headless\"", "sf:b2b:e2e:headless:ci": "ORYX_PRESET=b2b npx concurrently --kill-others --success first \"npx nx run storefront:serve-e2e\" \"wait-on -i=2000 -v -c wait-on-config.json http-get://localhost:3001/ && npx nx run storefront-e2e:e2e:b2b-headless-ci\"", "sf:b2b:e2e:headless:ci:affected": "ORYX_PRESET=b2b npx nx print-affected --select=projects | grep -E -v 'storefront' && echo 'nothing changed, skip' || npm run sf:b2b:e2e:headless:ci", - "fa:serve": "npx concurrently --kill-others --success first \"npx nx run fulfillment:serve\"", - "fa:serve:ci": "npx concurrently --kill-others --success first \"npx nx run fulfillment:build && npx nx run fulfillment:preview\"", - "fa:wait-on": "wait-on -i=2000 -c wait-on-config.json http-get://localhost:4200 && wait-on -i=2000 -t=60000 -v apps/fulfillment/dev-dist/sw/app.js", - "fa:wait-on:ci": "wait-on -i=2000 -c wait-on-config.json http-get://localhost:4200 && wait-on -i=2000 -t=60000 -v apps/fulfillment/dev-dist/sw/app.js", - "fa:e2e:open": "npx concurrently --kill-others --success first \"npm run fa:serve\" \"npm run fa:wait-on && npx nx run fulfillment-e2e:e2e\"", - "fa:e2e:open:ci": "npx concurrently --kill-others --success first \"npm run fa:serve:ci\" \"npm run fa:wait-on && npx nx run fulfillment-e2e:e2e\"", - "fa:e2e:headless": "npx concurrently --kill-others --success first \"npm run fa:serve\" \"npm run fa:wait-on && npx nx run fulfillment-e2e:e2e:headless\"", - "fa:e2e:headless:ci": "npx concurrently --kill-others --success first \"npm run fa:serve:ci\" \"npm run fa:wait-on:ci && npx nx run fulfillment-e2e:e2e:headless-ci\"", - "fa:e2e:headless:ci:affected": "npx nx print-affected --select=projects | grep -E -v 'fulfillment' && echo 'nothing changed, skip' || npm run fa:e2e:headless:ci", "release-test:e2e": "npx nx run storefront-e2e:e2e:headless-ci-release", "testfront": "cd apps/testfront && npm run dev &", "testfront:e2e": "npx concurrently --kill-others --success first \"cd apps/testfront && npm run dev\" \"wait-on -c wait-on-config.json --verbose -i=2000 http-get://localhost:3001 && npm run release-test:e2e \"", diff --git a/tsconfig.base.json b/tsconfig.base.json index 3720cbbc7..77a2b6d7f 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -164,49 +164,6 @@ "@spryker-oryx/order/mocks": ["libs/domain/order/src/mocks/index.ts"], "@spryker-oryx/order/summary": ["libs/domain/order/summary/index.ts"], "@spryker-oryx/order/totals": ["libs/domain/order/totals/index.ts"], - "@spryker-oryx/picking": ["libs/domain/picking/src/index.ts"], - "@spryker-oryx/picking/customer-note": [ - "libs/domain/picking/customer-note/index.ts" - ], - "@spryker-oryx/picking/customer-note-modal": [ - "libs/domain/picking/customer-note-modal/index.ts" - ], - "@spryker-oryx/picking/discard-modal": [ - "libs/domain/picking/discard-modal/index.ts" - ], - "@spryker-oryx/picking/filter-button": [ - "libs/domain/picking/filter-button/index.ts" - ], - "@spryker-oryx/picking/filters": ["libs/domain/picking/filters/index.ts"], - "@spryker-oryx/picking/list-item": [ - "libs/domain/picking/list-item/index.ts" - ], - "@spryker-oryx/picking/lists": ["libs/domain/picking/lists/index.ts"], - "@spryker-oryx/picking/mocks": ["libs/domain/picking/mocks/index.ts"], - "@spryker-oryx/picking/offline": ["libs/domain/picking/offline/index.ts"], - "@spryker-oryx/picking/order-reference": [ - "libs/domain/picking/order-reference/index.ts" - ], - "@spryker-oryx/picking/picker": ["libs/domain/picking/picker/index.ts"], - "@spryker-oryx/picking/picking-in-progress": [ - "libs/domain/picking/picking-in-progress/index.ts" - ], - "@spryker-oryx/picking/product-card": [ - "libs/domain/picking/product-card/index.ts" - ], - "@spryker-oryx/picking/search": ["libs/domain/picking/search/index.ts"], - "@spryker-oryx/picking/service-worker": [ - "libs/domain/picking/service-worker/index.ts" - ], - "@spryker-oryx/picking/services": [ - "libs/domain/picking/services/index.ts" - ], - "@spryker-oryx/picking/user-profile": [ - "libs/domain/picking/user-profile/index.ts" - ], - "@spryker-oryx/picking/warehouse-assignment": [ - "libs/domain/picking/warehouse-assignment/index.ts" - ], "@spryker-oryx/presets": ["libs/template/presets/src/index.ts"], "@spryker-oryx/presets/b2b-storefront": [ "libs/template/presets/b2b-storefront/index.ts" @@ -218,12 +175,6 @@ "libs/template/presets/backoffice-ng/index.ts" ], "@spryker-oryx/presets/fes": ["libs/template/presets/fes/index.ts"], - "@spryker-oryx/presets/fulfillment": [ - "libs/template/presets/fulfillment/index.ts" - ], - "@spryker-oryx/presets/fulfillment-sw": [ - "libs/template/presets/fulfillment-sw/index.ts" - ], "@spryker-oryx/presets/storefront": [ "libs/template/presets/storefront/index.ts" ], diff --git a/workspace.json b/workspace.json index 1de7a8491..d43e840ae 100644 --- a/workspace.json +++ b/workspace.json @@ -12,15 +12,12 @@ "di": "libs/base/di", "experience": "libs/platform/experience", "form": "libs/platform/form", - "fulfillment": "apps/fulfillment", - "fulfillment-e2e": "apps/fulfillment-e2e", "i18n": "libs/platform/i18n", "indexed-db": "libs/platform/indexed-db", "labs": "libs/template/labs", "merchant": "libs/domain/merchant", "offline": "libs/platform/offline", "order": "libs/domain/order", - "picking": "libs/domain/picking", "presets": "libs/template/presets", "product": "libs/domain/product", "push-notification": "libs/platform/push-notification",