Skip to content

Commit

Permalink
WIP: fixed test
Browse files Browse the repository at this point in the history
  • Loading branch information
marcushaddon committed Nov 13, 2023
1 parent e1c79f5 commit 6e0d743
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ const DetailedExplantion: FunctionComponent<Props> = ({
return (
<>
<Localized id={`common-moderationReason-rejectionReason-${code}`}>
<RadioButton value={code} name={code} key={code} checked>
<RadioButton
tabIndex={-1}
aria-hidden
value={code}
name={code}
key={code}
checked
>
{unsnake(code)}
</RadioButton>
</Localized>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ const Reasons: FunctionComponent<Props> = ({
.filter(
(code) =>
code !== GQLREJECTION_REASON_CODE.ILLEGAL_CONTENT &&
code !== GQLREJECTION_REASON_CODE.BANNED_WORD &&
code !== GQLREJECTION_REASON_CODE.OTHER
)
.map((code) => (
<>
<div key={code}>
<Localized id={`common-moderationReason-rejectionReason-${code}`}>
<RadioButton
value={code}
name={code}
key={code}
checked={selected === code}
onChange={(e) => {
if (e.target.checked) {
Expand All @@ -68,7 +68,7 @@ const Reasons: FunctionComponent<Props> = ({
{selected === code && (
<AddExpanationButton onClick={onAddExplanation} />
)}
</>
</div>
))}

<Localized id="common-moderationReason-reason-moreReasons">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ const ModerationDropdownContainer: FunctionComponent<Props> = ({
/>
</Dropdown>
) : view === "REJECT_REASON" ? (
<ModerationReason onReason={reject} onCancel={onDismiss} />
<ModerationReason
id={comment.id}
onReason={reject}
onCancel={onDismiss}
/>
) : (
<UserBanPopoverContainer
comment={comment}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,6 @@ it("requires rection reason when dsaFeaturesEnabled", async () => {
},
});
});
// const tabPane = await screen.findByTestId("current-tab-pane");
const comment = screen.getByTestId(`comment-${firstComment.id}`);

const caretButton = within(comment).getByLabelText("Moderate");
Expand All @@ -683,17 +682,15 @@ it("requires rection reason when dsaFeaturesEnabled", async () => {

const rejectButton = within(comment).getByRole("button", { name: "Reject" });

await act(async () => {
act(() => {
fireEvent.click(rejectButton);
});

await waitFor(() => {
expect(screen.queryByTestId("moderation-reason-modal")).toBeInTheDocument();
expect(screen.getByRole("dialog")).toBeInTheDocument();
});

const reasonModal = await within(comment).findByTestId(
"moderation-reason-modal"
);
const reasonModal = screen.getByRole("dialog");

expect(reasonModal).toBeInTheDocument();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,37 @@ export interface RadioButtonProps {
onFocus: EventHandler<FocusEvent<HTMLElement>>;
onBlur: EventHandler<FocusEvent<HTMLElement>>;
keyboardFocus: boolean;
tabIndex?: number;
}

export class RadioButton extends Component<RadioButtonProps> {
public state = {
randomID: uuid(),
};
public render() {
const { className, classes, id, light, children, keyboardFocus, ...rest } =
this.props;
const {
className,
classes,
id,
light,
children,
keyboardFocus,
tabIndex,
...rest
} = this.props;

const rootClassName = cn(classes.root, className);
const finalID = id || this.state.randomID;

return (
<Flex alignItems="center" className={rootClassName}>
<input className={classes.input} type="radio" id={finalID} {...rest} />
<input
className={classes.input}
type="radio"
id={finalID}
{...rest}
tabIndex={tabIndex}
/>
<label
className={cn(classes.label, {
[classes.labelLight]: light,
Expand Down

0 comments on commit 6e0d743

Please sign in to comment.