ronantakizawa/codereview-bench huggingface dataset:
Repository: freeCodeCamp/freeCodeCamp
File: e2e/settings.spec.ts (TypeScript)

Code before:
    ).toBeVisible();
    await expect(
      page.getByText(translations.settings.honesty.p2)
    ).toBeVisible();
    await expect(
      page.getByText(translations.settings.honesty.p3)
    ).toBeVisible();
    await expect(
      page.getByText(translations.settings.honesty.p4)
    ).toBeVisible();
    await expect(
      page.getByText(translations.settings.honesty.p5)
    ).toBeVisible();
    await expect(
      page.getByText(translations.settings.honesty.p6)
    ).toBeVisible();
    await expect(
      page.getByText(
        translations.settings.honesty.p7.replace(
          settingsObject.supportEmailPlaceholder,
          settingsObject.supportEmail
        )
      )
    ).toBeVisible();
  });
  test('Should validate Certification Settings', async ({
    page,
    browserName
  }) => {
    test.skip(browserName === 'webkit', 'csrf_token cookie is being deleted');
    await expect(
      page.getByRole('heading', {
        name: translations.settings.headings.certs,
        exact: true
      })
    ).toBeVisible();
    for (let i = 0; i < certifications.length; i++) {
      await expect(
        page.getByRole('heading', {
          name: certifications[i],
          exact: true
        })
      ).toBeVisible();
      await expect(
        page.getByRole('link', {
          name: `${translations.buttons['show-cert']} ${certifications[i]}`
        })
      ).toBeVisible();
    }
  });


Review comment (suggestion):
```suggestion
  });
  
  test('Should validate Certification Settings', async ({
```

Code after:
    ).toBeVisible();
    for (let i = 0; i < certifications.length; i++) {
      await expect(
        page.getByRole('heading', {
          name: certifications[i],
          exact: true
        })
      ).toBeVisible();
      await expect(
        page.getByRole('link', {
          name: `${translations.buttons['show-cert']} ${certifications[i]}`
        })
      ).toBeVisible();
    }
  });

  test('Should validate Legacy Certification Settings', async ({
    page,
    browserName
  }) => {
    test.skip(browserName === 'webkit', 'csrf_token cookie is being deleted');
    await expect(
      page.getByRole('heading', {
        name: translations.settings.headings['legacy-certs'],
        exact: true
      })
    ).toBeVisible();
    for (let i = 0; i < legacyCertifications.length; i++) {
      await expect(
        page.getByRole('heading', {
          name: legacyCertifications[i],
          exact: true
        })
      ).toBeVisible();
      await expect(
        page.getByRole('link', {
          name: `${translations.buttons['show-cert']} ${legacyCertifications[i]}`,
          exact: true
        })
      ).toBeVisible();
    }
  });

  test('Should validate Danger Section Settings', async ({
    page,
    browserName
  }) => {
    test.skip(browserName === 'webkit', 'csrf_token cookie is being deleted');
    await expect(
      page.getByText(translations.settings.danger.heading, {
        exact: true
Repository: freeCodeCamp/freeCodeCamp
File: e2e/settings.spec.ts (TypeScript)

Code before:
    page,
    browserName
  }) => {
    test.skip(browserName === 'webkit', 'csrf_token cookie is being deleted');
    await expect(
      page.getByRole('heading', {
        name: translations.settings.headings['legacy-certs'],
        exact: true
      })
    ).toBeVisible();
    for (let i = 0; i < legacyCertifications.length; i++) {
      await expect(
        page.getByRole('heading', {
          name: legacyCertifications[i],
          exact: true
        })
      ).toBeVisible();
      await expect(
        page.getByRole('link', {
          name: `${translations.buttons['show-cert']} ${legacyCertifications[i]}`,
          exact: true
        })
      ).toBeVisible();
    }
  });
  test('Should validate Danger Section Settings', async ({
    page,
    browserName
  }) => {
    test.skip(browserName === 'webkit', 'csrf_token cookie is being deleted');
    await expect(
      page.getByText(translations.settings.danger.heading, {
        exact: true
      })
    ).toBeVisible();
    await expect(
      page.getByText(translations.settings.danger['be-careful'], {
        exact: true
      })
    ).toBeVisible();
    await page
      .getByRole('button', {
        name: translations.settings.danger.reset,
        exact: true
      })
      .click();
    await page
      .getByRole('button', {
        name: translations.settings.danger['nevermind-2'],
        exact: true
      })

Review comment (suggestion):
```suggestion
  });
  
  test('Should validate Danger Section Settings', async ({
```

Code after:
    ).toBeVisible();
    await expect(
      page.getByText(translations.settings.danger['be-careful'], {
        exact: true
      })
    ).toBeVisible();
    await page
      .getByRole('button', {
        name: translations.settings.danger.reset,
        exact: true
      })
      .click();
    await page
      .getByRole('button', {
        name: translations.settings.danger['nevermind-2'],
        exact: true
      })
      .click();
    await expect(
      page.getByRole('button', {
        name: translations.settings.danger['reset-confirm'],
        exact: true
      })
    ).toBeVisible();
    await page
      .getByRole('button', {
        name: translations.settings.danger.delete,
        exact: true
      })
      .click();
    await page
      .getByRole('button', {
        name: translations.settings.danger.nevermind,
        exact: true
      })
      .click();
    await expect(
      page.getByRole('button', {
        name: translations.settings.danger.certain,
        exact: true
      })
    ).toBeVisible();
  });
});
Repository: freeCodeCamp/freeCodeCamp
File: e2e/unsubscribed.spec.ts (TypeScript)

Code before:
import { test, expect, type Page } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';
import metaTags from '../client/i18n/locales/english/meta-tags.json';

let page: Page;

test.afterAll(async () => {
  await page.close();
});

test.describe('The unsubscribed page without unsubscribeId', () => {
  test.beforeAll(async ({ browser }) => {
    page = await browser.newPage();
    await page.goto('/unsubscribed');
  });

  test('The page renders with correct title', async () => {
    await expect(page).toHaveTitle(
      `${metaTags['youre-unsubscribed']} | freeCodeCamp.org`
    );
  });

  test('The page has correct main heading', async () => {
    const mainHeading = page.getByTestId('main-heading');

    await expect(mainHeading).toBeVisible();
    await expect(mainHeading).toContainText(translations.misc['unsubscribed']);
  });

  test('The page has correct motivation text', async () => {
    const motivationText = page.getByTestId('motivation-text');

    await expect(motivationText).toBeVisible();
    await expect(motivationText).toContainText(
      translations.misc['keep-coding']
    );
  });

  test('The page has no button to resubscribe', async () => {
    const resubscribeButton = page.getByRole('link', {

Review comment (suggestion):
```suggestion
test.afterEach(async ({ page }) => {
  await page.close();
});

test.describe('The unsubscribed page without unsubscribeId', () => {
  test.beforeEach(async ({ page }) => {
    await page.goto('/unsubscribed');
  });
```

We should ideally run tests in isolation.

Code after:
import { test, expect } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';
import metaTags from '../client/i18n/locales/english/meta-tags.json';

test.afterEach(async ({ page }) => {
  await page.close();
});

test.describe('The unsubscribed page without unsubscribeId', () => {
  test.beforeEach(async ({ page }) => {
    await page.goto('/unsubscribed');
  });

  test('The page renders with correct title', async ({ page }) => {
    await expect(page).toHaveTitle(
      `${metaTags['youre-unsubscribed']} | freeCodeCamp.org`
    );
  });

  test('The page has correct main heading', async ({ page }) => {
    const mainHeading = page.getByTestId('main-heading');

    await expect(mainHeading).toBeVisible();
    await expect(mainHeading).toContainText(translations.misc['unsubscribed']);
  });

  test('The page has correct motivation text', async ({ page }) => {
    const motivationText = page.getByTestId('motivation-text');

    await expect(motivationText).toBeVisible();
    await expect(motivationText).toContainText(
      translations.misc['keep-coding']
    );
  });

  test('The page has no button to resubscribe', async ({ page }) => {
    const resubscribeButton = page.getByRole('link', {
      name: translations.buttons['resubscribe']
    });
Repository: freeCodeCamp/freeCodeCamp
File: e2e/unsubscribed.spec.ts (TypeScript)

Code before:
import { test, expect, type Page } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';
import metaTags from '../client/i18n/locales/english/meta-tags.json';

let page: Page;

test.afterAll(async () => {
  await page.close();
});

test.describe('The unsubscribed page without unsubscribeId', () => {
  test.beforeAll(async ({ browser }) => {
    page = await browser.newPage();
    await page.goto('/unsubscribed');
  });

  test('The page renders with correct title', async () => {
    await expect(page).toHaveTitle(
      `${metaTags['youre-unsubscribed']} | freeCodeCamp.org`
    );
  });

  test('The page has correct main heading', async () => {
    const mainHeading = page.getByTestId('main-heading');

    await expect(mainHeading).toBeVisible();
    await expect(mainHeading).toContainText(translations.misc['unsubscribed']);
  });

  test('The page has correct motivation text', async () => {

Review comment (suggestion):
```suggestion
import { test, expect } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';
import metaTags from '../client/i18n/locales/english/meta-tags.json';
```

We don't need a global page variable because...

Code after:
import { test, expect } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';
import metaTags from '../client/i18n/locales/english/meta-tags.json';

test.afterEach(async ({ page }) => {
  await page.close();
});

test.describe('The unsubscribed page without unsubscribeId', () => {
  test.beforeEach(async ({ page }) => {
    await page.goto('/unsubscribed');
  });

  test('The page renders with correct title', async ({ page }) => {
    await expect(page).toHaveTitle(
      `${metaTags['youre-unsubscribed']} | freeCodeCamp.org`
    );
  });

  test('The page has correct main heading', async ({ page }) => {
    const mainHeading = page.getByTestId('main-heading');

    await expect(mainHeading).toBeVisible();
    await expect(mainHeading).toContainText(translations.misc['unsubscribed']);
  });

  test('The page has correct motivation text', async ({ page }) => {
    const motivationText = page.getByTestId('motivation-text');

    await expect(motivationText).toBeVisible();
Repository: freeCodeCamp/freeCodeCamp
File: e2e/unsubscribed.spec.ts (TypeScript)

Code before:
import { test, expect, type Page } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';
import metaTags from '../client/i18n/locales/english/meta-tags.json';

let page: Page;

test.afterAll(async () => {
  await page.close();
});

test.describe('The unsubscribed page without unsubscribeId', () => {
  test.beforeAll(async ({ browser }) => {
    page = await browser.newPage();
    await page.goto('/unsubscribed');
  });

  test('The page renders with correct title', async () => {
    await expect(page).toHaveTitle(
      `${metaTags['youre-unsubscribed']} | freeCodeCamp.org`
    );
  });

  test('The page has correct main heading', async () => {
    const mainHeading = page.getByTestId('main-heading');

    await expect(mainHeading).toBeVisible();
    await expect(mainHeading).toContainText(translations.misc['unsubscribed']);
  });

  test('The page has correct motivation text', async () => {
    const motivationText = page.getByTestId('motivation-text');

    await expect(motivationText).toBeVisible();
    await expect(motivationText).toContainText(
      translations.misc['keep-coding']
    );
  });

  test('The page has no button to resubscribe', async () => {
    const resubscribeButton = page.getByRole('link', {
      name: translations.buttons['resubscribe']
    });

Review comment (suggestion):
```suggestion
  test('The page renders with correct title', async ({ page }) => {
```

We can get `page` from the function args.

Code after:
import { test, expect } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';
import metaTags from '../client/i18n/locales/english/meta-tags.json';

test.afterEach(async ({ page }) => {
  await page.close();
});

test.describe('The unsubscribed page without unsubscribeId', () => {
  test.beforeEach(async ({ page }) => {
    await page.goto('/unsubscribed');
  });

  test('The page renders with correct title', async ({ page }) => {
    await expect(page).toHaveTitle(
      `${metaTags['youre-unsubscribed']} | freeCodeCamp.org`
    );
  });

  test('The page has correct main heading', async ({ page }) => {
    const mainHeading = page.getByTestId('main-heading');

    await expect(mainHeading).toBeVisible();
    await expect(mainHeading).toContainText(translations.misc['unsubscribed']);
  });

  test('The page has correct motivation text', async ({ page }) => {
    const motivationText = page.getByTestId('motivation-text');

    await expect(motivationText).toBeVisible();
    await expect(motivationText).toContainText(
      translations.misc['keep-coding']
    );
  });

  test('The page has no button to resubscribe', async ({ page }) => {
    const resubscribeButton = page.getByRole('link', {
      name: translations.buttons['resubscribe']
    });

    await expect(resubscribeButton).not.toBeVisible();
  });
Repository: freeCodeCamp/freeCodeCamp
File: e2e/unsubscribed.spec.ts (TypeScript)

Code before:
  const unsubscribeId = 'tBX8stC5jiustPBteF2mV';

  test.beforeAll(async ({ browser }) => {
    page = await browser.newPage();
    await page.goto(`/unsubscribed/${unsubscribeId}`);
  });

  test('The page renders with correct title and other texts', async () => {
    await expect(page).toHaveTitle(
      `${metaTags['youre-unsubscribed']} | freeCodeCamp.org`
    );

    const mainHeading = page.getByTestId('main-heading');

    await expect(mainHeading).toBeVisible();
    await expect(mainHeading).toContainText(translations.misc['unsubscribed']);

    const motivationText = page.getByTestId('motivation-text');

    await expect(motivationText).toBeVisible();
    await expect(motivationText).toContainText(
      translations.misc['keep-coding']
    );
  });

  test('Resubscribe and redirect to home with encoded text in the url', async () => {
    const resubscribeButton = page.getByRole('link', {
      name: translations.buttons['resubscribe']
    });

    await expect(resubscribeButton).toBeVisible();
    const resubscribeButtonHref = await resubscribeButton.getAttribute('href');
    expect(resubscribeButtonHref).toContain(`/resubscribe/${unsubscribeId}`);
    await resubscribeButton.click();

    await expect(page).toHaveURL(`${encoded_url_text}`);
  });
});


Review comment (suggestion):
```suggestion
  test('Resubscribe and redirect to home with encoded text in the url', async ({ page }) => {
```

Code after:
    await page.goto(`/unsubscribed/${unsubscribeId}`);
  });

  test('The page renders with correct title and other texts', async ({
    page
  }) => {
    await expect(page).toHaveTitle(
      `${metaTags['youre-unsubscribed']} | freeCodeCamp.org`
    );

    const mainHeading = page.getByTestId('main-heading');

    await expect(mainHeading).toBeVisible();
    await expect(mainHeading).toContainText(translations.misc['unsubscribed']);

    const motivationText = page.getByTestId('motivation-text');

    await expect(motivationText).toBeVisible();
    await expect(motivationText).toContainText(
      translations.misc['keep-coding']
    );
  });

  test('Resubscribe and redirect to home with encoded text in the url', async ({
    page
  }) => {
    const resubscribeButton = page.getByRole('link', {
      name: translations.buttons['resubscribe']
    });

    await expect(resubscribeButton).toBeVisible();
    const resubscribeButtonHref = await resubscribeButton.getAttribute('href');
    expect(resubscribeButtonHref).toContain(`/resubscribe/${unsubscribeId}`);
    await resubscribeButton.click();

    await expect(page).toHaveURL(`${encoded_url_text}`);
  });
});
Repository: freeCodeCamp/freeCodeCamp
File: e2e/ms-trophy-show.spec.ts (TypeScript)

Code before:
import { test, expect } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';

const verifyTrophy = translations.buttons['verify-trophy'];
const askForHelpButton = translations.buttons['ask-for-help'];

test.beforeEach(async ({ page }) => {
  await page.goto(
    '/learn/foundational-c-sharp-with-microsoft/write-your-first-code-using-c-sharp/trophy-write-your-first-code-using-c-sharp'
  );
});

test.afterEach(async ({ page }) => {
  await page.close();
});

test('the page should render with correct title', async ({ page }) => {
  await expect(page).toHaveTitle(
    'Write Your First Code Using C# - Trophy - Write Your First Code Using C# | Learn | freeCodeCamp.org'
  );
});

test('Correct Verify Trophy button', async ({ page }) => {
  const askHelp = page.getByTestId('verify-trophy-button');
  await expect(askHelp).toBeVisible();
  await expect(askHelp).toContainText(verifyTrophy);
});

test('Correct Ask for help button', async ({ page }) => {

Review comment (suggestion):
```suggestion
const verifyTrophyButtonText = translations.buttons['verify-trophy'];
```

Code after:
import { test, expect } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';

const verifyTrophyButtonText = translations.buttons['verify-trophy'];
const askForHelpButtonText = translations.buttons['ask-for-help'];

test.beforeEach(async ({ page }) => {
  await page.goto(
    '/learn/foundational-c-sharp-with-microsoft/write-your-first-code-using-c-sharp/trophy-write-your-first-code-using-c-sharp'
  );
});

test.afterEach(async ({ page }) => {
  await page.close();
});

test('the page should render with correct title', async ({ page }) => {
  await expect(page).toHaveTitle(
    'Write Your First Code Using C# - Trophy - Write Your First Code Using C# | Learn | freeCodeCamp.org'
  );
});

test('Correct Verify Trophy button', async ({ page }) => {
  const askHelpButton = page.getByRole('button', {
    name: verifyTrophyButtonText
  });
  await expect(askHelpButton).toBeVisible();
  await expect(askHelpButton).toHaveText(verifyTrophyButtonText);
});
Repository: freeCodeCamp/freeCodeCamp
File: e2e/ms-trophy-show.spec.ts (TypeScript)

Code before:
import { test, expect } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';

const verifyTrophy = translations.buttons['verify-trophy'];
const askForHelpButton = translations.buttons['ask-for-help'];

test.beforeEach(async ({ page }) => {
  await page.goto(
    '/learn/foundational-c-sharp-with-microsoft/write-your-first-code-using-c-sharp/trophy-write-your-first-code-using-c-sharp'
  );
});

test.afterEach(async ({ page }) => {
  await page.close();
});

test('the page should render with correct title', async ({ page }) => {
  await expect(page).toHaveTitle(
    'Write Your First Code Using C# - Trophy - Write Your First Code Using C# | Learn | freeCodeCamp.org'
  );
});

test('Correct Verify Trophy button', async ({ page }) => {
  const askHelp = page.getByTestId('verify-trophy-button');
  await expect(askHelp).toBeVisible();
  await expect(askHelp).toContainText(verifyTrophy);
});

test('Correct Ask for help button', async ({ page }) => {
  const checkAnswer = page.getByTestId('ask-for-help-button');

Review comment (suggestion):
```suggestion
const askForHelpButtonText = translations.buttons['ask-for-help'];
```

Code after:
import { test, expect } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';

const verifyTrophyButtonText = translations.buttons['verify-trophy'];
const askForHelpButtonText = translations.buttons['ask-for-help'];

test.beforeEach(async ({ page }) => {
  await page.goto(
    '/learn/foundational-c-sharp-with-microsoft/write-your-first-code-using-c-sharp/trophy-write-your-first-code-using-c-sharp'
  );
});

test.afterEach(async ({ page }) => {
  await page.close();
});

test('the page should render with correct title', async ({ page }) => {
  await expect(page).toHaveTitle(
    'Write Your First Code Using C# - Trophy - Write Your First Code Using C# | Learn | freeCodeCamp.org'
  );
});

test('Correct Verify Trophy button', async ({ page }) => {
  const askHelpButton = page.getByRole('button', {
    name: verifyTrophyButtonText
  });
  await expect(askHelpButton).toBeVisible();
  await expect(askHelpButton).toHaveText(verifyTrophyButtonText);
});
Repository: freeCodeCamp/freeCodeCamp
File: e2e/ms-trophy-show.spec.ts (TypeScript)

Code before:
import { test, expect } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';

const verifyTrophy = translations.buttons['verify-trophy'];
const askForHelpButton = translations.buttons['ask-for-help'];

test.beforeEach(async ({ page }) => {
  await page.goto(
    '/learn/foundational-c-sharp-with-microsoft/write-your-first-code-using-c-sharp/trophy-write-your-first-code-using-c-sharp'
  );
});

test.afterEach(async ({ page }) => {
  await page.close();
});

test('the page should render with correct title', async ({ page }) => {
  await expect(page).toHaveTitle(
    'Write Your First Code Using C# - Trophy - Write Your First Code Using C# | Learn | freeCodeCamp.org'
  );
});

test('Correct Verify Trophy button', async ({ page }) => {
  const askHelp = page.getByTestId('verify-trophy-button');
  await expect(askHelp).toBeVisible();
  await expect(askHelp).toContainText(verifyTrophy);
});

test('Correct Ask for help button', async ({ page }) => {
  const checkAnswer = page.getByTestId('ask-for-help-button');
  await expect(checkAnswer).toBeVisible();
  await expect(checkAnswer).toContainText(askForHelpButton);
});


Review comment (suggestion):
```suggestion
  const askHelp = page.getByRole('button', { name: verifyTrophyButtonText })
    ).toBeVisible();
```

Code after:
import { test, expect } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';

const verifyTrophyButtonText = translations.buttons['verify-trophy'];
const askForHelpButtonText = translations.buttons['ask-for-help'];

test.beforeEach(async ({ page }) => {
  await page.goto(
    '/learn/foundational-c-sharp-with-microsoft/write-your-first-code-using-c-sharp/trophy-write-your-first-code-using-c-sharp'
  );
});

test.afterEach(async ({ page }) => {
  await page.close();
});

test('the page should render with correct title', async ({ page }) => {
  await expect(page).toHaveTitle(
    'Write Your First Code Using C# - Trophy - Write Your First Code Using C# | Learn | freeCodeCamp.org'
  );
});

test('Correct Verify Trophy button', async ({ page }) => {
  const askHelpButton = page.getByRole('button', {
    name: verifyTrophyButtonText
  });
  await expect(askHelpButton).toBeVisible();
  await expect(askHelpButton).toHaveText(verifyTrophyButtonText);
});

test('Correct Ask for help button', async ({ page }) => {
  const checkAnswerButton = page.getByRole('button', {
    name: askForHelpButtonText
  });
  await expect(checkAnswerButton).toBeVisible();
  await expect(checkAnswerButton).toContainText(askForHelpButtonText);
});