describe('ZoneWarehouse', () => {
    const data = {
        Warehouse: { val: 'Algemesi', type: 'select' },
    };
    const deviceProductionField =
        '.vn-row > :nth-child(1) > .q-field > .q-field__inner > .q-field__control > .q-field__control-container';
    const dataError = "ER_DUP_ENTRY: Duplicate entry '2-2' for key 'zoneFk'";

    beforeEach(() => {
        cy.viewport(1280, 720);
        cy.login('developer');
        cy.visit(`/#/zone/2/warehouses`);
    });

    it('should throw an error if the warehouse chosen is already put in the zone', () => {
        cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click();
        cy.get(deviceProductionField).click();
        cy.get(deviceProductionField).type('{upArrow}{enter}');
        cy.get('.q-notification__message').should('have.text', dataError);
    });

    it('should create a warehouse', () => {
        cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click();
        cy.get(deviceProductionField).click();
        cy.fillInForm(data);
        cy.get('.q-mt-lg > .q-btn--standard').click();
    });

    it('should delete a warehouse', () => {
        cy.get('tbody > :nth-child(2) > :nth-child(2) > .q-icon').click();
        cy.get('.q-card__actions > .q-btn--flat > .q-btn__content').click();
        cy.reload();
    });
});
