dify/web/test/console/system-features.ts
Xiyuan Chen ab0e131e87
refactor(api): move license expiry notice flag onto license detail (#40128)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-08-07 03:53:35 +00:00

119 lines
2.9 KiB
TypeScript

import type {
GetSystemFeaturesLicenseResponse,
GetSystemFeaturesResponse,
} from '@dify/contracts/api/console/system-features/types.gen'
import {
zLicenseStatus,
zPluginInstallationScope,
} from '@dify/contracts/api/console/system-features/zod.gen'
export type DeepPartial<T> =
T extends Array<infer U>
? Array<U>
: T extends object
? { [K in keyof T]?: DeepPartial<T[K]> }
: T
const baseSystemFeatures = {
deployment_edition: 'COMMUNITY',
enable_app_deploy: false,
sso_enforced_for_signin: false,
sso_enforced_for_signin_protocol: null,
enable_marketplace: false,
enable_email_code_login: false,
enable_email_password_login: true,
enable_social_oauth_login: false,
enable_collaboration_mode: true,
is_allow_register: false,
is_email_setup: false,
enable_change_email: true,
license: {
status: zLicenseStatus.enum.none,
},
branding: {
enabled: false,
login_page_logo: '',
workspace_logo: '',
favicon: '',
application_title: '',
},
webapp_auth: {
enabled: false,
allow_sso: false,
sso_config: {
protocol: null,
},
allow_email_code_login: false,
allow_email_password_login: false,
allow_public_access: true,
},
plugin_installation_permission: {
plugin_installation_scope: zPluginInstallationScope.enum.all,
restrict_to_marketplace_only: false,
},
rbac_enabled: false,
enable_creators_platform: false,
enable_explore_banner: false,
enable_learn_app: true,
enable_step_by_step_tour: false,
knowledge_fs_enabled: false,
} satisfies GetSystemFeaturesResponse
const baseSystemFeaturesLicense = {
status: zLicenseStatus.enum.none,
license_expiry_notice_enabled: false,
expired_at: '',
workspaces: {
enabled: false,
size: 0,
limit: 0,
},
seats: {
enabled: false,
size: 0,
limit: 0,
},
} satisfies GetSystemFeaturesLicenseResponse
export const createSystemFeaturesFixture = (
overrides: DeepPartial<GetSystemFeaturesResponse> = {},
): GetSystemFeaturesResponse => ({
...baseSystemFeatures,
...overrides,
branding: {
...baseSystemFeatures.branding,
...overrides.branding,
},
webapp_auth: {
...baseSystemFeatures.webapp_auth,
...overrides.webapp_auth,
sso_config: {
...baseSystemFeatures.webapp_auth.sso_config,
...overrides.webapp_auth?.sso_config,
},
},
plugin_installation_permission: {
...baseSystemFeatures.plugin_installation_permission,
...overrides.plugin_installation_permission,
},
license: {
...baseSystemFeatures.license,
...overrides.license,
},
})
export const createSystemFeaturesLicenseFixture = (
overrides: DeepPartial<GetSystemFeaturesLicenseResponse> = {},
): GetSystemFeaturesLicenseResponse => ({
...baseSystemFeaturesLicense,
...overrides,
workspaces: {
...baseSystemFeaturesLicense.workspaces,
...overrides.workspaces,
},
seats: {
...baseSystemFeaturesLicense.seats,
...overrides.seats,
},
})