Commit 195d5f87 authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'qa-e2e-group-level-wiki-spec' into 'master'

Add Basic Group Level Wiki E2E

See merge request gitlab-org/gitlab!56171
parents 55b4cc6f 689c3c27
%li{ class: active_when(params[:id] == wiki_page.slug) } %li{ class: active_when(params[:id] == wiki_page.slug) }
= link_to wiki_page_path(@wiki, wiki_page), data: { qa_selector: 'wiki_page_link', qa_page_name: wiki_page.slug } do = link_to wiki_page_path(@wiki, wiki_page), data: { qa_selector: 'wiki_page_link', qa_page_name: wiki_page.human_title } do
= wiki_page.human_title = wiki_page.human_title
...@@ -121,6 +121,7 @@ module QA ...@@ -121,6 +121,7 @@ module QA
module Wiki module Wiki
autoload :ProjectPage, 'qa/resource/wiki/project_page' autoload :ProjectPage, 'qa/resource/wiki/project_page'
autoload :GroupPage, 'qa/resource/wiki/group_page'
end end
end end
...@@ -380,7 +381,6 @@ module QA ...@@ -380,7 +381,6 @@ module QA
autoload :Edit, 'qa/page/project/wiki/edit' autoload :Edit, 'qa/page/project/wiki/edit'
autoload :Show, 'qa/page/project/wiki/show' autoload :Show, 'qa/page/project/wiki/show'
autoload :GitAccess, 'qa/page/project/wiki/git_access' autoload :GitAccess, 'qa/page/project/wiki/git_access'
autoload :Sidebar, 'qa/page/project/wiki/sidebar'
autoload :List, 'qa/page/project/wiki/list' autoload :List, 'qa/page/project/wiki/list'
end end
...@@ -496,6 +496,9 @@ module QA ...@@ -496,6 +496,9 @@ module QA
autoload :Snippet, 'qa/page/component/snippet' autoload :Snippet, 'qa/page/component/snippet'
autoload :NewSnippet, 'qa/page/component/new_snippet' autoload :NewSnippet, 'qa/page/component/new_snippet'
autoload :InviteMembersModal, 'qa/page/component/invite_members_modal' autoload :InviteMembersModal, 'qa/page/component/invite_members_modal'
autoload :Wiki, 'qa/page/component/wiki'
autoload :WikiSidebar, 'qa/page/component/wiki_sidebar'
autoload :WikiPageForm, 'qa/page/component/wiki_page_form'
module Issuable module Issuable
autoload :Common, 'qa/page/component/issuable/common' autoload :Common, 'qa/page/component/issuable/common'
......
...@@ -49,6 +49,11 @@ module QA ...@@ -49,6 +49,11 @@ module QA
autoload :LDAPSync, 'qa/ee/page/group/settings/ldap_sync' autoload :LDAPSync, 'qa/ee/page/group/settings/ldap_sync'
autoload :General, 'qa/ee/page/group/settings/general' autoload :General, 'qa/ee/page/group/settings/general'
end end
module Wiki
autoload :Show, 'qa/ee/page/group/wiki/show'
autoload :Edit, 'qa/ee/page/group/wiki/edit'
end
end end
module File module File
......
# frozen_string_literal: true
module QA
module EE
module Page
module Group
module Wiki
class Edit < QA::Page::Base
include QA::Page::Component::WikiPageForm
include QA::Page::Component::WikiSidebar
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module EE
module Page
module Group
module Wiki
class Show < QA::Page::Base
include QA::Page::Component::Wiki
include QA::Page::Component::WikiSidebar
include QA::Page::Component::LazyLoader
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module Page
module Component
module Wiki
extend QA::Page::PageConcern
def self.included(base)
super
base.view 'app/views/shared/wikis/show.html.haml' do
element :wiki_page_title
element :wiki_page_content
element :edit_page_button
end
base.view 'app/views/shared/wikis/_main_links.html.haml' do
element :new_page_button
element :page_history_button
end
base.view 'app/views/shared/empty_states/_wikis.html.haml' do
element :create_first_page_link
end
base.view 'app/views/shared/empty_states/_wikis_layout.html.haml' do
element :svg_content
end
end
def click_create_your_first_page
# The svg takes a fraction of a second to load after which the
# "Create your first page" button shifts up a bit. This can cause
# webdriver to miss the hit so we wait for the svg to load before
# clicking the button.
within_element(:svg_content) do
has_element?(:js_lazy_loaded)
end
click_element(:create_first_page_link)
end
def click_new_page
click_element(:new_page_button)
end
def click_page_history
click_element(:page_history_button)
end
def click_edit
click_element(:edit_page_button)
end
def has_title?(title)
has_element?(:wiki_page_title, title)
end
def has_content?(content)
has_element?(:wiki_page_content, content)
end
def has_no_content?(content)
has_no_element?(:wiki_page_content, content)
end
def has_no_page?
has_element?(:create_first_page_link)
end
end
end
end
end
# frozen_string_literal: true
module QA
module Page
module Component
module WikiPageForm
extend QA::Page::PageConcern
def self.included(base)
super
base.view 'app/views/shared/wikis/_form.html.haml' do
element :wiki_title_textbox
element :wiki_content_textarea
element :wiki_message_textbox
element :save_changes_button
element :create_page_button
end
base.view 'app/assets/javascripts/pages/shared/wikis/components/delete_wiki_modal.vue' do
element :delete_button
end
end
def set_title(title)
fill_element(:wiki_title_textbox, title)
end
def set_content(content)
fill_element(:wiki_content_textarea, content)
end
def set_message(message)
fill_element(:wiki_message_textbox, message)
end
def click_save_changes
click_element(:save_changes_button)
end
def click_create_page
click_element(:create_page_button)
end
def delete_page
click_element(:delete_button, Page::Modal::DeleteWiki)
Page::Modal::DeleteWiki.perform(&:confirm_deletion)
end
end
end
end
end
# frozen_string_literal: true
module QA
module Page
module Component
module WikiSidebar
extend QA::Page::PageConcern
def self.included(base)
super
base.view 'app/views/shared/wikis/_sidebar.html.haml' do
element :clone_repository_link
element :view_all_pages_button
end
base.view 'app/views/shared/wikis/_sidebar_wiki_page.html.haml' do
element :wiki_page_link
end
base.view 'app/views/shared/wikis/_wiki_directory.html.haml' do
element :wiki_directory_content
end
end
def click_clone_repository
click_element(:clone_repository_link)
end
def click_view_all_pages
click_element(:view_all_pages_button)
end
def click_page_link(page_title)
click_element(:wiki_page_link, page_name: page_title)
end
def has_page_listed?(page_title)
has_element?(:wiki_page_link, page_name: page_title)
end
def has_directory?(directory)
has_element?(:wiki_directory_content, text: directory)
end
end
end
end
end
...@@ -5,44 +5,8 @@ module QA ...@@ -5,44 +5,8 @@ module QA
module Project module Project
module Wiki module Wiki
class Edit < Base class Edit < Base
include Wiki::Sidebar include Page::Component::WikiPageForm
include Page::Component::WikiSidebar
view 'app/views/shared/wikis/_form.html.haml' do
element :wiki_title_textbox
element :wiki_content_textarea
element :wiki_message_textbox
element :save_changes_button
element :create_page_button
end
view 'app/assets/javascripts/pages/shared/wikis/components/delete_wiki_modal.vue' do
element :delete_button
end
def set_title(title)
fill_element :wiki_title_textbox, title
end
def set_content(content)
fill_element :wiki_content_textarea, content
end
def set_message(message)
fill_element :wiki_message_textbox, message
end
def click_save_changes
click_element :save_changes_button
end
def click_create_page
click_element :create_page_button
end
def delete_page
click_element :delete_button, Page::Modal::DeleteWiki
Page::Modal::DeleteWiki.perform(&:confirm_deletion)
end
end end
end end
end end
......
...@@ -5,67 +5,9 @@ module QA ...@@ -5,67 +5,9 @@ module QA
module Project module Project
module Wiki module Wiki
class Show < Base class Show < Base
include Wiki::Sidebar include Page::Component::Wiki
include Component::LazyLoader include Page::Component::WikiSidebar
include Page::Component::LazyLoader
view 'app/views/shared/wikis/show.html.haml' do
element :wiki_page_title
element :wiki_page_content
element :edit_page_button
end
view 'app/views/shared/wikis/_main_links.html.haml' do
element :new_page_button
element :page_history_button
end
view 'app/views/shared/empty_states/_wikis.html.haml' do
element :create_first_page_link
end
view 'app/views/shared/empty_states/_wikis_layout.html.haml' do
element :svg_content
end
def click_create_your_first_page
# The svg takes a fraction of a second to load after which the
# "Create your first page" button shifts up a bit. This can cause
# webdriver to miss the hit so we wait for the svg to load before
# clicking the button.
within_element(:svg_content) do
has_element? :js_lazy_loaded
end
click_element :create_first_page_link
end
def click_new_page
click_element(:new_page_button)
end
def click_page_history
click_element(:page_history_button)
end
def click_edit
click_element(:edit_page_button)
end
def has_title?(title)
has_element?(:wiki_page_title, title)
end
def has_content?(content)
has_element?(:wiki_page_content, content)
end
def has_no_content?(content)
has_no_element?(:wiki_page_content, content)
end
def has_no_page?
has_element? :create_first_page_link
end
end end
end end
end end
......
# frozen_string_literal: true
module QA
module Page
module Project
module Wiki
module Sidebar
extend QA::Page::PageConcern
def self.included(base)
super
base.view 'app/views/shared/wikis/_sidebar.html.haml' do
element :clone_repository_link
element :view_all_pages_button
end
base.view 'app/views/shared/wikis/_sidebar_wiki_page.html.haml' do
element :wiki_page_link
end
base.view 'app/views/shared/wikis/_wiki_directory.html.haml' do
element :wiki_directory_content
end
end
def click_clone_repository
click_element(:clone_repository_link)
end
def click_view_all_pages
click_element(:view_all_pages_button)
end
def click_page_link(page_title)
click_element :wiki_page_link, page_name: page_title
end
def has_page_listed?(page_title)
has_element? :wiki_page_link, page_name: page_title
end
def has_directory?(directory)
has_element? :wiki_directory_content, text: directory
end
end
end
end
end
end
# frozen_string_literal: true
require 'securerandom'
module QA
module Resource
module Wiki
class GroupPage < Base
attribute :title
attribute :content
attribute :slug
attribute :group do
Group.fabricate_via_api! do |group|
group.path = "group-with-wiki-#{SecureRandom.hex(8)}"
end
end
def initialize
@title = 'Home'
@content = 'This wiki page is created via API'
end
def resource_web_url(resource)
super
rescue ResourceURLMissingError
"#{group.web_url}/-/wikis/#{slug}"
end
def api_get_path
"/groups/#{group.id}/wikis/#{slug}"
end
def api_post_path
"/groups/#{group.id}/wikis"
end
def api_post_body
{
id: group.id,
content: content,
title: title
}
end
end
end
end
end
# frozen_string_literal: true
module QA
RSpec.describe 'Create' do
context 'Wiki' do
describe 'Creating pages in Group Wikis' do
let(:wiki_title) { 'New Wiki page' }
let(:wiki_content) { 'New Wiki content' }
before do
Flow::Login.sign_in
end
context 'when Wiki is empty' do
let(:group) { Resource::Group.fabricate_via_api! }
it 'creates a home page', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1708' do
group.visit!
Page::Group::Menu.perform(&:click_group_wiki_link)
EE::Page::Group::Wiki::Show.perform(&:click_create_your_first_page)
EE::Page::Group::Wiki::Edit.perform do |edit|
edit.set_title(wiki_title)
edit.set_content(wiki_content)
edit.click_create_page
end
EE::Page::Group::Wiki::Show.perform do |wiki|
expect(wiki).to have_title(wiki_title)
expect(wiki).to have_content(wiki_content)
end
end
end
context 'when Wiki has a home page' do
let(:wiki) do
Resource::Wiki::GroupPage.fabricate_via_api! do |wiki|
wiki.title = 'Home page'
end
end
it 'adds a second page', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1728' do
wiki.visit!
EE::Page::Group::Wiki::Show.perform(&:click_new_page)
EE::Page::Group::Wiki::Edit.perform do |edit|
edit.set_title(wiki_title)
edit.set_content(wiki_content)
edit.click_create_page
end
EE::Page::Group::Wiki::Show.perform do |wiki|
expect(wiki).to have_title(wiki_title)
expect(wiki).to have_content(wiki_content)
expect(wiki).to have_page_listed('Home page')
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