9f548a340d
A second project's corpus now renders under /p/<id>/, isolated by its own
slug namespace. Completes step (1) "RFC app supports multiple projects" for
the read path.
- api.py: GET /api/projects/{pid}/rfcs (scoped catalog) + /{slug} (entry by
(project_id,slug)), behind the §22.5 read gate. Unscoped /api/rfcs stay as
default-project compat.
- cache.py: refresh_meta_repo iterates every projects row, mirroring each
content_repo into cached_rfcs stamped with its project_id (_upsert_cached_rfc
gains a project_id arg).
- frontend: api.listRFCs(projectId)/getRFC(projectId,slug); Catalog + RFCView
pass useProjectId(); ProjectLayout's NotServedPlaceholder guard removed (every
project serves), 404/not-readable branch kept; NotServedPlaceholder deleted.
- tests: test_project_scoped_serving.py (catalog scoping, entry isolation,
gated 404); ProjectLayout.test updated (non-default renders). 445 backend +
11 Vitest green; clean build.
Known limitation (next slice): write path + default-id re-stamp not yet scoped
(non-default project read-only); no live impact (no 2nd project in prod yet).
Per docs/superpowers/specs/2026-06-04-m3-backend-planb-design.md.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
57 lines
2.2 KiB
React
57 lines
2.2 KiB
React
import React from 'react'
|
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
import { render, screen, waitFor } from '@testing-library/react'
|
|
import { MemoryRouter, Routes, Route } from 'react-router-dom'
|
|
import ProjectLayout from './ProjectLayout.jsx'
|
|
|
|
vi.mock('../api', () => ({ getProject: vi.fn() }))
|
|
vi.mock('../context/DeploymentProvider', () => ({
|
|
useDeployment: () => ({ defaultProjectId: 'default', name: 'Dep', projects: [] }),
|
|
}))
|
|
import { getProject } from '../api'
|
|
|
|
function renderAt(path) {
|
|
return render(
|
|
<MemoryRouter initialEntries={[path]}>
|
|
<Routes>
|
|
<Route path="/p/:projectId/*" element={
|
|
<ProjectLayout><div data-testid="corpus">CORPUS</div></ProjectLayout>
|
|
} />
|
|
</Routes>
|
|
</MemoryRouter>,
|
|
)
|
|
}
|
|
|
|
describe('ProjectLayout', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
document.documentElement.style.removeProperty('--c-accent')
|
|
})
|
|
|
|
it('renders the corpus children for the corpus-served default project', async () => {
|
|
getProject.mockResolvedValue({ id: 'default', name: 'OHM', type: 'document', theme: {} })
|
|
renderAt('/p/default/')
|
|
expect(await screen.findByTestId('corpus')).toBeInTheDocument()
|
|
})
|
|
|
|
it('applies the project theme to :root and resets it on unmount', async () => {
|
|
getProject.mockResolvedValue({ id: 'default', name: 'OHM', type: 'document', theme: { accent: '#123456' } })
|
|
const { unmount } = renderAt('/p/default/')
|
|
await waitFor(() =>
|
|
expect(document.documentElement.style.getPropertyValue('--c-accent')).toBe('#123456'))
|
|
unmount()
|
|
expect(document.documentElement.style.getPropertyValue('--c-accent')).toBe('')
|
|
})
|
|
|
|
it('renders the corpus for a non-default project too (Plan B: every project serves)', async () => {
|
|
getProject.mockResolvedValue({ id: 'other', name: 'Ecomm', type: 'bdd', theme: {} })
|
|
renderAt('/p/other/')
|
|
expect(await screen.findByTestId('corpus')).toBeInTheDocument()
|
|
})
|
|
|
|
it('shows a not-found message when the project 404s', async () => {
|
|
getProject.mockRejectedValue(Object.assign(new Error('nope'), { status: 404 }))
|
|
renderAt('/p/ghost/')
|
|
expect(await screen.findByText(/Not found/i)).toBeInTheDocument()
|
|
})
|
|
}) |