mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-26 21:53:06 +00:00
B119 — fix crash ao abrir Nível no card mobile de municípios
O footer portaled do CampaignListSheetProvider ficava fora da árvore React do Drawer; DrawerCloseButton exigia useDialogRootContext e derrubava a página. Substitui Cancelar por Button + onOpenChange(false) nos footers de nível e sinal. Pin: unit com provider compartilhado + e2e mobile. Closes #206 Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
This commit is contained in:
parent
891f654655
commit
f8cfe0746b
5 changed files with 66 additions and 4 deletions
|
|
@ -12,7 +12,6 @@ import { useCampaignCellFailureChannel } from '@/components/campaign/shared/useC
|
|||
import { Alert, AlertDescription } from '@/components/ui/Alert'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Checkbox } from '@/components/ui/Checkbox'
|
||||
import { DrawerCloseButton } from '@/components/ui/Drawer'
|
||||
import { Field, FieldContent, FieldLabel } from '@/components/ui/field'
|
||||
import { NativeSelect, NativeSelectOption } from '@/components/ui/native-select'
|
||||
import { Spinner } from '@/components/ui/Spinner'
|
||||
|
|
@ -239,7 +238,14 @@ export const MunicipalityListLevelControl = ({
|
|||
isSheet && open ? (
|
||||
<>
|
||||
{submitButton}
|
||||
<DrawerCloseButton>Cancelar</DrawerCloseButton>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
className="min-h-11 w-full"
|
||||
onClick={() => handleOpenChange(false)}
|
||||
>
|
||||
Cancelar
|
||||
</Button>
|
||||
</>
|
||||
) : undefined
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import {
|
|||
import { CampaignFormActionMessage } from '@/components/campaign/shared/CampaignFormActionMessage'
|
||||
import { useCampaignFormSuccessToast } from '@/components/campaign/shared/useCampaignFormSuccessToast'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { DrawerCloseButton } from '@/components/ui/Drawer'
|
||||
import { Spinner } from '@/components/ui/Spinner'
|
||||
import type { CampaignFormActionState } from '@/utilities/campaignFormActionError'
|
||||
import {
|
||||
|
|
@ -85,7 +84,14 @@ export const MunicipalityListSignalControl = ({
|
|||
isSheet && open ? (
|
||||
<>
|
||||
{submitButton}
|
||||
<DrawerCloseButton>Cancelar</DrawerCloseButton>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
className="min-h-11 w-full"
|
||||
onClick={() => setOpen(false)}
|
||||
>
|
||||
Cancelar
|
||||
</Button>
|
||||
</>
|
||||
) : undefined
|
||||
}
|
||||
|
|
|
|||
|
|
@ -204,6 +204,7 @@ export const CampaignCellEditOverlay = ({
|
|||
{triggerButton}
|
||||
{liveRegion}
|
||||
{showPortals && bodyTarget ? createPortal(children, bodyTarget) : null}
|
||||
{/* Portaled footer is outside the Drawer React tree — no DrawerCloseButton (B119). */}
|
||||
{showPortals && footerTarget && footer ? createPortal(footer, footerTarget) : null}
|
||||
</>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -424,6 +424,33 @@ test.describe('Municípios — cards no celular (B42)', () => {
|
|||
await expect(page).toHaveURL(`${campaign.baseURL}/campanha/municipios/${municipality.slug}`)
|
||||
await expect(page.getByRole('heading', { name: municipality.name })).toBeVisible()
|
||||
})
|
||||
|
||||
test('opens the nivel Drawer without navigating or crashing (B119)', async ({
|
||||
campaign,
|
||||
page,
|
||||
}) => {
|
||||
const { fixtures } = campaign
|
||||
const coordinator = await fixtures.createCampaignUser('coordinator', {
|
||||
name: fixtures.value('Coordenador Mobile Nivel'),
|
||||
})
|
||||
const municipality = await fixtures.claimMunicipality()
|
||||
|
||||
await campaign.login(page, coordinator.email!, coordinator.password)
|
||||
const listURL = `${campaign.baseURL}/campanha/municipios?q=${encodeURIComponent(municipality.name)}`
|
||||
await page.goto(listURL)
|
||||
|
||||
const card = page.locator('[data-view="mobile-cards"] article').first()
|
||||
await expect(card).toBeVisible()
|
||||
|
||||
await card.getByRole('button', { name: 'Nível de envolvimento' }).click()
|
||||
const drawer = page.getByRole('dialog', { name: 'Registrar nível de envolvimento' })
|
||||
await expect(drawer).toBeVisible()
|
||||
await expect(drawer.getByText(municipality.name, { exact: true })).toBeVisible()
|
||||
await expect(page).toHaveURL(listURL)
|
||||
|
||||
await drawer.getByRole('button', { name: 'Cancelar' }).click()
|
||||
await expect(drawer).toBeHidden()
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { MunicipalityListLevelControl } from '@/components/campaign/municipality
|
|||
import { MunicipalityListSignalControl } from '@/components/campaign/municipality/MunicipalityListSignalControl'
|
||||
import { MunicipalityListTrendControl } from '@/components/campaign/municipality/MunicipalityListTrendControl'
|
||||
import type { CampaignCellEditOverlayVariant } from '@/components/campaign/shared/CampaignCellEditOverlay'
|
||||
import { CampaignListSheetProvider } from '@/components/campaign/shared/CampaignListSheetHost'
|
||||
import { MunicipalityPortfolioCell } from '@/components/campaign/shared/MunicipalityPortfolioCell'
|
||||
import { TooltipProvider } from '@/components/ui/tooltip'
|
||||
import { toVoteEstimateScenarioViewModel } from '@/lib/voteEstimate'
|
||||
|
|
@ -179,6 +180,27 @@ describe('campaign cell edit overlay', () => {
|
|||
},
|
||||
)
|
||||
|
||||
/**
|
||||
* B119: the mobile cards host ONE shared Drawer (`CampaignListSheetProvider`)
|
||||
* and portal cell footers into it. `DrawerCloseButton` must stay inside the
|
||||
* Drawer React tree — portaled footers call `onOpenChange(false)` instead.
|
||||
*/
|
||||
it('opens the nivel sheet through CampaignListSheetProvider without crashing', async () => {
|
||||
const nivelCase = overlayCases.find((item) => item.name === 'nível de envolvimento')
|
||||
expect(nivelCase).toBeDefined()
|
||||
|
||||
renderWithTooltip(createElement(CampaignListSheetProvider, null, nivelCase!.element('sheet')))
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: nivelCase!.triggerLabel }))
|
||||
|
||||
const dialog = await screen.findByRole('dialog')
|
||||
expect(dialog.querySelector('[data-slot="drawer-title"]')?.textContent).toBe(
|
||||
nivelCase!.drawerTitle,
|
||||
)
|
||||
expect(dialog.textContent).toContain('Cancelar')
|
||||
expect(dialog.textContent).toContain(nivelCase!.footerLabel)
|
||||
})
|
||||
|
||||
it.each(overlayCases)(
|
||||
'keeps $name in a Popover on the desktop table',
|
||||
async ({ triggerLabel, element }) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue