Skip to content

Commit

Permalink
change previously added antivirus_registration.mode from optional t…
Browse files Browse the repository at this point in the history
…o required
  • Loading branch information
gergoabraham committed Apr 29, 2024
1 parent 694acf7 commit 9c84758
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ export interface PolicyConfig {
};
};
antivirus_registration: {
mode?: AntivirusRegistrationModes;
mode: AntivirusRegistrationModes;
enabled: boolean;
};
attack_surface_reduction: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,28 +169,4 @@ describe('Policy Form Antivirus Registration Card', () => {
expect(getRadioButton(antivirusTestSubj.syncRadioButton).checked).toBe(true);
});
});

describe('when antivirus_registration.mode is not available (serverless rollout)', () => {
beforeEach(() => {
delete formProps.policy.windows.antivirus_registration.mode;
});

it('should show disabled if `antivirus_registration.enabled` is false', () => {
formProps.policy.windows.antivirus_registration.enabled = false;
render();

expect(getRadioButton(antivirusTestSubj.disabledRadioButton).checked).toBe(true);
expect(getRadioButton(antivirusTestSubj.enabledRadioButton).checked).toBe(false);
expect(getRadioButton(antivirusTestSubj.syncRadioButton).checked).toBe(false);
});

it('should show enabled if `antivirus_registration.enabled` is true', () => {
formProps.policy.windows.antivirus_registration.enabled = true;
render();

expect(getRadioButton(antivirusTestSubj.disabledRadioButton).checked).toBe(false);
expect(getRadioButton(antivirusTestSubj.enabledRadioButton).checked).toBe(true);
expect(getRadioButton(antivirusTestSubj.syncRadioButton).checked).toBe(false);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,7 @@ export const AntivirusRegistrationCard = memo<AntivirusRegistrationCardProps>(
const getTestId = useTestIdGenerator(dataTestSubj);
const isProtectionsAllowed = !useGetProtectionsUnavailableComponent();
const isEditMode = mode === 'edit';

let currentMode: AntivirusRegistrationModes;
if (policy.windows.antivirus_registration.mode) {
currentMode = policy.windows.antivirus_registration.mode;
} else {
currentMode = policy.windows.antivirus_registration.enabled
? AntivirusRegistrationModes.enabled
: AntivirusRegistrationModes.disabled;
}
const currentMode = policy.windows.antivirus_registration.mode;

const labels: Record<AntivirusRegistrationModes, React.ReactNode> = useMemo(
() => ({
Expand Down

0 comments on commit 9c84758

Please sign in to comment.