Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OBPIH-6702: Receive without partial receiving #32

Merged
merged 3 commits into from
Jan 14, 2025
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
12 changes: 12 additions & 0 deletions src/pages/receiving/steps/ReceivingStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ class ReceivingStep extends BasePageModel {
get autofillQuantitiesButton() {
return this.page.getByRole('button', { name: 'Autofill quantities' });
}

get confirmReceivingDialog() {
return this.page.locator('.react-confirm-alert-body');
}

get rejectConfirmReceivingDialog() {
return this.confirmReceivingDialog.getByRole('button', { name: 'No' });
}

get acceptConfirmReceivingDialog() {
return this.confirmReceivingDialog.getByRole('button', { name: 'Yes' });
}
}

export default ReceivingStep;
347 changes: 347 additions & 0 deletions src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,347 @@
import AppConfig from '@/config/AppConfig';
import { ShipmentType } from '@/constants/ShipmentType';
import { expect, test } from '@/fixtures/fixtures';
import { StockMovementResponse } from '@/types';
import { formatDate, getToday } from '@/utils/DateUtils';

test.describe('Receive inbound stock movement in location without partial receiving', () => {
let STOCK_MOVEMENT: StockMovementResponse;
const description = 'some description';
const dateRequested = getToday();

test.beforeEach(
async ({
supplierLocationService,
stockMovementService,
mainProductService,
otherProductService,
depotLocationService,
}) => {
const supplierLocation = await supplierLocationService.getLocation();
const depotLocation = await depotLocationService.getLocation();
const PRODUCT_ONE = await mainProductService.getProduct();
const PRODUCT_TWO = await otherProductService.getProduct();

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

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

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

test.afterEach(
async ({ stockMovementShowPage, stockMovementService, authService }) => {
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
const isRollbackLastReceiptButtonVisible =
await stockMovementShowPage.rollbackLastReceiptButton.isVisible();
const isRollbackButtonVisible =
await stockMovementShowPage.rollbackButton.isVisible();

// due to failed test, shipment might not be received which will not show the button
if (isRollbackLastReceiptButtonVisible) {
await stockMovementShowPage.rollbackLastReceiptButton.click();
}

if (isRollbackButtonVisible) {
await stockMovementShowPage.rollbackButton.click();
}

await authService.changeLocation(AppConfig.instance.locations.main.id);
await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id);
}
);

test('Assert Confirm receiving dialog and select No, receive 1 item fully', async ({
stockMovementShowPage,
receivingPage,
supplierLocationService,
depotLocationService,
mainProductService,
otherProductService,
authService,
}) => {
await test.step('Go to stock movement show page', async () => {
await authService.changeLocation(AppConfig.instance.locations.depot.id);
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
await stockMovementShowPage.isLoaded();
});

await test.step('Go to shipment receiving page', async () => {
await stockMovementShowPage.receiveButton.click();
await receivingPage.receivingStep.isLoaded();
});

await test.step('Assert header on receiving page', async () => {
const supplierLocation = await supplierLocationService.getLocation();
const depotLocation = await depotLocationService.getLocation();
await receivingPage.assertHeaderIsVisible({
origin: supplierLocation.name,
destination: depotLocation.name,
description: description,
date: formatDate(dateRequested),
});
});

await test.step('Assert table column headers on receiving page', async () => {
await receivingPage.assertColumnHeaderTooltipOnReceivingStep(
'Pack level 1'
);
await receivingPage.assertColumnHeaderTooltipOnReceivingStep(
'Pack level 2'
);
await receivingPage.assertColumnHeaderTooltipOnReceivingStep('Code');
await receivingPage.assertColumnHeaderTooltipOnReceivingStep('Product');
await receivingPage.assertColumnHeaderTooltipOnReceivingStep(
'Lot/Serial No.'
);
await receivingPage.assertColumnHeaderTooltipOnReceivingStep(
'Expiration date'
);
await receivingPage.assertColumnHeaderTooltipOnReceivingStep(
'Bin Location'
);
await receivingPage.assertColumnHeaderTooltipOnReceivingStep('Recipient');
await receivingPage.assertColumnHeaderTooltipOnReceivingStep('Shipped');
await receivingPage.assertColumnHeaderTooltipOnReceivingStep(
'Receiving now'
);
await receivingPage.assertColumnHeaderTooltipOnReceivingStep('Comment');
});

await test.step('Assert product in receiving table', async () => {
const item = await mainProductService.getProduct();
const item2 = await otherProductService.getProduct();
await receivingPage.receivingStep.table.row(1).getItem(item.name).hover();
await expect(receivingPage.tooltip).toContainText(item.name);
await receivingPage.receivingStep.table
.row(2)
.getItem(item2.name)
.hover();
await expect(receivingPage.tooltip).toContainText(item2.name);
});

await test.step('Select item to receive', async () => {
await receivingPage.receivingStep.isLoaded();
await receivingPage.receivingStep.table
.row(1)
.receivingNowField.textbox.fill('20');
});

await test.step('Try to go to next page', async () => {
await receivingPage.nextButton.click();
});

await test.step('Assert Confirm receiving dialog', async () => {
await expect(
receivingPage.receivingStep.confirmReceivingDialog
).toBeVisible();
});

await test.step('Select No on Confirm receiving dialog', async () => {
await receivingPage.receivingStep.rejectConfirmReceivingDialog.click();
});

await test.step('Assert receiving page is visible ', async () => {
await receivingPage.receivingStep.isLoaded();
await expect(
receivingPage.receivingStep.table.row(1).receivingNowField.textbox
).toHaveValue('20');
});
});

test('Assert Confirm receiving dialog and select Yes, receive 1 item fully', async ({
stockMovementShowPage,
receivingPage,
supplierLocationService,
depotLocationService,
mainProductService,
otherProductService,
authService,
}) => {
await test.step('Go to stock movement show page', async () => {
await authService.changeLocation(AppConfig.instance.locations.depot.id);
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
await stockMovementShowPage.isLoaded();
});

await test.step('Go to shipment receiving page', async () => {
await stockMovementShowPage.receiveButton.click();
await receivingPage.receivingStep.isLoaded();
});

await test.step('Select items to receive', async () => {
await receivingPage.receivingStep.isLoaded();
await receivingPage.receivingStep.table
.row(1)
.receivingNowField.textbox.fill('20');
});

await test.step('Try to go to next page', async () => {
await receivingPage.nextButton.click();
});

await test.step('Assert Confirm receiving dialog', async () => {
await expect(
receivingPage.receivingStep.confirmReceivingDialog
).toBeVisible();
});

await test.step('Select Yes on Confirm receiving dialog', async () => {
await receivingPage.receivingStep.acceptConfirmReceivingDialog.click();
});

await test.step('Assert checking page is visible ', async () => {
await receivingPage.checkStep.isLoaded();
});

await test.step('Assert header on checking page', async () => {
const supplierLocation = await supplierLocationService.getLocation();
const depotLocation = await depotLocationService.getLocation();
await receivingPage.checkStep.isLoaded();
await receivingPage.assertHeaderIsVisible({
origin: supplierLocation.name,
destination: depotLocation.name,
description: description,
date: formatDate(dateRequested),
});
});

await test.step('Assert table column headers on checking page', async () => {
await receivingPage.assertColumnHeaderTooltipOnCheckingStep(
'Pack level 1'
);
await receivingPage.assertColumnHeaderTooltipOnCheckingStep(
'Pack level 2'
);
await receivingPage.assertColumnHeaderTooltipOnCheckingStep('Code');
await receivingPage.assertColumnHeaderTooltipOnCheckingStep('Product');
await receivingPage.assertColumnHeaderTooltipOnCheckingStep(
'Lot/Serial No.'
);
await receivingPage.assertColumnHeaderTooltipOnCheckingStep(
'Expiration date'
);
await receivingPage.assertColumnHeaderTooltipOnCheckingStep(
'Bin Location'
);
await receivingPage.assertColumnHeaderTooltipOnCheckingStep('Recipient');
await receivingPage.assertColumnHeaderTooltipOnCheckingStep(
'Receiving now'
);
await receivingPage.assertColumnHeaderTooltipOnCheckingStep('Remaining');
await receivingPage.assertColumnHeaderTooltipOnCheckingStep('Comment');
});

await test.step('Assert product in checking table', async () => {
const item = await mainProductService.getProduct();
const item2 = await otherProductService.getProduct();
await receivingPage.checkStep.table.row(1).getItem(item.name).hover();
await expect(receivingPage.tooltip).toContainText(item.name);
await receivingPage.receivingStep.table
.row(2)
.getItem(item2.name)
.hover();
await expect(receivingPage.tooltip).toContainText(item2.name);
});

await test.step('Assert receiving now and remaining qty on checking table', async () => {
await receivingPage.checkStep.isLoaded();
await expect(
receivingPage.checkStep.table.getCellValue(1, 'Receiving now')
).toContainText('20');
await expect(
receivingPage.checkStep.table.getCellValue(1, 'Remaining')
).toContainText('0');
await expect(
receivingPage.checkStep.table.getCellValue(2, 'Receiving now')
).toContainText('0');
await expect(
receivingPage.checkStep.table.getCellValue(2, 'Remaining')
).toContainText('10');
});

await test.step('Receive shipment', async () => {
await receivingPage.checkStep.isLoaded();
await receivingPage.checkStep.receiveShipmentButton.click();
await stockMovementShowPage.isLoaded();
});
});

test('Assert Confirm receiving dialog not visible when receive all items, 1 partially', async ({
stockMovementShowPage,
receivingPage,
authService,
}) => {
await test.step('Go to stock movement show page', async () => {
await authService.changeLocation(AppConfig.instance.locations.depot.id);
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
await stockMovementShowPage.isLoaded();
});

await test.step('Go to shipment receiving page', async () => {
await stockMovementShowPage.receiveButton.click();
await receivingPage.receivingStep.isLoaded();
});

await test.step('Select items to receive', async () => {
await receivingPage.receivingStep.isLoaded();
await receivingPage.receivingStep.table
.row(1)
.receivingNowField.textbox.fill('15');
await receivingPage.receivingStep.isLoaded();
await receivingPage.receivingStep.table
.row(2)
.receivingNowField.textbox.fill('10');
});

await test.step('Try to go to next page', async () => {
await receivingPage.nextButton.click();
});

await test.step('Assert Confirm receiving dialog', async () => {
await expect(
receivingPage.receivingStep.confirmReceivingDialog
).not.toBeVisible();
});

await test.step('Assert checking page is visible ', async () => {
await receivingPage.checkStep.isLoaded();
});

await test.step('Assert receiving now and remaining qty on checking table', async () => {
await receivingPage.checkStep.isLoaded();
await expect(
receivingPage.checkStep.table.getCellValue(1, 'Receiving now')
).toContainText('15');
await expect(
receivingPage.checkStep.table.getCellValue(1, 'Remaining')
).toContainText('5');
await expect(
receivingPage.checkStep.table.getCellValue(2, 'Receiving now')
).toContainText('10');
await expect(
receivingPage.checkStep.table.getCellValue(2, 'Remaining')
).toContainText('0');
});

await test.step('Receive shipment', async () => {
await receivingPage.checkStep.isLoaded();
await receivingPage.checkStep.receiveShipmentButton.click();
await stockMovementShowPage.isLoaded();
});
});
});
Loading