mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
How to test: 1. Connect a project to GH repo 2. Deploy the `config.toml` once 3. Change some setting in Auth 4. You should see a change in `/dashboard/project/_/settings/code-configuration` <img width="1271" height="1186" alt="Screenshot 2026-09-16 at 16 26 39" src="https://github.com/user-attachments/assets/dfc135a4-e495-489e-88fd-b760383793b4" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Configuration drift comparisons now use a consistent project configuration schema. - Drift details display complete current-environment and `config.toml` values, grouped by section. - Matching and unmanaged settings are organized into dedicated sections. - Configuration fields link directly to relevant Studio settings. - Added a warning that GitHub deployments overwrite local changes. - **Bug Fixes** - Configuration updates now refresh project configuration data automatically. - Improved labels and formatting for boolean and redirect URL values. - Drift errors identify invalid configuration paths and provide corrective guidance. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
62 lines
2.1 KiB
TypeScript
62 lines
2.1 KiB
TypeScript
import { toProjectConfigJsonSchema } from '@supabase/config'
|
|
import { isPlainObject } from 'lodash'
|
|
import { describe, it } from 'vitest'
|
|
|
|
import { CONFIG_FIELD_REGISTRY, getFieldDefinition } from './ConfigurationDriftPage.constants'
|
|
|
|
function getConfigFieldPaths(): string[] {
|
|
const schema: unknown = toProjectConfigJsonSchema()
|
|
const sections = isRecord(schema) ? schema.properties : undefined
|
|
if (!isRecord(sections)) return []
|
|
|
|
const configPaths: string[] = []
|
|
|
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
return isPlainObject(value)
|
|
}
|
|
|
|
function walk(node: unknown, path: string[]) {
|
|
const properties = isRecord(node) ? node.properties : undefined
|
|
if (isRecord(properties) && Object.keys(properties).length > 0) {
|
|
for (const [key, childNode] of Object.entries(properties)) walk(childNode, [...path, key])
|
|
return
|
|
}
|
|
|
|
configPaths.push(path.join('.'))
|
|
}
|
|
|
|
for (const [section, sectionNode] of Object.entries(sections)) walk(sectionNode, [section])
|
|
|
|
return configPaths
|
|
}
|
|
|
|
describe('getFieldDefinition', () => {
|
|
it('has a definition for every field the default project config can report', () => {
|
|
const missingPaths = getConfigFieldPaths().filter(
|
|
(configPath) => !getFieldDefinition(configPath)
|
|
)
|
|
|
|
if (missingPaths.length > 0) {
|
|
throw new Error(
|
|
`CONFIG_FIELD_REGISTRY is missing a definition for:\n${missingPaths.join('\n')}`
|
|
)
|
|
}
|
|
})
|
|
|
|
// marked as fails because it depends on @supabase/config being fixed. Once it's fixed, this test should pass and
|
|
// be kept for future regressions of the package.
|
|
it.fails('has no definitions for fields the default project config cannot report', () => {
|
|
const validPaths = new Set(getConfigFieldPaths())
|
|
|
|
const extraPaths = Object.keys(CONFIG_FIELD_REGISTRY).filter(
|
|
(configPath) => !validPaths.has(configPath)
|
|
)
|
|
|
|
if (extraPaths.length > 0) {
|
|
throw new Error(
|
|
`CONFIG_FIELD_REGISTRY has definitions for fields the default project config never reports:\n${extraPaths.join('\n')}`
|
|
)
|
|
}
|
|
})
|
|
})
|