Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ProgressBar for quizzes #835

Merged
merged 12 commits into from Dec 22, 2023

Conversation

create-issue-branch[bot]
Copy link
Contributor

@create-issue-branch create-issue-branch bot commented Dec 19, 2023

closes #834

  • ProgressBar is added to quizzes
  • Quizzes increment the currentStepPosition when they're complete so that the next step can be rendered
  • Quiz logic refactored to remove a useEffect() and quizReady state

@create-issue-branch create-issue-branch bot temporarily deployed to previews/issues/834-Enable_ProgressBar_for_quizzes December 19, 2023 09:20 Inactive
Copy link

Copy link

@PetarSimonovic PetarSimonovic temporarily deployed to previews/issues/834-Enable_ProgressBar_for_quizzes December 19, 2023 09:24 — with GitHub Actions Inactive
@PetarSimonovic PetarSimonovic temporarily deployed to previews/issues/834-Enable_ProgressBar_for_quizzes December 19, 2023 09:41 — with GitHub Actions Inactive
Copy link

Copy link

@PetarSimonovic PetarSimonovic temporarily deployed to previews/issues/834-Enable_ProgressBar_for_quizzes December 22, 2023 10:54 — with GitHub Actions Inactive
Copy link

@PetarSimonovic PetarSimonovic temporarily deployed to previews/issues/834-Enable_ProgressBar_for_quizzes December 22, 2023 11:18 — with GitHub Actions Inactive
Copy link

Copy link

@PetarSimonovic PetarSimonovic temporarily deployed to previews/issues/834-Enable_ProgressBar_for_quizzes December 22, 2023 14:14 — with GitHub Actions Inactive
Copy link

@loiswells97 loiswells97 temporarily deployed to previews/issues/834-Enable_ProgressBar_for_quizzes December 22, 2023 14:46 — with GitHub Actions Inactive
const [isQuiz, setIsQuiz] = useState(false);

const quizCompleted = useMemo(() => {
return quiz.currentQuestion === quiz?.questionCount;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the first half of this need a guard against quiz being blank as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if both sides are null/undefined?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added optional chaining to the first half.

Copy link

Comment on lines 78 to 101
describe("When on a quiz step", () => {
beforeEach(() => {
renderProgressBarOnStep(2);
});

test("Progress bar renders with correct max and value", () => {
const progressBar = screen.getByRole("progressbar");
expect(progressBar).toHaveValue(2);
expect(progressBar).toHaveAttribute("max", "3");
});

test("Clicking previous step button goes back a step", () => {
const previousStepButton = screen.getByTitle(
"instructionsPanel.previousStep",
);
fireEvent.click(previousStepButton);
expect(store.getActions()).toEqual([setCurrentStepPosition(1)]);
});

test("Clicking next step button goes forward a step", () => {
const nextStepButton = screen.getByTitle("instructionsPanel.nextStep");
fireEvent.click(nextStepButton);
expect(store.getActions()).toEqual([setCurrentStepPosition(3)]);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I quite understand what's going on here... I might be missing something, but what indicates that the "Quiz step 1" step is a quiz?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you're right! I've fixed (I think I reverted some changes I made and removed the knowledgeQuiz property on that step). Thanks for spotting!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not sure I understand... Does the progress bar know anything about whether it's a quiz?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it doesn't.

I put it in since the ProgressBar was previously removed on a quiz step but maybe this validation is unnecessary

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm yeah, tbh I was wondering whether the test was redundant 🤔 I guess in another file you've got the test that the project bar shows on a quiz step, so I think that's enough... I suppose all you've done is remove the logic to hide the progress bar on a quiz step, so if the tests were to go back to how they were before that was added, that would make sense in my mind at least 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - I've removed!

Copy link
Contributor

@loiswells97 loiswells97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few comments on this one and looks like you're missing a changelog entry too

@PetarSimonovic PetarSimonovic temporarily deployed to previews/issues/834-Enable_ProgressBar_for_quizzes December 22, 2023 16:52 — with GitHub Actions Inactive
@PetarSimonovic PetarSimonovic temporarily deployed to previews/issues/834-Enable_ProgressBar_for_quizzes December 22, 2023 16:59 — with GitHub Actions Inactive
Copy link

@PetarSimonovic PetarSimonovic marked this pull request as ready for review December 22, 2023 17:04
Copy link
Contributor

@loiswells97 loiswells97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

Copy link

@PetarSimonovic PetarSimonovic merged commit dde4ee7 into main Dec 22, 2023
8 checks passed
@PetarSimonovic PetarSimonovic deleted the issues/834-Enable_ProgressBar_for_quizzes branch December 22, 2023 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable ProgressBar for quizzes
2 participants