Skip to content

fix(toppreise): correctly render badge states by ignoring hidden reference prices and using exact cent math - #34

Merged
tazztone merged 3 commits into
mainfrom
fix/toppreise-aufschlag-badge-logic-9872297218425983263
Sep 18, 2026
Merged

tazztone merged 3 commits into
mainfrom
fix/toppreise-aufschlag-badge-logic-9872297218425983263

Conversation

@tazztone

Copy link
Copy Markdown
Owner

This PR refactors price extraction and comparison logic in the Toppreise suite. It ensures that canonical visible prices are selected over hidden competing prices, exact cent math replaces 1% approximations, and explicit states (new-low, at-low, above-low) drive badge rendering. It also removes an aggressive force=True in Playwright tests and adds a regression fixture.


PR created automatically by Jules for task 9872297218425983263 started by @tazztone

…traction

This commit addresses an issue in the Toppreise suite where a competing hidden reference price (e.g., CHF 47.82) was incorrectly parsed, leading to an 'Aufschlag' (markup) warning being displayed on cards where the current visible price (e.g., CHF 37.95) was actually an all-time low.

- Refactored `extractCardData` to utilize a new `extractCanonicalPrice` helper, ensuring the canonical displayed price is reliably extracted and competing reference prices are ignored.
- Replaced fuzzy 1% (`* 1.01` and `* 0.99`) floating-point comparisons with exact integer-cent comparison (`priceToCents`) across the codebase.
- Re-architected badge rendering logic to rely on four explicit states (`new-low`, `at-low`, `above-low`, and `unknown`), ensuring "Aufschlag" is rendered strictly for the `above-low` state.
- Added synchronous validation inside the `badgeDifEl` click event to prevent stale history from applying to a dynamically swapped card price.
- Updated `mock_toppreise.html` with a regression fixture containing a conflicting reference price and wrote matching test assertions.
- Fixed an overly aggressive `force=True` click interaction in Playwright tests (`test_deal_score_weight_preset_dropdown_in_filter_bar`) by using `node.click()` evaluation.

Co-authored-by: tazztone <62671577+tazztone@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules Bot and others added 2 commits September 18, 2026 11:44
…s and using exact cent math

This commit addresses an issue in the Toppreise suite where a competing hidden reference price (e.g., CHF 47.82) was incorrectly parsed, leading to an 'Aufschlag' (markup) warning being displayed on cards where the current visible price (e.g., CHF 37.95) was actually an all-time low.

- Refactored `extractCardData` to utilize a new `extractCanonicalPrice` helper, ensuring the canonical displayed price is reliably extracted and competing reference prices are ignored. The fallback fails cleanly to avoid catching hidden `.Plugin_Price` elements.
- Replaced fuzzy 1% floating-point comparisons with exact integer-cent comparison (`priceToCents`) for explicit badge rendering states (`new-low`, `at-low`, `above-low`), while explicitly keeping 1% bounds in historical clustering to preserve intended threshold behavior.
- Added synchronous validation inside the `badgeDifEl` click event to prevent stale history from applying to a dynamically swapped card price using `priceToCents() !== priceToCents()` logic.
- Cleaned up the regression fixture `mock_toppreise.html` mimicking the competing reference price, fixing route mocking for `page.route` to handle both GET URLs and POST variants cleanly.
- Replaced aggressive `force=True` and raw node `.click()` interactions in Playwright tests with proper overlay waits to obey Playwright's actionability checks naturally.
- Deleted obsolete one-off `patch_*.py` development mutation scripts.

Co-authored-by: tazztone <62671577+tazztone@users.noreply.github.com>
…s and using exact cent math

This commit addresses an issue in the Toppreise suite where a competing hidden reference price (e.g., CHF 47.82) was incorrectly parsed, leading to an 'Aufschlag' (markup) warning being displayed on cards where the current visible price (e.g., CHF 37.95) was actually an all-time low.

- Refactored `extractCardData` to utilize a new `extractCanonicalPrice` helper, ensuring the canonical displayed price is reliably extracted and competing reference prices are ignored. The fallback fails cleanly to avoid catching hidden `.Plugin_Price` elements.
- Replaced fuzzy 1% floating-point comparisons with exact integer-cent comparison (`priceToCents`) for explicit badge rendering states (`new-low`, `at-low`, `above-low`), while explicitly keeping 1% bounds in historical clustering to preserve intended threshold behavior.
- Added synchronous validation inside the `badgeDifEl` click event to prevent stale history from applying to a dynamically swapped card price using `priceToCents() !== priceToCents()` logic.
- Cleaned up the regression fixture `mock_toppreise.html` mimicking the competing reference price, fixing route mocking for `page.route` to handle both GET URLs and POST variants cleanly.
- Replaced aggressive `force=True` and raw node `.click()` interactions in Playwright tests with proper overlay waits to obey Playwright's actionability checks naturally.
- Deleted obsolete one-off `patch_*.py` development mutation scripts.

Co-authored-by: tazztone <62671577+tazztone@users.noreply.github.com>
@tazztone
tazztone merged commit 389ebd9 into main Sep 18, 2026
1 check passed
@tazztone
tazztone deleted the fix/toppreise-aufschlag-badge-logic-9872297218425983263 branch September 24, 2026 08:17
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