Skip to content

Commit 464cfdc

Browse files
authored
OBPIH-7694 refactor putaway page tests to use consistent test IDs and improve readability (#74)
1 parent ae52071 commit 464cfdc

15 files changed

Lines changed: 69 additions & 91 deletions

src/pages/putaway/CreatePutawayPage.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ class CreatePutawayPage extends BasePageModel {
4343
}
4444

4545
get linesInPendingPutawayFilter() {
46-
return this.page
47-
.locator('#select-id_1 div')
48-
.filter({ hasText: 'Exclude' })
49-
.nth(1);
46+
return this.page.getByTestId('custom-select-element');
5047
}
5148

5249
get includeLinesInPendingPutawayFilter() {

src/pages/putaway/components/CompletePutawayTable.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class Row extends BasePageModel {
2828
this.row = row;
2929
}
3030

31-
getputawayBin(rowIndex: number) {
32-
return this.row.getByTestId(`cell-${rowIndex}-undefined`).nth(9);
31+
get putawayBin() {
32+
return this.row.getByTestId('table-cell').nth(10);
3333
}
3434
}
3535

src/pages/putaway/components/CreatePutawayTable.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ class Row extends BasePageModel {
3434

3535
getExpandBinLocation(binLocation: string) {
3636
return this.row
37-
.getByTestId('cell-undefined-undefined')
37+
.getByTestId('table-cell')
3838
.getByText(binLocation);
3939
}
4040

4141
get receivingBin() {
42-
return this.row.getByTestId('cell-undefined-undefined');
42+
return this.row.getByTestId('table-cell');
4343
}
4444

4545
getProductName(name: string) {

src/pages/putaway/components/SplitModal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class SplitModal extends BasePageModel {
1313
}
1414

1515
get modal() {
16-
return this.page.locator('.ReactModal__Content');
16+
return this.page.getByTestId('split-line-modal');
1717
}
1818

1919
async isLoaded() {

src/pages/putaway/components/StartPutawayTable.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,23 @@ class Row extends BasePageModel {
5656
}
5757

5858
getCurrentBin(currentBin: string) {
59-
return this.row.getByTestId('cell-0-currentBin').getByText(currentBin);
59+
return this.row.getByTestId('table-cell').getByText(currentBin);
6060
}
6161

62-
getPreferredBin(rowIndex: number) {
63-
return this.row.getByTestId(`cell-${rowIndex}-preferredBin`);
62+
get preferredBin() {
63+
return this.row.getByTestId('table-cell').nth(8);
6464
}
6565

6666
get quantityField() {
67-
return this.row.getByTestId('cell-0-quantity').getByRole('spinbutton');
67+
return this.row.getByTestId('table-cell').nth(7);
6868
}
6969

70-
get splitLineinPutawayBin() {
71-
return this.row.getByTestId('cell-0-putawayBin');
70+
get quantityInput() {
71+
return this.row.getByTestId('quantity-input')
72+
}
73+
74+
get splitLineInPutawayBin() {
75+
return this.row.getByTestId('open-modal');
7276
}
7377
}
7478

src/pages/putaway/list/PutawayListPage.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,26 @@ class PutawayListPage extends BasePageModel {
2626
}
2727

2828
get filters() {
29-
return this.page.locator('.box');
29+
return this.page.getByTestId('filters')
3030
}
3131

3232
get searchField() {
3333
return this.filters
34-
.locator('.filter-list-item')
3534
.getByTestId('search-input');
3635
}
3736

3837
get orderTypeFilter() {
3938
return this.filters
40-
.locator('.filter-list-item')
4139
.getByTestId('order-type-select');
4240
}
4341

4442
get statusFilter() {
4543
return this.filters
46-
.locator('.filter-list-item')
4744
.getByTestId('status.select');
4845
}
4946

5047
get destinationFilter() {
5148
return this.filters
52-
.locator('.filter-list-item')
5349
.getByTestId('destination-select');
5450
}
5551

@@ -62,9 +58,7 @@ class PutawayListPage extends BasePageModel {
6258
}
6359

6460
get emptyPutawayList() {
65-
return this.page
66-
.locator('.empty fade center')
67-
.getByText('No orders match the given criteria');
61+
return this.page.getByTestId('empty-table');
6862
}
6963
}
7064

src/pages/putaway/list/PutawayListTable.ts

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,9 @@ class PutawayListTable extends BasePageModel {
1515
return new Row(this.page, this.rows.nth(index));
1616
}
1717

18-
get viewOrderDetailsButton() {
19-
return this.page
20-
.locator('.action-menu-item')
21-
.getByRole('link', { name: 'View order details' });
22-
}
23-
24-
get deleteOrderButton() {
25-
return this.page
26-
.locator('.action-menu-item')
27-
.getByRole('link', { name: 'Delete Order' });
28-
}
29-
30-
async clickDeleteOrderButton() {
18+
async clickDeleteOrderButton(index: number) {
3119
this.page.once('dialog', (dialog) => dialog.accept());
32-
await this.deleteOrderButton.click();
33-
}
34-
35-
get emptyPutawayList() {
36-
return this.table
37-
.locator('.empty')
38-
.getByText('No orders match the given criteria');
20+
await this.row(index).deleteOrder.click();
3921
}
4022
}
4123

@@ -48,15 +30,23 @@ class Row extends BasePageModel {
4830
}
4931

5032
get actionsButton() {
51-
return this.row.getByTestId('action-menu-0');
33+
return this.row.getByTestId('action-menu');
5234
}
5335

5436
get statusTag() {
55-
return this.row.getByTestId('status-0');
37+
return this.row.getByTestId('status');
5638
}
5739

5840
get orderNumber() {
59-
return this.row.getByTestId('order-number-0');
41+
return this.row.getByTestId('order-number');
42+
}
43+
44+
get viewOrderDetails() {
45+
return this.row.getByTestId('view-details-item');
46+
}
47+
48+
get deleteOrder() {
49+
return this.row.getByTestId('delete-order-item');
6050
}
6151
}
6252
export default PutawayListTable;

src/pages/putaway/putawayDetails/PutawayDetailsPage.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,37 +31,27 @@ class PutawayDetailsPage extends BasePageModel {
3131
}
3232

3333
get actionsViewOrderDetailsButton() {
34-
return this.page
35-
.locator('.action-menu-item')
36-
.getByRole('link', { name: 'View order details' });
34+
return this.page.getByTestId('view-details-item');
3735
}
3836

3937
get actionsAddCommentButton() {
40-
return this.page
41-
.locator('.action-menu-item')
42-
.getByRole('link', { name: 'Add comment' });
38+
return this.page.getByTestId('add-comment-item');
4339
}
4440

4541
get actionsAddDocumentsButton() {
46-
return this.page
47-
.locator('.action-menu-item')
48-
.getByRole('link', { name: 'Add document' });
42+
return this.page.getByTestId('add-document-item');
4943
}
5044

5145
get actionsGeneratePutawayListButton() {
52-
return this.page
53-
.locator('.action-menu-item')
54-
.getByRole('link', { name: 'Generate Putaway List' });
46+
return this.page.getByTestId('generate-pdf-item');
5547
}
5648

5749
get actionsDeleteButton() {
58-
return this.page
59-
.locator('.action-menu-item')
60-
.getByRole('link', { name: 'Delete Order' });
50+
return this.page.getByTestId('delete-order-item');
6151
}
6252

6353
get statusTag() {
64-
return this.summary.locator('.tag-alert');
54+
return this.summary.getByTestId('status');
6555
}
6656

6757
// TABS

src/tests/putaway/assertAttemptToEditCompletedPutaway.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ test.describe('Assert attempt to edit completed putaway', () => {
189189
).toBeVisible();
190190
await createPutawayPage.startStep.closeDisplayedError();
191191
await createPutawayPage.startStep.table.row(0).editButton.click();
192-
await createPutawayPage.startStep.table.row(0).quantityField.fill('20');
192+
await createPutawayPage.startStep.table.row(0).quantityInput.fill('20');
193193
await expect(createPutawayPage.startStep.nextButton).toBeDisabled();
194194
await expect(createPutawayPage.startStep.saveButton).toBeDisabled();
195195
});

src/tests/putaway/assertPutawayDetailsPage.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,9 @@ test.describe('Assert putaway details page', () => {
140140
});
141141

142142
await test.step('Go to putaway view page and assert page elements', async () => {
143-
await putawayListPage.table.row(1).actionsButton.click();
144-
await putawayListPage.table.viewOrderDetailsButton.click();
143+
const row = putawayListPage.table.row(1)
144+
await row.actionsButton.click();
145+
await row.viewOrderDetails.click();
145146
await putawayDetailsPage.isLoaded();
146147
await expect(putawayDetailsPage.listOrdersButton).toBeVisible();
147148
await expect(putawayDetailsPage.createOrderButton).toBeVisible();

0 commit comments

Comments
 (0)