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
c32fafac
Commit
c32fafac
authored
Oct 22, 2020
by
Anastasia McDonald
Committed by
Mark Lapierre
Oct 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
E2E test to add files to an existing snippet
Also adds support for creating single-file snippet via API
parent
3ca8dee1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
127 additions
and
7 deletions
+127
-7
qa/qa/page/dashboard/snippet/edit.rb
qa/qa/page/dashboard/snippet/edit.rb
+30
-0
qa/qa/resource/project_snippet.rb
qa/qa/resource/project_snippet.rb
+8
-0
qa/qa/resource/snippet.rb
qa/qa/resource/snippet.rb
+29
-1
qa/qa/specs/features/browser_ui/3_create/snippet/add_file_to_snippet_spec.rb
...s/browser_ui/3_create/snippet/add_file_to_snippet_spec.rb
+54
-0
qa/qa/specs/features/browser_ui/3_create/snippet/clone_push_pull_personal_snippet_spec.rb
...3_create/snippet/clone_push_pull_personal_snippet_spec.rb
+2
-2
qa/qa/specs/features/browser_ui/3_create/snippet/clone_push_pull_project_snippet_spec.rb
.../3_create/snippet/clone_push_pull_project_snippet_spec.rb
+2
-2
qa/qa/specs/features/browser_ui/3_create/snippet/share_snippet_spec.rb
...eatures/browser_ui/3_create/snippet/share_snippet_spec.rb
+2
-2
No files found.
qa/qa/page/dashboard/snippet/edit.rb
View file @
c32fafac
...
@@ -9,6 +9,11 @@ module QA
...
@@ -9,6 +9,11 @@ module QA
element
:submit_button
,
required:
true
element
:submit_button
,
required:
true
end
end
view
'app/assets/javascripts/snippets/components/snippet_blob_edit.vue'
do
element
:file_name_field
element
:file_holder_container
end
def
add_to_file_content
(
content
)
def
add_to_file_content
(
content
)
text_area
.
set
content
text_area
.
set
content
text_area
.
has_text?
(
content
)
# wait for changes to take effect
text_area
.
has_text?
(
content
)
# wait for changes to take effect
...
@@ -18,7 +23,32 @@ module QA
...
@@ -18,7 +23,32 @@ module QA
choose
(
visibility_type
)
choose
(
visibility_type
)
end
end
def
click_add_file
click_element
(
:add_file_button
)
end
def
fill_file_name
(
name
,
file_number
=
nil
)
if
file_number
within_element_by_index
(
:file_holder_container
,
file_number
-
1
)
do
fill_element
(
:file_name_field
,
name
)
end
else
fill_element
(
:file_name_field
,
name
)
end
end
def
fill_file_content
(
content
,
file_number
=
nil
)
if
file_number
within_element_by_index
(
:file_holder_container
,
file_number
-
1
)
do
text_area
.
set
(
content
)
end
else
text_area
.
set
(
content
)
end
end
def
save_changes
def
save_changes
wait_until
(
reload:
false
)
{
!
find_element
(
:submit_button
).
disabled?
}
click_element
(
:submit_button
,
Page
::
Dashboard
::
Snippet
::
Show
)
click_element
(
:submit_button
,
Page
::
Dashboard
::
Snippet
::
Show
)
end
end
...
...
qa/qa/resource/project_snippet.rb
View file @
c32fafac
...
@@ -31,6 +31,14 @@ module QA
...
@@ -31,6 +31,14 @@ module QA
new_snippet
.
click_create_snippet_button
new_snippet
.
click_create_snippet_button
end
end
end
end
def
api_get_path
"/projects/
#{
project
.
id
}
/snippets/
#{
snippet_id
}
"
end
def
api_post_path
"/projects/
#{
project
.
id
}
/snippets"
end
end
end
end
end
end
end
qa/qa/resource/snippet.rb
View file @
c32fafac
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
module
QA
module
QA
module
Resource
module
Resource
class
Snippet
<
Base
class
Snippet
<
Base
attr_accessor
:title
,
:description
,
:file_content
,
:visibility
,
:file_name
attr_accessor
:title
,
:description
,
:file_content
,
:visibility
,
:file_name
,
:snippet_id
def
initialize
def
initialize
@title
=
'New snippet title'
@title
=
'New snippet title'
...
@@ -36,6 +36,34 @@ module QA
...
@@ -36,6 +36,34 @@ module QA
new_page
.
click_create_snippet_button
new_page
.
click_create_snippet_button
end
end
end
end
def
fabricate_via_api!
resource_web_url
(
api_post
)
rescue
ResourceNotFoundError
super
end
def
api_get_path
"/snippets/
#{
snippet_id
}
"
end
def
api_post_path
'/snippets'
end
def
api_post_body
{
title:
title
,
description:
description
,
visibility:
visibility
.
downcase
,
files:
[
{
content:
file_content
,
file_path:
file_name
}
]
}
end
end
end
end
end
end
end
qa/qa/specs/features/browser_ui/3_create/snippet/add_file_to_snippet_spec.rb
0 → 100644
View file @
c32fafac
# frozen_string_literal: true
module
QA
RSpec
.
describe
'Create'
do
describe
'Multiple file snippet'
do
let
(
:personal_snippet
)
do
Resource
::
Snippet
.
fabricate_via_api!
do
|
snippet
|
snippet
.
title
=
'Personal snippet to add file to'
snippet
.
file_name
=
'Original file name'
snippet
.
file_content
=
'Original file content'
end
end
let
(
:project_snippet
)
do
Resource
::
ProjectSnippet
.
fabricate_via_api!
do
|
snippet
|
snippet
.
title
=
'Project snippet to add file to'
snippet
.
file_name
=
'Original file name'
snippet
.
file_content
=
'Original file content'
end
end
before
do
Flow
::
Login
.
sign_in
end
shared_examples
'adding file to snippet'
do
|
snippet_type
|
it
"adds second file to an existing
#{
snippet_type
}
to make it multi-file"
do
send
(
snippet_type
).
visit!
Page
::
Dashboard
::
Snippet
::
Show
.
perform
(
&
:click_edit_button
)
Page
::
Dashboard
::
Snippet
::
Edit
.
perform
do
|
snippet
|
snippet
.
click_add_file
snippet
.
fill_file_name
(
'Second file name'
,
2
)
snippet
.
fill_file_content
(
'Second file content'
,
2
)
snippet
.
save_changes
end
Page
::
Dashboard
::
Snippet
::
Show
.
perform
do
|
snippet
|
aggregate_failures
'file names and contents'
do
expect
(
snippet
).
to
have_file_name
(
'Original file name'
,
1
)
expect
(
snippet
).
to
have_file_content
(
'Original file content'
,
1
)
expect
(
snippet
).
to
have_file_name
(
'Second file name'
,
2
)
expect
(
snippet
).
to
have_file_content
(
'Second file content'
,
2
)
end
end
end
end
it_behaves_like
'adding file to snippet'
,
:personal_snippet
it_behaves_like
'adding file to snippet'
,
:project_snippet
end
end
end
qa/qa/specs/features/browser_ui/3_create/snippet/clone_push_pull_personal_snippet_spec.rb
View file @
c32fafac
...
@@ -22,13 +22,13 @@ module QA
...
@@ -22,13 +22,13 @@ module QA
end
end
let
(
:repository_uri_http
)
do
let
(
:repository_uri_http
)
do
snippet
snippet
.
visit!
Page
::
Dashboard
::
Snippet
::
Show
.
perform
(
&
:get_repository_uri_http
)
Page
::
Dashboard
::
Snippet
::
Show
.
perform
(
&
:get_repository_uri_http
)
end
end
let
(
:repository_uri_ssh
)
do
let
(
:repository_uri_ssh
)
do
ssh_key
ssh_key
snippet
snippet
.
visit!
Page
::
Dashboard
::
Snippet
::
Show
.
perform
(
&
:get_repository_uri_ssh
)
Page
::
Dashboard
::
Snippet
::
Show
.
perform
(
&
:get_repository_uri_ssh
)
end
end
...
...
qa/qa/specs/features/browser_ui/3_create/snippet/clone_push_pull_project_snippet_spec.rb
View file @
c32fafac
...
@@ -22,13 +22,13 @@ module QA
...
@@ -22,13 +22,13 @@ module QA
end
end
let
(
:repository_uri_http
)
do
let
(
:repository_uri_http
)
do
snippet
snippet
.
visit!
Page
::
Dashboard
::
Snippet
::
Show
.
perform
(
&
:get_repository_uri_http
)
Page
::
Dashboard
::
Snippet
::
Show
.
perform
(
&
:get_repository_uri_http
)
end
end
let
(
:repository_uri_ssh
)
do
let
(
:repository_uri_ssh
)
do
ssh_key
ssh_key
snippet
snippet
.
visit!
Page
::
Dashboard
::
Snippet
::
Show
.
perform
(
&
:get_repository_uri_ssh
)
Page
::
Dashboard
::
Snippet
::
Show
.
perform
(
&
:get_repository_uri_ssh
)
end
end
...
...
qa/qa/specs/features/browser_ui/3_create/snippet/share_snippet_spec.rb
View file @
c32fafac
...
@@ -18,7 +18,7 @@ module QA
...
@@ -18,7 +18,7 @@ module QA
context
'when the snippet is public'
do
context
'when the snippet is public'
do
it
'can be shared with not signed-in users'
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1016'
do
it
'can be shared with not signed-in users'
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1016'
do
snippet
snippet
.
visit!
sharing_link
=
Page
::
Dashboard
::
Snippet
::
Show
.
perform
do
|
snippet
|
sharing_link
=
Page
::
Dashboard
::
Snippet
::
Show
.
perform
do
|
snippet
|
expect
(
snippet
).
to
have_embed_dropdown
expect
(
snippet
).
to
have_embed_dropdown
...
@@ -40,7 +40,7 @@ module QA
...
@@ -40,7 +40,7 @@ module QA
context
'when the snippet is changed to private'
do
context
'when the snippet is changed to private'
do
it
'does not display Embed/Share dropdown'
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1015'
do
it
'does not display Embed/Share dropdown'
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1015'
do
snippet
snippet
.
visit!
Page
::
Dashboard
::
Snippet
::
Show
.
perform
do
|
snippet
|
Page
::
Dashboard
::
Snippet
::
Show
.
perform
do
|
snippet
|
expect
(
snippet
).
to
have_embed_dropdown
expect
(
snippet
).
to
have_embed_dropdown
...
...
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