debian-mirror-gitlab/spec/features/dashboard/datetime_on_tooltips_spec.rb

57 lines
1.4 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
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) }
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
context 'on the activity tab' do
before do
2021-04-29 21:17:54 +05:30
Event.create!( project: project, author_id: user.id, action: :joined,
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
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)
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
visit user_snippets_path(user)
2019-03-02 22:35:43 +05:30
wait_for_requests
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)
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
end