From 5c2543a560b5e9977fe8d56783a0b5eb6ca838af Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Fri, 22 Aug 2025 14:20:43 +0200 Subject: [PATCH 01/13] 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 1f8caea..640e2f4 100644 --- a/src/config/AppConfig.ts +++ b/src/config/AppConfig.ts @@ -54,6 +54,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 0000000..6b7affa --- /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 afeaf49e4baaf7146860ab152ba209da6f61bba0 Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Fri, 22 Aug 2025 14:21:00 +0200 Subject: [PATCH 02/13] 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 da0913d..4cf04c7 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 0362ec7a05a94fdc299cb3a8da91e5a2735a8b88 Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Fri, 22 Aug 2025 14:21:18 +0200 Subject: [PATCH 03/13] 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 b626eb1..ae9745d 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 b1734939ecd578e5e4b04aebb7a40e8083873d08 Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Fri, 22 Aug 2025 14:21:34 +0200 Subject: [PATCH 04/13] 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 3150b63..cfcc8de 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 9fa9da7d1d02f7278e5e0f968dcda87b290184f4 Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Fri, 22 Aug 2025 14:22:08 +0200 Subject: [PATCH 05/13] 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 0000000..118b6ff --- /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 053e391c3c10caa5a99ac8c5dd6a27b9b70e9bce Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Fri, 22 Aug 2025 14:22:23 +0200 Subject: [PATCH 06/13] 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 9c551a9..2622d12 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 ce5437d960f2ad6fd4d402b1557052f961d728b0 Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Tue, 26 Aug 2025 14:34:43 +0200 Subject: [PATCH 07/13] 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 640e2f4..78cee61 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 { @@ -71,7 +72,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; @@ -290,44 +291,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: 0, - required: false, - }), - }; + }) + }) this.receivingBinPrefix = env .get('RECEIVING_BIN_PREFIX') diff --git a/src/config/ProductConfig.ts b/src/config/ProductConfig.ts index dd3b1ac..1b6a6f2 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 a4bc78e..0a6b42c 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 118b6ff..5ddf784 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 6b7affa..a3c4de7 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 86bce7cd84eb1cbe1e8b0744db8af996e58b97b5 Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Wed, 3 Sep 2025 11:01:32 +0200 Subject: [PATCH 08/13] 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 0000000..812037f --- /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 78cee61..36ab404 100644 --- a/src/config/AppConfig.ts +++ b/src/config/AppConfig.ts @@ -59,6 +59,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 5ddf784..d3589e8 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 0000000..402c381 --- /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 bc2f21da813b54fe445bfe36cc891e63c5aac036 Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Fri, 5 Sep 2025 17:46:28 +0200 Subject: [PATCH 09/13] 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 | 26 ++++++----- .../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, 247 insertions(+), 237 deletions(-) diff --git a/src/fixtures/fixtures.ts b/src/fixtures/fixtures.ts index 1d8e166..3c7cf0f 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'; @@ -95,11 +94,7 @@ type Fixtures = { internalLocation2Service: LocationData; // PRODUCT DATA - mainProductService: ProductData; - otherProductService: ProductData; - thirdProductService: ProductData; - fourthProductService: ProductData; - fifthProductService: ProductData; + productService: ProductData; // USERS DATA mainUserService: UserData; altUserService: UserData; @@ -184,16 +179,8 @@ export const test = baseTest.extend({ internalLocation2Service: async ({ page }, use) => use(new LocationData(LOCATION_KEY.BIN_LOCATION2, 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 061c87a..7ee9c08 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(); @@ -191,15 +191,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 af8ff0f..0b7f92a 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 79be1dc..b9b528f 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 fcc5737..31e8ff3 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 47eb45d..f3e35bc 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 fdd4afd..4552a08 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 3869adb..273ba6e 100644 --- a/src/tests/inbound/createInbound/inboundStatusChanges.test.ts +++ b/src/tests/inbound/createInbound/inboundStatusChanges.test.ts @@ -18,13 +18,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 db5a106..cc86be8 100644 --- a/src/tests/inbound/createInbound/itemTemplate.test.ts +++ b/src/tests/inbound/createInbound/itemTemplate.test.ts @@ -77,8 +77,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 () => { @@ -87,8 +86,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 = [ @@ -178,8 +178,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 () => { @@ -198,8 +197,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 = [ @@ -259,8 +259,7 @@ test.describe('Import template with data', () => { test.skip('Update existing values with template import', async ({ createInboundPage, - otherProductService, - mainProductService, + productService, altUserService, mainUserService, }) => { @@ -272,7 +271,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 = [ @@ -307,7 +306,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 = { @@ -352,8 +352,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, }) => { @@ -365,7 +364,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 = { @@ -397,7 +396,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 acbd47e..2c38f2f 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 19d252a..23b5ddb 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 fceff99..47419bf 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 b750593..0e2887a 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 99e2404..633e4af 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 5ac1374..71e1364 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 7124ecb..1e71a80 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 dab2cb0..b0fc67b 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, @@ -208,8 +208,7 @@ test.describe('Filter by "Receiving" status', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, - otherProductService, + productService, stockMovementShowPage, receivingPage, }) => { @@ -218,8 +217,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, @@ -306,7 +306,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({ @@ -317,7 +317,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 dfb21e2..8ed7e90 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 e7859a1..7c2d180 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 91e8ec4..759e4e3 100644 --- a/src/tests/receiving/assertBinLocationField.test.ts +++ b/src/tests/receiving/assertBinLocationField.test.ts @@ -11,10 +11,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 6b8f665..d7fead0 100644 --- a/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts +++ b/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts @@ -11,12 +11,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 90418f4..4d30f90 100644 --- a/src/tests/receiving/assertCreationOfReceivingBin.test.ts +++ b/src/tests/receiving/assertCreationOfReceivingBin.test.ts @@ -15,12 +15,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 042d295..38b5ff2 100644 --- a/src/tests/receiving/assertQtyInputs.test.ts +++ b/src/tests/receiving/assertQtyInputs.test.ts @@ -12,14 +12,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 e9f8153..1346561 100644 --- a/src/tests/receiving/assertRecipientField.test.ts +++ b/src/tests/receiving/assertRecipientField.test.ts @@ -11,13 +11,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 8c1933b..1167f41 100644 --- a/src/tests/receiving/cancelRemainingQty.test.ts +++ b/src/tests/receiving/cancelRemainingQty.test.ts @@ -11,12 +11,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 815ca19..de41a36 100644 --- a/src/tests/receiving/editBinLocationWhenReceive.test.ts +++ b/src/tests/receiving/editBinLocationWhenReceive.test.ts @@ -17,16 +17,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, @@ -185,16 +185,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, @@ -404,16 +404,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 5d0506f..37f68e8 100644 --- a/src/tests/receiving/editOriginalLineQtyTo0.test.ts +++ b/src/tests/receiving/editOriginalLineQtyTo0.test.ts @@ -15,18 +15,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, @@ -239,10 +239,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, @@ -298,8 +299,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); @@ -312,7 +312,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(); @@ -333,8 +334,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(); @@ -374,7 +377,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( @@ -389,8 +393,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 80402a0..4645377 100644 --- a/src/tests/receiving/editsInReceiving.test.ts +++ b/src/tests/receiving/editsInReceiving.test.ts @@ -16,12 +16,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 5a54bbf..108cb31 100644 --- a/src/tests/receiving/exportReceivingTemplate.test.ts +++ b/src/tests/receiving/exportReceivingTemplate.test.ts @@ -19,14 +19,15 @@ 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(); + productService.setProduct('1'); + 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, @@ -85,16 +86,17 @@ 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(); + productService.setProduct('1'); + 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 8cd7854..063655d 100644 --- a/src/tests/receiving/importReceivingTemplate.test.ts +++ b/src/tests/receiving/importReceivingTemplate.test.ts @@ -22,10 +22,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 6c4d65a..dece8fc 100644 --- a/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts +++ b/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts @@ -59,7 +59,7 @@ test.describe('Lot number system expiry date modification on receiving workflow' stockMovementShowPage, receivingPage, stockMovementService, - mainProductService, + productService, productShowPage, supplierLocationService, }) => { @@ -74,7 +74,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); @@ -190,7 +190,7 @@ test.describe('Lot number system expiry date modification on receiving workflow' stockMovementShowPage, receivingPage, stockMovementService, - mainProductService, + productService, productShowPage, supplierLocationService, }) => { @@ -198,7 +198,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'); @@ -281,13 +281,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(); @@ -395,13 +395,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 8ea4017..6f340ab 100644 --- a/src/tests/receiving/receiveInbound.test.ts +++ b/src/tests/receiving/receiveInbound.test.ts @@ -15,8 +15,7 @@ test.describe('Receive inbound stock movement', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, - otherProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); STOCK_MOVEMENT = await stockMovementService.createInbound({ @@ -25,8 +24,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, @@ -80,7 +80,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); @@ -134,7 +134,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); }); @@ -190,7 +190,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 344545e..4d7af78 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, @@ -67,8 +67,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 () => { @@ -120,8 +119,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 @@ -165,8 +165,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 () => { @@ -244,8 +243,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 ebcc55a..a7789fe 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 82b7fe9..5e91c34 100644 --- a/src/tests/receiving/receiveToHoldBin.test.ts +++ b/src/tests/receiving/receiveToHoldBin.test.ts @@ -17,14 +17,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 da11fc3..7fb03e7 100644 --- a/src/tests/receiving/receivingStatusChanges.test.ts +++ b/src/tests/receiving/receivingStatusChanges.test.ts @@ -16,12 +16,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 1a56370..e660701 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 621139d..c0f5c95 100644 --- a/src/tests/receiving/rollbackStatusChanges.test.ts +++ b/src/tests/receiving/rollbackStatusChanges.test.ts @@ -16,12 +16,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 64f9d37..1d6e136 100644 --- a/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts +++ b/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts @@ -3,6 +3,7 @@ import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; 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; @@ -14,12 +15,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, @@ -75,7 +77,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 () => { @@ -99,7 +101,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'); @@ -131,7 +134,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(); @@ -156,7 +160,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(); @@ -164,7 +169,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 313e9b3..776c49d 100644 --- a/src/tests/receiving/tableShortcutsInReceiving.test.ts +++ b/src/tests/receiving/tableShortcutsInReceiving.test.ts @@ -15,18 +15,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 0d87022..0920969 100644 --- a/src/tests/receiving/validationsOnDeliverOnDate.test.ts +++ b/src/tests/receiving/validationsOnDeliverOnDate.test.ts @@ -12,14 +12,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 80cfd59..93708a5 100644 --- a/src/tests/receiving/validationsOnEditAndReceive.test.ts +++ b/src/tests/receiving/validationsOnEditAndReceive.test.ts @@ -14,7 +14,7 @@ test.describe('Assert validation on try to receive not yet shipped inbound', () async ({ supplierLocationService, stockMovementService, - mainProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); STOCK_MOVEMENT = await stockMovementService.createInbound({ @@ -23,7 +23,7 @@ test.describe('Assert validation on try to receive not yet shipped inbound', () 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 567b74d..2916b1d 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 8804d6638228c5ed7b438d3fb2956e242d7315fd Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Mon, 8 Sep 2025 12:45:30 +0200 Subject: [PATCH 10/13] 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 812037f..67134fd 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 b9b528f..1e6141b 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 31e8ff3..231ea80 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 1d6e136..52c11fe 100644 --- a/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts +++ b/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts @@ -3,7 +3,6 @@ import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; 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 28d57230c43a535cc9a5c174e2fdc1582ea5ad8c Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Mon, 8 Sep 2025 13:38:14 +0200 Subject: [PATCH 11/13] 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 cfcc8de..bf83b07 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 f8e2d2e3c34fdcab4fd596bd10d96a6864aeedca Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Wed, 10 Sep 2025 18:48:01 +0200 Subject: [PATCH 12/13] 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/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 + 35 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/tests/inbound/createInbound/createInbound.test.ts b/src/tests/inbound/createInbound/createInbound.test.ts index 7ee9c08..46e1f22 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(); @@ -197,6 +198,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 0b7f92a..3804b5a 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 f3e35bc..9cc7faf 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 4552a08..9f32fc6 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 273ba6e..d5495a4 100644 --- a/src/tests/inbound/createInbound/inboundStatusChanges.test.ts +++ b/src/tests/inbound/createInbound/inboundStatusChanges.test.ts @@ -22,6 +22,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 cc86be8..59ebc85 100644 --- a/src/tests/inbound/createInbound/itemTemplate.test.ts +++ b/src/tests/inbound/createInbound/itemTemplate.test.ts @@ -86,6 +86,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(); @@ -197,6 +198,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(); @@ -271,6 +273,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(); @@ -364,6 +367,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 2c38f2f..9d454ef 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 23b5ddb..b770aab 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 47419bf..3d0cb23 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 0e2887a..d5cab17 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 633e4af..12b193b 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 71e1364..efcaf31 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 1e71a80..6a4ec9d 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 b0fc67b..88a9936 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( @@ -217,6 +219,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(); @@ -317,6 +320,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 8ed7e90..b66e3bd 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 7c2d180..1ac21e5 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 d7fead0..cb07756 100644 --- a/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts +++ b/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts @@ -14,6 +14,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 4d30f90..2bf61b4 100644 --- a/src/tests/receiving/assertCreationOfReceivingBin.test.ts +++ b/src/tests/receiving/assertCreationOfReceivingBin.test.ts @@ -18,6 +18,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 38b5ff2..4c4e2d5 100644 --- a/src/tests/receiving/assertQtyInputs.test.ts +++ b/src/tests/receiving/assertQtyInputs.test.ts @@ -15,6 +15,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 1167f41..7e3e3e3 100644 --- a/src/tests/receiving/cancelRemainingQty.test.ts +++ b/src/tests/receiving/cancelRemainingQty.test.ts @@ -14,6 +14,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 de41a36..870f92b 100644 --- a/src/tests/receiving/editBinLocationWhenReceive.test.ts +++ b/src/tests/receiving/editBinLocationWhenReceive.test.ts @@ -24,6 +24,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(); @@ -78,7 +79,14 @@ test.describe('Edit Bin Location when receive inbound stock movement', () => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; 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); @@ -192,6 +200,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(); @@ -411,6 +420,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 37f68e8..57503d8 100644 --- a/src/tests/receiving/editOriginalLineQtyTo0.test.ts +++ b/src/tests/receiving/editOriginalLineQtyTo0.test.ts @@ -18,6 +18,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 4645377..c61d3f1 100644 --- a/src/tests/receiving/editsInReceiving.test.ts +++ b/src/tests/receiving/editsInReceiving.test.ts @@ -19,6 +19,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/importReceivingTemplate.test.ts b/src/tests/receiving/importReceivingTemplate.test.ts index 063655d..9744bd5 100644 --- a/src/tests/receiving/importReceivingTemplate.test.ts +++ b/src/tests/receiving/importReceivingTemplate.test.ts @@ -25,6 +25,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 dece8fc..e217b9e 100644 --- a/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts +++ b/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts @@ -74,6 +74,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 () => { @@ -198,6 +199,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 = @@ -287,6 +289,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 () => { @@ -401,6 +404,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 6f340ab..d9c5d9a 100644 --- a/src/tests/receiving/receiveInbound.test.ts +++ b/src/tests/receiving/receiveInbound.test.ts @@ -24,6 +24,7 @@ test.describe('Receive inbound stock movement', () => { dateRequested, }); + productService.setProduct('1'); const product = await productService.getProduct(); productService.setProduct('2'); const product2 = await productService.getProduct(); @@ -134,6 +135,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); @@ -190,6 +192,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 4d7af78..e3437c9 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(); @@ -119,6 +120,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(); @@ -243,6 +245,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 a7789fe..4c489b8 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 5e91c34..61ee06f 100644 --- a/src/tests/receiving/receiveToHoldBin.test.ts +++ b/src/tests/receiving/receiveToHoldBin.test.ts @@ -24,6 +24,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 7fb03e7..bba256e 100644 --- a/src/tests/receiving/receivingStatusChanges.test.ts +++ b/src/tests/receiving/receivingStatusChanges.test.ts @@ -19,6 +19,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 e660701..b2d31c4 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 c0f5c95..18a9f97 100644 --- a/src/tests/receiving/rollbackStatusChanges.test.ts +++ b/src/tests/receiving/rollbackStatusChanges.test.ts @@ -19,6 +19,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 776c49d..a4a887e 100644 --- a/src/tests/receiving/tableShortcutsInReceiving.test.ts +++ b/src/tests/receiving/tableShortcutsInReceiving.test.ts @@ -18,6 +18,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 0920969..244b6bc 100644 --- a/src/tests/receiving/validationsOnDeliverOnDate.test.ts +++ b/src/tests/receiving/validationsOnDeliverOnDate.test.ts @@ -19,6 +19,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 93708a5..dbabb20 100644 --- a/src/tests/receiving/validationsOnEditAndReceive.test.ts +++ b/src/tests/receiving/validationsOnEditAndReceive.test.ts @@ -23,6 +23,7 @@ test.describe('Assert validation on try to receive not yet shipped inbound', () dateRequested, }); + productService.setProduct('1'); const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( From 0eaf31ac606a3f8d116f518bd37e35067ee2aa03 Mon Sep 17 00:00:00 2001 From: Alan Nadolny Date: Mon, 9 Feb 2026 11:44:22 +0100 Subject: [PATCH 13/13] OBPIH-6969 Refactor product service usage in inbound tests --- src/setup/dataImport/inventory.csv | 2 ++ src/setup/dataImport/products.csv | 12 +++---- ...ssertAttemptToEditCompletedPutaway.test.ts | 5 +-- .../putaway/assertPutawayDetailsPage.test.ts | 5 +-- .../changeLocationOnCreatePutawayPage.test.ts | 10 +++--- src/tests/putaway/createPutaway.test.ts | 10 +++--- .../putaway/putawayMoreThan1Item.test.ts | 36 ++++++++++--------- ...lbackLastReceiptWhenPutawayCreated.test.ts | 5 +-- src/tests/putaway/splitLineInPutaway.test.ts | 10 +++--- src/tests/receiving/receiveInbound.test.ts | 9 ++--- .../validationsOnEditAndReceive.test.ts | 5 +-- 11 files changed, 63 insertions(+), 46 deletions(-) diff --git a/src/setup/dataImport/inventory.csv b/src/setup/dataImport/inventory.csv index 402c381..7b399b2 100644 --- a/src/setup/dataImport/inventory.csv +++ b/src/setup/dataImport/inventory.csv @@ -1,3 +1,5 @@ Product code,Product,Lot number,Expiration date,Bin location,Quantity,Comment 1,E2E-product-one,,,,122, 2,E2E-product-two,,,,123, +3,E2E-product-three,,,,100, +4,E2E-product-four,,,,100, diff --git a/src/setup/dataImport/products.csv b/src/setup/dataImport/products.csv index a3c4de7..db1f2a9 100644 --- a/src/setup/dataImport/products.csv +++ b/src/setup/dataImport/products.csv @@ -1,6 +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,,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,,,,,,,,,,,,,,,,,,,,, +Id,Active,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 +,true,1,Default,E2E-product-one,,ARVS,,,,,,,,,,,,,,,,,,,,, +,true,2,Default,E2E-product-two,,ARVS,,,,,,,,,,,,,,,,,,,,, +,true,3,Default,E2E-product-three,,ARVS,,,,,,,,,,,,,,,,,,,,, +,true,4,Default,E2E-product-four,,ARVS,,,,,,,,,,,,,,,,,,,,, +,true,5,Default,E2E-product-five,,ARVS,,,,,,,,,,,,,,,,,,,,, diff --git a/src/tests/putaway/assertAttemptToEditCompletedPutaway.test.ts b/src/tests/putaway/assertAttemptToEditCompletedPutaway.test.ts index 2aa6d42..5279fec 100644 --- a/src/tests/putaway/assertAttemptToEditCompletedPutaway.test.ts +++ b/src/tests/putaway/assertAttemptToEditCompletedPutaway.test.ts @@ -11,7 +11,7 @@ test.describe('Assert attempt to edit completed putaway', () => { async ({ supplierLocationService, stockMovementService, - fifthProductService, + productService, receivingService, }) => { const supplierLocation = await supplierLocationService.getLocation(); @@ -19,7 +19,8 @@ test.describe('Assert attempt to edit completed putaway', () => { originId: supplierLocation.id, }); - const product = await fifthProductService.getProduct(); + productService.setProduct('5'); + const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, diff --git a/src/tests/putaway/assertPutawayDetailsPage.test.ts b/src/tests/putaway/assertPutawayDetailsPage.test.ts index d7e4f21..051ef51 100644 --- a/src/tests/putaway/assertPutawayDetailsPage.test.ts +++ b/src/tests/putaway/assertPutawayDetailsPage.test.ts @@ -11,7 +11,7 @@ test.describe('Assert putaway details page', () => { async ({ supplierLocationService, stockMovementService, - fifthProductService, + productService, receivingService, }) => { const supplierLocation = await supplierLocationService.getLocation(); @@ -19,7 +19,8 @@ test.describe('Assert putaway details page', () => { originId: supplierLocation.id, }); - const product = await fifthProductService.getProduct(); + productService.setProduct('5'); + const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, diff --git a/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts b/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts index 540edbf..4bfff8e 100644 --- a/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts +++ b/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts @@ -11,7 +11,7 @@ test.describe('Change location on putaway create page and list pages', () => { async ({ supplierLocationService, stockMovementService, - fifthProductService, + productService, receivingService, }) => { const supplierLocation = await supplierLocationService.getLocation(); @@ -19,7 +19,8 @@ test.describe('Change location on putaway create page and list pages', () => { originId: supplierLocation.id, }); - const product = await fifthProductService.getProduct(); + productService.setProduct('5'); + const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -77,7 +78,7 @@ test.describe('Change location on putaway create page and list pages', () => { navbar, createPutawayPage, locationChooser, - fifthProductService, + productService, depotLocationService, mainLocationService, putawayListPage, @@ -85,7 +86,8 @@ test.describe('Change location on putaway create page and list pages', () => { }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - const product = await fifthProductService.getProduct(); + productService.setProduct('5'); + const product = await productService.getProduct(); const mainLocation = await mainLocationService.getLocation(); const depotLocation = await depotLocationService.getLocation(); diff --git a/src/tests/putaway/createPutaway.test.ts b/src/tests/putaway/createPutaway.test.ts index 0737a42..8bd64bd 100644 --- a/src/tests/putaway/createPutaway.test.ts +++ b/src/tests/putaway/createPutaway.test.ts @@ -11,7 +11,7 @@ test.describe('Putaway received inbound shipment', () => { async ({ supplierLocationService, stockMovementService, - fifthProductService, + productService, receivingService, }) => { const supplierLocation = await supplierLocationService.getLocation(); @@ -19,7 +19,8 @@ test.describe('Putaway received inbound shipment', () => { originId: supplierLocation.id, }); - const product = await fifthProductService.getProduct(); + productService.setProduct('5'); + const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -84,7 +85,7 @@ test.describe('Putaway received inbound shipment', () => { internalLocationService, productShowPage, putawayDetailsPage, - fifthProductService, + productService, }) => { await test.step('Go to stock movement show page and assert received status', async () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); @@ -128,7 +129,8 @@ test.describe('Putaway received inbound shipment', () => { await test.step('Assert putaway bin on stock card', async () => { await putawayDetailsPage.summaryTab.click(); - const product = await fifthProductService.getProduct(); + productService.setProduct('5'); + const product = await productService.getProduct(); await productShowPage.goToPage(product.id) await productShowPage.inStockTab.click(); await productShowPage.inStockTabSection.isLoaded(); diff --git a/src/tests/putaway/putawayMoreThan1Item.test.ts b/src/tests/putaway/putawayMoreThan1Item.test.ts index 1e04d55..f32cca5 100644 --- a/src/tests/putaway/putawayMoreThan1Item.test.ts +++ b/src/tests/putaway/putawayMoreThan1Item.test.ts @@ -11,8 +11,7 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { async ({ supplierLocationService, stockMovementService, - fifthProductService, - fourthProductService, + productService, receivingService, }) => { const supplierLocation = await supplierLocationService.getLocation(); @@ -20,8 +19,10 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { originId: supplierLocation.id, }); - const product = await fifthProductService.getProduct(); - const product2 = await fourthProductService.getProduct(); + productService.setProduct('5'); + const product = await productService.getProduct(); + productService.setProduct('4'); + const product2 = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -90,14 +91,15 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { internalLocationService, productShowPage, putawayDetailsPage, - fifthProductService, - fourthProductService, + productService, putawayListPage, }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - const product = await fifthProductService.getProduct(); - const product2 = await fourthProductService.getProduct(); + productService.setProduct('5'); + const product = await productService.getProduct(); + productService.setProduct('4'); + const product2 = await productService.getProduct(); const internalLocation = await internalLocationService.getLocation(); await test.step('Go to create putaway page', async () => { @@ -243,8 +245,7 @@ test.describe('Putaway 2 items in the same putaway', () => { async ({ supplierLocationService, stockMovementService, - fifthProductService, - fourthProductService, + productService, receivingService, }) => { const supplierLocation = await supplierLocationService.getLocation(); @@ -252,8 +253,10 @@ test.describe('Putaway 2 items in the same putaway', () => { originId: supplierLocation.id, }); - const product = await fifthProductService.getProduct(); - const product2 = await fourthProductService.getProduct(); + productService.setProduct('5'); + const product = await productService.getProduct(); + productService.setProduct('4'); + const product2 = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -321,13 +324,14 @@ test.describe('Putaway 2 items in the same putaway', () => { internalLocationService, productShowPage, putawayDetailsPage, - fifthProductService, - fourthProductService, + productService, }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - const product = await fifthProductService.getProduct(); - const product2 = await fourthProductService.getProduct(); + productService.setProduct('5'); + const product = await productService.getProduct(); + productService.setProduct('4'); + const product2 = await productService.getProduct(); const internalLocation = await internalLocationService.getLocation(); await test.step('Go to create putaway page', async () => { diff --git a/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts b/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts index b0a99f3..5df8330 100644 --- a/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts +++ b/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts @@ -11,7 +11,7 @@ test.describe('Rollback last receipt behavior when putaway created', () => { async ({ supplierLocationService, stockMovementService, - fifthProductService, + productService, receivingService, }) => { const supplierLocation = await supplierLocationService.getLocation(); @@ -19,7 +19,8 @@ test.describe('Rollback last receipt behavior when putaway created', () => { originId: supplierLocation.id, }); - const product = await fifthProductService.getProduct(); + productService.setProduct('5'); + const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, diff --git a/src/tests/putaway/splitLineInPutaway.test.ts b/src/tests/putaway/splitLineInPutaway.test.ts index 44fa590..b1f66a6 100644 --- a/src/tests/putaway/splitLineInPutaway.test.ts +++ b/src/tests/putaway/splitLineInPutaway.test.ts @@ -11,7 +11,7 @@ test.describe('Split line in Putaway', () => { async ({ supplierLocationService, stockMovementService, - fifthProductService, + productService, receivingService, }) => { const supplierLocation = await supplierLocationService.getLocation(); @@ -19,7 +19,8 @@ test.describe('Split line in Putaway', () => { originId: supplierLocation.id, }); - const product = await fifthProductService.getProduct(); + productService.setProduct('5'); + const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -88,7 +89,7 @@ test.describe('Split line in Putaway', () => { internalLocation2Service, putawayDetailsPage, productShowPage, - fifthProductService, + productService, }) => { const internalLocation = await internalLocationService.getLocation(); const internalLocation2 = await internalLocation2Service.getLocation(); @@ -176,7 +177,8 @@ test.describe('Split line in Putaway', () => { await test.step('Assert putaway bin on stock card', async () => { await putawayDetailsPage.summaryTab.click(); - const product = await fifthProductService.getProduct(); + productService.setProduct('5'); + const product = await productService.getProduct(); await productShowPage.goToPage(product.id); await productShowPage.inStockTab.click(); await productShowPage.inStockTabSection.isLoaded(); diff --git a/src/tests/receiving/receiveInbound.test.ts b/src/tests/receiving/receiveInbound.test.ts index d9c5d9a..0f57ecb 100644 --- a/src/tests/receiving/receiveInbound.test.ts +++ b/src/tests/receiving/receiveInbound.test.ts @@ -392,8 +392,7 @@ test.describe('Receive from different locations', () => { async ({ supplierLocationService, stockMovementService, - mainProductService, - otherProductService, + productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); STOCK_MOVEMENT = await stockMovementService.createInbound({ @@ -402,8 +401,10 @@ test.describe('Receive from different locations', () => { dateRequested, }); - const product = await mainProductService.getProduct(); - const product2 = await otherProductService.getProduct(); + productService.setProduct('1'); + const product = await productService.getProduct(); + productService.setProduct('2'); + const product2 = 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 dbabb20..a5c76fe 100644 --- a/src/tests/receiving/validationsOnEditAndReceive.test.ts +++ b/src/tests/receiving/validationsOnEditAndReceive.test.ts @@ -74,7 +74,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({ @@ -83,7 +83,8 @@ test.describe('Validations on edit and receive inbound stock movement', () => { dateRequested, }); - const product = await mainProductService.getProduct(); + productService.setProduct('1'); + const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id,