/// <reference types="cypress" />
describe('ParkingList', () => {
    const firstCard = '.q-card:nth-child(1)';
    const firstChipId =
        ':nth-child(1) > :nth-child(1) > .justify-between > .flex > .q-chip > .q-chip__content';
    const firstDetailBtn =
        ':nth-child(1) > :nth-child(1) > .card-list-body > .actions > .q-btn';
    const summaryHeader = '.summaryBody .header';

    beforeEach(() => {
        cy.viewport(1920, 1080);
        cy.login('developer');
        cy.visit(`/#/parking/list`);
    });

    it('should redirect on clicking a parking', () => {
        cy.get(firstChipId)
            .invoke('text')
            .then((content) => {
                const id = content.substring(4);
                cy.get(firstCard).click();
                cy.url().should('include', `/parking/${id}/summary`);
            });
    });

    it('should open the details', () => {
        cy.get(firstDetailBtn).click();
        cy.get(summaryHeader).contains('Basic data');
    });
});
