Skip to content

Fix saving status filter by correctly saving preferences#3445

Merged
lunkwill42 merged 1 commit intoUninett:5.13.xfrom
johannaengland:bugfix/status-save-filter
Aug 18, 2025
Merged

Fix saving status filter by correctly saving preferences#3445
lunkwill42 merged 1 commit intoUninett:5.13.xfrom
johannaengland:bugfix/status-save-filter

Conversation

@johannaengland
Copy link
Copy Markdown
Contributor

@johannaengland johannaengland commented Aug 14, 2025

Scope and purpose

Fixes #3442.

b3a2502 added encoding the status preference pickle. The resulting bytes were saved without decoding them to string. That lead to the status tool not showing the saved filter.

The filtering itself still worked since that is done by the frontend.

Contributor Checklist

Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to NAV can be found in the
Hacker's guide to NAV.

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • Added/changed documentation
  • Linted/formatted the code with ruff, easiest by using pre-commit
  • The first line of the commit message continues the sentence "If applied, this commit will ...", starts with a capital letter, does not end with punctuation and is 50 characters or less long. See https://cbea.ms/git-commit/
  • This pull request is based on the correct upstream branch: For a patch/bugfix affecting the latest stable version, it should be based on that version's branch (<major>.<minor>.x). For a new feature or other additions, it should be based on master.

@johannaengland johannaengland requested a review from a team August 14, 2025 13:09
@johannaengland johannaengland self-assigned this Aug 14, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Aug 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.80%. Comparing base (efb4dcd) to head (5ac0af1).
⚠️ Report is 2 commits behind head on 5.13.x.

Additional details and impacted files
@@             Coverage Diff             @@
##           5.13.x    #3445       +/-   ##
===========================================
+ Coverage        0   60.80%   +60.80%     
===========================================
  Files           0      606      +606     
  Lines           0    43809    +43809     
  Branches        0       48       +48     
===========================================
+ Hits            0    26638    +26638     
- Misses          0    17159    +17159     
- Partials        0       12       +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@johannaengland johannaengland force-pushed the bugfix/status-save-filter branch from 8c3eb7d to 56f585b Compare August 14, 2025 13:34
lunkwill42
lunkwill42 previously approved these changes Aug 15, 2025
Copy link
Copy Markdown
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

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

Good stuff, only comment are three apparently non-functional lines

Comment on lines +35 to +54
def test_get_default_status_filter_should_show_filter_for_encoded_filter(
client, admin_account
):
datastring = base64.b64encode(
pickle.dumps(
{
"status_filters": "alert_type",
"alert_type": "linkDegraded",
"stateless_threshold": "24",
}
)
)
admin_account.preferences[admin_account.PREFERENCE_KEY_STATUS] = datastring
admin_account.save()

url = reverse('status2-index')
response = client.get(url)
assert response.status_code == 200
assert "Alert type" in smart_str(response.content)
assert "linkDegraded" in smart_str(response.content)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Have you verified that this test fails before your patch is added?

Because, I would assume both the "Alert type" and "linkDegraded" strings are always present in the response content of the status page, as part of the hidden form fields.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Very good point, fixed it now, but needed to rebase, since I made a mess of the commit history when I first thought I would not be able to test it

b3a2502 added encoding status preference pickle
The resulting bytes were saved without decoding them to string
That lead to the status tool not showing the saved filter
The filtering itself still worked since that is done by the frontend
@johannaengland johannaengland force-pushed the bugfix/status-save-filter branch from 947e86b to 5ac0af1 Compare August 15, 2025 12:19
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

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

🎉

@lunkwill42 lunkwill42 merged commit 3e4a7b6 into Uninett:5.13.x Aug 18, 2025
15 checks passed
@lunkwill42 lunkwill42 linked an issue Aug 18, 2025 that may be closed by this pull request
@johannaengland johannaengland deleted the bugfix/status-save-filter branch August 27, 2025 09:59
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.

[BUG] Saved status tool filter preferences are active but not shown

2 participants