Commit 9a2e5179 authored by Tiffany Rea's avatar Tiffany Rea Committed by Sanad Liaquat

MR work continues

Add new page object for ToDos page
Add autoloader for the new page object
Add new selectors on ToDos page elements
Complete test scenario
parent 3c506f6a
......@@ -2,7 +2,7 @@
.todo-avatar
= author_avatar(todo, size: 40)
.todo-item.todo-block.align-self-center
.todo-item.todo-block.align-self-center{ data: { qa_selector: "todo_item_container" } }
.todo-title
- if todo_author_display?(todo)
= todo_target_state_pill(todo)
......@@ -13,7 +13,7 @@
- else
(removed)
%span.title-item.action-name
%span.title-item.action-name{ data: { qa_selector: "todo_action_name_content" } }
= todo_action_name(todo)
%span.title-item.todo-label.todo-target-link
......@@ -22,7 +22,7 @@
- else
= _("(removed)")
%span.title-item.todo-target-title
%span.title-item.todo-target-title{ data: { qa_selector: "todo_target_title_content" } }
= todo_target_title(todo)
%span.title-item.todo-project.todo-label
......
......@@ -83,7 +83,7 @@
.todos-list-container.js-todos-all
- if @todos.any?
.js-todos-list-container
.js-todos-list-container{ data: { qa_selector: "todos_list_container" } }
.js-todos-options{ data: { per_page: @todos.limit_value, current_page: @todos.current_page, total_pages: @todos.total_pages } }
.card.card-without-border.card-without-margin
%ul.content-list.todos-list
......
......@@ -18,6 +18,7 @@ module QA
autoload :Project, 'qa/flow/project'
autoload :Saml, 'qa/flow/saml'
autoload :User, 'qa/flow/user'
autoload :MergeRequest, 'qa/flow/merge_request'
end
##
......@@ -191,6 +192,7 @@ module QA
autoload :Projects, 'qa/page/dashboard/projects'
autoload :Groups, 'qa/page/dashboard/groups'
autoload :Welcome, 'qa/page/dashboard/welcome'
autoload :Todos, 'qa/page/dashboard/todos'
module Snippet
autoload :New, 'qa/page/dashboard/snippet/new'
......
......@@ -23,6 +23,7 @@ module QA
end
def sign_in(as: nil, address: :gitlab, skip_page_validation: false)
Page::Main::Menu.perform(&:sign_out) if Page::Main::Menu.perform(&:signed_in?)
Runtime::Browser.visit(address, Page::Main::Login)
Page::Main::Login.perform { |login| login.sign_in_using_credentials(user: as, skip_page_validation: skip_page_validation) }
end
......
# frozen_string_literal: true
module QA
module Flow
module MergeRequest
module_function
def enable_merge_trains
Page::Project::Menu.perform(&:go_to_general_settings)
Page::Project::Settings::Main.perform(&:expand_merge_requests_settings)
Page::Project::Settings::MergeRequest.perform(&:enable_merge_train)
end
end
end
end
# frozen_string_literal: true
module QA
module Page
module Dashboard
class Todos < Page::Base
include Page::Component::Snippet
view 'app/views/dashboard/todos/index.html.haml' do
element :todos_list_container, required: true
end
view 'app/views/dashboard/todos/_todo.html.haml' do
element :todo_item_container
element :todo_action_name_content
element :todo_target_title_content
end
def has_todo_list?
has_element? :todo_item_container
end
def has_latest_todo_item_with_content?(action, title)
within_element(:todos_list_container) do
within_element_by_index(:todo_item_container, 0) do
has_element?(:todo_action_name_content, text: action) && has_element?(:todo_target_title_content, text: title)
end
end
end
end
end
end
end
# frozen_string_literal: true
require 'faker'
module QA
RSpec.describe 'Verify' do
describe 'Merge train', :runner do
let(:file_name) { 'custom_file.txt' }
let(:mr_title) { Faker::Lorem.sentence }
let(:executor) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(8)}" }
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'pipeline-for-merge-train'
end
end
let!(:runner) do
Resource::Runner.fabricate_via_api! do |runner|
runner.project = project
runner.name = executor
runner.tags = [executor]
end
end
let!(:ci_file) do
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project
commit.commit_message = 'Add .gitlab-ci.yml'
commit.add_files(
[
{
file_path: '.gitlab-ci.yml',
content: <<~YAML
test_merge_train:
tags:
- #{executor}
script:
- sleep 3
- echo 'OK!'
only:
- merge_requests
YAML
}
]
)
end
end
let(:user) { Resource::User.fabricate_via_api! }
let(:user_api_client) { Runtime::API::Client.new(:gitlab, user: user) }
let(:merge_request) do
Resource::MergeRequest.fabricate_via_api! do |merge_request|
merge_request.api_client = user_api_client
merge_request.title = mr_title
merge_request.project = project
merge_request.description = Faker::Lorem.sentence
merge_request.target_new_branch = false
merge_request.file_name = file_name
merge_request.file_content = Faker::Lorem.sentence
end
end
before do
Flow::Login.sign_in
project.visit!
Flow::MergeRequest.enable_merge_trains
project.add_member(user, Resource::Members::AccessLevel::MAINTAINER)
create_user_personal_access_token
Flow::Login.sign_in(as: user)
merge_request.visit!
Page::MergeRequest::Show.perform do |show|
show.has_pipeline_status?('passed')
show.try_to_merge!
show.wait_until(reload: false) { show.has_content? 'started a merge train' }
end
end
after do
runner.remove_via_api!
user.remove_via_api!
end
context 'when system cancels a merge request' do
it 'creates a TODO task', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/927' do
# Create a merge conflict
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.api_client = user_api_client
commit.project = project
commit.commit_message = 'changing text file'
commit.add_files(
[
{
file_path: file_name,
content: Faker::Lorem.sentence
}
]
)
end
Page::MergeRequest::Show.perform do |show|
show.wait_until(max_duration: 90, reload: false) { show.has_content?('removed this merge request from the merge train') }
end
Page::Main::Menu.perform do |main|
main.go_to_page_by_shortcut(:todos_shortcut_button)
end
Page::Dashboard::Todos.perform do |todos|
todos.wait_until(reload: true, sleep_interval: 1) { todos.has_todo_list? }
expect(todos).to have_latest_todo_item_with_content("Removed from Merge Train:", "#{mr_title}")
end
end
end
private
def create_user_personal_access_token
user_api_client.personal_access_token
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