Commit 7c3742f8 authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'jsl-add-geo-project-snippet-spec' into 'master'

Add Geo project snippet replication end-to-end test

Closes gitlab-org/quality/testcases#911

See merge request gitlab-org/gitlab!42517
parents 7e6fd918 93334d16
- link_project = local_assigns.fetch(:link_project, false)
- notes_count = @noteable_meta_data[snippet.id].user_notes_count
%li.snippet-row.py-3
%li.snippet-row.py-3{ data: { qa_selector: 'snippet_link', qa_snippet_title: snippet.title } }
= image_tag avatar_icon_for_user(snippet.author), class: "avatar s40 d-none d-sm-block", alt: ''
.title
......
......@@ -373,6 +373,7 @@ module QA
module Snippet
autoload :New, 'qa/page/project/snippet/new'
autoload :Show, 'qa/page/project/snippet/show'
autoload :Index, 'qa/page/project/snippet/index'
end
end
......
......@@ -170,6 +170,10 @@ module QA
module Packages
autoload :Index, 'qa/ee/page/project/packages/index'
end
module Snippet
autoload :Index, 'qa/ee/page/project/snippet/index'
end
end
module MergeRequest
......
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module Snippet
module Index
extend QA::Page::PageConcern
def wait_for_snippet_replication(title)
QA::Runtime::Logger.debug(%Q[#{self.class.name} - wait_for_snippet_replication])
wait_until(max_duration: Runtime::Geo.max_file_replication_time) do
has_project_snippet?(title)
end
end
end
end
end
end
end
end
......@@ -122,6 +122,18 @@ module QA
end
end
def has_no_file_content?(file_content, file_number = nil)
if file_number
within_element_by_index(:file_content, file_number - 1) do
has_no_text?(file_content)
end
else
within_element(:file_content) do
has_no_text?(file_content)
end
end
end
def has_embed_dropdown?
has_element?(:snippet_embed_dropdown)
end
......
# frozen_string_literal: true
module QA
module Page
module Project
module Snippet
class Index < Page::Base
include Page::Component::Snippet
view 'app/views/shared/snippets/_snippet.html.haml' do
element :snippet_link
end
def has_project_snippet?(title)
has_element?(:snippet_link, snippet_title: title)
end
def click_snippet_link(title)
within_element(:snippet_link, text: title) do
click_link(title)
end
end
end
end
end
end
end
QA::Page::Project::Snippet::Index.prepend_if_ee('QA::EE::Page::Project::Snippet::Index')
......@@ -21,8 +21,8 @@ module QA
expect(snippet).to have_file_name('markdown_file.md')
expect(snippet).to have_file_content('Snippet heading')
expect(snippet).to have_file_content('Gitlab link')
expect(snippet).not_to have_file_content('###')
expect(snippet).not_to have_file_content('https://gitlab.com/')
expect(snippet).to have_no_file_content('###')
expect(snippet).to have_no_file_content('https://gitlab.com/')
end
end
end
......
......@@ -31,8 +31,6 @@ module QA
expect(banner).to have_secondary_read_only_banner
end
expect(page).to have_content 'You are on a secondary, read-only Geo node'
Page::Main::Menu.perform do |menu|
menu.go_to_projects
end
......
# frozen_string_literal: true
module QA
RSpec.describe 'Geo', :orchestrated, :geo do
describe 'Project snippet' do
let(:snippet_title) { "Geo project snippet-#{SecureRandom.hex(8)}" }
let(:snippet_description) { 'Geo snippet description' }
let(:file_name) { 'geo_snippet_file.md' }
let(:file_content) { "### Geo snippet heading\n\n[GitLab link](https://gitlab.com/)" }
it 'replicates to the Geo secondary site', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/911' do
snippet = nil
QA::Flow::Login.while_signed_in(address: :geo_primary) do
snippet = Resource::ProjectSnippet.fabricate_via_browser_ui! do |snippet|
snippet.title = snippet_title
snippet.description = snippet_description
snippet.visibility = 'Private'
snippet.file_name = file_name
snippet.file_content = file_content
end
end
QA::Runtime::Logger.debug('Visiting the secondary Geo site')
QA::Flow::Login.while_signed_in(address: :geo_secondary) do
EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner
end
Page::Main::Menu.perform(&:go_to_projects)
Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(snippet.project.name)
dashboard.go_to_project(snippet.project.name)
end
Page::Project::Menu.perform(&:click_snippets)
Page::Project::Snippet::Index.perform do |index|
index.wait_for_snippet_replication(snippet_title)
index.click_snippet_link(snippet_title)
end
Page::Dashboard::Snippet::Show.perform do |snippet|
aggregate_failures 'checking snippet details' do
expect(snippet).to have_snippet_title(snippet_title)
expect(snippet).to have_snippet_description(snippet_description)
expect(snippet).to have_visibility_type(/private/i)
expect(snippet).to have_file_name(file_name)
expect(snippet).to have_file_content('Geo snippet heading')
expect(snippet).to have_file_content('GitLab link')
expect(snippet).to have_no_file_content('###')
expect(snippet).to have_no_file_content('https://gitlab.com/')
end
end
end
end
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