-
-
Notifications
You must be signed in to change notification settings - Fork 0
OBPIH-6956 Add tests for assert qty and split line with 0 qty #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ea9c70d
OBPIH-6956 add elements to edit modal
kkrawczyk123 06bc3fc
OBPIH-6956 add elements to check step
kkrawczyk123 3882d59
OBPIH-6956 add tests for assert qty and split line with 0 qty
kkrawczyk123 4a0a994
OBPIH-6956 improve naming and update locator
kkrawczyk123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,276 @@ | ||
| import { ShipmentType } from '@/constants/ShipmentType'; | ||
| import { expect, test } from '@/fixtures/fixtures'; | ||
| import { StockMovementResponse } from '@/types'; | ||
| import { formatDate, getDateByOffset } from '@/utils/DateUtils'; | ||
|
|
||
| test.describe('Assert if quantity inputs remain when split lines', () => { | ||
| let STOCK_MOVEMENT: StockMovementResponse; | ||
|
|
||
| test.beforeEach( | ||
| async ({ | ||
| supplierLocationService, | ||
| stockMovementService, | ||
| mainProductService, | ||
| otherProductService, | ||
| thirdProductService, | ||
| }) => { | ||
| const supplierLocation = await supplierLocationService.getLocation(); | ||
| const PRODUCT_ONE = await mainProductService.getProduct(); | ||
| const PRODUCT_TWO = await otherProductService.getProduct(); | ||
| const PRODUCT_THREE = await thirdProductService.getProduct(); | ||
|
|
||
| STOCK_MOVEMENT = await stockMovementService.createInbound({ | ||
| originId: supplierLocation.id, | ||
| }); | ||
|
|
||
| await stockMovementService.addItemsToInboundStockMovement( | ||
| STOCK_MOVEMENT.id, | ||
| [ | ||
| { | ||
| productId: PRODUCT_ONE.id, | ||
| quantity: 50, | ||
| }, | ||
| { productId: PRODUCT_TWO.id, quantity: 100 }, | ||
| { productId: PRODUCT_THREE.id, quantity: 200 }, | ||
| ] | ||
| ); | ||
|
|
||
| await stockMovementService.sendInboundStockMovement(STOCK_MOVEMENT.id, { | ||
| shipmentType: ShipmentType.AIR, | ||
| }); | ||
| } | ||
| ); | ||
|
|
||
| test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { | ||
| await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); | ||
| const isRollbackLastReceiptButtonVisible = | ||
| await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); | ||
| const isRollbackButtonVisible = | ||
| await stockMovementShowPage.rollbackButton.isVisible(); | ||
|
|
||
| // due to failed test, shipment might not be received which will not show the button | ||
| if (isRollbackLastReceiptButtonVisible) { | ||
| await stockMovementShowPage.rollbackLastReceiptButton.click(); | ||
| } | ||
|
|
||
| if (isRollbackButtonVisible) { | ||
| await stockMovementShowPage.rollbackButton.click(); | ||
| } | ||
|
|
||
| await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); | ||
| }); | ||
|
|
||
| test('Assert quantity input after split line', async ({ | ||
| stockMovementShowPage, | ||
| receivingPage, | ||
| }) => { | ||
| const lot = 'add-lot-test'; | ||
| const expDate = getDateByOffset(new Date(), 5); | ||
|
|
||
| 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('Autofill receiving quantity', async () => { | ||
| await receivingPage.receivingStep.isLoaded(); | ||
| await receivingPage.receivingStep.autofillQuantitiesButton.click(); | ||
| }); | ||
|
|
||
| await test.step('Open edit modal for item and split line', async () => { | ||
| await receivingPage.receivingStep.table.row(2).editButton.click(); | ||
| await receivingPage.receivingStep.editModal.isLoaded(); | ||
| await receivingPage.receivingStep.editModal.addLineButton.click(); | ||
| await receivingPage.receivingStep.editModal.table | ||
| .row(0) | ||
| .quantityShippedField.numberbox.fill('100'); | ||
| await receivingPage.receivingStep.editModal.table | ||
| .row(0) | ||
| .lotNumberField.textbox.fill(lot); | ||
| await receivingPage.receivingStep.editModal.table | ||
| .row(0) | ||
| .expiryDatePickerField.fill(expDate); | ||
| await receivingPage.receivingStep.editModal.table | ||
| .row(1) | ||
| .quantityShippedField.numberbox.fill('50'); | ||
| await receivingPage.receivingStep.editModal.addLineButton.click(); | ||
| await receivingPage.receivingStep.editModal.table | ||
| .row(2) | ||
| .quantityShippedField.numberbox.fill('50'); | ||
| await receivingPage.receivingStep.editModal.saveButton.click(); | ||
| await receivingPage.receivingStep.isLoaded(); | ||
| }); | ||
|
|
||
| await test.step('Assert quantity input before split line', async () => { | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(1).receivingNowField.textbox | ||
| ).toHaveValue('50'); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(2).receivingNowField.textbox | ||
| ).toBeEmpty(); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(3).receivingNowField.textbox | ||
| ).toBeEmpty(); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(4).receivingNowField.textbox | ||
| ).toBeEmpty(); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(5).receivingNowField.textbox | ||
| ).toHaveValue('100'); | ||
| await expect( | ||
| receivingPage.receivingStep.table.getCellValue(2, 'Lot/Serial No.') | ||
| ).toContainText(lot); | ||
| await expect( | ||
| receivingPage.receivingStep.table.getCellValue(2, 'Expiration date') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
| ).toContainText(formatDate(expDate, 'MM/DD/YYYY')); | ||
| }); | ||
|
|
||
| await test.step('Autofill quantity after split line', async () => { | ||
| await receivingPage.receivingStep.isLoaded(); | ||
| await receivingPage.receivingStep.autofillQuantitiesButton.click(); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(2).receivingNowField.textbox | ||
| ).toHaveValue('100'); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(3).receivingNowField.textbox | ||
| ).toHaveValue('50'); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(4).receivingNowField.textbox | ||
| ).toHaveValue('50'); | ||
| }); | ||
|
|
||
| await test.step('Edit another line', async () => { | ||
| await receivingPage.receivingStep.table.row(5).editButton.click(); | ||
| await receivingPage.receivingStep.editModal.isLoaded(); | ||
| await receivingPage.receivingStep.editModal.table | ||
| .row(0) | ||
| .lotNumberField.textbox.fill(lot); | ||
| await receivingPage.receivingStep.editModal.table | ||
| .row(0) | ||
| .expiryDatePickerField.fill(expDate); | ||
| await receivingPage.receivingStep.editModal.saveButton.click(); | ||
| await receivingPage.receivingStep.isLoaded(); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(1).receivingNowField.textbox | ||
| ).toHaveValue('50'); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(2).receivingNowField.textbox | ||
| ).toHaveValue('100'); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(3).receivingNowField.textbox | ||
| ).toHaveValue('50'); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(4).receivingNowField.textbox | ||
| ).toHaveValue('50'); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(5).receivingNowField.textbox | ||
| ).toBeEmpty(); | ||
| await expect( | ||
| receivingPage.receivingStep.table.getCellValue(5, 'Lot/Serial No.') | ||
| ).toContainText(lot); | ||
| await expect( | ||
| receivingPage.receivingStep.table.getCellValue(5, 'Expiration date') | ||
| ).toContainText(formatDate(expDate, 'MM/DD/YYYY')); | ||
| }); | ||
| }); | ||
|
|
||
| test('Assert quantity input after split line whe use save and exit', async ({ | ||
| stockMovementShowPage, | ||
| receivingPage, | ||
| }) => { | ||
| const lot = 'add-lot-test'; | ||
| const expDate = getDateByOffset(new Date(), 5); | ||
|
|
||
| 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('Autofill quantity for items', async () => { | ||
| await receivingPage.receivingStep.isLoaded(); | ||
| await receivingPage.receivingStep.table | ||
| .row(2) | ||
| .receivingNowField.textbox.fill('200'); | ||
| await receivingPage.receivingStep.table | ||
| .row(3) | ||
| .receivingNowField.textbox.fill('100'); | ||
| await receivingPage.receivingStep.saveAndExitButton.click(); | ||
| }); | ||
|
|
||
| await test.step('Return to receipt', async () => { | ||
| await stockMovementShowPage.receiveButton.click(); | ||
| await receivingPage.receivingStep.isLoaded(); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(1).receivingNowField.textbox | ||
| ).toBeEmpty(); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(2).receivingNowField.textbox | ||
| ).toHaveValue('200'); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(3).receivingNowField.textbox | ||
| ).toHaveValue('100'); | ||
| }); | ||
|
|
||
| await test.step('Open edit modal for item without quantity input', async () => { | ||
| await receivingPage.receivingStep.table.row(1).editButton.click(); | ||
| await receivingPage.receivingStep.editModal.isLoaded(); | ||
| await receivingPage.receivingStep.editModal.addLineButton.click(); | ||
| await receivingPage.receivingStep.editModal.table | ||
| .row(0) | ||
| .quantityShippedField.numberbox.fill('25'); | ||
| await receivingPage.receivingStep.editModal.table | ||
| .row(0) | ||
| .lotNumberField.textbox.fill(lot); | ||
| await receivingPage.receivingStep.editModal.table | ||
| .row(0) | ||
| .expiryDatePickerField.fill(expDate); | ||
| await receivingPage.receivingStep.editModal.table | ||
| .row(1) | ||
| .quantityShippedField.numberbox.fill('25'); | ||
| await receivingPage.receivingStep.editModal.saveButton.click(); | ||
| await receivingPage.receivingStep.isLoaded(); | ||
| }); | ||
|
|
||
| await test.step('Assert quantity input after split line', async () => { | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(1).receivingNowField.textbox | ||
| ).toBeEmpty(); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(2).receivingNowField.textbox | ||
| ).toBeEmpty(); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(3).receivingNowField.textbox | ||
| ).toHaveValue('200'); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(4).receivingNowField.textbox | ||
| ).toHaveValue('100'); | ||
| await expect( | ||
| receivingPage.receivingStep.table.getCellValue(1, 'Lot/Serial No.') | ||
| ).toContainText(lot); | ||
| await expect( | ||
| receivingPage.receivingStep.table.getCellValue(1, 'Expiration date') | ||
| ).toContainText(formatDate(expDate, 'MM/DD/YYYY')); | ||
| }); | ||
|
|
||
| await test.step('Autofill quantity after split line', async () => { | ||
| await receivingPage.receivingStep.isLoaded(); | ||
| await receivingPage.receivingStep.autofillQuantitiesButton.click(); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(1).receivingNowField.textbox | ||
| ).toHaveValue('25'); | ||
| await expect( | ||
| receivingPage.receivingStep.table.row(2).receivingNowField.textbox | ||
| ).toHaveValue('25'); | ||
| }); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this to some constant?