mirror of
https://github.com/btouchard/ackify.git
synced 2026-05-19 15:28:23 -05:00
a7891618c1
Reorganize GitHub Actions workflows into reusable components and implement complete code coverage tracking across backend, frontend, and E2E tests. **CI/CD Improvements:** - Split monolithic ci.yml into 6 specialized reusable workflows - New workflows: test-backend, test-frontend, test-e2e, build-docker, security, coverage-report - Orchestrated execution with proper dependencies and parallel jobs - Codecov integration with multi-flag coverage (backend/frontend/e2e) **Frontend Testing:** - Add Vitest for unit testing with coverage-v8 provider - Create test setup with window mocks for Ackify globals - Add 34 unit tests for titleExtractor, referenceDetector, and http utils - Configure Istanbul instrumentation for E2E coverage collection - Integrate @cypress/code-coverage for E2E test coverage **Test Infrastructure:** - Create run-tests-suite.sh for local comprehensive test execution - Proper Docker Compose orchestration for integration and E2E tests - Automatic cleanup handlers with trap for test environments - Coverage summary aggregation across all test types **Bug Fixes:** - Fix backend config tests after OAuth/MagicLink validation changes - Update tests from panic expectations to error checking - Ensure OAUTH_COOKIE_SECRET is properly configured in tests **Configuration:** - Add .codecov.yml for coverage reporting with flags - Add .nycrc.json for E2E LCOV generation - Update .gitignore for test artifacts and coverage reports - Configure Vite for test environment and code instrumentation
127 lines
4.1 KiB
TypeScript
127 lines
4.1 KiB
TypeScript
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
import { describe, it, expect } from 'vitest'
|
|
import { detectReference, type ReferenceInfo } from '@/services/referenceDetector'
|
|
|
|
describe('referenceDetector', () => {
|
|
describe('detectReference', () => {
|
|
it('should detect HTTP URL', () => {
|
|
const result = detectReference('http://example.com/document.pdf')
|
|
|
|
expect(result.type).toBe('url')
|
|
expect(result.value).toBe('http://example.com/document.pdf')
|
|
expect(result.isDownloadable).toBe(true)
|
|
expect(result.fileExtension).toBe('pdf')
|
|
})
|
|
|
|
it('should detect HTTPS URL', () => {
|
|
const result = detectReference('https://example.com/file.docx')
|
|
|
|
expect(result.type).toBe('url')
|
|
expect(result.isDownloadable).toBe(true)
|
|
expect(result.fileExtension).toBe('docx')
|
|
})
|
|
|
|
it('should detect downloadable PDF', () => {
|
|
const result = detectReference('https://example.com/report.pdf')
|
|
|
|
expect(result.isDownloadable).toBe(true)
|
|
expect(result.fileExtension).toBe('pdf')
|
|
})
|
|
|
|
it('should detect downloadable HTML', () => {
|
|
const result = detectReference('https://example.com/page.html')
|
|
|
|
expect(result.isDownloadable).toBe(true)
|
|
expect(result.fileExtension).toBe('html')
|
|
})
|
|
|
|
it('should detect downloadable Markdown', () => {
|
|
const result = detectReference('https://example.com/README.md')
|
|
|
|
expect(result.isDownloadable).toBe(true)
|
|
expect(result.fileExtension).toBe('md')
|
|
})
|
|
|
|
it('should detect downloadable text file', () => {
|
|
const result = detectReference('https://example.com/notes.txt')
|
|
|
|
expect(result.isDownloadable).toBe(true)
|
|
expect(result.fileExtension).toBe('txt')
|
|
})
|
|
|
|
it('should detect non-downloadable URL without extension', () => {
|
|
const result = detectReference('https://example.com/api/endpoint')
|
|
|
|
expect(result.type).toBe('url')
|
|
expect(result.isDownloadable).toBe(false)
|
|
expect(result.fileExtension).toBeUndefined()
|
|
})
|
|
|
|
it('should detect non-downloadable URL with non-document extension', () => {
|
|
const result = detectReference('https://example.com/image.jpg')
|
|
|
|
expect(result.type).toBe('url')
|
|
expect(result.isDownloadable).toBe(false)
|
|
expect(result.fileExtension).toBe('jpg')
|
|
})
|
|
|
|
it('should detect Unix file path', () => {
|
|
const result = detectReference('/home/user/documents/file.pdf')
|
|
|
|
expect(result.type).toBe('path')
|
|
expect(result.value).toBe('/home/user/documents/file.pdf')
|
|
expect(result.isDownloadable).toBe(false)
|
|
})
|
|
|
|
it('should detect Windows file path', () => {
|
|
const result = detectReference('C:\\Users\\John\\file.docx')
|
|
|
|
expect(result.type).toBe('path')
|
|
expect(result.isDownloadable).toBe(false)
|
|
})
|
|
|
|
it('should detect relative path', () => {
|
|
const result = detectReference('./documents/file.pdf')
|
|
|
|
expect(result.type).toBe('path')
|
|
expect(result.isDownloadable).toBe(false)
|
|
})
|
|
|
|
it('should detect simple reference without path or URL', () => {
|
|
const result = detectReference('CONTRACT-2024-001')
|
|
|
|
expect(result.type).toBe('reference')
|
|
expect(result.value).toBe('CONTRACT-2024-001')
|
|
expect(result.isDownloadable).toBe(false)
|
|
})
|
|
|
|
it('should detect alphanumeric reference', () => {
|
|
const result = detectReference('DOC123ABC')
|
|
|
|
expect(result.type).toBe('reference')
|
|
expect(result.isDownloadable).toBe(false)
|
|
})
|
|
|
|
it('should handle case-insensitive file extensions', () => {
|
|
const result = detectReference('https://example.com/file.PDF')
|
|
|
|
expect(result.fileExtension).toBe('pdf')
|
|
expect(result.isDownloadable).toBe(true)
|
|
})
|
|
|
|
it('should detect ODT files as downloadable', () => {
|
|
const result = detectReference('https://example.com/document.odt')
|
|
|
|
expect(result.isDownloadable).toBe(true)
|
|
expect(result.fileExtension).toBe('odt')
|
|
})
|
|
|
|
it('should detect RTF files as downloadable', () => {
|
|
const result = detectReference('https://example.com/document.rtf')
|
|
|
|
expect(result.isDownloadable).toBe(true)
|
|
expect(result.fileExtension).toBe('rtf')
|
|
})
|
|
})
|
|
})
|