|
| 1 | +import { expect, test } from '@/fixtures/fixtures'; |
| 2 | +import { AddItemsTableRow, LocationResponse } from '@/types'; |
| 3 | +import { formatDate, getDateByOffset, getToday } from '@/utils/DateUtils'; |
| 4 | +import UniqueIdentifier from '@/utils/UniqueIdentifier'; |
| 5 | + |
| 6 | +test.describe('Select person in requested by', () => { |
| 7 | + const TODAY = getToday(); |
| 8 | + let ROWS: AddItemsTableRow[]; |
| 9 | + let INBOUND_ID: string; |
| 10 | + const DESCRIPTION = 'some description'; |
| 11 | + let ORIGIN: LocationResponse; |
| 12 | + const EXPECTED_DELIVERY_DATE = getDateByOffset(TODAY, 1); |
| 13 | + const SHIPMENT_TYPE = 'Land'; |
| 14 | + const uniqueIdentifier = new UniqueIdentifier(); |
| 15 | + const personFirstName = uniqueIdentifier.generateUniqueString('person'); |
| 16 | + const personLastName = uniqueIdentifier.generateUniqueString('lastname'); |
| 17 | + const person = `${personFirstName} ${personLastName}`; |
| 18 | + |
| 19 | + test.beforeEach( |
| 20 | + async ({ |
| 21 | + mainProductService, |
| 22 | + supplierLocationService, |
| 23 | + page, |
| 24 | + personsListPage, |
| 25 | + createPersonPage, |
| 26 | + }) => { |
| 27 | + const PRODUCT_ONE = await mainProductService.getProduct(); |
| 28 | + ORIGIN = await supplierLocationService.getLocation(); |
| 29 | + |
| 30 | + ROWS = [ |
| 31 | + { |
| 32 | + packLevel1: 'test-pallet', |
| 33 | + packLevel2: 'test-box', |
| 34 | + productCode: PRODUCT_ONE.productCode, |
| 35 | + productName: PRODUCT_ONE.name, |
| 36 | + quantity: '12', |
| 37 | + lotNumber: 'E2E-lot-test', |
| 38 | + recipient: person, |
| 39 | + expirationDate: getDateByOffset(new Date(), 3), |
| 40 | + }, |
| 41 | + ]; |
| 42 | + |
| 43 | + await test.step('Create person', async () => { |
| 44 | + await page.goto('./person/list'); |
| 45 | + await personsListPage.isLoaded(); |
| 46 | + await personsListPage.addPersonButton.click(); |
| 47 | + await createPersonPage.firstNameField.fill(personFirstName); |
| 48 | + await createPersonPage.lastNameField.fill(personLastName); |
| 49 | + await createPersonPage.createPersonButton.click(); |
| 50 | + await personsListPage.isLoaded(); |
| 51 | + }); |
| 52 | + } |
| 53 | + ); |
| 54 | + |
| 55 | + test.afterEach( |
| 56 | + async ({ |
| 57 | + stockMovementService, |
| 58 | + stockMovementShowPage, |
| 59 | + page, |
| 60 | + personsListPage, |
| 61 | + createPersonPage, |
| 62 | + }) => { |
| 63 | + await stockMovementShowPage.rollbackButton.click(); |
| 64 | + await stockMovementService.deleteStockMovement(INBOUND_ID); |
| 65 | + await page.goto('./person/list'); |
| 66 | + await personsListPage.isLoaded(); |
| 67 | + await personsListPage.searchField.fill(personFirstName); |
| 68 | + await personsListPage.findButton.click(); |
| 69 | + await personsListPage.getPersonToEdit(person).click(); |
| 70 | + await createPersonPage.deletePersonButton.click(); |
| 71 | + } |
| 72 | + ); |
| 73 | + |
| 74 | + test('Select person in requested by', async ({ |
| 75 | + createInboundPage, |
| 76 | + stockMovementShowPage, |
| 77 | + }) => { |
| 78 | + await test.step('Go to create inbound page', async () => { |
| 79 | + await createInboundPage.goToPage(); |
| 80 | + await createInboundPage.createStep.isLoaded(); |
| 81 | + await createInboundPage.wizzardSteps.assertActiveStep('Create'); |
| 82 | + }); |
| 83 | + |
| 84 | + await test.step('Create Stock Movement step', async () => { |
| 85 | + await createInboundPage.createStep.originSelect.findAndSelectOption( |
| 86 | + ORIGIN.name |
| 87 | + ); |
| 88 | + await createInboundPage.createStep.requestedBySelect.findAndSelectOption( |
| 89 | + person |
| 90 | + ); |
| 91 | + await createInboundPage.createStep.dateRequestedDatePicker.fill(TODAY); |
| 92 | + await createInboundPage.createStep.descriptionField.textbox.fill( |
| 93 | + DESCRIPTION |
| 94 | + ); |
| 95 | + }); |
| 96 | + |
| 97 | + await test.step('Go next step (Add items)', async () => { |
| 98 | + await createInboundPage.nextButton.click(); |
| 99 | + await createInboundPage.addItemsStep.isLoaded(); |
| 100 | + }); |
| 101 | + |
| 102 | + INBOUND_ID = createInboundPage.getId(); |
| 103 | + |
| 104 | + await test.step('Add first line items (Add items), add person as recipient', async () => { |
| 105 | + const data = ROWS[0]; |
| 106 | + const row = createInboundPage.addItemsStep.table.row(0); |
| 107 | + await row.productSelect.findAndSelectOption(data.productName); |
| 108 | + await row.quantityField.numberbox.fill(data.quantity); |
| 109 | + await row.lotField.textbox.fill(data.lotNumber); |
| 110 | + await row.recipientSelect.findAndSelectOption(person); |
| 111 | + }); |
| 112 | + |
| 113 | + await test.step('Go to next step (Send)', async () => { |
| 114 | + await createInboundPage.nextButton.click(); |
| 115 | + await createInboundPage.wizzardSteps.assertActiveStep('Send'); |
| 116 | + await createInboundPage.sendStep.isLoaded(); |
| 117 | + }); |
| 118 | + |
| 119 | + await test.step('Fill shipment fields (Send)', async () => { |
| 120 | + await createInboundPage.sendStep.shipmentTypeSelect.findAndSelectOption( |
| 121 | + SHIPMENT_TYPE |
| 122 | + ); |
| 123 | + await createInboundPage.sendStep.expectedDeliveryDatePicker.fill( |
| 124 | + EXPECTED_DELIVERY_DATE |
| 125 | + ); |
| 126 | + }); |
| 127 | + |
| 128 | + await test.step('Send shipment', async () => { |
| 129 | + await createInboundPage.sendStep.sendShipmentButton.click(); |
| 130 | + await stockMovementShowPage.waitForUrl(); |
| 131 | + await stockMovementShowPage.isLoaded(); |
| 132 | + }); |
| 133 | + |
| 134 | + await test.step('Assert requested by and recipient on sm show page', async () => { |
| 135 | + await expect( |
| 136 | + stockMovementShowPage.auditingTable.dateRequestedRow |
| 137 | + ).toContainText(`${formatDate(new Date(), 'DD/MMM/YYYY')} by ${person}`); |
| 138 | + await expect( |
| 139 | + stockMovementShowPage.packingListTable.row(1).recipient |
| 140 | + ).toContainText(`${person}`); |
| 141 | + }); |
| 142 | + }); |
| 143 | +}); |
0 commit comments