discourse/spec/system/page_objects/components/select_kit.rb
David Taylor b5721b7b4f
FIX: default_list_filter = none navigation and preloading (#20641)
When a category has default_list_filter=none, there were a number of issues which this commit resolves:

1. When using the breadcrumbs to navigate a `default_list_filter=none` category, adding a tag filter would not apply the no-subcategories filter, but the subcategories dropdown would still say 'none'. This commit adjusts `getCategoryAndTagUrl` so that `/none` is added to the URL

2. When landing on `/tags/c/{slug}/{id}/{tag}`, for a default_list_filter=none category, it would include subcategories. This commit introduces a client-side redirect to match the behavior of `/c/{slug}/{id}`

3. When directly navigating to `/c/{slug}/{id}`, it was correctly redirecting to `/c/{slug}/{id}/none`, BUT it was still using the preloaded data for the old route. This has been happening since e7a84948. Prior to that, the preloaded data was discarded and a new JSON request was made to the server. This commit restores that discarding behavior. In future we may want to look into making this more efficient.

System specs are introduced to provide end-end testing of this functionality
2023-03-14 10:46:05 +00:00

43 lines
938 B
Ruby

# frozen_string_literal: true
module PageObjects
module Components
class SelectKit < PageObjects::Components::Base
attr_reader :element
def initialize(element)
@element = element
end
def is_expanded?
element.has_css?(".is-expanded")
end
def is_collapsed?
element.has_css?(":not(.is-expanded)")
end
def has_selected_value?(value)
element.find(".select-kit-header[data-value='#{value}']")
end
def has_selected_name?(value)
element.find(".select-kit-header[data-name='#{value}']")
end
def expand
element.find(":not(.is-expanded) .select-kit-header").click
end
def collapse
element.find(".is-expanded .select-kit-header").click
end
def select_row_by_value(value)
expand
element.find(".select-kit-row[data-value='#{value}']").click
end
end
end
end