Repository: freeCodeCamp/freeCodeCamp
File: e2e/reset-modal.spec.ts (TypeScript)

Code before:
  // Modify the text in the editor pane, clearing first, otherwise the existing
  // text will be selected before typing
  await page.getByLabel(editorPaneLabel).fill('');
  await page.getByLabel(editorPaneLabel).fill(updatedText);
  await expect(updatedFrame).toBeVisible();

  // Run the tests so the lower jaw updates (later we confirm that the update
  // are reset)
  await page
    .getByRole('button', {
      name: translations.buttons['check-code']
    })
    .click();

  await expect(
    page.getByText(translations.learn['sorry-keep-trying'])
  ).toBeVisible();

  // Reset the challenge
  await page.getByTestId('lowerJaw-reset-button').click();
  await page
    .getByRole('button', { name: translations.buttons['reset-lesson'] })
    .click();

  // Check it's back to the initial state
  await expect(initialFrame).toBeVisible();
  await expect(
    page.getByText(translations.learn['sorry-keep-trying'])
  ).not.toBeVisible();
});

test('User can reset classic challenge', async ({ page, isMobile }) => {
  await page.goto(
    '/learn/javascript-algorithms-and-data-structures/basic-javascript/comment-your-javascript-code'
  );

  const editorPaneLabel =
    'Editor content;Press Alt+F1 for Accessibility Options.';
  const challengeSolution = '// This is in-line comment';

  await page.getByLabel(editorPaneLabel).fill(challengeSolution);

  const submitButton = page.getByRole('button', {
    name: isMobile ? translations.buttons.run : translations.buttons['run-test']
  });
  await submitButton.click();

  await expect(
    page.locator('.view-lines').getByText(challengeSolution)
  ).toBeVisible();
  await expect(

Review comment (suggestion):
```suggestion
  await expect(initialFrame).toBeVisible({ timeout: 10000 });
```

Code after:
  // Modify the text in the editor pane, clearing first, otherwise the existing
  // text will be selected before typing
  await page.getByLabel(editorPaneLabel).fill('');
  await page.getByLabel(editorPaneLabel).fill(updatedText);
  await expect(updatedFrame).toBeVisible({ timeout: 10000 });

  // Run the tests so the lower jaw updates (later we confirm that the update
  // are reset)
  await page
    .getByRole('button', {
      name: translations.buttons['check-code']
    })
    .click();

  await expect(
    page.getByText(translations.learn['sorry-keep-trying'])
  ).toBeVisible();

  // Reset the challenge
  await page.getByTestId('lowerJaw-reset-button').click();
  await page
    .getByRole('button', { name: translations.buttons['reset-lesson'] })
    .click();

  // Check it's back to the initial state
  await expect(initialFrame).toBeVisible({ timeout: 10000 });
  await expect(
    page.getByText(translations.learn['sorry-keep-trying'])
  ).not.toBeVisible();
});

test('User can reset classic challenge', async ({ page, isMobile }) => {
  await page.goto(
    '/learn/javascript-algorithms-and-data-structures/basic-javascript/comment-your-javascript-code'
  );

  const editorPaneLabel =
    'Editor content;Press Alt+F1 for Accessibility Options.';
  const challengeSolution = '// This is in-line comment';

  await page.getByLabel(editorPaneLabel).fill(challengeSolution);

  const submitButton = page.getByRole('button', {
    name: isMobile ? translations.buttons.run : translations.buttons['run-test']
  });
  await submitButton.click();

  await expect(
    page.locator('.view-lines').getByText(challengeSolution)
  ).toBeVisible();
  await expect(