2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
RSpec.describe 'Project Network Graph', :js, feature_category: :projects do
|
2018-03-27 19:54:05 +05:30
|
|
|
let(:user) { create :user }
|
|
|
|
let(:project) { create :project, :repository, namespace: user.namespace }
|
2023-04-23 21:23:45 +05:30
|
|
|
let(:ref_selector) { '.ref-selector' }
|
2018-03-27 19:54:05 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
# Stub Graph max_size to speed up test (10 commits vs. 650)
|
|
|
|
allow(Network::Graph).to receive(:max_count).and_return(10)
|
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
shared_examples 'network graph' do
|
|
|
|
context 'when branch is master' do
|
|
|
|
def switch_ref_to(ref_name)
|
2023-04-23 21:23:45 +05:30
|
|
|
first(ref_selector).click
|
|
|
|
wait_for_requests
|
2023-01-13 00:05:48 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
page.within ref_selector do
|
|
|
|
fill_in 'Search by Git revision', with: ref_name
|
|
|
|
wait_for_requests
|
|
|
|
find('li', text: ref_name, match: :prefer_exact).click
|
2023-01-13 00:05:48 +05:30
|
|
|
end
|
2018-03-27 19:54:05 +05:30
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
def click_show_only_selected_branch_checkbox
|
|
|
|
find('#filter_ref').click
|
|
|
|
end
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
before do
|
|
|
|
visit project_network_path(project, 'master')
|
|
|
|
end
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
it 'renders project network' do
|
|
|
|
expect(page).to have_selector ".network-graph"
|
2023-04-23 21:23:45 +05:30
|
|
|
expect(page).to have_selector ref_selector, text: "master"
|
2023-01-13 00:05:48 +05:30
|
|
|
page.within '.network-graph' do
|
|
|
|
expect(page).to have_content 'master'
|
|
|
|
end
|
2018-03-27 19:54:05 +05:30
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
it 'switches ref to branch' do
|
|
|
|
switch_ref_to('feature')
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
expect(page).to have_selector ref_selector, text: 'feature'
|
2023-01-13 00:05:48 +05:30
|
|
|
page.within '.network-graph' do
|
|
|
|
expect(page).to have_content 'feature'
|
|
|
|
end
|
2018-03-27 19:54:05 +05:30
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
it 'switches ref to tag' do
|
|
|
|
switch_ref_to('v1.0.0')
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
expect(page).to have_selector ref_selector, text: 'v1.0.0'
|
2023-01-13 00:05:48 +05:30
|
|
|
page.within '.network-graph' do
|
|
|
|
expect(page).to have_content 'v1.0.0'
|
|
|
|
end
|
2018-03-27 19:54:05 +05:30
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
it 'renders by commit sha of "v1.0.0"' do
|
|
|
|
page.within ".network-form" do
|
|
|
|
fill_in 'extended_sha1', with: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9'
|
|
|
|
find('button').click
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_selector ".network-graph"
|
2023-04-23 21:23:45 +05:30
|
|
|
expect(page).to have_selector ref_selector, text: "master"
|
2023-01-13 00:05:48 +05:30
|
|
|
page.within '.network-graph' do
|
|
|
|
expect(page).to have_content 'v1.0.0'
|
|
|
|
end
|
2018-03-27 19:54:05 +05:30
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
it 'filters select tag' do
|
|
|
|
switch_ref_to('v1.0.0')
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
expect(page).to have_css 'title', text: 'Graph · v1.0.0', visible: false
|
|
|
|
page.within '.network-graph' do
|
|
|
|
expect(page).to have_content 'Change some files'
|
|
|
|
end
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
click_show_only_selected_branch_checkbox
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
page.within '.network-graph' do
|
|
|
|
expect(page).not_to have_content 'Change some files'
|
|
|
|
end
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
click_show_only_selected_branch_checkbox
|
|
|
|
|
|
|
|
page.within '.network-graph' do
|
|
|
|
expect(page).to have_content 'Change some files'
|
|
|
|
end
|
2018-03-27 19:54:05 +05:30
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
it 'renders error message when sha commit not exists' do
|
|
|
|
page.within ".network-form" do
|
|
|
|
fill_in 'extended_sha1', with: ';'
|
|
|
|
find('button').click
|
|
|
|
end
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
expect(page).to have_selector '[data-testid="alert-danger"]', text: "Git revision ';' does not exist."
|
2018-03-27 19:54:05 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
it 'renders project network with test branch' do
|
|
|
|
visit project_network_path(project, "'test'")
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
page.within '.network-graph' do
|
|
|
|
expect(page).to have_content "'test'"
|
|
|
|
end
|
2018-03-27 19:54:05 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
it_behaves_like 'network graph'
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
context 'when disable_network_graph_notes_count is disabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(disable_network_graph_notes_count: false)
|
2018-03-27 19:54:05 +05:30
|
|
|
end
|
2023-01-13 00:05:48 +05:30
|
|
|
|
|
|
|
it_behaves_like 'network graph'
|
2018-03-27 19:54:05 +05:30
|
|
|
end
|
|
|
|
end
|