Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 195 additions & 0 deletions src/tests/putaway/putawayToHoldBin.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
import AppConfig from '@/config/AppConfig';
import { ShipmentType } from '@/constants/ShipmentType';
import { expect, test } from '@/fixtures/fixtures';
import { StockMovementResponse } from '@/types';
import BinLocationUtils from '@/utils/BinLocationUtils';
import RefreshCachesUtils from '@/utils/RefreshCaches';
import {
deleteReceivedShipment,
getShipmentId,
getShipmentItemId,
} from '@/utils/shipmentUtils';
import UniqueIdentifier from '@/utils/UniqueIdentifier';

test.describe('Putaway item into hold bin', () => {
test.describe.configure({ timeout: 60000 });
//timeout has been added for this test to make sure that the content on bin location tab will load as it can include a lot of data
let STOCK_MOVEMENT: StockMovementResponse;
const uniqueIdentifier = new UniqueIdentifier();
const holdBinLocationName = uniqueIdentifier.generateUniqueString('holdbin');

test.beforeEach(
async ({
supplierLocationService,
mainLocationService,
stockMovementService,
productService,
receivingService,
page,
locationListPage,
createLocationPage,
}) => {
const supplierLocation = await supplierLocationService.getLocation();
productService.setProduct('5');
const product = await productService.getProduct();

STOCK_MOVEMENT = await stockMovementService.createInbound({
originId: supplierLocation.id,
});

await stockMovementService.addItemsToInboundStockMovement(
STOCK_MOVEMENT.id,
[{ productId: product.id, quantity: 10 }]
);

await stockMovementService.sendInboundStockMovement(STOCK_MOVEMENT.id, {
shipmentType: ShipmentType.AIR,
});

const { data: stockMovement } =
await stockMovementService.getStockMovement(STOCK_MOVEMENT.id);
const shipmentId = getShipmentId(stockMovement);
const { data: receipt } = await receivingService.getReceipt(shipmentId);
const receivingBin =
AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;

await receivingService.createReceivingBin(shipmentId, receipt);

await receivingService.updateReceivingItems(shipmentId, [
{
shipmentItemId: getShipmentItemId(receipt, 0, 0),
quantityReceiving: 10,
binLocationName: receivingBin,
},
]);
await receivingService.completeReceipt(shipmentId);

await test.step('Create bin location with hold stock activity for location', async () => {
await BinLocationUtils.createHoldBin({
mainLocationService,
locationListPage,
createLocationPage,
page,
holdBinLocationName,
});
});
}
);

test.afterEach(
async ({
navbar,
transactionListPage,
stockMovementShowPage,
stockMovementService,
page,
locationListPage,
mainLocationService,
createLocationPage,
oldViewShipmentPage,
}) => {
const receivingBin =
AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;
await navbar.configurationButton.click();
await navbar.transactions.click();
await transactionListPage.table.row(1).actionsButton.click();
await transactionListPage.table.deleteButton.click();
await expect(transactionListPage.successMessage).toBeVisible();
await transactionListPage.table.row(1).actionsButton.click();
await transactionListPage.table.deleteButton.click();
await expect(transactionListPage.successMessage).toBeVisible();

await deleteReceivedShipment({
stockMovementShowPage,
oldViewShipmentPage,
stockMovementService,
STOCK_MOVEMENT,
});

await test.step('Deactivate created bin location', async () => {
await BinLocationUtils.deactivateCreatedBin({
mainLocationService,
locationListPage,
createLocationPage,
page,
binLocationName: holdBinLocationName,
});
});

await BinLocationUtils.deactivateReceivingBin({
mainLocationService,
locationListPage,
createLocationPage,
page,
receivingBin,
});
}
);

test('Putaway to hold bin', async ({
stockMovementShowPage,
createPutawayPage,
putawayDetailsPage,
navbar,
productShowPage,
productService,
}) => {
await test.step('Go to stock movement show page and assert received status', async () => {
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
await stockMovementShowPage.isLoaded();
await expect(stockMovementShowPage.statusTag).toHaveText('Received');
await RefreshCachesUtils.refreshCaches({
navbar,
});
});

await test.step('Go to create putaway page', async () => {
await navbar.inbound.click();
await navbar.createPutaway.click();
await createPutawayPage.isLoaded();
});

await test.step('Start putaway', async () => {
await createPutawayPage.table.row(0).checkbox.click();
await createPutawayPage.startPutawayButton.click();
await createPutawayPage.startStep.isLoaded();
});

await test.step('Select bin to putaway', async () => {
await createPutawayPage.startStep.table.row(0).putawayBinSelect.click();
await createPutawayPage.startStep.table
.row(0)
.getPutawayBin(holdBinLocationName)
.click();
await createPutawayPage.startStep.nextButton.click();
});

await test.step('Go to next page and complete putaway', async () => {
await createPutawayPage.completeStep.isLoaded();
await createPutawayPage.completeStep.completePutawayButton.click();
});

await test.step('Assert completing putaway', async () => {
await putawayDetailsPage.isLoaded();
await expect(putawayDetailsPage.statusTag).toHaveText('Completed');
});

await test.step('Assert putaway bin on stock card', async () => {
await putawayDetailsPage.summaryTab.click();
productService.setProduct('5');
const product = await productService.getProduct();
await productShowPage.goToPage(product.id);
await productShowPage.inStockTab.click();
await productShowPage.inStockTabSection.isLoaded();
await expect(
productShowPage.inStockTabSection.row(1).binLocation
).toHaveText(holdBinLocationName);
await expect(
productShowPage.inStockTabSection.row(1).row
).toHaveAttribute('title', 'This bin has been restricted');
await expect(
productShowPage.inStockTabSection.row(1).inventoryInformation
).toHaveText('Hold');
});
});
});
86 changes: 19 additions & 67 deletions src/tests/receiving/receiveToHoldBin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test.describe('Receive item into hold bin', () => {
//timeout has been added for this test to make sure that the content on bin location tab will load as it can include a lot of data
let STOCK_MOVEMENT: StockMovementResponse;
const uniqueIdentifier = new UniqueIdentifier();
const binLocationName = uniqueIdentifier.generateUniqueString('holdbin');
const holdBinLocationName = uniqueIdentifier.generateUniqueString('holdbin');

test.beforeEach(
async ({
Expand All @@ -23,7 +23,6 @@ test.describe('Receive item into hold bin', () => {
createLocationPage,
}) => {
const supplierLocation = await supplierLocationService.getLocation();
const mainLocation = await mainLocationService.getLocation();
productService.setProduct('1');
const PRODUCT_ONE = await productService.getProduct();

Expand All @@ -41,44 +40,13 @@ test.describe('Receive item into hold bin', () => {
});

await test.step('Create bin location with hold stock activity for location', async () => {
await page.goto('./location/list');
await locationListPage.searchByLocationNameField.fill(
mainLocation.name
);
await locationListPage.findButton.click();
await expect(
locationListPage.getLocationEditButton(mainLocation.name)
).toBeVisible();
await locationListPage.getLocationEditButton(mainLocation.name).click();
await createLocationPage.binLocationTab.click();
await createLocationPage.binLocationTabSection.isLoaded();
await createLocationPage.binLocationTabSection.addBinLocationButton.click();
await createLocationPage.binLocationTabSection.addBinLocationDialog.binLocationNameField.fill(
binLocationName
);
await createLocationPage.binLocationTabSection.addBinLocationDialog.saveButton.click();
await createLocationPage.binLocationTab.click();
await createLocationPage.binLocationTabSection.searchField.fill(
binLocationName
);
await createLocationPage.binLocationTabSection.searchField.press(
'Enter'
);
await createLocationPage.binLocationTabSection.isLoaded();
await createLocationPage.binLocationTabSection.editBinButton.click();
await createLocationPage.locationConfigurationTab.click();
await createLocationPage.locationConfigurationTabSection.useDefaultSettingsCheckbox.uncheck();
await createLocationPage.locationConfigurationTabSection
.removeSupportedActivitiesButton('Putaway stock')
.click();
await createLocationPage.locationConfigurationTabSection
.removeSupportedActivitiesButton('Pick stock')
.click();
await createLocationPage.locationConfigurationTabSection.supportedActivitiesSelect.click();
await createLocationPage.locationConfigurationTabSection
.getSupportedActivitiesOption('Hold stock')
.click();
await createLocationPage.locationConfigurationTabSection.saveButton.click();
await BinLocationUtils.createHoldBin({
mainLocationService,
locationListPage,
createLocationPage,
page,
holdBinLocationName,
});
});
}
);
Expand All @@ -92,37 +60,21 @@ test.describe('Receive item into hold bin', () => {
mainLocationService,
createLocationPage,
}) => {
const mainLocation = await mainLocationService.getLocation();
const receivingBin =
AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
await stockMovementShowPage.rollbackLastReceiptButton.click();
await stockMovementShowPage.rollbackButton.click();
await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id);

await test.step('Deactitave created bin location', async () => {
await page.goto('./location/list');
await locationListPage.searchByLocationNameField.fill(
mainLocation.name
);
await locationListPage.findButton.click();
await expect(
locationListPage.getLocationEditButton(mainLocation.name)
).toBeVisible();
await locationListPage.getLocationEditButton(mainLocation.name).click();
await createLocationPage.binLocationTab.click();
await createLocationPage.binLocationTabSection.isLoaded();
await createLocationPage.binLocationTabSection.searchField.fill(
binLocationName
);
await createLocationPage.binLocationTabSection.searchField.press(
'Enter'
);
await createLocationPage.binLocationTabSection.isLoaded();
await createLocationPage.binLocationTabSection.editBinButton.click();
await createLocationPage.locationConfigurationTab.click();
await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck();
await createLocationPage.locationConfigurationTabSection.saveButton.click();
await test.step('Deactivate created bin location', async () => {
await BinLocationUtils.deactivateCreatedBin({
mainLocationService,
locationListPage,
createLocationPage,
page,
binLocationName: holdBinLocationName,
});
});

await BinLocationUtils.deactivateReceivingBin({
Expand Down Expand Up @@ -155,7 +107,7 @@ test.describe('Receive item into hold bin', () => {
await receivingPage.receivingStep.table.row(1).binLocationSelect.click();
await receivingPage.receivingStep.table
.row(1)
.getBinLocation(binLocationName)
.getBinLocation(holdBinLocationName)
.click();
await receivingPage.receivingStep.table
.row(1)
Expand All @@ -176,7 +128,7 @@ test.describe('Receive item into hold bin', () => {
await test.step('Assert edited bin on Packing list', async () => {
await expect(
stockMovementShowPage.packingListTable.row(1).binLocation
).toHaveText(binLocationName);
).toHaveText(holdBinLocationName);
});

await test.step('Go to product page and assert bin location', async () => {
Expand All @@ -185,7 +137,7 @@ test.describe('Receive item into hold bin', () => {
await productShowPage.inStockTabSection.isLoaded();
await expect(
productShowPage.inStockTabSection.row(2).binLocation
).toHaveText(binLocationName);
).toHaveText(holdBinLocationName);
await expect(
productShowPage.inStockTabSection.row(2).row
).toHaveAttribute('title', 'This bin has been restricted');
Expand Down
Loading
Loading