mirror of
https://github.com/supabase/supabase.git
synced 2026-06-21 23:12:45 +08:00
## What kind of change does this PR introduce? Chore ## What is the current behavior? Endpoints have no (public) unique identifier, making it hard to distinguish in UI. ## What is the new behavior? Endpoints now have a name field. This is optional but strongly encouraged: - No _(Optional)_ on label - Autogenerated name Removing an endpoint name makes corresponding UI fall back the URL. | Before | After | | --- | --- | | <img width="1234" height="629" alt="Settings Oldie 2 Toolshed Supabase-CF557DE5-FA03-40E7-938E-2CC87F27C9A5" src="https://github.com/user-attachments/assets/4b55fcb7-f8bc-4b85-a374-9ee62e452cb0" /> | <img width="1234" height="629" alt="Settings Oldie 2 Toolshed Supabase-74BBF142-DEC0-4626-B614-B05EBB2AC0EF" src="https://github.com/user-attachments/assets/7ff40a91-c71a-4e20-85f8-0837d62202aa" /> | | <img width="1234" height="629" alt="Settings Oldie 2 Toolshed Supabase-32A4B56C-61F5-4C1C-81DD-C455835E075F" src="https://github.com/user-attachments/assets/f732ca50-2c60-4fbc-99c7-53afb5c34682" /> | <img width="1234" height="629" alt="Settings Oldie 2 Toolshed Supabase-29987973-9616-4409-9DF1-B9581112D4C3" src="https://github.com/user-attachments/assets/0cf1db9a-fe84-4140-a2fc-bf10cf295c3b" /> |
92 lines
2.5 KiB
TypeScript
92 lines
2.5 KiB
TypeScript
import { beforeEach, describe, expect, it } from 'vitest'
|
|
|
|
import {
|
|
clearPendingSigningSecretReveal,
|
|
getPendingSigningSecretReveal,
|
|
resetPendingSigningSecretRevealForTests,
|
|
setPendingSigningSecretReveal,
|
|
shouldHandleEndpointNotFound,
|
|
} from './PlatformWebhooksPage.utils'
|
|
|
|
describe('PlatformWebhooksPage.utils', () => {
|
|
const endpointId = '7f2c9d4a-6e31-4d9d-9a1f-2c4b5e6f7081'
|
|
const otherEndpointId = '1a4e8c73-5b29-44af-8c62-9f1d2b3c4d5e'
|
|
const missingEndpointId = '00000000-0000-4000-8000-000000000000'
|
|
|
|
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,
|
|
hasSelectedEndpoint: true,
|
|
pendingCreatedEndpointId: null,
|
|
})
|
|
).toBe(false)
|
|
})
|
|
|
|
it('returns false while route is transitioning to a newly created endpoint', () => {
|
|
expect(
|
|
shouldHandleEndpointNotFound({
|
|
endpointId,
|
|
hasSelectedEndpoint: false,
|
|
pendingCreatedEndpointId: endpointId,
|
|
})
|
|
).toBe(false)
|
|
})
|
|
|
|
it('returns true for invalid endpoint routes', () => {
|
|
expect(
|
|
shouldHandleEndpointNotFound({
|
|
endpointId: missingEndpointId,
|
|
hasSelectedEndpoint: false,
|
|
pendingCreatedEndpointId: null,
|
|
})
|
|
).toBe(true)
|
|
})
|
|
|
|
it('stores and reads pending signing secret reveal for matching endpoint route', () => {
|
|
setPendingSigningSecretReveal('project', {
|
|
endpointId,
|
|
signingSecret: 'whsec_example',
|
|
})
|
|
|
|
expect(getPendingSigningSecretReveal('project', endpointId)).toEqual({
|
|
endpointId,
|
|
signingSecret: 'whsec_example',
|
|
})
|
|
})
|
|
|
|
it('ignores pending signing secret reveal when endpoint route does not match', () => {
|
|
setPendingSigningSecretReveal('project', {
|
|
endpointId,
|
|
signingSecret: 'whsec_example',
|
|
})
|
|
|
|
expect(getPendingSigningSecretReveal('project', otherEndpointId)).toBeNull()
|
|
})
|
|
|
|
it('clears pending signing secret reveal', () => {
|
|
setPendingSigningSecretReveal('project', {
|
|
endpointId,
|
|
signingSecret: 'whsec_example',
|
|
})
|
|
|
|
clearPendingSigningSecretReveal('project')
|
|
|
|
expect(getPendingSigningSecretReveal('project', endpointId)).toBeNull()
|
|
})
|
|
})
|