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
4 changes: 4 additions & 0 deletions src/pages/putaway/components/CreatePutawayTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class Row extends BasePageModel {
.getByText(binLocation);
}

get receivingBin() {
return this.row.getByTestId('cell-undefined-undefined');
Copy link
Collaborator

Choose a reason for hiding this comment

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

this -undefined-undefined data-testid should be fixed 😢

}

getProductName(name: string) {
return this.row.getByTestId('table-cell').getByText(name);
}
Expand Down
6 changes: 6 additions & 0 deletions src/pages/putaway/list/PutawayListPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ class PutawayListPage extends BasePageModel {
get clearFilteringButton() {
return this.filters.getByTestId('cancel-button');
}

get emptyPutawayList() {
return this.page
.locator('.empty fade center')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't there a better selector than those coming from Bootstrap?

.getByText('No orders match the given criteria');
}
}

export default PutawayListPage;
15 changes: 15 additions & 0 deletions src/pages/putaway/list/PutawayListTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ class PutawayListTable extends BasePageModel {
.locator('.action-menu-item')
.getByRole('link', { name: 'View order details' });
}

get deleteOrderButton() {
return this.page
.locator('.action-menu-item')
.getByRole('link', { name: 'Delete Order' });
}

async clickDeleteOrderButton() {
this.page.once('dialog', (dialog) => dialog.accept());
await this.deleteOrderButton.click();
}
}

class Row extends BasePageModel {
Expand All @@ -37,5 +48,9 @@ class Row extends BasePageModel {
get statusTag() {
return this.row.getByTestId('status-0');
}

get orderNumber() {
return this.row.getByTestId('order-number-0');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the -0 working? The idea of that was that the number at the end is the row number

}
}
export default PutawayListTable;
191 changes: 191 additions & 0 deletions src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
import AppConfig from '@/config/AppConfig';
import { ShipmentType } from '@/constants/ShipmentType';
import { expect, test } from '@/fixtures/fixtures';
import { StockMovementResponse } from '@/types';
import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils';

test.describe('Change location on putaway create page and list pages', () => {
let STOCK_MOVEMENT: StockMovementResponse;

test.beforeEach(
async ({
supplierLocationService,
stockMovementService,
fifthProductService,
receivingService,
}) => {
const supplierLocation = await supplierLocationService.getLocation();
STOCK_MOVEMENT = await stockMovementService.createInbound({
originId: supplierLocation.id,
});

const product = await fifthProductService.getProduct();

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);
}
);

test.afterEach(
async ({
stockMovementShowPage,
stockMovementService,
putawayListPage,
oldViewShipmentPage,
}) => {
await putawayListPage.goToPage();
await putawayListPage.table.row(1).actionsButton.click();
await putawayListPage.table.clickDeleteOrderButton();
await putawayListPage.emptyPutawayList.isVisible();

await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click();
await oldViewShipmentPage.undoStatusChangeButton.click();
await stockMovementShowPage.isLoaded();
await stockMovementShowPage.rollbackButton.click();

await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id);
}
);

test('Change location on putaway create page and list page', async ({
stockMovementShowPage,
navbar,
createPutawayPage,
locationChooser,
fifthProductService,
depotLocationService,
mainLocationService,
putawayListPage,
authService,
}) => {
const receivingBin =
AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;
const product = await fifthProductService.getProduct();
const mainLocation = await mainLocationService.getLocation();
const depotLocation = await depotLocationService.getLocation();

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 navbar.profileButton.click();
await navbar.refreshCachesButton.click();
});

await test.step('Go to create putaway page and assert its content', async () => {
await createPutawayPage.goToPage();
await createPutawayPage.isLoaded();
await expect(createPutawayPage.table.row(0).receivingBin).toContainText(
receivingBin
);
await createPutawayPage.table
.row(0)
.getExpandBinLocation(receivingBin)
.click();
await expect(
createPutawayPage.table.row(1).getProductName(product.name)
).toBeVisible();
});

await test.step('Change location to another depot', async () => {
await navbar.locationChooserButton.click();
await locationChooser
.getOrganization(depotLocation.organization?.name as string)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is it cast to a string? I think here we should be sure that the name is not null, so the type casting shouldn't be required

.click();
await locationChooser.getLocation(depotLocation.name).click();
await navbar.profileButton.click();
await navbar.refreshCachesButton.click();
await createPutawayPage.goToPage();
await expect(createPutawayPage.emptyCreatePageInformation).toBeVisible();
await expect(
createPutawayPage.table.row(0).getExpandBinLocation(receivingBin)
).toBeHidden();
});

await test.step('Return to main location and create pending putaway', async () => {
await navbar.locationChooserButton.click();
await locationChooser
.getOrganization(mainLocation.organization?.name as string)
.click();
await locationChooser.getLocation(mainLocation.name).click();
await navbar.profileButton.click();
await navbar.refreshCachesButton.click();
await createPutawayPage.goToPage();
await createPutawayPage.table
.row(0)
.getExpandBinLocation(receivingBin)
.click();
await createPutawayPage.table.row(1).checkbox.click();
await createPutawayPage.startPutawayButton.click();
await createPutawayPage.startStep.isLoaded();
await createPutawayPage.startStep.saveButton.click();
});

await test.step('Go to list page and assert putaway is created', async () => {
await putawayListPage.goToPage();
await putawayListPage.isLoaded();
await expect(putawayListPage.table.row(1).statusTag).toHaveText(
'Pending'
);
});

const putawayOrderIdentifier = await putawayListPage.table
.row(1)
.orderNumber.textContent();

await test.step('Change location to another depot', async () => {
await navbar.locationChooserButton.click();
await locationChooser
.getOrganization(depotLocation.organization?.name as string)
.click();
await locationChooser.getLocation(depotLocation.name).click();
await putawayListPage.goToPage();
await putawayListPage.searchField.fill(
`${putawayOrderIdentifier}`.toString().trim()
);
await putawayListPage.searchButton.click();
await putawayListPage.emptyPutawayList.isVisible();
});

await test.step('Go to putaway list page and assert pending putaway not visible in other location', async () => {
await putawayListPage.goToPage();
await expect(putawayListPage.destinationFilter).toContainText(
depotLocation.name
);
await putawayListPage.searchField.fill(
`${putawayOrderIdentifier}`.toString().trim()
);
await putawayListPage.searchButton.click();
await putawayListPage.emptyPutawayList.isVisible();
});

await test.step('Return to main location', async () => {
await authService.changeLocation(AppConfig.instance.locations.main.id);
});
Comment on lines +187 to +189
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't you somehow check if that redirect works?

});
});
Loading