e2e refactor

This commit is contained in:
Carlos Jimenez 2018-11-20 14:22:00 +01:00
parent f90bad0719
commit 8f307b28b6
21 changed files with 837 additions and 887 deletions

View File

@ -1,125 +1,123 @@
import selectors from '../../helpers/selectors'; import selectors from '../../helpers/selectors';
import createNightmare from '../../helpers/nightmare'; import createNightmare from '../../helpers/nightmare';
describe('Client', () => { describe('Client create path', () => {
describe('create path', () => { const nightmare = createNightmare();
const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitForLogin('employee'); .waitForLogin('employee');
}); });
it('should access to the clients index by clicking the clients button', async () => { it('should access to the clients index by clicking the clients button', async () => {
const url = await nightmare const url = await nightmare
.click(selectors.moduleAccessView.clientsSectionButton) .click(selectors.moduleAccessView.clientsSectionButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.parsedUrl(); .parsedUrl();
expect(url.hash).toEqual('#!/client/index'); expect(url.hash).toEqual('#!/client/index');
}); });
it(`should search for the user Carol Danvers to confirm it isn't created yet`, async () => { it(`should search for the user Carol Danvers to confirm it isn't created yet`, async () => {
const result = await nightmare const result = await nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Carol Danvers') .type(selectors.clientsIndex.searchClientInput, 'Carol Danvers')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 0) .waitForNumberOfElements(selectors.clientsIndex.searchResult, 0)
.countElement(selectors.clientsIndex.searchResult); .countElement(selectors.clientsIndex.searchResult);
expect(result).toEqual(0); expect(result).toEqual(0);
}); });
it('should access to the create client view by clicking the create-client floating button', async () => { it('should access to the create client view by clicking the create-client floating button', async () => {
const url = await nightmare const url = await nightmare
.click(selectors.clientsIndex.createClientButton) .click(selectors.clientsIndex.createClientButton)
.wait(selectors.createClientView.createButton) .wait(selectors.createClientView.createButton)
.parsedUrl(); .parsedUrl();
expect(url.hash).toEqual('#!/client/create'); expect(url.hash).toEqual('#!/client/create');
}); });
it('should return to the client index by clicking the cancel button', async () => { it('should return to the client index by clicking the cancel button', async () => {
const url = await nightmare const url = await nightmare
.click(selectors.createClientView.cancelButton) .click(selectors.createClientView.cancelButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.parsedUrl(); .parsedUrl();
expect(url.hash).toEqual('#!/client/index'); expect(url.hash).toEqual('#!/client/index');
}); });
it('should now access to the create client view by clicking the create-client floating button', async () => { it('should now access to the create client view by clicking the create-client floating button', async () => {
const url = await nightmare const url = await nightmare
.click(selectors.clientsIndex.createClientButton) .click(selectors.clientsIndex.createClientButton)
.wait(selectors.createClientView.createButton) .wait(selectors.createClientView.createButton)
.parsedUrl(); .parsedUrl();
expect(url.hash).toEqual('#!/client/create'); expect(url.hash).toEqual('#!/client/create');
}); });
it('should receive an error when clicking the create button having all the form fields empty', async () => { it('should receive an error when clicking the create button having all the form fields empty', async () => {
const result = await nightmare const result = await nightmare
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('Some fields are invalid'); expect(result).toEqual('Some fields are invalid');
}); });
it('should receive an error when clicking the create button having name and Business name fields empty', async () => { it('should receive an error when clicking the create button having name and Business name fields empty', async () => {
const result = await nightmare const result = await nightmare
.type(selectors.createClientView.taxNumber, '74451390E') .type(selectors.createClientView.taxNumber, '74451390E')
.type(selectors.createClientView.userName, 'CaptainMarvel') .type(selectors.createClientView.userName, 'CaptainMarvel')
.type(selectors.createClientView.email, 'CarolDanvers@verdnatura.es') .type(selectors.createClientView.email, 'CarolDanvers@verdnatura.es')
.waitToClick(selectors.createClientView.salesPersonInput) .waitToClick(selectors.createClientView.salesPersonInput)
.waitToClick(selectors.createClientView.salesBruceBannerOption) .waitToClick(selectors.createClientView.salesBruceBannerOption)
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('Some fields are invalid'); expect(result).toEqual('Some fields are invalid');
}); });
it(`should attempt to create a new user with all it's data but wrong email`, async () => { it(`should attempt to create a new user with all it's data but wrong email`, async () => {
const result = await nightmare const result = await nightmare
.type(selectors.createClientView.name, 'Carol Danvers') .type(selectors.createClientView.name, 'Carol Danvers')
.type(selectors.createClientView.socialName, 'AVG tax') .type(selectors.createClientView.socialName, 'AVG tax')
.clearInput(selectors.createClientView.email) .clearInput(selectors.createClientView.email)
.type(selectors.createClientView.email, 'incorrect email format') .type(selectors.createClientView.email, 'incorrect email format')
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('Some fields are invalid'); expect(result).toEqual('Some fields are invalid');
}); });
it(`should create a new user with all correct data`, async () => { it(`should create a new user with all correct data`, async () => {
const result = await nightmare const result = await nightmare
.clearInput(selectors.createClientView.email) .clearInput(selectors.createClientView.email)
.type(selectors.createClientView.email, 'caroldanvers@verdnatura.es') .type(selectors.createClientView.email, 'caroldanvers@verdnatura.es')
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should click on the Clients button of the top bar menu', async () => { it('should click on the Clients button of the top bar menu', async () => {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.parsedUrl(); .parsedUrl();
expect(url.hash).toEqual('#!/client/index'); expect(url.hash).toEqual('#!/client/index');
}); });
it(`should search for the user Carol Danvers to confirm it exists`, async () => { it(`should search for the user Carol Danvers to confirm it exists`, async () => {
const result = await nightmare const result = await nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Carol Danvers') .type(selectors.clientsIndex.searchClientInput, 'Carol Danvers')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countElement(selectors.clientsIndex.searchResult); .countElement(selectors.clientsIndex.searchResult);
expect(result).toEqual(1); expect(result).toEqual(1);
});
}); });
}); });

View File

