Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccaalpert committed Mar 30, 2020
1 parent 59eae39 commit e14c823
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 27 deletions.
5 changes: 5 additions & 0 deletions frontend/packages/operator-lifecycle-manager/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export const testClusterServiceVersion: ClusterServiceVersionKind = {
apiVersion: 'operators.coreos.com/v1alpha1',
kind: 'ClusterServiceVersion',
metadata: {
annotations: {
'olm.operatorGroup': 'global-operators',
'olm.operatorNamespace': 'openshift-operators',
'olm.targetNamespaces': 'openshift-operators',
},
name: 'testapp',
uid: 'c02c0a8f-88e0-11e7-851b-080027b424ef',
creationTimestamp: '2017-09-20T18:19:49Z',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,24 +116,16 @@ describe(ClusterServiceVersionTableRow.displayName, () => {
).toBe(true);
});

it('renders column for app namespace link', () => {
const link = wrapper
.find(TableRow)
.childAt(1)
.find(ResourceLink);

expect(link.props().kind).toEqual('Namespace');
expect(link.props().title).toEqual(testClusterServiceVersion.metadata.namespace);
expect(link.props().name).toEqual(testClusterServiceVersion.metadata.namespace);
it('renders column for managedNamespace', () => {
const col = wrapper.find(TableRow).childAt(1);
const managedNamespace = col.childAt(0).find('span.text-muted');
expect(managedNamespace.exists()).toBeTruthy();
expect(managedNamespace.render().text()).toContain('All Namespaces');
});

it('renders column with link to Operator deployment', () => {
it('renders column for last updated', () => {
const col = wrapper.find(TableRow).childAt(3);

expect(col.find(ResourceLink).props().kind).toEqual('Deployment');
expect(col.find(ResourceLink).props().name).toEqual(
testClusterServiceVersion.spec.install.spec.deployments[0].name,
);
expect(col.render().text()).toContain('years from now');
});

it('renders column for app status', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,15 +513,15 @@ export const ClusterServiceVersionList: React.SFC<ClusterServiceVersionListProps
const filteredData =
data.length > 0 ?
data.filter((source) => {
if (_.isUndefined(source)) {
if (_.isUndefined(source) || source === null) {
return null;
}
if (source.kind !== 'ClusterServiceVersion') {
return source;
}
if (source.kind === 'ClusterServiceVersion') {
if (
!_.isUndefined(source.metadata.annotations['olm.operatorGroup']) &&
(!_.isUndefined(source.metadata.annotations['olm.operatorGroup']) && source.metadata.annotations['olm.operatorGroup'] !== null) &&
source.metadata.annotations['olm.operatorGroup'] === 'global-operators'
) {
return source.metadata.namespace === 'openshift-operators' ? source : null;
Expand Down
19 changes: 9 additions & 10 deletions frontend/public/components/factory/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,16 @@ const sorts = {
managedNamespace: (obj) => {
const olmOperatorGroup = _.get(obj, 'metadata.annotations["olm.operatorGroup"]');
let olmManagedNamespace;
if (!_.isUndefined(olmOperatorGroup)) {
if ((olmManagedNamespace = olmOperatorGroup === 'global-operators')) {
olmManagedNamespace = 'All Namespaces';
} else {
const namespaces = _.get(obj, 'metadata.annotations["olm.targetNamespaces"]');
const namespacesList = _.isUndefined(namespaces) ? [] : namespaces.split(',');
namespacesList.length > 1
? (olmManagedNamespace = `{namespacesList.length} Namespaces`)
: (olmManagedNamespace = namespacesList);
}
if ((!_.isUndefined(olmOperatorGroup) && olmOperatorGroup !== null) && olmOperatorGroup === 'global-operators') {
olmManagedNamespace = 'All Namespaces';
} else {
const namespaces = _.get(obj, 'metadata.annotations["olm.targetNamespaces"]');
const namespacesList = _.isUndefined(namespaces) ? [] : namespaces.split(',');
namespacesList.length > 1
? (olmManagedNamespace = `{namespacesList.length} Namespaces`)
: (olmManagedNamespace = namespacesList);
}
if (obj.kind === 'Subscription') {
olmManagedNamespace = 'None';
}
return olmManagedNamespace;
Expand Down

0 comments on commit e14c823

Please sign in to comment.