-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Optional Environment Banner (#212)
Currently, if an organization uses Test Track for multiple environments (e.g. production and stage), it can be a bit difficult to discern at first glance for which environment a user is managing a given split test. This proposed change gives users the option to set a `DEPLOYMENT_ENV_LABEL` variable in the `.env` or `.env.local` file, which will subsequently be rendered in a bright red banner, like so: ![Screenshot 2024-03-20 at 5 23 52 PM](https://github.com/Betterment/test_track/assets/67171899/f273fb03-dd86-433d-bd7b-77268bf27ae5) The banner is intentionally a tad obnoxious to make it glaringly obvious to the user which environment they are in. When no `DEPLOYMENT_ENV_LABEL` variable is set, the header renders as usual: ![Screenshot 2024-03-20 at 5 23 24 PM](https://github.com/Betterment/test_track/assets/67171899/fc01c995-b5d0-40ac-ac97-1421a725c449) I envision organizations using the existing state for production and the banner state for a non-production environment (or perhaps vice-versa).
- Loading branch information
Showing
6 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.banner { | ||
background-color: #ff6759; | ||
height: 22px; | ||
width: 100%; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.banner-text { | ||
color: white; | ||
font-size: 13px; | ||
text-transform: uppercase; | ||
font-weight: 500; | ||
margin-bottom: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Admin::SplitsController do | ||
include Warden::Test::Helpers | ||
|
||
describe 'GET /admin' do | ||
let(:admin) { FactoryBot.create(:admin) } | ||
let(:deployment_env_label) { 'Stage Environment' } | ||
let(:banner_tag) { "<p class=\"banner-text\">" } | ||
|
||
before do | ||
login_as admin | ||
end | ||
|
||
context 'when no DEPLOYMENT_ENV_LABEL is set' do | ||
it 'renders without environment label banner' do | ||
get '/admin' | ||
|
||
expect(response).to have_http_status :ok | ||
|
||
expect(response.body).not_to include(banner_tag) | ||
expect(response.body).not_to include(deployment_env_label) | ||
end | ||
end | ||
|
||
context 'when DEPLOYMENT_ENV_LABEL is set' do | ||
around do |example| | ||
with_env DEPLOYMENT_ENV_LABEL: deployment_env_label do | ||
example.run | ||
end | ||
end | ||
|
||
it 'renders with environment label banner' do | ||
get '/admin' | ||
|
||
expect(response).to have_http_status :ok | ||
|
||
expect(response.body).to include(banner_tag) | ||
expect(response.body).to include(deployment_env_label) | ||
end | ||
end | ||
end | ||
end |