fix(learn): multiple portfolio issues (#65427)

This commit is contained in:
Sem Bauke
2026-02-01 05:53:55 +01:00
committed by GitHub
parent 2b9427737f
commit 5fa0ccfd8e
3 changed files with 104 additions and 72 deletions
+54 -5
View File
@@ -2,10 +2,10 @@ import { execSync } from 'child_process';
import { test, expect } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';
test.use({ storageState: 'playwright/.auth/development-user.json' });
test.use({ storageState: 'playwright/.auth/certified-user.json' });
test.beforeAll(() => {
execSync('node ../tools/scripts/seed/seed-demo-user');
execSync('node ../tools/scripts/seed/seed-demo-user --certified-user');
});
test.afterAll(() => {
@@ -14,7 +14,7 @@ test.afterAll(() => {
test.describe('Add Portfolio Item', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/developmentuser');
await page.goto('/certifieduser');
if (!process.env.CI) {
await page
@@ -110,7 +110,9 @@ test.describe('Add Portfolio Item', () => {
.fill('https://my-portfolio.com');
await page
.getByLabel(translations.settings.labels.image)
.fill('https://my-portfolio.com/image.png');
.fill(
'https://cdn.freecodecamp.org/universal/favicons/favicon-32x32.png'
);
await page
.getByLabel(translations.settings.labels.description)
.fill('My description');
@@ -122,6 +124,14 @@ test.describe('Add Portfolio Item', () => {
await expect(page.getByTestId('portfolio-items')).toBeHidden();
});
test('The save button should be disabled when the form is pristine', async ({
page
}) => {
await expect(
page.getByRole('button', { name: 'Save this portfolio item' })
).toBeDisabled();
});
test('It should be possible to add a portfolio item', async ({ page }) => {
await expect(
page.getByRole('button', { name: 'Add a new portfolio Item' })
@@ -135,14 +145,53 @@ test.describe('Add Portfolio Item', () => {
.fill('https://my-portfolio.com');
await page
.getByLabel(translations.settings.labels.image)
.fill('https://my-portfolio.com/image.png');
.fill(
'https://cdn.freecodecamp.org/universal/favicons/favicon-32x32.png'
);
await page
.getByLabel(translations.settings.labels.description)
.fill('My description');
// Wait for async image validation to complete
await expect(
page.getByRole('button', { name: 'Save this portfolio item' })
).toBeEnabled();
await page
.getByRole('button', { name: 'Save this portfolio item' })
.click();
await page.getByRole('button', { name: 'Close' }).click();
await expect(page.getByRole('alert').first()).toContainText(
/We have updated your portfolio/
);
});
test('The edit modal should stay open after saving a portfolio item', async ({
page
}) => {
await page
.getByLabel(translations.settings.labels.title)
.first()
.fill('My portfolio');
await page
.getByLabel(translations.settings.labels.url)
.first()
.fill('https://my-portfolio.com');
// Wait for form validation to complete
await expect(
page.getByRole('button', { name: 'Save this portfolio item' }).first()
).toBeEnabled();
await page
.getByRole('button', { name: 'Save this portfolio item' })
.first()
.click();
// Modal should still be open and portfolio form should be visible
await expect(page.getByTestId('portfolio-items').first()).toBeVisible();
await page.getByRole('button', { name: 'Close' }).click();
await expect(page.getByRole('alert').first()).toContainText(
/We have updated your portfolio/
);