Commit 1a426b04 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'project_wiki_scenario_automation' into 'master'

Added Wiki Scenario Automation gitlab-qa#263

Closes gitlab-qa#263

See merge request gitlab-org/gitlab-ce!19568
parents 3a1a5b28 bc07b89f
...@@ -46,10 +46,13 @@ module QA ...@@ -46,10 +46,13 @@ module QA
autoload :Runner, 'qa/factory/resource/runner' autoload :Runner, 'qa/factory/resource/runner'
autoload :PersonalAccessToken, 'qa/factory/resource/personal_access_token' autoload :PersonalAccessToken, 'qa/factory/resource/personal_access_token'
autoload :KubernetesCluster, 'qa/factory/resource/kubernetes_cluster' autoload :KubernetesCluster, 'qa/factory/resource/kubernetes_cluster'
autoload :Wiki, 'qa/factory/resource/wiki'
end end
module Repository module Repository
autoload :Push, 'qa/factory/repository/push' autoload :Push, 'qa/factory/repository/push'
autoload :ProjectPush, 'qa/factory/repository/project_push'
autoload :WikiPush, 'qa/factory/repository/wiki_push'
end end
module Settings module Settings
...@@ -165,6 +168,16 @@ module QA ...@@ -165,6 +168,16 @@ module QA
autoload :Show, 'qa/page/project/operations/kubernetes/show' autoload :Show, 'qa/page/project/operations/kubernetes/show'
end end
end end
module Wiki
autoload :Edit, 'qa/page/project/wiki/edit'
autoload :New, 'qa/page/project/wiki/new'
autoload :Show, 'qa/page/project/wiki/show'
end
end
module Shared
autoload :ClonePanel, 'qa/page/shared/clone_panel'
end end
module Profile module Profile
......
module QA
module Factory
module Repository
class ProjectPush < Factory::Repository::Push
dependency Factory::Resource::Project, as: :project do |project|
project.name = 'project-with-code'
project.description = 'Project with repository'
end
product :output do |factory|
factory.output
end
def initialize
@file_name = 'file.txt'
@file_content = '# This is test project'
@commit_message = "This is a test commit"
@branch_name = 'master'
@new_branch = true
end
def repository_uri
@repository_uri ||= begin
project.visit!
Page::Project::Show.act do
choose_repository_clone_http
repository_location.uri
end
end
end
end
end
end
end
...@@ -5,25 +5,17 @@ module QA ...@@ -5,25 +5,17 @@ module QA
module Repository module Repository
class Push < Factory::Base class Push < Factory::Base
attr_accessor :file_name, :file_content, :commit_message, attr_accessor :file_name, :file_content, :commit_message,
:branch_name, :new_branch, :output :branch_name, :new_branch, :output, :repository_uri
attr_writer :remote_branch attr_writer :remote_branch
dependency Factory::Resource::Project, as: :project do |project|
project.name = 'project-with-code'
project.description = 'Project with repository'
end
product :output do |factory|
factory.output
end
def initialize def initialize
@file_name = 'file.txt' @file_name = 'file.txt'
@file_content = '# This is test project' @file_content = '# This is test file'
@commit_message = "This is a test commit" @commit_message = "This is a test commit"
@branch_name = 'master' @branch_name = 'master'
@new_branch = true @new_branch = true
@repository_uri = ""
end end
def remote_branch def remote_branch
...@@ -37,14 +29,8 @@ module QA ...@@ -37,14 +29,8 @@ module QA
end end
def fabricate! def fabricate!
project.visit!
Git::Repository.perform do |repository| Git::Repository.perform do |repository|
repository.uri = Page::Project::Show.act do repository.uri = repository_uri
choose_repository_clone_http
repository_location.uri
end
repository.use_default_credentials repository.use_default_credentials
repository.clone repository.clone
repository.configure_identity('GitLab QA', 'root@gitlab.com') repository.configure_identity('GitLab QA', 'root@gitlab.com')
......
module QA
module Factory
module Repository
class WikiPush < Factory::Repository::Push
dependency Factory::Resource::Wiki, as: :wiki do |wiki|
wiki.title = 'Home'
wiki.content = '# My First Wiki Content'
wiki.message = 'Update home'
end
def initialize
@file_name = 'Home.md'
@file_content = '# Welcome to My Wiki'
@commit_message = 'Updating Home Page'
@branch_name = 'master'
@new_branch = false
end
def repository_uri
@repository_uri ||= begin
wiki.visit!
Page::Project::Wiki::Show.act do
go_to_clone_repository
choose_repository_clone_http
repository_location.uri
end
end
end
end
end
end
end
...@@ -31,13 +31,13 @@ module QA ...@@ -31,13 +31,13 @@ module QA
def fabricate! def fabricate!
project.visit! project.visit!
Factory::Repository::Push.fabricate! do |resource| Factory::Repository::ProjectPush.fabricate! do |resource|
resource.project = project resource.project = project
resource.file_name = 'kick-off.txt' resource.file_name = 'kick-off.txt'
resource.commit_message = 'First commit' resource.commit_message = 'First commit'
end end
branch = Factory::Repository::Push.fabricate! do |resource| branch = Factory::Repository::ProjectPush.fabricate! do |resource|
resource.project = project resource.project = project
resource.file_name = 'README.md' resource.file_name = 'README.md'
resource.commit_message = 'Add readme' resource.commit_message = 'Add readme'
......
...@@ -21,14 +21,14 @@ module QA ...@@ -21,14 +21,14 @@ module QA
project.name = 'project-with-merge-request' project.name = 'project-with-merge-request'
end end
dependency Factory::Repository::Push, as: :target do |push, factory| dependency Factory::Repository::ProjectPush, as: :target do |push, factory|
factory.project.visit! factory.project.visit!
push.project = factory.project push.project = factory.project
push.branch_name = 'master' push.branch_name = 'master'
push.remote_branch = factory.target_branch push.remote_branch = factory.target_branch
end end
dependency Factory::Repository::Push, as: :source do |push, factory| dependency Factory::Repository::ProjectPush, as: :source do |push, factory|
push.project = factory.project push.project = factory.project
push.branch_name = factory.target_branch push.branch_name = factory.target_branch
push.remote_branch = factory.source_branch push.remote_branch = factory.source_branch
......
module QA
module Factory
module Resource
class Wiki < Factory::Base
attr_accessor :title, :content, :message
dependency Factory::Resource::Project, as: :project do |project|
project.name = 'project-for-wikis'
project.description = 'project for adding wikis'
end
def fabricate!
Page::Menu::Side.act { click_wiki }
Page::Project::Wiki::New.perform do |page|
page.go_to_create_first_page
page.set_title(@title)
page.set_content(@content)
page.set_message(@message)
page.create_new_page
end
end
end
end
end
end
...@@ -13,6 +13,7 @@ module QA ...@@ -13,6 +13,7 @@ module QA
element :top_level_items, '.sidebar-top-level-items' element :top_level_items, '.sidebar-top-level-items'
element :operations_section, "class: 'shortcuts-operations'" element :operations_section, "class: 'shortcuts-operations'"
element :activity_link, "title: 'Activity'" element :activity_link, "title: 'Activity'"
element :wiki_link_text, "Wiki"
end end
view 'app/assets/javascripts/fly_out_nav.js' do view 'app/assets/javascripts/fly_out_nav.js' do
...@@ -61,6 +62,12 @@ module QA ...@@ -61,6 +62,12 @@ module QA
end end
end end
def click_wiki
within_sidebar do
click_link('Wiki')
end
end
private private
def hover_settings def hover_settings
......
...@@ -2,11 +2,7 @@ module QA ...@@ -2,11 +2,7 @@ module QA
module Page module Page
module Project module Project
class Show < Page::Base class Show < Page::Base
view 'app/views/shared/_clone_panel.html.haml' do include Page::Shared::ClonePanel
element :clone_dropdown
element :clone_options_dropdown, '.clone-options-dropdown'
element :project_repository_location, 'text_field_tag :project_clone'
end
view 'app/views/projects/_last_push.html.haml' do view 'app/views/projects/_last_push.html.haml' do
element :create_merge_request element :create_merge_request
...@@ -26,21 +22,6 @@ module QA ...@@ -26,21 +22,6 @@ module QA
element :branches_dropdown element :branches_dropdown
end end
def choose_repository_clone_http
choose_repository_clone('HTTP', 'http')
end
def choose_repository_clone_ssh
# It's not always beginning with ssh:// so detecting with @
# would be more reliable because ssh would always contain it.
# We can't use .git because HTTP also contain that part.
choose_repository_clone('SSH', '@')
end
def repository_location
Git::Location.new(find('#project_clone').value)
end
def project_name def project_name
find('.qa-project-name').text find('.qa-project-name').text
end end
...@@ -65,31 +46,11 @@ module QA ...@@ -65,31 +46,11 @@ module QA
click_element :create_merge_request click_element :create_merge_request
end end
def wait_for_push
sleep 5
refresh
end
def go_to_new_issue def go_to_new_issue
click_element :new_menu_toggle click_element :new_menu_toggle
click_link 'New issue' click_link 'New issue'
end end
private
def choose_repository_clone(kind, detect_text)
wait(reload: false) do
click_element :clone_dropdown
page.within('.clone-options-dropdown') do
click_link(kind)
end
# Ensure git clone textbox was updated
repository_location.git_uri.include?(detect_text)
end
end
end end
end end
end end
......
module QA
module Page
module Project
module Wiki
class Edit < Page::Base
view 'app/views/projects/wikis/_main_links.html.haml' do
element :new_page_link, 'New page'
element :page_history_link, 'Page history'
element :edit_page_link, 'Edit'
end
def go_to_new_page
click_on 'New page'
end
def got_to_view_history_page
click_on 'Page history'
end
def go_to_edit_page
click_on 'Edit'
end
end
end
end
end
end
module QA
module Page
module Project
module Wiki
class New < Page::Base
view 'app/views/projects/wikis/_form.html.haml' do
element :wiki_title_textbox, 'text_field :title'
element :wiki_content_textarea, "render 'projects/zen', f: f, attr: :content"
element :wiki_message_textbox, 'text_field :message'
element :save_changes_button, 'submit _("Save changes")'
element :create_page_button, 'submit s_("Wiki|Create page")'
end
view 'app/views/shared/empty_states/_wikis.html.haml' do
element :create_link, 'Create your first page'
end
def go_to_create_first_page
click_link 'Create your first page'
end
def set_title(title)
fill_in 'wiki_title', with: title
end
def set_content(content)
fill_in 'wiki_content', with: content
end
def set_message(message)
fill_in 'wiki_message', with: message
end
def save_changes
click_on 'Save changes'
end
def create_new_page
click_on 'Create page'
end
end
end
end
end
end
module QA
module Page
module Project
module Wiki
class Show < Page::Base
include Page::Shared::ClonePanel
view 'app/views/projects/wikis/pages.html.haml' do
element :clone_repository_link, 'Clone repository'
end
def go_to_clone_repository
click_on 'Clone repository'
end
end
end
end
end
end
module QA
module Page
module Shared
module ClonePanel
def self.included(base)
base.view 'app/views/shared/_clone_panel.html.haml' do
element :clone_dropdown
element :clone_options_dropdown, '.clone-options-dropdown'
element :project_repository_location, 'text_field_tag :project_clone'
end
end
def choose_repository_clone_http
choose_repository_clone('HTTP', 'http')
end
def choose_repository_clone_ssh
# It's not always beginning with ssh:// so detecting with @
# would be more reliable because ssh would always contain it.
# We can't use .git because HTTP also contain that part.
choose_repository_clone('SSH', '@')
end
def repository_location
Git::Location.new(find('#project_clone').value)
end
def wait_for_push
sleep 5
refresh
end
private
def choose_repository_clone(kind, detect_text)
wait(reload: false) do
click_element :clone_dropdown
page.within('.clone-options-dropdown') do
click_link(kind)
end
# Ensure git clone textbox was updated
repository_location.git_uri.include?(detect_text)
end
end
end
end
end
end
...@@ -16,7 +16,7 @@ module QA ...@@ -16,7 +16,7 @@ module QA
merge_request.title = 'Needs rebasing' merge_request.title = 'Needs rebasing'
end end
Factory::Repository::Push.fabricate! do |push| Factory::Repository::ProjectPush.fabricate! do |push|
push.project = project push.project = project
push.file_name = "other.txt" push.file_name = "other.txt"
push.file_content = "New file added!" push.file_content = "New file added!"
......
...@@ -13,7 +13,7 @@ module QA ...@@ -13,7 +13,7 @@ module QA
merge_request.title = 'Squashing commits' merge_request.title = 'Squashing commits'
end end
Factory::Repository::Push.fabricate! do |push| Factory::Repository::ProjectPush.fabricate! do |push|
push.project = project push.project = project
push.commit_message = 'to be squashed' push.commit_message = 'to be squashed'
push.branch_name = merge_request.source_branch push.branch_name = merge_request.source_branch
......
...@@ -4,7 +4,7 @@ module QA ...@@ -4,7 +4,7 @@ module QA
Runtime::Browser.visit(:gitlab, Page::Main::Login) Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials } Page::Main::Login.act { sign_in_using_credentials }
Factory::Repository::Push.fabricate! do |push| Factory::Repository::ProjectPush.fabricate! do |push|
push.file_name = 'README.md' push.file_name = 'README.md'
push.file_content = '# This is a test project' push.file_content = '# This is a test project'
push.commit_message = 'Add README.md' push.commit_message = 'Add README.md'
......
...@@ -16,7 +16,7 @@ module QA ...@@ -16,7 +16,7 @@ module QA
end end
# Create Auto Devops compatible repo # Create Auto Devops compatible repo
Factory::Repository::Push.fabricate! do |push| Factory::Repository::ProjectPush.fabricate! do |push|
push.project = project push.project = project
push.directory = Pathname push.directory = Pathname
.new(__dir__) .new(__dir__)
......
...@@ -75,7 +75,7 @@ module QA ...@@ -75,7 +75,7 @@ module QA
- docker - docker
YAML YAML
Factory::Repository::Push.fabricate! do |resource| Factory::Repository::ProjectPush.fabricate! do |resource|
resource.project = @project resource.project = @project
resource.file_name = '.gitlab-ci.yml' resource.file_name = '.gitlab-ci.yml'
resource.commit_message = 'Add .gitlab-ci.yml' resource.commit_message = 'Add .gitlab-ci.yml'
......
...@@ -40,7 +40,7 @@ module QA ...@@ -40,7 +40,7 @@ module QA
runner.tags = %w[qa test] runner.tags = %w[qa test]
end end
Factory::Repository::Push.fabricate! do |push| Factory::Repository::ProjectPush.fabricate! do |push|
push.project = project push.project = project
push.file_name = '.gitlab-ci.yml' push.file_name = '.gitlab-ci.yml'
push.commit_message = 'Add .gitlab-ci.yml' push.commit_message = 'Add .gitlab-ci.yml'
......
module QA
feature 'Wiki Functionality', :core do
def login
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
end
def validate_content(content)
expect(page).to have_content('Wiki was successfully updated')
expect(page).to have_content(/#{content}/)
end
before do
login
end
scenario 'User creates, edits, clones, and pushes to the wiki' do
wiki = Factory::Resource::Wiki.fabricate! do |resource|
resource.title = 'Home'
resource.content = '# My First Wiki Content'
resource.message = 'Update home'
end
validate_content('My First Wiki Content')
Page::Project::Wiki::Edit.act { go_to_edit_page }
Page::Project::Wiki::New.perform do |page|
page.set_content("My Second Wiki Content")
page.save_changes
end
validate_content('My Second Wiki Content')
Factory::Repository::WikiPush.fabricate! do |push|
push.wiki = wiki
push.file_name = 'Home.md'
push.file_content = '# My Third Wiki Content'
push.commit_message = 'Update Home.md'
end
Page::Menu::Side.act { click_wiki }
expect(page).to have_content('My Third Wiki Content')
end
end
end
...@@ -56,7 +56,7 @@ module QA ...@@ -56,7 +56,7 @@ module QA
end end
def push_new_file(branch) def push_new_file(branch)
Factory::Repository::Push.fabricate! do |resource| Factory::Repository::ProjectPush.fabricate! do |resource|
resource.project = project resource.project = project
resource.file_name = 'new_file.md' resource.file_name = 'new_file.md'
resource.file_content = '# This is a new file' resource.file_content = '# This is a new file'
......
...@@ -5,7 +5,7 @@ module QA ...@@ -5,7 +5,7 @@ module QA
Runtime::Browser.visit(:gitlab, Page::Main::Login) Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials } Page::Main::Login.act { sign_in_using_credentials }
Factory::Repository::Push.fabricate! do |push| Factory::Repository::ProjectPush.fabricate! do |push|
push.file_name = 'README.md' push.file_name = 'README.md'
push.file_content = '# This is a test project' push.file_content = '# This is a test project'
push.commit_message = 'Add README.md' push.commit_message = 'Add README.md'
......
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