mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-29 00:23:06 +00:00
test: atualizar specs do shell para CampaignPageChromeProvider
Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
This commit is contained in:
parent
ccfbf592a8
commit
24e35d5a14
2 changed files with 70 additions and 54 deletions
|
|
@ -2,6 +2,7 @@ import { cleanup, render, screen, within } from '@testing-library/react'
|
||||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||||
|
|
||||||
vi.mock('next/navigation', () => ({
|
vi.mock('next/navigation', () => ({
|
||||||
|
usePathname: () => '/campanha/acoes/atualizar-votos',
|
||||||
useRouter: () => ({
|
useRouter: () => ({
|
||||||
push: vi.fn(),
|
push: vi.fn(),
|
||||||
replace: vi.fn(),
|
replace: vi.fn(),
|
||||||
|
|
@ -9,6 +10,7 @@ vi.mock('next/navigation', () => ({
|
||||||
}))
|
}))
|
||||||
|
|
||||||
import { CampaignWizardShell } from '@/components/campaign/shared/CampaignWizardShell'
|
import { CampaignWizardShell } from '@/components/campaign/shared/CampaignWizardShell'
|
||||||
|
import { CampaignPageChromeProvider } from '@/components/campaign/shell/CampaignPageChromeContext'
|
||||||
import { CampaignMobileTopBar } from '@/components/campaign/shell/CampaignMobileTopBar'
|
import { CampaignMobileTopBar } from '@/components/campaign/shell/CampaignMobileTopBar'
|
||||||
import { CampaignWizardChromeProvider } from '@/components/campaign/shell/CampaignWizardChromeContext'
|
import { CampaignWizardChromeProvider } from '@/components/campaign/shell/CampaignWizardChromeContext'
|
||||||
import { SidebarProvider } from '@/components/ui/Sidebar'
|
import { SidebarProvider } from '@/components/ui/Sidebar'
|
||||||
|
|
@ -18,10 +20,12 @@ import { stubMatchMedia } from '../helpers/matchMedia'
|
||||||
const renderWizardShell = (props: React.ComponentProps<typeof CampaignWizardShell>) =>
|
const renderWizardShell = (props: React.ComponentProps<typeof CampaignWizardShell>) =>
|
||||||
render(
|
render(
|
||||||
<SidebarProvider>
|
<SidebarProvider>
|
||||||
<CampaignWizardChromeProvider>
|
<CampaignPageChromeProvider role="coordinator">
|
||||||
<CampaignMobileTopBar />
|
<CampaignWizardChromeProvider>
|
||||||
<CampaignWizardShell {...props} />
|
<CampaignMobileTopBar />
|
||||||
</CampaignWizardChromeProvider>
|
<CampaignWizardShell {...props} />
|
||||||
|
</CampaignWizardChromeProvider>
|
||||||
|
</CampaignPageChromeProvider>
|
||||||
</SidebarProvider>,
|
</SidebarProvider>,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -104,35 +108,39 @@ describe('CampaignWizardShell', () => {
|
||||||
it('skips title focus when contentFocus is none', () => {
|
it('skips title focus when contentFocus is none', () => {
|
||||||
const { rerender } = render(
|
const { rerender } = render(
|
||||||
<SidebarProvider>
|
<SidebarProvider>
|
||||||
<CampaignWizardChromeProvider>
|
<CampaignPageChromeProvider role="coordinator">
|
||||||
<CampaignMobileTopBar />
|
<CampaignWizardChromeProvider>
|
||||||
<CampaignWizardShell
|
<CampaignMobileTopBar />
|
||||||
flowTitle="Ajustar votos"
|
<CampaignWizardShell
|
||||||
stepTitle="Passo 1"
|
flowTitle="Ajustar votos"
|
||||||
isEntryStep
|
stepTitle="Passo 1"
|
||||||
previousHref="/campanha"
|
isEntryStep
|
||||||
contentFocus="none"
|
previousHref="/campanha"
|
||||||
>
|
contentFocus="none"
|
||||||
<input aria-label="Primeiro campo" />
|
>
|
||||||
</CampaignWizardShell>
|
<input aria-label="Primeiro campo" />
|
||||||
</CampaignWizardChromeProvider>
|
</CampaignWizardShell>
|
||||||
|
</CampaignWizardChromeProvider>
|
||||||
|
</CampaignPageChromeProvider>
|
||||||
</SidebarProvider>,
|
</SidebarProvider>,
|
||||||
)
|
)
|
||||||
|
|
||||||
rerender(
|
rerender(
|
||||||
<SidebarProvider>
|
<SidebarProvider>
|
||||||
<CampaignWizardChromeProvider>
|
<CampaignPageChromeProvider role="coordinator">
|
||||||
<CampaignMobileTopBar />
|
<CampaignWizardChromeProvider>
|
||||||
<CampaignWizardShell
|
<CampaignMobileTopBar />
|
||||||
flowTitle="Ajustar votos"
|
<CampaignWizardShell
|
||||||
stepTitle="Passo 2"
|
flowTitle="Ajustar votos"
|
||||||
isEntryStep
|
stepTitle="Passo 2"
|
||||||
previousHref="/campanha"
|
isEntryStep
|
||||||
contentFocus="none"
|
previousHref="/campanha"
|
||||||
>
|
contentFocus="none"
|
||||||
<input aria-label="Primeiro campo" />
|
>
|
||||||
</CampaignWizardShell>
|
<input aria-label="Primeiro campo" />
|
||||||
</CampaignWizardChromeProvider>
|
</CampaignWizardShell>
|
||||||
|
</CampaignWizardChromeProvider>
|
||||||
|
</CampaignPageChromeProvider>
|
||||||
</SidebarProvider>,
|
</SidebarProvider>,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -144,33 +152,37 @@ describe('CampaignWizardShell', () => {
|
||||||
it('moves focus to the step title when stepTitle changes', () => {
|
it('moves focus to the step title when stepTitle changes', () => {
|
||||||
const { rerender } = render(
|
const { rerender } = render(
|
||||||
<SidebarProvider>
|
<SidebarProvider>
|
||||||
<CampaignWizardChromeProvider>
|
<CampaignPageChromeProvider role="coordinator">
|
||||||
<CampaignMobileTopBar />
|
<CampaignWizardChromeProvider>
|
||||||
<CampaignWizardShell
|
<CampaignMobileTopBar />
|
||||||
flowTitle="Ajustar votos"
|
<CampaignWizardShell
|
||||||
stepTitle="Passo 1"
|
flowTitle="Ajustar votos"
|
||||||
isEntryStep
|
stepTitle="Passo 1"
|
||||||
previousHref="/campanha"
|
isEntryStep
|
||||||
>
|
previousHref="/campanha"
|
||||||
Corpo
|
>
|
||||||
</CampaignWizardShell>
|
Corpo
|
||||||
</CampaignWizardChromeProvider>
|
</CampaignWizardShell>
|
||||||
|
</CampaignWizardChromeProvider>
|
||||||
|
</CampaignPageChromeProvider>
|
||||||
</SidebarProvider>,
|
</SidebarProvider>,
|
||||||
)
|
)
|
||||||
|
|
||||||
rerender(
|
rerender(
|
||||||
<SidebarProvider>
|
<SidebarProvider>
|
||||||
<CampaignWizardChromeProvider>
|
<CampaignPageChromeProvider role="coordinator">
|
||||||
<CampaignMobileTopBar />
|
<CampaignWizardChromeProvider>
|
||||||
<CampaignWizardShell
|
<CampaignMobileTopBar />
|
||||||
flowTitle="Ajustar votos"
|
<CampaignWizardShell
|
||||||
stepTitle="Passo 2"
|
flowTitle="Ajustar votos"
|
||||||
isEntryStep
|
stepTitle="Passo 2"
|
||||||
previousHref="/campanha"
|
isEntryStep
|
||||||
>
|
previousHref="/campanha"
|
||||||
Corpo
|
>
|
||||||
</CampaignWizardShell>
|
Corpo
|
||||||
</CampaignWizardChromeProvider>
|
</CampaignWizardShell>
|
||||||
|
</CampaignWizardChromeProvider>
|
||||||
|
</CampaignPageChromeProvider>
|
||||||
</SidebarProvider>,
|
</SidebarProvider>,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ const routerState = vi.hoisted(() => ({
|
||||||
|
|
||||||
vi.mock('next/navigation', async (importActual) => ({
|
vi.mock('next/navigation', async (importActual) => ({
|
||||||
...(await importActual()),
|
...(await importActual()),
|
||||||
|
usePathname: () => '/campanha/acoes/atualizar-votos',
|
||||||
useRouter: () => ({
|
useRouter: () => ({
|
||||||
push: (...args: unknown[]) => routerState.push(...args),
|
push: (...args: unknown[]) => routerState.push(...args),
|
||||||
replace: vi.fn(),
|
replace: vi.fn(),
|
||||||
|
|
@ -17,6 +18,7 @@ vi.mock('next/navigation', async (importActual) => ({
|
||||||
|
|
||||||
import { CampaignListPendingBoundary } from '@/components/campaign/shared/CampaignListPending'
|
import { CampaignListPendingBoundary } from '@/components/campaign/shared/CampaignListPending'
|
||||||
import { CampaignWizardShell } from '@/components/campaign/shared/CampaignWizardShell'
|
import { CampaignWizardShell } from '@/components/campaign/shared/CampaignWizardShell'
|
||||||
|
import { CampaignPageChromeProvider } from '@/components/campaign/shell/CampaignPageChromeContext'
|
||||||
import { CampaignMobileTopBar } from '@/components/campaign/shell/CampaignMobileTopBar'
|
import { CampaignMobileTopBar } from '@/components/campaign/shell/CampaignMobileTopBar'
|
||||||
import { CampaignWizardChromeProvider } from '@/components/campaign/shell/CampaignWizardChromeContext'
|
import { CampaignWizardChromeProvider } from '@/components/campaign/shell/CampaignWizardChromeContext'
|
||||||
import { SidebarProvider } from '@/components/ui/Sidebar'
|
import { SidebarProvider } from '@/components/ui/Sidebar'
|
||||||
|
|
@ -26,10 +28,11 @@ import { stubMatchMedia } from '../helpers/matchMedia'
|
||||||
const mountWizardNavigation = () =>
|
const mountWizardNavigation = () =>
|
||||||
render(
|
render(
|
||||||
<SidebarProvider>
|
<SidebarProvider>
|
||||||
<CampaignWizardChromeProvider>
|
<CampaignPageChromeProvider role="coordinator">
|
||||||
<CampaignListPendingBoundary>
|
<CampaignWizardChromeProvider>
|
||||||
<CampaignMobileTopBar />
|
<CampaignListPendingBoundary>
|
||||||
<CampaignWizardShell
|
<CampaignMobileTopBar />
|
||||||
|
<CampaignWizardShell
|
||||||
flowTitle="Ajustar votos"
|
flowTitle="Ajustar votos"
|
||||||
stepTitle="Quantos votos?"
|
stepTitle="Quantos votos?"
|
||||||
isEntryStep={false}
|
isEntryStep={false}
|
||||||
|
|
@ -41,6 +44,7 @@ const mountWizardNavigation = () =>
|
||||||
</CampaignWizardShell>
|
</CampaignWizardShell>
|
||||||
</CampaignListPendingBoundary>
|
</CampaignListPendingBoundary>
|
||||||
</CampaignWizardChromeProvider>
|
</CampaignWizardChromeProvider>
|
||||||
|
</CampaignPageChromeProvider>
|
||||||
</SidebarProvider>,
|
</SidebarProvider>,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue