-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #872 from othrayte/likert-like-labelling
website: Switch to likert style labeling
- Loading branch information
Showing
19 changed files
with
476 additions
and
521 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
describe("labeling assistant replies", () => { | ||
it("completes the current task on submit and on request shows a new task", () => { | ||
cy.signInWithEmail("cypress@example.com"); | ||
cy.visit("/label/label_assistant_reply"); | ||
|
||
cy.get('[data-cy="task"]') | ||
.invoke("attr", "data-task-type") | ||
.then((type) => { | ||
cy.log("Task type", type); | ||
|
||
// For specific task pages the no task available result is normal. | ||
if (type === undefined) return; | ||
|
||
cy.get('[data-cy="label-options"]').each((label) => { | ||
// Click the 4th option | ||
cy.wrap(label).find('[data-cy="radio-option"]').eq(3).click(); | ||
}); | ||
|
||
cy.get('[data-cy="review"]').click(); | ||
|
||
cy.get('[data-cy="submit"]').click(); | ||
}); | ||
}); | ||
}); | ||
|
||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
describe("labeling initial prompts", () => { | ||
it("completes the current task on submit and on request shows a new task", () => { | ||
cy.signInWithEmail("cypress@example.com"); | ||
cy.visit("/label/label_initial_prompt"); | ||
|
||
cy.get('[data-cy="task"]') | ||
.invoke("attr", "data-task-type") | ||
.then((type) => { | ||
cy.log("Task type", type); | ||
|
||
// For specific task pages the no task available result is normal. | ||
if (type === undefined) return; | ||
|
||
cy.get('[data-cy="label-options"]').each((label) => { | ||
// Click the 4th option | ||
cy.wrap(label).find('[data-cy="radio-option"]').eq(3).click(); | ||
}); | ||
|
||
cy.get('[data-cy="review"]').click(); | ||
|
||
cy.get('[data-cy="submit"]').click(); | ||
}); | ||
}); | ||
}); | ||
|
||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
describe("labeling prompter replies", () => { | ||
it("completes the current task on submit and on request shows a new task", () => { | ||
cy.signInWithEmail("cypress@example.com"); | ||
cy.visit("/label/label_prompter_reply"); | ||
|
||
cy.get('[data-cy="task"]') | ||
.invoke("attr", "data-task-type") | ||
.then((type) => { | ||
cy.log("Task type", type); | ||
|
||
// For specific task pages the no task available result is normal. | ||
if (type === undefined) return; | ||
|
||
cy.get('[data-cy="label-options"]').each((label) => { | ||
// Click the 4th option | ||
cy.wrap(label).find('[data-cy="radio-option"]').eq(3).click(); | ||
}); | ||
|
||
cy.get('[data-cy="review"]').click(); | ||
|
||
cy.get('[data-cy="submit"]').click(); | ||
}); | ||
}); | ||
}); | ||
|
||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Radio, RadioGroup } from "@chakra-ui/react"; | ||
import { PropsWithChildren } from "react"; | ||
|
||
export const LikertButtons = ({ | ||
isDisabled, | ||
count, | ||
onChange, | ||
"data-cy": dataCy, | ||
}: PropsWithChildren<{ | ||
isDisabled: boolean; | ||
count: number; | ||
onChange: (value: number) => void; | ||
"data-cy"?: string; | ||
}>) => { | ||
const valueMap = Object.fromEntries(Array.from({ length: count }, (_, idx) => [`${idx}`, idx / (count - 1)])); | ||
|
||
return ( | ||
<RadioGroup | ||
data-cy={dataCy} | ||
isDisabled={isDisabled} | ||
onChange={(value) => { | ||
onChange(valueMap[value]); | ||
}} | ||
style={{ display: "flex", justifyContent: "space-between" }} | ||
> | ||
{Object.keys(valueMap).map((value) => { | ||
return <Radio key={value} value={value} data-cy="radio-option" size="md" padding="0.6em" />; | ||
})} | ||
</RadioGroup> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { | ||
IconButton, | ||
Popover, | ||
PopoverArrow, | ||
PopoverBody, | ||
PopoverCloseButton, | ||
PopoverContent, | ||
PopoverTrigger, | ||
Text, | ||
} from "@chakra-ui/react"; | ||
import { InformationCircleIcon } from "@heroicons/react/20/solid"; | ||
|
||
interface ExplainProps { | ||
explanation: string[]; | ||
} | ||
|
||
export const Explain = ({ explanation }: ExplainProps) => { | ||
return ( | ||
<Popover> | ||
<PopoverTrigger> | ||
<IconButton | ||
aria-label="explanation" | ||
variant="link" | ||
size="xs" | ||
icon={<InformationCircleIcon className="h-4 w-4" />} | ||
></IconButton> | ||
</PopoverTrigger> | ||
<PopoverContent> | ||
<PopoverArrow /> | ||
<PopoverCloseButton /> | ||
<PopoverBody> | ||
{explanation.map((paragraph, idx) => ( | ||
<Text key={idx}>{paragraph}</Text> | ||
))} | ||
</PopoverBody> | ||
</PopoverContent> | ||
</Popover> | ||
); | ||
}; |
Oops, something went wrong.