Skip to content

Commit 0f30379

Browse files
committed
OBPIH-6969 Fix usages of product services
1 parent d990fbf commit 0f30379

Some content is hidden

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

43 files changed

+245
-237
lines changed

src/fixtures/fixtures.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import LocationChooser from '@/components/LocationChooser';
99
import Navbar from '@/components/Navbar';
1010
import AppConfig, {
1111
LOCATION_KEY,
12-
PRODUCT_KEY,
1312
USER_KEY,
1413
} from '@/config/AppConfig';
1514
import CreateInbound from '@/pages/inbound/create/CreateInboundPage';
@@ -80,11 +79,7 @@ type Fixtures = {
8079
wardLocationService: LocationData;
8180
noPickAndPutawayStockDepotService: LocationData;
8281
// PRODUCT DATA
83-
mainProductService: ProductData;
84-
otherProductService: ProductData;
85-
thirdProductService: ProductData;
86-
fourthProductService: ProductData;
87-
fifthProductService: ProductData;
82+
productService: ProductData;
8883
// USERS DATA
8984
mainUserService: UserData;
9085
altUserService: UserData;
@@ -155,16 +150,8 @@ export const test = baseTest.extend<Fixtures>({
155150
noPickAndPutawayStockDepotService: async ({ page }, use) =>
156151
use(new LocationData(LOCATION_KEY.NO_PICK_AND_PUTAWAY_STOCK, page.request)),
157152
// PRODUCTS
158-
mainProductService: async ({ page }, use) =>
159-
use(new ProductData(PRODUCT_KEY.ONE, page.request)),
160-
otherProductService: async ({ page }, use) =>
161-
use(new ProductData(PRODUCT_KEY.TWO, page.request)),
162-
thirdProductService: async ({ page }, use) =>
163-
use(new ProductData(PRODUCT_KEY.THREE, page.request)),
164-
fourthProductService: async ({ page }, use) =>
165-
use(new ProductData(PRODUCT_KEY.FOUR, page.request)),
166-
fifthProductService: async ({ page }, use) =>
167-
use(new ProductData(PRODUCT_KEY.FIVE, page.request)),
153+
productService: async ({ page }, use) =>
154+
use(new ProductData(page.request)),
168155
// USERS
169156
mainUserService: async ({ page }, use) =>
170157
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();
@@ -188,15 +188,15 @@ test.describe('Values persistance between steps', () => {
188188

189189
test.beforeEach(
190190
async ({
191-
mainProductService,
192-
otherProductService,
191+
productService,
193192
mainUserService,
194193
createInboundPage,
195194
mainLocationService,
196195
supplierLocationService,
197196
}) => {
198-
const PRODUCT_ONE = await mainProductService.getProduct();
199-
const PRODUCT_TWO = await otherProductService.getProduct();
197+
const PRODUCT_ONE = await productService.getProduct();
198+
productService.setProduct('2');
199+
const PRODUCT_TWO = await productService.getProduct();
200200
USER = await mainUserService.getUser();
201201
CURRENT_LOCATION = await mainLocationService.getLocation();
202202
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
@@ -22,13 +22,13 @@ test.describe('Status changes for inbound sm on view sm and inbound list page',
2222

2323
test.beforeEach(
2424
async ({
25-
mainProductService,
26-
otherProductService,
25+
productService,
2726
mainUserService,
2827
supplierLocationService,
2928
}) => {
30-
const PRODUCT_ONE = await mainProductService.getProduct();
31-
const PRODUCT_TWO = await otherProductService.getProduct();
29+
const PRODUCT_ONE = await productService.getProduct();
30+
productService.setProduct('2');
31+
const PRODUCT_TWO = await productService.getProduct();
3232
USER = await mainUserService.getUser();
3333
ORIGIN = await supplierLocationService.getLocation();
3434

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

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

7676
test('Downloaded template should contain all added items', async ({
7777
createInboundPage,
78-
mainProductService,
79-
otherProductService,
78+
productService,
8079
mainUserService,
8180
}) => {
8281
await test.step('Go to inbound list page', async () => {
8382
await createInboundPage.goToPage(STOCK_MOVEMENT.id);
8483
await createInboundPage.addItemsStep.isLoaded();
8584
});
8685

87-
const PRODUCT_ONE = await mainProductService.getProduct();
88-
const PRODUCT_TWO = await otherProductService.getProduct();
86+
const PRODUCT_ONE = await productService.getProduct();
87+
productService.setProduct('2');
88+
const PRODUCT_TWO = await productService.getProduct();
8989
const USER = await mainUserService.getUser();
9090

9191
const ROWS = [
@@ -175,8 +175,7 @@ test.describe('Import template with data', () => {
175175

176176
test('Import filled template on an empty table', async ({
177177
createInboundPage,
178-
mainProductService,
179-
otherProductService,
178+
productService,
180179
mainUserService,
181180
}) => {
182181
await test.step('Go to inbound list page', async () => {
@@ -193,8 +192,9 @@ test.describe('Import template with data', () => {
193192
workbooks.push(downloadedTemplateFile);
194193
});
195194

196-
const PRODUCT_ONE = await mainProductService.getProduct();
197-
const PRODUCT_TWO = await otherProductService.getProduct();
195+
const PRODUCT_ONE = await productService.getProduct();
196+
productService.setProduct('2');
197+
const PRODUCT_TWO = await productService.getProduct();
198198
const USER = await mainUserService.getUser();
199199

200200
const ROWS = [
@@ -254,8 +254,7 @@ test.describe('Import template with data', () => {
254254

255255
test.skip('Update existing values with template import', async ({
256256
createInboundPage,
257-
otherProductService,
258-
mainProductService,
257+
productService,
259258
altUserService,
260259
mainUserService,
261260
}) => {
@@ -265,7 +264,7 @@ test.describe('Import template with data', () => {
265264
});
266265

267266
await test.step('Add items to table', async () => {
268-
const PRODUCT_ONE = await mainProductService.getProduct();
267+
const PRODUCT_ONE = await productService.getProduct();
269268
const USER = await mainUserService.getUser();
270269

271270
const ROWS = [
@@ -300,7 +299,8 @@ test.describe('Import template with data', () => {
300299
parsedDocumentData = downloadedTemplateFile.sheetToJSON();
301300
});
302301

303-
const PRODUCT_TWO = await otherProductService.getProduct();
302+
productService.setProduct('2');
303+
const PRODUCT_TWO = await productService.getProduct();
304304
const ALT_USER = await altUserService.getUser();
305305

306306
const NEW_ROW = {
@@ -345,8 +345,7 @@ test.describe('Import template with data', () => {
345345

346346
test('Add new row to with existing items in the table', async ({
347347
createInboundPage,
348-
otherProductService,
349-
mainProductService,
348+
productService,
350349
altUserService,
351350
mainUserService,
352351
}) => {
@@ -357,7 +356,7 @@ test.describe('Import template with data', () => {
357356

358357
let ROW: CreateInboundAddItemsTableEntity;
359358
await test.step('Add items to table', async () => {
360-
const PRODUCT_ONE = await mainProductService.getProduct();
359+
const PRODUCT_ONE = await productService.getProduct();
361360
const USER = await mainUserService.getUser();
362361

363362
ROW = {
@@ -389,7 +388,8 @@ test.describe('Import template with data', () => {
389388
parsedDocumentData = downloadedTemplateFile.sheetToJSON();
390389
});
391390

392-
const PRODUCT_TWO = await otherProductService.getProduct();
391+
productService.setProduct('2')
392+
const PRODUCT_TWO = await productService.getProduct();
393393
const ALT_USER = await altUserService.getUser();
394394

395395
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)