webpack/scenes/ContentViews/Details/Versions/Compare/__tests__/CVVersionCompare.test.js in katello-4.6.2.1 vs webpack/scenes/ContentViews/Details/Versions/Compare/__tests__/CVVersionCompare.test.js in katello-4.7.0.rc1

- old
+ new

@@ -8,10 +8,11 @@ import ContentViewVersions from '../../ContentViewVersions'; import cvVersionsData from './contentViewVersions.fixtures.json'; import cvDetailsData from './contentViewDetails.fixtures.json'; import environmentPathsData from '../../../../Publish/__tests__/environmentPaths.fixtures.json'; import CVVersionCompare from '../CVVersionCompare'; +import cvCompareRepositoriesData from './cvCompareRepositories.fixtures.json'; import cvVersionRPMPackagesCompareAllContentData from './RPMPackagesCompareAllContentData.fixtures.json'; import cvVersionErrataCompareAllContentData from './ErrataCompareAllContentData.fixtures.json'; import cvVersionPackageGroupsCompareAllContentData from './PackageGroupsCompareAllContentData.fixtures.json'; import cvVersionFilesCompareAllContentData from './FilesCompareAllContentData.fixtures.json'; import cvVersionModuleStreamsCompareAllContentData from './ModuleStreamsCompareAllContentData.fixtures.json'; @@ -33,10 +34,11 @@ const cvDetails = api.getApiUrl('/content_views/4'); const versionDetails = versionId => api.getApiUrl(`/content_view_versions/${versionId}`); const autocompleteUrl = '/content_view_versions/auto_complete_search'; const withCVRoute = component => <Route path="/content_views/:id">{component}</Route>; const environmentPathsPath = api.getApiUrl('/organizations/1/environments/paths'); +const sortedRpmPackagesPath = api.getApiUrl('/packages/compare?content_view_version_ids[]=15&content_view_version_ids[]=17&restrict_comparison=all&sort_by=nvra&sort_order=desc&per_page=20&page=1'); const renderOptions = { initialState: { API: { CONTENT_VIEW_VERSION_DETAILS_51_21: { status: 'RESOLVED', @@ -87,10 +89,19 @@ assertNockRequest(envScope); }); const testConfigAllContentTypes = [ { + name: 'Repositories', + autoCompleteUrl: '/repositories/auto_complete_search', + dataUrl: api.getApiUrl('/repositories/compare'), + data: cvCompareRepositoriesData, + textQuery: [ + head(cvCompareRepositoriesData.results).name, + last(cvCompareRepositoriesData.results).name], + }, + { name: 'RPM packages', countKey: 'rpm_count', autoCompleteUrl: '/packages/auto_complete_search', dataUrl: api.getApiUrl('/packages/compare'), data: cvVersionRPMPackagesCompareAllContentData, @@ -180,10 +191,19 @@ }, ]; const testConfigThreeContentTypes = [ { + name: 'Repositories', + autoCompleteUrl: '/repositories/auto_complete_search', + dataUrl: api.getApiUrl('/repositories/compare'), + data: cvCompareRepositoriesData, + textQuery: [ + head(cvCompareRepositoriesData.results).name, + last(cvCompareRepositoriesData.results).name], + }, + { name: 'RPM packages', countKey: 'rpm_count', autoCompleteUrl: '/packages/auto_complete_search', dataUrl: api.getApiUrl('/packages/compare'), data: cvVersionRPMPackagesCompareThreeContentTypesData, @@ -214,10 +234,17 @@ ]; const emptyContentViewByText = contentType => `No matching ${contentType} found.`; const testConfigViewByDifferent = [ { + name: 'Repositories', + autoCompleteUrl: '/repositories/auto_complete_search', + dataUrl: api.getApiUrl('/repositories/compare'), + data: cvVersionEmptyContent, + textQuery: emptyContentViewByText('Repositories'), + }, + { name: 'RPM packages', countKey: 'rpm_count', autoCompleteUrl: '/packages/auto_complete_search', dataUrl: api.getApiUrl('/packages/compare'), data: cvVersionEmptyContent, @@ -243,10 +270,19 @@ }, ]; const testConfigViewBySame = [ { + name: 'Repositories', + autoCompleteUrl: '/repositories/auto_complete_search', + dataUrl: api.getApiUrl('/repositories/compare'), + data: cvCompareRepositoriesData, + textQuery: [ + head(cvCompareRepositoriesData.results).name, + last(cvCompareRepositoriesData.results).name], + }, + { name: 'RPM packages', countKey: 'rpm_count', autoCompleteUrl: '/packages/auto_complete_search', dataUrl: api.getApiUrl('/packages/compare'), data: cvVersionRPMPackagesCompareThreeContentTypesData, @@ -272,11 +308,11 @@ data: cvVersionEmptyContent, textQuery: emptyContentViewByText('Files'), }, ]; -test('Can make an API call and show comparison of two versions with all content types', async (done) => { +test('Can make an API call and show comparison of two versions with all content types and sort tables', async (done) => { const autoCompleteContentTypesScope = testConfigAllContentTypes.map(({ autoCompleteUrl }) => mockAutocomplete(nockInstance, autoCompleteUrl)); const scopeContentTypes = testConfigAllContentTypes.map(({ dataUrl, data }) => nockInstance.get(dataUrl).query(true).reply(200, data)); @@ -292,10 +328,14 @@ .reply(200, versionOneDetailsData); const scopeVersionTwoDetails = nockInstance .get(versionDetails(17)) .query(true) .reply(200, versionTwoDetailsData); + const sortedRpmTabScope = nockInstance + .get(sortedRpmPackagesPath) + .reply(200, cvCompareRepositoriesData); + const { queryByText, queryAllByText, getAllByText } = renderWithRedux( withCVRoute(<CVVersionCompare cvId={4} versionIds={versionIdsAllContentTypes} versionLabels={versionLabelsAllContentTypes} @@ -325,16 +365,24 @@ expect(queryByText(name)).toBeTruthy(); textQuery.forEach(query => expect(queryAllByText(query)).toBeTruthy()); }); }); + // Can sort rendered table + const rpmTab = queryByText('RPM packages'); + fireEvent.click(rpmTab); + await patientlyWaitFor(() => { + expect(queryByText('Name')).toBeTruthy(); + }); + fireEvent.click(queryByText('Name')); assertNockRequest(scopeCVDetails); assertNockRequest(scopeVersionOneDetails); assertNockRequest(scopeVersionTwoDetails); scopeContentTypes.map(cv => assertNockRequest(cv)); autoCompleteContentTypesScope.map(cv => assertNockRequest(cv)); + assertNockRequest(sortedRpmTabScope); assertNockRequest(searchDelayScope); assertNockRequest(autoSearchScope); act(done); }); @@ -562,13 +610,18 @@ await patientlyWaitFor(() => { testConfigViewByDifferent.forEach(({ name }) => { expect(queryByText(name)).toBeTruthy(); }); - expect(getByText('No matching RPM packages found.')).toBeTruthy(); - (testConfigViewByDifferent.find(({ name }) => name === 'Files')).textQuery.forEach(query => expect(queryAllByText(query)).toBeTruthy()); + expect(getByText('No matching Repositories found.')).toBeTruthy(); }); + (testConfigViewByDifferent.find(({ name }) => name === 'Files')).textQuery.forEach(query => expect(queryAllByText(query)).toBeTruthy()); + + fireEvent.click(getByText('RPM packages')); + await patientlyWaitFor(() => { + expect(getByText('No matching RPM packages found.')).toBeTruthy(); + }); fireEvent.click(getByText('Errata')); await patientlyWaitFor(() => { expect(getByText('No matching Errata found.')).toBeTruthy(); });