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-6882: Fix for Export all items empty db case #30

Merged
merged 4 commits into from
Jan 13, 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
4 changes: 2 additions & 2 deletions src/fixtures/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import AppConfig, {
} from '@/config/AppConfig';
import CreateInbound from '@/pages/inbound/create/CreateInboundPage';
import InboundListPage from '@/pages/inbound/list/InboundListPage';
import CreateInvoicePage from '@/pages/invoice/CreateInvoicePage';
import InvoiceListPage from '@/pages/invoice/InvoiceListPage';
import CreateLocationPage from '@/pages/location/createLocation/CreateLocationPage';
import LocationListPage from '@/pages/location/LocationListPage';
import CreateLocationGroupPage from '@/pages/locationGroup/CreateLocationGroupPage';
Expand All @@ -33,8 +35,6 @@ import UserListPage from '@/pages/user/UserListPage';
import LocationData from '@/utils/LocationData';
import ProductData from '@/utils/ProductData';
import UserData from '@/utils/UserData';
import CreateInvoicePage from '@/pages/invoice/CreateInvoicePage';
import InvoiceListPage from '@/pages/invoice/InvoiceListPage';

type Fixtures = {
// PAGES
Expand Down
4 changes: 4 additions & 0 deletions src/pages/inbound/list/InboundStockMovementTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class InboundStockMovementTable extends BasePageModel {
get allDateCreatedColumnCells() {
return this.table.locator('[role="row"] [role="gridcell"]:nth-child(9)');
}

get emptyInboundList() {
return this.table.locator('.rt-noData');
}
}

class Row extends BasePageModel {
Expand Down
132 changes: 95 additions & 37 deletions src/tests/inbound/createInbound/exportItems.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { WorkbookUtils } from '@/utils/WorkbookUtils';

test.describe('Export all incoming items', () => {
let INBOUND_ID: string;
let INBOUND2_ID: string;
const workbooks: WorkbookUtils[] = [];

test.beforeEach(
Expand All @@ -13,19 +14,20 @@ test.describe('Export all incoming items', () => {
mainProductService,
mainUserService,
otherProductService,
stockMovementShowPage
stockMovementShowPage,
inboundListPage,
}) => {
const ORIGIN = await supplierLocationService.getLocation();
const DESCRIPTION = 'some description';
const USER = await mainUserService.getUser();
const TODAY = getToday();

const PRODUCT_ONE = await mainProductService.getProduct();
const PRODUCT_TWO = await otherProductService.getProduct();
const SHIPMENT_TYPE = 'Land';
const EXPECTED_DELIVERY_DATE = getDateByOffset(TODAY, 1);
const ROWS = [

const ROWS1 = [
{
product: {
productCode: PRODUCT_ONE.productCode,
Expand All @@ -42,11 +44,62 @@ test.describe('Export all incoming items', () => {
},
];

const ROWS2 = [
{
product: {
productCode: PRODUCT_ONE.productCode,
productName: PRODUCT_ONE.name,
},
quantity: '10',
},
];

await inboundListPage.goToPage();
const ifInboundListPageIsEmpty =
await inboundListPage.table.emptyInboundList.isVisible();

if (ifInboundListPageIsEmpty) {
await test.step('Create and ship stock movement when inbound list is empty', async () => {
await createInboundPage.goToPage();
await createInboundPage.createStep.originSelect.findAndSelectOption(
ORIGIN.name
);
await createInboundPage.createStep.requestedBySelect.findAndSelectOption(
USER.name
);
await createInboundPage.createStep.dateRequestedDatePicker.fill(
TODAY
);
await createInboundPage.createStep.descriptionField.textbox.fill(
DESCRIPTION
);
await createInboundPage.nextButton.click();
await createInboundPage.addItemsStep.isLoaded();
await createInboundPage.wizzardSteps.assertActiveStep('Add items');

INBOUND2_ID = createInboundPage.getId();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need to declare the INBOUND2_ID as a let? I don't see you are overriding this value, but maybe I am missing something

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise it'd need to be initialized in a different place, so I guess it is fine. Plus I see this is done like that in other places as well.


await createInboundPage.addItemsStep.addItems(ROWS2);
await createInboundPage.nextButton.click();
await createInboundPage.sendStep.isLoaded();

await createInboundPage.sendStep.shipmentTypeSelect.findAndSelectOption(
SHIPMENT_TYPE
);
await createInboundPage.sendStep.expectedDeliveryDatePicker.fill(
EXPECTED_DELIVERY_DATE
);
await createInboundPage.sendStep.sendShipmentButton.click();
await stockMovementShowPage.waitForUrl();
await stockMovementShowPage.isLoaded();
});
}

await test.step('Go to create stock movement', async () => {
await createInboundPage.goToPage();
await createInboundPage.createStep.isLoaded();
});

await test.step('Create Stock Movement step', async () => {
await createInboundPage.createStep.originSelect.findAndSelectOption(
ORIGIN.name
Expand All @@ -59,21 +112,21 @@ test.describe('Export all incoming items', () => {
DESCRIPTION
);
});

await test.step('Go next step (Add items)', async () => {
await createInboundPage.nextButton.click();
await createInboundPage.addItemsStep.isLoaded();
});

INBOUND_ID = createInboundPage.getId();
await createInboundPage.addItemsStep.addItems(ROWS);

await createInboundPage.addItemsStep.addItems(ROWS1);

await test.step('Go to next step (Send)', async () => {
await createInboundPage.nextButton.click();
await createInboundPage.sendStep.isLoaded();
});

await test.step('Fill shipment fields (Send)', async () => {
await createInboundPage.sendStep.shipmentTypeSelect.findAndSelectOption(
SHIPMENT_TYPE
Expand All @@ -88,37 +141,44 @@ test.describe('Export all incoming items', () => {
await stockMovementShowPage.waitForUrl();
await stockMovementShowPage.isLoaded();
});

}
);

test.afterEach(async ({ stockMovementService, stockMovementShowPage }) => {
await stockMovementShowPage.goToPage(INBOUND_ID);
await stockMovementShowPage.isLoaded();
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();
}
test.afterEach(
async ({ stockMovementService, stockMovementShowPage, page }) => {
await stockMovementShowPage.goToPage(INBOUND_ID);
await stockMovementShowPage.isLoaded();
const isRollbackLastReceiptButtonVisible =
await stockMovementShowPage.rollbackLastReceiptButton.isVisible();
const isRollbackButtonVisible =
await stockMovementShowPage.rollbackButton.isVisible();

if (isRollbackButtonVisible) {
await stockMovementShowPage.rollbackButton.click();
}
// 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 stockMovementService.deleteStockMovement(INBOUND_ID);

await stockMovementService.deleteStockMovement(INBOUND_ID);
for (const workbook of workbooks) {
workbook.delete();
}

for (const workbook of workbooks) {
workbook.delete();
if (INBOUND2_ID) {
await stockMovementShowPage.goToPage(INBOUND2_ID);
await stockMovementShowPage.isLoaded();
await stockMovementShowPage.rollbackButton.click();
await stockMovementService.deleteStockMovement(INBOUND2_ID);
}
}
});
);

test('Export all incoming items should include shipped items', async ({
inboundListPage,
stockMovementShowPage,
stockMovementService,
}) => {
await test.step('Go to inbound list page', async () => {
Expand Down Expand Up @@ -211,7 +271,7 @@ test.describe('Export all incoming items', () => {
});

// TODO: Adjust to rely on the empty database (on empty db it fails, because there is 404 No shipment items found)
test.skip('Export all incoming items should not include received items', async ({
test('Export all incoming items should not include received items', async ({
inboundListPage,
stockMovementShowPage,
stockMovementService,
Expand All @@ -233,8 +293,8 @@ test.describe('Export all incoming items', () => {
await test.step('Select item to receive', async () => {
await receivingPage.receivingStep.isLoaded();
await receivingPage.receivingStep.table
.row(1)
.receivingNowField.textbox.fill('12');
.row(1)
.receivingNowField.textbox.fill('12');
await receivingPage.receivingStep.table
.row(2)
.receivingNowField.textbox.fill('12');
Expand Down Expand Up @@ -274,6 +334,4 @@ test.describe('Export all incoming items', () => {
expect(stockMovementItemsFromFile).toHaveLength(0);
});
});


});
Loading