Commit 72b62b51 authored by Tomislav Nikic's avatar Tomislav Nikic Committed by Mark Lapierre

Creating a new elasticsearch test

Adding a new elasticsearch test suite with all the changes to views
as well as pageobjects.
parent a2c5925e
......@@ -13,7 +13,8 @@
tabindex: '1',
autocomplete: 'off',
data: { issues_path: issues_dashboard_path,
mr_path: merge_requests_dashboard_path },
mr_path: merge_requests_dashboard_path,
qa_selector: 'search_term_field' },
aria: { label: _('Search or jump to…') }
%button.hidden.js-dropdown-search-toggle{ type: 'button', data: { toggle: 'dropdown' } }
.dropdown-menu.dropdown-select.js-dashboard-search-options
......
......@@ -236,7 +236,7 @@
%span
= _('General')
= nav_link(path: 'application_settings#integrations') do
= link_to integrations_admin_application_settings_path, title: _('Integrations') do
= link_to integrations_admin_application_settings_path, title: _('Integrations'), data: { qa_selector: 'integration_settings_link' } do
%span
= _('Integrations')
= nav_link(path: 'application_settings#repository') do
......
......@@ -12,7 +12,7 @@
%ul.nav-links.search-filter.scrolling-tabs.nav.nav-tabs
- if @project
- if project_search_tabs?(:blobs)
%li{ class: active_when(@scope == 'blobs') }
%li{ class: active_when(@scope == 'blobs'), data: { qa_selector: 'code_tab' } }
= link_to search_filter_path(scope: 'blobs') do
= _("Code")
%span.badge.badge-pill
......
.blob-result
.blob-result{ data: { qa_selector: 'result_item_content' } }
.file-holder
.js-file-title.file-title
.js-file-title.file-title{ data: { qa_selector: 'file_title_content' } }
= link_to blob_link do
%i.fa.fa-file
%strong
= search_blob_title(project, file_name)
- if blob.data
.file-content.code.term
.file-content.code.term{ data: { qa_selector: 'file_text_content' } }
= render 'shared/file_highlight', blob: blob, first_line_number: blob.startline
......@@ -4,7 +4,7 @@
- recreate_index_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: recreate_index_url }
- recreate_index_text = s_("Changes won't take place until the index is %{link_start}recreated%{link_end}.").html_safe % { link_start: recreate_index_link_start, link_end: '</a>'.html_safe }
%section.settings.as-elasticsearch.no-animate#js-elasticsearch-settings{ class: ('expanded' if expanded) }
%section.settings.as-elasticsearch.no-animate#js-elasticsearch-settings{ class: ('expanded' if expanded), data: { qa_selector: 'elasticsearch_tab' } }
.settings-header
%h4
= _('Elasticsearch')
......@@ -21,14 +21,14 @@
.sub-section
.form-group
.form-check
= f.check_box :elasticsearch_indexing, class: 'form-check-input'
= f.check_box :elasticsearch_indexing, class: 'form-check-input', data: { qa_selector: 'indexing_checkbox' }
= f.label :elasticsearch_indexing, class: 'form-check-label' do
Elasticsearch indexing
- missing = !Gitlab::Elastic::Indexer.experimental_indexer_present?
.form-group
.form-check
= f.check_box :elasticsearch_experimental_indexer, disabled: missing, class: 'form-check-input'
= f.check_box :elasticsearch_experimental_indexer, disabled: missing, class: 'form-check-input', data: { qa_selector: 'experimental_indexer_checkbox' }
= f.label :elasticsearch_experimental_indexer, class: 'form-check-label' do
Use the <a href="https://gitlab.com/gitlab-org/gitlab-elasticsearch-indexer">new repository indexer (beta)</a>
- if missing
......@@ -36,13 +36,13 @@
.form-group
.form-check
= f.check_box :elasticsearch_search, class: 'form-check-input'
= f.check_box :elasticsearch_search, class: 'form-check-input', data: { qa_selector: 'search_checkbox' }
= f.label :elasticsearch_search, class: 'form-check-label' do
Search with Elasticsearch enabled
.form-group
= f.label :elasticsearch_url, 'URL', class: 'label-bold'
= f.text_field :elasticsearch_url, value: @application_setting.elasticsearch_url.join(', '), class: 'form-control', placeholder: 'http://localhost:9200'
= f.text_field :elasticsearch_url, value: @application_setting.elasticsearch_url.join(', '), class: 'form-control', placeholder: 'http://localhost:9200', data: { qa_selector: 'url_field' }
.form-text.text-muted
The url to use for connecting to Elasticsearch. Use a comma-separated list to support clustering (e.g., "http://localhost:9200, http://localhost:9201").
......@@ -101,7 +101,7 @@
.form-text.text-muted
AWS Secret Access Key. Only required if not using role instance credentials
= f.submit 'Save changes', class: "btn btn-success"
= f.submit 'Save changes', class: "btn btn-success", data: { qa_selector: 'submit_button' }
- if Feature.enabled?(:elasticsearch_web_indexing)
%br
......
......@@ -4,7 +4,7 @@
= _("Comments")
%span.badge.badge-pill
= limited_count(@search_results.notes_count)
%li{ class: active_when(@scope == 'blobs') }
%li{ class: active_when(@scope == 'blobs'), data: { qa_selector: 'code_tab' } }
= link_to search_filter_path(scope: 'blobs') do
= _("Code")
%span.badge.badge-pill
......
......@@ -314,6 +314,10 @@ module QA
autoload :Login, 'qa/page/mattermost/login'
end
module Search
autoload :Results, 'qa/page/search/results'
end
##
# Classes describing components that are used by several pages.
#
......
......@@ -49,6 +49,11 @@ module QA
module Settings
autoload :Templates, 'qa/ee/page/admin/settings/templates'
autoload :Integration, 'qa/ee/page/admin/settings/integration'
module Component
autoload :Elasticsearch, 'qa/ee/page/admin/settings/component/elasticsearch'
end
end
end
......@@ -111,6 +116,10 @@ module QA
module Geo
autoload :Node, 'qa/ee/resource/geo/node'
end
module Settings
autoload :Elasticsearch, 'qa/ee/resource/settings/elasticsearch'
end
end
module Scenario
......@@ -118,6 +127,7 @@ module QA
autoload :Geo, 'qa/ee/scenario/test/geo'
module Integration
autoload :GroupSAML, 'qa/ee/scenario/test/integration/group_saml'
autoload :Elasticsearch, 'qa/ee/scenario/test/integration/elasticsearch'
end
end
end
......
# frozen_string_literal: true
module QA
module EE
module Page
module Admin
module Settings
module Component
class Elasticsearch < QA::Page::Base
view 'ee/app/views/admin/application_settings/_elasticsearch_form.html.haml' do
element :indexing_checkbox
element :experimental_indexer_checkbox
element :search_checkbox
element :url_field
element :submit_button
end
def check_indexing
check_element :indexing_checkbox
end
def check_new_indexer
check_element :experimental_indexer_checkbox
end
def check_search
check_element :search_checkbox
end
def enter_link(link)
fill_element(:url_field, link)
end
def click_submit
click_element(:submit_button)
end
end
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module EE
module Page
module Admin
module Settings
class Integration < QA::Page::Base
include QA::Page::Settings::Common
view 'ee/app/views/admin/application_settings/_elasticsearch_form.html.haml' do
element :elasticsearch_tab
end
def expand_elasticsearch(&block)
expand_section(:elasticsearch_tab) do
Component::Elasticsearch.perform(&block)
end
end
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module EE
module Resource
module Settings
class Elasticsearch < QA::Resource::Base
attr_accessor :es_enabled
attr_accessor :es_indexing
attr_accessor :es_url
attr_accessor :es_experimental_indexer
def initialize
@es_enabled = true
@es_indexing = true
@es_experimental_indexer = true
@es_url = 'http://elastic68:9200'
end
def fabricate!
QA::Page::Main::Menu.perform(&:click_admin_area)
QA::Page::Admin::Menu.perform(&:go_to_integration_settings)
QA::EE::Page::Admin::Settings::Integration.perform do |integration|
integration.expand_elasticsearch do |es|
es.check_indexing if @es_indexing
es.check_new_indexer if @es_experimental_indexer
es.check_search if @es_enabled
es.enter_link(@es_url)
es.click_submit
end
end
end
def fabricate_via_api!
@es_enabled ? api_post : resource_web_url(api_get)
end
def resource_web_url(resource)
super
rescue ResourceURLMissingError
# this particular resource does not expose a web_url property
end
def api_get_path
"/application/settings"
end
def api_post_path
"/application/settings"
end
def api_post_body
{
elasticsearch_search: @es_enabled,
elasticsearch_indexing: @es_indexing,
elasticsearch_experimental_indexer: @es_experimental_indexer,
elasticsearch_url: @es_url
}
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module EE
module Scenario
module Test
module Integration
class Elasticsearch < QA::Scenario::Test::Instance::All
tags :elasticsearch
end
end
end
end
end
end
......@@ -15,6 +15,10 @@ module QA
element :admin_settings_metrics_and_profiling_item
end
view 'app/views/layouts/nav/sidebar/_admin.html.haml' do
element :integration_settings_link
end
def go_to_repository_settings
hover_settings do
within_submenu do
......@@ -23,6 +27,14 @@ module QA
end
end
def go_to_integration_settings
hover_settings do
within_submenu do
click_element :integration_settings_link
end
end
end
def go_to_general_settings
hover_settings do
within_submenu do
......
......@@ -27,6 +27,10 @@ module QA
element :your_projects_link
end
view 'app/views/layouts/_search.html.haml' do
element :search_term_field
end
def go_to_groups
within_top_menu do
click_element :groups_dropdown
......@@ -71,6 +75,10 @@ module QA
click_element :snippets_link
end
def search_for(term)
fill_element :search_term_field, "#{term}\n"
end
def has_personal_area?(wait: Capybara.default_max_wait_time)
has_element?(:user_avatar, wait: wait)
end
......
# frozen_string_literal: true
module QA::Page
module Search
class Results < QA::Page::Base
view 'app/views/search/_category.html.haml' do
element :code_tab
end
view 'app/views/search/results/_blob_data.html.haml' do
element :result_item_content
element :file_title_content
element :file_text_content
end
def switch_to_code
click_element(:code_tab)
end
def has_file_in_project?(file_name, project_name)
has_element? :result_item_content, text: "#{project_name}: #{file_name}"
end
def has_file_with_content?(file_name, file_text)
within_element_by_index :result_item_content, 0 do
false unless has_element? :file_title_content, text: file_name
has_element? :file_text_content, text: file_text
end
end
end
end
end
# frozen_string_literal: true
module QA
context 'Create' do
describe 'Search using Elasticsearch', :orchestrated, :elasticsearch do
include Runtime::Fixtures
before do
project_name = 'testing_elasticsearch_indexing'
@project_file_name = 'elasticsearch.rb'
@project_file_content = 'elasticsearch: true'
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
QA::EE::Resource::Settings::Elasticsearch.fabricate_via_browser_ui!
@project = Resource::Project.fabricate_via_api! do |project|
project.name = project_name
end
Resource::Repository::ProjectPush.fabricate! do |push|
push.project = @project
push.file_name = @project_file_name
push.file_content = @project_file_content
end
end
it 'tests reindexing after push' do
QA::Page::Main::Menu.perform do |menu|
menu.search_for(@project_file_content)
end
Page::Search::Results.perform do |search|
search.switch_to_code
expect(search).to have_file_with_content @project_file_name, @project_file_content
end
end
it 'tests reindexing after webIDE' do
template = {
file_name: 'LICENSE',
name: 'Mozilla Public License 2.0',
api_path: 'licenses',
api_key: 'mpl-2.0'
}
content = fetch_template_from_api(template[:api_path], template[:api_key])
Page::Project::Show.perform(&:open_web_ide!)
Page::Project::WebIDE::Edit.perform do |ide|
ide.create_new_file_from_template template[:file_name], template[:name]
ide.commit_changes
end
Page::Main::Menu.perform(&:go_to_groups)
QA::Page::Main::Menu.perform do |menu|
menu.search_for content[0..33]
end
Page::Search::Results.perform do |search|
search.switch_to_code
expect(search).to have_file_in_project template[:file_name], @project.name
expect(search).to have_file_with_content template[:file_name], content[0..33]
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