UNPKG

mycoder-agent

Version:

Agent module for mycoder - an AI-powered software development assistant

48 lines 2.17 kB
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest'; import { SessionManager } from './SessionManager.js'; // Set global timeout for all tests in this file vi.setConfig({ testTimeout: 15000 }); describe('Browser Navigation Tests', () => { let browserManager; let session; const baseUrl = 'https://the-internet.herokuapp.com'; beforeAll(async () => { browserManager = new SessionManager(); session = await browserManager.createSession({ headless: true }); }); afterAll(async () => { await browserManager.closeAllSessions(); }); it('should navigate to main page and verify content', async () => { await session.page.goto(baseUrl); const title = await session.page.title(); expect(title).toBe('The Internet'); const headerText = await session.page.$eval('h1.heading', (el) => el.textContent); expect(headerText).toBe('Welcome to the-internet'); }); it('should navigate to login page and verify title', async () => { await session.page.goto(`${baseUrl}/login`); const title = await session.page.title(); expect(title).toBe('The Internet'); const headerText = await session.page.$eval('h2', (el) => el.textContent); expect(headerText).toBe('Login Page'); }); it('should handle 404 pages appropriately', async () => { await session.page.goto(`${baseUrl}/nonexistent`); // Wait for the page to stabilize await session.page.waitForLoadState('networkidle'); // Check for 404 content instead of title since title may vary const bodyText = await session.page.$eval('body', (el) => el.textContent); expect(bodyText).toContain('Not Found'); }); it('should handle navigation timeouts', async () => { await expect(session.page.goto(`${baseUrl}/slow`, { timeout: 1 })).rejects.toThrow(); }); it('should wait for network idle', async () => { await session.page.goto(baseUrl, { waitUntil: 'networkidle', }); expect(session.page.url()).toBe(`${baseUrl}/`); }); }); //# sourceMappingURL=navigation.test.js.map