Commit c0192281 authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera Committed by David Fernandez

Enable by default new refactored page

- tests
- feature flag definition

Changelog: changed
parent c8d65dda
...@@ -8,7 +8,6 @@ import { SHOW_DELETE_SUCCESS_ALERT } from '~/packages/shared/constants'; ...@@ -8,7 +8,6 @@ import { SHOW_DELETE_SUCCESS_ALERT } from '~/packages/shared/constants';
import { import {
PROJECT_RESOURCE_TYPE, PROJECT_RESOURCE_TYPE,
GROUP_RESOURCE_TYPE, GROUP_RESOURCE_TYPE,
LIST_QUERY_DEBOUNCE_TIME,
GRAPHQL_PAGE_SIZE, GRAPHQL_PAGE_SIZE,
} from '~/packages_and_registries/package_registry/constants'; } from '~/packages_and_registries/package_registry/constants';
import getPackagesQuery from '~/packages_and_registries/package_registry/graphql/queries/get_packages.query.graphql'; import getPackagesQuery from '~/packages_and_registries/package_registry/graphql/queries/get_packages.query.graphql';
...@@ -52,7 +51,9 @@ export default { ...@@ -52,7 +51,9 @@ export default {
update(data) { update(data) {
return data[this.graphqlResource].packages; return data[this.graphqlResource].packages;
}, },
debounce: LIST_QUERY_DEBOUNCE_TIME, skip() {
return !this.sort;
},
}, },
}, },
computed: { computed: {
......
...@@ -83,5 +83,4 @@ export const INSTANCE_PACKAGE_ENDPOINT_TYPE = 'instance'; ...@@ -83,5 +83,4 @@ export const INSTANCE_PACKAGE_ENDPOINT_TYPE = 'instance';
export const PROJECT_RESOURCE_TYPE = 'project'; export const PROJECT_RESOURCE_TYPE = 'project';
export const GROUP_RESOURCE_TYPE = 'group'; export const GROUP_RESOURCE_TYPE = 'group';
export const LIST_QUERY_DEBOUNCE_TIME = 50;
export const GRAPHQL_PAGE_SIZE = 20; export const GRAPHQL_PAGE_SIZE = 20;
(async function packageApp() { import packageList from '~/packages_and_registries/package_registry/pages/list';
if (window.gon.features.packageListApollo) {
const newPackageList = await import('~/packages_and_registries/package_registry/pages/list');
newPackageList.default(); packageList();
} else {
const packageList = await import('~/packages/list/packages_list_app_bundle');
packageList.default();
}
})();
(async function packageApp() { import packageList from '~/packages_and_registries/package_registry/pages/list';
if (window.gon.features.packageListApollo) {
const newPackageList = await import('~/packages_and_registries/package_registry/pages/list');
newPackageList.default(); packageList();
} else {
const packageList = await import('~/packages/list/packages_list_app_bundle');
packageList.default();
}
})();
...@@ -6,10 +6,6 @@ module Groups ...@@ -6,10 +6,6 @@ module Groups
feature_category :package_registry feature_category :package_registry
before_action do
push_frontend_feature_flag(:package_list_apollo, default_enabled: :yaml)
end
private private
def verify_packages_enabled! def verify_packages_enabled!
......
...@@ -7,10 +7,6 @@ module Projects ...@@ -7,10 +7,6 @@ module Projects
feature_category :package_registry feature_category :package_registry
before_action do
push_frontend_feature_flag(:package_list_apollo, default_enabled: :yaml)
end
def show def show
@package = project.packages.find(params[:id]) @package = project.packages.find(params[:id])
end end
......
---
name: package_list_apollo
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70598
rollout_issue_url:
milestone: '14.3'
type: development
group: group::package
default_enabled: false
...@@ -28,10 +28,6 @@ RSpec.describe 'Group Packages' do ...@@ -28,10 +28,6 @@ RSpec.describe 'Group Packages' do
context 'when feature is available', :js do context 'when feature is available', :js do
before do before do
# we are simply setting the featrure flag to false because the new UI has nothing to test yet
# when the refactor is complete or almost complete we will turn on the feature tests
# see https://gitlab.com/gitlab-org/gitlab/-/issues/330846 for status of this work
stub_feature_flags(package_list_apollo: false)
visit_group_packages visit_group_packages
end end
......
...@@ -27,10 +27,6 @@ RSpec.describe 'Packages' do ...@@ -27,10 +27,6 @@ RSpec.describe 'Packages' do
context 'when feature is available', :js do context 'when feature is available', :js do
before do before do
# we are simply setting the featrure flag to false because the new UI has nothing to test yet
# when the refactor is complete or almost complete we will turn on the feature tests
# see https://gitlab.com/gitlab-org/gitlab/-/issues/330846 for status of this work
stub_feature_flags(package_list_apollo: false)
visit_project_packages visit_project_packages
end end
......
...@@ -15,7 +15,6 @@ import DeletePackage from '~/packages_and_registries/package_registry/components ...@@ -15,7 +15,6 @@ import DeletePackage from '~/packages_and_registries/package_registry/components
import { import {
PROJECT_RESOURCE_TYPE, PROJECT_RESOURCE_TYPE,
GROUP_RESOURCE_TYPE, GROUP_RESOURCE_TYPE,
LIST_QUERY_DEBOUNCE_TIME,
GRAPHQL_PAGE_SIZE, GRAPHQL_PAGE_SIZE,
} from '~/packages_and_registries/package_registry/constants'; } from '~/packages_and_registries/package_registry/constants';
...@@ -86,15 +85,24 @@ describe('PackagesListApp', () => { ...@@ -86,15 +85,24 @@ describe('PackagesListApp', () => {
wrapper.destroy(); wrapper.destroy();
}); });
const waitForDebouncedApollo = () => { const waitForFirstRequest = () => {
jest.advanceTimersByTime(LIST_QUERY_DEBOUNCE_TIME); // emit a search update so the query is executed
findSearch().vm.$emit('update', { sort: 'NAME_DESC', filters: [] });
return waitForPromises(); return waitForPromises();
}; };
it('does not execute the query without sort being set', () => {
const resolver = jest.fn().mockResolvedValue(packagesListQuery());
mountComponent({ resolver });
expect(resolver).not.toHaveBeenCalled();
});
it('renders', async () => { it('renders', async () => {
mountComponent(); mountComponent();
await waitForDebouncedApollo(); await waitForFirstRequest();
expect(wrapper.element).toMatchSnapshot(); expect(wrapper.element).toMatchSnapshot();
}); });
...@@ -102,7 +110,7 @@ describe('PackagesListApp', () => { ...@@ -102,7 +110,7 @@ describe('PackagesListApp', () => {
it('has a package title', async () => { it('has a package title', async () => {
mountComponent(); mountComponent();
await waitForDebouncedApollo(); await waitForFirstRequest();
expect(findPackageTitle().exists()).toBe(true); expect(findPackageTitle().exists()).toBe(true);
expect(findPackageTitle().props('count')).toBe(2); expect(findPackageTitle().props('count')).toBe(2);
...@@ -121,8 +129,7 @@ describe('PackagesListApp', () => { ...@@ -121,8 +129,7 @@ describe('PackagesListApp', () => {
findSearch().vm.$emit('update', searchPayload); findSearch().vm.$emit('update', searchPayload);
await waitForDebouncedApollo(); await waitForPromises();
jest.advanceTimersByTime(LIST_QUERY_DEBOUNCE_TIME);
expect(resolver).toHaveBeenCalledWith( expect(resolver).toHaveBeenCalledWith(
expect.objectContaining({ expect.objectContaining({
...@@ -140,7 +147,7 @@ describe('PackagesListApp', () => { ...@@ -140,7 +147,7 @@ describe('PackagesListApp', () => {
resolver = jest.fn().mockResolvedValue(packagesListQuery()); resolver = jest.fn().mockResolvedValue(packagesListQuery());
mountComponent({ resolver }); mountComponent({ resolver });
return waitForDebouncedApollo(); return waitForFirstRequest();
}); });
it('exists and has the right props', () => { it('exists and has the right props', () => {
...@@ -182,7 +189,7 @@ describe('PackagesListApp', () => { ...@@ -182,7 +189,7 @@ describe('PackagesListApp', () => {
provide = { ...defaultProvide, isGroupPage }; provide = { ...defaultProvide, isGroupPage };
resolver = jest.fn().mockResolvedValue(packagesListQuery({ type })); resolver = jest.fn().mockResolvedValue(packagesListQuery({ type }));
mountComponent({ provide, resolver }); mountComponent({ provide, resolver });
return waitForDebouncedApollo(); return waitForFirstRequest();
}); });
it('succeeds', () => { it('succeeds', () => {
...@@ -191,7 +198,7 @@ describe('PackagesListApp', () => { ...@@ -191,7 +198,7 @@ describe('PackagesListApp', () => {
it('calls the resolver with the right parameters', () => { it('calls the resolver with the right parameters', () => {
expect(resolver).toHaveBeenCalledWith( expect(resolver).toHaveBeenCalledWith(
expect.objectContaining({ isGroupPage, [sortType]: '' }), expect.objectContaining({ isGroupPage, [sortType]: 'NAME_DESC' }),
); );
}); });
}); });
...@@ -201,7 +208,7 @@ describe('PackagesListApp', () => { ...@@ -201,7 +208,7 @@ describe('PackagesListApp', () => {
const resolver = jest.fn().mockResolvedValue(packagesListQuery({ extend: { nodes: [] } })); const resolver = jest.fn().mockResolvedValue(packagesListQuery({ extend: { nodes: [] } }));
mountComponent({ resolver }); mountComponent({ resolver });
return waitForDebouncedApollo(); return waitForFirstRequest();
}); });
it('generate the correct empty list link', () => { it('generate the correct empty list link', () => {
const link = findListComponent().findComponent(GlLink); const link = findListComponent().findComponent(GlLink);
...@@ -219,7 +226,7 @@ describe('PackagesListApp', () => { ...@@ -219,7 +226,7 @@ describe('PackagesListApp', () => {
beforeEach(async () => { beforeEach(async () => {
mountComponent(); mountComponent();
await waitForDebouncedApollo(); await waitForFirstRequest();
findSearch().vm.$emit('update', searchPayload); findSearch().vm.$emit('update', searchPayload);
...@@ -236,7 +243,7 @@ describe('PackagesListApp', () => { ...@@ -236,7 +243,7 @@ describe('PackagesListApp', () => {
it('exists and has the correct props', async () => { it('exists and has the correct props', async () => {
mountComponent(); mountComponent();
await waitForDebouncedApollo(); await waitForFirstRequest();
expect(findDeletePackage().props()).toMatchObject({ expect(findDeletePackage().props()).toMatchObject({
refetchQueries: [{ query: getPackagesQuery, variables: {} }], refetchQueries: [{ query: getPackagesQuery, variables: {} }],
...@@ -247,7 +254,7 @@ describe('PackagesListApp', () => { ...@@ -247,7 +254,7 @@ describe('PackagesListApp', () => {
it('deletePackage is bound to package-list package:delete event', async () => { it('deletePackage is bound to package-list package:delete event', async () => {
mountComponent(); mountComponent();
await waitForDebouncedApollo(); await waitForFirstRequest();
findListComponent().vm.$emit('package:delete', { id: 1 }); findListComponent().vm.$emit('package:delete', { id: 1 });
...@@ -257,7 +264,7 @@ describe('PackagesListApp', () => { ...@@ -257,7 +264,7 @@ describe('PackagesListApp', () => {
it('start and end event set loading correctly', async () => { it('start and end event set loading correctly', async () => {
mountComponent(); mountComponent();
await waitForDebouncedApollo(); await waitForFirstRequest();
findDeletePackage().vm.$emit('start'); findDeletePackage().vm.$emit('start');
......
...@@ -21,10 +21,6 @@ end ...@@ -21,10 +21,6 @@ end
RSpec.shared_examples 'package details link' do |property| RSpec.shared_examples 'package details link' do |property|
let(:package) { packages.first } let(:package) { packages.first }
before do
stub_feature_flags(packages_details_one_column: false)
end
it 'navigates to the correct url' do it 'navigates to the correct url' do
page.within(packages_table_selector) do page.within(packages_table_selector) do
click_link package.name click_link package.name
...@@ -94,16 +90,24 @@ def packages_table_selector ...@@ -94,16 +90,24 @@ def packages_table_selector
end end
def click_sort_option(option, ascending) def click_sort_option(option, ascending)
page.within('.gl-sorting') do wait_for_requests
# Reset the sort direction
click_button 'Sort direction' if page.has_selector?('svg[aria-label="Sorting Direction: Ascending"]', wait: 0)
find('button.gl-dropdown-toggle').click # Reset the sort direction
if page.has_selector?('button[aria-label="Sorting Direction: Ascending"]', wait: 0) && !ascending
click_button 'Sort direction'
page.within('.dropdown-menu') do wait_for_requests
click_button option end
end
find('button.gl-dropdown-toggle').click
page.within('.dropdown-menu') do
click_button option
end
if ascending
wait_for_requests
click_button 'Sort direction' if ascending click_button 'Sort direction'
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