diff --git a/console-rs/src/lib.rs b/console-rs/src/lib.rs index 5bcf2c72..fba71adf 100644 --- a/console-rs/src/lib.rs +++ b/console-rs/src/lib.rs @@ -218,6 +218,52 @@ mod tests { assert!(!index.data.is_empty()); } + #[test] + fn test_all_placeholders_present_in_embedded_files() { + // Must stay in sync with the placeholders replaced in `get_file`. + let placeholders = [ + "VITE_IDP_AUTHORITY_PLACEHOLDER", + "VITE_IDP_CLIENT_ID_PLACEHOLDER", + "VITE_IDP_REDIRECT_PATH_PLACEHOLDER", + "VITE_IDP_SCOPE_PLACEHOLDER", + "VITE_IDP_RESOURCE_PLACEHOLDER", + "VITE_IDP_POST_LOGOUT_REDIRECT_PATH_PLACEHOLDER", + "VITE_IDP_POST_LOGOUT_REDIRECT_URL_PLACEHOLDER", + "VITE_IDP_POST_LOGOUT_REDIRECT_DISABLED_PLACEHOLDER", + "VITE_ENABLE_AUTHENTICATION_PLACEHOLDER", + "VITE_ENABLE_PERMISSIONS_PLACEHOLDER", + "VITE_ENABLE_USER_SURVEYS_PLACEHOLDER", + "VITE_IDP_TOKEN_TYPE_PLACEHOLDER", + "VITE_BASE_URL_PREFIX_PLACEHOLDER", + "VITE_APP_ICEBERG_CATALOG_URL_PLACEHOLDER", + ]; + + // Iterate via `embedded_iter`/`embedded` so gzipped entries (>=64 KB) are + // searched by their decompressed contents, not their gzip bytes. + let files: Vec<_> = embedded_iter().collect(); + let mut found = Vec::new(); + let mut missing = Vec::new(); + + for placeholder in &placeholders { + let is_found = files.iter().any(|file_path| { + embedded(file_path).is_some_and(|file| { + std::str::from_utf8(&file.data) + .is_ok_and(|content| content.contains(placeholder)) + }) + }); + if is_found { + found.push(*placeholder); + } else { + missing.push(*placeholder); + } + } + + assert!( + missing.is_empty(), + "Placeholders not found in any embedded console file — frontend build likely no longer emits them, so templating in get_file() is a no-op.\n missing: {missing:#?}\n found: {found:#?}" + ); + } + #[test] fn test_get_all_files() { let config = LakekeeperConsoleConfig { diff --git a/index.html b/index.html index 8d3ec6f5..6fb14c8d 100644 --- a/index.html +++ b/index.html @@ -12,6 +12,7 @@ globalThis.__lkauth = 'VITE_ENABLE_AUTHENTICATION_PLACEHOLDER'; globalThis.__lkperm = 'VITE_ENABLE_PERMISSIONS_PLACEHOLDER'; globalThis.__lknologout = 'VITE_IDP_POST_LOGOUT_REDIRECT_DISABLED_PLACEHOLDER'; + globalThis.__lksurveys = 'VITE_ENABLE_USER_SURVEYS_PLACEHOLDER';
diff --git a/vite.config.mts b/vite.config.mts index 138e8f4f..257025f3 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -148,6 +148,7 @@ export default defineConfig(({ mode }) => { 'import.meta.env.VITE_ENABLE_AUTHENTICATION': '(globalThis.__lkauth)', 'import.meta.env.VITE_ENABLE_PERMISSIONS': '(globalThis.__lkperm)', 'import.meta.env.VITE_IDP_POST_LOGOUT_REDIRECT_DISABLED': '(globalThis.__lknologout)', + 'import.meta.env.VITE_ENABLE_USER_SURVEYS': '(globalThis.__lksurveys)', }), }, resolve: {