Repository: freeCodeCamp/freeCodeCamp
File: e2e/hotkeys.spec.ts (TypeScript)

Code before:
  await page.keyboard.press('p');
  const previousCourse = '**/comment-your-javascript-code';
  await page.waitForURL(previousCourse);
  // Ensure that the page content is loaded before simulating user interactions.
  await expect(
    page.getByRole('heading', { name: 'Comment Your JavaScript Code' })
  ).toBeVisible();

  await page.keyboard.press('e');
  await expect(getEditors(page)).toBeFocused();

  await getEditors(page).press('Escape');
  await page.keyboard.press('r');
  await expect(page.locator('.instructions-panel')).toBeFocused();
});

test('User can use shortcuts to navigate between projects', async ({
  page
}) => {
  await page.goto(links.frontEnd1);
  await expect(page.locator('#editor-layout')).toBeFocused();
  await page.keyboard.press('Escape');
  await page.keyboard.press('n');

  await page.waitForURL(links.frontEnd2);
  await expect(page.locator('#editor-layout')).toBeFocused();
  await page.keyboard.press('p');
  await page.keyboard.press('Escape');
  await page.waitForURL(links.frontEnd1);
});

test('User can use shortcuts to navigate backend projects', async ({
  page
}) => {
  await page.goto(links.backEnd1);
  await expect(page.locator('#editor-layout')).toBeFocused();
  await page.keyboard.press('Escape');
  await page.keyboard.press('n');

  await page.waitForURL(links.backEnd2);
  await expect(page.locator('#editor-layout')).toBeFocused();
  await page.keyboard.press('p');
  await page.keyboard.press('Escape');
  await page.waitForURL(links.backEnd1);
});

test('User can use shortcuts to navigate videos', async ({ page }) => {
  await page.goto(links.video1);
  await expect(page.locator('#editor-layout')).toBeFocused();
  await page.keyboard.press('Escape');
  await page.keyboard.press('n');

Review comment (suggestion):
```suggestion
  await expect(getEditors(page)).toBeFocused();
```

Code after:
  await page.keyboard.press('p');
  const previousCourse = '**/comment-your-javascript-code';
  await page.waitForURL(previousCourse);
  // Ensure that the page content is loaded before simulating user interactions.
  await expect(
    page.getByRole('heading', { name: 'Comment Your JavaScript Code' })
  ).toBeVisible();

  await page.keyboard.press('e');
  await expect(getEditors(page)).toBeFocused();

  await getEditors(page).press('Escape');
  await page.keyboard.press('r');
  await expect(page.locator('.instructions-panel')).toBeFocused();
});

test('User can use shortcuts to navigate between frontend projects', async ({
  page
}) => {
  await page.goto(links.frontEnd1);
  await expect(page.locator('#editor-layout')).toBeFocused();
  await page.keyboard.press('Escape');
  await page.keyboard.press('n');

  await page.waitForURL(links.frontEnd2);
  await expect(page.locator('#editor-layout')).toBeFocused();
  await page.keyboard.press('p');
  await page.keyboard.press('Escape');
  await page.waitForURL(links.frontEnd1);
});

test('User can use shortcuts to navigate between backend projects', async ({
  page
}) => {
  await page.goto(links.backEnd1);
  await expect(page.locator('#editor-layout')).toBeFocused();
  await page.keyboard.press('Escape');
  await page.keyboard.press('n');

  await page.waitForURL(links.backEnd2);
  await expect(page.locator('#editor-layout')).toBeFocused();
  await page.keyboard.press('p');
  await page.keyboard.press('Escape');
  await page.waitForURL(links.backEnd1);
});

test('User can use shortcuts to navigate between video-based challenges', async ({
  page
}) => {
  await page.goto(links.video1);
  await expect(page.locator('#editor-layout')).toBeFocused();