-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OBPIH-6695 Add test for edit bin location in the middle of receipt (#40)
* OBPIH-6695 add bin location tab and dialog to create location page * OBPIH-6695 add locators to receiving table * OBPIH-6695 add in stock tab to product page * OBPIH-6695 add test for edit bin location in the middle of receipt * OBPIH-6695 fix import on create location page * OBPIH-6695 fix another import
- Loading branch information
1 parent
ba1b581
commit 6045702
Showing
7 changed files
with
285 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/pages/location/createLocation/components/AddBinLocationDialog.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import BasePageModel from '@/pages/BasePageModel'; | ||
|
||
class AddBinLocationDialog extends BasePageModel { | ||
get binLocationNameField() { | ||
return this.page.locator('#dlgAddBinLocation').locator('#name'); | ||
} | ||
|
||
get saveButton() { | ||
return this.page.getByRole('button', { name: 'Save' }); | ||
} | ||
} | ||
|
||
export default AddBinLocationDialog; |
36 changes: 36 additions & 0 deletions
36
src/pages/location/createLocation/tabs/BinLocationsTabSection.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import BasePageModel from '@/pages/BasePageModel'; | ||
import { expect, Page } from '@playwright/test'; | ||
import AddBinLocationDialog from '@/pages/location/createLocation/components/AddBinLocationDialog'; | ||
|
||
class BinLocationsTabSection extends BasePageModel { | ||
addBinLocationDialog: AddBinLocationDialog; | ||
|
||
constructor(page: Page) { | ||
super(page); | ||
this.addBinLocationDialog = new AddBinLocationDialog(page); | ||
} | ||
|
||
get section() { | ||
return this.page.getByRole('region', { name: 'Bin Locations' }); | ||
} | ||
|
||
async isLoaded() { | ||
await expect( | ||
this.page.locator('.box').getByText('Bin Locations') | ||
).toBeVisible(); | ||
} | ||
|
||
get addBinLocationButton() { | ||
return this.page.getByRole('button', { name: 'Add Bin Location' }); | ||
} | ||
|
||
get searchField() { | ||
return this.page.getByRole('textbox', { name: 'Search:' }); | ||
} | ||
|
||
get deleteBinButton() { | ||
return this.page.getByRole('link', { name: 'Delete' }); | ||
} | ||
} | ||
|
||
export default BinLocationsTabSection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import BasePageModel from '@/pages/BasePageModel'; | ||
import { expect, Locator, Page } from '@playwright/test'; | ||
|
||
class InStockTabSection extends BasePageModel { | ||
constructor(page: Page) { | ||
super(page); | ||
} | ||
|
||
async isLoaded() { | ||
await expect( | ||
this.page.getByRole('heading').getByText('Current stock') | ||
).toBeVisible(); | ||
} | ||
|
||
get table() { | ||
return this.page.locator('#ui-tabs-1').getByRole('table'); | ||
} | ||
|
||
get rows() { | ||
return this.table.getByRole('row'); | ||
} | ||
|
||
row(index: number) { | ||
return new Row(this.page, this.rows.nth(index)); | ||
} | ||
} | ||
|
||
class Row extends BasePageModel { | ||
row: Locator; | ||
constructor(page: Page, row: Locator) { | ||
super(page); | ||
this.row = row; | ||
} | ||
|
||
get actionsButton() { | ||
return this.row.locator('.action-menu').getByRole('button'); | ||
} | ||
|
||
get binLocation() { | ||
return this.row.locator('.line').getByRole('link'); | ||
} | ||
} | ||
|
||
export default InStockTabSection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
import { ShipmentType } from '@/constants/ShipmentType'; | ||
import { expect, test } from '@/fixtures/fixtures'; | ||
import { StockMovementResponse } from '@/types'; | ||
import { getToday } from '@/utils/DateUtils'; | ||
import UniqueIdentifier from '@/utils/UniqueIdentifier'; | ||
|
||
test.describe('Edit Bin Location when receive inbound stock movement', () => { | ||
let STOCK_MOVEMENT: StockMovementResponse; | ||
const description = 'some description'; | ||
const dateRequested = getToday(); | ||
const uniqueIdentifier = new UniqueIdentifier(); | ||
const binLocationName = uniqueIdentifier.generateUniqueString('bin'); | ||
|
||
test.beforeEach( | ||
async ({ | ||
supplierLocationService, | ||
mainLocationService, | ||
stockMovementService, | ||
mainProductService, | ||
otherProductService, | ||
page, | ||
locationListPage, | ||
createLocationPage, | ||
}) => { | ||
const supplierLocation = await supplierLocationService.getLocation(); | ||
const mainLocation = await mainLocationService.getLocation(); | ||
const PRODUCT_ONE = await mainProductService.getProduct(); | ||
const PRODUCT_TWO = await otherProductService.getProduct(); | ||
|
||
STOCK_MOVEMENT = await stockMovementService.createInbound({ | ||
originId: supplierLocation.id, | ||
description, | ||
dateRequested, | ||
}); | ||
|
||
await stockMovementService.addItemsToInboundStockMovement( | ||
STOCK_MOVEMENT.id, | ||
[ | ||
{ productId: PRODUCT_ONE.id, quantity: 20 }, | ||
{ productId: PRODUCT_TWO.id, quantity: 10 }, | ||
] | ||
); | ||
|
||
await stockMovementService.sendInboundStockMovement(STOCK_MOVEMENT.id, { | ||
shipmentType: ShipmentType.AIR, | ||
}); | ||
|
||
await test.step('Create bin location for location', async () => { | ||
await page.goto('./location/list'); | ||
await locationListPage.searchByLocationNameField.fill( | ||
mainLocation.name | ||
); | ||
await locationListPage.findButton.click(); | ||
await expect( | ||
locationListPage.getLocationEditButton(mainLocation.name) | ||
).toBeVisible(); | ||
await locationListPage.getLocationEditButton(mainLocation.name).click(); | ||
await createLocationPage.binLocationTab.click(); | ||
await createLocationPage.binLocationTabSection.isLoaded(); | ||
await createLocationPage.binLocationTabSection.addBinLocationButton.click(); | ||
await createLocationPage.binLocationTabSection.addBinLocationDialog.binLocationNameField.fill( | ||
binLocationName | ||
); | ||
await createLocationPage.binLocationTabSection.addBinLocationDialog.saveButton.click(); | ||
}); | ||
} | ||
); | ||
|
||
test.afterEach( | ||
async ({ | ||
stockMovementShowPage, | ||
stockMovementService, | ||
page, | ||
locationListPage, | ||
mainLocationService, | ||
createLocationPage, | ||
}) => { | ||
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); | ||
await stockMovementShowPage.rollbackLastReceiptButton.click(); | ||
await stockMovementShowPage.rollbackButton.click(); | ||
await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); | ||
|
||
await test.step('Delete created bin location', async () => { | ||
const mainLocation = await mainLocationService.getLocation(); | ||
await page.goto('./location/list'); | ||
await locationListPage.searchByLocationNameField.fill( | ||
mainLocation.name | ||
); | ||
await locationListPage.findButton.click(); | ||
await expect( | ||
locationListPage.getLocationEditButton(mainLocation.name) | ||
).toBeVisible(); | ||
await locationListPage.getLocationEditButton(mainLocation.name).click(); | ||
await createLocationPage.binLocationTab.click(); | ||
await createLocationPage.binLocationTabSection.isLoaded(); | ||
await createLocationPage.binLocationTabSection.searchField.fill( | ||
binLocationName | ||
); | ||
await createLocationPage.binLocationTabSection.searchField.press( | ||
'Enter' | ||
); | ||
await createLocationPage.binLocationTabSection.isLoaded(); | ||
await createLocationPage.binLocationTabSection.deleteBinButton.click(); | ||
await createLocationPage.binLocationTabSection.isLoaded(); | ||
}); | ||
} | ||
); | ||
|
||
test('Edit Bin location when receive', async ({ | ||
stockMovementShowPage, | ||
receivingPage, | ||
productShowPage, | ||
}) => { | ||
await test.step('Go to stock movement show page', async () => { | ||
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); | ||
await stockMovementShowPage.isLoaded(); | ||
}); | ||
|
||
await test.step('Go to shipment receiving page', async () => { | ||
await stockMovementShowPage.receiveButton.click(); | ||
await receivingPage.receivingStep.isLoaded(); | ||
}); | ||
|
||
await test.step('Edit bin when receive item', async () => { | ||
await receivingPage.receivingStep.isLoaded(); | ||
await receivingPage.receivingStep.table.row(1).binLocationSelect.click(); | ||
await receivingPage.receivingStep.table | ||
.row(1) | ||
.getBinLocation(binLocationName) | ||
.click(); | ||
await receivingPage.receivingStep.table | ||
.row(1) | ||
.receivingNowField.textbox.fill('10'); | ||
}); | ||
|
||
await test.step('Go to check page', async () => { | ||
await receivingPage.nextButton.click(); | ||
await receivingPage.checkStep.isLoaded(); | ||
}); | ||
|
||
await test.step('Finish receipt of item', async () => { | ||
await receivingPage.checkStep.isLoaded(); | ||
await receivingPage.checkStep.receiveShipmentButton.click(); | ||
await stockMovementShowPage.isLoaded(); | ||
}); | ||
|
||
await test.step('Assert edited bin on Packing list', async () => { | ||
await expect( | ||
stockMovementShowPage.packingListTable.row(1).binLocation | ||
).toHaveText(binLocationName); | ||
}); | ||
|
||
await test.step('Go to product page and assert bin location', async () => { | ||
await stockMovementShowPage.packingListTable.row(1).product.click(); | ||
await productShowPage.inStockTab.click(); | ||
await productShowPage.inStockTabSection.isLoaded(); | ||
await expect( | ||
productShowPage.inStockTabSection.row(2).binLocation | ||
).toHaveText(binLocationName); | ||
}); | ||
}); | ||
}); |