/**
 * Vertical Farm E2E Tests
 */

describe('Vertical Farm', () => {
  describe('Farm List Page', () => {
    beforeEach(() => {
      cy.visit('/vertical-farm');
      cy.waitForPageLoad();
    });

    it('should load the vertical farm page', () => {
      cy.url().should('include', '/vertical-farm');
    });

    it('should display farm management content', () => {
      cy.get('main').should('be.visible');
    });

    it('should have navigation to register new farm', () => {
      cy.contains(/register|new|add|create/i).should('exist');
    });
  });

  describe('Farm Registration', () => {
    beforeEach(() => {
      cy.visit('/vertical-farm/register');
      cy.waitForPageLoad();
    });

    it('should load the registration page', () => {
      cy.url().should('include', '/vertical-farm/register');
    });

    it('should display registration form', () => {
      cy.get('form').should('be.visible');
    });

    it('should have required form fields', () => {
      cy.get('input, select, textarea').should('have.length.at.least', 1);
    });
  });

  describe('Responsiveness', () => {
    it('should display correctly on mobile', () => {
      cy.viewport('iphone-x');
      cy.visit('/vertical-farm');
      cy.waitForPageLoad();
      cy.get('main').should('be.visible');
    });

    it('should display correctly on tablet', () => {
      cy.viewport('ipad-2');
      cy.visit('/vertical-farm');
      cy.waitForPageLoad();
      cy.get('main').should('be.visible');
    });
  });
});
