Commit 8d5fb3c7 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch 'nfriend-update-releases-index-rspec-for-apollo-client-ff' into 'master'

Run releases feature specs with feature flag enabled and disabled

See merge request gitlab-org/gitlab!63332
parents 9bb6286f 5b0e5272
...@@ -76,6 +76,7 @@ export default { ...@@ -76,6 +76,7 @@ export default {
<gl-sorting <gl-sorting
:text="sortText" :text="sortText"
:is-ascending="isDirectionAscending" :is-ascending="isDirectionAscending"
data-testid="releases-sort"
@sortDirectionChange="onDirectionChange" @sortDirectionChange="onDirectionChange"
> >
<gl-sorting-item <gl-sorting-item
......
...@@ -15,134 +15,151 @@ RSpec.describe 'User views releases', :js do ...@@ -15,134 +15,151 @@ RSpec.describe 'User views releases', :js do
let_it_be(:guest) { create(:user) } let_it_be(:guest) { create(:user) }
before do before do
stub_feature_flags(releases_index_apollo_client: false)
project.add_maintainer(maintainer) project.add_maintainer(maintainer)
project.add_guest(guest) project.add_guest(guest)
end end
context('when the user is a maintainer') do shared_examples 'releases index page' do
before do context('when the user is a maintainer') do
sign_in(maintainer) before do
sign_in(maintainer)
visit project_releases_path(project)
end
it 'sees the release' do visit project_releases_path(project)
page.within("##{release_v1.tag}") do
expect(page).to have_content(release_v1.name)
expect(page).to have_content(release_v1.tag)
expect(page).not_to have_content('Upcoming Release')
end end
end
context 'when there is a link as an asset' do
let!(:release_link) { create(:release_link, release: release_v1, url: url ) }
let(:url) { "#{project.web_url}/-/jobs/1/artifacts/download" }
let(:direct_asset_link) { Gitlab::Routing.url_helpers.project_release_url(project, release_v1) << "/downloads#{release_link.filepath}" }
it 'sees the link' do it 'sees the release' do
page.within("##{release_v1.tag} .js-assets-list") do page.within("##{release_v1.tag}") do
expect(page).to have_link release_link.name, href: direct_asset_link expect(page).to have_content(release_v1.name)
expect(page).not_to have_css('[data-testid="external-link-indicator"]') expect(page).to have_content(release_v1.tag)
expect(page).not_to have_content('Upcoming Release')
end end
end end
context 'when there is a link redirect' do context 'when there is a link as an asset' do
let!(:release_link) { create(:release_link, release: release_v1, name: 'linux-amd64 binaries', filepath: '/binaries/linux-amd64', url: url) } let!(:release_link) { create(:release_link, release: release_v1, url: url ) }
let(:url) { "#{project.web_url}/-/jobs/1/artifacts/download" } let(:url) { "#{project.web_url}/-/jobs/1/artifacts/download" }
let(:direct_asset_link) { Gitlab::Routing.url_helpers.project_release_url(project, release_v1) << "/downloads#{release_link.filepath}" }
it 'sees the link', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/329301' do it 'sees the link' do
page.within("##{release_v1.tag} .js-assets-list") do page.within("##{release_v1.tag} .js-assets-list") do
expect(page).to have_link release_link.name, href: direct_asset_link expect(page).to have_link release_link.name, href: direct_asset_link
expect(page).not_to have_css('[data-testid="external-link-indicator"]') expect(page).not_to have_css('[data-testid="external-link-indicator"]')
end end
end end
end
context 'when url points to external resource' do context 'when there is a link redirect' do
let(:url) { 'http://google.com/download' } let!(:release_link) { create(:release_link, release: release_v1, name: 'linux-amd64 binaries', filepath: '/binaries/linux-amd64', url: url) }
let(:url) { "#{project.web_url}/-/jobs/1/artifacts/download" }
it 'sees that the link is external resource', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/329302' do it 'sees the link', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/329301' do
page.within("##{release_v1.tag} .js-assets-list") do page.within("##{release_v1.tag} .js-assets-list") do
expect(page).to have_css('[data-testid="external-link-indicator"]') expect(page).to have_link release_link.name, href: direct_asset_link
expect(page).not_to have_css('[data-testid="external-link-indicator"]')
end
end
end
context 'when url points to external resource' do
let(:url) { 'http://google.com/download' }
it 'sees that the link is external resource', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/329302' do
page.within("##{release_v1.tag} .js-assets-list") do
expect(page).to have_css('[data-testid="external-link-indicator"]')
end
end end
end end
end end
end
context 'with an upcoming release' do context 'with an upcoming release' do
it 'sees the upcoming tag' do it 'sees the upcoming tag' do
page.within("##{release_v3.tag}") do page.within("##{release_v3.tag}") do
expect(page).to have_content('Upcoming Release') expect(page).to have_content('Upcoming Release')
end
end end
end end
end
context 'with a tag containing a slash' do context 'with a tag containing a slash' do
it 'sees the release' do it 'sees the release' do
page.within("##{release_v2.tag.parameterize}") do page.within("##{release_v2.tag.parameterize}") do
expect(page).to have_content(release_v2.name) expect(page).to have_content(release_v2.name)
expect(page).to have_content(release_v2.tag) expect(page).to have_content(release_v2.tag)
end
end end
end end
end
context 'sorting' do context 'sorting' do
def sort_page(by:, direction:) def sort_page(by:, direction:)
within '[data-testid="releases-sort"]' do within '[data-testid="releases-sort"]' do
find('.dropdown-toggle').click find('.dropdown-toggle').click
click_button(by, class: 'dropdown-item') click_button(by, class: 'dropdown-item')
find('.sorting-direction-button').click if direction == :ascending find('.sorting-direction-button').click if direction == :ascending
end
end end
end
shared_examples 'releases sort order' do shared_examples 'releases sort order' do
it "sorts the releases #{description}" do it "sorts the releases #{description}" do
card_titles = page.all('.release-block .card-title', minimum: expected_releases.count) card_titles = page.all('.release-block .card-title', minimum: expected_releases.count)
card_titles.each_with_index do |title, index| card_titles.each_with_index do |title, index|
expect(title).to have_content(expected_releases[index].name) expect(title).to have_content(expected_releases[index].name)
end
end end
end end
end
context "when the page is sorted by the default sort order" do context "when the page is sorted by the default sort order" do
let(:expected_releases) { [release_v3, release_v2, release_v1] } let(:expected_releases) { [release_v3, release_v2, release_v1] }
it_behaves_like 'releases sort order' it_behaves_like 'releases sort order'
end end
context "when the page is sorted by created_at ascending " do context "when the page is sorted by created_at ascending " do
let(:expected_releases) { [release_v2, release_v1, release_v3] } let(:expected_releases) { [release_v2, release_v1, release_v3] }
before do before do
sort_page by: 'Created date', direction: :ascending sort_page by: 'Created date', direction: :ascending
end
it_behaves_like 'releases sort order'
end end
end
end
context('when the user is a guest') do
before do
sign_in(guest)
end
it 'renders release info except for Git-related data' do
visit project_releases_path(project)
within('.release-block', match: :first) do
expect(page).to have_content(release_v3.description)
it_behaves_like 'releases sort order' # The following properties (sometimes) include Git info,
# so they are not rendered for Guest users
expect(page).not_to have_content(release_v3.name)
expect(page).not_to have_content(release_v3.tag)
expect(page).not_to have_content(release_v3.commit.short_id)
end
end end
end end
end end
context('when the user is a guest') do context 'when the releases_index_apollo_client feature flag is enabled' do
before do before do
sign_in(guest) stub_feature_flags(releases_index_apollo_client: true)
end end
it 'renders release info except for Git-related data' do it_behaves_like 'releases index page'
visit project_releases_path(project) end
within('.release-block', match: :first) do
expect(page).to have_content(release_v3.description)
# The following properties (sometimes) include Git info, context 'when the releases_index_apollo_client feature flag is disabled' do
# so they are not rendered for Guest users before do
expect(page).not_to have_content(release_v3.name) stub_feature_flags(releases_index_apollo_client: false)
expect(page).not_to have_content(release_v3.tag)
expect(page).not_to have_content(release_v3.commit.short_id)
end
end end
it_behaves_like 'releases index page'
end end
end end
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