test: move independent lower jaw button coverage to client (#68352)

Co-authored-by: sembauke <sembauke@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Sem Bauke
2026-08-27 19:44:11 +02:00
committed by GitHub
parent d04ee71fac
commit 353fa7b38a
2 changed files with 73 additions and 12 deletions
@@ -156,6 +156,79 @@ describe('<IndependentLowerJaw />', () => {
expect(openHelpModal).toHaveBeenCalledTimes(1);
});
it('checks the challenge when the check button is clicked', async () => {
const executeChallenge = vi.fn();
const failingTests: Test[] = [
{ pass: false, err: 'fail', text: 'test', testString: 'test' }
];
render(
<IndependentLowerJaw
{...baseProps}
executeChallenge={executeChallenge}
tests={failingTests}
/>,
createStore()
);
await userEvent.click(
screen.getByRole('button', { name: 'buttons.check-code' })
);
expect(executeChallenge).toHaveBeenCalled();
});
it('opens the reset modal when the reset button is clicked', async () => {
const openResetModal = vi.fn();
render(
<IndependentLowerJaw {...baseProps} openResetModal={openResetModal} />,
createStore()
);
await userEvent.click(
screen.getByRole('button', { name: 'buttons.reset' })
);
expect(openResetModal).toHaveBeenCalled();
});
it('saves the challenge when the save button is clicked', async () => {
const saveChallenge = vi.fn();
render(
<IndependentLowerJaw
{...baseProps}
challengeMeta={{ ...baseChallengeMeta, saveSubmissionToDB: true }}
saveChallenge={saveChallenge}
/>,
createStore()
);
await userEvent.click(screen.getByRole('button', { name: 'buttons.save' }));
expect(saveChallenge).toHaveBeenCalled();
});
it('opens the reset modal when the revert button is clicked', async () => {
const openResetModal = vi.fn();
render(
<IndependentLowerJaw
{...baseProps}
challengeMeta={{ ...baseChallengeMeta, saveSubmissionToDB: true }}
openResetModal={openResetModal}
/>,
createStore()
);
await userEvent.click(
screen.getByRole('button', { name: 'buttons.revert' })
);
expect(openResetModal).toHaveBeenCalled();
});
it('shows socrates button when hasSocratesAccess is true and flag is on', () => {
render(
<IndependentLowerJaw {...baseProps} hasSocratesAccess={true} />,
-12
View File
@@ -52,18 +52,6 @@ test('Clicking "Check Your Code" reveals failing feedback', async ({
).toBeVisible();
});
test('Reset button opens and closes the reset modal', async ({ page }) => {
await page.goto(workshopChallengeUrl);
await page.getByTestId('independentLowerJaw-reset-button').click();
const resetModal = page.getByRole('dialog', { name: 'Reset this lesson?' });
await expect(resetModal).toBeVisible();
await page.getByRole('button', { name: /close/i }).click();
await expect(resetModal).not.toBeVisible();
});
test('Checks hotkeys when instruction is focused', async ({
page,
browserName