2020-09-03 17:08:18 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module FeatureFlagHelpers
|
2021-06-15 08:10:11 -04:00
|
|
|
def create_flag(project, name, active = true, description: nil, version: Operations::FeatureFlag.versions['new_version_flag'])
|
2020-09-03 17:08:18 -04:00
|
|
|
create(:operations_feature_flag, name: name, active: active, version: version,
|
|
|
|
description: description, project: project)
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_scope(feature_flag, environment_scope, active = true, strategies = [{ name: "default", parameters: {} }])
|
|
|
|
create(:operations_feature_flag_scope,
|
|
|
|
feature_flag: feature_flag,
|
|
|
|
environment_scope: environment_scope,
|
|
|
|
active: active,
|
|
|
|
strategies: strategies)
|
|
|
|
end
|
|
|
|
|
2021-06-22 02:07:26 -04:00
|
|
|
def create_strategy(feature_flag, name = 'default', parameters = {})
|
|
|
|
create(:operations_strategy,
|
|
|
|
feature_flag: feature_flag,
|
|
|
|
name: name)
|
|
|
|
end
|
|
|
|
|
2020-09-03 17:08:18 -04:00
|
|
|
def within_feature_flag_row(index)
|
|
|
|
within ".gl-responsive-table-row:nth-child(#{index + 1})" do
|
|
|
|
yield
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def within_feature_flag_scopes
|
|
|
|
within '.js-feature-flag-environments' do
|
|
|
|
yield
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def within_scope_row(index)
|
|
|
|
within ".gl-responsive-table-row:nth-child(#{index + 1})" do
|
|
|
|
yield
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def within_strategy_row(index)
|
|
|
|
within ".feature-flags-form > fieldset > div[data-testid='feature-flag-strategies'] > div:nth-child(#{index})" do
|
|
|
|
yield
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def within_environment_spec
|
|
|
|
within '.table-section:nth-child(1)' do
|
|
|
|
yield
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def within_status
|
|
|
|
within '.table-section:nth-child(2)' do
|
|
|
|
yield
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def within_delete
|
|
|
|
within '.table-section:nth-child(4)' do
|
|
|
|
yield
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit_feature_flag_button
|
|
|
|
find('.js-feature-flag-edit-button')
|
|
|
|
end
|
|
|
|
|
|
|
|
def delete_strategy_button
|
|
|
|
find("button[data-testid='delete-strategy-button']")
|
|
|
|
end
|
|
|
|
|
|
|
|
def add_linked_issue_button
|
|
|
|
find('.js-issue-count-badge-add-button')
|
|
|
|
end
|
|
|
|
|
|
|
|
def remove_linked_issue_button
|
|
|
|
find('.js-issue-item-remove-button')
|
|
|
|
end
|
|
|
|
|
|
|
|
def status_toggle_button
|
|
|
|
find('[data-testid="feature-flag-status-toggle"] button')
|
|
|
|
end
|
|
|
|
|
|
|
|
def expect_status_toggle_button_to_be_checked
|
|
|
|
expect(page).to have_css('[data-testid="feature-flag-status-toggle"] button.is-checked')
|
|
|
|
end
|
|
|
|
|
|
|
|
def expect_status_toggle_button_not_to_be_checked
|
|
|
|
expect(page).to have_css('[data-testid="feature-flag-status-toggle"] button:not(.is-checked)')
|
|
|
|
end
|
|
|
|
|
|
|
|
def expect_status_toggle_button_to_be_disabled
|
|
|
|
expect(page).to have_css('[data-testid="feature-flag-status-toggle"] button.is-disabled')
|
|
|
|
end
|
|
|
|
|
|
|
|
def expect_user_to_see_feature_flags_index_page
|
|
|
|
expect(page).to have_text('Feature Flags')
|
|
|
|
end
|
|
|
|
end
|