@ -5,7 +5,7 @@ describe('Client Edit basicData path', () => {
const nightmare = createNightmare(); const nightmare = createNightmare();
describe('as employee', () => { describe('as employee', () => {
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitForLogin('employee'); .waitForLogin('employee');
}); });
@ -121,7 +121,7 @@ describe('Client Edit basicData path', () => {
describe('as salesAssistanrt', () => { describe('as salesAssistanrt', () => {
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitToClick(selectors.globalItems.logOutButton) .waitToClick(selectors.globalItems.logOutButton)
.waitForLogin('salesAssistant'); .waitForLogin('salesAssistant');
}); });

View File

@ -1,138 +1,136 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import createNightmare from '../../helpers/nightmare';
describe('Client', () => { describe('Client Add address path', () => {
describe('Add address path', () => { const nightmare = createNightmare();
const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitForLogin('employee'); .waitForLogin('employee');
}); });
it('should click on the Clients button of the top bar menu', async () => { it('should click on the Clients button of the top bar menu', async () => {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.parsedUrl(); .parsedUrl();
expect(url.hash).toEqual('#!/client/index'); expect(url.hash).toEqual('#!/client/index');
}); });
it('should search for the user Bruce Banner', async () => { it('should search for the user Bruce Banner', async () => {
const resultCount = await nightmare const resultCount = await nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countElement(selectors.clientsIndex.searchResult); .countElement(selectors.clientsIndex.searchResult);
expect(resultCount).toEqual(1); expect(resultCount).toEqual(1);
}); });
it(`should click on the search result to access to the client addresses`, async () => { it(`should click on the search result to access to the client addresses`, async () => {
const url = await nightmare const url = await nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner')
.waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientAddresses.addressesButton) .waitToClick(selectors.clientAddresses.addressesButton)
.waitForURL('address/index') .waitForURL('address/index')
.url(); .url();
expect(url).toContain('address/index'); expect(url).toContain('address/index');
}); });
it(`should click on the add new address button to access to the new address form`, async () => { it(`should click on the add new address button to access to the new address form`, async () => {
const url =await nightmare const url = await nightmare
.waitToClick(selectors.clientAddresses.createAddress) .waitToClick(selectors.clientAddresses.createAddress)
.waitForURL('address/create') .waitForURL('address/create')
.url(); .url();
expect(url).toContain('address/create'); expect(url).toContain('address/create');
}); });
it(`should return to the addreses section by clicking the cancel button`, async () => { it(`should return to the addreses section by clicking the cancel button`, async () => {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.clientAddresses.cancelButton) .waitToClick(selectors.clientAddresses.cancelButton)
.waitForURL('address/index') .waitForURL('address/index')
.url(); .url();
expect(url).toContain('address/index'); expect(url).toContain('address/index');
}); });
it(`should now click on the add new address button to access to the new address form`, async () => { it(`should now click on the add new address button to access to the new address form`, async () => {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.clientAddresses.createAddress) .waitToClick(selectors.clientAddresses.createAddress)
.waitForURL('address/create') .waitForURL('address/create')
.url(); .url();
expect(url).toContain('address/create'); expect(url).toContain('address/create');
}); });
it('should receive an error after clicking save button as consignee, street and town fields are empty', async () => { it('should receive an error after clicking save button as consignee, street and town fields are empty', async () => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.clientAddresses.defaultCheckboxInput) .waitToClick(selectors.clientAddresses.defaultCheckboxInput)
.clearInput(selectors.clientAddresses.streetAddressInput) .clearInput(selectors.clientAddresses.streetAddressInput)
.type(selectors.clientAddresses.postcodeInput, '10022') .type(selectors.clientAddresses.postcodeInput, '10022')
.waitToClick(selectors.clientAddresses.provinceInput) .waitToClick(selectors.clientAddresses.provinceInput)
.waitToClick(selectors.clientAddresses.provinceSecondOption) .waitToClick(selectors.clientAddresses.provinceSecondOption)
.waitToClick(selectors.clientAddresses.agencyInput) .waitToClick(selectors.clientAddresses.agencyInput)
.waitToClick(selectors.clientAddresses.agenctySecondOption) .waitToClick(selectors.clientAddresses.agenctySecondOption)
.type(selectors.clientAddresses.phoneInput, '999887744') .type(selectors.clientAddresses.phoneInput, '999887744')
.type(selectors.clientAddresses.mobileInput, '999887744') .type(selectors.clientAddresses.mobileInput, '999887744')
.waitToClick(selectors.clientFiscalData.saveButton) .waitToClick(selectors.clientFiscalData.saveButton)
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('Some fields are invalid'); expect(result).toEqual('Some fields are invalid');
}); });
it(`should create a new address with all it's data`, async () => { it(`should create a new address with all it's data`, async () => {
const result = await nightmare const result = await nightmare
.type(selectors.clientAddresses.consigneeInput, 'Bruce Bunner') .type(selectors.clientAddresses.consigneeInput, 'Bruce Bunner')
.type(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York') .type(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York')
.type(selectors.clientAddresses.cityInput, 'New York') .type(selectors.clientAddresses.cityInput, 'New York')
.click(selectors.clientAddresses.saveButton) .click(selectors.clientAddresses.saveButton)
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it(`should click on the addresses button confirm the new address exists and it's the default one`, async () => { it(`should click on the addresses button confirm the new address exists and it's the default one`, async () => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.clientAddresses.addressesButton) .waitToClick(selectors.clientAddresses.addressesButton)
.wait(selectors.clientAddresses.defaultAddress) .wait(selectors.clientAddresses.defaultAddress)
.getInnerText(selectors.clientAddresses.defaultAddress); .getInnerText(selectors.clientAddresses.defaultAddress);
expect(result).toContain('320 Park Avenue New York'); expect(result).toContain('320 Park Avenue New York');
}); });
it(`should click on the make default icon of the second address then confirm it is the default one now`, async () => { it(`should click on the make default icon of the second address then confirm it is the default one now`, async () => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.clientAddresses.secondMakeDefaultStar) .waitToClick(selectors.clientAddresses.secondMakeDefaultStar)
.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand') .waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand')
.getInnerText(selectors.clientAddresses.defaultAddress); .getInnerText(selectors.clientAddresses.defaultAddress);
expect(result).toContain('Somewhere in Thailand'); expect(result).toContain('Somewhere in Thailand');
}); });
it(`should click on the edit icon of the default address`, async () => { it(`should click on the edit icon of the default address`, async () => {
const url = await nightmare const url = await nightmare
.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand') .waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand')
.waitToClick(selectors.clientAddresses.firstEditButton) .waitToClick(selectors.clientAddresses.firstEditButton)
.waitForURL('/edit') .waitForURL('/edit')
.url(); .url();
expect(url).toContain('/edit'); expect(url).toContain('/edit');
}); });
it(`should click on the active checkbox and receive an error to save it because it is the default address`, async () => { it(`should click on the active checkbox and receive an error to save it because it is the default address`, async () => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.clientAddresses.activeCheckbox) .waitToClick(selectors.clientAddresses.activeCheckbox)
.waitToClick(selectors.clientAddresses.saveButton) .waitToClick(selectors.clientAddresses.saveButton)
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('The default consignee can not be unchecked'); expect(result).toEqual('The default consignee can not be unchecked');
});
}); });
}); });

View File

@ -5,7 +5,7 @@ describe('Client add address notes path', () => {
const nightmare = createNightmare(); const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitForLogin('employee'); .waitForLogin('employee');
}); });

View File

@ -1,79 +1,77 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import createNightmare from '../../helpers/nightmare';
describe('Client', () => { describe('Client Edit web access path', () => {
describe('Edit web access path', () => { const nightmare = createNightmare();
const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitForLogin('employee'); .waitForLogin('employee');
}); });
it('should click on the Clients button of the top bar menu', async () => { it('should click on the Clients button of the top bar menu', async () => {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.parsedUrl(); .parsedUrl();
expect(url.hash).toEqual('#!/client/index'); expect(url.hash).toEqual('#!/client/index');
}); });
it('should search for the user Bruce Banner', async () => { it('should search for the user Bruce Banner', async () => {
const resultCount = await nightmare const resultCount = await nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countElement(selectors.clientsIndex.searchResult); .countElement(selectors.clientsIndex.searchResult);
expect(resultCount).toEqual(1); expect(resultCount).toEqual(1);
}); });
it(`should click on the search result to access to the client's web access`, async () => { it(`should click on the search result to access to the client's web access`, async () => {
const url = await nightmare const url = await nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner')
.waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientsIndex.othersButton) .waitToClick(selectors.clientsIndex.othersButton)
.waitToClick(selectors.clientWebAccess.webAccessButton) .waitToClick(selectors.clientWebAccess.webAccessButton)
.waitForURL('web-access') .waitForURL('web-access')
.url(); .url();
expect(url).toContain('web-access'); expect(url).toContain('web-access');
}); });
it(`should uncheck the Enable web access checkbox and update the name`, async () => { it(`should uncheck the Enable web access checkbox and update the name`, async () => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.clientWebAccess.enableWebAccessCheckbox) .waitToClick(selectors.clientWebAccess.enableWebAccessCheckbox)
.clearInput(selectors.clientWebAccess.userNameInput) .clearInput(selectors.clientWebAccess.userNameInput)
.type(selectors.clientWebAccess.userNameInput, 'Hulk') .type(selectors.clientWebAccess.userNameInput, 'Hulk')
.waitToClick(selectors.clientWebAccess.saveButton) .waitToClick(selectors.clientWebAccess.saveButton)
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should confirm web access is now unchecked', async () => { it('should confirm web access is now unchecked', async () => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.clientBasicData.basicDataButton) .waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientsIndex.othersButton) .waitToClick(selectors.clientsIndex.othersButton)
.waitToClick(selectors.clientWebAccess.webAccessButton) .waitToClick(selectors.clientWebAccess.webAccessButton)
.wait(selectors.clientWebAccess.enableWebAccessCheckbox) .wait(selectors.clientWebAccess.enableWebAccessCheckbox)
.evaluate((selector) => { .evaluate(selector => {
return document.querySelector(selector).checked; return document.querySelector(selector).checked;
}, selectors.clientWebAccess.enableWebAccessCheckbox); }, selectors.clientWebAccess.enableWebAccessCheckbox);
expect(result).toBeFalsy(); expect(result).toBeFalsy();
}); });
it('should confirm web access name have been updated', async () => { it('should confirm web access name have been updated', async () => {
const result = await nightmare const result = await nightmare
.getInputValue(selectors.clientWebAccess.userNameInput); .getInputValue(selectors.clientWebAccess.userNameInput);
expect(result).toEqual('Hulk'); expect(result).toEqual('Hulk');
});
}); });
}); });

