Compare commits

...

4 Commits

Author SHA1 Message Date
vaidankarswapnil
f108ed4fbd Resolved test case issue 2021-09-16 22:49:50 +05:30
vaidankarswapnil
74095b6bc4 Update test snapshot issue 2021-09-16 15:32:47 +05:30
vaidankarswapnil
5a4b170857 Merge branch 'master' of https://github.com/Azure/cosmos-explorer into fix_a11y_database_throughput_radiobuttons 2021-09-16 12:36:25 +05:30
vaidankarswapnil
8ebd0f9b01 Fix a11y new collection throughput radiobutton issue 2021-09-16 12:36:13 +05:30
3 changed files with 1358 additions and 80 deletions

View File

@@ -21,12 +21,10 @@ describe("ThroughputInput Pane", () => {
});
it("should switch mode properly", () => {
wrapper.find('[aria-label="Manual mode"]').simulate("change");
expect(wrapper.find('[aria-label="Throughput header"]').at(0).text()).toBe(
"Container throughput (400 - unlimited RU/s)"
);
wrapper.find(".ms-ChoiceField-input").at(0).simulate("change");
expect(wrapper.find("#throughPut").at(0).text()).toBe("Container throughput (autoscale)");
wrapper.find('[aria-label="Autoscale mode"]').simulate("change");
expect(wrapper.find('[aria-label="Throughput header"]').at(0).text()).toBe("Container throughput (autoscale)");
wrapper.find(".ms-ChoiceField-input").at(1).simulate("change");
expect(wrapper.find("#throughPut").at(0).text()).toBe("Container throughput (400 - unlimited RU/s)");
});
});

View File

@@ -1,4 +1,15 @@
import { Checkbox, DirectionalHint, Link, Stack, Text, TextField, TooltipHost } from "@fluentui/react";
import {
Checkbox,
ChoiceGroup,
DirectionalHint,
IChoiceGroupOption,
Label,
Link,
Stack,
Text,
TextField,
TooltipHost,
} from "@fluentui/react";
import React, { FunctionComponent, useState } from "react";
import * as Constants from "../../../Common/Constants";
import { InfoTooltip } from "../../../Common/Tooltip/InfoTooltip";
@@ -90,7 +101,7 @@ export const ThroughputInput: FunctionComponent<ThroughputInputProps> = ({
);
};
const handleOnChangeMode = (event: React.ChangeEvent<HTMLInputElement>, mode: string): void => {
const handleOnChangeMode = (_: React.ChangeEvent<HTMLInputElement>, mode: string): void => {
if (mode === "Autoscale") {
setThroughput(AutoPilotUtils.minAutoPilotThroughput);
setIsAutoScaleSelected(true);
@@ -103,39 +114,46 @@ export const ThroughputInput: FunctionComponent<ThroughputInputProps> = ({
setIsAutoscale(false);
}
};
const choiceButtonStyles = {
flexContainer: [
{
selectors: {
".ms-ChoiceField-wrapper label": {
fontSize: 12,
paddingTop: 0,
},
".ms-ChoiceField": {
marginTop: 0,
},
},
},
],
};
const throughPutOptions: IChoiceGroupOption[] = [
{ key: "Autoscale", text: "Autoscale" },
{ key: "Manual", text: "Manual" },
];
return (
<div className="throughputInputContainer throughputInputSpacing">
<Stack horizontal>
<span className="mandatoryStar">*&nbsp;</span>
<Text aria-label="Throughput header" variant="small" style={{ lineHeight: "20px", fontWeight: 600 }}>
<Label id="throughPut" aria-label={getThroughputLabelText()} style={{ lineHeight: "20px", fontWeight: 600 }}>
{getThroughputLabelText()}
</Text>
</Label>
<InfoTooltip>{PricingUtils.getRuToolTipText()}</InfoTooltip>
</Stack>
<Stack horizontal verticalAlign="center">
<input
className="throughputInputRadioBtn"
aria-label="Autoscale mode"
checked={isAutoscaleSelected}
type="radio"
role="radio"
tabIndex={0}
onChange={(e) => handleOnChangeMode(e, "Autoscale")}
<Stack verticalAlign="center">
<ChoiceGroup
ariaLabelledBy="throughPut"
styles={choiceButtonStyles}
options={throughPutOptions}
defaultSelectedKey={throughPutOptions[0].key}
onChange={(_: React.ChangeEvent<HTMLInputElement>, options: IChoiceGroupOption) =>
handleOnChangeMode(_, options.key.toString())
}
required
/>
<span className="throughputInputRadioBtnLabel">Autoscale</span>
<input
className="throughputInputRadioBtn"
aria-label="Manual mode"
checked={!isAutoscaleSelected}
type="radio"
role="radio"
tabIndex={0}
onChange={(e) => handleOnChangeMode(e, "Manual")}
/>
<span className="throughputInputRadioBtnLabel">Manual</span>
</Stack>
{isAutoscaleSelected && (