From 6529a51eb6f91cb6edc9a9da1b09a0ef0c2bab8c Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Fri, 22 Aug 2025 14:20:43 +0200 Subject: [PATCH 01/12] OBPIH-6969 Add import file --- src/config/AppConfig.ts | 4 ++++ src/setup/dataImport/products.csv | 8 ++++++++ 2 files changed, 12 insertions(+) create mode 100644 src/setup/dataImport/products.csv diff --git a/src/config/AppConfig.ts b/src/config/AppConfig.ts index 7e3e14b9..814daa14 100644 --- a/src/config/AppConfig.ts +++ b/src/config/AppConfig.ts @@ -52,6 +52,10 @@ class AppConfig { public static TEST_DATA_FILE_PATH = path.join(process.cwd(), '.data.json'); + public static DATA_IMPORT_DIRECTORY_PATH = path.join(process.cwd(), 'src/setup/dataImport'); + + public static PRODUCTS_IMPORT_FILE_PATH = path.join(AppConfig.DATA_IMPORT_DIRECTORY_PATH, '/products.csv'); + // Base URL to use in actions like `await page.goto('./dashboard')`. public appURL!: string; diff --git a/src/setup/dataImport/products.csv b/src/setup/dataImport/products.csv new file mode 100644 index 00000000..6b7affa4 --- /dev/null +++ b/src/setup/dataImport/products.csv @@ -0,0 +1,8 @@ +Id,ProductCode,ProductType,Name,ProductFamily,Category,GLAccount,Description,UnitOfMeasure,Tags,UnitCost,LotAndExpiryControl,ColdChain,ControlledSubstance,HazardousMaterial,Reconditioned,Manufacturer,BrandName,ManufacturerCode,ManufacturerName,Vendor,VendorCode,VendorName,UPC,NDC,Created,Updated +,1,Default,E2E-product-one-T0SOek,,ARVS,,,,,,,,,,,,,,,,,,,,19/Dec/2024 02:43:40,19/Dec/2024 02:43:40 +,2,Default,E2E-product-two-T0SOek,,ARVS,,,,,,,,,,,,,,,,,,,,19/Dec/2024 02:43:46,19/Dec/2024 02:43:46 +,3,Default,E2E-product-three-sUuCcW,,ARVS,,,,,,,,,,,,,,,,,,,,18/Feb/2025 11:15:58,18/Feb/2025 11:15:58 +,4,Default,E2E-product-four-sUuCcW,,ARVS,,,,,,,,,,,,,,,,,,,,18/Feb/2025 11:16:03,18/Feb/2025 11:16:03 +,5,Default,E2E-product-five-sUuCcW,,ARVS,,,,,,,,,,,,,,,,,,,,18/Feb/2025 11:16:07,18/Feb/2025 11:16:07 +,10001,Default,test product 1,,Food,,,,,,,,,,,,,,,,,,,,20/Feb/2025 02:53:27,20/Feb/2025 02:53:27 +,10002,Default,test product 2,,Chronic Care,,,,,,,,,,,,,,,,,,,,20/Feb/2025 02:54:03,20/Feb/2025 02:54:03 From bc426fba580778e48b6938a019e13de8980d76ac Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Fri, 22 Aug 2025 14:21:00 +0200 Subject: [PATCH 02/12] OBPIH-6969 Add util for reading csv files --- src/utils/FileIOUtils.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/utils/FileIOUtils.ts b/src/utils/FileIOUtils.ts index da0913d4..4cf04c77 100644 --- a/src/utils/FileIOUtils.ts +++ b/src/utils/FileIOUtils.ts @@ -15,6 +15,36 @@ const readFile = (path: string) => { } }; +export const readCsvFile = (path: string): Record[] => { + try { + const rawdata = fs.readFileSync(path, 'utf8'); + const lines = rawdata.trim().split('\n'); + + if (!lines.length) { + return []; + } + + const headers = lines[0].split(','); + return lines.slice(1).map(line => { + const values = line.split(','); + const obj: Record = {}; + headers.forEach((header, i) => { + obj[header.trim()] = values[i]?.trim() ?? ''; + }); + + return obj; + }); + } catch (error) { + if ( + error instanceof Error && + (error as NodeJS.ErrnoException).code === 'ENOENT' + ) { + return []; + } + throw error; + } +}; + const writeToFile = (path: string, data: unknown) => { const parsedData = JSON.stringify(data, null, 2); fs.writeFileSync(path, parsedData, 'utf8'); From 91eba40529b4cc56311ab2cde89b6cc26fd1fbaa Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Fri, 22 Aug 2025 14:21:18 +0200 Subject: [PATCH 03/12] OBPIH-6969 Add parsing json to csv --- src/utils/ServiceUtils.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/utils/ServiceUtils.ts b/src/utils/ServiceUtils.ts index b626eb18..ae9745db 100644 --- a/src/utils/ServiceUtils.ts +++ b/src/utils/ServiceUtils.ts @@ -18,3 +18,19 @@ export function unflatten(obj: object) { return result; } + +export function jsonToCsv(data: Record[]): string { + if (!Array.isArray(data) || !data.length) { + throw new Error('Input JSON array is empty'); + } + + const headers = Object.keys(data[0]); + const csvRows = [ + headers.join(','), + ...data.map(row => headers.map(header => + JSON.stringify(row[header] ?? '')).join(',') + ), + ]; + + return csvRows.join('\n'); +} From cb5cc86202ba5d90106c041c8a08c77a715be64c Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Fri, 22 Aug 2025 14:21:34 +0200 Subject: [PATCH 04/12] OBPIH-6969 Add service method for importing products --- src/api/ProductService.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/api/ProductService.ts b/src/api/ProductService.ts index 3150b633..cfcc8def 100644 --- a/src/api/ProductService.ts +++ b/src/api/ProductService.ts @@ -1,6 +1,6 @@ import BaseServiceModel from '@/api/BaseServiceModel'; import { ApiResponse, ProductDemandResponse, ProductResponse } from '@/types'; -import { parseRequestToJSON } from '@/utils/ServiceUtils'; +import { jsonToCsv, parseRequestToJSON } from '@/utils/ServiceUtils'; class ProductService extends BaseServiceModel { async getDemand(id: string): Promise> { @@ -22,6 +22,24 @@ class ProductService extends BaseServiceModel { throw new Error('Problem fetching product data'); } } + + async importProducts(data: Record[]): Promise> { + try { + const csvContent = jsonToCsv(data); + + const apiResponse = await this.request.post( + './api/products/import', + { + data: csvContent, + headers: { 'Content-Type': 'text/csv' } + } + ); + + return await parseRequestToJSON(apiResponse); + } catch (error) { + throw new Error('Problem importing products'); + } + } } export default ProductService; From df00ba88a0d85d753733dfa3898c3631abf6f5a5 Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Fri, 22 Aug 2025 14:22:08 +0200 Subject: [PATCH 05/12] OBPIH-6969 Add data import setup file --- src/setup/dataImport.setup.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/setup/dataImport.setup.ts diff --git a/src/setup/dataImport.setup.ts b/src/setup/dataImport.setup.ts new file mode 100644 index 00000000..118b6ff4 --- /dev/null +++ b/src/setup/dataImport.setup.ts @@ -0,0 +1,23 @@ +import ProductService from '@/api/ProductService'; +import AppConfig from '@/config/AppConfig'; +import { test } from '@/fixtures/fixtures'; +import { readCsvFile, readFile, writeToFile } from '@/utils/FileIOUtils'; + +test('import data', async ({ request }) => { + // eslint-disable-next-line playwright/no-conditional-in-test + const data = readFile(AppConfig.TEST_DATA_FILE_PATH) || {}; + + // PRODUCTS + const productService = new ProductService(request); + + const productsData = readCsvFile(AppConfig.PRODUCTS_IMPORT_FILE_PATH); + + await test.step(`importing ${productsData.length} products`, async () => { + const importedData = await productService.importProducts(productsData); + importedData.data.forEach((product) => { + data.products[product.productCode] = product.id; + }) + }) + + writeToFile(AppConfig.TEST_DATA_FILE_PATH, data); +}); From d63dd4037666af7c17cc574ce08fbb1cafc6fecb Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Fri, 22 Aug 2025 14:22:23 +0200 Subject: [PATCH 06/12] OBPIH-6969 Include data import in configuration --- playwright.config.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index 9c551a92..2622d127 100755 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -32,7 +32,7 @@ export default defineConfig({ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: 'retain-on-failure', - + launchOptions: { // slowMo: 1000, }, @@ -60,6 +60,15 @@ export default defineConfig({ storageState: appConfig.users['main'].storagePath, }, }, + { + name: 'data-import-setup', + testMatch: 'dataImport.setup.ts', + testDir: './src/setup', + dependencies: ['create-data-setup'], + use: { + storageState: appConfig.users['main'].storagePath, + }, + }, { name: 'chromium', use: { @@ -67,7 +76,7 @@ export default defineConfig({ viewport: { width: 1366, height: 768 }, storageState: appConfig.users['main'].storagePath, }, - dependencies: ['auth-setup', 'create-data-setup'], + dependencies: ['auth-setup', 'create-data-setup', 'data-import-setup'], }, ], }); From eba4871cad218259481117c4061615ce63d7ade9 Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Tue, 26 Aug 2025 14:34:43 +0200 Subject: [PATCH 07/12] OBPIH-6969 Replace hardcoded products with date from csv file --- src/config/AppConfig.ts | 49 +++++++------------------------ src/config/ProductConfig.ts | 2 +- src/setup/createData.setup.ts | 41 +------------------------- src/setup/dataImport.setup.ts | 9 ++++-- src/setup/dataImport/products.csv | 12 ++++---- 5 files changed, 25 insertions(+), 88 deletions(-) diff --git a/src/config/AppConfig.ts b/src/config/AppConfig.ts index 814daa14..a740b878 100644 --- a/src/config/AppConfig.ts +++ b/src/config/AppConfig.ts @@ -8,6 +8,7 @@ import TestUserConfig from '@/config/TestUserConfig'; import { ActivityCode } from '@/constants/ActivityCodes'; import { LocationTypeCode } from '@/constants/LocationTypeCode'; import RoleType from '@/constants/RoleTypes'; +import { readCsvFile } from '@/utils/FileIOUtils'; import UniqueIdentifier from '@/utils/UniqueIdentifier'; export enum USER_KEY { @@ -69,7 +70,7 @@ class AppConfig { public locations!: Record; // test products used in all of the tests - public products!: Record; + public products: Record = {}; //recivingbin configurable prefix public receivingBinPrefix!: string; @@ -262,44 +263,16 @@ class AppConfig { }), }; - this.products = { - productOne: new ProductConfig({ - id: env.get('PRODUCT_ONE').asString(), - key: PRODUCT_KEY.ONE, - name: this.uniqueIdentifier.generateUniqueString('product-one'), - quantity: 122, + // Fulfill products data in app config dynamically based on the products.csv + const productsData = readCsvFile(AppConfig.PRODUCTS_IMPORT_FILE_PATH); + productsData.forEach((productData) => { + this.products[productData['ProductCode']] = new ProductConfig({ + key: productData['ProductCode'], + name: productData['Name'], + quantity: parseInt(productData['Quantity']), required: false, - }), - productTwo: new ProductConfig({ - id: env.get('PRODUCT_TWO').asString(), - key: PRODUCT_KEY.TWO, - name: this.uniqueIdentifier.generateUniqueString('product-two'), - quantity: 123, - required: false, - }), - productThree: new ProductConfig({ - id: env.get('PRODUCT_THREE').asString(), - key: PRODUCT_KEY.THREE, - name: this.uniqueIdentifier.generateUniqueString('product-three'), - quantity: 150, - required: false, - }), - productFour: new ProductConfig({ - id: env.get('PRODUCT_FOUR').asString(), - key: PRODUCT_KEY.FOUR, - name: this.uniqueIdentifier.generateUniqueString('product-four'), - quantity: 100, - required: false, - }), - productFive: new ProductConfig({ - id: env.get('PRODUCT_FIVE').asString(), - key: PRODUCT_KEY.FIVE, - name: this.uniqueIdentifier.generateUniqueString('aa-product-five'), - //'aa' part was added to improve visibility of ordering products alphabetically - quantity: 160, - required: false, - }), - }; + }) + }) this.receivingBinPrefix = env .get('RECEIVING_BIN_PREFIX') diff --git a/src/config/ProductConfig.ts b/src/config/ProductConfig.ts index dd3b1ac8..1b6a6f29 100644 --- a/src/config/ProductConfig.ts +++ b/src/config/ProductConfig.ts @@ -44,7 +44,7 @@ class ProductConfig { * @returns {boolean} */ get isCreateNew() { - return !this.id; + return !this.readId(); } /** diff --git a/src/setup/createData.setup.ts b/src/setup/createData.setup.ts index a4bc78e8..0a6b42cd 100644 --- a/src/setup/createData.setup.ts +++ b/src/setup/createData.setup.ts @@ -1,58 +1,19 @@ import AppConfig from '@/config/AppConfig'; import { test } from '@/fixtures/fixtures'; import { readFile, writeToFile } from '@/utils/FileIOUtils'; -import { parseUrl } from '@/utils/UrlUtils'; test('create data', async ({ - page, - createProductPage, - productShowPage, locationService, mainLocationService, }) => { // eslint-disable-next-line playwright/no-conditional-in-test const data = readFile(AppConfig.TEST_DATA_FILE_PATH) || {}; - const seedData: Record<'products' | 'locations', Record> = { + const seedData: Record<'locations', Record> = { ...data, - products: {}, locations: {}, }; - // // PRODUCST - const products = Object.values(AppConfig.instance.products).filter( - (product) => product.isCreateNew - ); - - for (const product of products) { - await test.step(`create product ${product.key}`, async () => { - await createProductPage.goToPage(); - await createProductPage.waitForUrl(); - await createProductPage.productDetails.nameField.fill(product.name); - await createProductPage.productDetails.categorySelect.click(); - await createProductPage.productDetails.categorySelectDropdown - .getByRole('listitem') - .first() - .click(); - await createProductPage.saveButton.click(); - - await productShowPage.recordStockButton.click(); - - await productShowPage.recordStock.lineItemsTable - .row(1) - .newQuantity.getByRole('textbox') - .fill(`${product.quantity}`); - await productShowPage.recordStock.lineItemsTable.saveButton.click(); - await productShowPage.showStockCardButton.click(); - - const productUrl = parseUrl( - page.url(), - '/openboxes/inventoryItem/showStockCard/$id' - ); - seedData.products[`${product.key}`] = productUrl.id; - }); - } - // LOCATIONS const { organization } = await mainLocationService.getLocation(); const { data: locationTypes } = await locationService.getLocationTypes(); diff --git a/src/setup/dataImport.setup.ts b/src/setup/dataImport.setup.ts index 118b6ff4..5ddf7843 100644 --- a/src/setup/dataImport.setup.ts +++ b/src/setup/dataImport.setup.ts @@ -7,6 +7,11 @@ test('import data', async ({ request }) => { // eslint-disable-next-line playwright/no-conditional-in-test const data = readFile(AppConfig.TEST_DATA_FILE_PATH) || {}; + const seedData: Record<'products', Record> = { + ...data, + products: {}, + }; + // PRODUCTS const productService = new ProductService(request); @@ -15,9 +20,9 @@ test('import data', async ({ request }) => { await test.step(`importing ${productsData.length} products`, async () => { const importedData = await productService.importProducts(productsData); importedData.data.forEach((product) => { - data.products[product.productCode] = product.id; + seedData.products[product.productCode] = product.id; }) }) - writeToFile(AppConfig.TEST_DATA_FILE_PATH, data); + writeToFile(AppConfig.TEST_DATA_FILE_PATH, seedData); }); diff --git a/src/setup/dataImport/products.csv b/src/setup/dataImport/products.csv index 6b7affa4..a3c4de76 100644 --- a/src/setup/dataImport/products.csv +++ b/src/setup/dataImport/products.csv @@ -1,8 +1,6 @@ Id,ProductCode,ProductType,Name,ProductFamily,Category,GLAccount,Description,UnitOfMeasure,Tags,UnitCost,LotAndExpiryControl,ColdChain,ControlledSubstance,HazardousMaterial,Reconditioned,Manufacturer,BrandName,ManufacturerCode,ManufacturerName,Vendor,VendorCode,VendorName,UPC,NDC,Created,Updated -,1,Default,E2E-product-one-T0SOek,,ARVS,,,,,,,,,,,,,,,,,,,,19/Dec/2024 02:43:40,19/Dec/2024 02:43:40 -,2,Default,E2E-product-two-T0SOek,,ARVS,,,,,,,,,,,,,,,,,,,,19/Dec/2024 02:43:46,19/Dec/2024 02:43:46 -,3,Default,E2E-product-three-sUuCcW,,ARVS,,,,,,,,,,,,,,,,,,,,18/Feb/2025 11:15:58,18/Feb/2025 11:15:58 -,4,Default,E2E-product-four-sUuCcW,,ARVS,,,,,,,,,,,,,,,,,,,,18/Feb/2025 11:16:03,18/Feb/2025 11:16:03 -,5,Default,E2E-product-five-sUuCcW,,ARVS,,,,,,,,,,,,,,,,,,,,18/Feb/2025 11:16:07,18/Feb/2025 11:16:07 -,10001,Default,test product 1,,Food,,,,,,,,,,,,,,,,,,,,20/Feb/2025 02:53:27,20/Feb/2025 02:53:27 -,10002,Default,test product 2,,Chronic Care,,,,,,,,,,,,,,,,,,,,20/Feb/2025 02:54:03,20/Feb/2025 02:54:03 +,1,Default,E2E-product-one,,ARVS,,,,,,,,,,,,,,,,,,,,, +,2,Default,E2E-product-two,,ARVS,,,,,,,,,,,,,,,,,,,,, +,3,Default,E2E-product-three,,ARVS,,,,,,,,,,,,,,,,,,,,, +,4,Default,E2E-product-four,,ARVS,,,,,,,,,,,,,,,,,,,,, +,5,Default,E2E-product-five,,ARVS,,,,,,,,,,,,,,,,,,,,, From 7b9726a58e16901a1f1fb9f00cb2936dfa7e7b4e Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Wed, 3 Sep 2025 11:01:32 +0200 Subject: [PATCH 08/12] OBPIH-6969 Add inventories import --- src/api/InventoryService.ts | 23 +++++++++++++++++++++++ src/config/AppConfig.ts | 2 ++ src/setup/dataImport.setup.ts | 15 ++++++++++++++- src/setup/dataImport/inventory.csv | 3 +++ 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/api/InventoryService.ts create mode 100644 src/setup/dataImport/inventory.csv diff --git a/src/api/InventoryService.ts b/src/api/InventoryService.ts new file mode 100644 index 00000000..812037f4 --- /dev/null +++ b/src/api/InventoryService.ts @@ -0,0 +1,23 @@ +import BaseServiceModel from '@/api/BaseServiceModel'; +import { jsonToCsv } from '@/utils/ServiceUtils'; + +class InventoryService extends BaseServiceModel { + async importInventories(data: Record[], locationId: string): Promise { + try { + const csvContent = jsonToCsv(data); + + const response = await this.request.post(`./api/locations/${locationId}/inventories/import`, { + data: csvContent, + headers: { 'Content-Type': 'text/csv' }, + }); + + if (!response.ok()) { + throw new Error(`Import failed with status ${response.status()}: ${await response.text()}`); + } + } catch (error) { + throw new Error(`Problem importing inventories: ${error instanceof Error ? error.message : String(error)}`); + } + } +} + +export default InventoryService; diff --git a/src/config/AppConfig.ts b/src/config/AppConfig.ts index a740b878..f8f0c62c 100644 --- a/src/config/AppConfig.ts +++ b/src/config/AppConfig.ts @@ -57,6 +57,8 @@ class AppConfig { public static PRODUCTS_IMPORT_FILE_PATH = path.join(AppConfig.DATA_IMPORT_DIRECTORY_PATH, '/products.csv'); + public static INVENTORY_IMPORT_FILE_PATH = path.join(AppConfig.DATA_IMPORT_DIRECTORY_PATH, '/inventory.csv'); + // Base URL to use in actions like `await page.goto('./dashboard')`. public appURL!: string; diff --git a/src/setup/dataImport.setup.ts b/src/setup/dataImport.setup.ts index 5ddf7843..d3589e8e 100644 --- a/src/setup/dataImport.setup.ts +++ b/src/setup/dataImport.setup.ts @@ -1,3 +1,4 @@ +import InventoryService from '@/api/InventoryService'; import ProductService from '@/api/ProductService'; import AppConfig from '@/config/AppConfig'; import { test } from '@/fixtures/fixtures'; @@ -24,5 +25,17 @@ test('import data', async ({ request }) => { }) }) + // INVENTORIES + const inventoryService = new InventoryService(request); + + const inventoriesData = readCsvFile(AppConfig.INVENTORY_IMPORT_FILE_PATH); + + await test.step(`importing ${inventoriesData.length} inventories`, async () => { + await inventoryService.importInventories( + inventoriesData, + AppConfig.instance.locations.main.id, + ); + }); + writeToFile(AppConfig.TEST_DATA_FILE_PATH, seedData); -}); +}) diff --git a/src/setup/dataImport/inventory.csv b/src/setup/dataImport/inventory.csv new file mode 100644 index 00000000..402c3812 --- /dev/null +++ b/src/setup/dataImport/inventory.csv @@ -0,0 +1,3 @@ +Product code,Product,Lot number,Expiration date,Bin location,Quantity,Comment +1,E2E-product-one,,,,122, +2,E2E-product-two,,,,123, From 69fb942d9460983c8efe919ae83a6096e9612519 Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Fri, 5 Sep 2025 17:46:28 +0200 Subject: [PATCH 09/12] OBPIH-6969 Fix usages of product services --- src/fixtures/fixtures.ts | 19 ++------ .../createInbound/createInbound.test.ts | 16 +++---- .../downloadDocsFromSendPage.test.ts | 4 +- .../editDestinationFromSendPage.test.ts | 10 ++-- .../expectedDeliveryDate.test.ts | 10 ++-- .../inbound/createInbound/exportItems.test.ts | 8 ++-- .../createInbound/fieldValidation.test.ts | 4 +- .../inboundStatusChanges.test.ts | 8 ++-- .../createInbound/itemTemplate.test.ts | 32 ++++++------- .../inbound/createInbound/packLevels.test.ts | 4 +- .../inbound/createInbound/saveAndExit.test.ts | 4 +- .../selectPersonInRequestedBy.test.ts | 4 +- .../createInbound/switchLocations.test.ts | 4 +- .../createInbound/tableShortcuts.test.ts | 4 +- .../listPage/exportStockMovements.test.ts | 8 ++-- .../listPage/myStockMovementFilter.test.ts | 8 ++-- .../listPage/receiptStatusFilter.test.ts | 20 ++++---- .../listPage/shipmentTypeFilter.test.ts | 8 ++-- .../inbound/listPage/updatedByFilter.test.ts | 4 +- .../receiving/assertBinLocationField.test.ts | 5 +- .../assertCreationOfGoodsReceiptNote.test.ts | 8 ++-- .../assertCreationOfReceivingBin.test.ts | 8 ++-- src/tests/receiving/assertQtyInputs.test.ts | 12 ++--- .../receiving/assertRecipientField.test.ts | 9 ++-- .../receiving/cancelRemainingQty.test.ts | 8 ++-- .../editBinLocationWhenReceive.test.ts | 24 +++++----- .../receiving/editOriginalLineQtyTo0.test.ts | 46 +++++++++++-------- src/tests/receiving/editsInReceiving.test.ts | 8 ++-- .../receiving/exportReceivingTemplate.test.ts | 24 +++++----- .../receiving/importReceivingTemplate.test.ts | 4 +- .../lotExpirySystemUpdateOnReceiving.test.ts | 16 +++---- src/tests/receiving/receiveInbound.test.ts | 14 +++--- ...eiveInboundWithoutPartialReceiving.test.ts | 24 +++++----- ...eInboundWithoutPickAndPutawayStock.test.ts | 6 +-- src/tests/receiving/receiveToHoldBin.test.ts | 4 +- .../receiving/receivingStatusChanges.test.ts | 8 ++-- ...atusChangesWithoutPartialReceiving.test.ts | 8 ++-- .../receiving/rollbackStatusChanges.test.ts | 8 ++-- ...ByAlphabeticalOrderAndRemainInputs.test.ts | 24 ++++++---- .../tableShortcutsInReceiving.test.ts | 20 ++++---- .../validationsOnDeliverOnDate.test.ts | 4 +- .../validationsOnEditAndReceive.test.ts | 4 +- src/utils/ProductData.ts | 7 ++- 43 files changed, 245 insertions(+), 237 deletions(-) diff --git a/src/fixtures/fixtures.ts b/src/fixtures/fixtures.ts index 164f4d7b..461b60bc 100644 --- a/src/fixtures/fixtures.ts +++ b/src/fixtures/fixtures.ts @@ -10,7 +10,6 @@ import LocationChooser from '@/components/LocationChooser'; import Navbar from '@/components/Navbar'; import AppConfig, { LOCATION_KEY, - PRODUCT_KEY, USER_KEY, } from '@/config/AppConfig'; import CreateInbound from '@/pages/inbound/create/CreateInboundPage'; @@ -82,11 +81,7 @@ type Fixtures = { wardLocationService: LocationData; noPickAndPutawayStockDepotService: LocationData; // PRODUCT DATA - mainProductService: ProductData; - otherProductService: ProductData; - thirdProductService: ProductData; - fourthProductService: ProductData; - fifthProductService: ProductData; + productService: ProductData; // USERS DATA mainUserService: UserData; altUserService: UserData; @@ -159,16 +154,8 @@ export const test = baseTest.extend({ noPickAndPutawayStockDepotService: async ({ page }, use) => use(new LocationData(LOCATION_KEY.NO_PICK_AND_PUTAWAY_STOCK, page.request)), // PRODUCTS - mainProductService: async ({ page }, use) => - use(new ProductData(PRODUCT_KEY.ONE, page.request)), - otherProductService: async ({ page }, use) => - use(new ProductData(PRODUCT_KEY.TWO, page.request)), - thirdProductService: async ({ page }, use) => - use(new ProductData(PRODUCT_KEY.THREE, page.request)), - fourthProductService: async ({ page }, use) => - use(new ProductData(PRODUCT_KEY.FOUR, page.request)), - fifthProductService: async ({ page }, use) => - use(new ProductData(PRODUCT_KEY.FIVE, page.request)), + productService: async ({ page }, use) => + use(new ProductData(page.request)), // USERS mainUserService: async ({ page }, use) => use(new UserData(USER_KEY.MAIN, page.request)), diff --git a/src/tests/inbound/createInbound/createInbound.test.ts b/src/tests/inbound/createInbound/createInbound.test.ts index 4968b5da..6e9b19ac 100644 --- a/src/tests/inbound/createInbound/createInbound.test.ts +++ b/src/tests/inbound/createInbound/createInbound.test.ts @@ -18,14 +18,14 @@ test.describe('Create inbound stock movement', () => { test.beforeEach( async ({ - mainProductService, - otherProductService, + productService, mainUserService, supplierLocationService, mainLocationService, }) => { - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); USER = await mainUserService.getUser(); ORIGIN = await supplierLocationService.getLocation(); CURRENT_LOCATION = await mainLocationService.getLocation(); @@ -188,15 +188,15 @@ test.describe('Values persistance between steps', () => { test.beforeEach( async ({ - mainProductService, - otherProductService, + productService, mainUserService, createInboundPage, mainLocationService, supplierLocationService, }) => { - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); USER = await mainUserService.getUser(); CURRENT_LOCATION = await mainLocationService.getLocation(); ORIGIN = await supplierLocationService.getLocation(); diff --git a/src/tests/inbound/createInbound/downloadDocsFromSendPage.test.ts b/src/tests/inbound/createInbound/downloadDocsFromSendPage.test.ts index 08d892dd..e2ee91c3 100644 --- a/src/tests/inbound/createInbound/downloadDocsFromSendPage.test.ts +++ b/src/tests/inbound/createInbound/downloadDocsFromSendPage.test.ts @@ -16,11 +16,11 @@ test.describe('Download documents from inbound send page', () => { test.beforeEach( async ({ - mainProductService, + productService, mainUserService, supplierLocationService, }) => { - const PRODUCT_ONE = await mainProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); USER = await mainUserService.getUser(); ORIGIN = await supplierLocationService.getLocation(); diff --git a/src/tests/inbound/createInbound/editDestinationFromSendPage.test.ts b/src/tests/inbound/createInbound/editDestinationFromSendPage.test.ts index 79be1dc3..b9b528f1 100644 --- a/src/tests/inbound/createInbound/editDestinationFromSendPage.test.ts +++ b/src/tests/inbound/createInbound/editDestinationFromSendPage.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import productService from '@/api/ProductService'; test.describe('Edit destination from send page', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -10,12 +11,13 @@ test.describe('Edit destination from send page', () => { async ({ supplierLocationService, stockMovementService, - otherProductService, - thirdProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const PRODUCT_TWO = await otherProductService.getProduct(); - const PRODUCT_THREE = await thirdProductService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); + productService.setProduct('3') + const PRODUCT_THREE = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, diff --git a/src/tests/inbound/createInbound/expectedDeliveryDate.test.ts b/src/tests/inbound/createInbound/expectedDeliveryDate.test.ts index fcc57370..31e8ff34 100644 --- a/src/tests/inbound/createInbound/expectedDeliveryDate.test.ts +++ b/src/tests/inbound/createInbound/expectedDeliveryDate.test.ts @@ -1,6 +1,7 @@ import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse, User } from '@/types'; import { formatDate, getDateByOffset } from '@/utils/DateUtils'; +import productService from '@/api/ProductService'; test.describe('Expected delivery date tests', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -12,13 +13,14 @@ test.describe('Expected delivery date tests', () => { supplierLocationService, mainUserService, stockMovementService, - thirdProductService, - fourthProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); USER = await mainUserService.getUser(); - const PRODUCT_THREE = await thirdProductService.getProduct(); - const PRODUCT_FOUR = await fourthProductService.getProduct(); + productService.setProduct('3'); + const PRODUCT_THREE = await productService.getProduct(); + productService.setProduct('4'); + const PRODUCT_FOUR = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, diff --git a/src/tests/inbound/createInbound/exportItems.test.ts b/src/tests/inbound/createInbound/exportItems.test.ts index e7b9d83d..9016932a 100644 --- a/src/tests/inbound/createInbound/exportItems.test.ts +++ b/src/tests/inbound/createInbound/exportItems.test.ts @@ -11,9 +11,8 @@ test.describe('Export all incoming items', () => { async ({ supplierLocationService, createInboundPage, - mainProductService, + productService, mainUserService, - otherProductService, stockMovementShowPage, inboundListPage, }) => { @@ -22,8 +21,9 @@ test.describe('Export all incoming items', () => { const USER = await mainUserService.getUser(); const TODAY = getToday(); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); const SHIPMENT_TYPE = 'Land'; const EXPECTED_DELIVERY_DATE = getDateByOffset(TODAY, 1); diff --git a/src/tests/inbound/createInbound/fieldValidation.test.ts b/src/tests/inbound/createInbound/fieldValidation.test.ts index 55b194fb..c4f550a1 100644 --- a/src/tests/inbound/createInbound/fieldValidation.test.ts +++ b/src/tests/inbound/createInbound/fieldValidation.test.ts @@ -11,12 +11,12 @@ let ORIGIN: LocationResponse; test.beforeEach( async ({ - mainProductService, + productService, mainUserService, createInboundPage, supplierLocationService, }) => { - const PRODUCT_ONE = await mainProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); USER = await mainUserService.getUser(); ORIGIN = await supplierLocationService.getLocation(); diff --git a/src/tests/inbound/createInbound/inboundStatusChanges.test.ts b/src/tests/inbound/createInbound/inboundStatusChanges.test.ts index 374f6d00..0b3fded5 100644 --- a/src/tests/inbound/createInbound/inboundStatusChanges.test.ts +++ b/src/tests/inbound/createInbound/inboundStatusChanges.test.ts @@ -22,13 +22,13 @@ test.describe('Status changes for inbound sm on view sm and inbound list page', test.beforeEach( async ({ - mainProductService, - otherProductService, + productService, mainUserService, supplierLocationService, }) => { - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); USER = await mainUserService.getUser(); ORIGIN = await supplierLocationService.getLocation(); diff --git a/src/tests/inbound/createInbound/itemTemplate.test.ts b/src/tests/inbound/createInbound/itemTemplate.test.ts index b6ad0cce..8adf329c 100644 --- a/src/tests/inbound/createInbound/itemTemplate.test.ts +++ b/src/tests/inbound/createInbound/itemTemplate.test.ts @@ -75,8 +75,7 @@ test.describe('Export items template on inbound add items page', () => { test('Downloaded template should contain all added items', async ({ createInboundPage, - mainProductService, - otherProductService, + productService, mainUserService, }) => { await test.step('Go to inbound list page', async () => { @@ -84,8 +83,9 @@ test.describe('Export items template on inbound add items page', () => { await createInboundPage.addItemsStep.isLoaded(); }); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); const USER = await mainUserService.getUser(); const ROWS = [ @@ -175,8 +175,7 @@ test.describe('Import template with data', () => { test('Import filled template on an empty table', async ({ createInboundPage, - mainProductService, - otherProductService, + productService, mainUserService, }) => { await test.step('Go to inbound list page', async () => { @@ -193,8 +192,9 @@ test.describe('Import template with data', () => { workbooks.push(downloadedTemplateFile); }); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); const USER = await mainUserService.getUser(); const ROWS = [ @@ -254,8 +254,7 @@ test.describe('Import template with data', () => { test.skip('Update existing values with template import', async ({ createInboundPage, - otherProductService, - mainProductService, + productService, altUserService, mainUserService, }) => { @@ -265,7 +264,7 @@ test.describe('Import template with data', () => { }); await test.step('Add items to table', async () => { - const PRODUCT_ONE = await mainProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); const USER = await mainUserService.getUser(); const ROWS = [ @@ -300,7 +299,8 @@ test.describe('Import template with data', () => { parsedDocumentData = downloadedTemplateFile.sheetToJSON(); }); - const PRODUCT_TWO = await otherProductService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); const ALT_USER = await altUserService.getUser(); const NEW_ROW = { @@ -345,8 +345,7 @@ test.describe('Import template with data', () => { test('Add new row to with existing items in the table', async ({ createInboundPage, - otherProductService, - mainProductService, + productService, altUserService, mainUserService, }) => { @@ -357,7 +356,7 @@ test.describe('Import template with data', () => { let ROW: CreateInboundAddItemsTableEntity; await test.step('Add items to table', async () => { - const PRODUCT_ONE = await mainProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); const USER = await mainUserService.getUser(); ROW = { @@ -389,7 +388,8 @@ test.describe('Import template with data', () => { parsedDocumentData = downloadedTemplateFile.sheetToJSON(); }); - const PRODUCT_TWO = await otherProductService.getProduct(); + productService.setProduct('2') + const PRODUCT_TWO = await productService.getProduct(); const ALT_USER = await altUserService.getUser(); const NEW_ROW = { diff --git a/src/tests/inbound/createInbound/packLevels.test.ts b/src/tests/inbound/createInbound/packLevels.test.ts index acbd47e5..2c38f2f8 100644 --- a/src/tests/inbound/createInbound/packLevels.test.ts +++ b/src/tests/inbound/createInbound/packLevels.test.ts @@ -8,12 +8,12 @@ let INBOUND_ID: string; test.beforeEach( async ({ - mainProductService, + productService, mainUserService, createInboundPage, supplierLocationService, }) => { - const PRODUCT_ONE = await mainProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); const USER = await mainUserService.getUser(); const ORIGIN = await supplierLocationService.getLocation(); const DESCRIPTION = 'some description'; diff --git a/src/tests/inbound/createInbound/saveAndExit.test.ts b/src/tests/inbound/createInbound/saveAndExit.test.ts index 19d252a9..23b5ddbc 100644 --- a/src/tests/inbound/createInbound/saveAndExit.test.ts +++ b/src/tests/inbound/createInbound/saveAndExit.test.ts @@ -8,12 +8,12 @@ let INBOUND_ID: string; test.beforeEach( async ({ - mainProductService, + productService, mainUserService, createInboundPage, supplierLocationService, }) => { - const PRODUCT_ONE = await mainProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); const USER = await mainUserService.getUser(); const ORIGIN = await supplierLocationService.getLocation(); const DESCRIPTION = 'some description'; diff --git a/src/tests/inbound/createInbound/selectPersonInRequestedBy.test.ts b/src/tests/inbound/createInbound/selectPersonInRequestedBy.test.ts index fceff999..47419bfc 100644 --- a/src/tests/inbound/createInbound/selectPersonInRequestedBy.test.ts +++ b/src/tests/inbound/createInbound/selectPersonInRequestedBy.test.ts @@ -18,13 +18,13 @@ test.describe('Select person in requested by', () => { test.beforeEach( async ({ - mainProductService, + productService, supplierLocationService, page, personsListPage, createPersonPage, }) => { - const PRODUCT_ONE = await mainProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); ORIGIN = await supplierLocationService.getLocation(); ROWS = [ diff --git a/src/tests/inbound/createInbound/switchLocations.test.ts b/src/tests/inbound/createInbound/switchLocations.test.ts index b7505939..0e2887a1 100644 --- a/src/tests/inbound/createInbound/switchLocations.test.ts +++ b/src/tests/inbound/createInbound/switchLocations.test.ts @@ -10,12 +10,12 @@ test.describe('Switching location on inbound stock movement', () => { test.beforeEach( async ({ - mainProductService, + productService, mainUserService, createInboundPage, supplierLocationService, }) => { - const PRODUCT_ONE = await mainProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); const USER = await mainUserService.getUser(); const ORIGIN = await supplierLocationService.getLocation(); const DESCRIPTION = 'some description'; diff --git a/src/tests/inbound/createInbound/tableShortcuts.test.ts b/src/tests/inbound/createInbound/tableShortcuts.test.ts index b17ef13e..2f003e7f 100644 --- a/src/tests/inbound/createInbound/tableShortcuts.test.ts +++ b/src/tests/inbound/createInbound/tableShortcuts.test.ts @@ -7,12 +7,12 @@ let INBOUND_ID: string; test.beforeEach( async ({ - mainProductService, + productService, mainUserService, createInboundPage, supplierLocationService, }) => { - const PRODUCT_ONE = await mainProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); const USER = await mainUserService.getUser(); const ORIGIN = await supplierLocationService.getLocation(); const DESCRIPTION = 'some description'; diff --git a/src/tests/inbound/listPage/exportStockMovements.test.ts b/src/tests/inbound/listPage/exportStockMovements.test.ts index 05b266ea..5b92065a 100644 --- a/src/tests/inbound/listPage/exportStockMovements.test.ts +++ b/src/tests/inbound/listPage/exportStockMovements.test.ts @@ -14,12 +14,12 @@ test.describe('Export stock movements', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, - otherProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); INBOUND1 = await stockMovementService.createInbound({ originId: supplierLocation.id, diff --git a/src/tests/inbound/listPage/myStockMovementFilter.test.ts b/src/tests/inbound/listPage/myStockMovementFilter.test.ts index 7124ecb2..1e71a804 100644 --- a/src/tests/inbound/listPage/myStockMovementFilter.test.ts +++ b/src/tests/inbound/listPage/myStockMovementFilter.test.ts @@ -11,13 +11,13 @@ test.describe('My Stock Movement filter', () => { supplierLocationService, mainUserService, stockMovementService, - mainProductService, - otherProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); USER = await mainUserService.getUser(); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); INBOUND = await stockMovementService.createInbound({ originId: supplierLocation.id, diff --git a/src/tests/inbound/listPage/receiptStatusFilter.test.ts b/src/tests/inbound/listPage/receiptStatusFilter.test.ts index a8238f00..12e79400 100644 --- a/src/tests/inbound/listPage/receiptStatusFilter.test.ts +++ b/src/tests/inbound/listPage/receiptStatusFilter.test.ts @@ -53,14 +53,14 @@ test.describe('Filter by "Shipped" status', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, }); - const product = await mainProductService.getProduct(); + const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -116,7 +116,7 @@ test.describe('Filter by "Received" status', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, + productService, stockMovementShowPage, receivingPage, }) => { @@ -125,7 +125,7 @@ test.describe('Filter by "Received" status', () => { originId: supplierLocation.id, }); - const product = await mainProductService.getProduct(); + const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -207,8 +207,7 @@ test.describe('Filter by "Receiving" status', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, - otherProductService, + productService, stockMovementShowPage, receivingPage, }) => { @@ -217,8 +216,9 @@ test.describe('Filter by "Receiving" status', () => { originId: supplierLocation.id, }); - const product = await mainProductService.getProduct(); - const productTwo = await otherProductService.getProduct(); + const product = await productService.getProduct(); + productService.setProduct('2'); + const productTwo = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -304,7 +304,7 @@ test.describe('Filter by multiple statuses - "Pending" and "Shipped"', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); STOCK_MOVEMENT = await stockMovementService.createInbound({ @@ -315,7 +315,7 @@ test.describe('Filter by multiple statuses - "Pending" and "Shipped"', () => { originId: supplierLocation.id, }); - const product = await mainProductService.getProduct(); + const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT_TWO.id, diff --git a/src/tests/inbound/listPage/shipmentTypeFilter.test.ts b/src/tests/inbound/listPage/shipmentTypeFilter.test.ts index dfb21e2f..8ed7e903 100644 --- a/src/tests/inbound/listPage/shipmentTypeFilter.test.ts +++ b/src/tests/inbound/listPage/shipmentTypeFilter.test.ts @@ -16,11 +16,11 @@ test.describe('Shipment type filter', () => { test.beforeEach( async ({ supplierLocationService, - mainProductService, + productService, stockMovementService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const product = await mainProductService.getProduct(); + const product = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -107,11 +107,11 @@ test.describe('Multiple shipment types', () => { test.beforeEach( async ({ supplierLocationService, - mainProductService, + productService, stockMovementService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const product = await mainProductService.getProduct(); + const product = await productService.getProduct(); STOCK_MOVEMENT_LAND = await stockMovementService.createInbound({ originId: supplierLocation.id, diff --git a/src/tests/inbound/listPage/updatedByFilter.test.ts b/src/tests/inbound/listPage/updatedByFilter.test.ts index e7859a14..7c2d1807 100644 --- a/src/tests/inbound/listPage/updatedByFilter.test.ts +++ b/src/tests/inbound/listPage/updatedByFilter.test.ts @@ -32,9 +32,9 @@ test.describe('Use "Updated By" filter', () => { test('Only show stock movements updated by filtered user', async ({ altUserContext, inboundListPage, - mainProductService, + productService, }) => { - const product = await mainProductService.getProduct(); + const product = await productService.getProduct(); await test.step('Go to inbound list page', async () => { await inboundListPage.goToPage(); diff --git a/src/tests/receiving/assertBinLocationField.test.ts b/src/tests/receiving/assertBinLocationField.test.ts index 7dcd40b4..a7657c63 100644 --- a/src/tests/receiving/assertBinLocationField.test.ts +++ b/src/tests/receiving/assertBinLocationField.test.ts @@ -10,10 +10,11 @@ test.describe('Assert bin location not clearable', () => { async ({ supplierLocationService, stockMovementService, - fourthProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const PRODUCT_FOUR = await fourthProductService.getProduct(); + productService.setProduct('4'); + const PRODUCT_FOUR = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, diff --git a/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts b/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts index 05eead7e..d77e093e 100644 --- a/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts +++ b/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts @@ -9,12 +9,12 @@ test.describe('Assert Goods Receipt Note is created and opened', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, - thirdProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_THREE = await thirdProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('3'); + const PRODUCT_THREE = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, diff --git a/src/tests/receiving/assertCreationOfReceivingBin.test.ts b/src/tests/receiving/assertCreationOfReceivingBin.test.ts index 6245728a..b89591e2 100644 --- a/src/tests/receiving/assertCreationOfReceivingBin.test.ts +++ b/src/tests/receiving/assertCreationOfReceivingBin.test.ts @@ -14,12 +14,12 @@ test.describe('Assert creation of receiving bin', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, - otherProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, diff --git a/src/tests/receiving/assertQtyInputs.test.ts b/src/tests/receiving/assertQtyInputs.test.ts index a74d1027..30dc6697 100644 --- a/src/tests/receiving/assertQtyInputs.test.ts +++ b/src/tests/receiving/assertQtyInputs.test.ts @@ -10,14 +10,14 @@ test.describe('Assert if quantity inputs remain when split lines', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, - otherProductService, - thirdProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); - const PRODUCT_THREE = await thirdProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); + productService.setProduct('3'); + const PRODUCT_THREE = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, diff --git a/src/tests/receiving/assertRecipientField.test.ts b/src/tests/receiving/assertRecipientField.test.ts index 083c32e1..0bb3abb5 100644 --- a/src/tests/receiving/assertRecipientField.test.ts +++ b/src/tests/receiving/assertRecipientField.test.ts @@ -9,13 +9,14 @@ test.describe('Assert recipient field when receive', () => { async ({ supplierLocationService, stockMovementService, - fourthProductService, - fifthProductService, + productService, mainUserService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const PRODUCT_FOUR = await fourthProductService.getProduct(); - const PRODUCT_FIVE = await fifthProductService.getProduct(); + productService.setProduct('4'); + const PRODUCT_FOUR = await productService.getProduct(); + productService.setProduct('5'); + const PRODUCT_FIVE = await productService.getProduct(); const USER = await mainUserService.getUser(); STOCK_MOVEMENT = await stockMovementService.createInbound({ diff --git a/src/tests/receiving/cancelRemainingQty.test.ts b/src/tests/receiving/cancelRemainingQty.test.ts index 827b8761..3cbea0e5 100644 --- a/src/tests/receiving/cancelRemainingQty.test.ts +++ b/src/tests/receiving/cancelRemainingQty.test.ts @@ -9,12 +9,12 @@ test.describe('Cancel qty in the middle of receipt', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, - otherProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, diff --git a/src/tests/receiving/editBinLocationWhenReceive.test.ts b/src/tests/receiving/editBinLocationWhenReceive.test.ts index cfa38575..c8940473 100644 --- a/src/tests/receiving/editBinLocationWhenReceive.test.ts +++ b/src/tests/receiving/editBinLocationWhenReceive.test.ts @@ -15,16 +15,16 @@ test.describe('Edit Bin Location when receive inbound stock movement', () => { supplierLocationService, mainLocationService, stockMovementService, - mainProductService, - otherProductService, + productService, page, locationListPage, createLocationPage, }) => { const supplierLocation = await supplierLocationService.getLocation(); const mainLocation = await mainLocationService.getLocation(); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -170,16 +170,16 @@ test.describe('Edit Bin Location to bin with zone when receive inbound stock mov supplierLocationService, mainLocationService, stockMovementService, - mainProductService, - otherProductService, + productService, page, locationListPage, createLocationPage, }) => { const supplierLocation = await supplierLocationService.getLocation(); const mainLocation = await mainLocationService.getLocation(); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -374,16 +374,16 @@ test.describe('Edit Bin Location when receive for all lines', () => { supplierLocationService, mainLocationService, stockMovementService, - mainProductService, - otherProductService, + productService, page, locationListPage, createLocationPage, }) => { const supplierLocation = await supplierLocationService.getLocation(); const mainLocation = await mainLocationService.getLocation(); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, diff --git a/src/tests/receiving/editOriginalLineQtyTo0.test.ts b/src/tests/receiving/editOriginalLineQtyTo0.test.ts index 801b95c4..99948a30 100644 --- a/src/tests/receiving/editOriginalLineQtyTo0.test.ts +++ b/src/tests/receiving/editOriginalLineQtyTo0.test.ts @@ -13,18 +13,18 @@ test.describe('Edit qty of original line to 0', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, - otherProductService, - thirdProductService, - fourthProductService, - fifthProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); - const PRODUCT_THREE = await thirdProductService.getProduct(); - const PRODUCT_FOUR = await fourthProductService.getProduct(); - const PRODUCT_FIVE = await fifthProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); + productService.setProduct('3'); + const PRODUCT_THREE = await productService.getProduct(); + productService.setProduct('4') + const PRODUCT_FOUR = await productService.getProduct(); + productService.setProduct('5') + const PRODUCT_FIVE = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -219,10 +219,11 @@ test.describe('Edit original line to other product in the middle of receipt', () async ({ supplierLocationService, stockMovementService, - fourthProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const PRODUCT_FOUR = await fourthProductService.getProduct(); + productService.setProduct('4'); + const PRODUCT_FOUR = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -261,8 +262,7 @@ test.describe('Edit original line to other product in the middle of receipt', () test('Edit qty of original line to 0 and edit product to other', async ({ stockMovementShowPage, receivingPage, - fifthProductService, - fourthProductService, + productService, }) => { await test.step('Go to stock movement show page', async () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); @@ -275,7 +275,8 @@ test.describe('Edit original line to other product in the middle of receipt', () }); await test.step('Open edit modal for item', async () => { - const PRODUCT_FIVE = await fifthProductService.getProduct(); + productService.setProduct('5'); + const PRODUCT_FIVE = await productService.getProduct(); await receivingPage.receivingStep.table.row(1).editButton.click(); await receivingPage.receivingStep.editModal.isLoaded(); await receivingPage.receivingStep.editModal.addLineButton.click(); @@ -296,8 +297,10 @@ test.describe('Edit original line to other product in the middle of receipt', () }); await test.step('Assert line with qty 0 is disabled', async () => { - const PRODUCT_FOUR = await fourthProductService.getProduct(); - const PRODUCT_FIVE = await fifthProductService.getProduct(); + productService.setProduct('4'); + const PRODUCT_FOUR = await productService.getProduct(); + productService.setProduct('5') + const PRODUCT_FIVE = await productService.getProduct(); await expect( receivingPage.receivingStep.table.row(1).checkbox ).toBeDisabled(); @@ -337,7 +340,8 @@ test.describe('Edit original line to other product in the middle of receipt', () }); await test.step('Assert product name on check step', async () => { - const PRODUCT_FIVE = await fifthProductService.getProduct(); + productService.setProduct('5'); + const PRODUCT_FIVE = await productService.getProduct(); await receivingPage.nextButton.click(); await receivingPage.checkStep.isLoaded(); await expect( @@ -352,8 +356,10 @@ test.describe('Edit original line to other product in the middle of receipt', () }); await test.step('Assert received product on stock movement show page', async () => { - const PRODUCT_FOUR = await fourthProductService.getProduct(); - const PRODUCT_FIVE = await fifthProductService.getProduct(); + productService.setProduct('4'); + const PRODUCT_FOUR = await productService.getProduct(); + productService.setProduct('5'); + const PRODUCT_FIVE = await productService.getProduct(); await stockMovementShowPage.packingListTab.isVisible(); await expect( stockMovementShowPage.packingListTable.row(1).product diff --git a/src/tests/receiving/editsInReceiving.test.ts b/src/tests/receiving/editsInReceiving.test.ts index 2deeb461..bc385127 100644 --- a/src/tests/receiving/editsInReceiving.test.ts +++ b/src/tests/receiving/editsInReceiving.test.ts @@ -14,12 +14,12 @@ test.describe('Edit items in the middle of receipt', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, - otherProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, diff --git a/src/tests/receiving/exportReceivingTemplate.test.ts b/src/tests/receiving/exportReceivingTemplate.test.ts index 54414a6e..a3e71f46 100644 --- a/src/tests/receiving/exportReceivingTemplate.test.ts +++ b/src/tests/receiving/exportReceivingTemplate.test.ts @@ -18,14 +18,14 @@ test.describe('Export receiving template', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, - otherProductService, - thirdProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); - const PRODUCT_THREE = await thirdProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); + productService.setProduct('3'); + const PRODUCT_THREE = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -65,16 +65,16 @@ test.describe('Export receiving template', () => { test('Export receiving template', async ({ stockMovementShowPage, receivingPage, - mainProductService, - otherProductService, - thirdProductService + productService, }) => { let filePath: string; let downloadedExportTemplateFile: WorkbookUtils; - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); - const PRODUCT_THREE = await thirdProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); + productService.setProduct('3'); + const PRODUCT_THREE = await productService.getProduct(); const ROWS = [ { diff --git a/src/tests/receiving/importReceivingTemplate.test.ts b/src/tests/receiving/importReceivingTemplate.test.ts index 9a765bca..f72cbb9a 100644 --- a/src/tests/receiving/importReceivingTemplate.test.ts +++ b/src/tests/receiving/importReceivingTemplate.test.ts @@ -21,10 +21,10 @@ test.describe('Import receiving template', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const PRODUCT_ONE = await mainProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, diff --git a/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts b/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts index 1a7052f4..51a0e20e 100644 --- a/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts +++ b/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts @@ -39,7 +39,7 @@ test.describe('Lot number system expiry date modification on receiving workflow' stockMovementShowPage, receivingPage, stockMovementService, - mainProductService, + productService, productShowPage, supplierLocationService, }) => { @@ -54,7 +54,7 @@ test.describe('Lot number system expiry date modification on receiving workflow' const UPDATED_EXPIRY_DATE_NEW_LOT = getDateByOffset(getToday(), 2); - const product = await mainProductService.getProduct(); + const product = await productService.getProduct(); await test.step('Ensure that lot number does not exist in product stock', async () => { await productShowPage.goToPage(product.id); @@ -170,7 +170,7 @@ test.describe('Lot number system expiry date modification on receiving workflow' stockMovementShowPage, receivingPage, stockMovementService, - mainProductService, + productService, productShowPage, supplierLocationService, }) => { @@ -178,7 +178,7 @@ test.describe('Lot number system expiry date modification on receiving workflow' let STOCK_MOVEMENT: StockMovementResponse; - const product = await mainProductService.getProduct(); + const product = await productService.getProduct(); TEST_INPUT_STOCK_EXISTING_LOT.lotNumber = uniqueIdentifier.generateUniqueString('lot'); @@ -261,13 +261,13 @@ test.describe('Lot number system expiry date modification on receiving workflow' stockMovementShowPage, receivingPage, stockMovementService, - mainProductService, + productService, productShowPage, supplierLocationService, }) => { let STOCK_MOVEMENT_2: StockMovementResponse; - const product = await mainProductService.getProduct(); + const product = await productService.getProduct(); await test.step('Create second inbound stock movement', async () => { const supplierLocation = await supplierLocationService.getLocation(); @@ -375,13 +375,13 @@ test.describe('Lot number system expiry date modification on receiving workflow' stockMovementShowPage, receivingPage, stockMovementService, - mainProductService, + productService, productShowPage, supplierLocationService, }) => { let STOCK_MOVEMENT_2: StockMovementResponse; - const product = await mainProductService.getProduct(); + const product = await productService.getProduct(); await test.step('Create second inbound stock movement', async () => { const supplierLocation = await supplierLocationService.getLocation(); diff --git a/src/tests/receiving/receiveInbound.test.ts b/src/tests/receiving/receiveInbound.test.ts index f1176075..9cc2ec4b 100644 --- a/src/tests/receiving/receiveInbound.test.ts +++ b/src/tests/receiving/receiveInbound.test.ts @@ -14,8 +14,7 @@ test.describe('Receive inbound stock movement', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, - otherProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); STOCK_MOVEMENT = await stockMovementService.createInbound({ @@ -24,8 +23,9 @@ test.describe('Receive inbound stock movement', () => { dateRequested, }); - const product = await mainProductService.getProduct(); - const product2 = await otherProductService.getProduct(); + const product = await productService.getProduct(); + productService.setProduct('2'); + const product2 = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -61,7 +61,7 @@ test.describe('Receive inbound stock movement', () => { receivingPage, supplierLocationService, mainLocationService, - mainProductService, + productService, }) => { await test.step('Go to stock movement show page', async () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); @@ -115,7 +115,7 @@ test.describe('Receive inbound stock movement', () => { }); await test.step('Assert product in receiving table', async () => { - const item = await mainProductService.getProduct(); + const item = await productService.getProduct(); await receivingPage.receivingStep.table.row(1).getItem(item.name).hover(); await expect(receivingPage.tooltip).toContainText(item.name); }); @@ -171,7 +171,7 @@ test.describe('Receive inbound stock movement', () => { }); await test.step('Assert product in checking table', async () => { - const item = await mainProductService.getProduct(); + const item = await productService.getProduct(); await receivingPage.checkStep.table.row(1).getItem(item.name).hover(); await expect(receivingPage.tooltip).toContainText(item.name); }); diff --git a/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts b/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts index a99f753f..f237d64a 100644 --- a/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts +++ b/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts @@ -13,14 +13,14 @@ test.describe('Receive inbound stock movement in location without partial receiv async ({ supplierLocationService, stockMovementService, - mainProductService, - otherProductService, + productService, depotLocationService, }) => { const supplierLocation = await supplierLocationService.getLocation(); const depotLocation = await depotLocationService.getLocation(); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -68,8 +68,7 @@ test.describe('Receive inbound stock movement in location without partial receiv receivingPage, supplierLocationService, depotLocationService, - mainProductService, - otherProductService, + productService, authService, }) => { await test.step('Go to stock movement show page', async () => { @@ -121,8 +120,9 @@ test.describe('Receive inbound stock movement in location without partial receiv }); await test.step('Assert product in receiving table', async () => { - const item = await mainProductService.getProduct(); - const item2 = await otherProductService.getProduct(); + const item = await productService.getProduct(); + productService.setProduct('2'); + const item2 = await productService.getProduct(); await receivingPage.receivingStep.table.row(1).getItem(item.name).hover(); await expect(receivingPage.tooltip).toContainText(item.name); await receivingPage.receivingStep.table @@ -166,8 +166,7 @@ test.describe('Receive inbound stock movement in location without partial receiv receivingPage, supplierLocationService, depotLocationService, - mainProductService, - otherProductService, + productService, authService, }) => { await test.step('Go to stock movement show page', async () => { @@ -245,8 +244,9 @@ test.describe('Receive inbound stock movement in location without partial receiv }); await test.step('Assert product in checking table', async () => { - const item = await mainProductService.getProduct(); - const item2 = await otherProductService.getProduct(); + const item = await productService.getProduct(); + productService.setProduct('2'); + const item2 = await productService.getProduct(); await receivingPage.checkStep.table.row(1).getItem(item.name).hover(); await expect(receivingPage.tooltip).toContainText(item.name); await receivingPage.receivingStep.table diff --git a/src/tests/receiving/receiveInboundWithoutPickAndPutawayStock.test.ts b/src/tests/receiving/receiveInboundWithoutPickAndPutawayStock.test.ts index ebcc55a0..a7789fe7 100644 --- a/src/tests/receiving/receiveInboundWithoutPickAndPutawayStock.test.ts +++ b/src/tests/receiving/receiveInboundWithoutPickAndPutawayStock.test.ts @@ -13,12 +13,12 @@ test.describe('Receive inbound stock movement in location without pick and putaw async ({ supplierLocationService, stockMovementService, - mainProductService, + productService, noPickAndPutawayStockDepotService, }) => { const supplierLocation = await supplierLocationService.getLocation(); const noPickAndPutawayStockDepot= await noPickAndPutawayStockDepotService.getLocation(); - const PRODUCT_ONE = await mainProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -100,7 +100,7 @@ test.describe('Receive inbound stock movement in location without pick and putaw await test.step('Go to and assert checking page is visible', async () => { - await receivingPage.nextButton.click(); + await receivingPage.nextButton.click(); await receivingPage.checkStep.isLoaded(); }); diff --git a/src/tests/receiving/receiveToHoldBin.test.ts b/src/tests/receiving/receiveToHoldBin.test.ts index 230772a1..e2854b85 100644 --- a/src/tests/receiving/receiveToHoldBin.test.ts +++ b/src/tests/receiving/receiveToHoldBin.test.ts @@ -15,14 +15,14 @@ test.describe('Receive item into hold bin', () => { supplierLocationService, mainLocationService, stockMovementService, - mainProductService, + productService, page, locationListPage, createLocationPage, }) => { const supplierLocation = await supplierLocationService.getLocation(); const mainLocation = await mainLocationService.getLocation(); - const PRODUCT_ONE = await mainProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, diff --git a/src/tests/receiving/receivingStatusChanges.test.ts b/src/tests/receiving/receivingStatusChanges.test.ts index 90e9c47d..2b66d4aa 100644 --- a/src/tests/receiving/receivingStatusChanges.test.ts +++ b/src/tests/receiving/receivingStatusChanges.test.ts @@ -14,12 +14,12 @@ test.describe('Status changes on sm view page when receive shipment', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, - otherProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, diff --git a/src/tests/receiving/receivingStatusChangesWithoutPartialReceiving.test.ts b/src/tests/receiving/receivingStatusChangesWithoutPartialReceiving.test.ts index 81f7c7a1..e45bd21d 100644 --- a/src/tests/receiving/receivingStatusChangesWithoutPartialReceiving.test.ts +++ b/src/tests/receiving/receivingStatusChangesWithoutPartialReceiving.test.ts @@ -15,14 +15,14 @@ test.describe('Status changes on sm view page when receive shipment in location async ({ supplierLocationService, stockMovementService, - mainProductService, - otherProductService, + productService, depotLocationService, }) => { const supplierLocation = await supplierLocationService.getLocation(); const depotLocation = await depotLocationService.getLocation(); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, diff --git a/src/tests/receiving/rollbackStatusChanges.test.ts b/src/tests/receiving/rollbackStatusChanges.test.ts index 0bf1c0fb..1d1a70ac 100644 --- a/src/tests/receiving/rollbackStatusChanges.test.ts +++ b/src/tests/receiving/rollbackStatusChanges.test.ts @@ -14,12 +14,12 @@ test.describe('Status changes on sm view page when rollback receipts', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, - otherProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, diff --git a/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts b/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts index 3bc8364b..c65d55fc 100644 --- a/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts +++ b/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts @@ -1,6 +1,7 @@ import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; import { getDateByOffset, getToday } from '@/utils/DateUtils'; +import productService from '@/api/ProductService'; test.describe('Apply sorting by alphabetical order and remain inputs', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -12,12 +13,13 @@ test.describe('Apply sorting by alphabetical order and remain inputs', () => { async ({ supplierLocationService, stockMovementService, - thirdProductService, - fourthProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const PRODUCT_THREE = await thirdProductService.getProduct(); - const PRODUCT_FOUR = await fourthProductService.getProduct(); + productService.setProduct('3'); + const PRODUCT_THREE = await productService.getProduct(); + productService.setProduct('4'); + const PRODUCT_FOUR = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -55,7 +57,7 @@ test.describe('Apply sorting by alphabetical order and remain inputs', () => { test('Apply sorting by alphabetical order and remain inputs', async ({ stockMovementShowPage, receivingPage, - fifthProductService, + productService, createInboundPage, }) => { await test.step('Go to stock movement show page', async () => { @@ -79,7 +81,8 @@ test.describe('Apply sorting by alphabetical order and remain inputs', () => { await createInboundPage.addItemsStep.confirmReloadPopup.yesButton.click(); await createInboundPage.addItemsStep.isLoaded(); await createInboundPage.addItemsStep.addLineButton.click(); - const item = await fifthProductService.getProduct(); + productService.setProduct('5'); + const item = await productService.getProduct(); const row = createInboundPage.addItemsStep.table.row(2); await row.productSelect.findAndSelectOption(item.name); await row.quantityField.numberbox.fill('100'); @@ -111,7 +114,8 @@ test.describe('Apply sorting by alphabetical order and remain inputs', () => { }); await test.step('Change ordering to alphabetical and assert order', async () => { - const item = await fifthProductService.getProduct(); + productService.setProduct('5'); + const item = await productService.getProduct(); await receivingPage.receivingStep.table.row(3).getItem(item.name).hover(); await expect(receivingPage.tooltip).toContainText(item.name); await expect(receivingPage.receivingStep.orderSelect).toBeVisible(); @@ -136,7 +140,8 @@ test.describe('Apply sorting by alphabetical order and remain inputs', () => { }); await test.step('Go to check page and assert applied order', async () => { - const item = await fifthProductService.getProduct(); + productService.setProduct('5'); + const item = await productService.getProduct(); await receivingPage.nextButton.click(); await receivingPage.checkStep.isLoaded(); await receivingPage.checkStep.table.row(1).getItem(item.name).hover(); @@ -144,7 +149,8 @@ test.describe('Apply sorting by alphabetical order and remain inputs', () => { }); await test.step('Go back to receive page and change order to shipment', async () => { - const item = await fifthProductService.getProduct(); + productService.setProduct('5'); + const item = await productService.getProduct(); await receivingPage.checkStep.backToEditButton.click(); await receivingPage.receivingStep.isLoaded(); await receivingPage.receivingStep.orderSelect.click(); diff --git a/src/tests/receiving/tableShortcutsInReceiving.test.ts b/src/tests/receiving/tableShortcutsInReceiving.test.ts index 047d7706..5a74a0d1 100644 --- a/src/tests/receiving/tableShortcutsInReceiving.test.ts +++ b/src/tests/receiving/tableShortcutsInReceiving.test.ts @@ -13,18 +13,18 @@ test.describe('Use table shortcuts on receiving page', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, - otherProductService, - thirdProductService, - fourthProductService, - fifthProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const PRODUCT_ONE = await mainProductService.getProduct(); - const PRODUCT_TWO = await otherProductService.getProduct(); - const PRODUCT_THREE = await thirdProductService.getProduct(); - const PRODUCT_FOUR = await fourthProductService.getProduct(); - const PRODUCT_FIVE = await fifthProductService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(); + productService.setProduct('2'); + const PRODUCT_TWO = await productService.getProduct(); + productService.setProduct('3'); + const PRODUCT_THREE = await productService.getProduct(); + productService.setProduct('4'); + const PRODUCT_FOUR = await productService.getProduct(); + productService.setProduct('5'); + const PRODUCT_FIVE = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, diff --git a/src/tests/receiving/validationsOnDeliverOnDate.test.ts b/src/tests/receiving/validationsOnDeliverOnDate.test.ts index 1f31e211..895188bd 100644 --- a/src/tests/receiving/validationsOnDeliverOnDate.test.ts +++ b/src/tests/receiving/validationsOnDeliverOnDate.test.ts @@ -10,14 +10,14 @@ test.describe('Validations on edit Deliver On Date when receiving shipment', () async ({ supplierLocationService, stockMovementService, - mainProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, }); - const product = await mainProductService.getProduct(); + const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, diff --git a/src/tests/receiving/validationsOnEditAndReceive.test.ts b/src/tests/receiving/validationsOnEditAndReceive.test.ts index 1c510cc2..a5910dad 100644 --- a/src/tests/receiving/validationsOnEditAndReceive.test.ts +++ b/src/tests/receiving/validationsOnEditAndReceive.test.ts @@ -12,7 +12,7 @@ test.describe('Validations on edit and receive inbound stock movement', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); STOCK_MOVEMENT = await stockMovementService.createInbound({ @@ -21,7 +21,7 @@ test.describe('Validations on edit and receive inbound stock movement', () => { dateRequested, }); - const product = await mainProductService.getProduct(); + const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, diff --git a/src/utils/ProductData.ts b/src/utils/ProductData.ts index 567b74df..2916b1d6 100644 --- a/src/utils/ProductData.ts +++ b/src/utils/ProductData.ts @@ -10,12 +10,15 @@ class ProductData { private productConfig: ProductConfig; constructor( - productType: keyof AppConfig['products'], request: APIRequestContext ) { this.productService = new ProductService(request); - this.productConfig = AppConfig.instance.products[productType]; + this.productConfig = AppConfig.instance.products['1']; + } + + setProduct(productCode: string) { + this.productConfig = AppConfig.instance.products[productCode]; } async getProduct() { From dac4814a1ac7025f998f5c74031e357b9523e66b Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Mon, 8 Sep 2025 12:45:30 +0200 Subject: [PATCH 10/12] OBPIH-6969 Change import url --- src/api/InventoryService.ts | 4 ++-- .../inbound/createInbound/editDestinationFromSendPage.test.ts | 1 - src/tests/inbound/createInbound/expectedDeliveryDate.test.ts | 1 - .../receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts | 1 - 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/api/InventoryService.ts b/src/api/InventoryService.ts index 812037f4..67134fde 100644 --- a/src/api/InventoryService.ts +++ b/src/api/InventoryService.ts @@ -2,11 +2,11 @@ import BaseServiceModel from '@/api/BaseServiceModel'; import { jsonToCsv } from '@/utils/ServiceUtils'; class InventoryService extends BaseServiceModel { - async importInventories(data: Record[], locationId: string): Promise { + async importInventories(data: Record[], facilityId: string): Promise { try { const csvContent = jsonToCsv(data); - const response = await this.request.post(`./api/locations/${locationId}/inventories/import`, { + const response = await this.request.post(`./api/facilities/${facilityId}/inventories/import`, { data: csvContent, headers: { 'Content-Type': 'text/csv' }, }); diff --git a/src/tests/inbound/createInbound/editDestinationFromSendPage.test.ts b/src/tests/inbound/createInbound/editDestinationFromSendPage.test.ts index b9b528f1..1e6141b6 100644 --- a/src/tests/inbound/createInbound/editDestinationFromSendPage.test.ts +++ b/src/tests/inbound/createInbound/editDestinationFromSendPage.test.ts @@ -2,7 +2,6 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; -import productService from '@/api/ProductService'; test.describe('Edit destination from send page', () => { let STOCK_MOVEMENT: StockMovementResponse; diff --git a/src/tests/inbound/createInbound/expectedDeliveryDate.test.ts b/src/tests/inbound/createInbound/expectedDeliveryDate.test.ts index 31e8ff34..231ea803 100644 --- a/src/tests/inbound/createInbound/expectedDeliveryDate.test.ts +++ b/src/tests/inbound/createInbound/expectedDeliveryDate.test.ts @@ -1,7 +1,6 @@ import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse, User } from '@/types'; import { formatDate, getDateByOffset } from '@/utils/DateUtils'; -import productService from '@/api/ProductService'; test.describe('Expected delivery date tests', () => { let STOCK_MOVEMENT: StockMovementResponse; diff --git a/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts b/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts index c65d55fc..de8831ab 100644 --- a/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts +++ b/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts @@ -1,7 +1,6 @@ import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; import { getDateByOffset, getToday } from '@/utils/DateUtils'; -import productService from '@/api/ProductService'; test.describe('Apply sorting by alphabetical order and remain inputs', () => { let STOCK_MOVEMENT: StockMovementResponse; From b4544e8e7b490eb405368a35dd171df845e6a8f2 Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Mon, 8 Sep 2025 13:38:14 +0200 Subject: [PATCH 11/12] OBH-6969 Add a more meaningful error message --- src/api/ProductService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/ProductService.ts b/src/api/ProductService.ts index cfcc8def..bf83b07f 100644 --- a/src/api/ProductService.ts +++ b/src/api/ProductService.ts @@ -37,7 +37,7 @@ class ProductService extends BaseServiceModel { return await parseRequestToJSON(apiResponse); } catch (error) { - throw new Error('Problem importing products'); + throw new Error(`Problem importing products: ${error instanceof Error ? error.message : String(error)}`); } } } From 368e7bcf2beb2e4680de867f2a39792281d1084e Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Wed, 10 Sep 2025 18:48:01 +0200 Subject: [PATCH 12/12] OBPIH-6969 Fix incorrectly assigned product --- .../inbound/createInbound/createInbound.test.ts | 2 ++ .../createInbound/downloadDocsFromSendPage.test.ts | 1 + src/tests/inbound/createInbound/exportItems.test.ts | 1 + .../inbound/createInbound/fieldValidation.test.ts | 1 + .../createInbound/inboundStatusChanges.test.ts | 1 + src/tests/inbound/createInbound/itemTemplate.test.ts | 4 ++++ src/tests/inbound/createInbound/packLevels.test.ts | 1 + src/tests/inbound/createInbound/saveAndExit.test.ts | 1 + .../createInbound/selectPersonInRequestedBy.test.ts | 1 + .../inbound/createInbound/switchLocations.test.ts | 1 + .../inbound/createInbound/tableShortcuts.test.ts | 1 + .../inbound/listPage/exportStockMovements.test.ts | 1 + .../inbound/listPage/myStockMovementFilter.test.ts | 1 + .../inbound/listPage/receiptStatusFilter.test.ts | 4 ++++ .../inbound/listPage/shipmentTypeFilter.test.ts | 2 ++ src/tests/inbound/listPage/updatedByFilter.test.ts | 1 + .../assertCreationOfGoodsReceiptNote.test.ts | 1 + .../receiving/assertCreationOfReceivingBin.test.ts | 1 + src/tests/receiving/assertQtyInputs.test.ts | 1 + src/tests/receiving/cancelRemainingQty.test.ts | 1 + .../receiving/editBinLocationWhenReceive.test.ts | 12 +++++++++++- src/tests/receiving/editOriginalLineQtyTo0.test.ts | 1 + src/tests/receiving/editsInReceiving.test.ts | 1 + src/tests/receiving/exportReceivingTemplate.test.ts | 2 ++ src/tests/receiving/importReceivingTemplate.test.ts | 1 + .../lotExpirySystemUpdateOnReceiving.test.ts | 4 ++++ src/tests/receiving/receiveInbound.test.ts | 3 +++ .../receiveInboundWithoutPartialReceiving.test.ts | 3 +++ .../receiveInboundWithoutPickAndPutawayStock.test.ts | 1 + src/tests/receiving/receiveToHoldBin.test.ts | 1 + src/tests/receiving/receivingStatusChanges.test.ts | 1 + ...ivingStatusChangesWithoutPartialReceiving.test.ts | 1 + src/tests/receiving/rollbackStatusChanges.test.ts | 1 + .../receiving/tableShortcutsInReceiving.test.ts | 1 + .../receiving/validationsOnDeliverOnDate.test.ts | 1 + .../receiving/validationsOnEditAndReceive.test.ts | 1 + 36 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/tests/inbound/createInbound/createInbound.test.ts b/src/tests/inbound/createInbound/createInbound.test.ts index 6e9b19ac..85a78b68 100644 --- a/src/tests/inbound/createInbound/createInbound.test.ts +++ b/src/tests/inbound/createInbound/createInbound.test.ts @@ -23,6 +23,7 @@ test.describe('Create inbound stock movement', () => { supplierLocationService, mainLocationService, }) => { + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); @@ -194,6 +195,7 @@ test.describe('Values persistance between steps', () => { mainLocationService, supplierLocationService, }) => { + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); diff --git a/src/tests/inbound/createInbound/downloadDocsFromSendPage.test.ts b/src/tests/inbound/createInbound/downloadDocsFromSendPage.test.ts index e2ee91c3..25c160ff 100644 --- a/src/tests/inbound/createInbound/downloadDocsFromSendPage.test.ts +++ b/src/tests/inbound/createInbound/downloadDocsFromSendPage.test.ts @@ -20,6 +20,7 @@ test.describe('Download documents from inbound send page', () => { mainUserService, supplierLocationService, }) => { + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); USER = await mainUserService.getUser(); ORIGIN = await supplierLocationService.getLocation(); diff --git a/src/tests/inbound/createInbound/exportItems.test.ts b/src/tests/inbound/createInbound/exportItems.test.ts index 9016932a..21ba584a 100644 --- a/src/tests/inbound/createInbound/exportItems.test.ts +++ b/src/tests/inbound/createInbound/exportItems.test.ts @@ -21,6 +21,7 @@ test.describe('Export all incoming items', () => { const USER = await mainUserService.getUser(); const TODAY = getToday(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); diff --git a/src/tests/inbound/createInbound/fieldValidation.test.ts b/src/tests/inbound/createInbound/fieldValidation.test.ts index c4f550a1..b215ca19 100644 --- a/src/tests/inbound/createInbound/fieldValidation.test.ts +++ b/src/tests/inbound/createInbound/fieldValidation.test.ts @@ -16,6 +16,7 @@ test.beforeEach( createInboundPage, supplierLocationService, }) => { + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); USER = await mainUserService.getUser(); ORIGIN = await supplierLocationService.getLocation(); diff --git a/src/tests/inbound/createInbound/inboundStatusChanges.test.ts b/src/tests/inbound/createInbound/inboundStatusChanges.test.ts index 0b3fded5..df10818a 100644 --- a/src/tests/inbound/createInbound/inboundStatusChanges.test.ts +++ b/src/tests/inbound/createInbound/inboundStatusChanges.test.ts @@ -26,6 +26,7 @@ test.describe('Status changes for inbound sm on view sm and inbound list page', mainUserService, supplierLocationService, }) => { + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); diff --git a/src/tests/inbound/createInbound/itemTemplate.test.ts b/src/tests/inbound/createInbound/itemTemplate.test.ts index 8adf329c..a33d16c5 100644 --- a/src/tests/inbound/createInbound/itemTemplate.test.ts +++ b/src/tests/inbound/createInbound/itemTemplate.test.ts @@ -83,6 +83,7 @@ test.describe('Export items template on inbound add items page', () => { await createInboundPage.addItemsStep.isLoaded(); }); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); @@ -192,6 +193,7 @@ test.describe('Import template with data', () => { workbooks.push(downloadedTemplateFile); }); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); @@ -264,6 +266,7 @@ test.describe('Import template with data', () => { }); await test.step('Add items to table', async () => { + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); const USER = await mainUserService.getUser(); @@ -356,6 +359,7 @@ test.describe('Import template with data', () => { let ROW: CreateInboundAddItemsTableEntity; await test.step('Add items to table', async () => { + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); const USER = await mainUserService.getUser(); diff --git a/src/tests/inbound/createInbound/packLevels.test.ts b/src/tests/inbound/createInbound/packLevels.test.ts index 2c38f2f8..9d454efa 100644 --- a/src/tests/inbound/createInbound/packLevels.test.ts +++ b/src/tests/inbound/createInbound/packLevels.test.ts @@ -13,6 +13,7 @@ test.beforeEach( createInboundPage, supplierLocationService, }) => { + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); const USER = await mainUserService.getUser(); const ORIGIN = await supplierLocationService.getLocation(); diff --git a/src/tests/inbound/createInbound/saveAndExit.test.ts b/src/tests/inbound/createInbound/saveAndExit.test.ts index 23b5ddbc..b770aab0 100644 --- a/src/tests/inbound/createInbound/saveAndExit.test.ts +++ b/src/tests/inbound/createInbound/saveAndExit.test.ts @@ -13,6 +13,7 @@ test.beforeEach( createInboundPage, supplierLocationService, }) => { + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); const USER = await mainUserService.getUser(); const ORIGIN = await supplierLocationService.getLocation(); diff --git a/src/tests/inbound/createInbound/selectPersonInRequestedBy.test.ts b/src/tests/inbound/createInbound/selectPersonInRequestedBy.test.ts index 47419bfc..3d0cb23c 100644 --- a/src/tests/inbound/createInbound/selectPersonInRequestedBy.test.ts +++ b/src/tests/inbound/createInbound/selectPersonInRequestedBy.test.ts @@ -24,6 +24,7 @@ test.describe('Select person in requested by', () => { personsListPage, createPersonPage, }) => { + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); ORIGIN = await supplierLocationService.getLocation(); diff --git a/src/tests/inbound/createInbound/switchLocations.test.ts b/src/tests/inbound/createInbound/switchLocations.test.ts index 0e2887a1..d5cab17a 100644 --- a/src/tests/inbound/createInbound/switchLocations.test.ts +++ b/src/tests/inbound/createInbound/switchLocations.test.ts @@ -15,6 +15,7 @@ test.describe('Switching location on inbound stock movement', () => { createInboundPage, supplierLocationService, }) => { + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); const USER = await mainUserService.getUser(); const ORIGIN = await supplierLocationService.getLocation(); diff --git a/src/tests/inbound/createInbound/tableShortcuts.test.ts b/src/tests/inbound/createInbound/tableShortcuts.test.ts index 2f003e7f..22a5495d 100644 --- a/src/tests/inbound/createInbound/tableShortcuts.test.ts +++ b/src/tests/inbound/createInbound/tableShortcuts.test.ts @@ -12,6 +12,7 @@ test.beforeEach( createInboundPage, supplierLocationService, }) => { + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); const USER = await mainUserService.getUser(); const ORIGIN = await supplierLocationService.getLocation(); diff --git a/src/tests/inbound/listPage/exportStockMovements.test.ts b/src/tests/inbound/listPage/exportStockMovements.test.ts index 5b92065a..4be6ac83 100644 --- a/src/tests/inbound/listPage/exportStockMovements.test.ts +++ b/src/tests/inbound/listPage/exportStockMovements.test.ts @@ -17,6 +17,7 @@ test.describe('Export stock movements', () => { productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); diff --git a/src/tests/inbound/listPage/myStockMovementFilter.test.ts b/src/tests/inbound/listPage/myStockMovementFilter.test.ts index 1e71a804..6a4ec9d0 100644 --- a/src/tests/inbound/listPage/myStockMovementFilter.test.ts +++ b/src/tests/inbound/listPage/myStockMovementFilter.test.ts @@ -15,6 +15,7 @@ test.describe('My Stock Movement filter', () => { }) => { const supplierLocation = await supplierLocationService.getLocation(); USER = await mainUserService.getUser(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); diff --git a/src/tests/inbound/listPage/receiptStatusFilter.test.ts b/src/tests/inbound/listPage/receiptStatusFilter.test.ts index 12e79400..20cc56c5 100644 --- a/src/tests/inbound/listPage/receiptStatusFilter.test.ts +++ b/src/tests/inbound/listPage/receiptStatusFilter.test.ts @@ -60,6 +60,7 @@ test.describe('Filter by "Shipped" status', () => { originId: supplierLocation.id, }); + productService.setProduct('1'); const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( @@ -125,6 +126,7 @@ test.describe('Filter by "Received" status', () => { originId: supplierLocation.id, }); + productService.setProduct('1'); const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( @@ -216,6 +218,7 @@ test.describe('Filter by "Receiving" status', () => { originId: supplierLocation.id, }); + productService.setProduct('1'); const product = await productService.getProduct(); productService.setProduct('2'); const productTwo = await productService.getProduct(); @@ -315,6 +318,7 @@ test.describe('Filter by multiple statuses - "Pending" and "Shipped"', () => { originId: supplierLocation.id, }); + productService.setProduct('1'); const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( diff --git a/src/tests/inbound/listPage/shipmentTypeFilter.test.ts b/src/tests/inbound/listPage/shipmentTypeFilter.test.ts index 8ed7e903..b66e3bd6 100644 --- a/src/tests/inbound/listPage/shipmentTypeFilter.test.ts +++ b/src/tests/inbound/listPage/shipmentTypeFilter.test.ts @@ -20,6 +20,7 @@ test.describe('Shipment type filter', () => { stockMovementService, }) => { const supplierLocation = await supplierLocationService.getLocation(); + productService.setProduct('1'); const product = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ @@ -111,6 +112,7 @@ test.describe('Multiple shipment types', () => { stockMovementService, }) => { const supplierLocation = await supplierLocationService.getLocation(); + productService.setProduct('1'); const product = await productService.getProduct(); STOCK_MOVEMENT_LAND = await stockMovementService.createInbound({ diff --git a/src/tests/inbound/listPage/updatedByFilter.test.ts b/src/tests/inbound/listPage/updatedByFilter.test.ts index 7c2d1807..1ac21e5b 100644 --- a/src/tests/inbound/listPage/updatedByFilter.test.ts +++ b/src/tests/inbound/listPage/updatedByFilter.test.ts @@ -34,6 +34,7 @@ test.describe('Use "Updated By" filter', () => { inboundListPage, productService, }) => { + productService.setProduct('1'); const product = await productService.getProduct(); await test.step('Go to inbound list page', async () => { diff --git a/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts b/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts index d77e093e..ce0c7505 100644 --- a/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts +++ b/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts @@ -12,6 +12,7 @@ test.describe('Assert Goods Receipt Note is created and opened', () => { productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('3'); const PRODUCT_THREE = await productService.getProduct(); diff --git a/src/tests/receiving/assertCreationOfReceivingBin.test.ts b/src/tests/receiving/assertCreationOfReceivingBin.test.ts index b89591e2..90c314c5 100644 --- a/src/tests/receiving/assertCreationOfReceivingBin.test.ts +++ b/src/tests/receiving/assertCreationOfReceivingBin.test.ts @@ -17,6 +17,7 @@ test.describe('Assert creation of receiving bin', () => { productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); diff --git a/src/tests/receiving/assertQtyInputs.test.ts b/src/tests/receiving/assertQtyInputs.test.ts index 30dc6697..f5acbc4d 100644 --- a/src/tests/receiving/assertQtyInputs.test.ts +++ b/src/tests/receiving/assertQtyInputs.test.ts @@ -13,6 +13,7 @@ test.describe('Assert if quantity inputs remain when split lines', () => { productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); diff --git a/src/tests/receiving/cancelRemainingQty.test.ts b/src/tests/receiving/cancelRemainingQty.test.ts index 3cbea0e5..7fd315ff 100644 --- a/src/tests/receiving/cancelRemainingQty.test.ts +++ b/src/tests/receiving/cancelRemainingQty.test.ts @@ -12,6 +12,7 @@ test.describe('Cancel qty in the middle of receipt', () => { productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); diff --git a/src/tests/receiving/editBinLocationWhenReceive.test.ts b/src/tests/receiving/editBinLocationWhenReceive.test.ts index c8940473..5b09351d 100644 --- a/src/tests/receiving/editBinLocationWhenReceive.test.ts +++ b/src/tests/receiving/editBinLocationWhenReceive.test.ts @@ -22,6 +22,7 @@ test.describe('Edit Bin Location when receive inbound stock movement', () => { }) => { const supplierLocation = await supplierLocationService.getLocation(); const mainLocation = await mainLocationService.getLocation(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); @@ -73,7 +74,14 @@ test.describe('Edit Bin Location when receive inbound stock movement', () => { createLocationPage, }) => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.rollbackLastReceiptButton.click(); + + const hasRollbackLastReceipt = + await stockMovementShowPage.rollbackLastReceiptButton.isVisible().catch(() => false); + + if (hasRollbackLastReceipt) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } + await stockMovementShowPage.rollbackButton.click(); await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); @@ -177,6 +185,7 @@ test.describe('Edit Bin Location to bin with zone when receive inbound stock mov }) => { const supplierLocation = await supplierLocationService.getLocation(); const mainLocation = await mainLocationService.getLocation(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); @@ -381,6 +390,7 @@ test.describe('Edit Bin Location when receive for all lines', () => { }) => { const supplierLocation = await supplierLocationService.getLocation(); const mainLocation = await mainLocationService.getLocation(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); diff --git a/src/tests/receiving/editOriginalLineQtyTo0.test.ts b/src/tests/receiving/editOriginalLineQtyTo0.test.ts index 99948a30..5e7dcfe7 100644 --- a/src/tests/receiving/editOriginalLineQtyTo0.test.ts +++ b/src/tests/receiving/editOriginalLineQtyTo0.test.ts @@ -16,6 +16,7 @@ test.describe('Edit qty of original line to 0', () => { productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); diff --git a/src/tests/receiving/editsInReceiving.test.ts b/src/tests/receiving/editsInReceiving.test.ts index bc385127..22ba77ae 100644 --- a/src/tests/receiving/editsInReceiving.test.ts +++ b/src/tests/receiving/editsInReceiving.test.ts @@ -17,6 +17,7 @@ test.describe('Edit items in the middle of receipt', () => { productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); diff --git a/src/tests/receiving/exportReceivingTemplate.test.ts b/src/tests/receiving/exportReceivingTemplate.test.ts index a3e71f46..732683e8 100644 --- a/src/tests/receiving/exportReceivingTemplate.test.ts +++ b/src/tests/receiving/exportReceivingTemplate.test.ts @@ -21,6 +21,7 @@ test.describe('Export receiving template', () => { productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); @@ -70,6 +71,7 @@ test.describe('Export receiving template', () => { let filePath: string; let downloadedExportTemplateFile: WorkbookUtils; + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); diff --git a/src/tests/receiving/importReceivingTemplate.test.ts b/src/tests/receiving/importReceivingTemplate.test.ts index f72cbb9a..34e2c010 100644 --- a/src/tests/receiving/importReceivingTemplate.test.ts +++ b/src/tests/receiving/importReceivingTemplate.test.ts @@ -24,6 +24,7 @@ test.describe('Import receiving template', () => { productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ diff --git a/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts b/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts index 51a0e20e..1a479785 100644 --- a/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts +++ b/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts @@ -54,6 +54,7 @@ test.describe('Lot number system expiry date modification on receiving workflow' const UPDATED_EXPIRY_DATE_NEW_LOT = getDateByOffset(getToday(), 2); + productService.setProduct('1'); const product = await productService.getProduct(); await test.step('Ensure that lot number does not exist in product stock', async () => { @@ -178,6 +179,7 @@ test.describe('Lot number system expiry date modification on receiving workflow' let STOCK_MOVEMENT: StockMovementResponse; + productService.setProduct('1'); const product = await productService.getProduct(); TEST_INPUT_STOCK_EXISTING_LOT.lotNumber = @@ -267,6 +269,7 @@ test.describe('Lot number system expiry date modification on receiving workflow' }) => { let STOCK_MOVEMENT_2: StockMovementResponse; + productService.setProduct('1'); const product = await productService.getProduct(); await test.step('Create second inbound stock movement', async () => { @@ -381,6 +384,7 @@ test.describe('Lot number system expiry date modification on receiving workflow' }) => { let STOCK_MOVEMENT_2: StockMovementResponse; + productService.setProduct('1'); const product = await productService.getProduct(); await test.step('Create second inbound stock movement', async () => { diff --git a/src/tests/receiving/receiveInbound.test.ts b/src/tests/receiving/receiveInbound.test.ts index 9cc2ec4b..b983455b 100644 --- a/src/tests/receiving/receiveInbound.test.ts +++ b/src/tests/receiving/receiveInbound.test.ts @@ -23,6 +23,7 @@ test.describe('Receive inbound stock movement', () => { dateRequested, }); + productService.setProduct('1'); const product = await productService.getProduct(); productService.setProduct('2'); const product2 = await productService.getProduct(); @@ -115,6 +116,7 @@ test.describe('Receive inbound stock movement', () => { }); await test.step('Assert product in receiving table', async () => { + productService.setProduct('1'); const item = await productService.getProduct(); await receivingPage.receivingStep.table.row(1).getItem(item.name).hover(); await expect(receivingPage.tooltip).toContainText(item.name); @@ -171,6 +173,7 @@ test.describe('Receive inbound stock movement', () => { }); await test.step('Assert product in checking table', async () => { + productService.setProduct('1'); const item = await productService.getProduct(); await receivingPage.checkStep.table.row(1).getItem(item.name).hover(); await expect(receivingPage.tooltip).toContainText(item.name); diff --git a/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts b/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts index f237d64a..a5ca82b5 100644 --- a/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts +++ b/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts @@ -18,6 +18,7 @@ test.describe('Receive inbound stock movement in location without partial receiv }) => { const supplierLocation = await supplierLocationService.getLocation(); const depotLocation = await depotLocationService.getLocation(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); @@ -120,6 +121,7 @@ test.describe('Receive inbound stock movement in location without partial receiv }); await test.step('Assert product in receiving table', async () => { + productService.setProduct('1'); const item = await productService.getProduct(); productService.setProduct('2'); const item2 = await productService.getProduct(); @@ -244,6 +246,7 @@ test.describe('Receive inbound stock movement in location without partial receiv }); await test.step('Assert product in checking table', async () => { + productService.setProduct('1'); const item = await productService.getProduct(); productService.setProduct('2'); const item2 = await productService.getProduct(); diff --git a/src/tests/receiving/receiveInboundWithoutPickAndPutawayStock.test.ts b/src/tests/receiving/receiveInboundWithoutPickAndPutawayStock.test.ts index a7789fe7..4c489b88 100644 --- a/src/tests/receiving/receiveInboundWithoutPickAndPutawayStock.test.ts +++ b/src/tests/receiving/receiveInboundWithoutPickAndPutawayStock.test.ts @@ -18,6 +18,7 @@ test.describe('Receive inbound stock movement in location without pick and putaw }) => { const supplierLocation = await supplierLocationService.getLocation(); const noPickAndPutawayStockDepot= await noPickAndPutawayStockDepotService.getLocation(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ diff --git a/src/tests/receiving/receiveToHoldBin.test.ts b/src/tests/receiving/receiveToHoldBin.test.ts index e2854b85..4844dc0e 100644 --- a/src/tests/receiving/receiveToHoldBin.test.ts +++ b/src/tests/receiving/receiveToHoldBin.test.ts @@ -22,6 +22,7 @@ test.describe('Receive item into hold bin', () => { }) => { const supplierLocation = await supplierLocationService.getLocation(); const mainLocation = await mainLocationService.getLocation(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); STOCK_MOVEMENT = await stockMovementService.createInbound({ diff --git a/src/tests/receiving/receivingStatusChanges.test.ts b/src/tests/receiving/receivingStatusChanges.test.ts index 2b66d4aa..c08547de 100644 --- a/src/tests/receiving/receivingStatusChanges.test.ts +++ b/src/tests/receiving/receivingStatusChanges.test.ts @@ -17,6 +17,7 @@ test.describe('Status changes on sm view page when receive shipment', () => { productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); diff --git a/src/tests/receiving/receivingStatusChangesWithoutPartialReceiving.test.ts b/src/tests/receiving/receivingStatusChangesWithoutPartialReceiving.test.ts index e45bd21d..ee270811 100644 --- a/src/tests/receiving/receivingStatusChangesWithoutPartialReceiving.test.ts +++ b/src/tests/receiving/receivingStatusChangesWithoutPartialReceiving.test.ts @@ -20,6 +20,7 @@ test.describe('Status changes on sm view page when receive shipment in location }) => { const supplierLocation = await supplierLocationService.getLocation(); const depotLocation = await depotLocationService.getLocation(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); diff --git a/src/tests/receiving/rollbackStatusChanges.test.ts b/src/tests/receiving/rollbackStatusChanges.test.ts index 1d1a70ac..855bc2af 100644 --- a/src/tests/receiving/rollbackStatusChanges.test.ts +++ b/src/tests/receiving/rollbackStatusChanges.test.ts @@ -17,6 +17,7 @@ test.describe('Status changes on sm view page when rollback receipts', () => { productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); diff --git a/src/tests/receiving/tableShortcutsInReceiving.test.ts b/src/tests/receiving/tableShortcutsInReceiving.test.ts index 5a74a0d1..3402be62 100644 --- a/src/tests/receiving/tableShortcutsInReceiving.test.ts +++ b/src/tests/receiving/tableShortcutsInReceiving.test.ts @@ -16,6 +16,7 @@ test.describe('Use table shortcuts on receiving page', () => { productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); + productService.setProduct('1'); const PRODUCT_ONE = await productService.getProduct(); productService.setProduct('2'); const PRODUCT_TWO = await productService.getProduct(); diff --git a/src/tests/receiving/validationsOnDeliverOnDate.test.ts b/src/tests/receiving/validationsOnDeliverOnDate.test.ts index 895188bd..917c7557 100644 --- a/src/tests/receiving/validationsOnDeliverOnDate.test.ts +++ b/src/tests/receiving/validationsOnDeliverOnDate.test.ts @@ -17,6 +17,7 @@ test.describe('Validations on edit Deliver On Date when receiving shipment', () originId: supplierLocation.id, }); + productService.setProduct('1'); const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( diff --git a/src/tests/receiving/validationsOnEditAndReceive.test.ts b/src/tests/receiving/validationsOnEditAndReceive.test.ts index a5910dad..5aadcd2a 100644 --- a/src/tests/receiving/validationsOnEditAndReceive.test.ts +++ b/src/tests/receiving/validationsOnEditAndReceive.test.ts @@ -21,6 +21,7 @@ test.describe('Validations on edit and receive inbound stock movement', () => { dateRequested, }); + productService.setProduct('1'); const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement(