import getBrowser from '../../helpers/puppeteer'; const $ = { reference: 'vn-entry-basic-data vn-textfield[ng-model="$ctrl.entry.reference"]', invoiceNumber: 'vn-entry-basic-data vn-textfield[ng-model="$ctrl.entry.invoiceNumber"]', notes: 'vn-entry-basic-data vn-textfield[ng-model="$ctrl.entry.notes"]', observations: 'vn-entry-basic-data vn-textarea[ng-model="$ctrl.entry.observation"]', supplier: 'vn-entry-basic-data vn-autocomplete[ng-model="$ctrl.entry.supplierFk"]', currency: 'vn-entry-basic-data vn-autocomplete[ng-model="$ctrl.entry.currencyFk"]', commission: 'vn-entry-basic-data vn-input-number[ng-model="$ctrl.entry.commission"]', company: 'vn-entry-basic-data vn-autocomplete[ng-model="$ctrl.entry.companyFk"]', ordered: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isOrdered"]', confirmed: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isConfirmed"]', inventory: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isExcludedFromAvailable"]', raid: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isRaid"]', booked: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isBooked"]', save: 'vn-entry-basic-data button[type=submit]', }; describe('Entry basic data path', () => { let browser; let page; beforeAll(async() => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('buyer', 'entry'); await page.accessToSearchResult('2'); await page.accessToSection('entry.card.basicData'); }); afterAll(async() => { await browser.close(); }); it('should edit the basic data and confirm the reference was edited', async() => { await page.write($.reference, 'new movement 8'); await page.write($.invoiceNumber, 'new movement 8'); await page.write($.observations, ' edited'); await page.autocompleteSearch($.supplier, 'Plants nick'); await page.autocompleteSearch($.currency, 'eur'); await page.clearInput($.commission); await page.write($.commission, '100'); await page.autocompleteSearch($.company, 'CCs'); await page.waitToClick($.ordered); await page.waitToClick($.confirmed); await page.waitToClick($.inventory); await page.waitToClick($.raid); await page.waitToClick($.booked); await page.waitToClick($.save); const message = await page.waitForSnackbar(); await page.reloadSection('entry.card.basicData'); const reference = await page.waitToGetProperty($.reference, 'value'); const supplier = await page.waitToGetProperty($.supplier, 'value'); const invoiceNumber = await page.waitToGetProperty($.invoiceNumber, 'value'); const observations = await page.waitToGetProperty($.observations, 'value'); const currency = await page.waitToGetProperty($.currency, 'value'); const commission = await page.waitToGetProperty($.commission, 'value'); const company = await page.waitToGetProperty($.company, 'value'); const ordered = await page.checkboxState($.ordered); const confirmed = await page.checkboxState($.confirmed); const inventory = await page.checkboxState($.inventory); const raid = await page.checkboxState($.raid); const booked = await page.checkboxState($.booked); expect(message.text).toContain('Data saved!'); expect(reference).toEqual('new movement 8'); expect(supplier).toEqual('Plants nick'); expect(invoiceNumber).toEqual('new movement 8'); expect(observations).toEqual('observation two edited'); expect(currency).toEqual('EUR'); expect(commission).toEqual('100'); expect(company).toEqual('CCs'); expect(ordered).toBe('checked'); expect(confirmed).toBe('checked'); expect(inventory).toBe('checked'); expect(raid).toBe('checked'); expect(booked).toBe('unchecked'); }); });