Skip to content

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

Adapt tests to new PageHeader structure

Henriette Darge46860150b115
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index c5f4f6c9f91..efe0e2795a4 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -128,7 +128,7 @@ module UsersHelper
href: change_status_user_path(user,
name.to_sym => "1",
back_url: request.fullpath),
- method: :post) do |button|
+ data: { method: :post }) do |button|
button.with_leading_visual_icon(icon: change_user_status_icons[name])
title
end
diff --git a/app/views/groups/show.html.erb b/app/views/groups/show.html.erb
index 369ad1d9d3a..2891a345637 100644
--- a/app/views/groups/show.html.erb
+++ b/app/views/groups/show.html.erb
@@ -30,7 +30,7 @@ See COPYRIGHT and LICENSE files for more details.
<%=
render(Primer::OpenProject::PageHeader.new) do |header|
- header.with_title { @group.name }
+ header.with_title(test_selector: "groups--title") { @group.name }
header.with_breadcrumbs(
[
{ href: groups_path, text: t(:label_group_plural) },
@@ -44,6 +44,7 @@ See COPYRIGHT and LICENSE files for more details.
size: :medium,
href: edit_group_path(@group),
aria: { label: I18n.t(:button_edit) },
+ data: { "test-selector": "groups--edit-group-button" },
title: I18n.t(:button_edit)) do |button|
button.with_leading_visual_icon(icon: :pencil)
t(:button_edit)
diff --git a/app/views/placeholder_users/_toolbar.html.erb b/app/views/placeholder_users/_toolbar.html.erb
index d969dec61a2..2d5f18d9153 100644
--- a/app/views/placeholder_users/_toolbar.html.erb
+++ b/app/views/placeholder_users/_toolbar.html.erb
@@ -57,6 +57,7 @@ See COPYRIGHT and LICENSE files for more details.
disabled: !deletable,
href: deletable ? deletion_info_placeholder_user_path(@placeholder_user) : "#",
aria: { label: I18n.t(:button_delete) },
+ data: { "test-selector": "placeholder-user--delete-button" },
title: deletable ?
I18n.t(:button_delete) :
I18n.t("placeholder_users.right_to_manage_members_missing")) do |button|
diff --git a/app/views/placeholder_users/show.html.erb b/app/views/placeholder_users/show.html.erb
index 5fc19af8b28..72537fe3ef0 100644
--- a/app/views/placeholder_users/show.html.erb
+++ b/app/views/placeholder_users/show.html.erb
@@ -64,6 +64,7 @@ See COPYRIGHT and LICENSE files for more details.
disabled: !deletable,
href: deletable ? deletion_info_placeholder_user_path(@placeholder_user) : "#",
aria: { label: I18n.t(:button_delete) },
+ data: { "test-selector": "placeholder-user--delete-button" },
title: deletable ?
I18n.t(:button_delete) :
I18n.t("placeholder_users.right_to_manage_members_missing")) do |button|
diff --git a/app/views/roles/index.html.erb b/app/views/roles/index.html.erb
index 2e03178fbcf..2c87cc4218a 100644
--- a/app/views/roles/index.html.erb
+++ b/app/views/roles/index.html.erb
@@ -43,6 +43,7 @@ See COPYRIGHT and LICENSE files for more details.
aria: { label: I18n.t(:label_role_new) },
title: I18n.t(:label_role_new),
tag: :a,
+ test_selector: "roles--create-button",
href: new_role_path) do |button|
button.with_leading_visual_icon(icon: :plus)
Role.model_name.human
diff --git a/spec/features/groups/group_show_spec.rb b/spec/features/groups/group_show_spec.rb
index e1971fb18d1..87ff37e61d4 100644
--- a/spec/features/groups/group_show_spec.rb
+++ b/spec/features/groups/group_show_spec.rb
@@ -42,8 +42,8 @@ RSpec.describe "group show page" do
it "I can visit the group page" do
visit show_group_path(group)
- expect(page).to have_css("h2", text: "Bob's Team")
- expect(page).to have_css(".toolbar-item", text: "Edit")
+ expect(page).to have_test_selector("groups--title", text: "Bob's Team")
+ expect(page).to have_test_selector("groups--edit-group-button", text: "Edit")
expect(page).to have_css("li", text: member.name)
end
end
@@ -53,8 +53,8 @@ RSpec.describe "group show page" do
it "I can visit the group page" do
visit show_group_path(group)
- expect(page).to have_css("h2", text: "Bob's Team")
- expect(page).to have_no_css(".toolbar-item")
+ expect(page).to have_test_selector("groups--title", text: "Bob's Team")
+ expect(page).not_to have_test_selector("groups--edit-group-button")
expect(page).to have_no_css("li", text: member.name)
end
end
diff --git a/spec/features/placeholder_users/delete_spec.rb b/spec/features/placeholder_users/delete_spec.rb
index 87763aaee28..9e67de49bec 100644
--- a/spec/features/placeholder_users/delete_spec.rb
+++ b/spec/features/placeholder_users/delete_spec.rb
@@ -35,11 +35,11 @@ RSpec.describe "delete placeholder user", :js do
it "can delete name" do
visit placeholder_user_path(placeholder_user)
- expect(page).to have_css ".button", text: "Delete"
+ expect(page).to have_test_selector "placeholder-user--delete-button", text: "Delete"
visit edit_placeholder_user_path(placeholder_user)
- expect(page).to have_css ".button", text: "Delete"
+ expect(page).to have_test_selector "placeholder-user--delete-button", text: "Delete"
click_on "Delete"
# Expect to be on delete confirmation
@@ -89,11 +89,11 @@ RSpec.describe "delete placeholder user", :js do
visit placeholder_user_path(placeholder_user)
- expect(page).to have_css ".button.-disabled", text: "Delete"
+ expect(page).to have_css("[data-test-selector='placeholder-user--delete-button'][disabled='disabled']", text: "Delete")
visit edit_placeholder_user_path(placeholder_user)
- expect(page).to have_css ".button.-disabled", text: "Delete"
+ expect(page).to have_css("[data-test-selector='placeholder-user--delete-button'][disabled='disabled']", text: "Delete")
end
end
diff --git a/spec/features/roles/create_spec.rb b/spec/features/roles/create_spec.rb
index 5b75ce12599..a1c4500254a 100644
--- a/spec/features/roles/create_spec.rb
+++ b/spec/features/roles/create_spec.rb
@@ -44,8 +44,8 @@ RSpec.describe "Role creation", :js, :with_cuprite do
it "allows creating roles and handles errors" do
visit roles_path
- within ".toolbar-item" do
- click_link "Role"
+ within ".SubHeader" do
+ page.find_test_selector("roles--create-button").click
end
fill_in "Name", with: existing_role.name
diff --git a/spec/features/users/edit_users_spec.rb b/spec/features/users/edit_users_spec.rb
index 07e481b9394..18d0c003c3a 100644
--- a/spec/features/users/edit_users_spec.rb
+++ b/spec/features/users/edit_users_spec.rb
@@ -85,7 +85,7 @@ RSpec.describe "edit users", :js, :with_cuprite do
end
def have_visible_tab(label)
- have_css(".op-tab-row--link", text: label.upcase)
+ have_css(".tabnav-tab", text: label)
end
context "as admin" do
@@ -93,7 +93,7 @@ RSpec.describe "edit users", :js, :with_cuprite do
another_admin = create(:admin)
visit edit_user_path(another_admin)
- expect(page).to have_visible_tab("GENERAL")
+ expect(page).to have_visible_tab("General")
end
end
@@ -104,7 +104,7 @@ RSpec.describe "edit users", :js, :with_cuprite do
it "can too edit the user" do
visit edit_user_path(user)
- expect(page).to have_visible_tab("GENERAL")
+ expect(page).to have_visible_tab("General")
expect(page).to have_no_css(".admin-overview-menu-item", text: "Overview")
expect(page).to have_no_css(".users-and-permissions-menu-item", text: "Users and permissions")
@@ -138,7 +138,7 @@ RSpec.describe "edit users", :js, :with_cuprite do
it "can reinvite the user" do
visit edit_user_path(user)
- click_button "Send invitation"
+ click_on "Send invitation"
expect(page).to have_css(".op-toast.-success", text: "An invitation has been sent to [email protected]")
end
@@ -146,8 +146,8 @@ RSpec.describe "edit users", :js, :with_cuprite do
it "can not edit attributes of an admin user" do
visit edit_user_path(admin)
- expect(page).to have_visible_tab("PROJECTS")
- expect(page).not_to have_visible_tab("GENERAL")
+ expect(page).to have_visible_tab("Projects")
+ expect(page).not_to have_visible_tab("General")
end
end
end
diff --git a/spec/support/pages/admin/individual_principals/edit.rb b/spec/support/pages/admin/individual_principals/edit.rb
index a8ca6fc2420..5900da868ad 100644
--- a/spec/support/pages/admin/individual_principals/edit.rb
+++ b/spec/support/pages/admin/individual_principals/edit.rb
@@ -47,7 +47,7 @@ module Pages
end
def open_projects_tab!
- within(".content--tabs") do
+ within(".PageHeader-tabNav") do
click_on "Projects"
end
end
diff --git a/spec/support/pages/admin/users/edit.rb b/spec/support/pages/admin/users/edit.rb
index 23abae8920f..028022ac6c1 100644
--- a/spec/support/pages/admin/users/edit.rb
+++ b/spec/support/pages/admin/users/edit.rb
@@ -105,8 +105,8 @@ module Pages
end
def activate!
- within ".toolbar-items" do
- click_button "Activate"
+ within ".PageHeader-actions" do
+ click_on "Activate"
end
end
end
diff --git a/spec/support/pages/groups.rb b/spec/support/pages/groups.rb
index 40bfbd13272..7eb7f2709a0 100644
--- a/spec/support/pages/groups.rb
+++ b/spec/support/pages/groups.rb
@@ -82,13 +82,13 @@ module Pages
end
def open_users_tab!
- within(".content--tabs") do
+ within(".PageHeader-tabNav") do
click_on "Users"
end
end
def open_projects_tab!
- within(".content--tabs") do
+ within(".PageHeader-tabNav") do
click_on "Projects"
end
end