Commit 13d31fb2 authored by Sanad Liaquat's avatar Sanad Liaquat

E2E: Fix follow user activity spec

parent e37b3e45
...@@ -5,21 +5,27 @@ module QA ...@@ -5,21 +5,27 @@ module QA
describe 'User', :requires_admin do describe 'User', :requires_admin do
let(:admin_api_client) { Runtime::API::Client.as_admin } let(:admin_api_client) { Runtime::API::Client.as_admin }
let(:user) do let(:followed_user_api_client) { Runtime::API::Client.new(:gitlab, user: followed_user) }
let(:followed_user) do
Resource::User.fabricate_via_api! do |user| Resource::User.fabricate_via_api! do |user|
user.name = "followed_user_#{SecureRandom.hex(8)}"
user.api_client = admin_api_client user.api_client = admin_api_client
end end
end end
let(:user_api_client) do let(:following_user) do
Runtime::API::Client.new(:gitlab, user: user) Resource::User.fabricate_via_api! do |user|
user.name = "following_user_#{SecureRandom.hex(8)}"
user.api_client = admin_api_client
end
end end
let(:group) do let(:group) do
group = QA::Resource::Group.fabricate_via_api! do |group| group = QA::Resource::Group.fabricate_via_api! do |group|
group.path = "group_for_follow_user_activity_#{SecureRandom.hex(8)}" group.path = "group_for_follow_user_activity_#{SecureRandom.hex(8)}"
end end
group.add_member(user, Resource::Members::AccessLevel::MAINTAINER) group.add_member(followed_user, Resource::Members::AccessLevel::MAINTAINER)
group group
end end
...@@ -27,7 +33,7 @@ module QA ...@@ -27,7 +33,7 @@ module QA
Resource::Project.fabricate_via_api! do |project| Resource::Project.fabricate_via_api! do |project|
project.name = 'project-for-tags' project.name = 'project-for-tags'
project.initialize_with_readme = true project.initialize_with_readme = true
project.api_client = user_api_client project.api_client = followed_user_api_client
project.group = group project.group = group
end end
end end
...@@ -35,14 +41,14 @@ module QA ...@@ -35,14 +41,14 @@ module QA
let(:merge_request) do let(:merge_request) do
Resource::MergeRequest.fabricate_via_api! do |mr| Resource::MergeRequest.fabricate_via_api! do |mr|
mr.project = project mr.project = project
mr.api_client = user_api_client mr.api_client = followed_user_api_client
end end
end end
let(:issue) do let(:issue) do
Resource::Issue.fabricate_via_api! do |issue| Resource::Issue.fabricate_via_api! do |issue|
issue.project = project issue.project = project
issue.api_client = user_api_client issue.api_client = followed_user_api_client
end end
end end
...@@ -51,19 +57,19 @@ module QA ...@@ -51,19 +57,19 @@ module QA
project_issue_note.project = project project_issue_note.project = project
project_issue_note.issue = issue project_issue_note.issue = issue
project_issue_note.body = 'This is a comment' project_issue_note.body = 'This is a comment'
project_issue_note.api_client = user_api_client project_issue_note.api_client = followed_user_api_client
end end
end end
before do before do
# Create both tokens before logging in the first time so that we don't need to log out in the middle of the test # Create both tokens before logging in the first time so that we don't need to log out in the middle of the test
admin_api_client.personal_access_token admin_api_client.personal_access_token
user_api_client.personal_access_token followed_user_api_client.personal_access_token
end end
it 'can be followed and their activity seen', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347678' do it 'can be followed and their activity seen', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347678' do
Flow::Login.sign_in Flow::Login.sign_in(as: following_user)
page.visit Runtime::Scenario.gitlab_address + "/#{user.username}" page.visit Runtime::Scenario.gitlab_address + "/#{followed_user.username}"
Page::User::Show.perform(&:click_follow_user_link) Page::User::Show.perform(&:click_follow_user_link)
expect(page).to have_text("No activities found") expect(page).to have_text("No activities found")
...@@ -76,7 +82,7 @@ module QA ...@@ -76,7 +82,7 @@ module QA
Page::Main::Menu.perform(&:click_user_profile_link) Page::Main::Menu.perform(&:click_user_profile_link)
Page::User::Show.perform do |show| Page::User::Show.perform do |show|
show.click_following_link show.click_following_link
show.click_user_link(user.username) show.click_user_link(followed_user.username)
aggregate_failures do aggregate_failures do
expect(show).to have_activity('created project') expect(show).to have_activity('created project')
...@@ -88,9 +94,10 @@ module QA ...@@ -88,9 +94,10 @@ module QA
end end
after do after do
project.api_client = admin_api_client project&.api_client = admin_api_client
project.remove_via_api! project&.remove_via_api!
user.remove_via_api! followed_user&.remove_via_api!
following_user&.remove_via_api!
end 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