|
| 1 | +import AppConfig from '@/config/AppConfig'; |
| 2 | +import { ShipmentType } from '@/constants/ShipmentType'; |
| 3 | +import { expect, test } from '@/fixtures/fixtures'; |
| 4 | +import CreateLocationPage from '@/pages/location/createLocation/CreateLocationPage'; |
| 5 | +import LocationListPage from '@/pages/location/LocationListPage'; |
| 6 | +import { StockMovementResponse } from '@/types'; |
| 7 | + |
| 8 | +test.describe('Assert creation of receiving bin', () => { |
| 9 | + test.describe.configure({ timeout: 60000 }); |
| 10 | + //timeout has been added for this test to make sure that the content on bin location tab will load as it can include a lot of data |
| 11 | + let STOCK_MOVEMENT: StockMovementResponse; |
| 12 | + |
| 13 | + test.beforeEach( |
| 14 | + async ({ |
| 15 | + supplierLocationService, |
| 16 | + stockMovementService, |
| 17 | + mainProductService, |
| 18 | + otherProductService, |
| 19 | + }) => { |
| 20 | + const supplierLocation = await supplierLocationService.getLocation(); |
| 21 | + const PRODUCT_ONE = await mainProductService.getProduct(); |
| 22 | + const PRODUCT_TWO = await otherProductService.getProduct(); |
| 23 | + |
| 24 | + STOCK_MOVEMENT = await stockMovementService.createInbound({ |
| 25 | + originId: supplierLocation.id, |
| 26 | + }); |
| 27 | + |
| 28 | + await stockMovementService.addItemsToInboundStockMovement( |
| 29 | + STOCK_MOVEMENT.id, |
| 30 | + [ |
| 31 | + { |
| 32 | + productId: PRODUCT_ONE.id, |
| 33 | + quantity: 100, |
| 34 | + }, |
| 35 | + { productId: PRODUCT_TWO.id, quantity: 10 }, |
| 36 | + ] |
| 37 | + ); |
| 38 | + |
| 39 | + await stockMovementService.sendInboundStockMovement(STOCK_MOVEMENT.id, { |
| 40 | + shipmentType: ShipmentType.AIR, |
| 41 | + }); |
| 42 | + } |
| 43 | + ); |
| 44 | + |
| 45 | + test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { |
| 46 | + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); |
| 47 | + await stockMovementShowPage.rollbackButton.click(); |
| 48 | + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); |
| 49 | + }); |
| 50 | + |
| 51 | + test('Assert receiving bin is not created when shipment is shipped', async ({ |
| 52 | + stockMovementShowPage, |
| 53 | + receivingPage, |
| 54 | + page, |
| 55 | + locationListPage, |
| 56 | + mainLocationService, |
| 57 | + createLocationPage, |
| 58 | + browser, |
| 59 | + }) => { |
| 60 | + await test.step('Go to stock movement show page and assert shipped status', async () => { |
| 61 | + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); |
| 62 | + await stockMovementShowPage.isLoaded(); |
| 63 | + await expect(stockMovementShowPage.statusTag).toHaveText('Shipped'); |
| 64 | + }); |
| 65 | + |
| 66 | + await test.step('Go to Bin location tab of edit location page', async () => { |
| 67 | + const mainLocation = await mainLocationService.getLocation(); |
| 68 | + await page.goto('./location/list'); |
| 69 | + await locationListPage.searchByLocationNameField.fill(mainLocation.name); |
| 70 | + await locationListPage.findButton.click(); |
| 71 | + await expect( |
| 72 | + locationListPage.getLocationEditButton(mainLocation.name) |
| 73 | + ).toBeVisible(); |
| 74 | + await locationListPage.getLocationEditButton(mainLocation.name).click(); |
| 75 | + await createLocationPage.binLocationTab.click(); |
| 76 | + await createLocationPage.binLocationTabSection.isLoaded(); |
| 77 | + }); |
| 78 | + |
| 79 | + await test.step('Assert Bin location is not created yet', async () => { |
| 80 | + const receivingBin = |
| 81 | + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; |
| 82 | + await createLocationPage.binLocationTabSection.searchField.fill( |
| 83 | + receivingBin |
| 84 | + ); |
| 85 | + await createLocationPage.binLocationTabSection.searchField.press('Enter'); |
| 86 | + await createLocationPage.binLocationTabSection.isLoaded(); |
| 87 | + await expect( |
| 88 | + createLocationPage.binLocationTabSection.emptyBinLocationTable |
| 89 | + ).toBeVisible(); |
| 90 | + }); |
| 91 | + |
| 92 | + await test.step('Go to stock movement show page', async () => { |
| 93 | + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); |
| 94 | + await stockMovementShowPage.isLoaded(); |
| 95 | + }); |
| 96 | + |
| 97 | + await test.step('Click on receive button', async () => { |
| 98 | + await stockMovementShowPage.receiveButton.click(); |
| 99 | + await receivingPage.receivingStep.isLoaded(); |
| 100 | + }); |
| 101 | + |
| 102 | + await test.step('Assert receiving bin has been created', async () => { |
| 103 | + const newPage = await browser.newPage(); |
| 104 | + const newLocationListPage = new LocationListPage(newPage); |
| 105 | + const newCreateLocationPage = new CreateLocationPage(newPage); |
| 106 | + const mainLocation = await mainLocationService.getLocation(); |
| 107 | + await newPage.goto('./location/list'); |
| 108 | + await newLocationListPage.searchByLocationNameField.fill( |
| 109 | + mainLocation.name |
| 110 | + ); |
| 111 | + await newLocationListPage.findButton.click(); |
| 112 | + await expect( |
| 113 | + newLocationListPage.getLocationEditButton(mainLocation.name) |
| 114 | + ).toBeVisible(); |
| 115 | + await newLocationListPage |
| 116 | + .getLocationEditButton(mainLocation.name) |
| 117 | + .click(); |
| 118 | + await newCreateLocationPage.binLocationTab.click(); |
| 119 | + await newCreateLocationPage.binLocationTabSection.isLoaded(); |
| 120 | + const receivingBin = |
| 121 | + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; |
| 122 | + await newCreateLocationPage.binLocationTabSection.searchField.fill( |
| 123 | + receivingBin |
| 124 | + ); |
| 125 | + await newCreateLocationPage.binLocationTabSection.searchField.press( |
| 126 | + 'Enter' |
| 127 | + ); |
| 128 | + await newCreateLocationPage.binLocationTabSection.isLoaded(); |
| 129 | + await expect( |
| 130 | + newCreateLocationPage.binLocationTabSection.emptyBinLocationTable |
| 131 | + ).toBeHidden(); |
| 132 | + await expect( |
| 133 | + newCreateLocationPage.binLocationTabSection.row(1).binLocation |
| 134 | + ).toHaveText(receivingBin); |
| 135 | + await newPage.close(); |
| 136 | + }); |
| 137 | + }); |
| 138 | +}); |
0 commit comments