/**
 * Cypress E2E Support File
 * This file is processed and loaded automatically before test files.
 */

// Import commands
import './commands';

// Global hooks
beforeEach(() => {
  // Clear local storage between tests
  cy.clearLocalStorage();
});

// Handle uncaught exceptions
Cypress.on('uncaught:exception', (err, runnable) => {
  // Returning false prevents Cypress from failing the test
  // This is useful for third-party scripts that may throw errors
  if (err.message.includes('ResizeObserver loop')) {
    return false;
  }
  return true;
});

// Add custom assertions if needed
declare global {
  namespace Cypress {
    interface Chainable {
      /**
       * Custom command to wait for page load
       */
      waitForPageLoad(): Chainable<void>;

      /**
       * Custom command to login (placeholder for auth tests)
       */
      login(email: string, password: string): Chainable<void>;

      /**
       * Custom command to navigate to a plant page
       */
      visitPlant(plantId: string): Chainable<void>;
    }
  }
}
