Skip to content

Commit bc2f21d

Browse files
committed
OBPIH-6969 Fix usages of product services
1 parent 86bce7c commit bc2f21d

43 files changed

Lines changed: 247 additions & 237 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/fixtures/fixtures.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import LocationChooser from '@/components/LocationChooser';
1010
import Navbar from '@/components/Navbar';
1111
import AppConfig, {
1212
LOCATION_KEY,
13-
PRODUCT_KEY,
1413
USER_KEY,
1514
} from '@/config/AppConfig';
1615
import CreateInbound from '@/pages/inbound/create/CreateInboundPage';
@@ -95,11 +94,7 @@ type Fixtures = {
9594
internalLocation2Service: LocationData;
9695

9796
// PRODUCT DATA
98-
mainProductService: ProductData;
99-
otherProductService: ProductData;
100-
thirdProductService: ProductData;
101-
fourthProductService: ProductData;
102-
fifthProductService: ProductData;
97+
productService: ProductData;
10398
// USERS DATA
10499
mainUserService: UserData;
105100
altUserService: UserData;
@@ -184,16 +179,8 @@ export const test = baseTest.extend<Fixtures>({
184179
internalLocation2Service: async ({ page }, use) =>
185180
use(new LocationData(LOCATION_KEY.BIN_LOCATION2, page.request)),
186181
// PRODUCTS
187-
mainProductService: async ({ page }, use) =>
188-
use(new ProductData(PRODUCT_KEY.ONE, page.request)),
189-
otherProductService: async ({ page }, use) =>
190-
use(new ProductData(PRODUCT_KEY.TWO, page.request)),
191-
thirdProductService: async ({ page }, use) =>
192-
use(new ProductData(PRODUCT_KEY.THREE, page.request)),
193-
fourthProductService: async ({ page }, use) =>
194-
use(new ProductData(PRODUCT_KEY.FOUR, page.request)),
195-
fifthProductService: async ({ page }, use) =>
196-
use(new ProductData(PRODUCT_KEY.FIVE, page.request)),
182+
productService: async ({ page }, use) =>
183+
use(new ProductData(page.request)),
197184
// USERS
198185
mainUserService: async ({ page }, use) =>
199186
use(new UserData(USER_KEY.MAIN, page.request)),

src/tests/inbound/createInbound/createInbound.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ test.describe('Create inbound stock movement', () => {
1818

1919
test.beforeEach(
2020
async ({
21-
mainProductService,
22-
otherProductService,
21+
productService,
2322
mainUserService,
2423
supplierLocationService,
2524
mainLocationService,
2625
}) => {
27-
const PRODUCT_ONE = await mainProductService.getProduct();
28-
const PRODUCT_TWO = await otherProductService.getProduct();
26+
const PRODUCT_ONE = await productService.getProduct();
27+
productService.setProduct('2');
28+
const PRODUCT_TWO = await productService.getProduct();
2929
USER = await mainUserService.getUser();
3030
ORIGIN = await supplierLocationService.getLocation();
3131
CURRENT_LOCATION = await mainLocationService.getLocation();
@@ -191,15 +191,15 @@ test.describe('Values persistance between steps', () => {
191191

192192
test.beforeEach(
193193
async ({
194-
mainProductService,
195-
otherProductService,
194+
productService,
196195
mainUserService,
197196
createInboundPage,
198197
mainLocationService,
199198
supplierLocationService,
200199
}) => {
201-
const PRODUCT_ONE = await mainProductService.getProduct();
202-
const PRODUCT_TWO = await otherProductService.getProduct();
200+
const PRODUCT_ONE = await productService.getProduct();
201+
productService.setProduct('2');
202+
const PRODUCT_TWO = await productService.getProduct();
203203
USER = await mainUserService.getUser();
204204
CURRENT_LOCATION = await mainLocationService.getLocation();
205205
ORIGIN = await supplierLocationService.getLocation();

src/tests/inbound/createInbound/downloadDocsFromSendPage.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ test.describe('Download documents from inbound send page', () => {
1616

1717
test.beforeEach(
1818
async ({
19-
mainProductService,
19+
productService,
2020
mainUserService,
2121
supplierLocationService,
2222
}) => {
23-
const PRODUCT_ONE = await mainProductService.getProduct();
23+
const PRODUCT_ONE = await productService.getProduct();
2424
USER = await mainUserService.getUser();
2525
ORIGIN = await supplierLocationService.getLocation();
2626

src/tests/inbound/createInbound/editDestinationFromSendPage.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig';
22
import { ShipmentType } from '@/constants/ShipmentType';
33
import { expect, test } from '@/fixtures/fixtures';
44
import { StockMovementResponse } from '@/types';
5+
import productService from '@/api/ProductService';
56

67
test.describe('Edit destination from send page', () => {
78
let STOCK_MOVEMENT: StockMovementResponse;
@@ -10,12 +11,13 @@ test.describe('Edit destination from send page', () => {
1011
async ({
1112
supplierLocationService,
1213
stockMovementService,
13-
otherProductService,
14-
thirdProductService,
14+
productService,
1515
}) => {
1616
const supplierLocation = await supplierLocationService.getLocation();
17-
const PRODUCT_TWO = await otherProductService.getProduct();
18-
const PRODUCT_THREE = await thirdProductService.getProduct();
17+
productService.setProduct('2');
18+
const PRODUCT_TWO = await productService.getProduct();
19+
productService.setProduct('3')
20+
const PRODUCT_THREE = await productService.getProduct();
1921

2022
STOCK_MOVEMENT = await stockMovementService.createInbound({
2123
originId: supplierLocation.id,

src/tests/inbound/createInbound/expectedDeliveryDate.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { expect, test } from '@/fixtures/fixtures';
22
import { StockMovementResponse, User } from '@/types';
33
import { formatDate, getDateByOffset } from '@/utils/DateUtils';
4+
import productService from '@/api/ProductService';
45

56
test.describe('Expected delivery date tests', () => {
67
let STOCK_MOVEMENT: StockMovementResponse;
@@ -12,13 +13,14 @@ test.describe('Expected delivery date tests', () => {
1213
supplierLocationService,
1314
mainUserService,
1415
stockMovementService,
15-
thirdProductService,
16-
fourthProductService,
16+
productService,
1717
}) => {
1818
const supplierLocation = await supplierLocationService.getLocation();
1919
USER = await mainUserService.getUser();
20-
const PRODUCT_THREE = await thirdProductService.getProduct();
21-
const PRODUCT_FOUR = await fourthProductService.getProduct();
20+
productService.setProduct('3');
21+
const PRODUCT_THREE = await productService.getProduct();
22+
productService.setProduct('4');
23+
const PRODUCT_FOUR = await productService.getProduct();
2224

2325
STOCK_MOVEMENT = await stockMovementService.createInbound({
2426
originId: supplierLocation.id,

src/tests/inbound/createInbound/exportItems.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ test.describe('Export all incoming items', () => {
1111
async ({
1212
supplierLocationService,
1313
createInboundPage,
14-
mainProductService,
14+
productService,
1515
mainUserService,
16-
otherProductService,
1716
stockMovementShowPage,
1817
inboundListPage,
1918
}) => {
@@ -22,8 +21,9 @@ test.describe('Export all incoming items', () => {
2221
const USER = await mainUserService.getUser();
2322
const TODAY = getToday();
2423

25-
const PRODUCT_ONE = await mainProductService.getProduct();
26-
const PRODUCT_TWO = await otherProductService.getProduct();
24+
const PRODUCT_ONE = await productService.getProduct();
25+
productService.setProduct('2');
26+
const PRODUCT_TWO = await productService.getProduct();
2727
const SHIPMENT_TYPE = 'Land';
2828
const EXPECTED_DELIVERY_DATE = getDateByOffset(TODAY, 1);
2929

src/tests/inbound/createInbound/fieldValidation.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ let ORIGIN: LocationResponse;
1111

1212
test.beforeEach(
1313
async ({
14-
mainProductService,
14+
productService,
1515
mainUserService,
1616
createInboundPage,
1717
supplierLocationService,
1818
}) => {
19-
const PRODUCT_ONE = await mainProductService.getProduct();
19+
const PRODUCT_ONE = await productService.getProduct();
2020
USER = await mainUserService.getUser();
2121
ORIGIN = await supplierLocationService.getLocation();
2222

src/tests/inbound/createInbound/inboundStatusChanges.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ test.describe('Status changes for inbound sm on view sm and inbound list page',
1818

1919
test.beforeEach(
2020
async ({
21-
mainProductService,
22-
otherProductService,
21+
productService,
2322
mainUserService,
2423
supplierLocationService,
2524
}) => {
26-
const PRODUCT_ONE = await mainProductService.getProduct();
27-
const PRODUCT_TWO = await otherProductService.getProduct();
25+
const PRODUCT_ONE = await productService.getProduct();
26+
productService.setProduct('2');
27+
const PRODUCT_TWO = await productService.getProduct();
2828
USER = await mainUserService.getUser();
2929
ORIGIN = await supplierLocationService.getLocation();
3030

src/tests/inbound/createInbound/itemTemplate.test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ test.describe('Export items template on inbound add items page', () => {
7777

7878
test('Downloaded template should contain all added items', async ({
7979
createInboundPage,
80-
mainProductService,
81-
otherProductService,
80+
productService,
8281
mainUserService,
8382
}) => {
8483
await test.step('Go to inbound list page', async () => {
@@ -87,8 +86,9 @@ test.describe('Export items template on inbound add items page', () => {
8786
await createInboundPage.addItemsStep.isLoaded();
8887
});
8988

90-
const PRODUCT_ONE = await mainProductService.getProduct();
91-
const PRODUCT_TWO = await otherProductService.getProduct();
89+
const PRODUCT_ONE = await productService.getProduct();
90+
productService.setProduct('2');
91+
const PRODUCT_TWO = await productService.getProduct();
9292
const USER = await mainUserService.getUser();
9393

9494
const ROWS = [
@@ -178,8 +178,7 @@ test.describe('Import template with data', () => {
178178

179179
test('Import filled template on an empty table', async ({
180180
createInboundPage,
181-
mainProductService,
182-
otherProductService,
181+
productService,
183182
mainUserService,
184183
}) => {
185184
await test.step('Go to inbound list page', async () => {
@@ -198,8 +197,9 @@ test.describe('Import template with data', () => {
198197
workbooks.push(downloadedTemplateFile);
199198
});
200199

201-
const PRODUCT_ONE = await mainProductService.getProduct();
202-
const PRODUCT_TWO = await otherProductService.getProduct();
200+
const PRODUCT_ONE = await productService.getProduct();
201+
productService.setProduct('2');
202+
const PRODUCT_TWO = await productService.getProduct();
203203
const USER = await mainUserService.getUser();
204204

205205
const ROWS = [
@@ -259,8 +259,7 @@ test.describe('Import template with data', () => {
259259

260260
test.skip('Update existing values with template import', async ({
261261
createInboundPage,
262-
otherProductService,
263-
mainProductService,
262+
productService,
264263
altUserService,
265264
mainUserService,
266265
}) => {
@@ -272,7 +271,7 @@ test.describe('Import template with data', () => {
272271
});
273272

274273
await test.step('Add items to table', async () => {
275-
const PRODUCT_ONE = await mainProductService.getProduct();
274+
const PRODUCT_ONE = await productService.getProduct();
276275
const USER = await mainUserService.getUser();
277276

278277
const ROWS = [
@@ -307,7 +306,8 @@ test.describe('Import template with data', () => {
307306
parsedDocumentData = downloadedTemplateFile.sheetToJSON();
308307
});
309308

310-
const PRODUCT_TWO = await otherProductService.getProduct();
309+
productService.setProduct('2');
310+
const PRODUCT_TWO = await productService.getProduct();
311311
const ALT_USER = await altUserService.getUser();
312312

313313
const NEW_ROW = {
@@ -352,8 +352,7 @@ test.describe('Import template with data', () => {
352352

353353
test('Add new row to with existing items in the table', async ({
354354
createInboundPage,
355-
otherProductService,
356-
mainProductService,
355+
productService,
357356
altUserService,
358357
mainUserService,
359358
}) => {
@@ -365,7 +364,7 @@ test.describe('Import template with data', () => {
365364

366365
let ROW: CreateInboundAddItemsTableEntity;
367366
await test.step('Add items to table', async () => {
368-
const PRODUCT_ONE = await mainProductService.getProduct();
367+
const PRODUCT_ONE = await productService.getProduct();
369368
const USER = await mainUserService.getUser();
370369

371370
ROW = {
@@ -397,7 +396,8 @@ test.describe('Import template with data', () => {
397396
parsedDocumentData = downloadedTemplateFile.sheetToJSON();
398397
});
399398

400-
const PRODUCT_TWO = await otherProductService.getProduct();
399+
productService.setProduct('2')
400+
const PRODUCT_TWO = await productService.getProduct();
401401
const ALT_USER = await altUserService.getUser();
402402

403403
const NEW_ROW = {

src/tests/inbound/createInbound/packLevels.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ let INBOUND_ID: string;
88

99
test.beforeEach(
1010
async ({
11-
mainProductService,
11+
productService,
1212
mainUserService,
1313
createInboundPage,
1414
supplierLocationService,
1515
}) => {
16-
const PRODUCT_ONE = await mainProductService.getProduct();
16+
const PRODUCT_ONE = await productService.getProduct();
1717
const USER = await mainUserService.getUser();
1818
const ORIGIN = await supplierLocationService.getLocation();
1919
const DESCRIPTION = 'some description';

0 commit comments

Comments
 (0)