<%
/**
 * step definition without page objects
 */
if (usePageObjects) {
%><%- isUsingTypeScript || isUsingBabel
    ? `import LoginPage from  '${relativePath}/login.page';`
    : `const LoginPage = require('${relativePath}/login.page');` %>
<%- isUsingTypeScript || isUsingBabel
    ? `import SecurePage from '${relativePath}/secure.page';`
    : `const SecurePage = require('${relativePath}/secure.page');` %>

describe('My Login application', () => {
    it('should login with valid credentials', <%= _async %>() => {
        <%= _await %>LoginPage.open();

        <%= _await %>LoginPage.login('tomsmith', 'SuperSecretPassword!');
        <%= _await %>expect(SecurePage.flashAlert).toBeExisting();
        <%= _await %>expect(SecurePage.flashAlert).toHaveTextContaining(
            'You logged into a secure area!');
    });
});

<% } else {

/**
 * step definition with page objects
 */
%>describe('My Login application', () => {
    it('should login with valid credentials', <%= _async %>() => {
        <%= _await %>browser.url(`https://the-internet.herokuapp.com/login`);

        <% if (isSync) {
        %>$('#username').setValue(username);
        $('#password').setValue(password);
        $('button[type="submit"]').click(); <% } else {
        %>await (await $('#username')).setValue('tomsmith');
        await (await $('#password')).setValue('SuperSecretPassword!');
        await (await $('button[type="submit"]')).click();<%
        } %>

        <%= _await %>expect($('#flash')).toBeExisting();
        <%= _await %>expect($('#flash')).toHaveTextContaining(
            'You logged into a secure area!');
    });
});
<% } %>
