Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { listPage } from '../../views/list-page';
import { modal } from '../../views/modal';
import * as yamlEditor from '../../views/yaml-editor';

const SEARCH_NAMESPACE = 'openshift-authentication-operator';
const SEARCH_DEPLOYMENT_NAME = 'authentication-operator';

describe('Filtering and Searching', () => {
let WORKLOAD_NAME;
let WORKLOAD_LABEL;
Expand Down Expand Up @@ -50,14 +53,13 @@ describe('Filtering and Searching', () => {
cy.deleteProjectWithCLI(testName);
});

// disabled as listPage.rows.shouldExist isn't a valid test
xit('filters Pod from object detail', () => {
it('filters Pod from object detail', () => {
cy.visit(`/k8s/ns/${testName}/deployments`);
listPage.rows.shouldExist(WORKLOAD_NAME);
listPage.dvRows.shouldExist(WORKLOAD_NAME);
cy.visit(`/k8s/ns/${testName}/deployments/${WORKLOAD_NAME}/pods`);
listPage.rows.shouldBeLoaded();
listPage.filter.byName(WORKLOAD_NAME);
listPage.rows.shouldExist(WORKLOAD_NAME);
listPage.dvRows.shouldBeLoaded();
listPage.dvFilter.byName(WORKLOAD_NAME);
listPage.dvRows.countShouldBe(3);
});

it('filters invalid Pod from object detail', () => {
Expand All @@ -68,24 +70,39 @@ describe('Filtering and Searching', () => {
cy.get('.pf-v6-l-bullseye').should('contain', 'No Pods found');
});
});
// disabled as listPage.rows.shouldExist isn't a valid test
xit('filters from Pods list', () => {

it('filters from Pods list', () => {
cy.visit(`/k8s/all-namespaces/pods`);
listPage.rows.shouldBeLoaded();
listPage.filter.byName(WORKLOAD_NAME);
listPage.rows.shouldExist(WORKLOAD_NAME);
listPage.dvRows.shouldBeLoaded();
listPage.dvFilter.byName(WORKLOAD_NAME);
listPage.dvRows.countShouldBe(3);
});

it('displays namespace on Search when All Namespaces is selected', () => {
cy.visit(
`/search/all-namespaces?kind=apps~v1~Deployment&page=1&perPage=50&name=${SEARCH_DEPLOYMENT_NAME}`,
);
listPage.dvRows.countShouldBe(1);
cy.get(`[data-test-id="${SEARCH_NAMESPACE}"]`).should('exist');
});

it('does not display namespace on Search when namespace is selected', () => {
cy.visit(
`/search/ns/${SEARCH_NAMESPACE}?kind=apps~v1~Deployment&page=1&perPage=50&name=${SEARCH_DEPLOYMENT_NAME}`,
);
listPage.dvRows.countShouldBe(1);
cy.get(`[data-test-id="${SEARCH_NAMESPACE}"]`).should('not.exist');
});

it('searches for object by kind and label', () => {
cy.visit(`/search/ns/${testName}`, { qs: { kind: 'Deployment', q: WORKLOAD_LABEL } });
listPage.dvRows.shouldExist(WORKLOAD_NAME);
});

// disabled as listPage.rows.shouldExist isn't a valid test
xit('searches for object by kind, label, and name', () => {
it('searches for object by kind, label, and name', () => {
cy.visit(`/search/all-namespaces`, {
qs: { kind: 'Pod', q: 'app=name', name: WORKLOAD_NAME },
});
listPage.rows.shouldExist(WORKLOAD_NAME);
listPage.dvRows.countShouldBe(3);
});
});
3 changes: 2 additions & 1 deletion frontend/public/components/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
} from '@console/dynamic-plugin-sdk/src/extensions/pages';
import { useActivePerspective } from '@console/dynamic-plugin-sdk/src/perspective';
import { useActiveNamespace, useK8sModel } from '@console/dynamic-plugin-sdk/src/lib-core';
import { ALL_NAMESPACES_KEY } from '@console/shared/src/constants';

const ResourceList = ({ kind, mock, namespace, selector, nameFilter }) => {
const { plural } = useParams<{ plural?: string }>();
Expand All @@ -67,7 +68,7 @@ const ResourceList = ({ kind, mock, namespace, selector, nameFilter }) => {
return (
<AsyncComponent
loader={componentLoader}
namespace={ns}
namespace={ns === ALL_NAMESPACES_KEY ? undefined : ns}
selector={selector}
nameFilter={nameFilter}
kind={kindObj.crd ? referenceForModel(kindObj) : kindObj.kind}
Expand Down