Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
766c2819
Commit
766c2819
authored
Jul 13, 2021
by
Vitaly Slobodin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add feature test for extending/reactivating trial
parent
3f3ff664
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
139 additions
and
0 deletions
+139
-0
ee/spec/features/billings/extend_reactivate_trial_spec.rb
ee/spec/features/billings/extend_reactivate_trial_spec.rb
+139
-0
No files found.
ee/spec/features/billings/extend_reactivate_trial_spec.rb
0 → 100644
View file @
766c2819
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'Billings > Extend / Reactivate Trial'
,
:js
do
include
SubscriptionPortalHelpers
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:plan
)
{
create
(
:free_plan
)
}
let_it_be
(
:plans_data
)
do
Gitlab
::
Json
.
parse
(
File
.
read
(
Rails
.
root
.
join
(
'ee/spec/fixtures/gitlab_com_plans.json'
))).
map
do
|
data
|
data
.
deep_symbolize_keys
end
end
before
do
group
.
add_owner
(
user
)
stub_ee_application_setting
(
should_check_namespace_plan:
true
)
stub_full_request
(
"
#{
EE
::
SUBSCRIPTIONS_URL
}
/gitlab_plans?plan=
#{
plan
.
name
}
&namespace_id=
#{
group
.
id
}
"
)
.
to_return
(
status:
200
,
body:
plans_data
.
to_json
)
stub_full_request
(
"
#{
EE
::
SUBSCRIPTIONS_URL
}
/trials/extend_reactivate_trial"
,
method: :put
)
.
to_return
(
status:
200
)
sign_in
(
user
)
stub_feature_flags
(
allow_extend_reactivate_trial:
true
)
end
shared_examples
'a non-reactivatable trial'
do
before
do
visit
group_billings_path
(
group
)
end
it
'does not display the "Reactivate trial" button'
do
expect
(
page
).
not_to
have_button
(
'Reactivate trial'
)
end
end
shared_examples
'a non-extendable trial'
do
before
do
visit
group_billings_path
(
group
)
end
it
'does not display the "Extend trial" button'
do
expect
(
page
).
not_to
have_button
(
'Extend trial'
)
end
end
shared_examples
'a reactivatable trial'
do
before
do
visit
group_billings_path
(
group
)
end
it
'reactivates trial'
do
click_button
(
'Reactivate trial'
)
within
'[data-testid="extend-reactivate-trial-modal"]'
do
click_button
(
'Reactivate trial'
)
end
expect
(
page
).
to
have_content
(
'Your trial has been reactivated'
)
expect
(
page
).
not_to
have_button
(
'Reactivate trial'
)
end
end
shared_examples
'an extendable trial'
do
before
do
visit
group_billings_path
(
group
)
end
it
'extends the trial'
do
click_button
(
'Extend trial'
)
within
'[data-testid="extend-reactivate-trial-modal"]'
do
click_button
(
'Extend trial'
)
end
expect
(
page
).
to
have_content
(
'Your trial has been extended'
)
expect
(
page
).
not_to
have_button
(
'Extend trial'
)
end
end
context
'with paid subscription'
do
context
'when expired'
do
let_it_be
(
:subscription
)
{
create
(
:gitlab_subscription
,
:expired
,
hosted_plan:
plan
,
namespace:
group
)
}
it_behaves_like
'a non-reactivatable trial'
it_behaves_like
'a non-extendable trial'
context
'when the feature flag is disabled'
do
before
do
stub_feature_flags
(
allow_extend_reactivate_trial:
false
)
end
it_behaves_like
'a non-reactivatable trial'
it_behaves_like
'a non-extendable trial'
end
end
context
'when not expired'
do
let_it_be
(
:subscription
)
{
create
(
:gitlab_subscription
,
hosted_plan:
plan
,
namespace:
group
)
}
it_behaves_like
'a non-reactivatable trial'
it_behaves_like
'a non-extendable trial'
end
end
context
'without a subscription'
do
it_behaves_like
'a non-reactivatable trial'
it_behaves_like
'a non-extendable trial'
end
context
'with active trial near the expiration date'
do
let_it_be
(
:subscription
)
{
create
(
:gitlab_subscription
,
:active_trial
,
trial_ends_on:
Date
.
tomorrow
,
hosted_plan:
plan
,
namespace:
group
)
}
it_behaves_like
'an extendable trial'
it_behaves_like
'a non-reactivatable trial'
end
context
'with extended trial'
do
let_it_be
(
:subscription
)
{
create
(
:gitlab_subscription
,
:extended_trial
,
hosted_plan:
plan
,
namespace:
group
)
}
it_behaves_like
'a non-extendable trial'
it_behaves_like
'a non-reactivatable trial'
end
context
'with reactivated trial'
do
let_it_be
(
:subscription
)
{
create
(
:gitlab_subscription
,
:reactivated_trial
,
hosted_plan:
plan
,
namespace:
group
)
}
it_behaves_like
'a non-extendable trial'
it_behaves_like
'a non-reactivatable trial'
end
context
'with expired trial'
do
let_it_be
(
:subscription
)
{
create
(
:gitlab_subscription
,
:expired_trial
,
hosted_plan:
plan
,
namespace:
group
)
}
it_behaves_like
'a reactivatable trial'
it_behaves_like
'a non-extendable trial'
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment