Skip to content

Commit 8539d86

Browse files
authored
Merge pull request #64 from openboxes/OBPIH-7530
OBPIH-7530 add test for behavior of rollback last receipt button when putaway created
2 parents 018c6bb + f15c2e0 commit 8539d86

File tree

8 files changed

+271
-1
lines changed

8 files changed

+271
-1
lines changed

src/components/Navbar.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ class Navbar extends BasePageModel {
9292
return this.getNavItem('Create Putaway');
9393
}
9494

95+
get listPutaways() {
96+
return this.getNavItem('List Putaways');
97+
}
98+
9599
get transactions() {
96100
return this.getNavItem('Transactions');
97101
}

src/fixtures/fixtures.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import PersonsListPage from '@/pages/people/PersonsListPage';
3131
import CreateProductPage from '@/pages/product/CreateProductPage';
3232
import ProductShowPage from '@/pages/product/productShow/ProductShowPage';
3333
import CreatePutawayPage from '@/pages/putaway/CreatePutawayPage';
34+
import PutawayListPage from '@/pages/putaway/list/PutawayListPage';
3435
import PutawayDetailsPage from '@/pages/putaway/putawayDetails/PutawayDetailsPage';
3536
import ReceivingPage from '@/pages/receiving/ReceivingPage';
3637
import OldViewShipmentPage from '@/pages/stockMovementShow/OldViewShipmentPage';
@@ -71,6 +72,7 @@ type Fixtures = {
7172
putawayDetailsPage: PutawayDetailsPage;
7273
transactionListPage: TransactionListPage;
7374
oldViewShipmentPage: OldViewShipmentPage;
75+
putawayListPage: PutawayListPage;
7476
// COMPONENTS
7577
navbar: Navbar;
7678
locationChooser: LocationChooser;
@@ -145,6 +147,7 @@ export const test = baseTest.extend<Fixtures>({
145147
use(new TransactionListPage(page)),
146148
oldViewShipmentPage: async ({ page }, use) =>
147149
use(new OldViewShipmentPage(page)),
150+
putawayListPage: async ({ page }, use) => use(new PutawayListPage(page)),
148151
// COMPONENTS
149152
navbar: async ({ page }, use) => use(new Navbar(page)),
150153
locationChooser: async ({ page }, use) => use(new LocationChooser(page)),
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { expect, Page } from '@playwright/test';
2+
3+
import BasePageModel from '@/pages/BasePageModel';
4+
5+
import PutawayListTable from './PutawayListTable';
6+
7+
class PutawayListPage extends BasePageModel {
8+
table: PutawayListTable;
9+
10+
constructor(page: Page) {
11+
super(page);
12+
13+
this.table = new PutawayListTable(page);
14+
}
15+
16+
async goToPage(status = 'PENDING') {
17+
await this.page.goto(
18+
'./order/list?orderType=PUTAWAY_ORDER&status=' + `${status}`
19+
);
20+
}
21+
22+
async isLoaded() {
23+
await expect(
24+
this.page.getByRole('heading').getByText('List Putaways')
25+
).toBeVisible();
26+
}
27+
}
28+
29+
export default PutawayListPage;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Locator, Page } from '@playwright/test';
2+
3+
import BasePageModel from '@/pages/BasePageModel';
4+
5+
class PutawayListTable extends BasePageModel {
6+
get table() {
7+
return this.page.getByRole('table');
8+
}
9+
10+
get rows() {
11+
return this.table.getByRole('row');
12+
}
13+
14+
row(index: number) {
15+
return new Row(this.page, this.rows.nth(index));
16+
}
17+
18+
get viewOrderDetailsButton() {
19+
return this.page
20+
.locator('.action-menu-item')
21+
.getByRole('link', { name: 'View order details' });
22+
}
23+
}
24+
25+
class Row extends BasePageModel {
26+
row: Locator;
27+
28+
constructor(page: Page, row: Locator) {
29+
super(page);
30+
this.row = row;
31+
}
32+
33+
get actionsButton() {
34+
return this.row.getByTestId('action-menu-0');
35+
}
36+
}
37+
export default PutawayListTable;

src/pages/putaway/putawayDetails/PutawayDetailsPage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class PutawayDetailsPage extends BasePageModel {
5151
}
5252

5353
get editButton() {
54-
return this.page.getByRole('button', { name: 'Edit Putaway' });
54+
return this.page.getByRole('link', { name: 'Edit Putaway' });
5555
}
5656
}
5757

src/pages/putaway/steps/StartStep.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ class StartStep extends BasePageModel {
1919
get nextButton() {
2020
return this.page.getByTestId('next-button');
2121
}
22+
23+
get saveButton() {
24+
return this.page.getByTestId('save-button');
25+
}
2226
}
2327

2428
export default StartStep;

src/pages/stockMovementShow/StockMovementShowPage.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ class StockMovementShowPage extends BasePageModel {
102102
return this.page.locator('div.error');
103103
}
104104

105+
get rollbackReceiptInformationMessage() {
106+
return this.page.getByRole('status', { name: 'message' });
107+
}
108+
105109
async clickDeleteShipment() {
106110
this.page.once('dialog', (dialog) => dialog.accept());
107111
await this.deleteButton.click();
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
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('Rollback last receipt behavior when putaway created', () => {
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+
navbar,
58+
transactionListPage,
59+
oldViewShipmentPage,
60+
}) => {
61+
await navbar.configurationButton.click();
62+
await navbar.transactions.click();
63+
await transactionListPage.table.row(1).actionsButton.click();
64+
await transactionListPage.table.deleteButton.click();
65+
await expect(transactionListPage.successMessage).toBeVisible();
66+
await transactionListPage.table.row(1).actionsButton.click();
67+
await transactionListPage.table.deleteButton.click();
68+
await expect(transactionListPage.successMessage).toBeVisible();
69+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
70+
await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click();
71+
await oldViewShipmentPage.undoStatusChangeButton.click();
72+
await stockMovementShowPage.isLoaded();
73+
await stockMovementShowPage.rollbackButton.click();
74+
await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id);
75+
}
76+
);
77+
78+
test('Rollback last receipt behavior when putaway created', async ({
79+
stockMovementShowPage,
80+
navbar,
81+
createPutawayPage,
82+
internalLocationService,
83+
receivingPage,
84+
putawayListPage,
85+
putawayDetailsPage,
86+
}) => {
87+
await test.step('Go to stock movement show page and assert received status', async () => {
88+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
89+
await stockMovementShowPage.isLoaded();
90+
await expect(stockMovementShowPage.statusTag).toHaveText('Received');
91+
await navbar.profileButton.click();
92+
await navbar.refreshCachesButton.click();
93+
});
94+
95+
await test.step('Go to create putaway page', async () => {
96+
await navbar.inbound.click();
97+
await navbar.createPutaway.click();
98+
await createPutawayPage.isLoaded();
99+
});
100+
101+
await test.step('Start putaway', async () => {
102+
await createPutawayPage.table.row(0).checkbox.click();
103+
await createPutawayPage.startPutawayButton.click();
104+
await createPutawayPage.startStep.isLoaded();
105+
});
106+
107+
await test.step('Select bin to putaway', async () => {
108+
const internalLocation = await internalLocationService.getLocation();
109+
await createPutawayPage.startStep.table.row(0).putawayBinSelect.click();
110+
await createPutawayPage.startStep.table
111+
.row(0)
112+
.getPutawayBin(internalLocation.name)
113+
.click();
114+
});
115+
116+
await test.step('Save progress on pending putaway', async () => {
117+
await createPutawayPage.startStep.saveButton.click();
118+
});
119+
120+
await test.step('Go to stock movement show page and rollback last receipt when pending putaway created', async () => {
121+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
122+
await stockMovementShowPage.isLoaded();
123+
await expect(stockMovementShowPage.statusTag).toHaveText('Received');
124+
await stockMovementShowPage.rollbackLastReceiptButton.click();
125+
await expect(
126+
stockMovementShowPage.rollbackReceiptInformationMessage
127+
).toBeVisible();
128+
await expect(
129+
stockMovementShowPage.rollbackReceiptInformationMessage
130+
).toContainText(
131+
'Successfully rolled back last receipt in stock movement '
132+
);
133+
await expect(stockMovementShowPage.statusTag).toHaveText('Shipped');
134+
});
135+
136+
await test.step('Receive sm', async () => {
137+
await stockMovementShowPage.receiveButton.click();
138+
await receivingPage.receivingStep.isLoaded();
139+
await receivingPage.receivingStep.autofillQuantitiesButton.click();
140+
await receivingPage.nextButton.click();
141+
await receivingPage.checkStep.isLoaded();
142+
await receivingPage.checkStep.receiveShipmentButton.click();
143+
await stockMovementShowPage.isLoaded();
144+
await expect(stockMovementShowPage.statusTag).toHaveText('Received');
145+
});
146+
147+
await test.step('Go to putaway list page', async () => {
148+
await navbar.inbound.click();
149+
await navbar.listPutaways.click();
150+
await putawayListPage.isLoaded();
151+
});
152+
153+
await test.step('Open putaway detials page', async () => {
154+
await putawayListPage.table.row(1).actionsButton.click();
155+
await putawayListPage.table.viewOrderDetailsButton.click();
156+
await putawayDetailsPage.isLoaded();
157+
});
158+
159+
await test.step('Edit pending putaway', async () => {
160+
await putawayDetailsPage.editButton.click();
161+
await createPutawayPage.startStep.isLoaded();
162+
await createPutawayPage.startStep.nextButton.click();
163+
});
164+
165+
await test.step('Go to next page and complete putaway', async () => {
166+
await createPutawayPage.completeStep.isLoaded();
167+
await createPutawayPage.completeStep.completePutawayButton.click();
168+
});
169+
170+
await test.step('Assert completing putaway', async () => {
171+
await putawayDetailsPage.isLoaded();
172+
await expect(putawayDetailsPage.statusTag).toHaveText('Completed');
173+
});
174+
175+
await test.step('Go to stock movement show page and rollback last receipt when completed putaway created', async () => {
176+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
177+
await stockMovementShowPage.isLoaded();
178+
await expect(stockMovementShowPage.statusTag).toHaveText('Received');
179+
await stockMovementShowPage.rollbackLastReceiptButton.click();
180+
await expect(
181+
stockMovementShowPage.rollbackReceiptInformationMessage
182+
).toBeVisible();
183+
await expect(
184+
stockMovementShowPage.rollbackReceiptInformationMessage
185+
).toContainText('Unable to rollback last receipt in stock movement');
186+
await expect(stockMovementShowPage.statusTag).toHaveText('Received');
187+
});
188+
});
189+
});

0 commit comments

Comments
 (0)