|
| 1 | +import { test, expect } from '@playwright/test'; |
| 2 | + |
| 3 | +test.describe('Direct URL Navigation', () => { |
| 4 | + test('should navigate directly to /mcp page', async ({ page }) => { |
| 5 | + // Navigate directly to the MCP page URL |
| 6 | + await page.goto('/mcp'); |
| 7 | + |
| 8 | + // Wait for the page to load |
| 9 | + await page.waitForLoadState('networkidle'); |
| 10 | + |
| 11 | + // Verify the URL is correct |
| 12 | + expect(page.url()).toContain('/mcp'); |
| 13 | + |
| 14 | + // Verify the page content is loaded (check for MCP specific content) |
| 15 | + const heading = page.locator('h1, h2').first(); |
| 16 | + await expect(heading).toBeVisible(); |
| 17 | + |
| 18 | + // Check that the MCP nav link is active |
| 19 | + const mcpNavLink = page.locator('a.nav-link.active', { hasText: 'MCP Badges' }); |
| 20 | + await expect(mcpNavLink).toBeVisible(); |
| 21 | + }); |
| 22 | + |
| 23 | + test('should navigate directly to /extensions page', async ({ page }) => { |
| 24 | + // Navigate directly to the Extensions page URL |
| 25 | + await page.goto('/extensions'); |
| 26 | + |
| 27 | + // Wait for the page to load |
| 28 | + await page.waitForLoadState('networkidle'); |
| 29 | + |
| 30 | + // Verify the URL is correct |
| 31 | + expect(page.url()).toContain('/extensions'); |
| 32 | + |
| 33 | + // Verify the page content is loaded |
| 34 | + const heading = page.locator('h1, h2').first(); |
| 35 | + await expect(heading).toBeVisible(); |
| 36 | + |
| 37 | + // Check that the Extensions nav link is active |
| 38 | + const extensionsNavLink = page.locator('a.nav-link.active', { hasText: 'VS Code Extensions' }); |
| 39 | + await expect(extensionsNavLink).toBeVisible(); |
| 40 | + }); |
| 41 | + |
| 42 | + test('should navigate directly to /settings page', async ({ page }) => { |
| 43 | + // Navigate directly to the Settings page URL |
| 44 | + await page.goto('/settings'); |
| 45 | + |
| 46 | + // Wait for the page to load |
| 47 | + await page.waitForLoadState('networkidle'); |
| 48 | + |
| 49 | + // Verify the URL is correct |
| 50 | + expect(page.url()).toContain('/settings'); |
| 51 | + |
| 52 | + // Verify the page content is loaded |
| 53 | + const heading = page.locator('h1, h2').first(); |
| 54 | + await expect(heading).toBeVisible(); |
| 55 | + |
| 56 | + // Check that the Settings nav link is active |
| 57 | + const settingsNavLink = page.locator('a.nav-link.settings-link.active'); |
| 58 | + await expect(settingsNavLink).toBeVisible(); |
| 59 | + }); |
| 60 | + |
| 61 | + test('should handle deep linking with query parameters', async ({ page }) => { |
| 62 | + // Navigate to a page with query parameters |
| 63 | + await page.goto('/mcp?test=value'); |
| 64 | + |
| 65 | + // Wait for the page to load |
| 66 | + await page.waitForLoadState('networkidle'); |
| 67 | + |
| 68 | + // Verify the URL preserves query parameters |
| 69 | + expect(page.url()).toContain('/mcp'); |
| 70 | + expect(page.url()).toContain('test=value'); |
| 71 | + |
| 72 | + // Verify the page loaded correctly |
| 73 | + const heading = page.locator('h1, h2').first(); |
| 74 | + await expect(heading).toBeVisible(); |
| 75 | + }); |
| 76 | + |
| 77 | + test('should navigate from home to subpage and back', async ({ page }) => { |
| 78 | + // Start at home |
| 79 | + await page.goto('/'); |
| 80 | + await page.waitForLoadState('networkidle'); |
| 81 | + |
| 82 | + // Navigate to MCP page |
| 83 | + await page.click('a.nav-link:has-text("MCP Badges")'); |
| 84 | + await page.waitForLoadState('networkidle'); |
| 85 | + |
| 86 | + // Verify we're on the MCP page |
| 87 | + expect(page.url()).toContain('/mcp'); |
| 88 | + |
| 89 | + // Navigate back to home |
| 90 | + await page.click('a.nav-link:has-text("Home")'); |
| 91 | + await page.waitForLoadState('networkidle'); |
| 92 | + |
| 93 | + // Verify we're back at home |
| 94 | + expect(page.url()).not.toContain('/mcp'); |
| 95 | + expect(page.url()).not.toContain('/extensions'); |
| 96 | + }); |
| 97 | +}); |
0 commit comments