Skip to content

chore(test): Add test for placeholder presence#281

Open
c-thiel wants to merge 2 commits into
mainfrom
ct/test-placeholder-presence
Open

chore(test): Add test for placeholder presence#281
c-thiel wants to merge 2 commits into
mainfrom
ct/test-placeholder-presence

Conversation

@c-thiel
Copy link
Copy Markdown
Member

@c-thiel c-thiel commented Apr 21, 2026

Summary by CodeRabbit

  • Tests
    • Added a validation test that verifies all required template/placeholders are present in the embedded console files. This improves reliability by catching missing configuration tokens early, reducing the risk of deployment or runtime template issues. No production behavior or public APIs were changed.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

Walkthrough

A new unit test, test_all_placeholders_present_in_embedded_files, was added to assert that a fixed list of Vite/template placeholder strings appears in at least one of the embedded console files enumerated via LakekeeperConsole::iter().

Changes

Test: placeholder presence

Layer / File(s) Summary
Test Data
console-rs/src/lib.rs
Defines an array of expected Vite/template placeholder strings to check.
Collection
console-rs/src/lib.rs
Uses LakekeeperConsole::iter() to gather all embedded console entries and decodes each file.data as UTF-8.
Assertion / Test Logic
console-rs/src/lib.rs
For each placeholder, asserts at least one embedded file's content contains it; on failure reports missing and found placeholders.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A test hops in to peek through each file,
Seeking placeholders with a curious smile,
It checks embedded bits, one by one,
Ensuring templates are intact when done,
Little guardrails, light and agile.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a test for placeholder presence in embedded files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ct/test-placeholder-presence

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@console-rs/src/lib.rs`:
- Around line 210-220: The test is iterating raw stored paths and calling
LakekeeperConsole::get which returns gzipped bytes, so UTF-8 checks always fail;
replace use of LakekeeperConsole::iter() with the test-only
LakekeeperConsole::embedded_iter() (which strips .gz suffixes) and call
LakekeeperConsole::embedded(name) instead of LakekeeperConsole::get(file_path)
so you receive decompressed content before running
std::str::from_utf8(...).contains(placeholder); update references in the loop to
use embedded_iter() and embedded() (or their returned bytes) so placeholders are
checked against decompressed text.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 41298aee-0974-4621-bb83-a53f2cb81c0f

📥 Commits

Reviewing files that changed from the base of the PR and between ab86b1e and 789345a.

📒 Files selected for processing (1)
  • console-rs/src/lib.rs

Comment thread console-rs/src/lib.rs
Comment on lines +210 to +220
let files: Vec<_> = LakekeeperConsole::iter().collect();
let mut found = Vec::new();
let mut missing = Vec::new();

for placeholder in &placeholders {
let is_found = files.iter().any(|file_path| {
LakekeeperConsole::get(file_path).is_some_and(|file| {
std::str::from_utf8(&file.data)
.is_ok_and(|content| content.contains(placeholder))
})
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Gzipped assets are not decompressed — placeholders will be falsely reported as missing

LakekeeperConsole::iter() yields the raw stored paths (including .js.gz, .html.gz, etc. produced by build.rs). LakekeeperConsole::get(file_path) then returns the raw compressed bytes, and std::str::from_utf8 fails on gzip binary content, so is_ok_and(…) is always false for those entries. In a build where large JS assets are stored only as .gz, all 11 placeholders would be reported as missing — a false failure that directly defeats the test's purpose.

The project already exposes the two helpers needed to fix this: the #[cfg(test)]-gated embedded_iter() (which strips .gz suffixes, lines 81–89) and the public embedded() (which decompresses transparently, lines 64–75). test_get_all_files uses exactly these two; the new test should too.

🐛 Proposed fix
-        let files: Vec<_> = LakekeeperConsole::iter().collect();
+        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| {
-                LakekeeperConsole::get(file_path).is_some_and(|file| {
+                embedded(file_path.as_ref()).is_some_and(|file| {
                     std::str::from_utf8(&file.data)
                         .is_ok_and(|content| content.contains(placeholder))
                 })
             });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let files: Vec<_> = LakekeeperConsole::iter().collect();
let mut found = Vec::new();
let mut missing = Vec::new();
for placeholder in &placeholders {
let is_found = files.iter().any(|file_path| {
LakekeeperConsole::get(file_path).is_some_and(|file| {
std::str::from_utf8(&file.data)
.is_ok_and(|content| content.contains(placeholder))
})
});
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.as_ref()).is_some_and(|file| {
std::str::from_utf8(&file.data)
.is_ok_and(|content| content.contains(placeholder))
})
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@console-rs/src/lib.rs` around lines 210 - 220, The test is iterating raw
stored paths and calling LakekeeperConsole::get which returns gzipped bytes, so
UTF-8 checks always fail; replace use of LakekeeperConsole::iter() with the
test-only LakekeeperConsole::embedded_iter() (which strips .gz suffixes) and
call LakekeeperConsole::embedded(name) instead of
LakekeeperConsole::get(file_path) so you receive decompressed content before
running std::str::from_utf8(...).contains(placeholder); update references in the
loop to use embedded_iter() and embedded() (or their returned bytes) so
placeholders are checked against decompressed text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant