import getBrowser from '../../helpers/puppeteer'; const $ = { form: 'vn-item-basic-data form', intrastatForm: '.vn-dialog.shown form', newIntrastatButton: 'vn-item-basic-data vn-icon-button[vn-tooltip="New intrastat"] > button' }; describe('Item Edit basic data path', () => { let browser; let page; beforeAll(async() => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('buyer', 'item'); await page.accessToSearchResult('Melee weapon combat fist 15cm'); }); beforeEach(async() => { await page.accessToSection('item.card.basicData'); }); afterAll(async() => { await browser.close(); }); it(`should edit the item basic data and confirm the item data was edited`, async() => { const values = { name: 'Rose of Purity', longName: 'RS Rose of Purity', type: 'Anthurium', intrastat: 'Coral y materiales similares', origin: 'Spain', relevancy: 1, generic: 'Pallet', isActive: false, priceInKg: true, isFragile: true, packingOut: 5 }; const message = await page.sendForm($.form, values); await page.reloadSection('item.card.basicData'); const formValues = await page.fetchForm($.form, Object.keys(values)); expect(message.isSuccess).toBeTrue(); expect(formValues).toEqual(values); }); it(`should create a new intrastat and save it`, async() => { await page.click($.newIntrastatButton); await page.waitForSelector($.intrastatForm); await page.fillForm($.intrastatForm, { id: '588420239', description: 'Tropical Flowers' }); await page.respondToDialog('accept'); const message = await page.sendForm($.form); await page.reloadSection('item.card.basicData'); const formValues = await page.fetchForm($.form, ['intrastat']); expect(message.isSuccess).toBeTrue(); expect(formValues).toEqual({intrastat: 'Tropical Flowers'}); }); });