Repository: freeCodeCamp/freeCodeCamp
File: e2e/daily-coding-challenge.spec.ts (TypeScript)

Code before:
        status: 200,
        headers: { 'Content-Type': 'application/json' },
        json: { invalid: 'data structure' }
      });
    });

    await page.goto('/learn/daily-coding-challenge?date=2025-06-27');
    await expect(
      page.getByText(/daily coding challenge not found\./i)
    ).toBeVisible();
  });

  test('should load and display a daily coding challenge with a valid date, and should be able to switch between JavaScript and Python', async ({
    page
  }) => {
    await page.route(dateRouteRe, async route => {
      await route.fulfill({
        status: 200,
        headers: { 'Content-Type': 'application/json' },
        json: mockApiChallenge
      });
    });

    await page.goto(`/learn/daily-coding-challenge?date=${todayUsCentral}`);

    // Title
    await expect(page.getByText('Test title')).toBeVisible();

    // Description
    await expect(page.getByText('Test description')).toBeVisible();

    // Language buttons
    await expect(
      page.getByRole('button', { name: /javascript/i })
    ).toBeVisible();
    await expect(page.getByRole('button', { name: /python/i })).toBeVisible();

    // Should show JS UI by default

    // script.js button
    await expect(
      page.getByRole('button', { name: /script.js/i })
    ).toBeVisible();
    // No main.py button
    await expect(
      page.getByRole('button', { name: /main.py/i })
    ).not.toBeVisible();
    // Console Button
    await expect(page.getByRole('button', { name: /console/i })).toBeVisible();
    // No Preview button
    await expect(page.getByTestId('preview-pane-button')).not.toBeVisible();

Review comment (suggestion):
Nit, but I think we could get rid of these comments.

```suggestion
```

Code after:
        status: 200,
        headers: { 'Content-Type': 'application/json' },
        json: { invalid: 'data structure' }
      });
    });

    await page.goto('/learn/daily-coding-challenge?date=2025-06-27');
    await expect(
      page.getByText(/daily coding challenge not found\./i)
    ).toBeVisible();
  });

  test('should load and display a daily coding challenge with a valid date, and should be able to switch between JavaScript and Python', async ({
    page
  }) => {
    await page.route(dateRouteRe, async route => {
      await route.fulfill({
        status: 200,
        headers: { 'Content-Type': 'application/json' },
        json: mockApiChallenge
      });
    });

    await page.goto(`/learn/daily-coding-challenge?date=${todayUsCentral}`);

    await expect(page.getByText('Test title')).toBeVisible();

    await expect(page.getByText('Test description')).toBeVisible();

    // Language buttons
    await expect(
      page.getByRole('button', { name: /javascript/i })
    ).toBeVisible();
    await expect(page.getByRole('button', { name: /python/i })).toBeVisible();

    // Should show JS UI by default

    await expect(
      page.getByRole('button', { name: /script.js/i })
    ).toBeVisible();
    await expect(
      page.getByRole('button', { name: /main.py/i })
    ).not.toBeVisible();
    await expect(page.getByRole('button', { name: /console/i })).toBeVisible();
    await expect(page.getByTestId('preview-pane-button')).not.toBeVisible();
    await expect(page.locator("div[role='code'].monaco-editor")).toContainText(
      '// JavaScript seed code'
    );

    // Show show Python UI after changing language
    await page.getByRole('button', { name: /python/i }).click();