Skip to content

Commit f00d68a

Browse files
authored
Merge pull request #68 from openboxes/OBPIH-7532
OBPIH-7532: Add test to change locations on putaway pages
2 parents 31e2239 + baaaa9e commit f00d68a

File tree

4 files changed

+216
-0
lines changed

4 files changed

+216
-0
lines changed

src/pages/putaway/components/CreatePutawayTable.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ class Row extends BasePageModel {
3838
.getByText(binLocation);
3939
}
4040

41+
get receivingBin() {
42+
return this.row.getByTestId('cell-undefined-undefined');
43+
}
44+
4145
getProductName(name: string) {
4246
return this.row.getByTestId('table-cell').getByText(name);
4347
}

src/pages/putaway/list/PutawayListPage.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ class PutawayListPage extends BasePageModel {
6060
get clearFilteringButton() {
6161
return this.filters.getByTestId('cancel-button');
6262
}
63+
64+
get emptyPutawayList() {
65+
return this.page
66+
.locator('.empty fade center')
67+
.getByText('No orders match the given criteria');
68+
}
6369
}
6470

6571
export default PutawayListPage;

src/pages/putaway/list/PutawayListTable.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ class PutawayListTable extends BasePageModel {
2020
.locator('.action-menu-item')
2121
.getByRole('link', { name: 'View order details' });
2222
}
23+
24+
get deleteOrderButton() {
25+
return this.page
26+
.locator('.action-menu-item')
27+
.getByRole('link', { name: 'Delete Order' });
28+
}
29+
30+
async clickDeleteOrderButton() {
31+
this.page.once('dialog', (dialog) => dialog.accept());
32+
await this.deleteOrderButton.click();
33+
}
2334
}
2435

