Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions console-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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';
</script>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
Expand Down
1 change: 1 addition & 0 deletions vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Loading