describe('Route', () => {
    beforeEach(() => {
        cy.viewport(1920, 1080);
        cy.login('developer');
        cy.visit(`/#/route/extended-list`);
    });
    const getVnSelect =
        '> :nth-child(1) > .column > .q-field > .q-field__inner > .q-field__control > .q-field__control-container';
    const getRowColumn = (row, column) => `:nth-child(${row}) > :nth-child(${column})`;

    it('Route list create route', () => {
        cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click();
        cy.get('input[name="description"]').type('routeTestOne{enter}');
        cy.get('.q-notification__message').should('have.text', 'Data created');
        cy.url().should('include', '/summary');
    });

    it('Route list search and edit', () => {
        cy.get('#searchbar input').type('{enter}');
        cy.get('input[name="description"]').type('routeTestOne{enter}');
        cy.get('.q-table tr')
            .its('length')
            .then((rowCount) => {
                expect(rowCount).to.be.greaterThan(0);
            });
        cy.get(getRowColumn(1, 3) + getVnSelect).type('{downArrow}{enter}');
        cy.get(getRowColumn(1, 4) + getVnSelect).type('{downArrow}{enter}');
        cy.get(getRowColumn(1, 5) + getVnSelect).type('{downArrow}{enter}');
        cy.get('button[title="Save"]').click();
        cy.get('.q-notification__message').should('have.text', 'Data saved');
    });
});