View File

@ -1,72 +1,70 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import createNightmare from '../../helpers/nightmare';
describe('Client', () => { describe('Client Add notes path', () => {
describe('Add notes path', () => { const nightmare = createNightmare();
const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitForLogin('employee'); .waitForLogin('employee');
}); });
it('should click on the Clients button of the top bar menu', async ()=> { it('should click on the Clients button of the top bar menu', async ()=> {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.parsedUrl(); .parsedUrl();
expect(url.hash).toEqual('#!/client/index'); expect(url.hash).toEqual('#!/client/index');
}); });
it('should search for the user Bruce Banner', async () => { it('should search for the user Bruce Banner', async () => {
const resultCount = await nightmare const resultCount = await nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countElement(selectors.clientsIndex.searchResult); .countElement(selectors.clientsIndex.searchResult);
expect(resultCount).toEqual(1); expect(resultCount).toEqual(1);
}); });
it(`should click on the search result to access to the client's notes`, async () => { it(`should click on the search result to access to the client's notes`, async () => {
const url = await nightmare const url = await nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner')
.waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientNotes.notesButton) .waitToClick(selectors.clientNotes.notesButton)
.waitForURL('note/index') .waitForURL('note/index')
.url(); .url();
expect(url).toContain('note/index'); expect(url).toContain('note/index');
}); });
it(`should click on the add note button`, async () => { it(`should click on the add note button`, async () => {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.clientNotes.addNoteFloatButton) .waitToClick(selectors.clientNotes.addNoteFloatButton)
.waitForURL('/note/create') .waitForURL('/note/create')
.url(); .url();
expect(url).toContain('/note/create'); expect(url).toContain('/note/create');
}); });
it(`should create a note`, async () => { it(`should create a note`, async () => {
const result = await nightmare const result = await nightmare
.type(selectors.clientNotes.noteInput, 'Meeting with Black Widow 21st 9am') .type(selectors.clientNotes.noteInput, 'Meeting with Black Widow 21st 9am')
.click(selectors.clientNotes.saveButton) .click(selectors.clientNotes.saveButton)
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should confirm the note was created', async () => { it('should confirm the note was created', async () => {
const result = await nightmare const result = await nightmare
.wait(selectors.clientNotes.firstNoteText) .wait(selectors.clientNotes.firstNoteText)
.getInnerText(selectors.clientNotes.firstNoteText); .getInnerText(selectors.clientNotes.firstNoteText);
expect(result).toEqual('Meeting with Black Widow 21st 9am'); expect(result).toEqual('Meeting with Black Widow 21st 9am');
});
}); });
}); });

View File

@ -1,74 +1,72 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import createNightmare from '../../helpers/nightmare';
describe('Client', () => { describe('Client Add credit path', () => {
describe('Add credit path', () => { const nightmare = createNightmare();
const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitForLogin('salesAssistant'); .waitForLogin('salesAssistant');
}); });
it('should click on the Clients button of the top bar menu', async () => { it('should click on the Clients button of the top bar menu', async () => {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.parsedUrl(); .parsedUrl();
expect(url.hash).toEqual('#!/client/index'); expect(url.hash).toEqual('#!/client/index');
}); });
it('should search for the user Hank Pym', async () => { it('should search for the user Hank Pym', async () => {
const resultCount = await nightmare const resultCount = await nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Hank Pym') .type(selectors.clientsIndex.searchClientInput, 'Hank Pym')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countElement(selectors.clientsIndex.searchResult); .countElement(selectors.clientsIndex.searchResult);
expect(resultCount).toEqual(1); expect(resultCount).toEqual(1);
}); });
it(`should click on the search result to access to the client's credit`, async () => { it(`should click on the search result to access to the client's credit`, async () => {
const url = await nightmare const url = await nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Hank Pym') .waitForTextInElement(selectors.clientsIndex.searchResult, 'Hank Pym')
.waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientCredit.creditButton) .waitToClick(selectors.clientCredit.creditButton)
.waitForURL('credit/index') .waitForURL('credit/index')
.url(); .url();
expect(url).toContain('credit/index'); expect(url).toContain('credit/index');
}); });
it(`should click on the add credit button`, async () => { it(`should click on the add credit button`, async () => {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.clientCredit.addCreditFloatButton) .waitToClick(selectors.clientCredit.addCreditFloatButton)
.waitForURL('/credit/create') .waitForURL('/credit/create')
.url(); .url();
expect(url).toContain('/credit/create'); expect(url).toContain('/credit/create');
}); });
it(`should edit the credit`, async () => { it(`should edit the credit`, async () => {
const result = await nightmare const result = await nightmare
.clearInput(selectors.clientCredit.creditInput) .clearInput(selectors.clientCredit.creditInput)
.type(selectors.clientCredit.creditInput, 999) .type(selectors.clientCredit.creditInput, 999)
.click(selectors.clientCredit.saveButton) .click(selectors.clientCredit.saveButton)
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should confirm the credit was updated', async () => { it('should confirm the credit was updated', async () => {
const result = await nightmare const result = await nightmare
.wait(selectors.clientCredit.firstCreditText) .wait(selectors.clientCredit.firstCreditText)
.getInnerText(selectors.clientCredit.firstCreditText); .getInnerText(selectors.clientCredit.firstCreditText);
expect(result).toContain(999); expect(result).toContain(999);
expect(result).toContain('salesAssistant'); expect(result).toContain('salesAssistant');
});
}); });
}); });

View File

