2020-11-17 15:52:19 +00:00
import selectors from '../../helpers/selectors.js' ;
import getBrowser from '../../helpers/puppeteer' ;
2021-06-17 14:17:18 +00:00
2023-02-21 13:12:06 +00:00
describe ( 'Travel descriptor path' , ( ) => {
2020-11-17 15:52:19 +00:00
let browser ;
let page ;
beforeAll ( async ( ) => {
browser = await getBrowser ( ) ;
page = browser . page ;
await page . loginAndModule ( 'buyer' , 'travel' ) ;
2023-03-24 08:21:55 +00:00
await page . write ( selectors . travelIndex . generalSearchFilter , '1' ) ;
await page . keyboard . press ( 'Enter' ) ;
2020-11-17 15:52:19 +00:00
await page . waitForState ( 'travel.card.summary' ) ;
} ) ;
afterAll ( async ( ) => {
await browser . close ( ) ;
} ) ;
it ( 'should click the descriptor button to navigate to the travel index showing all travels with current agency' , async ( ) => {
await page . waitToClick ( selectors . travelDescriptor . filterByAgencyButton ) ;
await page . waitForState ( 'travel.index' ) ;
const result = await page . countElement ( selectors . travelIndex . anySearchResult ) ;
2020-11-17 17:07:04 +00:00
expect ( result ) . toBeGreaterThanOrEqual ( 7 ) ;
2020-11-17 15:52:19 +00:00
} ) ;
it ( 'should navigate to the first search result' , async ( ) => {
await page . waitToClick ( selectors . travelIndex . firstSearchResult ) ;
await page . waitForState ( 'travel.card.summary' ) ;
2021-01-20 19:28:22 +00:00
const state = await page . getState ( ) ;
expect ( state ) . toBe ( 'travel.card.summary' ) ;
} ) ;
it ( 'should be redirected to the create entry view' , async ( ) => {
await page . waitToClick ( selectors . travelDescriptor . dotMenu ) ;
await page . waitToClick ( selectors . travelDescriptor . dotMenuAddEntry ) ;
await page . waitForState ( 'entry.create' ) ;
const state = await page . getState ( ) ;
expect ( state ) . toBe ( 'entry.create' ) ;
} ) ;
it ( 'should check some data was imported from the travel' , async ( ) => {
const travel = await page . waitToGetProperty ( selectors . entryCreate . travel , 'value' ) ;
const campany = await page . waitToGetProperty ( selectors . entryCreate . company , 'value' ) ;
expect ( travel ) . toContain ( 'Warehouse' ) ;
expect ( campany ) . toContain ( 'VNL' ) ;
} ) ;
it ( 'should navigate back to the travel index' , async ( ) => {
await page . waitToClick ( '.cancel' ) ;
await page . waitToClick ( selectors . globalItems . homeButton ) ;
await page . selectModule ( 'travel' ) ;
await page . waitForState ( 'travel.index' ) ;
const state = await page . getState ( ) ;
expect ( state ) . toBe ( 'travel.index' ) ;
} ) ;
it ( 'should click on the add entry button of the third result to be redirected to create entry' , async ( ) => {
await page . keyboard . press ( 'Enter' ) ;
await page . waitToClick ( selectors . travelIndex . firstTravelAddEntryButton ) ;
await page . waitForState ( 'entry.create' ) ;
const state = await page . getState ( ) ;
expect ( state ) . toBe ( 'entry.create' ) ;
} ) ;
it ( 'should check again some data was imported from the travel' , async ( ) => {
const travel = await page . waitToGetProperty ( selectors . entryCreate . travel , 'value' ) ;
const campany = await page . waitToGetProperty ( selectors . entryCreate . company , 'value' ) ;
expect ( travel ) . toContain ( 'Warehouse' ) ;
expect ( campany ) . toContain ( 'VNL' ) ;
} ) ;
it ( 'should navigate to the travel summary of a given travel' , async ( ) => {
await page . waitToClick ( '.cancel' ) ;
await page . waitToClick ( selectors . globalItems . homeButton ) ;
await page . selectModule ( 'travel' ) ;
2023-03-24 08:21:55 +00:00
await page . write ( selectors . travelIndex . generalSearchFilter , '3' ) ;
await page . keyboard . press ( 'Enter' ) ;
2021-01-20 19:28:22 +00:00
await page . waitForState ( 'travel.card.summary' ) ;
2020-11-17 15:52:19 +00:00
const state = await page . getState ( ) ;
expect ( state ) . toBe ( 'travel.card.summary' ) ;
} ) ;
it ( 'should be redirected to the create travel when using the clone option of the dot menu' , async ( ) => {
await page . waitToClick ( selectors . travelDescriptor . dotMenu ) ;
await page . waitToClick ( selectors . travelDescriptor . dotMenuClone ) ;
await page . respondToDialog ( 'accept' ) ;
await page . waitForState ( 'travel.create' ) ;
const state = await page . getState ( ) ;
expect ( state ) . toBe ( 'travel.create' ) ;
} ) ;
2020-12-30 13:54:51 +00:00
it ( 'should edit the data to clone and then get redirected to the cloned travel basic data' , async ( ) => {
await page . clearInput ( selectors . travelCreate . reference ) ;
await page . write ( selectors . travelCreate . reference , 'reference' ) ;
await page . autocompleteSearch ( selectors . travelCreate . agency , 'entanglement' ) ;
await page . pickDate ( selectors . travelCreate . shipped ) ;
await page . pickDate ( selectors . travelCreate . landed ) ;
await page . autocompleteSearch ( selectors . travelCreate . warehouseOut , 'warehouse one' ) ;
await page . autocompleteSearch ( selectors . travelCreate . warehouseIn , 'warehouse two' ) ;
await page . waitToClick ( selectors . travelCreate . saveButton ) ;
await page . waitForState ( 'travel.card.basicData' ) ;
const message = await page . waitForSnackbar ( ) ;
expect ( message . text ) . toContain ( 'Data saved!' ) ;
} ) ;
it ( 'should update the landed date to a future date to enable cloneWithEntries' , async ( ) => {
2023-01-16 14:18:24 +00:00
const nextMonth = Date . vnNew ( ) ;
2020-12-30 13:54:51 +00:00
nextMonth . setMonth ( nextMonth . getMonth ( ) + 1 ) ;
await page . pickDate ( selectors . travelBasicData . deliveryDate , nextMonth ) ;
await page . waitToClick ( selectors . travelBasicData . save ) ;
await page . waitForState ( 'travel.card.basicData' ) ;
const message = await page . waitForSnackbar ( ) ;
expect ( message . text ) . toContain ( 'Data saved!' ) ;
} ) ;
2021-06-17 06:17:02 +00:00
it ( 'should navigate to the summary and then clone the travel and its entries using the descriptor menu to get redirected to the cloned travel basic data' , async ( ) => {
2022-04-11 06:02:05 +00:00
await page . waitToClick ( 'vn-icon[icon="launch"]' ) ;
2020-12-31 09:39:09 +00:00
await page . waitForState ( 'travel.card.summary' ) ;
2021-06-17 14:17:18 +00:00
await page . waitForTimeout ( 1000 ) ;
2020-12-30 13:54:51 +00:00
await page . waitToClick ( selectors . travelDescriptor . dotMenu ) ;
await page . waitToClick ( selectors . travelDescriptor . dotMenuCloneWithEntries ) ;
await page . waitToClick ( selectors . travelDescriptor . acceptClonation ) ;
await page . waitForState ( 'travel.card.basicData' ) ;
} ) ;
2020-11-17 15:52:19 +00:00
} ) ;