emilepharand/Babilonia

View on GitHub
tests/e2e/specs/addIdeas/rowAlignment.cy.ts

Summary

Maintainability
A
0 mins
Test Coverage
import {
    addLanguages,
    getExpressionTextInputRow,
    getKnownExpressionCheckbox,
    getLanguageSelect,
} from '../../cy-utils';

context('The idea page', () => {
    beforeEach(() => {
        addLanguages();
    });
    specify('Row alignment', () => {
        // Ref issue #152
        // It was not always possible to reproduce the bug, so try multiple times
        for (let i = 0; i < 3; i++) {
            // The bug is triggered more easily when first navigating to another page
            cy.get('#search-link').click();
            cy.get('#add-ideas-link').click();
            getExpressionTextInputRow(0)
                .should('be.focused')
                .type('{downArrow}');
            getExpressionTextInputRow(1)
                .should('be.focused')
                .type('{leftArrow}');
            getLanguageSelect(1)
                .should('be.focused')
                .type('{rightArrow}');
            getExpressionTextInputRow(1)
                .should('be.focused')
                .type('{upArrow}');
            getExpressionTextInputRow(0)
                .should('be.focused')
                .type('{leftArrow}');
            getLanguageSelect(0)
                .should('be.focused')
                .type('{rightArrow}');
            getExpressionTextInputRow(0)
                .should('be.focused')
                .type('{downArrow}');
            getExpressionTextInputRow(1)
                .should('be.focused')
                .type('{downArrow}');
            getExpressionTextInputRow(2)
                .should('be.focused')
                .type('{downArrow}');
            getExpressionTextInputRow(3)
                .should('be.focused')
                .type('{downArrow}');
            getExpressionTextInputRow(4)
                .should('be.focused')
                .type('{leftArrow}');
            getLanguageSelect(4)
                .should('be.focused')
                .type('{rightArrow}');
            getExpressionTextInputRow(4)
                .should('be.focused')
                .type('{rightArrow}');
            getKnownExpressionCheckbox(4)
                .should('be.focused');

            cy.get('#search-link').click();
            cy.get('#add-ideas-link').click();
            getExpressionTextInputRow(0)
                .should('be.focused')
                .type('{downArrow}');
            getExpressionTextInputRow(1)
                .should('be.focused')
                .type('{rightArrow}');
            getKnownExpressionCheckbox(1)
                .should('be.focused')
                .type('{leftArrow}');
            getExpressionTextInputRow(1)
                .should('be.focused')
                .type('{upArrow}');
            getExpressionTextInputRow(0)
                .should('be.focused')
                .type('{rightArrow}');
            getKnownExpressionCheckbox(0)
                .should('be.focused');
        }
    });
});