Skip to content

Commit

Permalink
Fix test checking for no items and error message at the same time
Browse files Browse the repository at this point in the history
  • Loading branch information
camertron committed Dec 9, 2024
1 parent 5779027 commit be3fdf9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion app/components/primer/alpha/select_panel_element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,10 @@ export class SelectPanelElement extends HTMLElement {
#setErrorState(type: ErrorStateType) {
let errorElement = this.bodyErrorMessage

if (type === ErrorStateType.BODY) {
// If the error type is BODY but the body error message element doesn't exist,
// that means the no items/results message is showing, so the error needs to be
// shown in banner form instead.
if (type === ErrorStateType.BODY && this.bodyErrorMessage) {
this.bodyErrorMessage?.removeAttribute('hidden')
this.bannerErrorMessage.setAttribute('hidden', '')
} else {
Expand Down
6 changes: 3 additions & 3 deletions test/system/alpha/select_panel_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1075,15 +1075,15 @@ def test_no_results_filter_failure
end

# no items on initial load
assert_selector "select-panel", text: "No results found"
assert_selector "select-panel", text: "No items found"

wait_for_items_to_load do
filter_results(query: "foobar")
end

# only the banner-based error message should appear
assert_selector "[data-target='select-panel.bannerErrorElement']", text: "Sorry, something went wrong"
refute_selector "[data-target='select-panel.fragmentErrorElement']"
assert_selector "[data-target='select-panel.bannerErrorMessage']", text: "Sorry, something went wrong"
refute_selector "[data-target='select-panel.bodyErrorMessage']"
end

def test_remote_fetch_clears_input_on_close
Expand Down

0 comments on commit be3fdf9

Please sign in to comment.