/** * ApiInterceptor - Helper for deterministic waits in Cypress * * Replaces unreliable cy.wait(ms) with cy.intercept() based waits * that wait for actual API responses. * * @example Basic usage: * ```ts * const api = new ApiInterceptor('customers') * api.setupCrudIntercepts() * cy.visit('/dashboard/customers') * api.waitForList() * ``` * * @example Custom path: * ```ts * const api = new ApiInterceptor({ * slug: 'categories', * customPath: '/api/v1/post-categories' * }) * ``` */ interface ApiInterceptorConfig { /** Entity slug - used to generate aliases */ slug: string; /** Custom API path (e.g., '/api/v1/post-categories') */ customPath?: string; } declare class ApiInterceptor { private slug; private endpoint; constructor(slugOrConfig: string | ApiInterceptorConfig); /** Get the API endpoint path */ get path(): string; /** Get the entity slug */ get entitySlug(): string; /** Get alias names for all operations */ get aliases(): { list: string; create: string; update: string; delete: string; }; /** * Setup intercepts for all CRUD operations * Call this BEFORE navigation in beforeEach or at test start * * Note: We intercept both PUT and PATCH for updates since different * APIs may use different HTTP methods for updates. */ setupCrudIntercepts(): this; /** * Setup only list + create intercepts * Useful for list pages with inline create */ setupListIntercepts(): this; /** * Wait for list response (GET) * Use after navigation or after mutations to wait for refresh */ waitForList(timeout?: number): Cypress.Chainable; /** * Wait for create response (POST) and validate success status */ waitForCreate(timeout?: number): Cypress.Chainable; /** * Wait for update response (PATCH or PUT) and validate success status * Waits for PATCH first (more common), falls back to PUT */ waitForUpdate(timeout?: number): Cypress.Chainable; /** * Wait for delete response (DELETE) and validate success status */ waitForDelete(timeout?: number): Cypress.Chainable; /** * Wait for list refresh (alias for waitForList) * Semantic name for use after create/update/delete */ waitForRefresh(timeout?: number): Cypress.Chainable; /** * Wait for create + list refresh * Common pattern: create entity, wait for success, wait for list to refresh */ waitForCreateAndRefresh(timeout?: number): Cypress.Chainable; /** * Wait for update + list refresh * Common pattern: update entity, wait for success, wait for list to refresh */ waitForUpdateAndRefresh(timeout?: number): Cypress.Chainable; /** * Wait for delete + list refresh * Common pattern: delete entity, wait for success, wait for list to refresh */ waitForDeleteAndRefresh(timeout?: number): Cypress.Chainable; } export { ApiInterceptor, type ApiInterceptorConfig };