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.4 KB
Raw Blame
import { getAnalyticsConsentFromCookie, getAnalyticsConsentFromEvent } from '../consent-store'

describe('analytics consent store', () => {
  describe('CookieYes cookie parsing', () => {
    it.each([
      ['', 'unknown'],
      ['session=value', 'unknown'],
      ['cookieyes-consent=consentid:abc,necessary:yes', 'unknown'],
      ['cookieyes-consent=consentid:abc,analytics:yes', 'granted'],
      ['cookieyes-consent=consentid:abc,analytics:no', 'denied'],
      ['cookieyes-consent=consentid%3Aabc%2Canalytics%3Ayes', 'granted'],
    ] as const)('maps %s to %s', (cookie, expected) => {
      expect(getAnalyticsConsentFromCookie(cookie)).toBe(expected)
    })
  })

  describe('CookieYes update events', () => {
    it('grants consent when analytics is accepted', () => {
      expect(
        getAnalyticsConsentFromEvent({ accepted: ['necessary', 'analytics'], rejected: [] }),
      ).toBe('granted')
    })

    it('denies consent when analytics is rejected', () => {
      expect(
        getAnalyticsConsentFromEvent({ accepted: ['necessary'], rejected: ['analytics'] }),
      ).toBe('denied')
    })

    it('does not change consent for unrelated categories or malformed details', () => {
      expect(
        getAnalyticsConsentFromEvent({ accepted: ['functional'], rejected: ['advertisement'] }),
      ).toBeNull()
      expect(getAnalyticsConsentFromEvent(null)).toBeNull()
    })
  })
})