diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index ce2df2cd3..d127af2ba 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -37,6 +37,7 @@ module Admin
@user = User.find(params[:id])
if FeatureFlag.enabled?(:admin_member_view)
+ set_current_tab(params[:tab])
set_feedback_messages
set_related_reactions
end
@@ -300,5 +301,13 @@ module Admin
credit_params
end
+
+ def set_current_tab(current_tab = "overview")
+ @current_tab = if current_tab.in? Constants::UserDetails::TAB_LIST.map(&:downcase)
+ current_tab
+ else
+ "overview"
+ end
+ end
end
end
diff --git a/app/lib/constants/user_details.rb b/app/lib/constants/user_details.rb
new file mode 100644
index 000000000..1a85cf486
--- /dev/null
+++ b/app/lib/constants/user_details.rb
@@ -0,0 +1,11 @@
+module Constants
+ module UserDetails
+ TAB_LIST = %w[
+ Overview
+ Notes
+ Emails
+ Reports
+ Flags
+ ].freeze
+ end
+end
diff --git a/app/views/admin/users/show.html.erb b/app/views/admin/users/show.html.erb
index 374cdd569..103248942 100644
--- a/app/views/admin/users/show.html.erb
+++ b/app/views/admin/users/show.html.erb
@@ -1,10 +1,8 @@
-<%# TODO: incorporate a tab component. For now you have to manually change the value %>
-<% current_tab = "overview" # overview|emails|notes|reports|flags %>
<% if FeatureFlag.enabled?(:admin_member_view) %>
<%= render "admin/users/show/profile" %>
<%= render "admin/users/show/tabs" %>
- <% if current_tab == 'overview' %>
+ <% if @current_tab == "overview" %>
<%= render "admin/users/show/overview/stats" if @user.registered %>
@@ -30,7 +28,7 @@
- <% elsif current_tab == 'notes' %>
+ <% elsif @current_tab == "notes" %>
<%= render "admin/users/show/notes/form" %>
@@ -39,7 +37,7 @@
<%= render "admin/users/show/notes/index" %>
- <% elsif current_tab == 'emails' %>
+ <% elsif @current_tab == "emails" %>
<%= render "admin/users/show/emails/verification" %>
@@ -49,11 +47,11 @@
<%= render "admin/users/show/emails/index" %>
- <% elsif current_tab == 'reports' %>
+ <% elsif @current_tab == "reports" %>
<%= render "admin/users/show/reports/index" %>
- <% elsif current_tab == 'flags' %>
+ <% elsif @current_tab == "flags" %>
<%= render "admin/users/show/flags/index" %>
diff --git a/app/views/admin/users/show/_tabs.html.erb b/app/views/admin/users/show/_tabs.html.erb
index 67ca9c6af..6d5c23457 100644
--- a/app/views/admin/users/show/_tabs.html.erb
+++ b/app/views/admin/users/show/_tabs.html.erb
@@ -1,9 +1,9 @@
diff --git a/cypress/integration/seededFlows/adminFlows/users/navigateTabs.spec.js b/cypress/integration/seededFlows/adminFlows/users/navigateTabs.spec.js
new file mode 100644
index 000000000..dbe3ab6fd
--- /dev/null
+++ b/cypress/integration/seededFlows/adminFlows/users/navigateTabs.spec.js
@@ -0,0 +1,43 @@
+describe('Navigate User Tabs', () => {
+ describe('As an admin', () => {
+ beforeEach(() => {
+ cy.testSetup();
+ cy.fixture('users/adminUser.json').as('user');
+ cy.get('@user').then((user) => {
+ cy.loginAndVisit(user, '/admin/users/2');
+ });
+ });
+
+ it(`navigates to the "Overview" tab`, () => {
+ cy.findByRole('navigation', { name: 'Member details' }).within(() => {
+ cy.findByRole('link', { name: /Overview/i }).should('exist');
+ cy.findByRole('link', { name: /Overview/i }).click();
+ cy.url().should('not.contain', 'tab=');
+ });
+ });
+
+ it(`navigates to the "Notes" tab`, () => {
+ cy.findByRole('link', { name: /Notes/i }).should('exist');
+ cy.findByRole('link', { name: /Notes/i }).click();
+ cy.url().should('contain', '/admin/users/2?tab=notes');
+ });
+
+ it(`navigates to the "Emails" tab`, () => {
+ cy.findByRole('link', { name: /Emails/i }).should('exist');
+ cy.findByRole('link', { name: /Emails/i }).click();
+ cy.url().should('contain', '/admin/users/2?tab=emails');
+ });
+
+ it(`navigates to the "Reports" tab`, () => {
+ cy.findByRole('link', { name: /Reports/i }).should('exist');
+ cy.findByRole('link', { name: /Reports/i }).click();
+ cy.url().should('contain', '/admin/users/2?tab=reports');
+ });
+
+ it(`navigates to the "Flags" tab`, () => {
+ cy.findByRole('link', { name: /Flags/i }).should('exist');
+ cy.findByRole('link', { name: /Flags/i }).click();
+ cy.url().should('contain', '/admin/users/2?tab=flags');
+ });
+ });
+});