diff --git a/.gitignore b/.gitignore index 160c4de..4695d2d 100755 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,6 @@ node_modules/ /localFiles .idea/ + +# generated +src/generated/ diff --git a/package.json b/package.json index ce6b9f4..718543f 100755 --- a/package.json +++ b/package.json @@ -7,6 +7,8 @@ "lint": "eslint .", "lint-fix": "eslint . --fix", "format": "npx prettier --write .", + "generate:product-codes": "node scripts/generateProductCodes.mjs", + "pretest": "npm run generate:product-codes", "test": "npx playwright test", "ui": "npx playwright test --ui", "report": "npx playwright show-report" diff --git a/playwright.config.ts b/playwright.config.ts index 2622d12..7127c16 100755 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,9 +1,15 @@ import 'dotenv/config'; +import { execSync } from 'node:child_process'; + import { defineConfig, devices } from '@playwright/test'; import AppConfig from './src/config/AppConfig'; +// Regenerate ProductCodes.generated.ts before any test files are loaded. +// Runs whether tests are invoked via `npm test` (pretest hook) or `npx playwright test` directly. +execSync('node scripts/generateProductCodes.mjs', { stdio: 'inherit' }); + const appConfig = AppConfig.instance; appConfig.initialize(); diff --git a/scripts/generateProductCodes.mjs b/scripts/generateProductCodes.mjs new file mode 100644 index 0000000..5edee5d --- /dev/null +++ b/scripts/generateProductCodes.mjs @@ -0,0 +1,82 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + +const CSV_PATH = path.join(__dirname, '..', 'src', 'setup', 'dataImport', 'products.csv'); +const OUTPUT_PATH = path.join(__dirname, '..', 'src', 'generated', 'ProductCodes.generated.ts'); + +function parseCsv(csv) { + const lines = csv.trim().split('\n'); + if (lines.length < 2) { + return []; + } + const headers = lines[0].split(',').map((h) => h.trim()); + const codeIndex = headers.indexOf('ProductCode'); + const nameIndex = headers.indexOf('Name'); + if (codeIndex === -1) { + throw new Error(`ProductCode column not found in ${CSV_PATH}`); + } + if (nameIndex === -1) { + throw new Error(`Name column not found in ${CSV_PATH}`); + } + return lines + .slice(1) + .map((line) => line.split(',')) + .map((cols) => ({ + code: cols[codeIndex]?.trim() ?? '', + name: cols[nameIndex]?.trim() ?? '', + })) + .filter((row) => row.code.length > 0); +} + +function buildFileContent(rows) { + const codeByName = new Map(rows.map((row) => [row.name, row.code])); + + if (rows.length < 6) { + throw new Error('We require at least 6 rows with a valid product code in products.csv') + } + // Stable keys for the generated objects, mapped to the name value + // in products.csv that identifies the row. The productCode (value) is read + // from the CSV at generation time, so codes can change without touching tests. + const PRODUCT_KEYS = { + ONE: rows[0].name, + TWO: rows[1].name, + THREE: rows[2].name, + FOUR: rows[3].name, + FIVE: rows[4].name, + SIX: rows[5].name, + } + + const entries = Object.entries(PRODUCT_KEYS).map(([key, name]) => { + const code = codeByName.get(name); + if (!code) { + throw new Error( + `Product with Name "${name}" (key ${key}) not found in ${CSV_PATH}. ` + + 'Update PRODUCT_KEYS in scripts/generateProductCodes.mjs or add the row to products.csv.' + ); + } + return ` ${key}: '${code}',`; + }); + + return `// AUTO-GENERATED FILE. DO NOT EDIT. +// Regenerated from src/setup/dataImport/products.csv by scripts/generateProductCodes.mjs +// Output: src/generated/ProductCodes.generated.ts + +export const Product = { +${entries.join('\n')} +} as const; + +export type ProductCode = (typeof Product)[keyof typeof Product]; +`; +} + +const csv = fs.readFileSync(CSV_PATH, 'utf8'); +const rows = parseCsv(csv); +if (rows.length === 0) { + throw new Error(`No product codes found in ${CSV_PATH}`); +} + +fs.mkdirSync(path.dirname(OUTPUT_PATH), { recursive: true }); +fs.writeFileSync(OUTPUT_PATH, buildFileContent(rows), 'utf8'); diff --git a/src/api/AuthService.ts b/src/api/AuthService.ts index 51e41bc..3ce1c2c 100644 --- a/src/api/AuthService.ts +++ b/src/api/AuthService.ts @@ -1,17 +1,16 @@ import BaseServiceModel from '@/api/BaseServiceModel'; +import { CHOOSE_LOCATION, LOGIN_API } from '@/consts/apiUrls'; class AuthService extends BaseServiceModel { async login(data: { username: string; password: string; location?: string }) { - const apiResponse = await this.request.get('./api/login', { data }); + const apiResponse = await this.request.get(LOGIN_API, { data }); if (apiResponse.status() !== 200) { throw new Error(`Authentication for user "${data.username}" failed`); } } async changeLocation(locationId: string) { - const apiResponse = await this.request.put( - `./api/chooseLocation/${locationId}` - ); + const apiResponse = await this.request.put(CHOOSE_LOCATION(locationId)); return await apiResponse.body(); } } diff --git a/src/api/GenericService.ts b/src/api/GenericService.ts index b673af6..0176135 100644 --- a/src/api/GenericService.ts +++ b/src/api/GenericService.ts @@ -1,11 +1,12 @@ import BaseServiceModel from '@/api/BaseServiceModel'; +import { APP_CONTEXT, GENERIC_USER_BY_ID } from '@/consts/apiUrls'; import { ApiResponse, AppContextResponse, User } from '@/types'; import { parseRequestToJSON } from '@/utils/ServiceUtils'; class GenericService extends BaseServiceModel { async getAppContext(): Promise> { try { - const apiResponse = await this.request.get('./api/getAppContext'); + const apiResponse = await this.request.get(APP_CONTEXT); return await parseRequestToJSON(apiResponse); } catch (error) { throw new Error('Problem fetching app context'); @@ -14,7 +15,7 @@ class GenericService extends BaseServiceModel { async getUser(id: string): Promise> { try { - const apiResponse = await this.request.get(`./api/generic/user/${id}`); + const apiResponse = await this.request.get(GENERIC_USER_BY_ID(id)); return await parseRequestToJSON(apiResponse); } catch (error) { throw new Error(`Problem fetching a user with id: ${id}`); diff --git a/src/api/InventoryService.ts b/src/api/InventoryService.ts index 67134fd..c61caff 100644 --- a/src/api/InventoryService.ts +++ b/src/api/InventoryService.ts @@ -1,4 +1,5 @@ import BaseServiceModel from '@/api/BaseServiceModel'; +import { INVENTORY_IMPORT } from '@/consts/apiUrls'; import { jsonToCsv } from '@/utils/ServiceUtils'; class InventoryService extends BaseServiceModel { @@ -6,7 +7,7 @@ class InventoryService extends BaseServiceModel { try { const csvContent = jsonToCsv(data); - const response = await this.request.post(`./api/facilities/${facilityId}/inventories/import`, { + const response = await this.request.post(INVENTORY_IMPORT(facilityId), { data: csvContent, headers: { 'Content-Type': 'text/csv' }, }); diff --git a/src/api/LocationService.ts b/src/api/LocationService.ts index 55ef592..4ff4c9e 100644 --- a/src/api/LocationService.ts +++ b/src/api/LocationService.ts @@ -1,4 +1,9 @@ import BaseServiceModel from '@/api/BaseServiceModel'; +import { + LOCATION_API, + LOCATION_BY_ID, + LOCATION_TYPES, +} from '@/consts/apiUrls'; import { ApiResponse, CreateLocationPayload, @@ -10,7 +15,7 @@ import { parseRequestToJSON } from '@/utils/ServiceUtils'; class LocationService extends BaseServiceModel { async getLocation(id: string): Promise> { try { - const apiResponse = await this.request.get(`./api/locations/${id}`); + const apiResponse = await this.request.get(LOCATION_BY_ID(id)); return await parseRequestToJSON(apiResponse); } catch (error) { throw new Error(`Problem fetching location with id: ${id}`); @@ -22,7 +27,7 @@ class LocationService extends BaseServiceModel { params = {} ): Promise> { try { - const apiResponse = await this.request.post('./api/locations', { + const apiResponse = await this.request.post(LOCATION_API, { data: payload, params, }); @@ -34,9 +39,7 @@ class LocationService extends BaseServiceModel { async getLocationTypes(): Promise> { try { - const apiResponse = await this.request.get( - './api/locations/locationTypes' - ); + const apiResponse = await this.request.get(LOCATION_TYPES); return await parseRequestToJSON(apiResponse); } catch (error) { diff --git a/src/api/ProductService.ts b/src/api/ProductService.ts index bf83b07..604557d 100644 --- a/src/api/ProductService.ts +++ b/src/api/ProductService.ts @@ -1,11 +1,16 @@ import BaseServiceModel from '@/api/BaseServiceModel'; +import { + PRODUCT_BY_ID, + PRODUCT_DEMAND, + PRODUCT_IMPORT, +} from '@/consts/apiUrls'; import { ApiResponse, ProductDemandResponse, ProductResponse } from '@/types'; import { jsonToCsv, parseRequestToJSON } from '@/utils/ServiceUtils'; class ProductService extends BaseServiceModel { async getDemand(id: string): Promise> { try { - const apiResponse = await this.request.get(`./api/products/${id}/demand`); + const apiResponse = await this.request.get(PRODUCT_DEMAND(id)); return await parseRequestToJSON(apiResponse); } catch (error) { @@ -15,7 +20,7 @@ class ProductService extends BaseServiceModel { async get(id: string): Promise> { try { - const apiResponse = await this.request.get(`./api/products/${id}`); + const apiResponse = await this.request.get(PRODUCT_BY_ID(id)); return await parseRequestToJSON(apiResponse); } catch (error) { @@ -28,7 +33,7 @@ class ProductService extends BaseServiceModel { const csvContent = jsonToCsv(data); const apiResponse = await this.request.post( - './api/products/import', + PRODUCT_IMPORT, { data: csvContent, headers: { 'Content-Type': 'text/csv' } diff --git a/src/api/ReceivingService.ts b/src/api/ReceivingService.ts index 301101a..abe24ab 100644 --- a/src/api/ReceivingService.ts +++ b/src/api/ReceivingService.ts @@ -3,6 +3,7 @@ import _ from 'lodash'; import BaseServiceModel from '@/api/BaseServiceModel'; import { PartialReceiptStatus } from '@/constants/PartialReceiptStatus'; +import { PARTIAL_RECEIVING_BY_ID } from '@/consts/apiUrls'; import { ApiResponse, Container, @@ -24,9 +25,7 @@ class ReceivingService extends BaseServiceModel { */ async getReceipt(id: string): Promise> { try { - const apiResponse = await this.request.get( - `./api/partialReceiving/${id}` - ); + const apiResponse = await this.request.get(PARTIAL_RECEIVING_BY_ID(id)); return await parseRequestToJSON(apiResponse); } catch (error) { throw new Error('Problem fetching partial receipt'); @@ -94,7 +93,7 @@ class ReceivingService extends BaseServiceModel { containers: containers, recipient: receipt?.data?.recipient?.id, }; - await this.request.post(`./api/partialReceiving/${id}`, { + await this.request.post(PARTIAL_RECEIVING_BY_ID(id), { data: payload, }); } catch (error) { @@ -116,7 +115,7 @@ class ReceivingService extends BaseServiceModel { containers: this.createEmptyContainers(receipt?.containers), recipient: receipt.recipient?.id, }; - await this.request.post(`./api/partialReceiving/${id}`, { + await this.request.post(PARTIAL_RECEIVING_BY_ID(id), { data: payload, }); } catch (error) { @@ -267,7 +266,7 @@ class ReceivingService extends BaseServiceModel { } private async saveSplitLines(id: string, payload: ReceiptPayload) { - await this.request.post(`./api/partialReceiving/${id}`, { + await this.request.post(PARTIAL_RECEIVING_BY_ID(id), { data: payload, }); } @@ -276,7 +275,7 @@ class ReceivingService extends BaseServiceModel { id: string, status: PartialReceiptStatus ): Promise { - await this.request.post(`./api/partialReceiving/${id}`, { + await this.request.post(PARTIAL_RECEIVING_BY_ID(id), { data: { id, stepNumber: 2, diff --git a/src/api/StockMovementService.ts b/src/api/StockMovementService.ts index 4e162ef..1d73644 100644 --- a/src/api/StockMovementService.ts +++ b/src/api/StockMovementService.ts @@ -2,6 +2,13 @@ import { APIRequestContext } from '@playwright/test'; import BaseServiceModel from '@/api/BaseServiceModel'; import { ShipmentType } from '@/constants/ShipmentType'; +import { + STOCK_MOVEMENT_API, + STOCK_MOVEMENT_BY_ID, + STOCK_MOVEMENT_STATUS, + STOCK_MOVEMENT_UPDATE_ITEMS, + STOCK_MOVEMENT_UPDATE_SHIPMENT, +} from '@/consts/apiUrls'; import { ApiResponse, CreateInboundPayload, @@ -33,7 +40,7 @@ class StockMovementService extends BaseServiceModel { payload: CreateStockMovementPayload ): Promise> { try { - const apiResponse = await this.request.post('./api/stockMovements', { + const apiResponse = await this.request.post(STOCK_MOVEMENT_API, { data: payload, }); @@ -45,7 +52,7 @@ class StockMovementService extends BaseServiceModel { async deleteStockMovement(id: string) { try { - await this.request.delete(`./api/stockMovements/${id}`); + await this.request.delete(STOCK_MOVEMENT_BY_ID(id)); } catch (error) { throw new Error('Problem deleting stock movement'); } @@ -55,7 +62,7 @@ class StockMovementService extends BaseServiceModel { id: string ): Promise> { try { - const apiResponse = await this.request.get(`./api/stockMovements/${id}`); + const apiResponse = await this.request.get(STOCK_MOVEMENT_BY_ID(id)); return await parseRequestToJSON(apiResponse); } catch (error) { throw new Error('Problem deleting stock movement'); @@ -68,7 +75,7 @@ class StockMovementService extends BaseServiceModel { ): Promise> { try { const apiResponse = await this.request.post( - `./api/stockMovements/${id}/updateItems`, + STOCK_MOVEMENT_UPDATE_ITEMS(id), { data: payload, } @@ -82,7 +89,7 @@ class StockMovementService extends BaseServiceModel { async updateShipment(id: string, payload: UpdateStockMovementPayload) { try { - await this.request.post(`./api/stockMovements/${id}/updateShipment`, { + await this.request.post(STOCK_MOVEMENT_UPDATE_SHIPMENT(id), { data: payload, }); } catch (error) { @@ -112,7 +119,7 @@ class StockMovementService extends BaseServiceModel { payload: UpdateStockMovementStatusPayload ) { try { - await this.request.post(`./api/stockMovements/${id}/status`, { + await this.request.post(STOCK_MOVEMENT_STATUS(id), { data: payload, }); } catch (error) { diff --git a/src/consts/apiUrls.ts b/src/consts/apiUrls.ts new file mode 100644 index 0000000..e86b0aa --- /dev/null +++ b/src/consts/apiUrls.ts @@ -0,0 +1,54 @@ +/** + * Definitions of ENDPOINT URLs used for API calls in e2e tests. + * URLs are relative to APP_BASE_URL configured in Playwright. + */ + +const API = './api'; + +// AUTH +export const LOGIN_API = `${API}/login`; +export const CHOOSE_LOCATION = (locationId: string) => + `${API}/chooseLocation/${locationId}`; + +// APP CONTEXT +export const APP_CONTEXT = `${API}/getAppContext`; + +// GENERIC +export const GENERIC_API = `${API}/generic`; +export const GENERIC_USER_BY_ID = (id: string) => `${GENERIC_API}/user/${id}`; + +// LOCATIONS +export const LOCATION_API = `${API}/locations`; +export const LOCATION_BY_ID = (id: string) => `${LOCATION_API}/${id}`; +export const LOCATION_TYPES = `${LOCATION_API}/locationTypes`; + +// STOCK MOVEMENT +export const STOCK_MOVEMENT_API = `${API}/stockMovements`; +export const STOCK_MOVEMENT_API_PATTERN = `${STOCK_MOVEMENT_API}?**`; +export const STOCK_MOVEMENT_ITEMS_PATTERN = + /\/api\/stockMovements\/.*\/stockMovementItems/; +export const STOCK_MOVEMENT_BY_ID = (id: string) => + `${STOCK_MOVEMENT_API}/${id}`; +export const STOCK_MOVEMENT_UPDATE_ITEMS = (id: string) => + `${STOCK_MOVEMENT_BY_ID(id)}/updateItems`; +export const STOCK_MOVEMENT_UPDATE_SHIPMENT = (id: string) => + `${STOCK_MOVEMENT_BY_ID(id)}/updateShipment`; +export const STOCK_MOVEMENT_STATUS = (id: string) => + `${STOCK_MOVEMENT_BY_ID(id)}/status`; +export const STOCK_MOVEMENT_ITEMS = (id: string) => + `${STOCK_MOVEMENT_BY_ID(id)}/stockMovementItems`; + +// PARTIAL RECEIVING +export const PARTIAL_RECEIVING_BY_ID = (id: string) => + `${API}/partialReceiving/${id}`; +export const PARTIAL_RECEIVING_API_PATTERN = `${API}/partialReceiving/**`; + +// PRODUCTS +export const PRODUCT_API = `${API}/products`; +export const PRODUCT_BY_ID = (id: string) => `${PRODUCT_API}/${id}`; +export const PRODUCT_DEMAND = (id: string) => `${PRODUCT_BY_ID(id)}/demand`; +export const PRODUCT_IMPORT = `${PRODUCT_API}/import`; + +// INVENTORY +export const INVENTORY_IMPORT = (facilityId: string) => + `${API}/facilities/${facilityId}/inventories/import`; diff --git a/src/consts/applicationUrls.ts b/src/consts/applicationUrls.ts new file mode 100644 index 0000000..ee9c01b --- /dev/null +++ b/src/consts/applicationUrls.ts @@ -0,0 +1,97 @@ +/** + * Definitions of APPLICATION URLs used for navigating to pages. + * URLs are relative to APP_BASE_URL configured in Playwright. + */ + +const AUTH_URL = { + base: './auth', + login: () => `${AUTH_URL.base}/login`, +}; + +const DASHBOARD_URL = { + base: './dashboard', +}; + +const LOCATION_URL = { + base: './location', + list: () => `${LOCATION_URL.base}/list`, + edit: () => `${LOCATION_URL.base}/edit`, +}; + +const LOCATION_GROUP_URL = { + base: './locationGroup', + list: (params: { max: number }) => + `${LOCATION_GROUP_URL.base}/list?max=${params.max}`, +}; + +const PRODUCT_URL = { + base: './product', + create: () => `${PRODUCT_URL.base}/create`, + createPattern: '**/product/create**', + edit: (id: string) => `${PRODUCT_URL.base}/edit/${id}`, +}; + +const INVENTORY_ITEM_URL = { + base: './inventoryItem', + showStockCard: (id: string) => `${INVENTORY_ITEM_URL.base}/showStockCard/${id}`, +}; + +const STOCK_MOVEMENT_URL = { + base: './stockMovement', + list: () => `${STOCK_MOVEMENT_URL.base}/list`, + listPattern: '**/stockMovement/list**', + listInbound: () => `${STOCK_MOVEMENT_URL.list()}?direction=INBOUND`, + createInbound: () => `${STOCK_MOVEMENT_URL.base}/createInbound`, + editInbound: (id: string) => `${STOCK_MOVEMENT_URL.createInbound()}/${id}`, + show: (id: string) => `${STOCK_MOVEMENT_URL.base}/show/${id}`, + showPattern: '**/stockMovement/show/**', +}; + +const INVOICE_URL = { + base: './invoice', + list: () => `${INVOICE_URL.base}/list`, + create: () => `${INVOICE_URL.base}/create`, +}; + +const ORGANIZATION_URL = { + base: './organization', + create: () => `${ORGANIZATION_URL.base}/create`, +}; + +const PERSON_URL = { + base: './person', + list: () => `${PERSON_URL.base}/list`, +}; + +const USER_URL = { + base: './user', + list: () => `${USER_URL.base}/list`, +}; + +const PUTAWAY_URL = { + base: './putAway', + create: () => `${PUTAWAY_URL.base}/create`, +}; + +const ORDER_URL = { + base: './order', + list: () => `${ORDER_URL.base}/list`, + putawayList: (status: string) => + `${ORDER_URL.list()}?orderType=PUTAWAY_ORDER&status=${status}`, +}; + +export { + AUTH_URL, + DASHBOARD_URL, + INVENTORY_ITEM_URL, + INVOICE_URL, + LOCATION_GROUP_URL, + LOCATION_URL, + ORDER_URL, + ORGANIZATION_URL, + PERSON_URL, + PRODUCT_URL, + PUTAWAY_URL, + STOCK_MOVEMENT_URL, + USER_URL, +}; diff --git a/src/pages/LoginPage.ts b/src/pages/LoginPage.ts index ec24ff8..52ccb23 100644 --- a/src/pages/LoginPage.ts +++ b/src/pages/LoginPage.ts @@ -1,3 +1,4 @@ +import { AUTH_URL } from '@/consts/applicationUrls'; import BasePageModel from '@/pages/BasePageModel'; class LoginPage extends BasePageModel { @@ -14,7 +15,7 @@ class LoginPage extends BasePageModel { } async goToPage() { - await this.page.goto('./auth/login'); + await this.page.goto(AUTH_URL.login()); } async fillLoginForm(username: string, password: string) { diff --git a/src/pages/inbound/create/CreateInboundPage.ts b/src/pages/inbound/create/CreateInboundPage.ts index cb5be0f..abfda97 100644 --- a/src/pages/inbound/create/CreateInboundPage.ts +++ b/src/pages/inbound/create/CreateInboundPage.ts @@ -1,6 +1,7 @@ import { expect, Page } from '@playwright/test'; import WizzardSteps from '@/components/WizzardSteps'; +import { STOCK_MOVEMENT_URL } from '@/consts/applicationUrls'; import BasePageModel from '@/pages/BasePageModel'; import AddItemsStep from '@/pages/inbound/create/steps/AddItemsStep'; import CreateStep from '@/pages/inbound/create/steps/CreateStep'; @@ -26,10 +27,10 @@ class CreateInboundPage extends BasePageModel { async goToPage(id?: string) { if (id) { - await this.page.goto(`./stockMovement/createInbound/${id}`); + await this.page.goto(STOCK_MOVEMENT_URL.editInbound(id)); return; } - await this.page.goto('./stockMovement/createInbound?direction=INBOUND'); + await this.page.goto(STOCK_MOVEMENT_URL.createInbound()); } getId() { diff --git a/src/pages/inbound/create/steps/AddItemsStep.ts b/src/pages/inbound/create/steps/AddItemsStep.ts index dc6bd0d..0533116 100644 --- a/src/pages/inbound/create/steps/AddItemsStep.ts +++ b/src/pages/inbound/create/steps/AddItemsStep.ts @@ -2,6 +2,7 @@ import { Page } from '@playwright/test'; import AlertPopup from '@/components/AlertPopup'; import FileHandler from '@/components/FileHandler'; +import { STOCK_MOVEMENT_ITEMS_PATTERN } from '@/consts/apiUrls'; import { expect, test } from '@/fixtures/fixtures'; import BasePageModel from '@/pages/BasePageModel'; import AddItemsTable from '@/pages/inbound/create/components/AddItemsTable'; @@ -28,9 +29,7 @@ class AddItemsStep extends BasePageModel { } async waitForData() { - await this.page.waitForResponse( - /\/api\/stockMovements\/.*\/stockMovementItems/ - ); + await this.page.waitForResponse(STOCK_MOVEMENT_ITEMS_PATTERN); } get addLineButton() { diff --git a/src/pages/inbound/list/InboundListPage.ts b/src/pages/inbound/list/InboundListPage.ts index 7d465fe..533207f 100644 --- a/src/pages/inbound/list/InboundListPage.ts +++ b/src/pages/inbound/list/InboundListPage.ts @@ -1,6 +1,8 @@ import { Page } from '@playwright/test'; import FileHandler from '@/components/FileHandler'; +import { STOCK_MOVEMENT_API_PATTERN } from '@/consts/apiUrls'; +import { STOCK_MOVEMENT_URL } from '@/consts/applicationUrls'; import BasePageModel from '@/pages/BasePageModel'; import InboundListFilters from '@/pages/inbound/list/InboundListFilters'; import InboundStockMovementTable from '@/pages/inbound/list/InboundStockMovementTable'; @@ -34,15 +36,15 @@ class InboundListPage extends BasePageModel { } async goToPage() { - await this.page.goto('./stockMovement/list?direction=INBOUND'); + await this.page.goto(STOCK_MOVEMENT_URL.listInbound()); } async waitForUrl() { - await this.page.waitForURL('**/stockMovement/list**'); + await this.page.waitForURL(STOCK_MOVEMENT_URL.listPattern); } async waitForResponse() { - await this.page.waitForResponse('./api/stockMovements?**'); + await this.page.waitForResponse(STOCK_MOVEMENT_API_PATTERN); } async search() { diff --git a/src/pages/invoice/CreateInvoicePage.ts b/src/pages/invoice/CreateInvoicePage.ts index e42c2f9..56a0e60 100644 --- a/src/pages/invoice/CreateInvoicePage.ts +++ b/src/pages/invoice/CreateInvoicePage.ts @@ -1,3 +1,4 @@ +import { INVOICE_URL } from '@/consts/applicationUrls'; import { expect } from '@/fixtures/fixtures'; import BasePageModel from '@/pages/BasePageModel'; @@ -7,7 +8,7 @@ class CreateInvoicePage extends BasePageModel { } async goToPage() { - await this.page.goto('./invoice/create'); + await this.page.goto(INVOICE_URL.create()); } } diff --git a/src/pages/invoice/InvoiceListPage.ts b/src/pages/invoice/InvoiceListPage.ts index 31e9000..edb2400 100644 --- a/src/pages/invoice/InvoiceListPage.ts +++ b/src/pages/invoice/InvoiceListPage.ts @@ -1,3 +1,4 @@ +import { INVOICE_URL } from '@/consts/applicationUrls'; import { expect } from '@/fixtures/fixtures'; import BasePageModel from '@/pages/BasePageModel'; @@ -7,7 +8,7 @@ class InvoiceListPage extends BasePageModel { } async goToPage() { - await this.page.goto('./invoice/list'); + await this.page.goto(INVOICE_URL.list()); } get invoiceListHeader() { diff --git a/src/pages/location/createLocation/CreateLocationPage.ts b/src/pages/location/createLocation/CreateLocationPage.ts index 4a608f9..a49089e 100644 --- a/src/pages/location/createLocation/CreateLocationPage.ts +++ b/src/pages/location/createLocation/CreateLocationPage.ts @@ -1,5 +1,6 @@ import { Page } from '@playwright/test'; +import { LOCATION_URL } from '@/consts/applicationUrls'; import { expect } from '@/fixtures/fixtures'; import BasePageModel from '@/pages/BasePageModel'; import BinLocationsTabSection from '@/pages/location/createLocation/tabs/BinLocationsTabSection'; @@ -24,7 +25,7 @@ class CreateLocationPage extends BasePageModel { } async gotToPage() { - await this.page.goto('./location/edit'); + await this.page.goto(LOCATION_URL.edit()); } async isLoaded() { diff --git a/src/pages/locationGroup/LocationGroupsListPage.ts b/src/pages/locationGroup/LocationGroupsListPage.ts index 6bbf0a7..c85cde2 100644 --- a/src/pages/locationGroup/LocationGroupsListPage.ts +++ b/src/pages/locationGroup/LocationGroupsListPage.ts @@ -1,3 +1,4 @@ +import { LOCATION_GROUP_URL } from '@/consts/applicationUrls'; import { expect } from '@/fixtures/fixtures'; import BasePageModel from '@/pages/BasePageModel'; @@ -11,7 +12,7 @@ class LocationGroupsListPage extends BasePageModel { } async goToPage(params: { max: number }) { - this.page.goto(`./locationGroup/list?max=${params.max}`); + this.page.goto(LOCATION_GROUP_URL.list(params)); } getPaginationItem(pageNumber: string) { diff --git a/src/pages/oranization/CreateOrganizationPage.ts b/src/pages/oranization/CreateOrganizationPage.ts index fb196e8..61dfc2c 100644 --- a/src/pages/oranization/CreateOrganizationPage.ts +++ b/src/pages/oranization/CreateOrganizationPage.ts @@ -1,3 +1,4 @@ +import { ORGANIZATION_URL } from '@/consts/applicationUrls'; import { expect } from '@/fixtures/fixtures'; import BasePageModel from '@/pages/BasePageModel'; @@ -7,7 +8,7 @@ class CreateOrganizationPage extends BasePageModel { } async goToPage() { - await this.page.goto('./organization/create'); + await this.page.goto(ORGANIZATION_URL.create()); } get organizationNameField() { diff --git a/src/pages/product/CreateProductPage.ts b/src/pages/product/CreateProductPage.ts index 94ba49b..212f45a 100644 --- a/src/pages/product/CreateProductPage.ts +++ b/src/pages/product/CreateProductPage.ts @@ -1,5 +1,6 @@ import { Page } from '@playwright/test'; +import { PRODUCT_URL } from '@/consts/applicationUrls'; import BasePageModel from '@/pages/BasePageModel'; import ProductDetailsSection from '@/pages/product/sections/ProductDetailsSection'; @@ -16,11 +17,11 @@ class CreateProductPage extends BasePageModel { } async goToPage() { - await this.page.goto('./product/create'); + await this.page.goto(PRODUCT_URL.create()); } async waitForUrl() { - await this.page.waitForURL('**/product/create**'); + await this.page.waitForURL(PRODUCT_URL.createPattern); } } diff --git a/src/pages/product/productEdit/ProductEditPage.ts b/src/pages/product/productEdit/ProductEditPage.ts index acc12dd..50e2265 100644 --- a/src/pages/product/productEdit/ProductEditPage.ts +++ b/src/pages/product/productEdit/ProductEditPage.ts @@ -1,5 +1,6 @@ import { Page } from '@playwright/test'; +import { PRODUCT_URL } from '@/consts/applicationUrls'; import BasePageModel from '@/pages/BasePageModel'; import InventoryLevelsTabSection from '@/pages/product/productEdit/tabs/InventoryLevelsTabSection'; @@ -12,7 +13,7 @@ class ProductEditPage extends BasePageModel { } async goToPage(id: string) { - await this.page.goto(`./product/edit/${id}`); + await this.page.goto(PRODUCT_URL.edit(id)); } get detailskTab() { diff --git a/src/pages/product/productShow/ProductShowPage.ts b/src/pages/product/productShow/ProductShowPage.ts index 2f8b695..d998a55 100644 --- a/src/pages/product/productShow/ProductShowPage.ts +++ b/src/pages/product/productShow/ProductShowPage.ts @@ -1,5 +1,6 @@ import { Page } from '@playwright/test'; +import { INVENTORY_ITEM_URL } from '@/consts/applicationUrls'; import BasePageModel from '@/pages/BasePageModel'; import RecordStockSection from '@/pages/product/productShow/sections/RecordStockSection'; @@ -16,7 +17,7 @@ class ProductShowPage extends BasePageModel { } async goToPage(id: string) { - await this.page.goto(`./inventoryItem/showStockCard/${id}`); + await this.page.goto(INVENTORY_ITEM_URL.showStockCard(id)); } get showStockCardButton() { diff --git a/src/pages/putaway/CreatePutawayPage.ts b/src/pages/putaway/CreatePutawayPage.ts index 0e496ad..d30baa3 100644 --- a/src/pages/putaway/CreatePutawayPage.ts +++ b/src/pages/putaway/CreatePutawayPage.ts @@ -1,6 +1,7 @@ import { expect, Page } from '@playwright/test'; import WizzardSteps from '@/components/WizzardSteps'; +import { PUTAWAY_URL } from '@/consts/applicationUrls'; import BasePageModel from '@/pages/BasePageModel'; import StartStep from '@/pages/putaway/steps/StartStep'; @@ -31,7 +32,7 @@ class CreatePutawayPage extends BasePageModel { } async goToPage() { - await this.page.goto('./putAway/create'); + await this.page.goto(PUTAWAY_URL.create()); } get startPutawayButton() { diff --git a/src/pages/putaway/list/PutawayListPage.ts b/src/pages/putaway/list/PutawayListPage.ts index 5cf5b84..62e722b 100644 --- a/src/pages/putaway/list/PutawayListPage.ts +++ b/src/pages/putaway/list/PutawayListPage.ts @@ -1,5 +1,6 @@ import { expect, Page } from '@playwright/test'; +import { ORDER_URL } from '@/consts/applicationUrls'; import BasePageModel from '@/pages/BasePageModel'; import PutawayListTable from './PutawayListTable'; @@ -14,9 +15,7 @@ class PutawayListPage extends BasePageModel { } async goToPage(status = 'PENDING') { - await this.page.goto( - './order/list?orderType=PUTAWAY_ORDER&status=' + `${status}` - ); + await this.page.goto(ORDER_URL.putawayList(status)); } async isLoaded() { diff --git a/src/pages/receiving/steps/ReceivingStep.ts b/src/pages/receiving/steps/ReceivingStep.ts index 90379b2..59c93c2 100644 --- a/src/pages/receiving/steps/ReceivingStep.ts +++ b/src/pages/receiving/steps/ReceivingStep.ts @@ -2,6 +2,7 @@ import { expect, Page } from '@playwright/test'; import FileHandler from '@/components/FileHandler'; import NewAlertPopup from '@/components/NewAlertPopup'; +import { PARTIAL_RECEIVING_API_PATTERN } from '@/consts/apiUrls'; import BasePageModel from '@/pages/BasePageModel'; import EditModal from '@/pages/receiving/components/EditModal'; import ReceivingTable from '@/pages/receiving/components/ReceivingTable'; @@ -27,7 +28,7 @@ class ReceivingStep extends BasePageModel { } async waitForData() { - await this.page.waitForResponse('./api/partialReceiving/**'); + await this.page.waitForResponse(PARTIAL_RECEIVING_API_PATTERN); } get autofillQuantitiesButton() { diff --git a/src/pages/stockMovementShow/StockMovementShowPage.ts b/src/pages/stockMovementShow/StockMovementShowPage.ts index a009eab..29bd125 100644 --- a/src/pages/stockMovementShow/StockMovementShowPage.ts +++ b/src/pages/stockMovementShow/StockMovementShowPage.ts @@ -1,5 +1,6 @@ import { expect, Page } from '@playwright/test'; +import { STOCK_MOVEMENT_URL } from '@/consts/applicationUrls'; import BasePageModel from '@/pages/BasePageModel'; import AuditingTable from '@/pages/stockMovementShow/components/AuditingTable'; import PackingListTable from '@/pages/stockMovementShow/components/PackingListTable'; @@ -25,11 +26,11 @@ class StockMovementShowPage extends BasePageModel { } async goToPage(id: string) { - await this.page.goto(`./stockMovement/show/${id}`); + await this.page.goto(STOCK_MOVEMENT_URL.show(id)); } async waitForUrl() { - await this.page.waitForURL('**/stockMovement/show/**'); + await this.page.waitForURL(STOCK_MOVEMENT_URL.showPattern); } async isLoaded() { diff --git a/src/pages/user/UserListPage.ts b/src/pages/user/UserListPage.ts index f306b75..c50bb86 100644 --- a/src/pages/user/UserListPage.ts +++ b/src/pages/user/UserListPage.ts @@ -1,3 +1,4 @@ +import { USER_URL } from '@/consts/applicationUrls'; import { expect } from '@/fixtures/fixtures'; import BasePageModel from '@/pages/BasePageModel'; @@ -7,7 +8,7 @@ class UserListPage extends BasePageModel { } async goToPage() { - await this.page.goto('./user/list'); + await this.page.goto(USER_URL.list()); } get createUserButton() { diff --git a/src/tests/inbound/createInbound/createInbound.test.ts b/src/tests/inbound/createInbound/createInbound.test.ts index 46e1f22..f5e6c4f 100644 --- a/src/tests/inbound/createInbound/createInbound.test.ts +++ b/src/tests/inbound/createInbound/createInbound.test.ts @@ -1,4 +1,5 @@ import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { AddItemsTableRow, LocationResponse, User } from '@/types'; import { formatDate, getDateByOffset, getToday } from '@/utils/DateUtils'; @@ -23,10 +24,8 @@ 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); USER = await mainUserService.getUser(); ORIGIN = await supplierLocationService.getLocation(); CURRENT_LOCATION = await mainLocationService.getLocation(); @@ -198,10 +197,8 @@ 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); 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 1eec09d..512d6c8 100644 --- a/src/tests/inbound/createInbound/downloadDocsFromSendPage.test.ts +++ b/src/tests/inbound/createInbound/downloadDocsFromSendPage.test.ts @@ -1,4 +1,5 @@ import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { AddItemsTableRow, LocationResponse, User } from '@/types'; import { getDateByOffset, getToday } from '@/utils/DateUtils'; import UniqueIdentifier from '@/utils/UniqueIdentifier'; @@ -16,8 +17,7 @@ test.describe('Download documents from inbound send page', () => { test.beforeEach( async ({ productService, mainUserService, supplierLocationService }) => { - productService.setProduct('1'); - const PRODUCT_ONE = await productService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); 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 1e6141b..e6fea09 100644 --- a/src/tests/inbound/createInbound/editDestinationFromSendPage.test.ts +++ b/src/tests/inbound/createInbound/editDestinationFromSendPage.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; test.describe('Edit destination from send page', () => { @@ -13,10 +14,8 @@ test.describe('Edit destination from send page', () => { productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - productService.setProduct('2'); - const PRODUCT_TWO = await productService.getProduct(); - productService.setProduct('3') - const PRODUCT_THREE = await productService.getProduct(); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); + const PRODUCT_THREE = await productService.getProduct(Product.THREE); 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 231ea80..96821b0 100644 --- a/src/tests/inbound/createInbound/expectedDeliveryDate.test.ts +++ b/src/tests/inbound/createInbound/expectedDeliveryDate.test.ts @@ -1,4 +1,5 @@ import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse, User } from '@/types'; import { formatDate, getDateByOffset } from '@/utils/DateUtils'; @@ -16,10 +17,8 @@ test.describe('Expected delivery date tests', () => { }) => { const supplierLocation = await supplierLocationService.getLocation(); USER = await mainUserService.getUser(); - productService.setProduct('3'); - const PRODUCT_THREE = await productService.getProduct(); - productService.setProduct('4'); - const PRODUCT_FOUR = await productService.getProduct(); + const PRODUCT_THREE = await productService.getProduct(Product.THREE); + const PRODUCT_FOUR = await productService.getProduct(Product.FOUR); 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 9cc7faf..f778a4d 100644 --- a/src/tests/inbound/createInbound/exportItems.test.ts +++ b/src/tests/inbound/createInbound/exportItems.test.ts @@ -1,4 +1,5 @@ import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { getDateByOffset, getToday } from '@/utils/DateUtils'; import { WorkbookUtils } from '@/utils/WorkbookUtils'; @@ -21,10 +22,8 @@ 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); 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 9f32fc6..ae4f669 100644 --- a/src/tests/inbound/createInbound/fieldValidation.test.ts +++ b/src/tests/inbound/createInbound/fieldValidation.test.ts @@ -1,4 +1,5 @@ import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { AddItemsTableRow, LocationResponse, User } from '@/types'; import { getDateByOffset, getToday } from '@/utils/DateUtils'; @@ -16,8 +17,7 @@ test.beforeEach( createInboundPage, supplierLocationService, }) => { - productService.setProduct('1'); - const PRODUCT_ONE = await productService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); 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 d5495a4..2919d17 100644 --- a/src/tests/inbound/createInbound/inboundStatusChanges.test.ts +++ b/src/tests/inbound/createInbound/inboundStatusChanges.test.ts @@ -1,4 +1,5 @@ import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import InboundListPage from '@/pages/inbound/list/InboundListPage'; import StockMovementShowPage from '@/pages/stockMovementShow/StockMovementShowPage'; import { AddItemsTableRow, LocationResponse, User } from '@/types'; @@ -17,15 +18,9 @@ test.describe('Status changes for inbound sm on view sm and inbound list page', const uniqueIdentifier = new UniqueIdentifier(); test.beforeEach( - async ({ - productService, - mainUserService, - supplierLocationService, - }) => { - productService.setProduct('1'); - const PRODUCT_ONE = await productService.getProduct(); - productService.setProduct('2'); - const PRODUCT_TWO = await productService.getProduct(); + async ({ productService, mainUserService, supplierLocationService }) => { + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); 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 59ebc85..1f87284 100644 --- a/src/tests/inbound/createInbound/itemTemplate.test.ts +++ b/src/tests/inbound/createInbound/itemTemplate.test.ts @@ -4,6 +4,7 @@ import _ from 'lodash'; import AppConfig from '@/config/AppConfig'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { CreateInboundAddItemsTableEntity, StockMovementResponse, @@ -86,10 +87,8 @@ 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); const USER = await mainUserService.getUser(); const ROWS = [ @@ -198,10 +197,8 @@ 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); const USER = await mainUserService.getUser(); const ROWS = [ @@ -273,8 +270,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 PRODUCT_ONE = await productService.getProduct(Product.ONE); const USER = await mainUserService.getUser(); const ROWS = [ @@ -309,8 +305,7 @@ test.describe('Import template with data', () => { parsedDocumentData = downloadedTemplateFile.sheetToJSON(); }); - productService.setProduct('2'); - const PRODUCT_TWO = await productService.getProduct(); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); const ALT_USER = await altUserService.getUser(); const NEW_ROW = { @@ -367,8 +362,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 PRODUCT_ONE = await productService.getProduct(Product.ONE); const USER = await mainUserService.getUser(); ROW = { @@ -400,8 +394,7 @@ test.describe('Import template with data', () => { parsedDocumentData = downloadedTemplateFile.sheetToJSON(); }); - productService.setProduct('2') - const PRODUCT_TWO = await productService.getProduct(); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); 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 9d454ef..865bc0c 100644 --- a/src/tests/inbound/createInbound/packLevels.test.ts +++ b/src/tests/inbound/createInbound/packLevels.test.ts @@ -1,4 +1,5 @@ import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { AddItemsTableRow } from '@/types'; import { getDateByOffset, getToday } from '@/utils/DateUtils'; @@ -13,8 +14,7 @@ test.beforeEach( createInboundPage, supplierLocationService, }) => { - productService.setProduct('1'); - const PRODUCT_ONE = await productService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); 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 b770aab..0e52b85 100644 --- a/src/tests/inbound/createInbound/saveAndExit.test.ts +++ b/src/tests/inbound/createInbound/saveAndExit.test.ts @@ -1,4 +1,5 @@ import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { AddItemsTableRow } from '@/types'; import { getDateByOffset, getToday } from '@/utils/DateUtils'; @@ -13,8 +14,7 @@ test.beforeEach( createInboundPage, supplierLocationService, }) => { - productService.setProduct('1'); - const PRODUCT_ONE = await productService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); 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 3d0cb23..d75f085 100644 --- a/src/tests/inbound/createInbound/selectPersonInRequestedBy.test.ts +++ b/src/tests/inbound/createInbound/selectPersonInRequestedBy.test.ts @@ -1,4 +1,6 @@ +import { PERSON_URL } from '@/consts/applicationUrls'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { AddItemsTableRow, LocationResponse } from '@/types'; import { formatDate, getDateByOffset, getToday } from '@/utils/DateUtils'; import UniqueIdentifier from '@/utils/UniqueIdentifier'; @@ -24,8 +26,7 @@ test.describe('Select person in requested by', () => { personsListPage, createPersonPage, }) => { - productService.setProduct('1'); - const PRODUCT_ONE = await productService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); ORIGIN = await supplierLocationService.getLocation(); ROWS = [ @@ -42,7 +43,7 @@ test.describe('Select person in requested by', () => { ]; await test.step('Create person', async () => { - await page.goto('./person/list'); + await page.goto(PERSON_URL.list()); await personsListPage.isLoaded(); await personsListPage.addPersonButton.click(); await createPersonPage.firstNameField.fill(personFirstName); @@ -63,7 +64,7 @@ test.describe('Select person in requested by', () => { }) => { await stockMovementShowPage.rollbackButton.click(); await stockMovementService.deleteStockMovement(INBOUND_ID); - await page.goto('./person/list'); + await page.goto(PERSON_URL.list()); await personsListPage.isLoaded(); await personsListPage.searchField.fill(personFirstName); await personsListPage.findButton.click(); diff --git a/src/tests/inbound/createInbound/switchLocations.test.ts b/src/tests/inbound/createInbound/switchLocations.test.ts index d5cab17..80402df 100644 --- a/src/tests/inbound/createInbound/switchLocations.test.ts +++ b/src/tests/inbound/createInbound/switchLocations.test.ts @@ -1,5 +1,6 @@ import AppConfig from '@/config/AppConfig'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { AddItemsTableRow } from '@/types'; import { getDateByOffset, getToday } from '@/utils/DateUtils'; @@ -15,8 +16,7 @@ test.describe('Switching location on inbound stock movement', () => { createInboundPage, supplierLocationService, }) => { - productService.setProduct('1'); - const PRODUCT_ONE = await productService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); 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 12b193b..e04ddb4 100644 --- a/src/tests/inbound/createInbound/tableShortcuts.test.ts +++ b/src/tests/inbound/createInbound/tableShortcuts.test.ts @@ -1,4 +1,5 @@ import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { AddItemsTableRow } from '@/types'; import { getDateByOffset, getToday } from '@/utils/DateUtils'; const TODAY = getToday(); @@ -12,8 +13,7 @@ test.beforeEach( createInboundPage, supplierLocationService, }) => { - productService.setProduct('1'); - const PRODUCT_ONE = await productService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); 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 efcaf31..81885b7 100644 --- a/src/tests/inbound/listPage/exportStockMovements.test.ts +++ b/src/tests/inbound/listPage/exportStockMovements.test.ts @@ -1,5 +1,6 @@ import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import { formatDate, getToday } from '@/utils/DateUtils'; import { WorkbookUtils } from '@/utils/WorkbookUtils'; @@ -17,10 +18,8 @@ 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); 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 6a4ec9d..caec7d9 100644 --- a/src/tests/inbound/listPage/myStockMovementFilter.test.ts +++ b/src/tests/inbound/listPage/myStockMovementFilter.test.ts @@ -1,5 +1,6 @@ import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse, User } from '@/types'; test.describe('My Stock Movement filter', () => { @@ -15,10 +16,8 @@ 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); 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 88a9936..3ea9b59 100644 --- a/src/tests/inbound/listPage/receiptStatusFilter.test.ts +++ b/src/tests/inbound/listPage/receiptStatusFilter.test.ts @@ -1,6 +1,7 @@ import { ReceiptStatus } from '@/constants/ReceiptStatus'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; test.describe('Filter by "Pending" status', () => { @@ -60,8 +61,7 @@ test.describe('Filter by "Shipped" status', () => { originId: supplierLocation.id, }); - productService.setProduct('1'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.ONE); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -126,8 +126,7 @@ test.describe('Filter by "Received" status', () => { originId: supplierLocation.id, }); - productService.setProduct('1'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.ONE); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -219,10 +218,8 @@ 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(); + const product = await productService.getProduct(Product.ONE); + const productTwo = await productService.getProduct(Product.TWO); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -320,8 +317,7 @@ test.describe('Filter by multiple statuses - "Pending" and "Shipped"', () => { originId: supplierLocation.id, }); - productService.setProduct('1'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.ONE); 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 b66e3bd..be4e6b3 100644 --- a/src/tests/inbound/listPage/shipmentTypeFilter.test.ts +++ b/src/tests/inbound/listPage/shipmentTypeFilter.test.ts @@ -1,5 +1,6 @@ import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; test.describe('Shipment type filter', () => { @@ -20,8 +21,7 @@ test.describe('Shipment type filter', () => { stockMovementService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - productService.setProduct('1'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.ONE); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -112,8 +112,7 @@ test.describe('Multiple shipment types', () => { stockMovementService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - productService.setProduct('1'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.ONE); 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 1ac21e5..5202911 100644 --- a/src/tests/inbound/listPage/updatedByFilter.test.ts +++ b/src/tests/inbound/listPage/updatedByFilter.test.ts @@ -1,5 +1,6 @@ import StockMovementService from '@/api/StockMovementService'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse, User } from '@/types'; test.describe('Use "Updated By" filter', () => { @@ -34,8 +35,7 @@ test.describe('Use "Updated By" filter', () => { inboundListPage, productService, }) => { - productService.setProduct('1'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.ONE); await test.step('Go to inbound list page', async () => { await inboundListPage.goToPage(); diff --git a/src/tests/locationChooser/depotInLocationChooser.test.ts b/src/tests/locationChooser/depotInLocationChooser.test.ts index 3d9bd25..0b8db03 100644 --- a/src/tests/locationChooser/depotInLocationChooser.test.ts +++ b/src/tests/locationChooser/depotInLocationChooser.test.ts @@ -1,6 +1,7 @@ import LocationChooser from '@/components/LocationChooser'; import Navbar from '@/components/Navbar'; import AppConfig, { LOCATION_KEY } from '@/config/AppConfig'; +import { DASHBOARD_URL } from '@/consts/applicationUrls'; import { expect, test } from '@/fixtures/fixtures'; import CreateLocationPage from '@/pages/location/createLocation/CreateLocationPage'; import LocationListPage from '@/pages/location/LocationListPage'; @@ -102,7 +103,7 @@ test.describe('Check if depot location is present in location chooser', () => { const editLocationGroupPage = new EditLocationGroupPage(page); await test.step('Delete created location', async () => { - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await navbar.configurationButton.click(); await navbar.locations.click(); await locationListPage.searchByLocationNameField.fill(LOCATION_NAME); @@ -157,7 +158,7 @@ test.describe('Check if depot location is present in location chooser', () => { navbar, locationChooser, }) => { - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await navbar.locationChooserButton.click(); await expect( locationChooser.getOrganization(ORGANIZATION_NAME) @@ -174,7 +175,7 @@ test.describe('Check if depot location is present in location chooser', () => { navbar, locationChooser, }) => { - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await navbar.dashboard.click(); await navbar.locationChooserButton.click(); await expect( @@ -292,7 +293,7 @@ test.describe('Check if location is present in location chooser after editing', const createLocationPage = new CreateLocationPage(page); const editOrganizationPage = new EditOrganizationPage(page); - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await test.step('Delete created location', async () => { await navbar.configurationButton.click(); @@ -358,7 +359,7 @@ test.describe('Check if location is present in location chooser after editing', navbar, locationChooser, }) => { - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await navbar.locationChooserButton.click(); await expect( @@ -380,7 +381,7 @@ test.describe('Check if location is present in location chooser after editing', const locationListPage = new LocationListPage(page); const createLocationPage = new CreateLocationPage(page); - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await navbar.configurationButton.click(); await navbar.locations.click(); @@ -400,7 +401,7 @@ test.describe('Check if location is present in location chooser after editing', navbar, locationChooser, }) => { - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await navbar.locationChooserButton.click(); await expect( @@ -422,7 +423,7 @@ test.describe('Check if location is present in location chooser after editing', navbar, locationChooser, }) => { - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await navbar.dashboard.click(); await navbar.locationChooserButton.click(); @@ -486,7 +487,7 @@ test.describe('Check if non manage inventory location is present in location cho const createLocationPage = new CreateLocationPage(page); location = await mainLocation.getLocation(); - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await test.step('Go to create location page', async () => { await navbar.configurationButton.click(); @@ -524,7 +525,7 @@ test.describe('Check if non manage inventory location is present in location cho const locationListPage = new LocationListPage(page); const createLocationPage = new CreateLocationPage(page); - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await test.step('Delete created location', async () => { await navbar.configurationButton.click(); @@ -551,7 +552,7 @@ test.describe('Check if non manage inventory location is present in location cho navbar, locationChooser, }) => { - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await navbar.locationChooserButton.click(); await expect( @@ -569,7 +570,7 @@ test.describe('Check if non manage inventory location is present in location cho navbar, locationChooser, }) => { - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await navbar.dashboard.click(); await navbar.locationChooserButton.click(); diff --git a/src/tests/locationChooser/locationInLocationChooserBasedOnUserPermissions.test.ts b/src/tests/locationChooser/locationInLocationChooserBasedOnUserPermissions.test.ts index 3afebdb..cb62772 100644 --- a/src/tests/locationChooser/locationInLocationChooserBasedOnUserPermissions.test.ts +++ b/src/tests/locationChooser/locationInLocationChooserBasedOnUserPermissions.test.ts @@ -4,6 +4,7 @@ import Navbar from '@/components/Navbar'; import AppConfig from '@/config/AppConfig'; import { ActivityCode } from '@/constants/ActivityCodes'; import { LocationTypeCode } from '@/constants/LocationTypeCode'; +import { DASHBOARD_URL } from '@/consts/applicationUrls'; import { expect, test } from '@/fixtures/fixtures'; import LoginPage from '@/pages/LoginPage'; import { CreateUserType } from '@/types'; @@ -33,7 +34,7 @@ test.describe('Check if ward location is present in location chooser based on us password: 'testpassword123', }; - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await test.step('Go to create location page', async () => { await navbar.configurationButton.click(); @@ -56,7 +57,7 @@ test.describe('Check if ward location is present in location chooser based on us }); await test.step('Go to create user page', async () => { - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await navbar.configurationButton.click(); await navbar.users.click(); await userListPage.createUserButton.click(); @@ -98,7 +99,7 @@ test.describe('Check if ward location is present in location chooser based on us userListPage, editUserPage, }) => { - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await test.step('Go to edit user page', async () => { await userListPage.goToPage(); await userListPage.searchByNameField.fill(TEST_USER.username); @@ -204,7 +205,7 @@ test.describe('Check if ward location is present in location chooser based on us }); await test.step('Assert created ward on location chooser, react, admin', async () => { - await newUserPage.goto('./dashboard'); + await newUserPage.goto(DASHBOARD_URL.base); await newPageNavbar.dashboard.click(); await newPageNavbar.locationChooserButton.click(); await expect( @@ -288,7 +289,7 @@ test.describe('Check if ward location is present in location chooser based on us }); await test.step('Assert created ward on location chooser, react, manager', async () => { - await newUserPage.goto('./dashboard'); + await newUserPage.goto(DASHBOARD_URL.base); await newPageNavbar.dashboard.click(); await newPageNavbar.locationChooserButton.click(); await expect( @@ -372,7 +373,7 @@ test.describe('Check if ward location is present in location chooser based on us }); await test.step('Assert created ward on location chooser, react, browser', async () => { - await newUserPage.goto('./dashboard'); + await newUserPage.goto(DASHBOARD_URL.base); await newPageNavbar.dashboard.click(); await newPageNavbar.locationChooserButton.click(); await expect( @@ -427,7 +428,7 @@ test.describe('Check if ward location is present in location chooser based on us password: 'testpassword123', }; - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await test.step('Go to create location page', async () => { await navbar.configurationButton.click(); @@ -457,7 +458,7 @@ test.describe('Check if ward location is present in location chooser based on us }); await test.step('Go to create user page', async () => { - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await navbar.configurationButton.click(); await navbar.users.click(); await userListPage.createUserButton.click(); @@ -493,7 +494,7 @@ test.describe('Check if ward location is present in location chooser based on us userListPage, editUserPage, }) => { - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await test.step('Go to edit user page', async () => { await userListPage.goToPage(); await userListPage.searchByNameField.fill(TEST_USER.username); @@ -592,7 +593,7 @@ test.describe('Check if ward location is present in location chooser based on us }); await test.step('Assert created ward on location chooser, react, admin', async () => { - await newUserPage.goto('./dashboard'); + await newUserPage.goto(DASHBOARD_URL.base); await newPageNavbar.dashboard.click(); await newPageNavbar.locationChooserButton.click(); await expect( @@ -676,7 +677,7 @@ test.describe('Check if ward location is present in location chooser based on us }); await test.step('Assert created ward on location chooser, react, manager', async () => { - await newUserPage.goto('./dashboard'); + await newUserPage.goto(DASHBOARD_URL.base); await newPageNavbar.dashboard.click(); await newPageNavbar.locationChooserButton.click(); await expect( @@ -735,7 +736,7 @@ test.describe('Check if ward location is present in location chooser based on us LOCATION_NAME = uniqueIdentifier.generateUniqueString('Test-Ward'); - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await test.step('Go to create location page', async () => { await navbar.configurationButton.click(); @@ -765,7 +766,7 @@ test.describe('Check if ward location is present in location chooser based on us }); await test.step('Go to create user page', async () => { - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await navbar.configurationButton.click(); await navbar.users.click(); await userListPage.createUserButton.click(); @@ -807,7 +808,7 @@ test.describe('Check if ward location is present in location chooser based on us userListPage, editUserPage, }) => { - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await test.step('Go to edit user page', async () => { await userListPage.goToPage(); await userListPage.searchByNameField.fill(TEST_USER.username); @@ -883,7 +884,7 @@ test.describe('Check if ward location is present in location chooser based on us const newPageLocationChooser = new LocationChooser(newPage); await test.step('Assert created ward on location chooser in impersonate mode, react', async () => { - await newPage.goto('./dashboard'); + await newPage.goto(DASHBOARD_URL.base); await newPageNavbar.dashboard.click(); await newPageNavbar.locationChooserButton.click(); await expect( diff --git a/src/tests/locationChooser/wardInLocationChooser.test.ts b/src/tests/locationChooser/wardInLocationChooser.test.ts index b41e969..59211b7 100644 --- a/src/tests/locationChooser/wardInLocationChooser.test.ts +++ b/src/tests/locationChooser/wardInLocationChooser.test.ts @@ -1,6 +1,7 @@ import LocationChooser from '@/components/LocationChooser'; import Navbar from '@/components/Navbar'; import AppConfig from '@/config/AppConfig'; +import { DASHBOARD_URL } from '@/consts/applicationUrls'; import { expect, test } from '@/fixtures/fixtures'; import CreateLocationPage from '@/pages/location/createLocation/CreateLocationPage'; import LocationListPage from '@/pages/location/LocationListPage'; @@ -20,7 +21,7 @@ test.describe('Check if ward location is present in location chooser', () => { const locationListPage = new LocationListPage(page); const createLocationPage = new CreateLocationPage(page); - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await test.step('Go to create location page', async () => { await navbar.configurationButton.click(); @@ -76,7 +77,7 @@ test.describe('Check if ward location is present in location chooser', () => { const locationListPage = new LocationListPage(page); const createLocationPage = new CreateLocationPage(page); - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await test.step('Remove location role from user', async () => { await navbar.profileButton.click(); await navbar.editProfileButton.click(); @@ -115,7 +116,7 @@ test.describe('Check if ward location is present in location chooser', () => { navbar, locationChooser, }) => { - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await navbar.locationChooserButton.click(); await expect( locationChooser.getOrganization('No organization') @@ -133,7 +134,7 @@ test.describe('Check if ward location is present in location chooser', () => { navbar, locationChooser, }) => { - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await navbar.dashboard.click(); await navbar.locationChooserButton.click(); await expect( diff --git a/src/tests/putaway/assertAttemptToEditCompletedPutaway.test.ts b/src/tests/putaway/assertAttemptToEditCompletedPutaway.test.ts index ecd3e33..053673e 100644 --- a/src/tests/putaway/assertAttemptToEditCompletedPutaway.test.ts +++ b/src/tests/putaway/assertAttemptToEditCompletedPutaway.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; import { @@ -24,8 +25,7 @@ test.describe('Assert attempt to edit completed putaway', () => { originId: supplierLocation.id, }); - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, diff --git a/src/tests/putaway/assertPutawayDetailsPage.test.ts b/src/tests/putaway/assertPutawayDetailsPage.test.ts index bc00713..0c1c015 100644 --- a/src/tests/putaway/assertPutawayDetailsPage.test.ts +++ b/src/tests/putaway/assertPutawayDetailsPage.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; import { @@ -24,8 +25,7 @@ test.describe('Assert putaway details page', () => { originId: supplierLocation.id, }); - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, diff --git a/src/tests/putaway/assertPutawayInMenu.test.ts b/src/tests/putaway/assertPutawayInMenu.test.ts index 9267b2d..1934bd9 100644 --- a/src/tests/putaway/assertPutawayInMenu.test.ts +++ b/src/tests/putaway/assertPutawayInMenu.test.ts @@ -1,4 +1,5 @@ import AppConfig from '@/config/AppConfig'; +import { DASHBOARD_URL } from '@/consts/applicationUrls'; import { expect, test } from '@/fixtures/fixtures'; test.describe('Assert Putaway exist in menu', () => { @@ -11,7 +12,7 @@ test.describe('Assert Putaway exist in menu', () => { await authService.changeLocation( AppConfig.instance.locations.noPickAndPutawayStockDepot.id ); - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); }); await test.step('Assert content of inbound menu in location with pick and putaway stock', async () => { @@ -43,7 +44,7 @@ test.describe('Assert Putaway exist in menu', () => { }) => { await test.step('Open dashboard', async () => { await authService.changeLocation(AppConfig.instance.locations.main.id); - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); }); await test.step('Assert content of inbound menu in location with pick and putaway stock', async () => { diff --git a/src/tests/putaway/assertReceivingBinsOnCreatePutawayPage.test.ts b/src/tests/putaway/assertReceivingBinsOnCreatePutawayPage.test.ts index d79ea4c..2291011 100644 --- a/src/tests/putaway/assertReceivingBinsOnCreatePutawayPage.test.ts +++ b/src/tests/putaway/assertReceivingBinsOnCreatePutawayPage.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import { formatDate, getDateByOffset } from '@/utils/DateUtils'; import RefreshCachesUtils from '@/utils/RefreshCaches'; @@ -31,8 +32,7 @@ test.describe('Assert receiving bin on create putaway page', () => { originId: supplierLocation.id, }); - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); await stockMovementService.addItemsToInboundStockMovement( PRIMARY_STOCK_MOVEMENT.id, @@ -82,8 +82,7 @@ test.describe('Assert receiving bin on create putaway page', () => { originId: supplierLocation.id, }); - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); await stockMovementService.addItemsToInboundStockMovement( SECONDARY_STOCK_MOVEMENT.id, @@ -168,8 +167,7 @@ test.describe('Assert receiving bin on create putaway page', () => { const receivingBin2 = AppConfig.instance.receivingBinPrefix + SECONDARY_STOCK_MOVEMENT.identifier; - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); const expDate = getDateByOffset(new Date(), 3); const currentLocation = await mainLocationService.getLocation(); const internalLocation = await internalLocationService.getLocation(); diff --git a/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts b/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts index 0ba04a5..76d127b 100644 --- a/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts +++ b/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; import { @@ -24,8 +25,7 @@ test.describe('Change location on putaway create page and list pages', () => { originId: supplierLocation.id, }); - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -90,8 +90,7 @@ test.describe('Change location on putaway create page and list pages', () => { }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); const mainLocation = await mainLocationService.getLocation(); const depotLocation = await depotLocationService.getLocation(); diff --git a/src/tests/putaway/createMoreThan1PutawayForTheSameItem.test.ts b/src/tests/putaway/createMoreThan1PutawayForTheSameItem.test.ts index 7ffe9bc..5c12687 100644 --- a/src/tests/putaway/createMoreThan1PutawayForTheSameItem.test.ts +++ b/src/tests/putaway/createMoreThan1PutawayForTheSameItem.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; import { @@ -24,8 +25,7 @@ test.describe('Create more than 1 putaway from the same item', () => { originId: supplierLocation.id, }); - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -91,8 +91,7 @@ test.describe('Create more than 1 putaway from the same item', () => { putawayDetailsPage, productService, }) => { - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); const internalLocation = await internalLocationService.getLocation(); const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; diff --git a/src/tests/putaway/createPutaway.test.ts b/src/tests/putaway/createPutaway.test.ts index 4314677..97c1218 100644 --- a/src/tests/putaway/createPutaway.test.ts +++ b/src/tests/putaway/createPutaway.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; import { @@ -24,8 +25,7 @@ test.describe('Putaway received inbound shipment', () => { originId: supplierLocation.id, }); - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -134,8 +134,7 @@ test.describe('Putaway received inbound shipment', () => { await test.step('Assert putaway bin on stock card', async () => { await putawayDetailsPage.summaryTab.click(); - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); await productShowPage.goToPage(product.id); await productShowPage.inStockTab.click(); await productShowPage.inStockTabSection.isLoaded(); diff --git a/src/tests/putaway/deleteItemsFromPutaway.test.ts b/src/tests/putaway/deleteItemsFromPutaway.test.ts index b40e0d7..9f9fa23 100644 --- a/src/tests/putaway/deleteItemsFromPutaway.test.ts +++ b/src/tests/putaway/deleteItemsFromPutaway.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; import { @@ -24,10 +25,8 @@ test.describe('Delete items from putaway', () => { originId: supplierLocation.id, }); - productService.setProduct('5'); - const product = await productService.getProduct(); - productService.setProduct('4'); - const product2 = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); + const product2 = await productService.getProduct(Product.FOUR); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -99,10 +98,8 @@ test.describe('Delete items from putaway', () => { }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - productService.setProduct('5'); - const product = await productService.getProduct(); - productService.setProduct('4'); - const product2 = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); + const product2 = await productService.getProduct(Product.FOUR); const internalLocation = await internalLocationService.getLocation(); await test.step('Go to create putaway page', async () => { diff --git a/src/tests/putaway/deletePendingPutaway.test.ts b/src/tests/putaway/deletePendingPutaway.test.ts index d77382b..5f89ee3 100644 --- a/src/tests/putaway/deletePendingPutaway.test.ts +++ b/src/tests/putaway/deletePendingPutaway.test.ts @@ -2,6 +2,7 @@ import Navbar from '@/components/Navbar'; import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import CreatePutawayPage from '@/pages/putaway/CreatePutawayPage'; import PutawayListPage from '@/pages/putaway/list/PutawayListPage'; import PutawayDetailsPage from '@/pages/putaway/putawayDetails/PutawayDetailsPage'; @@ -29,8 +30,7 @@ test.describe('Delete pending putaways', () => { originId: supplierLocation.id, }); - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -86,8 +86,7 @@ test.describe('Delete pending putaways', () => { }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); await test.step('Go to create putaway page', async () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); @@ -138,8 +137,7 @@ test.describe('Delete pending putaways', () => { }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); await test.step('Go to create putaway page', async () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); @@ -192,8 +190,7 @@ test.describe('Delete pending putaways', () => { }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); const managerUserPage = await managerUserContext.newPage(); const navbar = new Navbar(managerUserPage); @@ -248,8 +245,7 @@ test.describe('Delete pending putaways', () => { }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); const managerUserPage = await managerUserContext.newPage(); const navbar = new Navbar(managerUserPage); @@ -312,8 +308,7 @@ test.describe('Delete pending putaways', () => { }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); const adminUserPage = await altUserContext.newPage(); const navbar = new Navbar(adminUserPage); @@ -368,8 +363,7 @@ test.describe('Delete pending putaways', () => { }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); const adminUserPage = await altUserContext.newPage(); const navbar = new Navbar(adminUserPage); @@ -432,8 +426,7 @@ test.describe('Delete pending putaways', () => { }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); const assistantUserPage = await assistantUserContext.newPage(); const navbar = new Navbar(assistantUserPage); @@ -488,8 +481,7 @@ test.describe('Delete pending putaways', () => { }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); const assistantUserPage = await assistantUserContext.newPage(); const navbar = new Navbar(assistantUserPage); diff --git a/src/tests/putaway/performPutawayAsManagerUser.test.ts b/src/tests/putaway/performPutawayAsManagerUser.test.ts index 12a6f49..35d0a6d 100644 --- a/src/tests/putaway/performPutawayAsManagerUser.test.ts +++ b/src/tests/putaway/performPutawayAsManagerUser.test.ts @@ -2,6 +2,7 @@ import Navbar from '@/components/Navbar'; import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import CreatePutawayPage from '@/pages/putaway/CreatePutawayPage'; import PutawayDetailsPage from '@/pages/putaway/putawayDetails/PutawayDetailsPage'; import StockMovementShowPage from '@/pages/stockMovementShow/StockMovementShowPage'; @@ -28,10 +29,8 @@ test.describe('Perform putaway as manager user', () => { originId: supplierLocation.id, }); - productService.setProduct('3'); - const product = await productService.getProduct(); - productService.setProduct('4'); - const product2 = await productService.getProduct(); + const product = await productService.getProduct(Product.THREE); + const product2 = await productService.getProduct(Product.FOUR); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -99,10 +98,8 @@ test.describe('Perform putaway as manager user', () => { }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - productService.setProduct('3'); - const product = await productService.getProduct(); - productService.setProduct('4'); - const product2 = await productService.getProduct(); + const product = await productService.getProduct(Product.THREE); + const product2 = await productService.getProduct(Product.FOUR); const internalLocation = await internalLocationService.getLocation(); const managerUserPage = await managerUserContext.newPage(); diff --git a/src/tests/putaway/putawayImtemWithEmptyLot.test.ts b/src/tests/putaway/putawayImtemWithEmptyLot.test.ts index c720ee1..5f8dd07 100644 --- a/src/tests/putaway/putawayImtemWithEmptyLot.test.ts +++ b/src/tests/putaway/putawayImtemWithEmptyLot.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; import { @@ -24,8 +25,7 @@ test.describe('Putaway item with empty lot', () => { originId: supplierLocation.id, }); - productService.setProduct('5'); - const product2 = await productService.getProduct(); + const product2 = await productService.getProduct(Product.FIVE); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -94,10 +94,8 @@ test.describe('Putaway item with empty lot', () => { AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; const currentLocation = await mainLocationService.getLocation(); const internalLocation = await internalLocationService.getLocation(); - productService.setProduct('6'); - const product = await productService.getProduct(); - productService.setProduct('5'); - const product2 = await productService.getProduct(); + const product = await productService.getProduct(Product.SIX); + const product2 = await productService.getProduct(Product.FIVE); await test.step('Go to stockcard', async () => { await productShowPage.goToPage(product.id); diff --git a/src/tests/putaway/putawayMoreThan1Item.test.ts b/src/tests/putaway/putawayMoreThan1Item.test.ts index 67bf3cc..eb79bee 100644 --- a/src/tests/putaway/putawayMoreThan1Item.test.ts +++ b/src/tests/putaway/putawayMoreThan1Item.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; import { @@ -24,10 +25,8 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { originId: supplierLocation.id, }); - productService.setProduct('5'); - const product = await productService.getProduct(); - productService.setProduct('4'); - const product2 = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); + const product2 = await productService.getProduct(Product.FOUR); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -100,10 +99,8 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - productService.setProduct('5'); - const product = await productService.getProduct(); - productService.setProduct('4'); - const product2 = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); + const product2 = await productService.getProduct(Product.FOUR); const internalLocation = await internalLocationService.getLocation(); await test.step('Go to create putaway page', async () => { @@ -261,10 +258,8 @@ test.describe('Putaway 2 items in the same putaway', () => { originId: supplierLocation.id, }); - productService.setProduct('5'); - const product = await productService.getProduct(); - productService.setProduct('4'); - const product2 = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); + const product2 = await productService.getProduct(Product.FOUR); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -336,10 +331,8 @@ test.describe('Putaway 2 items in the same putaway', () => { }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - productService.setProduct('5'); - const product = await productService.getProduct(); - productService.setProduct('4'); - const product2 = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); + const product2 = await productService.getProduct(Product.FOUR); const internalLocation = await internalLocationService.getLocation(); await test.step('Go to create putaway page', async () => { diff --git a/src/tests/putaway/putawayToHoldBin.test.ts b/src/tests/putaway/putawayToHoldBin.test.ts index ac7f418..993cde4 100644 --- a/src/tests/putaway/putawayToHoldBin.test.ts +++ b/src/tests/putaway/putawayToHoldBin.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; import RefreshCachesUtils from '@/utils/RefreshCaches'; @@ -30,8 +31,7 @@ test.describe('Putaway item into hold bin', () => { createLocationPage, }) => { const supplierLocation = await supplierLocationService.getLocation(); - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -176,8 +176,7 @@ test.describe('Putaway item into hold bin', () => { await test.step('Assert putaway bin on stock card', async () => { await putawayDetailsPage.summaryTab.click(); - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); await productShowPage.goToPage(product.id); await productShowPage.inStockTab.click(); await productShowPage.inStockTabSection.isLoaded(); diff --git a/src/tests/putaway/putawayToPreferredBin.test.ts b/src/tests/putaway/putawayToPreferredBin.test.ts index 6d79054..49429ec 100644 --- a/src/tests/putaway/putawayToPreferredBin.test.ts +++ b/src/tests/putaway/putawayToPreferredBin.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; import { @@ -27,10 +28,8 @@ test.describe('Putaway to preferred bin and default bin', () => { originId: supplierLocation.id, }); - productService.setProduct('5'); - const product = await productService.getProduct(); - productService.setProduct('4'); - const product2 = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); + const product2 = await productService.getProduct(Product.FOUR); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -102,8 +101,7 @@ test.describe('Putaway to preferred bin and default bin', () => { stockMovementService, STOCK_MOVEMENT, }); - productService.setProduct('4'); - const product2 = await productService.getProduct(); + const product2 = await productService.getProduct(Product.FOUR); await productShowPage.goToPage(product2.id); await productShowPage.editProductkButton.click(); await productEditPage.inventoryLevelsTab.click(); @@ -128,10 +126,8 @@ test.describe('Putaway to preferred bin and default bin', () => { }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - productService.setProduct('5'); - const product = await productService.getProduct(); - productService.setProduct('4'); - const product2 = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); + const product2 = await productService.getProduct(Product.FOUR); const internalLocation = await internalLocationService.getLocation(); await test.step('Go to create putaway page', async () => { @@ -228,8 +224,7 @@ test.describe('Putaway to preferred bin and default bin', () => { }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - productService.setProduct('4'); - const product2 = await productService.getProduct(); + const product2 = await productService.getProduct(Product.FOUR); const internalLocation = await internalLocationService.getLocation(); const internalLocation2 = await internalLocation2Service.getLocation(); diff --git a/src/tests/putaway/qtyValidationsInPutaways.test.ts b/src/tests/putaway/qtyValidationsInPutaways.test.ts index 3818f56..916a4ad 100644 --- a/src/tests/putaway/qtyValidationsInPutaways.test.ts +++ b/src/tests/putaway/qtyValidationsInPutaways.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; import { @@ -24,8 +25,7 @@ test.describe('Assert qty validations in putaways', () => { originId: supplierLocation.id, }); - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, diff --git a/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts b/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts index a0a1208..d6b205d 100644 --- a/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts +++ b/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; import { @@ -24,8 +25,7 @@ test.describe('Rollback last receipt behavior when putaway created', () => { originId: supplierLocation.id, }); - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, diff --git a/src/tests/putaway/splitLineInPutaway.test.ts b/src/tests/putaway/splitLineInPutaway.test.ts index 37d7ea5..cb2bf28 100644 --- a/src/tests/putaway/splitLineInPutaway.test.ts +++ b/src/tests/putaway/splitLineInPutaway.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; import { @@ -24,8 +25,7 @@ test.describe('Split line in Putaway', () => { originId: supplierLocation.id, }); - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -182,8 +182,7 @@ test.describe('Split line in Putaway', () => { await test.step('Assert putaway bin on stock card', async () => { await putawayDetailsPage.summaryTab.click(); - productService.setProduct('5'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); await productShowPage.goToPage(product.id); await productShowPage.inStockTab.click(); await productShowPage.inStockTabSection.isLoaded(); diff --git a/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts b/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts index ab7660f..ac43efc 100644 --- a/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts +++ b/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts @@ -1,7 +1,9 @@ import Navbar from '@/components/Navbar'; import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; +import { DASHBOARD_URL } from '@/consts/applicationUrls'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import ProductShowPage from '@/pages/product/productShow/ProductShowPage'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; @@ -26,10 +28,8 @@ test.describe('Assert validation on qty removed from receiving bin', () => { originId: supplierLocation.id, }); - productService.setProduct('5'); - const product = await productService.getProduct(); - productService.setProduct('4'); - const product2 = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); + const product2 = await productService.getProduct(Product.FOUR); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -106,14 +106,12 @@ test.describe('Assert validation on qty removed from receiving bin', () => { }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - productService.setProduct('5'); - const product = await productService.getProduct(); - productService.setProduct('4'); - const product2 = await productService.getProduct(); + const product = await productService.getProduct(Product.FIVE); + const product2 = await productService.getProduct(Product.FOUR); const internalLocation = await internalLocationService.getLocation(); await test.step('Edit transaction date of transfer in', async () => { - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await navbar.configurationButton.click(); await navbar.transactions.click(); // eslint-disable-next-line playwright/no-networkidle diff --git a/src/tests/receiving/assertBinLocationField.test.ts b/src/tests/receiving/assertBinLocationField.test.ts index 759e4e3..a2ee763 100644 --- a/src/tests/receiving/assertBinLocationField.test.ts +++ b/src/tests/receiving/assertBinLocationField.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; @@ -14,8 +15,7 @@ test.describe('Assert bin location not clearable', () => { productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - productService.setProduct('4'); - const PRODUCT_FOUR = await productService.getProduct(); + const PRODUCT_FOUR = await productService.getProduct(Product.FOUR); 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 cb07756..b6b685a 100644 --- a/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts +++ b/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; @@ -14,10 +15,8 @@ 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_THREE = await productService.getProduct(Product.THREE); 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 2bf61b4..79aadcd 100644 --- a/src/tests/receiving/assertCreationOfReceivingBin.test.ts +++ b/src/tests/receiving/assertCreationOfReceivingBin.test.ts @@ -1,6 +1,8 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; +import { LOCATION_URL } from '@/consts/applicationUrls'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import CreateLocationPage from '@/pages/location/createLocation/CreateLocationPage'; import LocationListPage from '@/pages/location/LocationListPage'; import { StockMovementResponse } from '@/types'; @@ -18,10 +20,8 @@ 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -86,7 +86,7 @@ test.describe('Assert creation of receiving bin', () => { await test.step('Go to Bin location tab of edit location page', async () => { const mainLocation = await mainLocationService.getLocation(); - await page.goto('./location/list'); + await page.goto(LOCATION_URL.list()); await locationListPage.searchByLocationNameField.fill(mainLocation.name); await locationListPage.findButton.click(); await expect( @@ -125,7 +125,7 @@ test.describe('Assert creation of receiving bin', () => { const newLocationListPage = new LocationListPage(newPage); const newCreateLocationPage = new CreateLocationPage(newPage); const mainLocation = await mainLocationService.getLocation(); - await newPage.goto('./location/list'); + await newPage.goto(LOCATION_URL.list()); await newLocationListPage.searchByLocationNameField.fill( mainLocation.name ); diff --git a/src/tests/receiving/assertQtyInputs.test.ts b/src/tests/receiving/assertQtyInputs.test.ts index 4c4e2d5..8b9af2e 100644 --- a/src/tests/receiving/assertQtyInputs.test.ts +++ b/src/tests/receiving/assertQtyInputs.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; import { formatDate, getDateByOffset } from '@/utils/DateUtils'; @@ -15,12 +16,9 @@ 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(); - productService.setProduct('3'); - const PRODUCT_THREE = await productService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); + const PRODUCT_THREE = await productService.getProduct(Product.THREE); 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 1346561..a113c37 100644 --- a/src/tests/receiving/assertRecipientField.test.ts +++ b/src/tests/receiving/assertRecipientField.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; @@ -15,10 +16,8 @@ test.describe('Assert recipient field when receive', () => { mainUserService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - productService.setProduct('4'); - const PRODUCT_FOUR = await productService.getProduct(); - productService.setProduct('5'); - const PRODUCT_FIVE = await productService.getProduct(); + const PRODUCT_FOUR = await productService.getProduct(Product.FOUR); + const PRODUCT_FIVE = await productService.getProduct(Product.FIVE); 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 7e3e3e3..6e3f149 100644 --- a/src/tests/receiving/cancelRemainingQty.test.ts +++ b/src/tests/receiving/cancelRemainingQty.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; @@ -14,10 +15,8 @@ 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); 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 870f92b..bc55bea 100644 --- a/src/tests/receiving/editBinLocationWhenReceive.test.ts +++ b/src/tests/receiving/editBinLocationWhenReceive.test.ts @@ -1,6 +1,8 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; +import { LOCATION_URL } from '@/consts/applicationUrls'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; import UniqueIdentifier from '@/utils/UniqueIdentifier'; @@ -24,10 +26,8 @@ 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -46,7 +46,7 @@ test.describe('Edit Bin Location when receive inbound stock movement', () => { }); await test.step('Create bin location for location', async () => { - await page.goto('./location/list'); + await page.goto(LOCATION_URL.list()); await locationListPage.searchByLocationNameField.fill( mainLocation.name ); @@ -81,7 +81,9 @@ test.describe('Edit Bin Location when receive inbound stock movement', () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); const hasRollbackLastReceipt = - await stockMovementShowPage.rollbackLastReceiptButton.isVisible().catch(() => false); + await stockMovementShowPage.rollbackLastReceiptButton + .isVisible() + .catch(() => false); if (hasRollbackLastReceipt) { await stockMovementShowPage.rollbackLastReceiptButton.click(); @@ -91,7 +93,7 @@ test.describe('Edit Bin Location when receive inbound stock movement', () => { await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); await test.step('Deactivate created bin location', async () => { - await page.goto('./location/list'); + await page.goto(LOCATION_URL.list()); await locationListPage.searchByLocationNameField.fill( mainLocation.name ); @@ -200,10 +202,8 @@ 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -222,7 +222,7 @@ test.describe('Edit Bin Location to bin with zone when receive inbound stock mov }); await test.step('Create zone for location', async () => { - await page.goto('./location/list'); + await page.goto(LOCATION_URL.list()); await locationListPage.searchByLocationNameField.fill( mainLocation.name ); @@ -285,7 +285,7 @@ test.describe('Edit Bin Location to bin with zone when receive inbound stock mov await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); await test.step('Deactivate created bin location', async () => { - await page.goto('./location/list'); + await page.goto(LOCATION_URL.list()); await locationListPage.searchByLocationNameField.fill( mainLocation.name ); @@ -420,10 +420,8 @@ 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -442,7 +440,7 @@ test.describe('Edit Bin Location when receive for all lines', () => { }); await test.step('Create bin location for location', async () => { - await page.goto('./location/list'); + await page.goto(LOCATION_URL.list()); await locationListPage.searchByLocationNameField.fill( mainLocation.name ); @@ -480,7 +478,7 @@ test.describe('Edit Bin Location when receive for all lines', () => { await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); await test.step('Deactivate created bin location', async () => { - await page.goto('./location/list'); + await page.goto(LOCATION_URL.list()); await locationListPage.searchByLocationNameField.fill( mainLocation.name ); diff --git a/src/tests/receiving/editOriginalLineQtyTo0.test.ts b/src/tests/receiving/editOriginalLineQtyTo0.test.ts index 57503d8..72e0ba1 100644 --- a/src/tests/receiving/editOriginalLineQtyTo0.test.ts +++ b/src/tests/receiving/editOriginalLineQtyTo0.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; import { getDateByOffset } from '@/utils/DateUtils'; @@ -18,16 +19,11 @@ 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(); - 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); + const PRODUCT_THREE = await productService.getProduct(Product.THREE); + const PRODUCT_FOUR = await productService.getProduct(Product.FOUR); + const PRODUCT_FIVE = await productService.getProduct(Product.FIVE); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -243,8 +239,7 @@ test.describe('Edit original line to other product in the middle of receipt', () productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - productService.setProduct('4'); - const PRODUCT_FOUR = await productService.getProduct(); + const PRODUCT_FOUR = await productService.getProduct(Product.FOUR); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -313,8 +308,7 @@ test.describe('Edit original line to other product in the middle of receipt', () }); await test.step('Open edit modal for item', async () => { - productService.setProduct('5'); - const PRODUCT_FIVE = await productService.getProduct(); + const PRODUCT_FIVE = await productService.getProduct(Product.FIVE); await receivingPage.receivingStep.table.row(1).editButton.click(); await receivingPage.receivingStep.editModal.isLoaded(); await receivingPage.receivingStep.editModal.addLineButton.click(); @@ -335,10 +329,8 @@ test.describe('Edit original line to other product in the middle of receipt', () }); await test.step('Assert line with qty 0 is disabled', async () => { - productService.setProduct('4'); - const PRODUCT_FOUR = await productService.getProduct(); - productService.setProduct('5') - const PRODUCT_FIVE = await productService.getProduct(); + const PRODUCT_FOUR = await productService.getProduct(Product.FOUR); + const PRODUCT_FIVE = await productService.getProduct(Product.FIVE); await expect( receivingPage.receivingStep.table.row(1).checkbox ).toBeDisabled(); @@ -378,8 +370,7 @@ test.describe('Edit original line to other product in the middle of receipt', () }); await test.step('Assert product name on check step', async () => { - productService.setProduct('5'); - const PRODUCT_FIVE = await productService.getProduct(); + const PRODUCT_FIVE = await productService.getProduct(Product.FIVE); await receivingPage.nextButton.click(); await receivingPage.checkStep.isLoaded(); await expect( @@ -394,10 +385,8 @@ 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 () => { - productService.setProduct('4'); - const PRODUCT_FOUR = await productService.getProduct(); - productService.setProduct('5'); - const PRODUCT_FIVE = await productService.getProduct(); + const PRODUCT_FOUR = await productService.getProduct(Product.FOUR); + const PRODUCT_FIVE = await productService.getProduct(Product.FIVE); 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 c61d3f1..f924520 100644 --- a/src/tests/receiving/editsInReceiving.test.ts +++ b/src/tests/receiving/editsInReceiving.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; import { formatDate, getDateByOffset, getToday } from '@/utils/DateUtils'; @@ -19,10 +20,8 @@ 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); 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 108cb31..1948844 100644 --- a/src/tests/receiving/exportReceivingTemplate.test.ts +++ b/src/tests/receiving/exportReceivingTemplate.test.ts @@ -3,6 +3,7 @@ import _ from 'lodash'; import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; import { formatDate, getDateByOffset } from '@/utils/DateUtils'; @@ -22,12 +23,9 @@ test.describe('Export receiving template', () => { productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - productService.setProduct('1'); - const PRODUCT_ONE = await productService.getProduct(); - productService.setProduct('2'); - const PRODUCT_TWO = await productService.getProduct(); - productService.setProduct('3'); - const PRODUCT_THREE = await productService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); + const PRODUCT_THREE = await productService.getProduct(Product.THREE); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -91,12 +89,9 @@ test.describe('Export receiving template', () => { let filePath: string; let downloadedExportTemplateFile: WorkbookUtils; - productService.setProduct('1'); - const PRODUCT_ONE = await productService.getProduct(); - productService.setProduct('2'); - const PRODUCT_TWO = await productService.getProduct(); - productService.setProduct('3'); - const PRODUCT_THREE = await productService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); + const PRODUCT_THREE = await productService.getProduct(Product.THREE); const ROWS = [ { diff --git a/src/tests/receiving/importReceivingTemplate.test.ts b/src/tests/receiving/importReceivingTemplate.test.ts index 9744bd5..5ed7587 100644 --- a/src/tests/receiving/importReceivingTemplate.test.ts +++ b/src/tests/receiving/importReceivingTemplate.test.ts @@ -3,6 +3,7 @@ import path from 'node:path'; import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; import { getDateByOffset } from '@/utils/DateUtils'; @@ -25,8 +26,7 @@ test.describe('Import receiving template', () => { productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - productService.setProduct('1'); - const PRODUCT_ONE = await productService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); 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 e217b9e..a0a1e82 100644 --- a/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts +++ b/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; import { formatDate, getDateByOffset, getToday } from '@/utils/DateUtils'; @@ -74,8 +75,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(); + const product = await productService.getProduct(Product.ONE); await test.step('Ensure that lot number does not exist in product stock', async () => { await productShowPage.goToPage(product.id); @@ -199,8 +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(); + const product = await productService.getProduct(Product.ONE); TEST_INPUT_STOCK_EXISTING_LOT.lotNumber = uniqueIdentifier.generateUniqueString('lot'); @@ -289,8 +288,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(); + const product = await productService.getProduct(Product.ONE); await test.step('Create second inbound stock movement', async () => { const supplierLocation = await supplierLocationService.getLocation(); @@ -404,8 +402,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(); + const product = await productService.getProduct(Product.ONE); 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 0f57ecb..d0d3c89 100644 --- a/src/tests/receiving/receiveInbound.test.ts +++ b/src/tests/receiving/receiveInbound.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; import { formatDate, getToday } from '@/utils/DateUtils'; @@ -24,10 +25,8 @@ test.describe('Receive inbound stock movement', () => { dateRequested, }); - productService.setProduct('1'); - const product = await productService.getProduct(); - productService.setProduct('2'); - const product2 = await productService.getProduct(); + const product = await productService.getProduct(Product.ONE); + const product2 = await productService.getProduct(Product.TWO); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -135,8 +134,7 @@ test.describe('Receive inbound stock movement', () => { }); await test.step('Assert product in receiving table', async () => { - productService.setProduct('1'); - const item = await productService.getProduct(); + const item = await productService.getProduct(Product.ONE); await receivingPage.receivingStep.table.row(1).getItem(item.name).hover(); await expect(receivingPage.tooltip).toContainText(item.name); }); @@ -192,8 +190,7 @@ test.describe('Receive inbound stock movement', () => { }); await test.step('Assert product in checking table', async () => { - productService.setProduct('1'); - const item = await productService.getProduct(); + const item = await productService.getProduct(Product.ONE); await receivingPage.checkStep.table.row(1).getItem(item.name).hover(); await expect(receivingPage.tooltip).toContainText(item.name); }); @@ -401,10 +398,8 @@ test.describe('Receive from different locations', () => { dateRequested, }); - productService.setProduct('1'); - const product = await productService.getProduct(); - productService.setProduct('2'); - const product2 = await productService.getProduct(); + const product = await productService.getProduct(Product.ONE); + const product2 = await productService.getProduct(Product.TWO); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, diff --git a/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts b/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts index e3437c9..9e4ff98 100644 --- a/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts +++ b/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import { formatDate, getToday } from '@/utils/DateUtils'; @@ -18,10 +19,8 @@ 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -120,10 +119,8 @@ 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(); + const item = await productService.getProduct(Product.ONE); + const item2 = await productService.getProduct(Product.TWO); await receivingPage.receivingStep.table.row(1).getItem(item.name).hover(); await expect(receivingPage.tooltip).toContainText(item.name); await receivingPage.receivingStep.table @@ -245,10 +242,8 @@ 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(); + const item = await productService.getProduct(Product.ONE); + const item2 = await productService.getProduct(Product.TWO); 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 4c489b8..601fae7 100644 --- a/src/tests/receiving/receiveInboundWithoutPickAndPutawayStock.test.ts +++ b/src/tests/receiving/receiveInboundWithoutPickAndPutawayStock.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import { getToday } from '@/utils/DateUtils'; @@ -17,9 +18,9 @@ test.describe('Receive inbound stock movement in location without pick and putaw noPickAndPutawayStockDepotService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - const noPickAndPutawayStockDepot= await noPickAndPutawayStockDepotService.getLocation(); - productService.setProduct('1'); - const PRODUCT_ONE = await productService.getProduct(); + const noPickAndPutawayStockDepot = + await noPickAndPutawayStockDepotService.getLocation(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -30,9 +31,7 @@ test.describe('Receive inbound stock movement in location without pick and putaw await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, - [ - { productId: PRODUCT_ONE.id, quantity: 200 }, - ] + [{ productId: PRODUCT_ONE.id, quantity: 200 }] ); await stockMovementService.sendInboundStockMovement(STOCK_MOVEMENT.id, { @@ -41,16 +40,14 @@ test.describe('Receive inbound stock movement in location without pick and putaw } ); - test.afterEach( - async ({ stockMovementShowPage, authService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.rollbackLastReceiptButton.click(); - await stockMovementShowPage.rollbackButton.click(); - await stockMovementShowPage.clickDeleteShipment(); + test.afterEach(async ({ stockMovementShowPage, authService }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await stockMovementShowPage.rollbackLastReceiptButton.click(); + await stockMovementShowPage.rollbackButton.click(); + await stockMovementShowPage.clickDeleteShipment(); - await authService.changeLocation(AppConfig.instance.locations.main.id); - } - ); + await authService.changeLocation(AppConfig.instance.locations.main.id); + }); test('Receive sm in location without pick and putaway stock', async ({ stockMovementShowPage, @@ -58,7 +55,9 @@ test.describe('Receive inbound stock movement in location without pick and putaw authService, }) => { await test.step('Go to stock movement show page', async () => { - await authService.changeLocation(AppConfig.instance.locations.noPickAndPutawayStockDepot.id); + await authService.changeLocation( + AppConfig.instance.locations.noPickAndPutawayStockDepot.id + ); await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); }); @@ -86,20 +85,20 @@ test.describe('Receive inbound stock movement in location without pick and putaw await receivingPage.assertColumnHeaderTooltipOnReceivingStep('Recipient'); await receivingPage.assertColumnHeaderTooltipOnReceivingStep('Shipped'); await receivingPage.assertColumnHeaderTooltipOnReceivingStep('Received'); - await receivingPage.assertColumnHeaderTooltipOnReceivingStep('To receive'); + await receivingPage.assertColumnHeaderTooltipOnReceivingStep( + 'To receive' + ); await receivingPage.assertColumnHeaderTooltipOnReceivingStep( 'Receiving now' ); await receivingPage.assertColumnHeaderTooltipOnReceivingStep('Comment'); }); - await test.step('Autofill receiving qty', async () => { await receivingPage.receivingStep.isLoaded(); await receivingPage.receivingStep.autofillQuantitiesButton.click(); }); - await test.step('Go to and assert checking page is visible', async () => { await receivingPage.nextButton.click(); await receivingPage.checkStep.isLoaded(); @@ -125,7 +124,9 @@ test.describe('Receive inbound stock movement in location without pick and putaw 'Receiving now' ); await receivingPage.assertColumnHeaderTooltipOnCheckingStep('Remaining'); - await receivingPage.assertColumnHeaderTooltipOnCheckingStep('Cancel remaining'); + await receivingPage.assertColumnHeaderTooltipOnCheckingStep( + 'Cancel remaining' + ); await receivingPage.assertColumnHeaderTooltipOnCheckingStep('Comment'); }); @@ -136,10 +137,9 @@ test.describe('Receive inbound stock movement in location without pick and putaw }); await test.step('Assert Default bin on Packing list', async () => { - await expect(stockMovementShowPage.packingListTable.row(1).binLocation).toHaveText('Default'); - }); - + await expect( + stockMovementShowPage.packingListTable.row(1).binLocation + ).toHaveText('Default'); + }); }); - - }); diff --git a/src/tests/receiving/receiveToHoldBin.test.ts b/src/tests/receiving/receiveToHoldBin.test.ts index a5888e3..12f446a 100644 --- a/src/tests/receiving/receiveToHoldBin.test.ts +++ b/src/tests/receiving/receiveToHoldBin.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; import UniqueIdentifier from '@/utils/UniqueIdentifier'; @@ -23,8 +24,7 @@ test.describe('Receive item into hold bin', () => { createLocationPage, }) => { const supplierLocation = await supplierLocationService.getLocation(); - productService.setProduct('1'); - const PRODUCT_ONE = await productService.getProduct(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); 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 bba256e..979d3a0 100644 --- a/src/tests/receiving/receivingStatusChanges.test.ts +++ b/src/tests/receiving/receivingStatusChanges.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import InboundListPage from '@/pages/inbound/list/InboundListPage'; import StockMovementShowPage from '@/pages/stockMovementShow/StockMovementShowPage'; import { StockMovementResponse } from '@/types'; @@ -19,10 +20,8 @@ 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); 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 b2d31c4..81227da 100644 --- a/src/tests/receiving/receivingStatusChangesWithoutPartialReceiving.test.ts +++ b/src/tests/receiving/receivingStatusChangesWithoutPartialReceiving.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import InboundListPage from '@/pages/inbound/list/InboundListPage'; import StockMovementShowPage from '@/pages/stockMovementShow/StockMovementShowPage'; import { StockMovementResponse } from '@/types'; @@ -20,10 +21,8 @@ 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); 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 18a9f97..3177cf7 100644 --- a/src/tests/receiving/rollbackStatusChanges.test.ts +++ b/src/tests/receiving/rollbackStatusChanges.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import InboundListPage from '@/pages/inbound/list/InboundListPage'; import StockMovementShowPage from '@/pages/stockMovementShow/StockMovementShowPage'; import { StockMovementResponse } from '@/types'; @@ -19,10 +20,8 @@ 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); 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 a665dd9..4192e1a 100644 --- a/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts +++ b/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts @@ -1,5 +1,6 @@ import AppConfig from '@/config/AppConfig'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; import { getDateByOffset, getToday } from '@/utils/DateUtils'; @@ -17,10 +18,8 @@ test.describe('Apply sorting by alphabetical order and remain inputs', () => { productService, }) => { const supplierLocation = await supplierLocationService.getLocation(); - productService.setProduct('3'); - const PRODUCT_THREE = await productService.getProduct(); - productService.setProduct('4'); - const PRODUCT_FOUR = await productService.getProduct(); + const PRODUCT_THREE = await productService.getProduct(Product.THREE); + const PRODUCT_FOUR = await productService.getProduct(Product.FOUR); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -102,8 +101,7 @@ test.describe('Apply sorting by alphabetical order and remain inputs', () => { await createInboundPage.addItemsStep.isLoaded(); await createInboundPage.addItemsStep.addLineButton.focus(); await createInboundPage.addItemsStep.addLineButton.click(); - productService.setProduct('5'); - const item = await productService.getProduct(); + const item = await productService.getProduct(Product.FIVE); const row = createInboundPage.addItemsStep.table.row(2); await row.productSelect.findAndSelectOption(item.name); await row.quantityField.numberbox.fill('100'); @@ -137,8 +135,7 @@ test.describe('Apply sorting by alphabetical order and remain inputs', () => { }); await test.step('Change ordering to alphabetical and assert order', async () => { - productService.setProduct('5'); - const item = await productService.getProduct(); + const item = await productService.getProduct(Product.FIVE); await receivingPage.receivingStep.table.row(3).getItem(item.name).hover(); await expect(receivingPage.tooltip).toContainText(item.name); await expect(receivingPage.receivingStep.orderSelect).toBeVisible(); @@ -163,8 +160,7 @@ test.describe('Apply sorting by alphabetical order and remain inputs', () => { }); await test.step('Go to check page and assert applied order', async () => { - productService.setProduct('5'); - const item = await productService.getProduct(); + const item = await productService.getProduct(Product.FIVE); await receivingPage.nextButton.click(); await receivingPage.checkStep.isLoaded(); await receivingPage.checkStep.table.row(1).getItem(item.name).hover(); @@ -172,8 +168,7 @@ test.describe('Apply sorting by alphabetical order and remain inputs', () => { }); await test.step('Go back to receive page and change order to shipment', async () => { - productService.setProduct('5'); - const item = await productService.getProduct(); + const item = await productService.getProduct(Product.FIVE); 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 a4a887e..c8834e8 100644 --- a/src/tests/receiving/tableShortcutsInReceiving.test.ts +++ b/src/tests/receiving/tableShortcutsInReceiving.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; @@ -18,16 +19,11 @@ 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(); - 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(); + const PRODUCT_ONE = await productService.getProduct(Product.ONE); + const PRODUCT_TWO = await productService.getProduct(Product.TWO); + const PRODUCT_THREE = await productService.getProduct(Product.THREE); + const PRODUCT_FOUR = await productService.getProduct(Product.FOUR); + const PRODUCT_FIVE = await productService.getProduct(Product.FIVE); 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 244b6bc..c19caf5 100644 --- a/src/tests/receiving/validationsOnDeliverOnDate.test.ts +++ b/src/tests/receiving/validationsOnDeliverOnDate.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; import { getDateByOffset } from '@/utils/DateUtils'; @@ -19,8 +20,7 @@ test.describe('Validations on edit Deliver On Date when receiving shipment', () originId: supplierLocation.id, }); - productService.setProduct('1'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.ONE); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, diff --git a/src/tests/receiving/validationsOnEditAndReceive.test.ts b/src/tests/receiving/validationsOnEditAndReceive.test.ts index a5c76fe..39b5017 100644 --- a/src/tests/receiving/validationsOnEditAndReceive.test.ts +++ b/src/tests/receiving/validationsOnEditAndReceive.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; import { getToday } from '@/utils/DateUtils'; @@ -23,8 +24,7 @@ test.describe('Assert validation on try to receive not yet shipped inbound', () dateRequested, }); - productService.setProduct('1'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.ONE); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -83,8 +83,7 @@ test.describe('Validations on edit and receive inbound stock movement', () => { dateRequested, }); - productService.setProduct('1'); - const product = await productService.getProduct(); + const product = await productService.getProduct(Product.ONE); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, diff --git a/src/tests/users/userPermission.test.ts b/src/tests/users/userPermission.test.ts index 15bc655..6f743cd 100644 --- a/src/tests/users/userPermission.test.ts +++ b/src/tests/users/userPermission.test.ts @@ -1,6 +1,7 @@ import ImpersonateBanner from '@/components/ImpersonateBanner'; import Navbar from '@/components/Navbar'; import AppConfig from '@/config/AppConfig'; +import { DASHBOARD_URL } from '@/consts/applicationUrls'; import { expect, test } from '@/fixtures/fixtures'; import LoginPage from '@/pages/LoginPage'; import { CreateUserType } from '@/types'; @@ -23,7 +24,7 @@ test.describe('User Permissions', () => { }; await test.step('Go to create user page', async () => { - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await navbar.configurationButton.click(); await navbar.users.click(); await userListPage.createUserButton.click(); diff --git a/src/tests/users/userSettings.test.ts b/src/tests/users/userSettings.test.ts index ab94f15..3caabbd 100644 --- a/src/tests/users/userSettings.test.ts +++ b/src/tests/users/userSettings.test.ts @@ -1,4 +1,5 @@ import LocationChooser from '@/components/LocationChooser'; +import { DASHBOARD_URL } from '@/consts/applicationUrls'; import { expect, test } from '@/fixtures/fixtures'; import CreateInvoicePage from '@/pages/invoice/CreateInvoicePage'; import InvoiceListPage from '@/pages/invoice/InvoiceListPage'; @@ -20,7 +21,7 @@ test.beforeEach( }; await test.step('Go to create user page', async () => { - await page.goto('./dashboard'); + await page.goto(DASHBOARD_URL.base); await navbar.configurationButton.click(); await navbar.users.click(); await userListPage.createUserButton.click(); diff --git a/src/utils/BinLocationUtils.ts b/src/utils/BinLocationUtils.ts index 16a55d0..810a1c4 100644 --- a/src/utils/BinLocationUtils.ts +++ b/src/utils/BinLocationUtils.ts @@ -1,5 +1,6 @@ import { Page } from '@playwright/test'; +import { LOCATION_URL } from '@/consts/applicationUrls'; import CreateLocationPage from '@/pages/location/createLocation/CreateLocationPage'; import LocationListPage from '@/pages/location/LocationListPage'; import LocationData from '@/utils/LocationData'; @@ -19,7 +20,7 @@ class BinLocationUtils { receivingBin: string; }) { const mainLocation = await mainLocationService.getLocation(); - await page.goto('./location/list'); + await page.goto(LOCATION_URL.list()); await locationListPage.searchByLocationNameField.fill(mainLocation.name); await locationListPage.findButton.click(); await locationListPage.getLocationEditButton(mainLocation.name).click(); @@ -50,7 +51,7 @@ class BinLocationUtils { holdBinLocationName: string; }) { const mainLocation = await mainLocationService.getLocation(); - await page.goto('./location/list'); + await page.goto(LOCATION_URL.list()); await locationListPage.searchByLocationNameField.fill(mainLocation.name); await locationListPage.findButton.click(); await locationListPage.getLocationEditButton(mainLocation.name).click(); @@ -97,7 +98,7 @@ class BinLocationUtils { binLocationName: string; }) { const mainLocation = await mainLocationService.getLocation(); - await page.goto('./location/list'); + await page.goto(LOCATION_URL.list()); await locationListPage.searchByLocationNameField.fill(mainLocation.name); await locationListPage.findButton.click(); await locationListPage.getLocationEditButton(mainLocation.name).click(); diff --git a/src/utils/ProductData.ts b/src/utils/ProductData.ts index 2916b1d..b636baa 100644 --- a/src/utils/ProductData.ts +++ b/src/utils/ProductData.ts @@ -2,34 +2,23 @@ import { APIRequestContext } from '@playwright/test'; import ProductService from '@/api/ProductService'; import AppConfig from '@/config/AppConfig'; -import ProductConfig from '@/config/ProductConfig'; +import { ProductCode } from '@/generated/ProductCodes.generated'; class ProductData { private productService: ProductService; - private productConfig: ProductConfig; - - constructor( - request: APIRequestContext - ) { + constructor(request: APIRequestContext) { this.productService = new ProductService(request); - - this.productConfig = AppConfig.instance.products['1']; } - setProduct(productCode: string) { - this.productConfig = AppConfig.instance.products[productCode]; - } - - async getProduct() { - const id = this.productConfig.readId(); - + async getProduct(code: ProductCode) { + const id = AppConfig.instance.products[code].readId(); const { data } = await this.productService.get(id); return data; } - async getProductDemand() { - const id = this.productConfig.readId(); + async getProductDemand(code: ProductCode) { + const id = AppConfig.instance.products[code].readId(); const { data } = await this.productService.getDemand(id); return data?.demand; }