Commit e99e3f2d authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch 'tmslvnkc/wiki/list_of_pages' into 'master'

Creating a test for wiki list navigation

Closes gitlab-org/quality/testcases#270

See merge request gitlab-org/gitlab!33265
parents 6047bf27 697c3a89
%li
= link_to wiki_page.title, wiki_page_path(@wiki, wiki_page)
= link_to wiki_page.title, wiki_page_path(@wiki, wiki_page), data: { qa_selector: 'wiki_page_link', qa_page_name: wiki_page.slug }
%small (#{wiki_page.format})
.float-right
- if wiki_page.last_version
......
......@@ -18,5 +18,5 @@
= render @sidebar_wiki_entries, context: 'sidebar'
.block.w-100
- if @sidebar_limited
= link_to wiki_path(@wiki, action: :pages), class: 'btn btn-block' do
= link_to wiki_path(@wiki, action: :pages), class: 'btn btn-block', data: { qa_selector: 'view_all_pages_button' } do
= s_("Wiki|View All Pages")
%li{ class: active_when(params[:id] == wiki_page.slug) }
= link_to wiki_page_path(@wiki, wiki_page) do
= link_to wiki_page_path(@wiki, wiki_page), data: { qa_selector: 'wiki_page_link', qa_page_name: wiki_page.slug } do
= wiki_page.human_title
......@@ -345,6 +345,8 @@ module QA
autoload :Edit, 'qa/page/project/wiki/edit'
autoload :Show, 'qa/page/project/wiki/show'
autoload :GitAccess, 'qa/page/project/wiki/git_access'
autoload :Sidebar, 'qa/page/project/wiki/sidebar'
autoload :List, 'qa/page/project/wiki/list'
end
module WebIDE
......
......@@ -4,7 +4,9 @@ module QA
module Page
module Project
module Wiki
class Edit < Page::Base
class Edit < Base
include Wiki::Sidebar
view 'app/views/shared/wikis/_form.html.haml' do
element :wiki_title_textbox
element :wiki_content_textarea
......
# frozen_string_literal: true
module QA
module Page
module Project
module Wiki
class List < Base
view 'app/views/shared/wikis/_pages_wiki_page.html.haml' do
element :wiki_page_link
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
end
end
end
end
end
......@@ -4,13 +4,10 @@ module QA
module Page
module Project
module Wiki
class Show < Page::Base
class Show < Base
include Wiki::Sidebar
include Component::LazyLoader
view 'app/views/shared/wikis/_sidebar.html.haml' do
element :clone_repository_link
end
view 'app/views/shared/wikis/show.html.haml' do
element :wiki_page_title
element :wiki_page_content
......@@ -54,14 +51,6 @@ module QA
click_element(:edit_page_button)
end
def click_clone_repository
click_element(:clone_repository_link)
end
def wiki_text
find_element(:wiki_page_content).text
end
def has_title?(title)
has_element?(:wiki_page_title, title)
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
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
end
end
end
end
end
......@@ -34,7 +34,7 @@ module QA
rescue ResourceURLMissingError
# TODO
# workaround
project.web_url.concat("/-/wikis/#{slug}")
"#{project.web_url}/-/wikis/#{slug}"
end
def api_get_path
......
# frozen_string_literal: true
module QA
RSpec.describe 'Create' do
context 'Wiki' do
let(:small_number_of_pages) { 5 }
let(:large_number_of_pages) { 15 }
let(:random_page) { "bulk_#{rand(0..4)}" }
let(:small_wiki) { create_wiki_pages small_number_of_pages }
let(:large_wiki) { create_wiki_pages large_number_of_pages }
before do
Flow::Login.sign_in
end
context 'Sidebar' do
it 'has all expected links that work' do
small_wiki.visit!
small_number_of_pages.times do |index|
Page::Project::Wiki::Show.perform do |list|
expect(list).to have_page_listed "bulk_#{index}"
end
end
Page::Project::Wiki::Show.perform do |list|
list.click_page_link random_page
end
Page::Project::Wiki::Show.perform do |wiki|
expect(wiki).to have_title random_page
end
end
end
context 'Page List' do
it 'has all expected links that work' do
large_wiki.visit!
Page::Project::Wiki::Show.perform(&:click_view_all_pages)
large_number_of_pages.times do |index|
Page::Project::Wiki::List.perform do |list|
expect(list).to have_page_listed "bulk_#{index}"
end
end
Page::Project::Wiki::List.perform do |list|
list.click_page_link random_page
end
Page::Project::Wiki::Show.perform do |wiki|
expect(wiki).to have_title random_page
end
end
end
private
def create_wiki_pages(no_of_pages)
wiki = Resource::Wiki::ProjectPage.fabricate_via_api!
no_of_pages.times do |index|
Resource::Wiki::ProjectPage.fabricate_via_api! do |page|
page.title = "bulk_#{index}"
page.project = wiki.project
end
end
wiki
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