Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as opaque submodule gitlinks on GitHub) into fully-tracked first-party content. AITM now merges its 7 vendored repos as first-party engines: - memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts - git: vendored C git (bundled binary) + gitnexus (in-process code intelligence) - agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess) Includes the full session's product build: Gitgram web/mobile/backend features, AITM website/CLI/MCP, the unified memory layer, engine build tooling (scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md), and extensive test suites. Build artifacts, node_modules, external/, and gemini-cli are gitignored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
187 lines
7.2 KiB
TypeScript
187 lines
7.2 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { testConfig } from '../test-config';
|
|
|
|
test.describe('Error Scenarios', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
// Add GitHub token BEFORE navigating to avoid rate limiting
|
|
await page.addInitScript((token) => {
|
|
if (token) {
|
|
sessionStorage.setItem('github_token', token);
|
|
}
|
|
}, testConfig.githubToken);
|
|
|
|
await page.goto('/');
|
|
await page.waitForLoadState('networkidle');
|
|
});
|
|
|
|
test('should handle invalid GitHub URL gracefully', async ({ page }) => {
|
|
const urlInput = page.getByPlaceholder('https://github.com/facebook/react');
|
|
|
|
// Enter invalid URL
|
|
await urlInput.fill('https://invalid-url');
|
|
await expect(page.getByText('Invalid GitHub URL format')).toBeVisible();
|
|
|
|
// Load button should be disabled or not work
|
|
const loadButton = page.getByRole('button', { name: /Load Repository/i });
|
|
await expect(loadButton).toBeDisabled();
|
|
});
|
|
|
|
test('should handle 404 repository not found', async ({ page }) => {
|
|
const urlInput = page.getByPlaceholder('https://github.com/facebook/react');
|
|
|
|
// Enter URL for non-existent repo
|
|
await urlInput.fill('https://github.com/nonexistent-user-12345/nonexistent-repo-67890');
|
|
|
|
const loadButton = page.getByRole('button', { name: /Load Repository/i });
|
|
await loadButton.click();
|
|
|
|
// Should show error dialog or message
|
|
await expect(page.getByText(/not found|404|error/i)).toBeVisible({ timeout: 10000 });
|
|
});
|
|
|
|
test('should show helpful error for rate limit', async ({ page }) => {
|
|
// Note: This test is hard to trigger reliably without actually hitting rate limits
|
|
// It verifies the error handling UI is in place
|
|
|
|
// The rate limit error message should be user-friendly when it occurs
|
|
// We can't easily simulate this in E2E, but we verify the error dialog component exists
|
|
const urlInput = page.getByPlaceholder('https://github.com/facebook/react');
|
|
await expect(urlInput).toBeVisible();
|
|
});
|
|
|
|
test('should handle network errors gracefully', async ({ page }) => {
|
|
// Simulate offline mode
|
|
await page.context().setOffline(true);
|
|
|
|
const urlInput = page.getByPlaceholder('https://github.com/facebook/react');
|
|
await urlInput.fill('https://github.com/facebook/react');
|
|
|
|
const loadButton = page.getByRole('button', { name: /Load Repository/i });
|
|
await loadButton.click();
|
|
|
|
// Should show network error
|
|
await expect(page.getByText(/network|offline|connection/i)).toBeVisible({ timeout: 10000 });
|
|
|
|
// Restore online mode
|
|
await page.context().setOffline(false);
|
|
});
|
|
|
|
test('should clear error when user corrects input', async ({ page }) => {
|
|
const urlInput = page.getByPlaceholder('https://github.com/facebook/react');
|
|
|
|
// Enter invalid URL
|
|
await urlInput.fill('invalid');
|
|
await expect(page.getByText('Invalid GitHub URL format')).toBeVisible();
|
|
|
|
// Correct the URL
|
|
await urlInput.clear();
|
|
await urlInput.fill('https://github.com/facebook/react');
|
|
|
|
// Error should be cleared
|
|
await expect(page.getByText('Invalid GitHub URL format')).not.toBeVisible();
|
|
await expect(page.getByText('Valid GitHub URL')).toBeVisible();
|
|
});
|
|
|
|
test('should handle empty file selection gracefully', async ({ page }) => {
|
|
// Load a repository
|
|
const urlInput = page.getByPlaceholder('https://github.com/facebook/react');
|
|
await urlInput.fill('https://github.com/abinthomasonline/repo2txt');
|
|
|
|
const loadButton = page.getByRole('button', { name: /Load Repository/i });
|
|
await loadButton.click();
|
|
|
|
// Wait for file tree using data-testid
|
|
await expect(page.getByTestId('file-tree-heading')).toBeVisible({ timeout: 30000 });
|
|
|
|
// Deselect all files using the global checkbox
|
|
const globalCheckbox = page.getByRole('checkbox', { name: 'Select all files' });
|
|
await expect(globalCheckbox).toBeVisible();
|
|
// Click once to deselect if checked, click twice if indeterminate
|
|
await globalCheckbox.click();
|
|
// Wait a bit for state to update
|
|
await page.waitForTimeout(200);
|
|
// If still checked (was indeterminate), click again
|
|
if (await globalCheckbox.isChecked()) {
|
|
await globalCheckbox.click();
|
|
await page.waitForTimeout(200);
|
|
}
|
|
|
|
// Try to generate output
|
|
const generateButton = page.getByTestId('generate-output-button');
|
|
await generateButton.click();
|
|
|
|
// Should show helpful error message - check for error dialog
|
|
await expect(page.getByRole('heading', { name: /Unable to Complete Request/i })).toBeVisible({ timeout: 10000 });
|
|
await expect(page.getByText(/No files selected/i)).toBeVisible();
|
|
});
|
|
|
|
test('should close error dialog when clicking close button', async ({ page }) => {
|
|
// Trigger an error (no files selected)
|
|
const urlInput = page.getByPlaceholder('https://github.com/facebook/react');
|
|
await urlInput.fill('https://github.com/abinthomasonline/repo2txt');
|
|
|
|
const loadButton = page.getByRole('button', { name: /Load Repository/i });
|
|
await loadButton.click();
|
|
|
|
await expect(page.getByTestId('file-tree-heading')).toBeVisible({ timeout: 30000 });
|
|
|
|
// Deselect all files using the global checkbox
|
|
const globalCheckbox = page.getByRole('checkbox', { name: 'Select all files' });
|
|
await expect(globalCheckbox).toBeVisible();
|
|
await globalCheckbox.click();
|
|
await page.waitForTimeout(200);
|
|
if (await globalCheckbox.isChecked()) {
|
|
await globalCheckbox.click();
|
|
await page.waitForTimeout(200);
|
|
}
|
|
|
|
const generateButton = page.getByTestId('generate-output-button');
|
|
await generateButton.click();
|
|
|
|
// Error dialog should be visible
|
|
const dialogHeading = page.getByRole('heading', { name: /Unable to Complete Request/i });
|
|
await expect(dialogHeading).toBeVisible({ timeout: 10000 });
|
|
|
|
// Close the error dialog using the Close button
|
|
const closeButton = page.getByRole('button', { name: 'Close' });
|
|
await closeButton.click();
|
|
|
|
// Dialog heading should be dismissed
|
|
await expect(dialogHeading).not.toBeVisible();
|
|
});
|
|
|
|
test('should handle Escape key to close error dialog', async ({ page }) => {
|
|
// Trigger an error
|
|
const urlInput = page.getByPlaceholder('https://github.com/facebook/react');
|
|
await urlInput.fill('https://github.com/abinthomasonline/repo2txt');
|
|
|
|
const loadButton = page.getByRole('button', { name: /Load Repository/i });
|
|
await loadButton.click();
|
|
|
|
await expect(page.getByTestId('file-tree-heading')).toBeVisible({ timeout: 30000 });
|
|
|
|
// Deselect all files using the global checkbox
|
|
const globalCheckbox = page.getByRole('checkbox', { name: 'Select all files' });
|
|
await expect(globalCheckbox).toBeVisible();
|
|
await globalCheckbox.click();
|
|
await page.waitForTimeout(200);
|
|
if (await globalCheckbox.isChecked()) {
|
|
await globalCheckbox.click();
|
|
await page.waitForTimeout(200);
|
|
}
|
|
|
|
const generateButton = page.getByTestId('generate-output-button');
|
|
await generateButton.click();
|
|
|
|
// Error dialog should be visible
|
|
const dialogHeading = page.getByRole('heading', { name: /Unable to Complete Request/i });
|
|
await expect(dialogHeading).toBeVisible({ timeout: 10000 });
|
|
|
|
// Press Escape
|
|
await page.keyboard.press('Escape');
|
|
|
|
// Dialog heading should be dismissed
|
|
await expect(dialogHeading).not.toBeVisible();
|
|
});
|
|
});
|