enonic / xp-apps

Enonic XP bundled applications.
GNU General Public License v3.0
1 stars 3 forks source link

Write a simple description on how to write tests with Selenium and JavaScript. #198

Closed jsi closed 6 years ago

jsi commented 7 years ago

All developers should start writing basic tests for their code. We now have the Users App tests as an example of how it can be done.

Please write this page: http://wiki.enonic.com/display/support/How+to+write+a+UI+test+for+XP

It should basically describe:

jsi commented 6 years ago

This is a good start. I would like to have a full example of a complete test somewhere. Just a very simple test, but one that does a full setup. Also, there should be some mention of the page objects.

This could look like this (I just picked a random test here. There may be better examples: `describe('Edit an user - change name and roles', function () { this.timeout(70000); webDriverHelper.setupBrowser(); let testUser;

it('GIVEN existing user is opened WHEN display name has been changed THEN user should be searchable with the new display name',
    () => {
        return testUtils.selectUserAndOpenWizard(testUser.displayName).then(()=> {
            return userWizard.typeDisplayName('new-name');
        }).pause(500).then(()=> {
            return testUtils.saveAndCloseWizard('new-name');
        }).then(()=> {
            return testUtils.typeNameInFilterPanel('new-name');
        }).pause(500).then(()=> {
            return expect(userBrowsePanel.isItemDisplayed(testUser.displayName)).to.eventually.be.true;
        })
    });

beforeEach(() => testUtils.navigateToUsersApp(webDriverHelper.browser));
afterEach(() => testUtils.doCloseUsersApp(webDriverHelper.browser));

});`

Then, explain each line: What does webDriverHelper.setupBrowser(); do? What does let testUser; do? What are the testUtils? Where can they be found? What does userBrowsePanel.isItemDisplayed do? Where is the code for this? What does beforeEach and afterEach do? (It is partially explained already, but here is an example that can help.)

Finally, it would be good with a link to the Chai API.

jsi commented 6 years ago

Alan have also given some feedback:

sgauruseu commented 6 years ago
  1. I added links to the Chai API in the "Technologies" topic
  2. I described how to run just one test in Idea in the "Run the Test Script" topic
  3. Added 2 examples of tests that create an User and change the name of the User and verify the info in
    the statistics panel