|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +describe "Bookmarking reports attached to a group", type: :system do |
| 4 | + fab!(:current_user) { Fabricate(:admin) } |
| 5 | + fab!(:query_1) do |
| 6 | + Fabricate( |
| 7 | + :query, |
| 8 | + name: "My query", |
| 9 | + description: "Test query", |
| 10 | + sql: "SELECT * FROM users", |
| 11 | + user: current_user, |
| 12 | + ) |
| 13 | + end |
| 14 | + fab!(:group) { Fabricate(:group, name: "group") } |
| 15 | + fab!(:group_user) { Fabricate(:group_user, user: current_user, group: group) } |
| 16 | + fab!(:query_group_1) { Fabricate(:query_group, query: query_1, group: group) } |
| 17 | + let(:bookmark_modal) { PageObjects::Modals::Bookmark.new } |
| 18 | + |
| 19 | + before do |
| 20 | + SiteSetting.data_explorer_enabled = true |
| 21 | + sign_in(current_user) |
| 22 | + end |
| 23 | + |
| 24 | + it "allows the user to bookmark a group report" do |
| 25 | + visit("/g/group/reports/#{query_1.id}") |
| 26 | + find(".query-group-bookmark").click |
| 27 | + expect(bookmark_modal).to be_open |
| 28 | + bookmark_modal.click_primary_button |
| 29 | + expect(page).to have_css(".query-group-bookmark.bookmarked") |
| 30 | + expect(Bookmark.exists?(user: current_user, bookmarkable: query_group_1)).to eq(true) |
| 31 | + end |
| 32 | + |
| 33 | + it "allows the user to edit and delete a group report bookmark" do |
| 34 | + bookmark = |
| 35 | + Fabricate(:bookmark, user: current_user, bookmarkable: query_group_1, reminder_at: nil) |
| 36 | + |
| 37 | + visit("/g/group/reports/#{query_1.id}") |
| 38 | + find(".query-group-bookmark").click |
| 39 | + expect(bookmark_modal).to be_open |
| 40 | + bookmark_modal.fill_name("Remember this query") |
| 41 | + bookmark_modal.click_primary_button |
| 42 | + expect(bookmark_modal).to be_closed |
| 43 | + expect(bookmark.reload.name).to eq("Remember this query") |
| 44 | + |
| 45 | + find(".query-group-bookmark").click |
| 46 | + expect(bookmark_modal).to be_open |
| 47 | + bookmark_modal.delete |
| 48 | + expect(bookmark_modal).to be_closed |
| 49 | + expect(page).not_to have_css(".query-group-bookmark.bookmarked") |
| 50 | + expect(Bookmark.exists?(user: current_user, bookmarkable: query_group_1)).to eq(false) |
| 51 | + end |
| 52 | + |
| 53 | + it "shows bookmarked group reports in the user bookmark list" do |
| 54 | + bookmark = Fabricate(:bookmark, user: current_user, bookmarkable: query_group_1) |
| 55 | + visit("/u/#{current_user.username_lower}/activity/bookmarks") |
| 56 | + expect(page.find(".bookmark-list")).to have_content("My query") |
| 57 | + end |
| 58 | +end |
0 commit comments