summaryrefslogtreecommitdiff
path: root/qa/qa/flow/integrations/slack.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-02-20 13:49:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-20 13:49:51 +0000
commit71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e (patch)
tree6a2d93ef3fb2d353bb7739e4b57e6541f51cdd71 /qa/qa/flow/integrations/slack.rb
parenta7253423e3403b8c08f8a161e5937e1488f5f407 (diff)
downloadgitlab-ce-71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e.tar.gz
Add latest changes from gitlab-org/gitlab@15-9-stable-eev15.9.0-rc42
Diffstat (limited to 'qa/qa/flow/integrations/slack.rb')
-rw-r--r--qa/qa/flow/integrations/slack.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/qa/qa/flow/integrations/slack.rb b/qa/qa/flow/integrations/slack.rb
new file mode 100644
index 00000000000..8f18ccaa791
--- /dev/null
+++ b/qa/qa/flow/integrations/slack.rb
@@ -0,0 +1,54 @@
+# frozen_string_literal: true
+
+module QA
+ module Flow
+ module Integrations
+ module Slack
+ extend self
+
+ # Need to sign in for this method
+ # @param [QA::Resource::Project]
+ def start_slack_install(project)
+ project.visit!
+
+ Page::Project::Menu.perform do |project_menu_page|
+ project_menu_page.click_project
+ project_menu_page.go_to_integrations_settings
+ end
+
+ Page::Project::Settings::Integrations.perform(&:click_slack_application_link)
+
+ EE::Page::Project::Settings::Services::Slack.perform(&:start_slack_install)
+ ::Slack::Page::Oauth.perform(&:submit_oauth)
+ end
+
+ # @param [QA::Resource::Project] project
+ # @option [String | Nil] channel
+ # @return [Boolean] is this account already authorized?
+ def start_gitlab_connect(project, channel: nil)
+ ::Slack::Page::Chat.perform do |chat_page|
+ # sometimes Slack will present a blocking page
+ # for downloading the app instead of using a browser
+ chat_page.skip_download_screen
+
+ lines = ["/staging-gitlab #{project.path_with_namespace} issue show 1"]
+ chat_page.send_message_to_channel(lines, channel: channel)
+
+ # The only way to know if we are authorized is to send a slash command to the channel.
+ # If the account / chat_name is already authorized, the Slack app will try to look up the issue
+ # and return a 404 because it doesn't exist
+ QA::Support::Waiter.wait_until(max_duration: 4, raise_on_failure: false) do
+ chat_page.messages.last.text =~ /connect your GitLab account|404 not found!/i
+ end
+
+ break(true) if chat_page.messages.last.text =~ /404 not found!/i
+
+ chat_page.click_connect_account_link
+
+ false
+ end
+ end
+ end
+ end
+ end
+end