@ -1,86 +1,84 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import createNightmare from '../../helpers/nightmare';
describe('Client', () => { describe('Client Add greuge path', () => {
describe('Add greuge path', () => { const nightmare = createNightmare();
const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitForLogin('salesAssistant'); .waitForLogin('salesAssistant');
}); });
it('should click on the Clients button of the top bar menu', async () => { it('should click on the Clients button of the top bar menu', async () => {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.parsedUrl(); .parsedUrl();
expect(url.hash).toEqual('#!/client/index'); expect(url.hash).toEqual('#!/client/index');
}); });
it('should search for the user Petter Parker', async () => { it('should search for the user Petter Parker', async () => {
const resultCount = await nightmare const resultCount = await nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker') .type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countElement(selectors.clientsIndex.searchResult); .countElement(selectors.clientsIndex.searchResult);
expect(resultCount).toEqual(1); expect(resultCount).toEqual(1);
}); });
it(`should click on the search result to access to the client's greuge`, async () => { it(`should click on the search result to access to the client's greuge`, async () => {
const url = await nightmare const url = await nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientGreuge.greugeButton) .waitToClick(selectors.clientGreuge.greugeButton)
.waitForURL('greuge/index') .waitForURL('greuge/index')
.url(); .url();
expect(url).toContain('greuge/index'); expect(url).toContain('greuge/index');
}); });
it(`should click on the add greuge button`, async () => { it(`should click on the add greuge button`, async () => {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.clientGreuge.addGreugeFloatButton) .waitToClick(selectors.clientGreuge.addGreugeFloatButton)
.waitForURL('greuge/create') .waitForURL('greuge/create')
.url(); .url();
expect(url).toContain('greuge/create'); expect(url).toContain('greuge/create');
}); });
it(`should receive an error if all fields are empty but date and type on submit`, async () => { it(`should receive an error if all fields are empty but date and type on submit`, async () => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.clientGreuge.typeInput) .waitToClick(selectors.clientGreuge.typeInput)
.waitToClick(selectors.clientGreuge.typeSecondOption) .waitToClick(selectors.clientGreuge.typeSecondOption)
.click(selectors.clientGreuge.saveButton) .click(selectors.clientGreuge.saveButton)
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('Some fields are invalid'); expect(result).toEqual('Some fields are invalid');
}); });
it(`should create a new greuge with all its data`, async () => { it(`should create a new greuge with all its data`, async () => {
const result = await nightmare const result = await nightmare
.type(selectors.clientGreuge.amountInput, 999) .type(selectors.clientGreuge.amountInput, 999)
.waitForTextInInput(selectors.clientGreuge.amountInput, '999') .waitForTextInInput(selectors.clientGreuge.amountInput, '999')
.type(selectors.clientGreuge.descriptionInput, 'new armor for Batman!') .type(selectors.clientGreuge.descriptionInput, 'new armor for Batman!')
.click(selectors.clientGreuge.saveButton) .click(selectors.clientGreuge.saveButton)
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should confirm the greuge was added to the list', async () => { it('should confirm the greuge was added to the list', async () => {
const result = await nightmare const result = await nightmare
.wait(selectors.clientGreuge.firstGreugeText) .wait(selectors.clientGreuge.firstGreugeText)
.getInnerText(selectors.clientGreuge.firstGreugeText); .getInnerText(selectors.clientGreuge.firstGreugeText);
expect(result).toContain(999); expect(result).toContain(999);
expect(result).toContain('new armor for Batman!'); expect(result).toContain('new armor for Batman!');
expect(result).toContain('Diff'); expect(result).toContain('Diff');
});
}); });
}); });

View File

@ -1,57 +1,55 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import createNightmare from '../../helpers/nightmare';
describe('Client', () => { describe('Client mandate path', () => {
describe('mandate path', () => { const nightmare = createNightmare();
const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitForLogin('salesPerson'); .waitForLogin('salesPerson');
}); });
it('should click on the Clients button of the top bar menu', async () => { it('should click on the Clients button of the top bar menu', async () => {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.parsedUrl(); .parsedUrl();
expect(url.hash).toEqual('#!/client/index'); expect(url.hash).toEqual('#!/client/index');
}); });
it('should search for the user Petter Parker', async () => { it('should search for the user Petter Parker', async () => {
const resultCount = await nightmare const resultCount = await nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker') .type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countElement(selectors.clientsIndex.searchResult); .countElement(selectors.clientsIndex.searchResult);
expect(resultCount).toEqual(1); expect(resultCount).toEqual(1);
}); });
it(`should click on the search result to access to the client's mandate`, async () => { it(`should click on the search result to access to the client's mandate`, async () => {
const url = await nightmare const url = await nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter') .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter')
.waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientsIndex.othersButton) .waitToClick(selectors.clientsIndex.othersButton)
.waitToClick(selectors.clientMandate.mandateButton) .waitToClick(selectors.clientMandate.mandateButton)
.waitForURL('mandate') .waitForURL('mandate')
.url(); .url();
expect(url).toContain('mandate'); expect(url).toContain('mandate');
}); });
it('should confirm the client has a mandate of the CORE type', async () => { it('should confirm the client has a mandate of the CORE type', async () => {
const result = await nightmare const result = await nightmare
.wait(selectors.clientMandate.firstMandateText) .wait(selectors.clientMandate.firstMandateText)
.getInnerText(selectors.clientMandate.firstMandateText); .getInnerText(selectors.clientMandate.firstMandateText);
expect(result).toContain('1'); expect(result).toContain('1');
expect(result).toContain('VNL'); expect(result).toContain('VNL');
expect(result).toContain('CORE'); expect(result).toContain('CORE');
});
}); });
}); });

View File

