RFC 50 - Remove old admin routes and related code (#13579)

* chore: remove current_admin routes file

* feat: move all the admin routes into the admin file

* chore: remove conditionals for the sidebar and tabbed navbar

* remove some more notes where we use the admin_restructure feature flag

* chore: amend the tests now that the old routes and the admin_restructure flag are removed

* chore: remove more references to the  admin_restructure flag

* chore: fix the tests

* chore: remove sidebar_spec

* chore: add slash back

* chore: comment it out for now whilst I try and figure out why its not passing
This commit is contained in:
Ridhwana 2021-05-03 16:03:38 +02:00 committed by GitHub
parent fb29a9cf54
commit ba5c97de50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 155 additions and 436 deletions

View file

@ -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

View file

@ -1,9 +1,4 @@
<header class="flex mb-6">
<!-- @ridhwana: temporary duplicate header removed. Will remove this with old navigation code -->
<% unless FeatureFlag.enabled?(:admin_restructure) %>
<h2 class="crayons-title">Badges</h2>
<% end %>
<div class="ml-auto">
<%= 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" %>

View file

@ -53,26 +53,15 @@
<div class="crayons-layout crayons-layout--2-cols">
<div class="admin__left-sidebar crayons-layout__left-sidebar" data-controller="sidebar" data-action="load@window->sidebar#disableCurrentNavItem">
<nav class="hidden m:block">
<% if FeatureFlag.enabled?(:admin_restructure) %>
<ul>
<li>
<a class="crayons-link crayons-link--block <%= "crayons-link--current" if controller.controller_name == "overview" %>" href="<%= admin_path %>" aria-current"<%= "page" if controller.controller_name == "overview" %>">
<a class="crayons-link crayons-link--block <%= "crayons-link--current" if controller.controller_name == "overview" %>" href="<%= admin_path %>" aria-current "<%= "page" if controller.controller_name == "overview" %>">
<%= inline_svg_tag("stack-line.svg", aria: true, class: "dropdown-icon crayons-icon") %>
Overview
</a>
</li>
<%= render "admin/shared/nested_sidebar", menu_items: AdminMenu.navigation_items %>
</ul>
<% else %>
<a class="crayons-link crayons-link--block <%= "crayons-link--current" if controller.controller_name == "overview" %>" href="<%= admin_path %>">
Overview
</a>
<%= render "admin/shared/navbar", menu_items: admin_menu_items %>
<% if FeatureFlag.enabled?(:data_update_scripts) %>
<p class="crayons-field__description mt-4 mb-3">Tech Resources</p>
<%= render "admin/shared/navbar", menu_items: AdminHelper::TECH_MENU_ITEMS %>
<% end %>
<% end %>
</nav>
</div>
<main class="crayons-layout__content min-w-0">
@ -85,11 +74,8 @@
</div>
<% end %>
<% if FeatureFlag.enabled?(:admin_restructure) %>
<!-- hack to ensure that when you go to the old admin view nothing breaks -->
<% 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 %>

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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',

View file

@ -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',

View file

@ -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',

View file

@ -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',

View file

@ -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',

View file

@ -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',

View file

@ -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',

View file

@ -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',

View file

@ -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');
});
});
});

View file

@ -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

View file

@ -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

View file

@ -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