OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
update feature specs
Behrokh Satarnejad65625c414976
diff --git a/spec/features/my/autologin_tokens_management_spec.rb b/spec/features/my/autologin_tokens_management_spec.rbdeleted file mode 100644index 07e18d83b18..00000000000--- a/spec/features/my/autologin_tokens_management_spec.rb+++ /dev/null@@ -1,86 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "spec_helper"--RSpec.describe "My account autologin tokens management", :js do- include Redmine::I18n- shared_let(:user) { create(:user) }- shared_let(:old_token) { create(:autologin_token, user:, created_at: 1.year.ago, expires_on: 1.year.ago + 1.day) }- shared_let(:new_token) do- create(:autologin_token,- user:,- data: { browser: "Mozilla Firefox", browser_version: "12.3", platform: "Linux" },- expires_on: 1.day.from_now)- end-- before do- login_as user- visit my_sessions_path- end-- context "with autologin disabled", with_settings: { autologin: 0 } do- it "does not show tokens" do- expect(page).to have_no_text "Remembered devices"- expect(page).not_to have_test_selector("Users::AutoLoginTokens::TableComponent")- end- end-- context "with autologin enabled", with_settings: { autologin: 1 } do- it "can list and terminate sessions" do- page.within_test_selector("Users::AutoLoginTokens::TableComponent") do- expect(page).to have_css(".generic-table tbody tr", count: 2)- trs = page.all(".generic-table tbody tr")- expect(trs[0]).to have_text("unknown browser")- expect(trs[0]).to have_text("unknown operating system")- expect(trs[0]).to have_css(".buttons a")- expect(trs[0]).to have_no_css(".icon-yes")- expect(trs[0]).to have_text format_date(1.year.ago + 1.day)-- expect(trs[1]).to have_text("Mozilla Firefox (Version 12.3)")- expect(trs[1]).to have_text("Linux")- expect(trs[1]).to have_no_css(".icon-yes")- expect(trs[1]).to have_css(".buttons a")- expect(trs[1]).to have_text format_date(1.day.from_now)-- accept_confirm do- trs[1].find(".buttons a").click- end- end-- expect(page).to have_text "Successful deletion"- page.within_test_selector("Users::AutoLoginTokens::TableComponent") do- expect(page).to have_css(".generic-table tbody tr", count: 1)- end-- expect { new_token.reload }.to raise_error(ActiveRecord::RecordNotFound)- end- end-enddiff --git a/spec/features/my/sessions_management_spec.rb b/spec/features/my/sessions_management_spec.rbindex 2a3dbabba72..a9e280072fe 100644--- a/spec/features/my/sessions_management_spec.rb+++ b/spec/features/my/sessions_management_spec.rb@@ -42,39 +42,67 @@ RSpec.describe "My account session management", :js, :selenium dolet!(:plain_session) { create(:user_session, user:, data: session_data) }let!(:user_session) { Sessions::UserSession.find_by(session_id: plain_session.session_id) }+ let!(:autologin_token) do+ create(:autologin_token,+ user:,+ data: { browser: "Firefox", browser_version: "142", platform: "macOS" },+ created_at: 3.days.ago,+ expires_on: 4.days.from_now)+ end+before dologin_as(user)- # Session is inserted with now() by default, and doesn't take the data attributeSessions::UserSession.where(id: user_session.id).update_all(updated_at: 5.days.ago)visit my_account_path- end-- it "can list and terminate sessions" doclick_on "Session management"+ end+ it "can list and terminate sessions and remembered devices" dopage.within_test_selector("Users::Sessions::TableComponent") do- expect(page).to have_css(".generic-table tbody tr", count: 2)- trs = page.all(".generic-table tbody tr")- expect(trs[0]).to have_css(".icon-yes")- expect(trs[0]).to have_text("Current session")+ # Current session + old session + remembered device+ expect(page).to have_css(".Box-row", count: 3)++ trs = page.all(".Box-row")++ # Current session+ expect(trs[0]).to have_text(I18n.t("users.sessions.current"))expect(trs[0]).to have_text("unknown browser")expect(trs[0]).to have_text("unknown operating system")expect(trs[0]).to have_no_css(".buttons a")- expect(trs[1]).to have_no_css(".spot-icon_yes")++ # Old sessionexpect(trs[1]).to have_text("Mozilla Firefox (Version 12.3)")expect(trs[1]).to have_text("Linux")expect(trs[1]).to have_text format_time(old_session_time)- expect(trs[1]).to have_css(".buttons a")+ expect(trs[1]).to have_css("a.Button")++ # Remembered device (token)+ expect(trs[2]).to have_text("Firefox (Version 142)")+ expect(trs[2]).to have_text("macOS")+ expect(trs[2]).to have_text(format_time(autologin_token.created_at))+ expect(trs[2]).to have_css("a.Button")++ # Revoke the old session+ trs[1].find("a.Button").click+ end- trs[1].find(".buttons a").click+ page.driver.browser.switch_to.alert.accept++ page.within_test_selector("Users::Sessions::TableComponent") do+ trs = page.all(".Box-row")+ # Revoke the remembered device+ trs[1].find("a.Button").clickendpage.driver.browser.switch_to.alert.acceptpage.within_test_selector("Users::Sessions::TableComponent") do- expect(page).to have_css(".generic-table tbody tr", count: 1)+ # Only current session remains+ expect(page).to have_css(".Box-row", count: 1)end+ # Both old session and token are goneexpect { user_session.reload }.to raise_error(ActiveRecord::RecordNotFound)+ expect { autologin_token.reload }.to raise_error(ActiveRecord::RecordNotFound)endend