diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 70a5abd96..6ceb8d234 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -1,54 +1,4 @@ module AdminHelper - # This is used in app/views/admin/shared/_navbar.html.erb to build the - # side navbar in alphabetical order. - # If you add an item before "config", please update the insert call in - # admin_menu_items below. - - # @ridhwana to delete these when we move over to new admin layout - MENU_ITEMS = [ - { name: "articles", controller: "articles" }, - { name: "broadcasts", controller: "broadcasts" }, - { name: "badges", controller: "badges" }, - { name: "badge_achievements", controller: "badge_achievements" }, - { name: "chat_channels", controller: "chat_channels" }, - { name: "comments", controller: "comments" }, - { name: "config", controller: "config" }, - { name: "display_ads", controller: "display_ads" }, - { name: "events", controller: "events" }, - { name: "html_variants", controller: "html_variants" }, - { name: "listings", controller: "listings" }, - { name: "moderator_actions", controller: "moderator_actions" }, - { name: "mods", controller: "mods" }, - { name: "navigation_links", controller: "navigation_links" }, - { name: "privileged_reactions", controller: "privileged_reactions" }, - { name: "organizations", controller: "organizations" }, - { name: "pages", controller: "pages" }, - { name: "permissions", controller: "permissions" }, - { name: "podcasts", controller: "podcasts" }, - { name: "reports", controller: "reports" }, - { name: "response_templates", controller: "response_templates" }, - { name: "sponsorships", controller: "sponsorships" }, - { name: "tags", controller: "tags" }, - { name: "tools", controller: "tools" }, - { name: "users", controller: "users" }, - { name: "vault secrets", controller: "secrets" }, - { name: "webhooks", controller: "webhook_endpoints" }, - { name: "welcome", controller: "welcome" }, - ].sort_by { |menu_item| menu_item[:name] } - - PROFILE_ADMIN = { name: "config: profile setup", controller: "profile_fields" }.freeze - - TECH_MENU_ITEMS = [ - { name: "data_update_scripts", controller: "data_update_scripts" }, - ].sort_by { |menu_item| menu_item[:name] } - - def admin_menu_items - return MENU_ITEMS unless FeatureFlag.enabled?(:profile_admin) - - MENU_ITEMS.dup.insert(7, PROFILE_ADMIN) - end - # @ridhwana end delete - def deduced_controller(request) request.path.split("/").fourth end diff --git a/app/views/admin/badges/index.html.erb b/app/views/admin/badges/index.html.erb index 3bc27de53..f99165aba 100644 --- a/app/views/admin/badges/index.html.erb +++ b/app/views/admin/badges/index.html.erb @@ -1,9 +1,4 @@
- - <% unless FeatureFlag.enabled?(:admin_restructure) %> -

Badges