@ -6,7 +6,7 @@ describe('Client lock verified data path', () => {
describe('as salesPerson', () => { describe('as salesPerson', () => {
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitForLogin('salesPerson'); .waitForLogin('salesPerson');
}); });
@ -87,7 +87,7 @@ describe('Client lock verified data path', () => {
describe('as administrative', () => { describe('as administrative', () => {
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitToClick(selectors.globalItems.logOutButton) .waitToClick(selectors.globalItems.logOutButton)
.waitForLogin('administrative'); .waitForLogin('administrative');
}); });
@ -191,7 +191,7 @@ describe('Client lock verified data path', () => {
describe('as salesPerson second run', () => { describe('as salesPerson second run', () => {
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitToClick(selectors.globalItems.logOutButton) .waitToClick(selectors.globalItems.logOutButton)
.waitForLogin('salesPerson'); .waitForLogin('salesPerson');
}); });
@ -262,7 +262,7 @@ describe('Client lock verified data path', () => {
describe('as salesAssistant', () => { describe('as salesAssistant', () => {
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitToClick(selectors.globalItems.logOutButton) .waitToClick(selectors.globalItems.logOutButton)
.waitForLogin('salesAssistant'); .waitForLogin('salesAssistant');
}); });
@ -344,7 +344,7 @@ describe('Client lock verified data path', () => {
describe('as salesPerson third run', () => { describe('as salesPerson third run', () => {
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitToClick(selectors.globalItems.logOutButton) .waitToClick(selectors.globalItems.logOutButton)
.waitForLogin('salesPerson'); .waitForLogin('salesPerson');
}); });

View File

@ -5,7 +5,7 @@ describe('Client log path', () => {
const nightmare = createNightmare(); const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitForLogin('employee'); .waitForLogin('employee');
}); });

View File

@ -5,7 +5,7 @@ describe('Client risk path', () => {
const nightmare = createNightmare(); const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitForLogin('administrative'); .waitForLogin('administrative');
}); });

View File

@ -30,17 +30,16 @@ describe('Item summary path', () => {
}); });
it(`should click on the search result summary button to open the item summary popup`, async () => { it(`should click on the search result summary button to open the item summary popup`, async () => {
const result = await nightmare const isVisibleBefore = await nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time') .waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time')
.isVisible(selectors.itemSummary.basicData) .isVisible(selectors.itemSummary.basicData);
.then(result => {
expect(result).toBeFalsy();
return nightmare
.waitToClick(selectors.itemsIndex.searchResultPreviewButton)
.isVisible(selectors.itemSummary.basicData);
});
expect(result).toBeTruthy(); const isVisibleAfter = await nightmare
.waitToClick(selectors.itemsIndex.searchResultPreviewButton)
.isVisible(selectors.itemSummary.basicData);
expect(isVisibleBefore).toBeFalsy();
expect(isVisibleAfter).toBeTruthy();
}); });
it(`should check the item summary preview shows fields from basic data`, async () => { it(`should check the item summary preview shows fields from basic data`, async () => {
@ -104,17 +103,17 @@ describe('Item summary path', () => {
}); });
it(`should now click on the search result summary button to open the item summary popup`, async () => { it(`should now click on the search result summary button to open the item summary popup`, async () => {
const result = await nightmare const isVisibleBefore = await nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Mind') .waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Mind')
.isVisible(selectors.itemSummary.basicData) .isVisible(selectors.itemSummary.basicData);
.then(result => {
expect(result).toBeFalsy();
return nightmare
.waitToClick(selectors.itemsIndex.searchResultPreviewButton)
.isVisible(selectors.itemSummary.basicData);
});
expect(result).toBeTruthy(); const isVisibleAfter = await nightmare
.waitToClick(selectors.itemsIndex.searchResultPreviewButton)
.isVisible(selectors.itemSummary.basicData);
expect(isVisibleBefore).toBeFalsy();
expect(isVisibleAfter).toBeTruthy();
}); });
it(`should now check the item summary preview shows fields from basic data`, async () => { it(`should now check the item summary preview shows fields from basic data`, async () => {

View File

@ -1,130 +1,133 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import createNightmare from '../../helpers/nightmare';
describe('Item', () => { describe('Item Edit basic data path', () => {
describe('Edit basic data path', () => { const nightmare = createNightmare();
const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitForLogin('buyer'); .waitForLogin('buyer');
}); });
it('should access to the items index by clicking the items button', async () => { it('should access to the items index by clicking the items button', async () => {
const url = await nightmare const url = await nightmare
.click(selectors.moduleAccessView.itemsSectionButton) .click(selectors.moduleAccessView.itemsSectionButton)
.wait(selectors.itemsIndex.createItemButton) .wait(selectors.itemsIndex.createItemButton)
.parsedUrl(); .parsedUrl();
expect(url.hash).toEqual('#!/item/index'); expect(url.hash).toEqual('#!/item/index');
}); });
it('should search for the item Gem of Mind', async () => { it('should search for the item Gem of Mind', async () => {
const resultCount = await nightmare const resultCount = await nightmare
.wait(selectors.itemsIndex.searchResult) .wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Gem of Mind') .type(selectors.itemsIndex.searchItemInput, 'Gem of Mind')
.click(selectors.itemsIndex.searchButton) .click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countElement(selectors.itemsIndex.searchResult); .countElement(selectors.itemsIndex.searchResult);
expect(resultCount).toEqual(1); expect(resultCount).toEqual(1);
}); });
it(`should click on the search result to access to the item basic data`, async () => { it(`should click on the search result to access to the item basic data`, async () => {
const url = await nightmare const url = await nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Mind') .waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Mind')
.waitToClick(selectors.itemsIndex.searchResult) .waitToClick(selectors.itemsIndex.searchResult)
.waitToClick(selectors.itemBasicData.basicDataButton) .waitToClick(selectors.itemBasicData.basicDataButton)
.waitForURL('data') .waitForURL('data')
.url(); .url();
expect(url).toContain('data'); expect(url).toContain('data');
}); });
it(`should edit the item basic data`, async () => { it(`should edit the item basic data`, async () => {
const result = await nightmare const result = await nightmare
.clearInput(selectors.itemBasicData.nameInput) .clearInput(selectors.itemBasicData.nameInput)
.type(selectors.itemBasicData.nameInput, 'Rose of Purity') .type(selectors.itemBasicData.nameInput, 'Rose of Purity')
.waitToClick(selectors.itemBasicData.typeSelect) .waitToClick(selectors.itemBasicData.typeSelect)
.waitToClick(selectors.itemBasicData.typeSelectOptionThree) .waitToClick(selectors.itemBasicData.typeSelectOptionThree)
.waitToClick(selectors.itemBasicData.intrastatSelect) .waitToClick(selectors.itemBasicData.intrastatSelect)
.waitToClick(selectors.itemBasicData.intrastatSelectOptionOne) .waitToClick(selectors.itemBasicData.intrastatSelectOptionOne)
.clearInput(selectors.itemBasicData.relevancyInput) .clearInput(selectors.itemBasicData.relevancyInput)
.type(selectors.itemBasicData.relevancyInput, '1') .type(selectors.itemBasicData.relevancyInput, '1')
.waitToClick(selectors.itemBasicData.originSelect) .waitToClick(selectors.itemBasicData.originSelect)
.waitToClick(selectors.itemBasicData.originSelectOptionTwo) .waitToClick(selectors.itemBasicData.originSelectOptionTwo)
.waitToClick(selectors.itemBasicData.expenceSelect) .waitToClick(selectors.itemBasicData.expenceSelect)
.waitToClick(selectors.itemBasicData.expenceSelectOptionThree) .waitToClick(selectors.itemBasicData.expenceSelectOptionThree)
.clearInput(selectors.itemBasicData.longNameInput) .clearInput(selectors.itemBasicData.longNameInput)
.type(selectors.itemBasicData.longNameInput, 'RS Rose of Purity') .type(selectors.itemBasicData.longNameInput, 'RS Rose of Purity')
.waitToClick(selectors.itemBasicData.isActiveCheckbox) .waitToClick(selectors.itemBasicData.isActiveCheckbox)
.click(selectors.itemBasicData.submitBasicDataButton) .click(selectors.itemBasicData.submitBasicDataButton)
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it(`should confirm the item name was edited`, async () => { it(`should confirm the item name was edited`, async () => {
const result = await nightmare const result = await nightmare
.click(selectors.itemNiches.nicheButton) .click(selectors.itemNiches.nicheButton)
.wait(selectors.itemNiches.firstWarehouseDisabled) .wait(selectors.itemNiches.firstWarehouseDisabled)
.waitToClick(selectors.itemBasicData.basicDataButton) .waitToClick(selectors.itemBasicData.basicDataButton)
.waitForTextInInput(selectors.itemBasicData.nameInput, 'Rose of Purity') .waitProperty(selectors.itemBasicData.nameInput, 'value')
.getInputValue(selectors.itemBasicData.nameInput); .getProperty(selectors.itemBasicData.nameInput, 'value');
expect(result).toEqual('Rose of Purity'); expect(result).toEqual('Rose of Purity');
}); });
it(`should confirm the item type was edited`, async () => { it(`should confirm the item type was edited`, async () => {
const result = await nightmare const result = await nightmare
.getInputValue(selectors.itemBasicData.typeSelect); .waitProperty(selectors.itemBasicData.typeSelect, 'value')
.getProperty(selectors.itemBasicData.typeSelect, 'value');
expect(result).toEqual('Crisantemo'); expect(result).toEqual('Crisantemo');
}); });
it(`should confirm the item intrastad was edited`, async () => { it(`should confirm the item intrastad was edited`, async () => {
const result = await nightmare const result = await nightmare
.waitProperty(selectors.itemBasicData.intrastatSelect, 'value') .waitProperty(selectors.itemBasicData.intrastatSelect, 'value')
.getProperty(selectors.itemBasicData.intrastatSelect, 'value'); .getProperty(selectors.itemBasicData.intrastatSelect, 'value');
expect(result).toEqual('5080000 Coral y materiales similares'); expect(result).toEqual('5080000 Coral y materiales similares');
}); });
it(`should confirm the item relevancy was edited`, async () => { it(`should confirm the item relevancy was edited`, async () => {
const result = await nightmare const result = await nightmare
.getInputValue(selectors.itemBasicData.relevancyInput); .waitProperty(selectors.itemBasicData.relevancyInput, 'value')
.getProperty(selectors.itemBasicData.relevancyInput, 'value');
expect(result).toEqual('1'); expect(result).toEqual('1');
}); });
it(`should confirm the item origin was edited`, async () => { it(`should confirm the item origin was edited`, async () => {
const result = await nightmare const result = await nightmare
.getInputValue(selectors.itemBasicData.originSelect); .waitProperty(selectors.itemBasicData.originSelect, 'value')
.getProperty(selectors.itemBasicData.originSelect, 'value');
expect(result).toEqual('Spain'); expect(result).toEqual('Spain');
}); });
it(`should confirm the item expence was edited`, async () => { it(`should confirm the item expence was edited`, async () => {
const result = await nightmare const result = await nightmare
.getInputValue(selectors.itemBasicData.expenceSelect); .waitProperty(selectors.itemBasicData.expenceSelect, 'value')
.getProperty(selectors.itemBasicData.expenceSelect, 'value');
expect(result).toEqual('Adquisición mercancia Extracomunitaria'); expect(result).toEqual('Adquisición mercancia Extracomunitaria');
}); });
it(`should confirm the item long name was edited`, async () => { it(`should confirm the item long name was edited`, async () => {
const result = await nightmare const result = await nightmare
.getInputValue(selectors.itemBasicData.longNameInput); .waitProperty(selectors.itemBasicData.longNameInput, 'value')
.getProperty(selectors.itemBasicData.longNameInput, 'value');
expect(result).toEqual('RS Rose of Purity'); expect(result).toEqual('RS Rose of Purity');
}); });
it('should confirm isActive checkbox is unchecked', async () => { it('should confirm isActive checkbox is unchecked', async () => {
const result = await nightmare const result = await nightmare
.evaluate((selector) => { .evaluate(selector => {
return document.querySelector(selector).checked; return document.querySelector(selector).checked;
}, selectors.itemBasicData.isActiveCheckbox); }, selectors.itemBasicData.isActiveCheckbox);
expect(result).toBeFalsy(); expect(result).toBeFalsy();
});
}); });
}); });

View File

@ -5,7 +5,7 @@ describe('Item edit tax path', () => {
const nightmare = createNightmare(); const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitForLogin('buyer'); .waitForLogin('buyer');
}); });

View File

@ -5,7 +5,7 @@ describe('Item create tags path', () => {
const nightmare = createNightmare(); const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitForLogin('buyer'); .waitForLogin('buyer');
}); });

View File

@ -5,7 +5,7 @@ describe('Item create niche path', () => {
const nightmare = createNightmare(); const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitForLogin('buyer'); .waitForLogin('buyer');
}); });

View File

@ -1,101 +1,86 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import createNightmare from '../../helpers/nightmare';
describe('Item', () => { describe('Item Create botanical path', () => {
describe('Create botanical path', () => { const nightmare = createNightmare();
const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitForLogin('buyer'); .waitForLogin('buyer');
}); });
it('should access to the items index by clicking the items button', done => { it('should access to the items index by clicking the items button', async () => {
return nightmare const url = await nightmare
.click(selectors.moduleAccessView.itemsSectionButton) .click(selectors.moduleAccessView.itemsSectionButton)
.wait(selectors.itemsIndex.createItemButton) .wait(selectors.itemsIndex.createItemButton)
.parsedUrl() .parsedUrl();
.then(url => {
expect(url.hash).toEqual('#!/item/index');
done();
}).catch(done.fail);
});
it('should search for the item Mjolnir', done => { expect(url.hash).toEqual('#!/item/index');
return nightmare });
it('should search for the item Mjolnir', async () => {
const result = await nightmare
.wait(selectors.itemsIndex.searchResult) .wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Mjolnir') .type(selectors.itemsIndex.searchItemInput, 'Mjolnir')
.click(selectors.itemsIndex.searchButton) .click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countElement(selectors.itemsIndex.searchResult) .countElement(selectors.itemsIndex.searchResult);
.then(result => {
expect(result).toEqual(1);
done();
}).catch(done.fail);
});
it(`should click on the search result to access to the item botanical`, done => { expect(result).toEqual(1);
return nightmare });
it(`should click on the search result to access to the item botanical`, async () => {
const url = await nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Mjolnir') .waitForTextInElement(selectors.itemsIndex.searchResult, 'Mjolnir')
.waitToClick(selectors.itemsIndex.searchResult) .waitToClick(selectors.itemsIndex.searchResult)
.waitToClick(selectors.itemBotanical.botanicalButton) .waitToClick(selectors.itemBotanical.botanicalButton)
.waitForURL('botanical') .waitForURL('botanical')
.url() .url();
.then(url => {
expect(url).toContain('botanical');
done();
}).catch(done.fail);
});
it(`should create a new botanical for the item with id Mjolnir`, done => { expect(url).toContain('botanical');
return nightmare });
it(`should create a new botanical for the item with id Mjolnir`, async () => {
const result = await nightmare
.type(selectors.itemBotanical.botanicalInput, 'Cicuta maculata') .type(selectors.itemBotanical.botanicalInput, 'Cicuta maculata')
.waitToClick(selectors.itemBotanical.genusSelect) .waitToClick(selectors.itemBotanical.genusSelect)
.waitToClick(selectors.itemBotanical.genusSelectOptionOne) .waitToClick(selectors.itemBotanical.genusSelectOptionOne)
.waitToClick(selectors.itemBotanical.speciesSelect) .waitToClick(selectors.itemBotanical.speciesSelect)
.waitToClick(selectors.itemBotanical.speciesSelectOptionOne) .waitToClick(selectors.itemBotanical.speciesSelectOptionOne)
.waitToClick(selectors.itemBotanical.submitBotanicalButton) .waitToClick(selectors.itemBotanical.submitBotanicalButton)
.waitForLastSnackbar() .waitForLastSnackbar();
.then(result => {
expect(result).toEqual('Data saved!');
done();
}).catch(done.fail);
});
it(`should confirm the botanical for item Mjolnir was created`, done => { expect(result).toEqual('Data saved!');
return nightmare });
it(`should confirm the botanical for item Mjolnir was created`, async () => {
const result = await nightmare
.click(selectors.itemBasicData.basicDataButton) .click(selectors.itemBasicData.basicDataButton)
.wait(selectors.itemBasicData.nameInput) .wait(selectors.itemBasicData.nameInput)
.click(selectors.itemBotanical.botanicalButton) .click(selectors.itemBotanical.botanicalButton)
.waitForTextInInput(selectors.itemBotanical.botanicalInput, 'Cicuta maculata') .waitForTextInInput(selectors.itemBotanical.botanicalInput, 'Cicuta maculata')
.getInputValue(selectors.itemBotanical.botanicalInput) .getInputValue(selectors.itemBotanical.botanicalInput);
.then(result => {
expect(result).toEqual('Cicuta maculata');
done();
}).catch(done.fail);
});
it(`should confirm the Genus for item Mjolnir was created`, done => { expect(result).toEqual('Cicuta maculata');
return nightmare });
it(`should confirm the Genus for item Mjolnir was created`, async () => {
const result = await nightmare
.waitForTextInInput(selectors.itemBotanical.genusSelect, 'Abelia') .waitForTextInInput(selectors.itemBotanical.genusSelect, 'Abelia')
.getInputValue(selectors.itemBotanical.genusSelect) .getInputValue(selectors.itemBotanical.genusSelect);
.then(result => {
expect(result).toEqual('Abelia');
done();
}).catch(done.fail);
});
it(`should confirm the Species for item Mjolnir was created`, done => { expect(result).toEqual('Abelia');
return nightmare });
.getInputValue(selectors.itemBotanical.speciesSelect)
.then(result => {
expect(result).toEqual('dealbata');
done();
}).catch(done.fail);
});
it(`should edit botanical for the item Mjolnir`, done => { it(`should confirm the Species for item Mjolnir was created`, async () => {
return nightmare const result = await nightmare
.getInputValue(selectors.itemBotanical.speciesSelect);
expect(result).toEqual('dealbata');
});
it(`should edit botanical for the item Mjolnir`, async () => {
const result = await nightmare
.clearInput(selectors.itemBotanical.botanicalInput) .clearInput(selectors.itemBotanical.botanicalInput)
.type(selectors.itemBotanical.botanicalInput, 'Herp Derp') .type(selectors.itemBotanical.botanicalInput, 'Herp Derp')
.waitToClick(selectors.itemBotanical.genusSelect) .waitToClick(selectors.itemBotanical.genusSelect)
@ -103,43 +88,34 @@ describe('Item', () => {
.waitToClick(selectors.itemBotanical.speciesSelect) .waitToClick(selectors.itemBotanical.speciesSelect)
.waitToClick(selectors.itemBotanical.speciesSelectOptionTwo) .waitToClick(selectors.itemBotanical.speciesSelectOptionTwo)
.waitToClick(selectors.itemBotanical.submitBotanicalButton) .waitToClick(selectors.itemBotanical.submitBotanicalButton)
.waitForLastSnackbar() .waitForLastSnackbar();
.then(result => {
expect(result).toEqual('Data saved!');
done();
}).catch(done.fail);
});
it(`should confirm the botanical for item Mjolnir was edited`, done => { expect(result).toEqual('Data saved!');
return nightmare });
it(`should confirm the botanical for item Mjolnir was edited`, async () => {
const result = await nightmare
.click(selectors.itemBasicData.basicDataButton) .click(selectors.itemBasicData.basicDataButton)
.wait(selectors.itemBasicData.nameInput) .wait(selectors.itemBasicData.nameInput)
.click(selectors.itemBotanical.botanicalButton) .click(selectors.itemBotanical.botanicalButton)
.waitForTextInInput(selectors.itemBotanical.botanicalInput, 'Herp Derp') .waitForTextInInput(selectors.itemBotanical.botanicalInput, 'Herp Derp')
.getInputValue(selectors.itemBotanical.botanicalInput) .getInputValue(selectors.itemBotanical.botanicalInput);
.then(result => {
expect(result).toEqual('Herp Derp');
done();
}).catch(done.fail);
});
it(`should confirm the Genus for item Mjolnir was edited`, done => { expect(result).toEqual('Herp Derp');
return nightmare });
it(`should confirm the Genus for item Mjolnir was edited`, async () => {
const result = await nightmare
.waitForTextInInput(selectors.itemBotanical.genusSelect, 'Abies') .waitForTextInInput(selectors.itemBotanical.genusSelect, 'Abies')
.getInputValue(selectors.itemBotanical.genusSelect) .getInputValue(selectors.itemBotanical.genusSelect);
.then(result => {
expect(result).toEqual('Abies');
done();
}).catch(done.fail);
});
it(`should confirm the Species for item Mjolnir was edited`, done => { expect(result).toEqual('Abies');
return nightmare });
.getInputValue(selectors.itemBotanical.speciesSelect)
.then(result => { it(`should confirm the Species for item Mjolnir was edited`, async () => {
expect(result).toEqual('decurrens'); const result = await nightmare
done(); .getInputValue(selectors.itemBotanical.speciesSelect);
}).catch(done.fail);
}); expect(result).toEqual('decurrens');
}); });
}); });

View File

@ -1,77 +1,65 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import createNightmare from '../../helpers/nightmare';
describe('Item', () => { describe('Item Create barcodes path', () => {
describe('Create barcodes path', () => { const nightmare = createNightmare();
const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitForLogin('buyer'); .waitForLogin('buyer');
}); });
it('should access to the items index by clicking the items button', done => { it('should access to the items index by clicking the items button', async () => {
return nightmare const url = await nightmare
.click(selectors.moduleAccessView.itemsSectionButton) .click(selectors.moduleAccessView.itemsSectionButton)
.wait(selectors.itemsIndex.createItemButton) .wait(selectors.itemsIndex.createItemButton)
.parsedUrl() .parsedUrl();
.then(url => {
expect(url.hash).toEqual('#!/item/index');
done();
}).catch(done.fail);
});
it('should search for the item Gem of Time', done => { expect(url.hash).toEqual('#!/item/index');
return nightmare });
it('should search for the item Gem of Time', async () => {
const result = await nightmare
.wait(selectors.itemsIndex.searchResult) .wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Gem of Time') .type(selectors.itemsIndex.searchItemInput, 'Gem of Time')
.click(selectors.itemsIndex.searchButton) .click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countElement(selectors.itemsIndex.searchResult) .countElement(selectors.itemsIndex.searchResult);
.then(result => {
expect(result).toEqual(1);
done();
}).catch(done.fail);
});
it(`should click on the search result to access to the item barcodes`, done => { expect(result).toEqual(1);
return nightmare });
it(`should click on the search result to access to the item barcodes`, async () => {
const url = await nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time') .waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time')
.waitToClick(selectors.itemsIndex.searchResult) .waitToClick(selectors.itemsIndex.searchResult)
.waitToClick(selectors.itemBarcodes.barcodeButton) .waitToClick(selectors.itemBarcodes.barcodeButton)
.waitForURL('barcode') .waitForURL('barcode')
.url() .url();
.then(url => {
expect(url).toContain('barcode');
done();
}).catch(done.fail);
});
it(`should click create a new code and delete a former one`, done => { expect(url).toContain('barcode');
return nightmare });
it(`should click create a new code and delete a former one`, async () => {
const result = await nightmare
.waitToClick(selectors.itemBarcodes.firstCodeRemoveButton) .waitToClick(selectors.itemBarcodes.firstCodeRemoveButton)
.waitToClick(selectors.itemBarcodes.addBarcodeButton) .waitToClick(selectors.itemBarcodes.addBarcodeButton)
.wait(selectors.itemBarcodes.thirdCodeInput) .wait(selectors.itemBarcodes.thirdCodeInput)
.type(selectors.itemBarcodes.thirdCodeInput, '5') .type(selectors.itemBarcodes.thirdCodeInput, '5')
.waitToClick(selectors.itemBarcodes.submitBarcodesButton) .waitToClick(selectors.itemBarcodes.submitBarcodesButton)
.waitForLastSnackbar() .waitForLastSnackbar();
.then(result => {
expect(result).toEqual('Data saved!');
done();
}).catch(done.fail);
});
it(`should confirm the barcode 5 is created and it is now the third barcode as the first was deleted`, done => { expect(result).toEqual('Data saved!');
return nightmare });
it(`should confirm the barcode 5 is created and it is now the third barcode as the first was deleted`, async () => {
const result = await nightmare
.click(selectors.itemBasicData.basicDataButton) .click(selectors.itemBasicData.basicDataButton)
.wait(selectors.itemBasicData.nameInput) .wait(selectors.itemBasicData.nameInput)
.click(selectors.itemBarcodes.barcodeButton) .click(selectors.itemBarcodes.barcodeButton)
.waitForTextInInput(selectors.itemBarcodes.thirdCodeInput, '5') .waitForTextInInput(selectors.itemBarcodes.thirdCodeInput, '5')
.getInputValue(selectors.itemBarcodes.thirdCodeInput) .getInputValue(selectors.itemBarcodes.thirdCodeInput);
.then(result => {
expect(result).toEqual('5'); expect(result).toEqual('5');
done();
}).catch(done.fail);
});
}); });
}); });

