salix/e2e/paths/ticket-module/08_list_components.spec.js

84 lines
3.0 KiB
JavaScript
Raw Normal View History

2018-10-25 14:44:03 +00:00
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Ticket List components path', () => {
const nightmare = createNightmare();
beforeAll(() => {
return nightmare
.waitForLogin('employee');
});
it('should click on the Tickets button of the top bar menu', async () => {
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchResult)
.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
});
it('should search for the ticket 1', async () => {
const result = await nightmare
.wait(selectors.ticketsIndex.searchResult)
.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 components`, async () => {
const url = await nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketComponents.componentsButton)
.waitForURL('components')
.url();
expect(url).toContain('components');
});
it('should confirm the total base is correct', async () => {
const name = 'Base €';
const minLength = name.length;
const base = await nightmare
.waitPropertyLength(selectors.ticketComponents.base, 'innerText', minLength)
.getProperty(selectors.ticketComponents.base, 'innerText');
expect(base).toContain('Base');
expect(base.length).toBeGreaterThan(minLength);
});
it('should confirm the total margin is correct', async () => {
const name = 'Margin €';
const minLength = name.length;
const margin = await nightmare
.waitPropertyLength(selectors.ticketComponents.margin, 'innerText', minLength)
.getProperty(selectors.ticketComponents.margin, 'innerText');
expect(margin).toContain('Margin');
expect(margin.length).toBeGreaterThan(minLength);
});
it('should confirm the total total is correct', async () => {
const name = 'Total €';
const minLength = name.length;
const total = await nightmare
.waitPropertyLength(selectors.ticketComponents.total, 'innerText', minLength)
.getProperty(selectors.ticketComponents.total, 'innerText');
expect(total).toContain('Total');
expect(total.length).toBeGreaterThan(minLength);
});
});