[BI Data Mapper] Update button selectors and file comparisons in e2e tests#1525
Conversation
📝 WalkthroughWalkthroughTest utility file updated with more specific VSCode button locators for DataMapper refresh and clear mapping actions. FileUtils whitespace normalization logic adjusted to remove all whitespace instead of collapsing to single spaces. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
`@workspaces/bi/bi-extension/src/test/e2e-playwright-tests/data-mapper/DataMapperUtils.ts`:
- Around line 191-192: The current whitespace normalization on file1Content and
file2Content is overly aggressive and contains a redundant replace: remove the
standalone .replace(/\n/g, '') and change the second call from .replace(/\s+/g,
'') to .replace(/\s+/g, ' ') so runs of whitespace collapse to a single space
instead of being removed; update the normalization logic where file1Content and
file2Content are transformed (the two replace(...) calls) to use only the
collapse-to-single-space behavior to preserve token boundaries and avoid
false-positive test matches.
| file1Content = file1Content.replace(/\n/g, '').replace(/\s+/g, ''); | ||
| file2Content = file2Content.replace(/\n/g, '').replace(/\s+/g, ''); |
There was a problem hiding this comment.
Whitespace normalization is both redundant and overly aggressive — risk of false-positive test passes.
Two problems with the new logic:
-
Redundant first replace. JavaScript's
\salready matches\n, so.replace(/\n/g, '')is completely subsumed by the immediately following.replace(/\s+/g, ''). The first call is dead code. -
Removing all whitespace conflates adjacent tokens. The previous strategy (collapsing runs to a single space) preserved token boundaries:
string namestayedstring name. The new strategy concatenates everything:string name→stringname. This means two semantically different Ballerina snippets that happen to share the same non-whitespace characters (e.g. different variable name casing caused by a formatter introducing a new binding) compare as equal, allowing tests to pass when the generated output is actually wrong.
Consider keeping the collapse-to-single-space approach (replace(/\s+/g, ' ')) instead, which is sufficient to ignore indentation/newline formatting differences while still catching meaningful token-level differences.
♻️ Proposed fix
- file1Content = file1Content.replace(/\n/g, '').replace(/\s+/g, '');
- file2Content = file2Content.replace(/\n/g, '').replace(/\s+/g, '');
+ file1Content = file1Content.replace(/\s+/g, ' ').trim();
+ file2Content = file2Content.replace(/\s+/g, ' ').trim();📝 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.
| file1Content = file1Content.replace(/\n/g, '').replace(/\s+/g, ''); | |
| file2Content = file2Content.replace(/\n/g, '').replace(/\s+/g, ''); | |
| file1Content = file1Content.replace(/\s+/g, ' ').trim(); | |
| file2Content = file2Content.replace(/\s+/g, ' ').trim(); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@workspaces/bi/bi-extension/src/test/e2e-playwright-tests/data-mapper/DataMapperUtils.ts`
around lines 191 - 192, The current whitespace normalization on file1Content and
file2Content is overly aggressive and contains a redundant replace: remove the
standalone .replace(/\n/g, '') and change the second call from .replace(/\s+/g,
'') to .replace(/\s+/g, ' ') so runs of whitespace collapse to a single space
instead of being removed; update the normalization logic where file1Content and
file2Content are transformed (the two replace(...) calls) to use only the
collapse-to-single-space behavior to preserve token boundaries and avoid
false-positive test matches.
There was a problem hiding this comment.
This is a quick fix until formatting is re-enabled for the data mapper. Replacing multiple spaces with a single space caused some failures after running, atm this change is required
Purpose
Summary by CodeRabbit