Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
filter search spec
Browse files Browse the repository at this point in the history
EinLama committed Oct 24, 2024
1 parent d4c7871 commit 5d1cfc3
Showing 2 changed files with 58 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -28,7 +28,9 @@

require "spec_helper"

RSpec.describe "Work package filtering by assignee", :js do
RSpec.describe "Work package filtering by assignee", :js, :with_cuprite do
include Components::Autocompleter::NgSelectAutocompleteHelpers

let(:project) { create(:project) }
let(:invisible_project) { create(:project) }
let(:wp_table) { Pages::WorkPackagesTable.new(project) }
@@ -94,4 +96,58 @@
wp_table.ensure_work_package_not_listed!(work_package_user_assignee)
wp_table.expect_work_package_listed(work_package_placeholder_user_assignee)
end

context "when using the auto completer" do
context "with no permission to view emails" do
let!(:global_role) { create(:empty_global_role) }

it "only shows the email address of the current user" do
wp_table.visit!
wp_table.expect_work_package_listed(work_package_user_assignee, work_package_placeholder_user_assignee)

# toggle open
filters.open
filters.add_filter_by("Assignee", "is (OR)", [""])

autocomplete = find(".advanced-filters--ng-select ng-select")
target_dropdown = search_autocomplete autocomplete,
query: "",
results_selector: "body"

# Their own email address is visible to users
expect(target_dropdown).to have_css(".ng-option", text: current_user.firstname)
expect(target_dropdown).to have_css(".ng-option", text: current_user.mail)

# Other users email address is invisible
expect(target_dropdown).to have_css(".ng-option", text: other_user.firstname)
expect(target_dropdown).to have_no_css(".ng-option", text: other_user.mail)
end
end

context "with permission to view emails" do
let!(:global_role) { create(:standard_global_role) }

it "shows the email address of all users" do
wp_table.visit!
wp_table.expect_work_package_listed(work_package_user_assignee, work_package_placeholder_user_assignee)

# toggle open
filters.open
filters.add_filter_by("Assignee", "is (OR)", [""])

autocomplete = find(".advanced-filters--ng-select ng-select")
target_dropdown = search_autocomplete autocomplete,
query: "",
results_selector: "body"

# Their own email address is visible to users
expect(target_dropdown).to have_css(".ng-option", text: current_user.firstname)
expect(target_dropdown).to have_css(".ng-option", text: current_user.mail)

# Other users email address is invisible
expect(target_dropdown).to have_css(".ng-option", text: other_user.firstname)
expect(target_dropdown).to have_css(".ng-option", text: other_user.mail)
end
end
end
end
2 changes: 1 addition & 1 deletion spec/support/components/work_packages/filters.rb
Original file line number Diff line number Diff line change
@@ -113,7 +113,7 @@ def expect_alternative_available_filter(search_term, displayed_name)

def expect_loaded
SeleniumHubWaiter.wait
expect(filter_button).to have_css(".badge", wait: 2, visible: :all)
expect(filter_button).to have_css(".badge", wait: 10, visible: :all)
end

def add_filter(name)

0 comments on commit 5d1cfc3

Please sign in to comment.