blob: 4e9d74a51179be3e0d8b82dce01547ebfe2fbcb2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# frozen_string_literal: true
module QA
RSpec.describe 'Plan', :orchestrated, :smtp, :reliable, product_group: :project_management do
describe 'Email Notification' do
include Support::API
let!(:user) do
Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1)
end
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'email-notification-test'
end
end
before do
Flow::Login.sign_in
end
it 'is received by a user for project invitation', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347961' do
project.visit!
Page::Project::Menu.perform(&:click_members)
Page::Project::Members.perform do |member_settings|
member_settings.add_member(user.username)
end
expect(page).to have_content("@#{user.username}")
mailhog_items = mailhog_json.dig('items')
expect(mailhog_items).to include(an_object_satisfying { |o| /project was granted/ === mailhog_item_subject(o) })
end
private
def mailhog_json
Support::Retrier.retry_until(sleep_interval: 1) do
Runtime::Logger.debug(%Q[retrieving "#{QA::Runtime::MailHog.api_messages_url}"])
mailhog_response = get QA::Runtime::MailHog.api_messages_url
mailhog_data = JSON.parse(mailhog_response.body)
total = mailhog_data.dig('total')
subjects = mailhog_data.dig('items')
.map { |item| mailhog_item_subject(item) }
Runtime::Logger.debug(%Q[Total number of emails: #{total}])
Runtime::Logger.debug(%Q[Subjects:\n#{subjects.join("\n")}])
# Expect at least two invitation messages: group and project
mailhog_data if mailhog_project_message_count(subjects) >= 1
end
end
def mailhog_item_subject(item)
item.dig('Content', 'Headers', 'Subject', 0)
end
def mailhog_project_message_count(subjects)
subjects.count { |subject| subject.include?('project was granted') }
end
end
end
end
|