forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage-picture-check.spec.ts
47 lines (40 loc) · 1.43 KB
/
image-picture-check.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { test, expect } from '@playwright/test';
test.describe('Picture input field', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/certifieduser');
if (!process.env.CI) {
await page
.getByRole('button', { name: 'Preview custom 404 page' })
.click();
}
await page.getByRole('button', { name: 'Edit my profile' }).click();
});
test('Should be possible to type', async ({ page }) => {
const pictureInput = page.getByLabel('Picture');
await pictureInput.fill('');
await pictureInput.fill('twaha');
await expect(pictureInput).toHaveAttribute('value', 'twaha');
});
test('Show an error message if an incorrect url was submitted', async ({
page
}) => {
const pictureInput = page.getByLabel('Picture');
await pictureInput.fill('');
await pictureInput.fill(
'https://s3.amazonaws.com/freecodecamp/camper-image'
);
await expect(
page.getByText('URL must link directly to an image file')
).toBeVisible();
});
test('Can submit a correct URL', async ({ page }) => {
const pictureInput = page.getByLabel('Picture');
await pictureInput.fill('');
await pictureInput.fill(
'https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png'
);
const form = page.getByTestId('camper-identity');
const saveButton = form.getByRole('button', { name: 'Save' });
await expect(saveButton).toBeEnabled();
});
});