salix/e2e/paths/ticket-module/04_create_ticket_packages.s...

106 lines
4.5 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Ticket Create packages path', () => {
const nightmare = createNightmare();
beforeAll(() => {
return nightmare
.loginAndModule('employee', 'ticket');
});
it('should search for the ticket 1', 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 packages`, async () => {
const url = await nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResultAddress, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketPackages.packagesButton)
.waitForURL('package/index')
.parsedUrl();
expect(url.hash).toContain('package/index');
});
it(`should delete the first package and receive and error to save a new one with blank quantity`, async () => {
const result = await nightmare
.waitToClick(selectors.ticketPackages.firstRemovePackageButton)
.waitToClick(selectors.ticketPackages.addPackageButton)
.waitToClick(selectors.ticketPackages.firstPackageSelect)
.waitToClick(selectors.ticketPackages.firstPackageSelectOptionTwo)
.click(selectors.ticketPackages.savePackagesButton)
.waitForLastSnackbar();
expect(result).toEqual('Some fields are invalid');
});
it(`should attempt create a new package but receive an error if quantity is a string`, async () => {
const result = await nightmare
.type(selectors.ticketPackages.firstQuantityInput, 'ninety 9')
.click(selectors.ticketPackages.savePackagesButton)
.waitForLastSnackbar();
expect(result).toEqual('Some fields are invalid');
});
it(`should attempt create a new package but receive an error if quantity is 0`, async () => {
const result = await nightmare
.clearInput(selectors.ticketPackages.firstQuantityInput)
.type(selectors.ticketPackages.firstQuantityInput, 0)
.click(selectors.ticketPackages.savePackagesButton)
.waitForLastSnackbar();
expect(result).toEqual('Some fields are invalid');
});
it(`should attempt create a new package but receive an error if package is blank`, async () => {
const result = await nightmare
.clearInput(selectors.ticketPackages.firstQuantityInput)
.type(selectors.ticketPackages.firstQuantityInput, 99)
.click(selectors.ticketPackages.clearPackageSelectButton)
.click(selectors.ticketPackages.savePackagesButton)
.waitForLastSnackbar();
expect(result).toEqual('Package cannot be blank');
});
it(`should create a new package with correct data`, async () => {
const result = await nightmare
.waitToClick(selectors.ticketPackages.firstPackageSelect)
.waitToClick(selectors.ticketPackages.firstPackageSelectOptionTwo)
.waitForTextInInput(selectors.ticketPackages.firstPackageSelect, 'Legendary Box')
.click(selectors.ticketPackages.savePackagesButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it(`should confirm the first select is the expected one`, async () => {
const result = await nightmare
.click(selectors.ticketSales.saleButton)
.wait(selectors.ticketSales.firstPackageSelect)
.click(selectors.ticketPackages.packagesButton)
.waitForTextInInput(selectors.ticketPackages.firstPackageSelect, 'Legendary Box')
.waitToGetProperty(selectors.ticketPackages.firstPackageSelect, 'value');
expect(result).toEqual('7 : Legendary Box');
});
it(`should confirm the first quantity is the expected one`, async () => {
const result = await nightmare
.waitForTextInInput(selectors.ticketPackages.firstQuantityInput, '99')
.waitToGetProperty(selectors.ticketPackages.firstQuantityInput, 'value');
expect(result).toEqual('99');
});
});