Skip to content

Commit

Permalink
Fixed a test file and removed couple of reduntant flag uses
Browse files Browse the repository at this point in the history
Signed-off-by: Kshitij Tandon <tandonks@amazon.com>
  • Loading branch information
tandonks committed Aug 21, 2024
1 parent 0d2f19a commit 93c2f96
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ interface ChangeManagedIndicesProps {
onChangeManagedIndices: (selectedManagedIndices: { label: string; value?: ManagedIndexItem }[]) => void;
onChangeStateFilters: (stateFilter: { label: string }[]) => void;
managedIndicesError: string;
useUpdatedUX?: boolean;
}

interface ChangeManagedIndicesState {
Expand Down Expand Up @@ -72,7 +71,7 @@ export default class ChangeManagedIndices extends Component<ChangeManagedIndices

render() {
const { managedIndices, managedIndicesIsLoading, stateFilterSearchValue } = this.state;
const { selectedManagedIndices, selectedStateFilters, managedIndicesError, useUpdatedUX } = this.props;
const { selectedManagedIndices, selectedStateFilters, managedIndicesError } = this.props;
const uniqueStates = selectedManagedIndices.reduce(
(accu: Set<any>, selectedManagedIndex: { label: string; value?: ManagedIndexItem }) => {
if (!selectedManagedIndex.value) return accu;
Expand Down Expand Up @@ -109,7 +108,6 @@ export default class ChangeManagedIndices extends Component<ChangeManagedIndices
// @ts-ignore
onChange={this.props.onChangeManagedIndices}
onSearchChange={this.onManagedIndexSearchChange}
compressed={useUpdatedUX ? true : undefined}
/>
</EuiCompressedFormRow>

Expand All @@ -122,7 +120,6 @@ export default class ChangeManagedIndices extends Component<ChangeManagedIndices
// @ts-ignore
onChange={this.props.onChangeStateFilters}
onSearchChange={this.onStateFilterSearchChange}
compressed={useUpdatedUX ? true : undefined}
/>
</EuiCompressedFormRow>
</div>
Expand Down
3 changes: 0 additions & 3 deletions public/pages/ChangePolicy/components/NewPolicy/NewPolicy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ interface NewPolicyProps {
onChangePolicy: (selectedPolicies: PolicyOption[]) => void;
onChangeStateRadio: (optionId: string) => void;
onStateSelectChange: (e: React.ChangeEvent<HTMLSelectElement>) => void;
useUpdatedUX?: boolean;
}

interface NewPolicyState {
Expand Down Expand Up @@ -123,7 +122,6 @@ export default class NewPolicy extends React.Component<NewPolicyProps, NewPolicy
// @ts-ignore
onChange={this.props.onChangePolicy}
onSearchChange={this.onPolicySearchChange}
compressed={useUpdatedUX ? true : false}
/>
</EuiCompressedFormRow>

Expand All @@ -140,7 +138,6 @@ export default class NewPolicy extends React.Component<NewPolicyProps, NewPolicy
value={stateSelected}
onChange={this.props.onStateSelectChange}
aria-label="Start state for new policy"
compressed={useUpdatedUX ? true : false}
/>
</EuiCompressedFormRow>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ export class ChangePolicy extends Component<ChangePolicyProps, ChangePolicyState
onChangeManagedIndices={this.onChangeManagedIndices}
onChangeStateFilters={this.onChangeStateFilters}
managedIndicesError={hasSubmitted ? managedIndicesError : ""}
useUpdatedUX={useUpdatedUX}
/>

<EuiSpacer />
Expand All @@ -187,7 +186,6 @@ export class ChangePolicy extends Component<ChangePolicyProps, ChangePolicyState
onChangeStateRadio={this.onChangeStateRadio}
onStateSelectChange={this.onStateSelectChange}
selectedPoliciesError={hasSubmitted ? selectedPoliciesError : ""}
useUpdatedUX={useUpdatedUX}
/>

<EuiSpacer />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ import { CoreServicesConsumer, CoreServicesContext } from "../../../../component
import ShrinkIndex from "./ShrinkIndex";
import { ModalProvider, ModalRoot } from "../../../../components/Modal";
import { BrowserServices } from "../../../../models/interfaces";
import { getApplication, getNavigationUI, getUISettings } from "../../../../services/Services";

jest.mock("../../../../services/Services", () => ({
...jest.requireActual("../../../../services/Services"),
getUISettings: jest.fn(),
getApplication: jest.fn(),
getNavigationUI: jest.fn(),
}));

beforeEach(() => {
(getUISettings as jest.Mock).mockReturnValue({
get: jest.fn().mockReturnValue(false), // or false, depending on your test case
});
(getApplication as jest.Mock).mockReturnValue({});

(getNavigationUI as jest.Mock).mockReturnValue({});
});

function renderWithRouter(initialEntries = [ROUTES.SHRINK_INDEX] as string[]) {
return {
Expand Down

0 comments on commit 93c2f96

Please sign in to comment.