Skip to content

Commit cdebe0e

Browse files
Change unnamed related object from * to - (stolostron#3328)
Since we just want one thing to possibly match, using "*" makes it seem like all of the things are bad. Using "-" also matches what we do for some things when we don’t know/care about the namespace Ref: https://issues.redhat.com/browse/ACM-8782 Signed-off-by: Yi Rae Kim <yikim@redhat.com>
1 parent eb264f0 commit cdebe0e

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

frontend/src/routes/Governance/policies/policy-details/PolicyTemplateDetails.test.tsx

+10-15
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { MemoryRouter } from 'react-router-dom'
44
import { RecoilRoot } from 'recoil'
55
import { managedClusterAddonsState } from '../../../../atoms'
66
import { nockGet, nockIgnoreApiPaths } from '../../../../lib/nock-util'
7-
import { waitForNocks, waitForText } from '../../../../lib/test-util'
7+
import { waitForNocks, waitForText, waitForNotText } from '../../../../lib/test-util'
88
import { ManagedClusterAddOn } from '../../../../resources'
99
import { PolicyTemplateDetails } from './PolicyTemplateDetails'
1010

@@ -607,11 +607,11 @@ describe('Policy Template Details content', () => {
607607
)
608608
})
609609

610-
test('Should render correctly with relatedObject name is * when it is cluster scope', async () => {
610+
test('Should render correctly with relatedObject name is - when it is cluster scope', async () => {
611611
const replaceRelatedObj = [
612612
{
613613
compliant: 'NonCompliant',
614-
object: { apiVersion: 'v1', kind: 'Namespace', metadata: { name: '*' } },
614+
object: { apiVersion: 'v1', kind: 'Namespace', metadata: { name: '-' } },
615615
reason: 'Resource found as expected',
616616
cluster: 'test-cluster',
617617
},
@@ -643,19 +643,17 @@ describe('Policy Template Details content', () => {
643643

644644
// wait for related resources table to load correctly
645645
await waitForText('Related resources')
646-
await waitForText('*')
646+
// Both namespace and name
647+
await waitForText('-', true)
647648
await waitForText('v1')
648-
const viewYamlLink = screen.getByText('View YAML')
649-
expect(viewYamlLink.getAttribute('href')).toEqual(
650-
`/multicloud/home/search/resources/yaml?cluster=test-cluster&kind=Namespace&apiversion=v1`
651-
)
649+
await waitForNotText('View YAML')
652650
})
653651

654-
test('Should render correctly with relatedObject name is * when it is namespace scope', async () => {
652+
test('Should render correctly with relatedObject name is - when it is namespace scope', async () => {
655653
const replaceRelatedObj = [
656654
{
657655
compliant: 'NonCompliant',
658-
object: { apiVersion: 'networking.k8s.io/v1', kind: 'Ingress', metadata: { namespace: 'ohmyns', name: '*' } },
656+
object: { apiVersion: 'networking.k8s.io/v1', kind: 'Ingress', metadata: { namespace: 'ohmyns', name: '-' } },
659657
reason: 'Resource found as expected',
660658
cluster: 'test-cluster',
661659
},
@@ -687,11 +685,8 @@ describe('Policy Template Details content', () => {
687685

688686
// wait for related resources table to load correctly
689687
await waitForText('Related resources')
690-
await waitForText('*')
688+
await waitForText('-')
691689
await waitForText('networking.k8s.io/v1')
692-
const viewYamlLink = screen.getByText('View YAML')
693-
expect(viewYamlLink.getAttribute('href')).toEqual(
694-
`/multicloud/home/search/resources/yaml?cluster=test-cluster&kind=Ingress&apiversion=networking.k8s.io/v1&namespace=ohmyns`
695-
)
690+
await waitForNotText('View YAML')
696691
})
697692
})

frontend/src/routes/Governance/policies/policy-details/PolicyTemplateDetails.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,13 @@ export function PolicyTemplateDetails(props: {
255255
) {
256256
return ''
257257
}
258-
if (cluster && kind && apiVersion && name) {
259-
const nameArg = name != '*' ? `&name=${name}` : ''
258+
if (cluster && kind && apiVersion && name && name != '-') {
260259
const namespaceArg = namespace ? `&namespace=${namespace}` : ''
261260
return (
262261
<a
263262
target="_blank"
264263
rel="noopener noreferrer"
265-
href={`${NavigationPath.resourceYAML}?cluster=${cluster}&kind=${kind}&apiversion=${apiVersion}${nameArg}${namespaceArg}`}
264+
href={`${NavigationPath.resourceYAML}?cluster=${cluster}&kind=${kind}&apiversion=${apiVersion}&name=${name}${namespaceArg}`}
266265
>
267266
{t('View YAML')}
268267
</a>

0 commit comments

Comments
 (0)