picimako / terra-support

Adds support for Cerner's Terra UI component and test automation libraries.
https://plugins.jetbrains.com/plugin/15430-terra-support
Apache License 2.0
0 stars 0 forks source link

Create inspection and quick fixes to migrate Terra.it helpers to Terra.validates calls #44

Closed picimako closed 3 years ago

picimako commented 3 years ago

Summary of scope

Since Terra.it helpers are deprecated since terra-toolkit 6.11.0 (see terra-toolkit changelog), and inspection with quick fixes would be useful to help users migrate their tests to Terra.validates calls.

See also Terra Commands.

Solution details

Without hooks:

Terra.it.validatesElement();

would become

it('INSERT TEST NAME', () => {
    Terra.validates.element();
});
----------------------------
Terra.it.validatesElement('test name');

would become

it('INSERT TEST NAME', () => {
    Terra.validates.element('test name');
});
----------------------------
Terra.it.validatesElement('test name' { selector: '#selector' });

would become

it('INSERT TEST NAME', () => {
    Terra.validates.element('test name', { selector: '#selector' });
});

With the before hook:

describe('describe block', () => {
    before(() => {
        browser.url('/');
    });
    Terra.it.validatesElement('test name', { selector: '#selector' });
});

would become

describe('describe block', () => {
    it('INSERT TEST NAME', () => {
        browser.url('/');
        Terra.validates.element('test name', { selector: '#selector' });
    });
});

before hook with multiple Terra.it calls after:

describe('describe block', () => {
    before(() => {
        browser.url('/');
    });
    Terra.it.validatesElement('test', { selector: '#selector' });
    Terra.it.matchesScreenshot('test', { selector: '#anotherselector' });
});

would become

describe('describe block', () => {
    it('INSERT TEST NAME', () => {
        browser.url('/');
        Terra.validates.element('test', { selector: '#selector' });
        Terra.validates.screenshot('name', { selector: '#anotherselector' });
    });
});

These also apply to the misMatchTolerance and axeRules properties, as well as the Terra.it.matchesScreenshot() and Terra.it.isAccessible() helpers.

Nice to have

Execute the inspection only when terra-toolkit is included in the project's package.json file with version 6.11.0 at least.

Classes that might be useful:

Out of scope

picimako commented 3 years ago

Completed on release branch.