import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; const $ = { form: 'vn-order-basic-data form', observation: 'vn-order-basic-data form [vn-name="note"]', saveButton: `vn-order-basic-data form button[type=submit]`, acceptButton: '.vn-confirm.shown button[response="accept"]' }; describe('Order edit basic data path', () => { let browser; let page; beforeAll(async() => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('employee', 'order'); await page.accessToSearchResult('1'); await page.accessToSection('order.card.basicData'); }); afterAll(async() => { await browser.close(); }); describe('when confirmed order', () => { it('should not be able to change the client', async() => { const message = await page.sendForm($.form, { client: 'Tony Stark', address: 'Tony Stark', }); expect(message.text).toContain(`You can't make changes on the basic data`); }); }); describe('when new order', () => { it('should create an order and edit its basic data', async() => { await page.waitToClick(selectors.globalItems.returnToModuleIndexButton); await page.waitToClick($.acceptButton); await page.waitForContentLoaded(); await page.waitToClick(selectors.ordersIndex.createOrderButton); await page.waitForState('order.create'); await page.autocompleteSearch(selectors.createOrderView.client, 'Jessica Jones'); await page.pickDate(selectors.createOrderView.landedDatePicker); await page.autocompleteSearch(selectors.createOrderView.agency, 'Other agency'); await page.waitToClick(selectors.createOrderView.createButton); await page.waitForState('order.card.catalog'); await page.accessToSection('order.card.basicData'); const values = { client: 'Tony Stark', address: 'Tony Stark', agencyMode: 'Other agency' }; const message = await page.sendForm($.form, values); await page.reloadSection('order.card.basicData'); const formValues = await page.fetchForm($.form, Object.keys(values)); expect(message.isSuccess).toBeTrue(); expect(formValues).toEqual(values); }); }); });