Skip to content

Commit

Permalink
refactor(e2e): optimize portfolio tests (freeCodeCamp#56843)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sembauke authored Oct 25, 2024
1 parent a2eaba1 commit df4c4e3
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions e2e/portfolio.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ test.describe('Add Portfolio Item', () => {
}

await page.getByRole('button', { name: 'Edit my profile' }).click();
});

test('The title has validation', async ({ page }) => {
await page
.getByRole('button', { name: 'Add a new portfolio Item' })
.click();
});

test('The title has validation', async ({ page }) => {
await page.getByLabel(translations.settings.labels.title).fill('T');
await expect(page.getByTestId('title-validation')).toContainText(
'Title is too short'
Expand All @@ -49,9 +50,6 @@ test.describe('Add Portfolio Item', () => {
});

test('The url has validation', async ({ page }) => {
await page
.getByRole('button', { name: 'Add a new portfolio Item' })
.click();
await page.getByLabel(translations.settings.labels.url).fill('T');
await expect(page.getByTestId('url-validation')).toContainText(
'Please use a valid URL'
Expand All @@ -63,9 +61,6 @@ test.describe('Add Portfolio Item', () => {
});

test('The image has validation', async ({ page }) => {
await page
.getByRole('button', { name: 'Add a new portfolio Item' })
.click();
await page.getByLabel(translations.settings.labels.image).fill('T');
await expect(page.getByTestId('image-validation')).toContainText(
'URL must link directly to an image file'
Expand All @@ -77,9 +72,6 @@ test.describe('Add Portfolio Item', () => {
});

test('The description has validation', async ({ page }) => {
await page
.getByRole('button', { name: 'Add a new portfolio Item' })
.click();
await page
.getByLabel(translations.settings.labels.description)
.fill(
Expand All @@ -95,9 +87,6 @@ test.describe('Add Portfolio Item', () => {
});

test('It should be possible to delete a portfolio item', async ({ page }) => {
await page
.getByRole('button', { name: 'Add a new portfolio Item' })
.click();
await page
.getByLabel(translations.settings.labels.title)
.fill('My portfolio');
Expand All @@ -119,9 +108,6 @@ test.describe('Add Portfolio Item', () => {
});

test('It should be possible to add a portfolio item', async ({ page }) => {
await page
.getByRole('button', { name: 'Add a new portfolio Item' })
.click();
await expect(
page.getByRole('button', { name: 'Add a new portfolio Item' })
).toBeDisabled();
Expand Down

0 comments on commit df4c4e3

Please sign in to comment.