salix/e2e/paths/ticket-module/11_ticket_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
.wait(selectors.ticketsIndex.searchTicketInput)
.type(selectors.ticketsIndex.searchTicketInput, 'id:1')
.click(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult);
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.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.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 url = await nightmare
.waitToClick(selectors.ticketSummary.firstSaleItemId)
.waitToClick(selectors.ticketSummary.popoverDiaryButton)
.waitForLogin('employee')
.goto(`${config.url}#!/item/1/diary?warehouseFk=1&ticketFk=1`)
.parsedUrl();
expect(url.hash).toContain('/diary');
});
it(`should check the seventh line id is marked as counter`, async() => {
const result = await nightmare
.waitToGetProperty(selectors.itemDiary.thirdTicketId, 'className');
expect(result).toContain('counter');
});
it(`should check the fifth line balance is marked as counter`, async() => {
const result = await nightmare
.waitToGetProperty(selectors.itemDiary.fifthBalance, 'className');
expect(result).toContain('counter');
});
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');
});
});