test(ST-1369): component-tests voor draft-op-trigger (G5) en isActiveProduct-gate (G6)
sprint-switcher: trigger toont concept-sprint bij een pending draft, en geen concept-label zonder draft. new-sprint-trigger: nieuw testbestand — rendert niet op een niet-actief product, wel op een actief product zonder draft. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ec3d72577b
commit
c68840d68a
2 changed files with 93 additions and 2 deletions
|
|
@ -24,6 +24,11 @@ vi.mock('sonner', () => ({
|
|||
}))
|
||||
|
||||
const isDemoMock = { value: false }
|
||||
const workflowMock: {
|
||||
value:
|
||||
| { pendingSprintDraft?: Record<string, { goal: string } | undefined> }
|
||||
| undefined
|
||||
} = { value: undefined }
|
||||
// Mock-state shape moet alle paden dekken die SprintSwitcher selecteert:
|
||||
// - s.context.isDemo (oude code)
|
||||
// - s.entities.settings.workflow?.pendingSprintDraft?.[productId]?.goal (PBI-79)
|
||||
|
|
@ -38,8 +43,11 @@ type MockStoreState = {
|
|||
}
|
||||
}
|
||||
vi.mock('@/stores/user-settings/store', () => ({
|
||||
useUserSettingsStore: (selector: (s: { context: { isDemo: boolean }; entities: { settings: { workflow: null } } }) => unknown) =>
|
||||
selector({ context: { isDemo: isDemoMock.value }, entities: { settings: { workflow: null } } }),
|
||||
useUserSettingsStore: (selector: (s: MockStoreState) => unknown) =>
|
||||
selector({
|
||||
context: { isDemo: isDemoMock.value },
|
||||
entities: { settings: { workflow: workflowMock.value } },
|
||||
}),
|
||||
}))
|
||||
|
||||
vi.mock('@/components/ui/dropdown-menu', () => {
|
||||
|
|
@ -85,6 +93,7 @@ const sprints = [
|
|||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
isDemoMock.value = false
|
||||
workflowMock.value = undefined
|
||||
actionMock.mockResolvedValue({ success: true })
|
||||
pathnameMock.mockReturnValue('/products/p1/sprint')
|
||||
})
|
||||
|
|
@ -137,4 +146,29 @@ describe('SprintSwitcher', () => {
|
|||
expect(pushMock).not.toHaveBeenCalled()
|
||||
expect(actionMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('shows the concept-sprint on the trigger when a draft is pending (G5)', () => {
|
||||
workflowMock.value = { pendingSprintDraft: { p1: { goal: 'Test goal' } } }
|
||||
render(
|
||||
<SprintSwitcher
|
||||
productId="p1"
|
||||
sprints={sprints}
|
||||
activeSprint={null}
|
||||
buildingSprintIds={[]}
|
||||
/>,
|
||||
)
|
||||
expect(screen.getByText('⚙ Concept — Test goal')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('shows no concept label on the trigger when no draft is pending', () => {
|
||||
render(
|
||||
<SprintSwitcher
|
||||
productId="p1"
|
||||
sprints={sprints}
|
||||
activeSprint={sprints[0]}
|
||||
buildingSprintIds={[]}
|
||||
/>,
|
||||
)
|
||||
expect(screen.queryByText(/⚙ Concept/)).not.toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue