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
b7ee782d
Commit
b7ee782d
authored
Sep 07, 2021
by
Andrejs Cunskis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
E2E: Add milestone migration validation spec
parent
b1ab29f0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
136 additions
and
55 deletions
+136
-55
qa/qa/resource/group_base.rb
qa/qa/resource/group_base.rb
+16
-0
qa/qa/resource/group_milestone.rb
qa/qa/resource/group_milestone.rb
+51
-16
qa/qa/resource/label_base.rb
qa/qa/resource/label_base.rb
+2
-2
qa/qa/specs/features/api/1_manage/bulk_import_group_spec.rb
qa/qa/specs/features/api/1_manage/bulk_import_group_spec.rb
+67
-37
No files found.
qa/qa/resource/group_base.rb
View file @
b7ee782d
...
...
@@ -30,6 +30,22 @@ module QA
end
end
# Get group milestones
#
# @return [Array<QA::Resource::GroupMilestone>]
def
milestones
parse_body
(
api_get_from
(
"
#{
api_get_path
}
/milestones"
)).
map
do
|
milestone
|
GroupMilestone
.
init
do
|
resource
|
resource
.
api_client
=
api_client
resource
.
group
=
self
resource
.
id
=
milestone
[
:id
]
resource
.
iid
=
milestone
[
:iid
]
resource
.
title
=
milestone
[
:title
]
resource
.
description
=
milestone
[
:description
]
end
end
end
# API get path
#
# @return [String]
...
...
qa/qa/resource/group_milestone.rb
View file @
b7ee782d
...
...
@@ -3,11 +3,14 @@
module
QA
module
Resource
class
GroupMilestone
<
Base
attr_writer
:start_date
,
:due_date
attribute
:id
attribute
:title
attribute
:description
attributes
:id
,
:iid
,
:title
,
:description
,
:start_date
,
:due_date
,
:updated_at
,
:created_at
attribute
:group
do
Group
.
fabricate_via_api!
do
|
resource
|
...
...
@@ -20,6 +23,21 @@ module QA
@description
=
"My awesome group milestone."
end
def
fabricate!
group
.
visit!
Page
::
Group
::
Menu
.
perform
(
&
:go_to_milestones
)
Page
::
Group
::
Milestone
::
Index
.
perform
(
&
:click_new_milestone_link
)
Page
::
Group
::
Milestone
::
New
.
perform
do
|
new_milestone
|
new_milestone
.
set_title
(
@title
)
new_milestone
.
set_description
(
@description
)
new_milestone
.
set_start_date
(
@start_date
)
if
@start_date
new_milestone
.
set_due_date
(
@due_date
)
if
@due_date
new_milestone
.
click_create_milestone_button
end
end
def
api_get_path
"/groups/
#{
group
.
id
}
/milestones/
#{
id
}
"
end
...
...
@@ -38,19 +56,36 @@ module QA
end
end
def
fabricate!
group
.
visit!
# Object comparison
#
# @param [QA::Resource::GroupMilestone] other
# @return [Boolean]
def
==
(
other
)
other
.
is_a?
(
GroupMilestone
)
&&
comparable_milestone
==
other
.
comparable_milestone
end
Page
::
Group
::
Menu
.
perform
(
&
:go_to_milestones
)
Page
::
Group
::
Milestone
::
Index
.
perform
(
&
:click_new_milestone_link
)
# Override inspect for a better rspec failure diff output
#
# @return [String]
def
inspect
JSON
.
pretty_generate
(
comparable_milestone
)
end
Page
::
Group
::
Milestone
::
New
.
perform
do
|
new_milestone
|
new_milestone
.
set_title
(
@title
)
new_milestone
.
set_description
(
@description
)
new_milestone
.
set_start_date
(
@start_date
)
if
@start_date
new_milestone
.
set_due_date
(
@due_date
)
if
@due_date
new_milestone
.
click_create_milestone_button
end
protected
# Return subset of fields for comparing milestones
#
# @return [Hash]
def
comparable_milestone
reload!
unless
api_response
api_response
.
slice
(
:title
,
:description
,
:state
,
:due_date
,
:start_date
)
end
end
end
...
...
qa/qa/resource/label_base.rb
View file @
b7ee782d
...
...
@@ -64,9 +64,9 @@ module QA
JSON
.
pretty_generate
(
comparable_label
)
end
#
protected
protected
# Return subset of fields for comparing
group
s
# Return subset of fields for comparing
label
s
#
# @return [Hash]
def
comparable_label
...
...
qa/qa/specs/features/api/1_manage/bulk_import_group_spec.rb
View file @
b7ee782d
...
...
@@ -5,6 +5,7 @@ module QA
describe
'Bulk group import'
do
let!
(
:staging?
)
{
Runtime
::
Scenario
.
gitlab_address
.
include?
(
'staging.gitlab.com'
)
}
let
(
:import_wait_duration
)
{
{
max_duration:
300
,
sleep_interval:
2
}
}
let
(
:admin_api_client
)
{
Runtime
::
API
::
Client
.
as_admin
}
let
(
:user
)
do
Resource
::
User
.
fabricate_via_api!
do
|
usr
|
...
...
@@ -14,7 +15,6 @@ module QA
end
let
(
:api_client
)
{
Runtime
::
API
::
Client
.
new
(
user:
user
)
}
let
(
:personal_access_token
)
{
api_client
.
personal_access_token
}
let
(
:sandbox
)
do
Resource
::
Sandbox
.
fabricate_via_api!
do
|
group
|
...
...
@@ -29,22 +29,6 @@ module QA
end
end
let
(
:subgroup
)
do
Resource
::
Group
.
fabricate_via_api!
do
|
group
|
group
.
api_client
=
api_client
group
.
sandbox
=
source_group
group
.
path
=
"subgroup-for-import-
#{
SecureRandom
.
hex
(
4
)
}
"
end
end
let
(
:imported_subgroup
)
do
Resource
::
Group
.
init
do
|
group
|
group
.
api_client
=
api_client
group
.
sandbox
=
imported_group
group
.
path
=
subgroup
.
path
end
end
let
(
:imported_group
)
do
Resource
::
BulkImportGroup
.
fabricate_via_api!
do
|
group
|
group
.
api_client
=
api_client
...
...
@@ -57,33 +41,79 @@ module QA
Runtime
::
Feature
.
enable
(
:top_level_group_creation_enabled
)
if
staging?
sandbox
.
add_member
(
user
,
Resource
::
Members
::
AccessLevel
::
MAINTAINER
)
end
Resource
::
GroupLabel
.
fabricate_via_api!
do
|
label
|
label
.
api_client
=
api_client
label
.
group
=
source_group
label
.
title
=
"source-group-
#{
SecureRandom
.
hex
(
4
)
}
"
context
'with subgroups and labels'
do
let
(
:subgroup
)
do
Resource
::
Group
.
fabricate_via_api!
do
|
group
|
group
.
api_client
=
api_client
group
.
sandbox
=
source_group
group
.
path
=
"subgroup-for-import-
#{
SecureRandom
.
hex
(
4
)
}
"
end
end
Resource
::
GroupLabel
.
fabricate_via_api!
do
|
label
|
label
.
api_client
=
api_client
label
.
group
=
subgroup
label
.
title
=
"subgroup-
#{
SecureRandom
.
hex
(
4
)
}
"
let
(
:imported_subgroup
)
do
Resource
::
Group
.
init
do
|
group
|
group
.
api_client
=
api_client
group
.
sandbox
=
imported_group
group
.
path
=
subgroup
.
path
end
end
before
do
Resource
::
GroupLabel
.
fabricate_via_api!
do
|
label
|
label
.
api_client
=
api_client
label
.
group
=
source_group
label
.
title
=
"source-group-
#{
SecureRandom
.
hex
(
4
)
}
"
end
Resource
::
GroupLabel
.
fabricate_via_api!
do
|
label
|
label
.
api_client
=
api_client
label
.
group
=
subgroup
label
.
title
=
"subgroup-
#{
SecureRandom
.
hex
(
4
)
}
"
end
end
it
(
'successfully imports groups and labels'
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/1873'
)
do
expect
{
imported_group
.
import_status
}.
to
eventually_eq
(
'finished'
).
within
(
import_wait_duration
)
aggregate_failures
do
expect
(
imported_group
.
reload!
).
to
eq
(
source_group
)
expect
(
imported_group
.
labels
).
to
include
(
*
source_group
.
labels
)
expect
(
imported_subgroup
.
reload!
).
to
eq
(
subgroup
)
expect
(
imported_subgroup
.
labels
).
to
include
(
*
subgroup
.
labels
)
end
end
end
it
(
'imports group with subgroups and labels'
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/1873'
)
do
expect
{
imported_group
.
import_status
}.
to
(
eventually_eq
(
'finished'
).
within
(
max_duration:
300
,
sleep_interval:
2
)
)
context
'with milestones'
do
let
(
:source_milestone
)
do
Resource
::
GroupMilestone
.
fabricate_via_api!
do
|
milestone
|
milestone
.
api_client
=
api_client
milestone
.
group
=
source_group
end
end
before
do
source_milestone
end
aggregate_failures
do
expect
(
imported_group
.
reload!
).
to
eq
(
source_group
)
expect
(
imported_group
.
labels
).
to
include
(
*
source_group
.
labels
)
it
(
'successfully imports group milestones'
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/2245'
)
do
expect
{
imported_group
.
import_status
}.
to
eventually_eq
(
'finished'
).
within
(
import_wait_duration
)
expect
(
imported_subgroup
.
reload!
).
to
eq
(
subgroup
)
expect
(
imported_subgroup
.
labels
).
to
include
(
*
subgroup
.
labels
)
imported_milestone
=
imported_group
.
reload!
.
milestones
.
find
{
|
ml
|
ml
.
title
==
source_milestone
.
title
}
aggregate_failures
do
expect
(
imported_milestone
).
to
eq
(
source_milestone
)
expect
(
imported_milestone
.
iid
).
to
eq
(
source_milestone
.
iid
)
expect
(
imported_milestone
.
created_at
).
to
eq
(
source_milestone
.
created_at
)
expect
(
imported_milestone
.
updated_at
).
to
eq
(
source_milestone
.
updated_at
)
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