diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-31 06:08:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-31 06:08:13 +0300 |
commit | 25805c16335ed6466f0e475417e3005cd09848c2 (patch) | |
tree | 59e83dff33c409d33b6cfac4c1bfd8e310eadb78 /qa/lib | |
parent | 13ddda5208f9175e822af6d05a32600bc9cad091 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa/lib')
-rw-r--r-- | qa/lib/slack.rb | 9 | ||||
-rw-r--r-- | qa/lib/slack/mixins/browser.rb | 11 | ||||
-rw-r--r-- | qa/lib/slack/mixins/gitlab_app.rb | 52 | ||||
-rw-r--r-- | qa/lib/slack/page/chat.rb | 68 | ||||
-rw-r--r-- | qa/lib/slack/page/login.rb | 40 | ||||
-rw-r--r-- | qa/lib/slack/page/oauth.rb | 9 |
6 files changed, 189 insertions, 0 deletions
diff --git a/qa/lib/slack.rb b/qa/lib/slack.rb new file mode 100644 index 00000000000..95e81b700f5 --- /dev/null +++ b/qa/lib/slack.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'chemlab/library' + +module Slack + include Chemlab::Library + + self.base_url = 'https://slack.com' +end diff --git a/qa/lib/slack/mixins/browser.rb b/qa/lib/slack/mixins/browser.rb new file mode 100644 index 00000000000..853ff2c7130 --- /dev/null +++ b/qa/lib/slack/mixins/browser.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Slack + module Mixins + module Browser + def browser + ::Chemlab.configuration.browser.session.engine + end + end + end +end diff --git a/qa/lib/slack/mixins/gitlab_app.rb b/qa/lib/slack/mixins/gitlab_app.rb new file mode 100644 index 00000000000..66b456ef824 --- /dev/null +++ b/qa/lib/slack/mixins/gitlab_app.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +module Slack + module Mixins + module GitlabApp + # @param [QA::Resource::Project] project + # @param [String] channel + # @param [String] title + # @param [String] description + def create_issue(project, channel:, title:, description:) + lines = [ + "/staging-gitlab #{project.path_with_namespace} issue new #{title}", + description + ] + + send_message_to_channel(lines, channel: channel) + end + + # @param [QA::Resource::Project] project + # @param [QA::Resource::Project] target + # @param [String] id + # @param [String] channel + def move_issue(project, target, id:, channel:) + line = "/staging-gitlab #{project.path_with_namespace} issue move #{id} to #{target.path_with_namespace}" + send_message_to_channel([line], channel: channel) + end + + # @param [QA::Resource::Project] project + # @param [String] id + # @param [String] channel + def show_issue(project, id:, channel:) + send_message_to_channel(["/staging-gitlab #{project.path_with_namespace} issue show #{id}"], channel: channel) + end + + # @param [QA::Resource::Project] project + # @param [String] id + # @param [String] channel + def close_issue(project, id:, channel:) + send_message_to_channel(["/staging-gitlab #{project.path_with_namespace} issue close #{id}"], channel: channel) + end + + # @param [QA::Resource::Project] project + # @param [String] channel + # @param [String] id + # @param [String] comment + def comment_on_issue(project, channel:, id:, comment:) + command = "/staging-gitlab #{project.path_with_namespace} issue comment #{id}" + send_message_to_channel([command, comment], channel: channel) + end + end + end +end diff --git a/qa/lib/slack/page/chat.rb b/qa/lib/slack/page/chat.rb new file mode 100644 index 00000000000..5f8553fc425 --- /dev/null +++ b/qa/lib/slack/page/chat.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true + +module Slack + module Page + class Chat < Chemlab::Page + include Mixins::Browser + include Mixins::GitlabApp + + div :message_field, data_qa: 'message_input' + button :connect_gitlab_button, visible_text: /Connect your GitLab account/ + button :skip_download_slack_button, data_qa: 'continue_in_browser' + + def skip_download_screen + wait_for_text('download the Slack app') + + skip_download_slack_button_element.click if skip_download_slack_button_element.exists? + end + + # @param [Array<String>] lines - messages to send + # @param [String] channel to send message to + def send_message_to_channel(lines, channel:) + go_to_channel(channel) + + message_field_element.focus + message_field_element.click + + while line = lines.shift + browser.send_keys(line) + wait_for_text(line) + + browser.send_keys([:shift, :enter]) unless lines.empty? + end + + browser.send_keys(:enter) + end + + def wait_for_text(line) + QA::Support::Waiter.wait_until(max_duration: 3, raise_on_failure: false) do + browser.text.include?(line) + end + end + + def go_to_channel(channel) + menu_item = messages.find do |div| + div.text == channel + end + menu_item.click + end + + def click_connect_account_link + divs = messages(visible_text: /connect your GitLab account/i) + el = divs.last.a(href: /staging-ref/) + el.scroll.to(:top) + el.click + end + + def messages(**opts) + browser.divs(data_qa: 'virtual-list-item', **opts) + end + + def gitlab_app_home + browser.divs(data_qa: 'channel_item_container').find do |el| + el.text == 'GitLab' + end + end + end + end +end diff --git a/qa/lib/slack/page/login.rb b/qa/lib/slack/page/login.rb new file mode 100644 index 00000000000..a11b0d27fd0 --- /dev/null +++ b/qa/lib/slack/page/login.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +module Slack + module Page + class Login < Chemlab::Page + path '/workspace-signin' + + text_field :workspace_field, data_qa: 'signin_domain_input' + button :continue_button, data_qa: 'submit_team_domain_button' + + link :sign_in_with_password_link, data_qa: 'sign_in_password_link' + + text_field :email_address_field, data_qa: 'login_email' + text_field :password_field, data_qa: 'login_password', type: 'password' + button :sign_in_button, data_qa: 'signin_button' + + def sign_in + navigate_to_workspace + + # sign into with password if needed + sign_in_with_password_link_element.click if sign_in_with_password_link_element.exists? + + finish_sign_in + end + + def navigate_to_workspace + self.workspace_field = ::QA::Runtime::Env.slack_workspace + continue_button + end + + def finish_sign_in + return unless email_address_field_element.exists? + + self.email_address_field = ::QA::Runtime::Env.slack_email + self.password_field = ::QA::Runtime::Env.slack_password + sign_in_button + end + end + end +end diff --git a/qa/lib/slack/page/oauth.rb b/qa/lib/slack/page/oauth.rb new file mode 100644 index 00000000000..700d19f0c4c --- /dev/null +++ b/qa/lib/slack/page/oauth.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Slack + module Page + class Oauth < Chemlab::Page + button :submit_oauth, data_qa: 'oauth_submit_button' + end + end +end |