mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 09:55:06 +03:00
## What kind of change does this PR introduce? Impending feature addition. Resolves DEPR-340. ## What is the current behavior? We don’t have any platform webhook support. ## What is the new behavior? This puts the scaffolding for platform webhooks **behind a feature flag**. The content is currently UI-only (with mock data and a [temporary tracking file](https://github.com/supabase/supabase/blob/8adadc61f57c70b686a0f5f05e9f7f05837e0466/apps/studio/components/interfaces/Platform/Webhooks/DEPR-340-backend-integration-tracker.md)). Merging this in lets us work incrementally from here on.
88 lines
2.4 KiB
TypeScript
88 lines
2.4 KiB
TypeScript
import { beforeEach, describe, expect, it } from 'vitest'
|
|
|
|
import {
|
|
clearPendingSigningSecretReveal,
|
|
getPendingSigningSecretReveal,
|
|
resetPendingSigningSecretRevealForTests,
|
|
setPendingSigningSecretReveal,
|
|
shouldHandleEndpointNotFound,
|
|
} from './PlatformWebhooksPage.utils'
|
|
|
|
describe('PlatformWebhooksPage.utils', () => {
|
|
beforeEach(() => {
|
|
resetPendingSigningSecretRevealForTests()
|
|
})
|
|
|
|
it('returns false when endpoint id is absent', () => {
|
|
expect(
|
|
shouldHandleEndpointNotFound({
|
|
endpointId: undefined,
|
|
hasSelectedEndpoint: false,
|
|
pendingCreatedEndpointId: null,
|
|
})
|
|
).toBe(false)
|
|
})
|
|
|
|
it('returns false when endpoint is selected', () => {
|
|
expect(
|
|
shouldHandleEndpointNotFound({
|
|
endpointId: 'endpoint-abc12345',
|
|
hasSelectedEndpoint: true,
|
|
pendingCreatedEndpointId: null,
|
|
})
|
|
).toBe(false)
|
|
})
|
|
|
|
it('returns false while route is transitioning to a newly created endpoint', () => {
|
|
expect(
|
|
shouldHandleEndpointNotFound({
|
|
endpointId: 'endpoint-abc12345',
|
|
hasSelectedEndpoint: false,
|
|
pendingCreatedEndpointId: 'endpoint-abc12345',
|
|
})
|
|
).toBe(false)
|
|
})
|
|
|
|
it('returns true for invalid endpoint routes', () => {
|
|
expect(
|
|
shouldHandleEndpointNotFound({
|
|
endpointId: 'endpoint-missing',
|
|
hasSelectedEndpoint: false,
|
|
pendingCreatedEndpointId: null,
|
|
})
|
|
).toBe(true)
|
|
})
|
|
|
|
it('stores and reads pending signing secret reveal for matching endpoint route', () => {
|
|
setPendingSigningSecretReveal('project', {
|
|
endpointId: 'endpoint-abc12345',
|
|
signingSecret: 'whsec_example',
|
|
})
|
|
|
|
expect(getPendingSigningSecretReveal('project', 'endpoint-abc12345')).toEqual({
|
|
endpointId: 'endpoint-abc12345',
|
|
signingSecret: 'whsec_example',
|
|
})
|
|
})
|
|
|
|
it('ignores pending signing secret reveal when endpoint route does not match', () => {
|
|
setPendingSigningSecretReveal('project', {
|
|
endpointId: 'endpoint-abc12345',
|
|
signingSecret: 'whsec_example',
|
|
})
|
|
|
|
expect(getPendingSigningSecretReveal('project', 'endpoint-other')).toBeNull()
|
|
})
|
|
|
|
it('clears pending signing secret reveal', () => {
|
|
setPendingSigningSecretReveal('project', {
|
|
endpointId: 'endpoint-abc12345',
|
|
signingSecret: 'whsec_example',
|
|
})
|
|
|
|
clearPendingSigningSecretReveal('project')
|
|
|
|
expect(getPendingSigningSecretReveal('project', 'endpoint-abc12345')).toBeNull()
|
|
})
|
|
})
|