Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

1.1 KB
Raw Blame
import { act, render, screen, waitFor } from '@testing-library/react'
import { setAnalyticsConsent, useAnalyticsConsent } from '../consent-store'
import { COOKIEYES_CONSENT_UPDATE_EVENT, CookieYesConsentBridge } from '../cookieyes-consent-bridge'

function ConsentProbe() {
  const consent = useAnalyticsConsent()
  return <span>{consent}</span>
}

describe('CookieYesConsentBridge', () => {
  beforeEach(() => {
    document.cookie = 'cookieyes-consent=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/'
    setAnalyticsConsent('unknown')
  })

  it('updates consent when CookieYes reports a rejection', async () => {
    document.cookie = 'cookieyes-consent=consentid:test,analytics:yes; path=/'
    render(
      <>
        <CookieYesConsentBridge />
        <ConsentProbe />
      </>,
    )
    expect(await screen.findByText('granted')).toBeInTheDocument()

    act(() =>
      document.dispatchEvent(
        new CustomEvent(COOKIEYES_CONSENT_UPDATE_EVENT, {
          detail: { accepted: ['necessary'], rejected: ['analytics'] },
        }),
      ),
    )

    await waitFor(() => expect(screen.getByText('denied')).toBeInTheDocument())
  })
})