135 lines
4.7 KiB
JavaScript
135 lines
4.7 KiB
JavaScript
import config from '../../helpers/config.js';
|
|
import createNightmare from '../../helpers/nightmare';
|
|
import selectors from '../../helpers/selectors.js';
|
|
import {catchErrors} from '../../../services/utils/jasmineHelpers';
|
|
const nightmare = createNightmare();
|
|
const moduleAccessViewHashURL = '#!/';
|
|
|
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
|
|
|
describe('Edit web access path', () => {
|
|
it('should log in', done => {
|
|
nightmare
|
|
.login()
|
|
.waitForURL(moduleAccessViewHashURL)
|
|
.url()
|
|
.then(url => {
|
|
expect(url).toEqual(config.url + moduleAccessViewHashURL);
|
|
done();
|
|
})
|
|
.catch(catchErrors(done));
|
|
});
|
|
|
|
it('should make sure the language is English', done => {
|
|
nightmare
|
|
.changeLanguageToEnglish()
|
|
.then(() => {
|
|
done();
|
|
})
|
|
.catch(catchErrors(done));
|
|
});
|
|
|
|
it('should click on the Clients button of the top bar menu', done => {
|
|
nightmare
|
|
.waitToClick(selectors.globalItems.applicationsMenuButton)
|
|
.wait(selectors.globalItems.applicationsMenuVisible)
|
|
.waitToClick(selectors.globalItems.clientsButton)
|
|
.wait(selectors.clientsIndex.createClientButton)
|
|
.url()
|
|
.then(url => {
|
|
expect(url).toEqual(config.url + '#!/clients');
|
|
done();
|
|
})
|
|
.catch(catchErrors(done));
|
|
});
|
|
|
|
it('should search for the user Bruce Banner', done => {
|
|
nightmare
|
|
.wait(selectors.clientsIndex.searchResult)
|
|
.type(selectors.clientsIndex.searchClientInput, 'Bruce Banner')
|
|
.click(selectors.clientsIndex.searchButton)
|
|
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
|
|
.countSearchResults(selectors.clientsIndex.searchResult)
|
|
.then(result => {
|
|
expect(result).toEqual(1);
|
|
done();
|
|
})
|
|
.catch(catchErrors(done));
|
|
});
|
|
|
|
it(`should click on the search result to access to the client's web access`, done => {
|
|
nightmare
|
|
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner')
|
|
.waitToClick(selectors.clientsIndex.searchResult)
|
|
.waitToClick(selectors.clientWebAccess.webAccessButton)
|
|
.waitForURL('web-access')
|
|
.url()
|
|
.then(url => {
|
|
expect(url).toContain('web-access');
|
|
done();
|
|
})
|
|
.catch(catchErrors(done));
|
|
});
|
|
|
|
it(`should click on the Enable web access checkbox to uncheck it`, done => {
|
|
nightmare
|
|
.waitToClick(selectors.clientWebAccess.enableWebAccessCheckbox)
|
|
.waitToClick(selectors.clientFiscalData.saveButton)
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
.then(result => {
|
|
expect(result).toContain(`Data saved!`);
|
|
done();
|
|
})
|
|
.catch(catchErrors(done));
|
|
});
|
|
|
|
it('should confirm Enable web access checkbox is unchecked', done => {
|
|
nightmare
|
|
.waitForSnackbarReset()
|
|
.waitToClick(selectors.clientBasicData.basicDataButton)
|
|
.wait(selectors.clientBasicData.nameInput)
|
|
.waitToClick(selectors.clientWebAccess.webAccessButton)
|
|
.wait(selectors.clientWebAccess.enableWebAccessCheckbox)
|
|
.evaluate(selector => {
|
|
return document.querySelector(selector).checked;
|
|
}, selectors.clientWebAccess.enableWebAccessCheckbox)
|
|
.then(value => {
|
|
expect(value).toBeFalsy();
|
|
done();
|
|
})
|
|
.catch(catchErrors(done));
|
|
});
|
|
|
|
it('should edit the User name', done => {
|
|
nightmare
|
|
.wait(selectors.clientWebAccess.userNameInput)
|
|
.clearInput(selectors.clientWebAccess.userNameInput)
|
|
.type(selectors.clientWebAccess.userNameInput, 'Hulk')
|
|
.click(selectors.clientWebAccess.saveButton)
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
.then(result => {
|
|
expect(result).toEqual('Data saved!');
|
|
done();
|
|
})
|
|
.catch(catchErrors(done));
|
|
});
|
|
|
|
it('should confirm the User name have been edited', done => {
|
|
nightmare
|
|
.waitForSnackbarReset()
|
|
.click(selectors.clientBasicData.basicDataButton)
|
|
.wait(selectors.clientBasicData.nameInput)
|
|
.click(selectors.clientWebAccess.webAccessButton)
|
|
.wait(selectors.clientWebAccess.userNameInput)
|
|
.waitForTextInInput(selectors.clientWebAccess.userNameInput, 'Hulk')
|
|
.getInputValue(selectors.clientWebAccess.userNameInput)
|
|
.then(result => {
|
|
expect(result).toEqual('Hulk');
|
|
done();
|
|
})
|
|
.catch(catchErrors(done));
|
|
});
|
|
});
|