Commit a544c64a authored by Anastasia McDonald's avatar Anastasia McDonald Committed by Sanad Liaquat

E2E test for index page display

parent 9c8129b5
......@@ -8,7 +8,7 @@
= link_to gitlab_snippet_path(snippet) do
= snippet.title
%ul.controls
%ul.controls{ data: { qa_selector: 'snippet_file_count_content', qa_snippet_files: snippet.statistics&.file_count } }
%li
= snippet_file_count(snippet)
%li
......@@ -16,7 +16,7 @@
= sprite_icon('comments', css_class: 'gl-vertical-align-text-bottom')
= notes_count
%li
%span.sr-only
%span.sr-only{ data: { qa_selector: 'snippet_visibility_content', qa_snippet_visibility: visibility_level_label(snippet.visibility_level) } }
= visibility_level_label(snippet.visibility_level)
= visibility_level_icon(snippet.visibility_level)
......
......@@ -10,10 +10,32 @@ module QA
element :global_new_snippet_link
end
view 'app/views/shared/snippets/_snippet.html.haml' do
element :snippet_link
element :snippet_visibility_content
element :snippet_file_count_content
end
def go_to_new_snippet_page
click_element :new_menu_toggle
click_element :global_new_snippet_link
end
def has_snippet_title?(snippet_title)
has_element?(:snippet_link, snippet_title: snippet_title)
end
def has_visibility_level?(snippet_title, visibility)
within_element(:snippet_link, snippet_title: snippet_title) do
has_element?(:snippet_visibility_content, snippet_visibility: visibility)
end
end
def has_number_of_files?(snippet_title, number)
within_element(:snippet_link, snippet_title: snippet_title) do
has_element?(:snippet_file_count_content, snippet_files: number)
end
end
end
end
end
......
......@@ -3,7 +3,7 @@
module QA
module Resource
class Snippet < Base
attr_accessor :title, :description, :file_content, :visibility, :file_name
attr_accessor :title, :description, :file_content, :visibility, :file_name, :files
attribute :id
attribute :http_url_to_repo
......
# frozen_string_literal: true
module QA
RSpec.describe 'Create' do
describe 'Snippet index page' do
let(:personal_snippet_with_single_file) do
Resource::Snippet.fabricate_via_api! do |snippet|
snippet.title = "Personal snippet with one file-#{SecureRandom.hex(8)}"
snippet.visibility = 'Public'
end
end
let(:personal_snippet_with_multiple_files) do
Resource::Snippet.fabricate_via_api! do |snippet|
snippet.title = "Personal snippet with multiple files-#{SecureRandom.hex(8)}"
snippet.visibility = 'Private'
snippet.file_name = 'First file name'
snippet.file_content = 'first file content'
snippet.add_files do |files|
files.append(name: 'Second file name', content: 'second file content')
files.append(name: 'Third file name', content: 'third file content')
end
end
end
let(:project_snippet_with_single_file) do
Resource::ProjectSnippet.fabricate_via_api! do |snippet|
snippet.title = "Project snippet with one file-#{SecureRandom.hex(8)}"
snippet.visibility = 'Private'
end
end
let(:project_snippet_with_multiple_files) do
Resource::ProjectSnippet.fabricate_via_api! do |snippet|
snippet.title = "Project snippet with multiple files-#{SecureRandom.hex(8)}"
snippet.visibility = 'Public'
snippet.file_name = 'First file name'
snippet.file_content = 'first file content'
snippet.add_files do |files|
files.append(name: 'Second file name', content: 'second file content')
files.append(name: 'Third file name', content: 'third file content')
end
end
end
before do
Flow::Login.sign_in
end
after do
personal_snippet_with_single_file.remove_via_api!
personal_snippet_with_multiple_files.remove_via_api!
project_snippet_with_single_file.remove_via_api!
project_snippet_with_multiple_files.remove_via_api!
end
shared_examples 'displaying details on index page' do |snippet_type|
it "shows correct details of #{snippet_type} including file number" do
send(snippet_type)
Page::Main::Menu.perform do |menu|
menu.go_to_more_dropdown_option(:snippets_link)
end
Page::Dashboard::Snippet::Index.perform do |snippet|
aggregate_failures 'file content verification' do
expect(snippet).to have_snippet_title(send(snippet_type).title)
expect(snippet).to have_visibility_level(send(snippet_type).title, send(snippet_type).visibility)
expect(snippet).to have_number_of_files(send(snippet_type).title, send(snippet_type).files.count)
end
end
end
end
it_behaves_like 'displaying details on index page', :personal_snippet_with_single_file
it_behaves_like 'displaying details on index page', :personal_snippet_with_multiple_files
it_behaves_like 'displaying details on index page', :project_snippet_with_single_file
it_behaves_like 'displaying details on index page', :project_snippet_with_multiple_files
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment