2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-16 23:09:34 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
RSpec.describe 'Tooltips on .timeago dates', :js, feature_category: :users do
|
2020-11-24 15:15:51 +05:30
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:project) { create(:project, name: 'test', namespace: user.namespace) }
|
2021-09-30 23:02:18 +05:30
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
let(:created_date) { 1.day.ago.beginning_of_minute - 1.hour }
|
|
|
|
|
|
|
|
before_all do
|
|
|
|
project.add_maintainer(user)
|
|
|
|
end
|
2016-06-16 23:09:34 +05:30
|
|
|
|
|
|
|
context 'on the activity tab' do
|
|
|
|
before do
|
2023-01-13 00:05:48 +05:30
|
|
|
Event.create!(project: project, author_id: user.id, action: :joined,
|
|
|
|
updated_at: created_date, created_at: created_date)
|
2016-06-16 23:09:34 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in user
|
2018-12-05 23:21:45 +05:30
|
|
|
visit user_activity_path(user)
|
2019-03-02 22:35:43 +05:30
|
|
|
wait_for_requests
|
2016-06-16 23:09:34 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the datetime formated correctly' do
|
2020-11-24 15:15:51 +05:30
|
|
|
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-06-16 23:09:34 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'on the snippets tab' do
|
|
|
|
before do
|
|
|
|
create(:snippet, author: user, updated_at: created_date, created_at: created_date)
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in user
|
2016-06-16 23:09:34 +05:30
|
|
|
visit user_snippets_path(user)
|
2019-03-02 22:35:43 +05:30
|
|
|
wait_for_requests
|
2016-06-16 23:09:34 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the datetime formated correctly' do
|
2022-11-25 23:54:43 +05:30
|
|
|
expect(page).to have_selector('[data-testid=snippet-created-at] .js-timeago', text: '1 day ago')
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
page.find('[data-testid=snippet-created-at] .js-timeago').hover
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
expect(datetime_in_tooltip).to eq(created_date)
|
2016-06-16 23:09:34 +05:30
|
|
|
end
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
def datetime_in_tooltip
|
2021-01-29 00:20:46 +05:30
|
|
|
datetime_text = page.find('.tooltip').text
|
2020-11-24 15:15:51 +05:30
|
|
|
DateTime.parse(datetime_text)
|
|
|
|
end
|
2016-06-16 23:09:34 +05:30
|
|
|
end
|