2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-05-25 19:32:37 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 18:09:01 +00:00
|
|
|
RSpec.describe 'Tooltips on .timeago dates', :js do
|
2020-09-11 09:08:44 +00:00
|
|
|
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-05-25 19:32:37 +00:00
|
|
|
|
|
|
|
context 'on the activity tab' do
|
|
|
|
before do
|
2021-04-06 06:09:00 +00:00
|
|
|
Event.create!( project: project, author_id: user.id, action: :joined,
|
2016-05-25 19:32:37 +00:00
|
|
|
updated_at: created_date, created_at: created_date)
|
|
|
|
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in user
|
2018-10-04 07:55:37 +00:00
|
|
|
visit user_activity_path(user)
|
2019-01-24 13:43:02 +00:00
|
|
|
wait_for_requests
|
2016-05-25 19:32:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the datetime formated correctly' do
|
2020-09-11 09:08:44 +00: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 19:32:37 +00: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 23:44:10 +00:00
|
|
|
sign_in user
|
2016-05-25 19:32:37 +00:00
|
|
|
visit user_snippets_path(user)
|
2019-01-24 13:43:02 +00:00
|
|
|
wait_for_requests
|
2016-05-25 19:32:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has the datetime formated correctly' do
|
2020-09-11 09:08:44 +00:00
|
|
|
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-05-25 19:32:37 +00:00
|
|
|
end
|
|
|
|
end
|
2020-09-11 09:08:44 +00:00
|
|
|
|
|
|
|
def datetime_in_tooltip
|
2020-11-12 12:09:39 +00:00
|
|
|
datetime_text = page.find('.tooltip').text
|
2020-09-11 09:08:44 +00:00
|
|
|
DateTime.parse(datetime_text)
|
|
|
|
end
|
2016-05-25 19:32:37 +00:00
|
|
|
end
|