2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-16 23:09:34 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe 'Tooltips on .timeago dates', :js 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) }
|
|
|
|
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
|
2020-06-23 00:09:42 +05:30
|
|
|
Event.create( project: project, author_id: user.id, action: :joined,
|
2016-06-16 23:09:34 +05:30
|
|
|
updated_at: created_date, created_at: created_date)
|
|
|
|
|
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
|
2020-11-24 15:15:51 +05:30
|
|
|
expect(page).to have_selector('.js-timeago.snippet-created-ago', text: '1 day ago')
|
|
|
|
|
|
|
|
page.find('.js-timeago.snippet-created-ago').hover
|
|
|
|
|
|
|
|
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
|