salix/e2e/paths/05-ticket-module/11_diary.spec.js

67 lines
2.5 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import config from '../../helpers/config.js';
import createNightmare from '../../helpers/nightmare';
describe('Ticket diary path', () => {
const nightmare = createNightmare();
beforeAll(() => {
nightmare
.loginAndModule('employee', 'ticket');
});
it('should search for a specific ticket', async() => {
const result = await nightmare
.write(selectors.ticketsIndex.searchTicketInput, 1)
.waitToClick(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.search-result, 1)
.countElement(selectors.ticketsIndex.search-result);
expect(result).toEqual(1);
});
it(`should click on the search result to access to the ticket summary`, async() => {
const url = await nightmare
.waitForTextInElement(selectors.ticketsIndex.search-result, 'Bat cave')
.waitToClick(selectors.ticketsIndex.search-result)
.waitForURL('/summary')
.parsedUrl();
expect(url.hash).toContain('/summary');
});
it(`should navigate to the item diary from the 1st sale item id descriptor popover`, async() => {
const itemId = 2;
const url = await nightmare
.waitToClick(selectors.ticketSummary.firstSaleItemId)
.waitToClick(selectors.ticketSummary.popoverDiaryButton)
.waitForLogin('employee')
.goto(`${config.url}#!/item/${itemId}/diary?warehouseFk=1&ticketFk=1`)
.parsedUrl();
expect(url.hash).toContain('/diary');
});
it(`should check the second line id is marked as message`, async() => {
const result = await nightmare
.waitToGetProperty(selectors.itemDiary.secondTicketId, 'className');
expect(result).toContain('message');
});
it(`should check the third line balance is marked as message`, async() => {
const result = await nightmare
.waitToGetProperty(`${selectors.itemDiary.fourthBalance} > span`, 'className');
expect(result).toContain('message');
});
it(`should change to the warehouse two and check there are sales marked as negative balance`, async() => {
const result = await nightmare
.autocompleteSearch(selectors.itemDiary.warehouseAutocomplete, 'Warehouse Two')
.waitToGetProperty(selectors.itemDiary.firstBalance, 'className');
expect(result).toContain('balance');
});
});