View File

@ -1,145 +1,143 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import createNightmare from '../../helpers/nightmare';
describe('Item', () => { describe('Item Create path', () => {
const nightmare = createNightmare(); const nightmare = createNightmare();
describe('Create path', () => { beforeAll(() => {
beforeAll(() => { nightmare
return nightmare .waitForLogin('buyer');
.waitForLogin('buyer');
});
it('should access to the items index by clicking the items button', async () => {
const url = await nightmare
.click(selectors.moduleAccessView.itemsSectionButton)
.wait(selectors.itemsIndex.createItemButton)
.parsedUrl();
expect(url.hash).toEqual('#!/item/index');
});
it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async () => {
const result = await nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 0)
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(0);
});
it('should access to the create item view by clicking the create floating button', async () => {
const url = await nightmare
.click(selectors.itemsIndex.createItemButton)
.wait(selectors.itemCreateView.createButton)
.parsedUrl();
expect(url.hash).toEqual('#!/item/create');
});
it('should return to the item index by clickig the cancel button', async () => {
const url = await nightmare
.click(selectors.itemCreateView.cancelButton)
.wait(selectors.itemsIndex.createItemButton)
.parsedUrl();
expect(url.hash).toEqual('#!/item/index');
});
it('should now access to the create item view by clicking the create floating button', async () => {
const url = await nightmare
.click(selectors.itemsIndex.createItemButton)
.wait(selectors.itemCreateView.createButton)
.parsedUrl();
expect(url.hash).toEqual('#!/item/create');
});
it('should create the Infinity Gauntlet item', async () => {
const result = await nightmare
.type(selectors.itemCreateView.name, 'Infinity Gauntlet')
.waitToClick(selectors.itemCreateView.typeSelect)
.waitToClick(selectors.itemCreateView.typeSelectOptionThree)
.waitToClick(selectors.itemCreateView.intrastatSelect)
.waitToClick(selectors.itemCreateView.intrastatSelectOptionOne)
.waitToClick(selectors.itemCreateView.originSelect)
.waitToClick(selectors.itemCreateView.originSelectOptionOne)
.click(selectors.itemCreateView.createButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should confirm Infinity Gauntlet item was created', async () => {
let result = await nightmare
.wait(selectors.itemBasicData.nameInput)
.getInputValue(selectors.itemBasicData.nameInput);
expect(result).toEqual('Infinity Gauntlet');
result = await nightmare
.getInputValue(selectors.itemBasicData.typeSelect);
expect(result).toEqual('Crisantemo');
result = await nightmare
.waitProperty(selectors.itemBasicData.intrastatSelect, 'value')
.getProperty(selectors.itemBasicData.intrastatSelect, 'value');
expect(result).toEqual('6021010 Plantas vivas: Esqueje/injerto, Vid');
result = await nightmare
.getInputValue(selectors.itemBasicData.originSelect);
expect(result).toEqual('Spain');
});
}); });
describe('Clone path', () => { it('should access to the items index by clicking the items button', async () => {
it('should return to the items index by clicking the return to items button', async () => { const url = await nightmare
const url = await nightmare .click(selectors.moduleAccessView.itemsSectionButton)
.click(selectors.itemBasicData.goToItemIndexButton) .wait(selectors.itemsIndex.createItemButton)
.wait(selectors.itemsIndex.createItemButton) .parsedUrl();
.waitForURL('#!/item/index')
.parsedUrl();
expect(url.hash).toContain('#!/item/index'); expect(url.hash).toEqual('#!/item/index');
}); });
it(`should search for the item Infinity Gauntlet`, async () => { it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async () => {
const result = await nightmare const result = await nightmare
.wait(selectors.itemsIndex.searchResult) .wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton) .click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 0)
.countElement(selectors.itemsIndex.searchResult); .countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(1); expect(result).toEqual(0);
}); });
it(`should clone the Infinity Gauntlet`, async () => { it('should access to the create item view by clicking the create floating button', async () => {
const url = await nightmare const url = await nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet') .click(selectors.itemsIndex.createItemButton)
.click(selectors.itemsIndex.searchResultCloneButton) .wait(selectors.itemCreateView.createButton)
.waitToClick(selectors.itemsIndex.acceptClonationAlertButton) .parsedUrl();
.waitForURL('tags')
.parsedUrl();
expect(url.hash).toContain('tags'); expect(url.hash).toEqual('#!/item/create');
}); });
it('should search for the item Infinity Gauntlet and find two', async () => { it('should return to the item index by clickig the cancel button', async () => {
const result = await nightmare const url = await nightmare
.waitToClick(selectors.itemTags.goToItemIndexButton) .click(selectors.itemCreateView.cancelButton)
.wait(selectors.itemsIndex.searchResult) .wait(selectors.itemsIndex.createItemButton)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') .parsedUrl();
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2)
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(2); expect(url.hash).toEqual('#!/item/index');
}); });
it('should now access to the create item view by clicking the create floating button', async () => {
const url = await nightmare
.click(selectors.itemsIndex.createItemButton)
.wait(selectors.itemCreateView.createButton)
.parsedUrl();
expect(url.hash).toEqual('#!/item/create');
});
it('should create the Infinity Gauntlet item', async () => {
const result = await nightmare
.type(selectors.itemCreateView.name, 'Infinity Gauntlet')
.waitToClick(selectors.itemCreateView.typeSelect)
.waitToClick(selectors.itemCreateView.typeSelectOptionThree)
.waitToClick(selectors.itemCreateView.intrastatSelect)
.waitToClick(selectors.itemCreateView.intrastatSelectOptionOne)
.waitToClick(selectors.itemCreateView.originSelect)
.waitToClick(selectors.itemCreateView.originSelectOptionOne)
.click(selectors.itemCreateView.createButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should confirm Infinity Gauntlet item was created', async () => {
let result = await nightmare
.wait(selectors.itemBasicData.nameInput)
.getInputValue(selectors.itemBasicData.nameInput);
expect(result).toEqual('Infinity Gauntlet');
result = await nightmare
.getInputValue(selectors.itemBasicData.typeSelect);
expect(result).toEqual('Crisantemo');
result = await nightmare
.waitProperty(selectors.itemBasicData.intrastatSelect, 'value')
.getProperty(selectors.itemBasicData.intrastatSelect, 'value');
expect(result).toEqual('6021010 Plantas vivas: Esqueje/injerto, Vid');
result = await nightmare
.getInputValue(selectors.itemBasicData.originSelect);
expect(result).toEqual('Spain');
});
});
describe('Clone path', () => {
it('should return to the items index by clicking the return to items button', async () => {
const url = await nightmare
.click(selectors.itemBasicData.goToItemIndexButton)
.wait(selectors.itemsIndex.createItemButton)
.waitForURL('#!/item/index')
.parsedUrl();
expect(url.hash).toContain('#!/item/index');
});
it(`should search for the item Infinity Gauntlet`, async () => {
const result = await nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(1);
});
it(`should clone the Infinity Gauntlet`, async () => {
const url = await nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchResultCloneButton)
.waitToClick(selectors.itemsIndex.acceptClonationAlertButton)
.waitForURL('tags')
.parsedUrl();
expect(url.hash).toContain('tags');
});
it('should search for the item Infinity Gauntlet and find two', async () => {
const result = await nightmare
.waitToClick(selectors.itemTags.goToItemIndexButton)
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2)
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(2);
}); });
}); });

View File

@ -4,7 +4,7 @@ import createNightmare from '../../helpers/nightmare';
describe('Item regularize path', () => { describe('Item regularize path', () => {
const nightmare = createNightmare(); const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
return nightmare nightmare
.waitForLogin('developer'); .waitForLogin('developer');
}); });