Skip to content

Commit

Permalink
feat: Convert "Certifications" spec to Playwright (#54965)
Browse files Browse the repository at this point in the history
Co-authored-by: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com>
  • Loading branch information
Sembauke and huyenltnguyen committed Jun 3, 2024
1 parent 5eb0558 commit 59102f0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function CertButton({ username, cert }: CertButtonProps): JSX.Element {
block
size='large'
href={`/certification/${username}/${cert.certSlug}`}
data-cy='claimed-certification'
data-playwright-test-label='claimed-certification'
>
{t('buttons.view-cert-title', {
certTitle: t(`certification.title.${cert.certSlug}`)
Expand Down
1 change: 0 additions & 1 deletion client/src/components/settings/username.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ class UsernameSettings extends Component<UsernameProps, UsernameState> {
name='username-settings'
onChange={this.handleChange}
value={formValue}
data-cy='username-input'
id='username-settings'
/>
</FormGroup>
Expand Down
42 changes: 0 additions & 42 deletions cypress/e2e/default/user/certifications.ts

This file was deleted.

46 changes: 46 additions & 0 deletions e2e/cert-username-case-navigation.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { execSync } from 'child_process';
import { expect, test } from '@playwright/test';

test.describe('Public profile certifications', () => {
test.use({ storageState: 'playwright/.auth/certified-user.json' });
test('Should show claimed certifications if the username has all lowercase characters', async ({
page
}) => {
await page.goto('/certifieduser');

// If you build the client locally, delete the button click below.
if (!process.env.CI) {
await page
.getByRole('button', { name: 'Preview custom 404 page' })
.click();
}

await expect(page.getByTestId('claimed-certification')).toHaveCount(19);
});

test('Should show claimed certifications if the username includes uppercase characters', async ({
page
}) => {
await page.goto('/settings');
await page.getByLabel('Username').fill('CertifiedBoozer');
await page.getByRole('button', { name: 'Save' }).nth(0).click();
await expect(page.getByTestId('flash-message')).toContainText(
/We have updated your username to/
);
await page.goto('/certifiedboozer');

// If you build the client locally, delete the button click below.
if (!process.env.CI) {
await page
.getByRole('button', { name: 'Preview custom 404 page' })
.click();
}

await page.waitForURL('/certifiedboozer');
await expect(page.getByTestId('claimed-certification')).toHaveCount(19);
});

test.afterAll(() => {
execSync('node ./tools/scripts/seed/seed-demo-user certified-user');
});
});

0 comments on commit 59102f0

Please sign in to comment.