2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-05-25 15:32:37 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Tooltips on .timeago dates', :js do
|
2020-09-11 05:08:44 -04:00
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:project) { create(:project, name: 'test', namespace: user.namespace) }
|
2021-06-28 23:07:32 -04:00
|
|
|
|
2020-09-11 05:08:44 -04:00
|
|
|
let(:created_date) { 1.day.ago.beginning_of_minute - 1.hour }
|
|
|
|
|
|
|
|
before_all do
|
|
|
|
project.add_maintainer(user)
|
|
|
|
end
|
2016-05-25 15:32:37 -04:00
|
|
|
|
|
|
|
context 'on the activity tab' do
|
|
|
|
before do
|
2022-10-24 20:09:22 -04:00
|
|
|
Event.create!(project: project, author_id: user.id, action: :joined,
|
|
|
|
updated_at: created_date, created_at: created_date)
|
2016-05-25 15:32:37 -04:00
|
|
|
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in user
|
2018-10-04 03:55:37 -04:00
|
|
|
visit user_activity_path(user)
|
2019-01-24 08:43:02 -05:00
|
|
|
wait_for_requests
|
2016-05-25 15:32:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the datetime formated correctly' do
|
2020-09-11 05:08:44 -04:00
|
|
|
expect(page).to have_selector('.js-timeago', text: '1 day ago')
|
|
|
|
|
|
|
|
page.find('.js-timeago').hover
|
|
|
|
|
|
|
|
expect(datetime_in_tooltip).to eq(created_date)
|
2016-05-25 15:32:37 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'on the snippets tab' do
|
|
|
|
before do
|
|
|
|
create(:snippet, author: user, updated_at: created_date, created_at: created_date)
|
|
|
|
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in user
|
2016-05-25 15:32:37 -04:00
|
|
|
visit user_snippets_path(user)
|
2019-01-24 08:43:02 -05:00
|
|
|
wait_for_requests
|
2016-05-25 15:32:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the datetime formated correctly' do
|
2022-09-21 17:13:33 -04:00
|
|
|
expect(page).to have_selector('[data-testid=snippet-created-at] .js-timeago', text: '1 day ago')
|
2020-09-11 05:08:44 -04:00
|
|
|
|
2022-09-21 17:13:33 -04:00
|
|
|
page.find('[data-testid=snippet-created-at] .js-timeago').hover
|
2020-09-11 05:08:44 -04:00
|
|
|
|
|
|
|
expect(datetime_in_tooltip).to eq(created_date)
|
2016-05-25 15:32:37 -04:00
|
|
|
end
|
|
|
|
end
|
2020-09-11 05:08:44 -04:00
|
|
|
|
|
|
|
def datetime_in_tooltip
|
2020-11-12 07:09:39 -05:00
|
|
|
datetime_text = page.find('.tooltip').text
|
2020-09-11 05:08:44 -04:00
|
|
|
DateTime.parse(datetime_text)
|
|
|
|
end
|
2016-05-25 15:32:37 -04:00
|
|
|
end
|