Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

THREESCALE-8979: Fix the issue with not being able to remove default plan #3131

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions app/javascript/src/Common/components/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ const Select = <T extends IRecord>({
label={label}
>
{isLoading && <Spinner className="pf-u-ml-md" size="md" />}
{/* TODO: id should be treated as a string */}
{/* TODO: should it be `value={item.id > -1 ? item.id : ''}`? */}
{item && <input name={name} type="hidden" value={item.id} />}
{/* Controllers expect an empty string for some operations (such as unsetting the default plan) */}
{item && <input name={name} type="hidden" value={item.id >= 0 ? item.id : ''} />}
<PF4Select
aria-label={ariaLabel}
className={isClearable ? '' : 'pf-m-select__toggle-clear-hidden'}
Expand Down
5 changes: 5 additions & 0 deletions features/api/application_plans.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Feature: Application plans index page
When an admin selects an application plan as default
Then any new application will use this plan

Scenario: Unset the default application plan
Given the service has a default application plan
When an admin unsets the default application plan
Then the service will not have the default plan set

Scenario: Hidden plans can be default
When an admin selects a hidden application plan as default
Then any new application will use this plan
Expand Down
18 changes: 18 additions & 0 deletions features/step_definitions/api/application_plans_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@
assert_equal @plan, default_service.reload.default_application_plan
end

When "the service has a default application plan" do
@service = default_service
plan = FactoryBot.create(:application_plan, issuer: @service)
@service.update!(default_application_plan: plan)
end

When "an admin unsets the default application plan" do
visit admin_service_application_plans_path(@service)
select_default_plan_by_name "No plan selected"
mayorova marked this conversation as resolved.
Show resolved Hide resolved
assert_flash 'The default plan has been changed.'
end

Then "the service will not have the default plan set" do
visit admin_service_application_plans_path(@service)
assert_equal('No plan selected', find('#default_plan_card .pf-c-select input').value)
assert_nil @service.reload.default_application_plan_id
end

Then "any new application will use this plan" do
FactoryBot.create(:buyer_account, provider_account: @provider)

Expand Down
14 changes: 9 additions & 5 deletions features/step_definitions/plans_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,15 @@ def default_service
end

def select_default_plan(plan)
select = find(:css, '#default_plan_card .pf-c-select')
select.find(:css, '.pf-c-button.pf-c-select__toggle-button').click unless select[:class].include?('pf-m-expanded')
select.find('.pf-c-select__menu-item', text: plan.name).click
button = find(:css, '#default_plan_card .pf-c-button[type="submit"]')
button.click(wait: 5)
select_default_plan_by_name(plan.name)
end

def select_default_plan_by_name(name)
within('#default_plan_card .pf-c-select') do
find('.pf-c-button.pf-c-select__toggle-button').click unless current_scope[:class].include?('pf-m-expanded')
find('.pf-c-select__menu-item', text: name).click
end
find('#default_plan_card .pf-c-button[type="submit"]').click(wait: 5)
end

def delete_plan_from_table_action(plan)
Expand Down