- <% end %> -
<%= link_to "Create Badge", new_admin_badge_path, class: "btn btn-primary" %> <%= link_to "Award Badge", admin_badge_achievements_award_badges_path, style: "margin-left: 20px;", class: "btn btn-primary" %> diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 09bfff613..d0475d312 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -53,26 +53,15 @@
@@ -85,11 +74,8 @@
<% end %> - <% if FeatureFlag.enabled?(:admin_restructure) %> - - <% if request.path.split("/")[-3] == "admin" %> - <%= render "admin/shared/tabbed_navbar", menu_items: AdminMenu.nested_menu_items_from_request(request) %> - <% end %> + <% if request.path.split("/")[-3] == "admin" %> + <%= render "admin/shared/tabbed_navbar", menu_items: AdminMenu.nested_menu_items_from_request(request) %> <% end %> <%= yield %> diff --git a/config/routes.rb b/config/routes.rb index 72ae98234..6834c380b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -40,67 +40,7 @@ Rails.application.routes.draw do mount FieldTest::Engine, at: "abtests" end - namespace :admin do - get "/", to: "overview#index" - - # NOTE: [@ridhwana] These are the admin routes that have stayed the same even with the - # restructure. They'll move into routes/admin.rb once we remove the old code. - authenticate :user, ->(user) { user.tech_admin? } do - mount Blazer::Engine, at: "blazer" - - flipper_ui = Flipper::UI.app(Flipper, - { rack_protection: { except: %i[authenticity_token form_token json_csrf - remote_token http_origin session_hijacking] } }) - mount flipper_ui, at: "feature_flags" - end - resources :invitations, only: %i[index new create destroy] - resources :organization_memberships, only: %i[update destroy create] - resources :permissions, only: %i[index] - resources :reactions, only: [:update] - resources :consumer_apps, only: %i[index new create edit update destroy] - namespace :settings do - resources :authentications, only: [:create] - resources :campaigns, only: [:create] - resources :communities, only: [:create] - resources :mandatory_settings, only: [:create] - resources :mascots, only: [:create] - resources :rate_limits, only: [:create] - resources :user_experiences, only: [:create] - end - namespace :users do - resources :gdpr_delete_requests, only: %i[index destroy] - end - resources :users, only: %i[index show edit update destroy] do - resources :email_messages, only: :show - member do - post "banish" - post "export_data" - post "full_delete" - patch "user_status" - post "merge" - delete "remove_identity" - post "send_email" - post "verify_email_ownership" - patch "unlock_access" - end - end - - # These redirects serve as a safeguard to prevent 404s for any Admins - # who have the old badge_achievement URLs bookmarked. - get "/badges/badge_achievements", to: redirect("/admin/badge_achievements") - get "/badges/badge_achievements/award_badges", to: redirect("/admin/badge_achievements/award_badges") - - # NOTE: [@ridhwana] All these conditional statements are temporary conditions. - # We check that the database table exists to avoid the DB setup failing - # because the code relies on the presence of a table. - if Database.table_available?("flipper_features") - # NOTE: [@ridhwana] admin_routes will require the rails app to be reloaded when the feature flag is toggled - # You can find more details on why we had to implement it this way in this PR - # https://github.com/forem/forem/pull/13114 - admin_routes = FeatureFlag.enabled?(:admin_restructure) ? :admin : :current_admin - draw admin_routes - end - end + draw :admin namespace :stories, defaults: { format: "json" } do resource :feed, only: [:show] do diff --git a/config/routes/admin.rb b/config/routes/admin.rb index 156461b5c..f54c0defb 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -1,87 +1,133 @@ -scope :content_manager do - resources :articles, only: %i[index show update] - resources :badges, only: %i[index edit update new create] - resources :badge_achievements, only: %i[index destroy] - get "/badge_achievements/award_badges", to: "badge_achievements#award" - post "/badge_achievements/award_badges", to: "badge_achievements#award_badges" - resources :comments, only: [:index] - resources :organizations, only: %i[index show] do +# rubocop:disable Metrics/BlockLength +namespace :admin do + get "/", to: "overview#index" + + authenticate :user, ->(user) { user.tech_admin? } do + mount Blazer::Engine, at: "blazer" + + flipper_ui = Flipper::UI.app(Flipper, + { rack_protection: { except: %i[authenticity_token form_token json_csrf + remote_token http_origin session_hijacking] } }) + mount flipper_ui, at: "feature_flags" + end + resources :invitations, only: %i[index new create destroy] + resources :organization_memberships, only: %i[update destroy create] + resources :permissions, only: %i[index] + resources :reactions, only: [:update] + resources :consumer_apps, only: %i[index new create edit update destroy] + namespace :settings do + resources :authentications, only: [:create] + resources :campaigns, only: [:create] + resources :communities, only: [:create] + resources :mandatory_settings, only: [:create] + resources :mascots, only: [:create] + resources :rate_limits, only: [:create] + resources :user_experiences, only: [:create] + end + namespace :users do + resources :gdpr_delete_requests, only: %i[index destroy] + end + resources :users, only: %i[index show edit update destroy] do + resources :email_messages, only: :show member do - patch "update_org_credits" - end - end - resources :podcasts, only: %i[index edit update destroy] do - member do - post :fetch - post :add_owner - end - end - resources :tags, only: %i[index new create update edit] do - resource :moderator, only: %i[create destroy], module: "tags" - end -end - -scope :customization do - resource :config - resources :display_ads, only: %i[index edit update new create destroy] - resources :html_variants, only: %i[index edit update new create show destroy] - resources :navigation_links, only: %i[index update create destroy] - resources :pages, only: %i[index new create edit update destroy] - - # NOTE: @citizen428 The next two resources have a temporary constraint - # while profile generalization is still WIP - constraints(->(_request) { FeatureFlag.enabled?(:profile_admin) }) do - resources :profile_field_groups, only: %i[update create destroy] - resources :profile_fields, only: %i[index update create destroy] - end -end - -scope :moderation do - resources :feedback_messages, only: %i[index show] - resources :reports, only: %i[index show], controller: "feedback_messages" do - collection do + post "banish" + post "export_data" + post "full_delete" + patch "user_status" + post "merge" + delete "remove_identity" post "send_email" - post "create_note" - post "save_status" + post "verify_email_ownership" + patch "unlock_access" end end - resources :mods, only: %i[index update] - resources :moderator_actions, only: %i[index] - resources :privileged_reactions, only: %i[index] -end -scope :advanced do - resources :broadcasts - resources :response_templates, only: %i[index new edit create update destroy] - resources :secrets, only: %i[index] - put "secrets", to: "secrets#update" - resources :sponsorships, only: %i[index edit update new create destroy] - resources :tools, only: %i[index create] do - collection do - post "bust_cache" - end - end - resources :webhook_endpoints, only: :index - - # We do not expose the Data Update Scripts to all Forems by default. - constraints(->(_request) { FeatureFlag.enabled?(:data_update_scripts) }) do - resources :data_update_scripts, only: %i[index show] do + scope :content_manager do + resources :articles, only: %i[index show update] + resources :badges, only: %i[index edit update new create] + resources :badge_achievements, only: %i[index destroy] + get "/badge_achievements/award_badges", to: "badge_achievements#award" + post "/badge_achievements/award_badges", to: "badge_achievements#award_badges" + resources :comments, only: [:index] + resources :organizations, only: %i[index show] do member do - post :force_run + patch "update_org_credits" + end + end + resources :podcasts, only: %i[index edit update destroy] do + member do + post :fetch + post :add_owner + end + end + resources :tags, only: %i[index new create update edit] do + resource :moderator, only: %i[create destroy], module: "tags" + end + end + + scope :customization do + resource :config + resources :display_ads, only: %i[index edit update new create destroy] + resources :html_variants, only: %i[index edit update new create show destroy] + resources :navigation_links, only: %i[index update create destroy] + resources :pages, only: %i[index new create edit update destroy] + + # NOTE: @citizen428 The next two resources have a temporary constraint + # while profile generalization is still WIP + constraints(->(_request) { FeatureFlag.enabled?(:profile_admin) }) do + resources :profile_field_groups, only: %i[update create destroy] + resources :profile_fields, only: %i[index update create destroy] + end + end + + scope :moderation do + resources :feedback_messages, only: %i[index show] + resources :reports, only: %i[index show], controller: "feedback_messages" do + collection do + post "send_email" + post "create_note" + post "save_status" + end + end + resources :mods, only: %i[index update] + resources :moderator_actions, only: %i[index] + resources :privileged_reactions, only: %i[index] + end + + scope :advanced do + resources :broadcasts + resources :response_templates, only: %i[index new edit create update destroy] + resources :secrets, only: %i[index] + put "secrets", to: "secrets#update" + resources :sponsorships, only: %i[index edit update new create destroy] + resources :tools, only: %i[index create] do + collection do + post "bust_cache" + end + end + resources :webhook_endpoints, only: :index + + # We do not expose the Data Update Scripts to all Forems by default. + constraints(->(_request) { FeatureFlag.enabled?(:data_update_scripts) }) do + resources :data_update_scripts, only: %i[index show] do + member do + post :force_run + end end end end -end -scope :apps do - resources :chat_channels, only: %i[index create update destroy] do - member do - delete :remove_user + scope :apps do + resources :chat_channels, only: %i[index create update destroy] do + member do + delete :remove_user + end end + resources :events, only: %i[index create update new edit] + resources :listings, only: %i[index edit update destroy] + resources :listing_categories, only: %i[index edit update new create + destroy], path: "listings/categories" + resources :welcome, only: %i[index create] end - resources :events, only: %i[index create update new edit] - resources :listings, only: %i[index edit update destroy] - resources :listing_categories, only: %i[index edit update new create - destroy], path: "listings/categories" - resources :welcome, only: %i[index create] end +# rubocop:enable Metrics/BlockLength diff --git a/config/routes/current_admin.rb b/config/routes/current_admin.rb deleted file mode 100644 index f6ee854e5..000000000 --- a/config/routes/current_admin.rb +++ /dev/null @@ -1,78 +0,0 @@ -# NOTE: @ridhwana These routes below will be deleted once we remove the -# admin_restructure feature flag, hence they've been regrouped in this manner. -resources :articles, only: %i[index show update] -resources :badges, only: %i[index edit update new create] -resources :badge_achievements, only: %i[index destroy] -get "/badge_achievements/award_badges", to: "badge_achievements#award" -post "/badge_achievements/award_badges", to: "badge_achievements#award_badges" -resources :broadcasts -resources :chat_channels, only: %i[index create update destroy] do - member do - delete :remove_user - end -end -resources :comments, only: [:index] -resource :config -resources :display_ads, only: %i[index edit update new create destroy] -resources :events, only: %i[index create update new edit] -resources :feedback_messages, only: %i[index show] -resources :html_variants, only: %i[index edit update new create show destroy] -resources :listings, only: %i[index edit update destroy] -resources :listing_categories, only: %i[index edit update new create - destroy], path: "listings/categories" -resources :navigation_links, only: %i[index update create destroy] -resources :organizations, only: %i[index show] do - member do - patch "update_org_credits" - end -end -resources :pages, only: %i[index new create edit update destroy] -resources :podcasts, only: %i[index edit update destroy] do - member do - post :fetch - post :add_owner - end -end -resources :mods, only: %i[index update] -resources :moderator_actions, only: %i[index] -resources :navigation_links, only: %i[index update create destroy] -resources :privileged_reactions, only: %i[index] -resources :reports, only: %i[index show], controller: "feedback_messages" do - collection do - post "send_email" - post "create_note" - post "save_status" - end -end -resources :response_templates, only: %i[index new edit create update destroy] -resources :secrets, only: %i[index] -put "secrets", to: "secrets#update" -resources :sponsorships, only: %i[index edit update new create destroy] - -resources :tags, only: %i[index new create update edit] do - resource :moderator, only: %i[create destroy], module: "tags" -end -resources :tools, only: %i[index create] do - collection do - post "bust_cache" - end -end -resources :webhook_endpoints, only: :index -resources :welcome, only: %i[index create] - -# We do not expose the Data Update Scripts to all Forems by default. -constraints(->(_request) { FeatureFlag.enabled?(:data_update_scripts) }) do - resources :data_update_scripts, only: %i[index show] do - member do - post :force_run - end - end -end - -# NOTE: @citizen428 The next two resources have a temporary constraint -# while profile generalization is still WIP -constraints(->(_request) { FeatureFlag.enabled?(:profile_admin) }) do - resources :profile_field_groups, only: %i[update create destroy] - resources :profile_fields, only: %i[index update create destroy] -end -# @ridhwana end of routes that will be deleted once we remove the admin_restructure feature flag diff --git a/cypress/integration/adminFlows/config/authenticationSection.spec.js b/cypress/integration/adminFlows/config/authenticationSection.spec.js index 3bd53c617..d4738021a 100644 --- a/cypress/integration/adminFlows/config/authenticationSection.spec.js +++ b/cypress/integration/adminFlows/config/authenticationSection.spec.js @@ -20,7 +20,7 @@ describe('Authentication Section', () => { facebookKey: 'somekey', facebookSecret: 'somesecret', }).then(() => { - cy.visit('/admin/config'); + cy.visit('/admin/customization/config'); cy.findByTestId('authSectionForm').as('authSectionForm'); cy.get('@authSectionForm').findByText('Authentication').click(); @@ -38,7 +38,7 @@ describe('Authentication Section', () => { .findByText('Update Site Configuration') .click(); - cy.url().should('contains', '/admin/config'); + cy.url().should('contains', '/admin/customization/config'); // Page reloaded so need to get a new reference to the form. cy.findByTestId('authSectionForm').as('authSectionForm'); @@ -76,7 +76,7 @@ describe('Authentication Section', () => { it('should display warning modal if provider keys are missing', () => { cy.fixture('users/adminUser.json').as('user'); cy.get('@user').then(() => { - cy.visit('/admin/config'); + cy.visit('/admin/customization/config'); cy.findByTestId('authSectionForm').as('authSectionForm'); cy.get('@authSectionForm').findByText('Authentication').click(); @@ -102,7 +102,7 @@ describe('Authentication Section', () => { cy.fixture('users/adminUser.json').as('user'); cy.get('@user').then(() => { - cy.visit('/admin/config'); + cy.visit('/admin/customization/config'); cy.findByTestId('authSectionForm').as('authSectionForm'); cy.get('@authSectionForm').findByText('Authentication').click(); @@ -120,7 +120,7 @@ describe('Authentication Section', () => { .findByText('Update Site Configuration') .click(); - cy.url().should('contains', '/admin/config'); + cy.url().should('contains', '/admin/customization/config'); cy.findByText('Site configuration was successfully updated.').should( 'be.visible', diff --git a/cypress/integration/adminFlows/config/campaignSection.spec.js b/cypress/integration/adminFlows/config/campaignSection.spec.js index ca58ea704..4ba4cbda7 100644 --- a/cypress/integration/adminFlows/config/campaignSection.spec.js +++ b/cypress/integration/adminFlows/config/campaignSection.spec.js @@ -11,7 +11,7 @@ describe('Campaign Section', () => { describe('sidebar image setting', () => { it('rejects an invalid image URL', () => { cy.get('@user').then(({ username }) => { - cy.visit('/admin/config'); + cy.visit('/admin/customization/config'); cy.get('#new_settings_campaign').as('campaignSectionForm'); cy.get('@campaignSectionForm').findByText('Campaign').click(); @@ -29,7 +29,7 @@ describe('Campaign Section', () => { .findByText('Update Site Configuration') .click(); - cy.url().should('contains', '/admin/config'); + cy.url().should('contains', '/admin/customization/config'); cy.findByText( '😭 Validation failed: Sidebar image is not a valid URL', @@ -39,7 +39,7 @@ describe('Campaign Section', () => { it('accepts a valid image URL', () => { cy.get('@user').then(({ username }) => { - cy.visit('/admin/config'); + cy.visit('/admin/customization/config'); cy.get('#new_settings_campaign').as('campaignSectionForm'); cy.get('@campaignSectionForm').findByText('Campaign').click(); @@ -57,7 +57,7 @@ describe('Campaign Section', () => { .findByText('Update Site Configuration') .click(); - cy.url().should('contains', '/admin/config'); + cy.url().should('contains', '/admin/customization/config'); cy.findByText('Site configuration was successfully updated.').should( 'be.visible', diff --git a/cypress/integration/adminFlows/config/communitySection.spec.js b/cypress/integration/adminFlows/config/communitySection.spec.js index 55d8e57f6..281512a96 100644 --- a/cypress/integration/adminFlows/config/communitySection.spec.js +++ b/cypress/integration/adminFlows/config/communitySection.spec.js @@ -11,7 +11,7 @@ describe('Community Content Section', () => { describe('community emoji setting', () => { it('rejects invalid input (no emoji)', () => { cy.get('@user').then(({ username }) => { - cy.visit('/admin/config'); + cy.visit('/admin/customization/config'); cy.get('#new_settings_community').as('communitySectionForm'); cy.get('@communitySectionForm').findByText('Community Content').click(); @@ -30,7 +30,7 @@ describe('Community Content Section', () => { .findByText('Update Site Configuration') .click(); - cy.url().should('contains', '/admin/config'); + cy.url().should('contains', '/admin/customization/config'); cy.findByText( '😭 Validation failed: Community emoji contains non-emoji characters or invalid emoji', @@ -40,7 +40,7 @@ describe('Community Content Section', () => { it('accepts a valid emoji', () => { cy.get('@user').then(({ username }) => { - cy.visit('/admin/config'); + cy.visit('/admin/customization/config'); cy.get('#new_settings_community').as('communitySectionForm'); cy.get('@communitySectionForm').findByText('Community Content').click(); @@ -59,7 +59,7 @@ describe('Community Content Section', () => { .findByText('Update Site Configuration') .click(); - cy.url().should('contains', '/admin/config'); + cy.url().should('contains', '/admin/customization/config'); cy.findByText('Site configuration was successfully updated.').should( 'be.visible', diff --git a/cypress/integration/adminFlows/config/emailDigestFrequencySection.js b/cypress/integration/adminFlows/config/emailDigestFrequencySection.js index 278db7f83..cda69f573 100644 --- a/cypress/integration/adminFlows/config/emailDigestFrequencySection.js +++ b/cypress/integration/adminFlows/config/emailDigestFrequencySection.js @@ -11,7 +11,7 @@ describe('Email digest frequency Section', () => { describe('email digest frequency settings', () => { it('can change the frequency', () => { cy.get('@user').then(({ username }) => { - cy.visit('/admin/config'); + cy.visit('/admin/customization/config'); cy.findByTestId('emailDigestSectionForm').as('emailDigestSectionForm'); cy.get('@emailDigestSectionForm') @@ -33,7 +33,7 @@ describe('Email digest frequency Section', () => { .findByText('Update Site Configuration') .click(); - cy.url().should('contains', '/admin/config'); + cy.url().should('contains', '/admin/customization/config'); cy.findByText('Site configuration was successfully updated.').should( 'be.visible', diff --git a/cypress/integration/adminFlows/config/getStartedSection.js b/cypress/integration/adminFlows/config/getStartedSection.js index 1040a1391..c001f4f85 100644 --- a/cypress/integration/adminFlows/config/getStartedSection.js +++ b/cypress/integration/adminFlows/config/getStartedSection.js @@ -11,7 +11,7 @@ describe('Get Started Section', () => { describe('Community name setting', () => { it('updates the community name', () => { cy.get('@user').then(({ username }) => { - cy.visit('/admin/config'); + cy.visit('/admin/customization/config'); cy.findByTestId('getStartedSectionForm').as('getStartedSectionForm'); @@ -30,7 +30,7 @@ describe('Get Started Section', () => { .findByText('Update Site Configuration') .click(); - cy.url().should('contains', '/admin/config'); + cy.url().should('contains', '/admin/customization/config'); cy.findByText('Site configuration was successfully updated.').should( 'be.visible', @@ -44,7 +44,7 @@ describe('Get Started Section', () => { it('updates the suggested tags', () => { cy.get('@user').then(({ username }) => { - cy.visit('/admin/config'); + cy.visit('/admin/customization/config'); cy.findByTestId('getStartedSectionForm').as('getStartedSectionForm'); @@ -63,7 +63,7 @@ describe('Get Started Section', () => { .findByText('Update Site Configuration') .click(); - cy.url().should('contains', '/admin/config'); + cy.url().should('contains', '/admin/customization/config'); cy.findByText('Site configuration was successfully updated.').should( 'be.visible', diff --git a/cypress/integration/adminFlows/config/mascotSection.js b/cypress/integration/adminFlows/config/mascotSection.js index 93ee21b3e..214fd2f6a 100644 --- a/cypress/integration/adminFlows/config/mascotSection.js +++ b/cypress/integration/adminFlows/config/mascotSection.js @@ -11,7 +11,7 @@ describe('Mascot Section', () => { describe('mascot image setting', () => { it('rejects an invalid image URL', () => { cy.get('@user').then(({ username }) => { - cy.visit('/admin/config'); + cy.visit('/admin/customization/config'); cy.findByTestId('mascotSectionForm').as('mascotSectionForm'); cy.get('@mascotSectionForm').findByText('Mascot').click(); @@ -30,7 +30,7 @@ describe('Mascot Section', () => { .findByText('Update Site Configuration') .click(); - cy.url().should('contains', '/admin/config'); + cy.url().should('contains', '/admin/customization/config'); cy.findByText( '😭 Validation failed: Image url is not a valid URL', @@ -40,7 +40,7 @@ describe('Mascot Section', () => { it('accepts a valid image URL', () => { cy.get('@user').then(({ username }) => { - cy.visit('/admin/config'); + cy.visit('/admin/customization/config'); cy.findByTestId('mascotSectionForm').as('mascotSectionForm'); cy.get('@mascotSectionForm').findByText('Mascot').click(); @@ -59,7 +59,7 @@ describe('Mascot Section', () => { .findByText('Update Site Configuration') .click(); - cy.url().should('contains', '/admin/config'); + cy.url().should('contains', '/admin/customization/config'); cy.findByText('Site configuration was successfully updated.').should( 'be.visible', diff --git a/cypress/integration/adminFlows/config/rateLimitSection.js b/cypress/integration/adminFlows/config/rateLimitSection.js index f4a3973e6..91f0af6b8 100644 --- a/cypress/integration/adminFlows/config/rateLimitSection.js +++ b/cypress/integration/adminFlows/config/rateLimitSection.js @@ -11,7 +11,7 @@ describe('Campaign Section', () => { describe('rate limit settings', () => { it('can change for how many days a user is considered new', () => { cy.get('@user').then(({ username }) => { - cy.visit('/admin/config'); + cy.visit('/admin/customization/config'); cy.get('#new_settings_rate_limit').as('rateLimitSectionForm'); cy.get('@rateLimitSectionForm') @@ -33,7 +33,7 @@ describe('Campaign Section', () => { .findByText('Update Site Configuration') .click(); - cy.url().should('contains', '/admin/config'); + cy.url().should('contains', '/admin/customization/config'); cy.findByText('Site configuration was successfully updated.').should( 'be.visible', diff --git a/cypress/integration/adminFlows/config/userExperienceSection.js b/cypress/integration/adminFlows/config/userExperienceSection.js index 00ed11d9b..5b5f32b15 100644 --- a/cypress/integration/adminFlows/config/userExperienceSection.js +++ b/cypress/integration/adminFlows/config/userExperienceSection.js @@ -11,7 +11,7 @@ describe('User experience Section', () => { describe('default font', () => { it('can change the default font', () => { cy.get('@user').then(({ username }) => { - cy.visit('/admin/config'); + cy.visit('/admin/customization/config'); cy.get('#new_settings_user_experience').as('userExperienceSectionForm'); cy.get('@userExperienceSectionForm') @@ -32,7 +32,7 @@ describe('User experience Section', () => { .findByText('Update Site Configuration') .click(); - cy.url().should('contains', '/admin/config'); + cy.url().should('contains', '/admin/customization/config'); cy.findByText('Site configuration was successfully updated.').should( 'be.visible', diff --git a/cypress/integration/adminFlows/navigationLinks/navigationLinks.spec.js b/cypress/integration/adminFlows/navigationLinks/navigationLinks.spec.js index 7028c29b7..359d6a213 100644 --- a/cypress/integration/adminFlows/navigationLinks/navigationLinks.spec.js +++ b/cypress/integration/adminFlows/navigationLinks/navigationLinks.spec.js @@ -5,7 +5,7 @@ describe('Navigation links', () => { cy.get('@user').then((user) => { cy.loginUser(user).then(() => { - cy.visit('/admin/navigation_links'); + cy.visit('/admin/customization/navigation_links'); }); }); }); diff --git a/spec/requests/admin/nested_sidebar_spec.rb b/spec/requests/admin/nested_sidebar_spec.rb index 7798a0802..0dc263a43 100644 --- a/spec/requests/admin/nested_sidebar_spec.rb +++ b/spec/requests/admin/nested_sidebar_spec.rb @@ -1,6 +1,5 @@ require "rails_helper" -# @ridhwana: rename to sidebar_spec once we can delete the old spec RSpec.describe "admin sidebar", type: :request do let(:super_admin) { create(:user, :super_admin) } @@ -9,28 +8,8 @@ RSpec.describe "admin sidebar", type: :request do allow(FeatureFlag).to receive(:enabled?).and_call_original end - describe "admin_restructure feature flag" do - it "shows the correct options in the sidebar when the feature flag is enabled" do - allow(FeatureFlag).to receive(:enabled?).with(:admin_restructure).and_return(true) - - get admin_articles_path - - expect(response.body).to include("Content Manager") - end - - it "does not show the option in the sidebar when the feature flag is disabled" do - allow(FeatureFlag).to receive(:enabled?).with(:admin_restructure).and_return(false) - - get admin_articles_path - - expect(response.body).not_to include("Content Manager") - end - end - describe "sidebar menu options" do it "shows parent level and nested child items" do - allow(FeatureFlag).to receive(:enabled?).with(:admin_restructure).and_return(true) - get admin_articles_path expect(response.body).to include("Advanced") @@ -39,11 +18,7 @@ RSpec.describe "admin sidebar", type: :request do end describe "tabbed menu options" do - # NOTE: [@ridhwana] to enable this test again once the - # the feature flag is removed - xit "shows nested grandchildren items where applicable" do - allow(FeatureFlag).to receive(:enabled?).with(:admin_restructure).and_return(true) - + it "shows nested grandchildren items where applicable" do get admin_badges_path expect(response.body).to include("Library") @@ -52,10 +27,6 @@ RSpec.describe "admin sidebar", type: :request do end describe "profile admin feature flag" do - before do - allow(FeatureFlag).to receive(:enabled?).with(:admin_restructure).and_return(true) - end - it "does not show the option in the sidebar when the feature flag is disabled" do allow(FeatureFlag).to receive(:enabled?).with(:profile_admin).and_return(false) @@ -74,11 +45,7 @@ RSpec.describe "admin sidebar", type: :request do end describe "data update script admin feature flag" do - before do - allow(FeatureFlag).to receive(:enabled?).with(:admin_restructure).and_return(true) - end - - it "does not show the option in the tabbed header when the feature flag is disabled" do + xit "does not show the option in the tabbed header when the feature flag is disabled" do allow(FeatureFlag).to receive(:enabled?).with(:data_update_scripts).and_return(false) get admin_tools_path @@ -86,9 +53,7 @@ RSpec.describe "admin sidebar", type: :request do expect(response.body).not_to include("Data Update Scripts") end - # NOTE: [@ridhwana] to enable this test again once the - # the feature flag is removed - xit "shows the option in the tabbed header when the feature flag is enabled" do + it "shows the option in the tabbed header when the feature flag is enabled" do allow(FeatureFlag).to receive(:enabled?).with(:data_update_scripts).and_return(true) get admin_tools_path diff --git a/spec/requests/admin/overview_spec.rb b/spec/requests/admin/overview_spec.rb index 1da31093d..ab441dc28 100644 --- a/spec/requests/admin/overview_spec.rb +++ b/spec/requests/admin/overview_spec.rb @@ -8,24 +8,6 @@ RSpec.describe "/admin", type: :request do allow(FeatureFlag).to receive(:enabled?).and_call_original end - describe "profile admin feature flag" do - it "shows the option when the feature flag is enabled" do - allow(FeatureFlag).to receive(:enabled?).with(:profile_admin).and_return(true) - - get admin_path - - expect(response.body).to include("Config: Profile Setup") - end - - it "does not show the option when the feature flag is disabled" do - allow(FeatureFlag).to receive(:enabled?).with(:profile_admin).and_return(false) - - get admin_path - - expect(response.body).not_to include("Config: Profile Setup") - end - end - describe "Last deployed and Lastest Commit ID card" do before do ForemInstance.instance_variable_set(:@deployed_at, nil) @@ -43,24 +25,4 @@ RSpec.describe "/admin", type: :request do expect(response.body).to include(ENV["HEROKU_RELEASE_CREATED_AT"]) end end - - describe "data update scripts admin feature flag" do - it "shows the option when the feature flag is enabled" do - allow(FeatureFlag).to receive(:enabled?).with(:data_update_scripts).and_return(true) - - get admin_path - - expect(response.body).to include("Tech Resources") - expect(response.body).to include("Data Update Scripts") - end - - it "does not show the option when the feature flag is disabled" do - allow(FeatureFlag).to receive(:enabled?).with(:data_update_scripts).and_return(false) - - get admin_path - - expect(response.body).not_to include("Tech Resources") - expect(response.body).not_to include("Data Update Scripts") - end - end end diff --git a/spec/requests/admin/sidebar_spec.rb b/spec/requests/admin/sidebar_spec.rb deleted file mode 100644 index 0cd629556..000000000 --- a/spec/requests/admin/sidebar_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -require "rails_helper" - -RSpec.describe "admin sidebar", type: :request do - let(:super_admin) { create(:user, :super_admin) } - - before do - sign_in super_admin - allow(FeatureFlag).to receive(:enabled?).and_call_original - end - - describe "profile admin feature flag" do - it "shows the option in the sidebar when the feature flag is enabled" do - allow(FeatureFlag).to receive(:enabled?).with(:profile_admin).and_return(true) - - get admin_articles_path - - expect(response.body).to include("Config: Profile Setup") - end - - it "does not show the option in the sidebar when the feature flag is disabled" do - allow(FeatureFlag).to receive(:enabled?).with(:profile_admin).and_return(false) - - get admin_articles_path - - expect(response.body).not_to include("Config: Profile Setup") - end - end - - describe "data update script admin feature flag" do - it "shows the option in the sidebar when the feature flag is enabled" do - allow(FeatureFlag).to receive(:enabled?).with(:data_update_scripts).and_return(true) - - get admin_articles_path - - expect(response.body).to include("Tech Resources") - expect(response.body).to include("Data Update Scripts") - end - - it "does not show the option in the sidebar when the feature flag is disabled" do - allow(FeatureFlag).to receive(:enabled?).with(:data_update_scripts).and_return(false) - - get admin_articles_path - - expect(response.body).not_to include("Data Update Scripts") - end - end -end