Repository: freeCodeCamp/freeCodeCamp
File: e2e/multifile-cert-projects.spec.ts (TypeScript)

Code before:
test.use({ storageState: 'playwright/.auth/certified-user.json' });
test.describe('multifileCertProjects', () => {
  test.beforeEach(async ({ page }) => {
    await page.goto(
      'learn/2022/responsive-web-design/build-a-tribute-page-project/build-a-tribute-page'
    );
    execSync('node ./tools/scripts/seed/seed-demo-user certified-user');
  });
  test('should save and reload user code', async ({ page, isMobile }) => {
    await focusEditor({ page, isMobile });

    if (isMacOS) {
      await page.keyboard.press('Meta+A');
    } else {
      await page.keyboard.press('Control+A');
    }

    await page.keyboard.press('Backspace');

    await page.keyboard.type('save1text');
    await expect(page.getByText('save1text')).toBeVisible();

    await page.getByRole('button', { name: 'Save your Code' }).click();

    await expect(page.getByTestId('flash-message')).toContainText(
      /Your code was saved to the database. It will be here when you return./
    );

    await page.reload();

    await expect(page.getByText('save1text')).toBeVisible();
  });

  test('should save using ctrl+s hotkey and persist through navigation', async ({
    page,
    isMobile
  }) => {
    await focusEditor({ page, isMobile });

    if (isMacOS) {
      await page.keyboard.press('Meta+A');
    } else {
      await page.keyboard.press('Control+A');
    }

    await page.keyboard.type('save2text');
    await expect(page.getByText('save2text')).toBeVisible();

    await page.keyboard.down('Control');
    await page.keyboard.press('KeyS');


Review comment (suggestion):
```suggestion
      /Your code was saved to the database\. It will be here when you return\./
```

Code after:
test.use({ storageState: 'playwright/.auth/certified-user.json' });
test.describe('multifileCertProjects', () => {
  test.beforeEach(async ({ page }) => {
    await page.goto(
      'learn/2022/responsive-web-design/build-a-tribute-page-project/build-a-tribute-page'
    );
    execSync('node ./tools/scripts/seed/seed-demo-user certified-user');
  });
  test('should save and reload user code', async ({ page, isMobile }) => {
    await focusEditor({ page, isMobile });

    if (isMacOS) {
      await page.keyboard.press('Meta+A');
    } else {
      await page.keyboard.press('Control+A');
    }

    await page.keyboard.press('Backspace');

    await page.keyboard.type('save1text');
    await expect(page.getByText('save1text')).toBeVisible();

    await page.getByRole('button', { name: 'Save your Code' }).click();

    await expect(page.getByTestId('flash-message')).toContainText(
      /Your code was saved to the database\. It will be here when you return\./
    );

    await page.reload();

    await expect(page.getByText('save1text')).toBeVisible();
  });

  test('should save using ctrl+s hotkey and persist through navigation', async ({
    page,
    isMobile
  }) => {
    await focusEditor({ page, isMobile });

    if (isMacOS) {
      await page.keyboard.press('Meta+A');
    } else {
      await page.keyboard.press('Control+A');
    }

    await page.keyboard.type('save2text');
    await expect(page.getByText('save2text')).toBeVisible();

    await page.keyboard.down('Control');
    await page.keyboard.press('KeyS');