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
9dd9a9ae
Commit
9dd9a9ae
authored
Nov 16, 2021
by
Desiree Chevalier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor epic milestone e2e
parent
158e643f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
103 deletions
+102
-103
qa/qa/ee/resource/epic.rb
qa/qa/ee/resource/epic.rb
+5
-1
qa/qa/resource/project_milestone.rb
qa/qa/resource/project_milestone.rb
+4
-0
qa/qa/specs/features/ee/api/2_plan/epics_milestone_dates_spec.rb
...pecs/features/ee/api/2_plan/epics_milestone_dates_spec.rb
+93
-102
No files found.
qa/qa/ee/resource/epic.rb
View file @
9dd9a9ae
...
...
@@ -15,7 +15,11 @@ module QA
:due_date_is_fixed
,
:due_date_fixed
,
:confidential
,
:author
:author
,
:start_date
,
:due_date
,
:start_date_from_milestones
,
:due_date_from_milestones
attribute
:group
do
QA
::
Resource
::
Group
.
fabricate!
...
...
qa/qa/resource/project_milestone.rb
View file @
9dd9a9ae
...
...
@@ -20,6 +20,10 @@ module QA
@description
=
"My awesome project milestone."
end
def
api_delete_path
"/projects/
#{
project
.
id
}
/milestones/
#{
id
}
"
end
def
api_get_path
"/projects/
#{
project
.
id
}
/milestones/
#{
id
}
"
end
...
...
qa/qa/specs/features/ee/api/2_plan/epics_milestone_dates_spec.rb
View file @
9dd9a9ae
...
...
@@ -6,151 +6,140 @@ module QA
RSpec
.
describe
'Plan'
do
# TODO: Convert back to reliable once proved to be stable. Related issue: https://gitlab.com/gitlab-org/gitlab/-/issues/219495
describe
'Epics milestone dates API'
do
before
(
:context
)
do
@api_client
=
Runtime
::
API
::
Client
.
new
(
:gitlab
)
@group_id
=
Resource
::
Group
.
fabricate_via_api!
.
id
@project_id
=
create_project
@milestone_start_date
=
(
Date
.
today
.
to_date
+
100
).
strftime
(
"%Y-%m-%d"
)
@milestone_due_date
=
(
Date
.
today
.
to_date
+
120
).
strftime
(
"%Y-%m-%d"
)
@fixed_start_date
=
Date
.
today
.
to_date
.
strftime
(
"%Y-%m-%d"
)
@fixed_due_date
=
(
Date
.
today
.
to_date
+
90
).
strftime
(
"%Y-%m-%d"
)
let
(
:milestone_start_date
)
{
(
Date
.
today
.
to_date
+
100
).
strftime
(
"%Y-%m-%d"
)
}
let
(
:milestone_due_date
)
{
(
Date
.
today
.
to_date
+
120
).
strftime
(
"%Y-%m-%d"
)
}
let
(
:fixed_start_date
)
{
Date
.
today
.
to_date
.
strftime
(
"%Y-%m-%d"
)
}
let
(
:fixed_due_date
)
{
(
Date
.
today
.
to_date
+
90
).
strftime
(
"%Y-%m-%d"
)
}
let
(
:api_client
)
{
Runtime
::
API
::
Client
.
new
(
:gitlab
)
}
let
(
:group
)
do
Resource
::
Group
.
fabricate_via_api!
do
|
group
|
group
.
path
=
"epic-milestone-group-
#{
SecureRandom
.
hex
(
8
)
}
"
end
end
it
'changes epic dates when updating milestones'
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/1480'
do
epic_iid
,
milestone_id
=
create_epic_issue_milestone
milestone_start_date
=
Date
.
today
.
to_date
.
strftime
(
"%Y-%m-%d"
)
milestone_due_date
=
(
Date
.
today
.
to_date
+
30
).
strftime
(
"%Y-%m-%d"
)
let
(
:project
)
do
Resource
::
Project
.
fabricate_via_api!
do
|
project
|
project
.
name
=
"epic-milestone-project-
#{
SecureRandom
.
hex
(
8
)
}
"
project
.
group
=
group
end
end
it
'updates epic dates when updating milestones'
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/1480'
do
epic
,
milestone
=
create_epic_issue_milestone
new_milestone_start_date
=
(
Date
.
today
.
to_date
+
20
).
strftime
(
"%Y-%m-%d"
)
new_milestone_due_date
=
(
Date
.
today
.
to_date
+
30
).
strftime
(
"%Y-%m-%d"
)
# Update Milestone to different dates and see it reflecting in the epics
request
=
create_request
(
"/projects/
#{
@project_id
}
/milestones/
#{
milestone_
id
}
"
)
put
request
.
url
,
start_date:
milestone_start_date
,
due_date:
milestone_due_date
request
=
create_request
(
"/projects/
#{
project
.
id
}
/milestones/
#{
milestone
.
id
}
"
)
put
request
.
url
,
start_date:
new_milestone_start_date
,
due_date:
new_
milestone_due_date
expect_status
(
200
)
# Get Epic Details
request
=
create_request
(
"/groups/
#{
@group_id
}
/epics/
#{
epic_iid
}
"
)
get
request
.
url
expect_status
(
200
)
epic
.
reload!
expect
_json
(
'start_date_from_milestones'
,
milestone_start_date
)
expect
_json
(
'due_date_from_milestones'
,
milestone_due_date
)
expect
_json
(
'start_date'
,
milestone_start_date
)
expect
_json
(
'due_date'
,
milestone_due_date
)
expect
(
epic
.
start_date_from_milestones
).
to
eq
(
new_
milestone_start_date
)
expect
(
epic
.
due_date_from_milestones
).
to
eq
(
new_
milestone_due_date
)
expect
(
epic
.
start_date
).
to
eq
(
new_
milestone_start_date
)
expect
(
epic
.
due_date
).
to
eq
(
new_
milestone_due_date
)
end
it
'updates epic dates when adding another issue'
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/1483'
do
epic
_iid
=
create_epic_issue_milestone
[
0
]
milestone_start_date
=
Date
.
today
.
to_date
.
strftime
(
"%Y-%m-%d"
)
milestone_due_date
=
(
Date
.
today
.
to_date
+
150
).
strftime
(
"%Y-%m-%d"
)
epic
=
create_epic_issue_milestone
[
0
]
new_
milestone_start_date
=
Date
.
today
.
to_date
.
strftime
(
"%Y-%m-%d"
)
new_
milestone_due_date
=
(
Date
.
today
.
to_date
+
150
).
strftime
(
"%Y-%m-%d"
)
# Add another Issue and milestone
second_milestone_id
=
create_milestone
(
milestone_start_date
,
milestone_due_date
)
second_issue_id
=
create_issue
(
second_milestone_id
)
request
=
create_request
(
"/groups/
#{
@group_id
}
/epics/
#{
epic_iid
}
/issues/
#{
second_issue_id
}
"
)
post
request
.
url
expect_status
(
201
)
second_milestone
=
create_milestone
(
new_milestone_start_date
,
new_milestone_due_date
)
second_issue
=
create_issue
(
second_milestone
)
add_issue_to_epic
(
epic
,
second_issue
)
# and check milestone dates
request
=
create_request
(
"/groups/
#{
@group_id
}
/epics/
#{
epic_iid
}
"
)
get
request
.
url
expect_status
(
200
)
epic
.
reload!
expect
_json
(
'start_date_from_milestones'
,
milestone_start_date
)
expect
_json
(
'due_date_from_milestones'
,
milestone_due_date
)
expect
_json
(
'start_date'
,
milestone_start_date
)
expect
_json
(
'due_date'
,
milestone_due_date
)
expect
(
epic
.
start_date_from_milestones
).
to
eq
(
new_
milestone_start_date
)
expect
(
epic
.
due_date_from_milestones
).
to
eq
(
new_
milestone_due_date
)
expect
(
epic
.
start_date
).
to
eq
(
new_
milestone_start_date
)
expect
(
epic
.
due_date
).
to
eq
(
new_
milestone_due_date
)
end
it
'updates epic dates when removing issue'
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/1481'
do
epic
_iid
=
create_epic_issue_milestone
[
0
]
epic
=
create_epic_issue_milestone
[
0
]
# Get epic_issue_id
request
=
create_request
(
"/groups/
#{
@group_id
}
/epics/
#{
epic_
iid
}
/issues"
)
request
=
create_request
(
"/groups/
#{
group
.
id
}
/epics/
#{
epic
.
iid
}
/issues"
)
get
request
.
url
expect_status
(
200
)
epic_issue_id
=
json_body
[
0
][
:epic_issue_id
]
# Remove Issue
request
=
create_request
(
"/groups/
#{
@group_id
}
/epics/
#{
epic_
iid
}
/issues/
#{
epic_issue_id
}
"
)
request
=
create_request
(
"/groups/
#{
group
.
id
}
/epics/
#{
epic
.
iid
}
/issues/
#{
epic_issue_id
}
"
)
delete
request
.
url
expect_status
(
200
)
# and check milestone dates
request
=
create_request
(
"/groups/
#{
@group_id
}
/epics/
#{
epic_iid
}
"
)
get
request
.
url
expect_status
(
200
)
epic
.
reload!
expect
_json
(
'start_date_from_milestones'
,
nil
)
expect
_json
(
'due_date_from_milestones'
,
nil
)
expect
_json
(
'start_date'
,
nil
)
expect
_json
(
'due_date'
,
nil
)
expect
(
epic
.
start_date_from_milestones
).
to
be_nil
expect
(
epic
.
due_date_from_milestones
).
to
be_nil
expect
(
epic
.
start_date
).
to
be_nil
expect
(
epic
.
due_date
).
to
be_nil
end
it
'updates epic dates when deleting milestones'
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/1482'
do
epic
_iid
,
milestone_id
=
create_epic_issue_milestone
epic
,
milestone
=
create_epic_issue_milestone
# Delete Milestone
request
=
create_request
(
"/projects/
#{
@project_id
}
/milestones/
#{
milestone_id
}
"
)
delete
request
.
url
expect_status
(
204
)
milestone
.
remove_via_api!
epic
.
reload!
# and check milestone dates
request
=
create_request
(
"/groups/
#{
@group_id
}
/epics/
#{
epic_iid
}
"
)
get
request
.
url
expect_status
(
200
)
expect_json
(
'start_date_from_milestones'
,
nil
)
expect_json
(
'due_date_from_milestones'
,
nil
)
expect_json
(
'start_date'
,
nil
)
expect_json
(
'due_date'
,
nil
)
expect
(
epic
.
start_date_from_milestones
).
to
be_nil
expect
(
epic
.
due_date_from_milestones
).
to
be_nil
expect
(
epic
.
start_date
).
to
be_nil
expect
(
epic
.
due_date
).
to
be_nil
end
private
def
create_epic_issue_milestone
epic
_iid
=
create_epic
milestone
_id
=
create_milestone
(
@milestone_start_date
,
@
milestone_due_date
)
issue
_id
=
create_issue
(
milestone_id
)
add_issue_to_epic
(
epic
_iid
,
issue_id
)
use_epics_milestone_dates
(
epic
_iid
)
[
epic
_iid
,
milestone_id
]
epic
=
create_epic
milestone
=
create_milestone
(
milestone_start_date
,
milestone_due_date
)
issue
=
create_issue
(
milestone
)
add_issue_to_epic
(
epic
,
issue
)
use_epics_milestone_dates
(
epic
)
[
epic
,
milestone
]
end
def
create_request
(
api_endpoint
)
Runtime
::
API
::
Request
.
new
(
@api_client
,
api_endpoint
)
end
def
create_project
project_name
=
"project_
#{
SecureRandom
.
hex
(
8
)
}
"
create_project_request
=
create_request
(
'/projects'
)
post
create_project_request
.
url
,
path:
project_name
,
name:
project_name
,
namespace_id:
@group_id
expect_status
(
201
)
json_body
[
:id
]
Runtime
::
API
::
Request
.
new
(
api_client
,
api_endpoint
)
end
def
create_issue
(
milestone_id
)
request
=
create_request
(
"/projects/
#{
@project_id
}
/issues"
)
post
request
.
url
,
title:
'My Test Issue'
,
milestone_id:
milestone_id
expect_status
(
201
)
json_body
[
:id
]
def
create_issue
(
milestone
)
Resource
::
Issue
.
fabricate_via_api!
do
|
issue
|
issue
.
title
=
'My Test Issue'
issue
.
project
=
project
issue
.
milestone
=
milestone
end
end
def
create_milestone
(
start_date
,
due_date
)
request
=
create_request
(
"/projects/
#{
@project_id
}
/milestones"
)
post
request
.
url
,
title:
"Test_Milestone_
#{
SecureRandom
.
hex
(
8
)
}
"
,
due_date:
due_date
,
start_date:
start_date
expect_status
(
201
)
json_body
[
:id
]
Resource
::
ProjectMilestone
.
fabricate_via_api!
do
|
milestone
|
milestone
.
project
=
project
milestone
.
start_date
=
start_date
milestone
.
due_date
=
due_date
end
end
def
create_epic
request
=
create_request
(
"/groups/
#{
@group_id
}
/epics"
)
post
request
.
url
,
title:
'My New Epic'
,
due_date_fixed:
@fixed_due_date
,
start_date_fixed:
@fixed_start_date
,
start_date_is_fixed:
true
,
due_date_is_fixed:
true
expect_status
(
201
)
json_body
[
:iid
]
EE
::
Resource
::
Epic
.
fabricate_via_api!
do
|
epic
|
epic
.
group
=
group
epic
.
title
=
'My New Epic'
epic
.
due_date_fixed
=
fixed_due_date
epic
.
start_date_fixed
=
fixed_start_date
epic
.
start_date_is_fixed
=
true
epic
.
due_date_is_fixed
=
true
end
end
def
add_issue_to_epic
(
epic
_iid
,
issue_id
)
def
add_issue_to_epic
(
epic
,
issue
)
# Add Issue with milestone to an epic
request
=
create_request
(
"/groups/
#{
@group_id
}
/epics/
#{
epic_iid
}
/issues/
#{
issue_
id
}
"
)
request
=
create_request
(
"/groups/
#{
group
.
id
}
/epics/
#{
epic
.
iid
}
/issues/
#{
issue
.
id
}
"
)
post
request
.
url
expect_status
(
201
)
...
...
@@ -158,18 +147,20 @@ module QA
expect_json
(
'issue.title'
,
'My Test Issue'
)
end
def
use_epics_milestone_dates
(
epic
_iid
)
def
use_epics_milestone_dates
(
epic
)
# Update Epic to use Milestone Dates
request
=
create_request
(
"/groups/
#{
@group_id
}
/epics/
#{
epic_
iid
}
"
)
request
=
create_request
(
"/groups/
#{
group
.
id
}
/epics/
#{
epic
.
iid
}
"
)
put
request
.
url
,
start_date_is_fixed:
false
,
due_date_is_fixed:
false
expect_status
(
200
)
expect_json
(
'start_date_from_milestones'
,
@milestone_start_date
)
expect_json
(
'due_date_from_milestones'
,
@milestone_due_date
)
expect_json
(
'due_date_fixed'
,
@fixed_due_date
)
expect_json
(
'start_date_fixed'
,
@fixed_start_date
)
expect_json
(
'start_date'
,
@milestone_start_date
)
expect_json
(
'due_date'
,
@milestone_due_date
)
epic
.
reload!
expect
(
epic
.
start_date_from_milestones
).
to
eq
(
milestone_start_date
)
expect
(
epic
.
due_date_from_milestones
).
to
eq
(
milestone_due_date
)
expect
(
epic
.
start_date_fixed
).
to
eq
(
fixed_start_date
)
expect
(
epic
.
due_date_fixed
).
to
eq
(
fixed_due_date
)
expect
(
epic
.
start_date
).
to
eq
(
milestone_start_date
)
expect
(
epic
.
due_date
).
to
eq
(
milestone_due_date
)
end
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