Commit 0bf21d6a authored by Phil Hughes's avatar Phil Hughes

Fixed merge request widget tests

parent 2bc956cf
require 'spec_helper'
feature 'Merge request environments', :feature, :js do
include WaitForAjax
it 'shows environments link' do
project = create(:project)
merge_request = create(:merge_request, source_project: project)
environment = create(:environment, project: project)
create(:deployment, environment: environment, ref: 'feature', sha: merge_request.diff_head_sha)
login_as :admin
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
wait_for_ajax
page.within('.mr-widget-heading') do
expect(page).to have_content("Deployed to #{environment.name}")
expect(find('.js-environment-link')[:href]).to include(environment.formatted_external_url)
end
end
end
require 'rails_helper'
describe 'Merge request', :feature, :js do
include WaitForAjax
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:merge_request) { create(:merge_request, source_project: project) }
before do
project.team << [user, :master]
login_as(user)
end
context 'new merge request' do
before do
visit new_namespace_project_merge_request_path(
project.namespace,
project,
merge_request: {
source_project_id: project.id,
target_project_id: project.id,
source_branch: 'feature',
target_branch: 'master'
}
)
end
it 'shows widget status after creating new merge request' do
click_button 'Submit merge request'
expect(find('.mr-state-widget')).to have_content('Checking ability to merge automatically')
wait_for_ajax
expect(page).to have_selector('.accept_merge_request')
end
end
context 'view merge request' do
let!(:environment) { create(:environment, project: project) }
let!(:deployment) { create(:deployment, environment: environment, ref: 'feature', sha: merge_request.diff_head_sha) }
before do
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end
it 'shows environments link' do
wait_for_ajax
page.within('.mr-widget-heading') do
expect(page).to have_content("Deployed to #{environment.name}")
expect(find('.js-environment-link')[:href]).to include(environment.formatted_external_url)
end
end
end
end
/* eslint-disable space-before-function-paren, quotes, comma-dangle, dot-notation, quote-props, no-var, max-len */
/*= require smart_interval */
/*= require merge_request_widget */
/*= require lib/utils/datetime_utility */
......@@ -73,7 +74,7 @@
}
it('should render less than a minute ago text', function() {
spyOn(this.class.$widgetBody, 'before').and.callFake(function(template) {
spyOn($('.mr-widget-body'), 'before').and.callFake(function(template) {
expect(getTimeagoText(template)).toBe('less than a minute ago.');
});
......@@ -85,7 +86,7 @@
oneHourAgo.setHours(oneHourAgo.getHours() - 1);
this.environments[0].deployed_at = oneHourAgo.toISOString();
spyOn(this.class.$widgetBody, 'before').and.callFake(function(template) {
spyOn($('.mr-widget-body'), 'before').and.callFake(function(template) {
expect(getTimeagoText(template)).toBe('about an hour ago.');
});
......@@ -97,7 +98,7 @@
twoHoursAgo.setHours(twoHoursAgo.getHours() - 2);
this.environments[0].deployed_at = twoHoursAgo.toISOString();
spyOn(this.class.$widgetBody, 'before').and.callFake(function(template) {
spyOn($('.mr-widget-body'), 'before').and.callFake(function(template) {
expect(getTimeagoText(template)).toBe('about 2 hours ago.');
});
......@@ -108,7 +109,7 @@
describe('mergeInProgress', function() {
it('should display error with h4 tag', function() {
spyOn(this.class.$widgetBody, 'html').and.callFake(function(html) {
spyOn($('.mr-widget-body'), 'html').and.callFake(function(html) {
expect(html).toBe('<h4>Sorry, something went wrong.</h4>');
});
spyOn($, 'ajax').and.callFake(function(e) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment