Skip to content

Add jobs view integration tests for selection, pinning and classification - #9804

Open
camd wants to merge 4 commits into
masterfrom
camd/jobs-view-integration-tests
Open

Add jobs view integration tests for selection, pinning and classification#9804
camd wants to merge 4 commits into
masterfrom
camd/jobs-view-integration-tests

Conversation

@camd

@camd camd commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

We've had a few navigation regressions in the jobs view, so this adds more Playwright integration coverage there — particularly around job selection and the pinning / classification flow. The new coverage also caught (and this PR fixes) a real regression: the job button was not re-rendering after saving a classification.

Changes

  • mockJobsApi.js — extracts the API fixture mocking from jobs_view.spec.js into a shared helper so all jobs-view specs can use it. Extended with:
    • a real failure-classification list
    • a logged-in mode (seedLoggedInSession() + user: [SHERIFF_USER])
    • capture of POST payloads to /note/ and /bug-job-map/ so tests can assert what would be written to the backend
  • job_selection.spec.js (new, 5 tests)
    • deep link with selectedTaskRun selects the job on load
    • n/p step through unclassified failures (skipping already-classified jobs) with the URL updating at each step
    • arrow keys step through all jobs regardless of status
    • Escape clears both the selection and the URL param
    • browser back after selecting a job returns to the unselected state
  • pinboard_classification.spec.js (new, 6 tests)
    • pinning via spacebar, the details panel pin button, and the push header pin-all button; un-pinning
    • the b shortcut opens the related-bug input and adds a bug chip
    • saving while logged out shows the "Must be logged in" notification
    • a full logged-in classification: pin, attach a bug, save — asserting the actual /note/ and /bug-job-map/ POST payloads, that the pinboard clears afterwards, and that the classification is reflected in the view: the job button gains the star icon and data-classified marker, and (after deselecting) the u unclassified-failures filter no longer shows the job
  • jobs_view.spec.js (+2 tests): the u unclassified-failures filter toggle, and searchStr deep links applying the filter on initial load
  • failure_summary.spec.js (new, 3 tests) — the suggestions themselves are backend logic covered by pytest (tests/model/test_error_summary.py); these cover the frontend wiring using the bug_suggestions.json fixture:
    • the failure summary is the default tab for a failed job and renders the failure line with its suggested bugs
    • pinning a suggested bug pins the job with the bug attached
    • a logged-in user can classify from a suggested bug, asserting the note and bug-job-map API payloads and the job button updating to classified

Bug fix: job button not updating after saving a classification

The new view-update assertions failed against the current code, and it turned out to be a real regression, not a test issue. The class-to-functional conversion replaced JobButton's custom shouldComponentUpdate with a plain memo(). Jobs are mutated in place when a classification is saved (PinBoard.jsx sets job.failure_classification_id and dispatches applyNewJobs), so the memo comparison saw the same job object reference and skipped the re-render — the classified star only appeared after the next jobs poll delivered fresh job objects, instead of immediately on save.

Fix: JobGroup/JobsAndGroups now pass failure_classification_id and resultStatus to JobButton as scalar props (as the old class component received them). Prop values are snapshotted at parent render time, so memo() sees the change even though the job object identity is unchanged. JobButton.test.jsx is updated for the new props.

Notes

  • Selecting a job currently pushes two identical history entries (duplicate pushState), so a single browser-back does not deselect. The back-button test loops goBack() with a comment for now; once that is fixed the test can be tightened to a single goBack().
  • The fixtures serve the same job list for every push, so a selected job lights up a copy on each push — assertions use .first(), and the classified-state assertions scope to the job's own push (push-<id>), since only that push receives the applyNewJobs update.
  • Playwright's hasText is case-insensitive substring matching (the classified icon's "classified" title text made 'D' match the Cpp button), so job symbols are matched with anchored regexes like /^B$/. The flip side: the star svg's <title> makes a classified button's text "Bclassified", so /^B$/ would miss it — the post-save assertions match on data-classified instead.
  • Keyboard shortcuts are ignored while an input has focus (KeyboardShortcuts.jsx), and Firefox does not move focus on button clicks, so the spec blurs the related-bug input before pressing Escape.

Testing

  • pnpm test:integration: all 35 tests pass (jobs-view specs also run with --repeat-each locally to check for flakiness)
  • pnpm test: full unit suite passes (1088 tests), including the updated JobButton.test.jsx
  • pnpm lint clean

@netlify

netlify Bot commented Aug 23, 2026

Copy link
Copy Markdown

Deploy Preview for treeherder ready!

Name Link
🔨 Latest commit 0c08155
🔍 Latest deploy log https://app.netlify.com/projects/treeherder/deploys/6a9709a4d99e7c00086849dd
😎 Deploy Preview https://deploy-preview-9804--treeherder.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

camd added 2 commits August 29, 2026 10:05
…tion

Extract the API fixture mocks from jobs_view.spec.js into a shared
mockJobsApi.js helper, extended with a logged-in mode and capture of
POSTs to the note and bug-job-map endpoints.

New coverage:
- job_selection.spec.js: selectedTaskRun deep links, n/p and arrow-key
  navigation, escape clearing the selection, and browser back after
  selecting a job
- pinboard_classification.spec.js: pinning via spacebar, the details
  panel pin button and the push header pin-all button, adding a related
  bug with the b shortcut, the logged-out save error, and a full
  logged-in classification asserting the API payloads
- jobs_view.spec.js: the u unclassified-failures filter toggle and
  searchStr deep links
Serve the bug_suggestions.json fixture through the shared mock helper
(new bugSuggestions option) and cover the wiring from a selected
failed job through the failure summary tab to the pinboard:

- the failure summary is the default tab for a failed job and renders
  the failure line with its suggested bugs
- pinning a suggested bug pins the job with the bug attached
- a logged-in user can classify from a suggested bug, asserting the
  note and bug-job-map API payloads
@camd
camd force-pushed the camd/jobs-view-integration-tests branch from fef38c0 to 1336a53 Compare August 29, 2026 17:05
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.67%. Comparing base (32d46df) to head (1336a53).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9804   +/-   ##
=======================================
  Coverage   83.67%   83.67%           
=======================================
  Files         640      640           
  Lines       38875    38875           
  Branches     3487     3492    +5     
=======================================
  Hits        32529    32529           
  Misses       5956     5956           
  Partials      390      390           

☔ View full report in Codecov by Harness.
📢 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.

@camd camd self-assigned this Sep 1, 2026
camd added 2 commits September 1, 2026 10:21
The class-to-functional conversion replaced JobButton's custom
shouldComponentUpdate with a plain memo(). Jobs are mutated in place
when a classification is saved, so the memo comparison saw the same
job reference and skipped the re-render; the classified star only
appeared after the next jobs poll instead of immediately.

Restore the old design by passing failure_classification_id and
resultStatus as scalar props from JobGroup/JobsAndGroups: prop values
are snapshotted at parent render time, so memo() sees the change even
though the job object identity is unchanged.
Extends the two logged-in classification tests to verify the saved
classification is reflected in the push list: the job button gains the
star icon and data-classified marker, and (after deselecting) the 'u'
unclassified-failures filter no longer shows the job.

Notes:
- The star svg's <title> adds 'classified' to the button text, so a
  /^B$/ hasText filter would miss the classified button; match on
  data-classified instead.
- Keyboard shortcuts are ignored while an input has focus and Firefox
  does not move focus on button clicks, so blur the related-bug input
  before pressing Escape.
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.

2 participants