2536
class Row extends BasePageModel {
@@ -37,5 +48,9 @@ class Row extends BasePageModel {
3748
get statusTag() {
3849
return this.row.getByTestId('status-0');
3950
}
51+
52+
get orderNumber() {
53+
return this.row.getByTestId('order-number-0');
54+
}
4055
}
4156
export default PutawayListTable;
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
import AppConfig from '@/config/AppConfig';
2+
import { ShipmentType } from '@/constants/ShipmentType';
3+
import { expect, test } from '@/fixtures/fixtures';
4+
import { StockMovementResponse } from '@/types';
5+
import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils';
6+
7+
test.describe('Change location on putaway create page and list pages', () => {
8+
let STOCK_MOVEMENT: StockMovementResponse;
9+
10+
test.beforeEach(
11+
async ({
12+
supplierLocationService,
13+
stockMovementService,
14+
fifthProductService,
15+
receivingService,
16+
}) => {
17+
const supplierLocation = await supplierLocationService.getLocation();
18+
STOCK_MOVEMENT = await stockMovementService.createInbound({
19+
originId: supplierLocation.id,
20+
});
21+
22+
const product = await fifthProductService.getProduct();
23+
24+
await stockMovementService.addItemsToInboundStockMovement(
25+
STOCK_MOVEMENT.id,
26+
[{ productId: product.id, quantity: 10 }]
27+
);
28+
29+
await stockMovementService.sendInboundStockMovement(STOCK_MOVEMENT.id, {
30+
shipmentType: ShipmentType.AIR,
31+
});
32+
33+
const { data: stockMovement } =
34+
await stockMovementService.getStockMovement(STOCK_MOVEMENT.id);
35+
const shipmentId = getShipmentId(stockMovement);
36+
const { data: receipt } = await receivingService.getReceipt(shipmentId);
37+
const receivingBin =
38+
AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;
39+
40+
await receivingService.createReceivingBin(shipmentId, receipt);
41+
42+
await receivingService.updateReceivingItems(shipmentId, [
43+
{
44+
shipmentItemId: getShipmentItemId(receipt, 0, 0),
45+
quantityReceiving: 10,
46+
binLocationName: receivingBin,
47+
},
48+
]);
49+
await receivingService.completeReceipt(shipmentId);
50+
}
51+
);
52+
53+
test.afterEach(
54+
async ({
55+
stockMovementShowPage,
56+
stockMovementService,
57+
putawayListPage,
58+
oldViewShipmentPage,
59+
}) => {
60+
await putawayListPage.goToPage();
61+
await putawayListPage.table.row(1).actionsButton.click();
62+
await putawayListPage.table.clickDeleteOrderButton();
63+
await putawayListPage.emptyPutawayList.isVisible();
64+
65+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
66+
await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click();
67+
await oldViewShipmentPage.undoStatusChangeButton.click();
68+
await stockMovementShowPage.isLoaded();
69+
await stockMovementShowPage.rollbackButton.click();
70+
71+
await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id);
72+
}
73+
);
74+
75+
test('Change location on putaway create page and list page', async ({
76+
stockMovementShowPage,
77+
navbar,
78+
createPutawayPage,
79+
locationChooser,
80+
fifthProductService,
81+
depotLocationService,
82+
mainLocationService,
83+
putawayListPage,
84+
authService,
85+
}) => {
86+
const receivingBin =
87+
AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;
88+
const product = await fifthProductService.getProduct();
89+
const mainLocation = await mainLocationService.getLocation();
90+
const depotLocation = await depotLocationService.getLocation();
91+
92+
await test.step('Go to stock movement show page and assert received status', async () => {
93+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
94+
await stockMovementShowPage.isLoaded();
95+
await expect(stockMovementShowPage.statusTag).toHaveText('Received');
96+
await navbar.profileButton.click();
97+
await navbar.refreshCachesButton.click();
98+
});
99+
100+
await test.step('Go to create putaway page and assert its content', async () => {
101+
await createPutawayPage.goToPage();
102+
await createPutawayPage.isLoaded();
103+
await expect(createPutawayPage.table.row(0).receivingBin).toContainText(
104+
receivingBin
105+
);
106+
await createPutawayPage.table
107+
.row(0)
108+
.getExpandBinLocation(receivingBin)
109+
.click();
110+
await expect(
111+
createPutawayPage.table.row(1).getProductName(product.name)
112+
).toBeVisible();
113+
});
114+
115+
await test.step('Change location to another depot', async () => {
116+
await navbar.locationChooserButton.click();
117+
await locationChooser
118+
.getOrganization(depotLocation.organization?.name as string)
119+
.click();
120+
await locationChooser.getLocation(depotLocation.name).click();
121+
await navbar.profileButton.click();
122+
await navbar.refreshCachesButton.click();
123+
await createPutawayPage.goToPage();
124+
await expect(createPutawayPage.emptyCreatePageInformation).toBeVisible();
125+
await expect(
126+
createPutawayPage.table.row(0).getExpandBinLocation(receivingBin)
127+
).toBeHidden();
128+
});
129+
130+
await test.step('Return to main location and create pending putaway', async () => {
131+
await navbar.locationChooserButton.click();
132+
await locationChooser
133+
.getOrganization(mainLocation.organization?.name as string)
134+
.click();
135+
await locationChooser.getLocation(mainLocation.name).click();
136+
await navbar.profileButton.click();
137+
await navbar.refreshCachesButton.click();
138+
await createPutawayPage.goToPage();
139+
await createPutawayPage.table
140+
.row(0)
141+
.getExpandBinLocation(receivingBin)
142+
.click();
143+
await createPutawayPage.table.row(1).checkbox.click();
144+
await createPutawayPage.startPutawayButton.click();
145+
await createPutawayPage.startStep.isLoaded();
146+
await createPutawayPage.startStep.saveButton.click();
147+
});
148+
149+
await test.step('Go to list page and assert putaway is created', async () => {
150+
await putawayListPage.goToPage();
151+
await putawayListPage.isLoaded();
152+
await expect(putawayListPage.table.row(1).statusTag).toHaveText(
153+
'Pending'
154+
);
155+
});
156+
157+
const putawayOrderIdentifier = await putawayListPage.table
158+
.row(1)
159+
.orderNumber.textContent();
160+
161+
await test.step('Change location to another depot', async () => {
162+
await navbar.locationChooserButton.click();
163+
await locationChooser
164+
.getOrganization(depotLocation.organization?.name as string)
165+
.click();
166+
await locationChooser.getLocation(depotLocation.name).click();
167+
await putawayListPage.goToPage();
168+
await putawayListPage.searchField.fill(
169+
`${putawayOrderIdentifier}`.toString().trim()
170+
);
171+
await putawayListPage.searchButton.click();
172+
await putawayListPage.emptyPutawayList.isVisible();
173+
});
174+
175+
await test.step('Go to putaway list page and assert pending putaway not visible in other location', async () => {
176+
await putawayListPage.goToPage();
177+
await expect(putawayListPage.destinationFilter).toContainText(
178+
depotLocation.name
179+
);
180+
await putawayListPage.searchField.fill(
181+
`${putawayOrderIdentifier}`.toString().trim()
182+
);
183+
await putawayListPage.searchButton.click();
184+
await putawayListPage.emptyPutawayList.isVisible();
185+
});
186+
187+
await test.step('Return to main location', async () => {
188+
await authService.changeLocation(AppConfig.instance.locations.main.id);
189+
});
190+
});
191+
});

0 commit comments

Comments
 (0)