Commit ed8abf6a authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'sh-fix-issue-202678' into 'master'

Fix time-dependent spec failures in user_sees_error_details_spec.rb

Closes #202678

See merge request gitlab-org/gitlab!24718
parents f8d712d5 958d868a
...@@ -11,17 +11,25 @@ shared_context 'sentry error tracking context feature' do ...@@ -11,17 +11,25 @@ shared_context 'sentry error tracking context feature' do
let_it_be(:event_response) { JSON.parse(event_response_body) } let_it_be(:event_response) { JSON.parse(event_response_body) }
let(:sentry_api_urls) { Sentry::ApiUrls.new(project_error_tracking_settings.api_url) } let(:sentry_api_urls) { Sentry::ApiUrls.new(project_error_tracking_settings.api_url) }
let(:issue_id) { issue_response['id'] } let(:issue_id) { issue_response['id'] }
let(:issue_seen) { 1.year.ago.utc }
let(:formatted_issue_seen) { issue_seen.strftime("%Y-%m-%d %I:%M:%S%p %Z") }
let(:date_received) { 1.month.ago.utc }
before do before do
request_headers = { 'Authorization' => 'Bearer access_token_123', 'Content-Type' => 'application/json' } request_headers = { 'Authorization' => 'Bearer access_token_123', 'Content-Type' => 'application/json' }
response_headers = { 'Content-Type' => 'application/json' } response_headers = { 'Content-Type' => 'application/json' }
issue_response['firstSeen'] = issue_seen.iso8601(6)
issue_response['lastSeen'] = issue_seen.iso8601(6)
event_response['dateReceived'] = date_received.iso8601(6)
issue_url = sentry_api_urls.issue_url(issue_id).to_s issue_url = sentry_api_urls.issue_url(issue_id).to_s
stub_request(:get, issue_url) stub_request(:get, issue_url)
.with(headers: request_headers) .with(headers: request_headers)
.to_return(status: 200, body: issue_response_body, headers: response_headers) .to_return(status: 200, body: issue_response.to_json, headers: response_headers)
event_url = sentry_api_urls.issue_latest_event_url(issue_id).to_s event_url = sentry_api_urls.issue_latest_event_url(issue_id).to_s
stub_request(:get, event_url) stub_request(:get, event_url)
.with(headers: request_headers) .with(headers: request_headers)
.to_return(status: 200, body: event_response_body, headers: response_headers) .to_return(status: 200, body: event_response.to_json, headers: response_headers)
end end
end end
...@@ -24,13 +24,11 @@ shared_examples 'error tracking index page' do ...@@ -24,13 +24,11 @@ shared_examples 'error tracking index page' do
end end
it 'renders the error index data' do it 'renders the error index data' do
Timecop.freeze(2020, 01, 01, 12, 0, 0) do within('div.error-list') do
within('div.error-list') do expect(page).to have_content(issues_response[0]['title'])
expect(page).to have_content(issues_response[0]['title']) expect(page).to have_content(issues_response[0]['count'].to_s)
expect(page).to have_content(issues_response[0]['count'].to_s) expect(page).to have_content(issues_response[0]['last_seen'])
expect(page).to have_content(issues_response[0]['last_seen']) expect(page).to have_content('1 year ago')
expect(page).to have_content('1 year ago')
end
end end
end end
end end
...@@ -54,17 +52,15 @@ shared_examples 'error tracking show page' do ...@@ -54,17 +52,15 @@ shared_examples 'error tracking show page' do
it 'renders the error details' do it 'renders the error details' do
release_short_version = issue_response['firstRelease']['shortVersion'] release_short_version = issue_response['firstRelease']['shortVersion']
Timecop.freeze(2020, 01, 01, 12, 0, 0) do expect(page).to have_content('1 month ago by raven.scripts.runner in main')
expect(page).to have_content('1 month ago by raven.scripts.runner in main') expect(page).to have_content(issue_response['metadata']['title'])
expect(page).to have_content(issue_response['metadata']['title']) expect(page).to have_content('level: error')
expect(page).to have_content('level: error') expect(page).to have_content('Error Details')
expect(page).to have_content('Error Details') expect(page).to have_content('GitLab Issue: https://gitlab.com/gitlab-org/gitlab/issues/1')
expect(page).to have_content('GitLab Issue: https://gitlab.com/gitlab-org/gitlab/issues/1') expect(page).to have_content("Sentry event: https://sentrytest.gitlab.com/sentry-org/sentry-project/issues/#{issue_id}")
expect(page).to have_content("Sentry event: https://sentrytest.gitlab.com/sentry-org/sentry-project/issues/#{issue_id}") expect(page).to have_content("First seen: 1 year ago (#{formatted_issue_seen}) Release: #{release_short_version}")
expect(page).to have_content("First seen: 1 year ago (2018-11-06 9:19:55PM UTC) Release: #{release_short_version}") expect(page).to have_content('Events: 1')
expect(page).to have_content('Events: 1') expect(page).to have_content('Users: 0')
expect(page).to have_content('Users: 0')
end
end end
it 'renders the stack trace heading' do it 'renders the stack trace heading' do
......
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