|
1 | 1 | const { test, expect } = require('@playwright/test'); |
2 | 2 |
|
3 | | -test('Login - Shop',async({page}) => { |
4 | | - await page.goto('https://qa-practice.netlify.app/auth_ecommerce') |
| 3 | +// Verify the page title |
| 4 | +test('Verify page title: QA Practice | Learn with RV', async ({ page }) => { |
| 5 | + await page.goto('https://qa-practice.netlify.app/auth_ecommerce'); |
5 | 6 |
|
6 | | - // Expect a title "to contain" a substring. |
7 | | - await expect(page).toHaveTitle('QA Practice | Learn with RV') |
| 7 | + // Verify that the page title matches the expected value |
| 8 | + await expect(page).toHaveTitle('QA Practice | Learn with RV'); |
8 | 9 | }); |
9 | 10 |
|
10 | | -test('check-form-validation', async ({ page }) => { |
| 11 | +// Test form submission without entering any fields |
| 12 | +test('Verify form validation for empty fields', async ({ page }) => { |
11 | 13 | await page.goto('https://qa-practice.netlify.app/auth_ecommerce'); |
12 | 14 |
|
13 | | - // Check form validation without entering any fields & click on submit |
| 15 | + // Attempt to submit the form without filling in the fields |
14 | 16 | await page.getByRole('button', { name: 'Submit' }).click(); |
15 | 17 |
|
16 | | - const errorMessage = await page.getByText('Bad credentials! Please try'); |
17 | | - |
| 18 | + // Check if the error message is displayed |
| 19 | + const errorMessage = page.getByText('Bad credentials! Please try'); |
18 | 20 | await expect(errorMessage).toBeVisible(); |
19 | | - |
20 | | - await expect(errorMessage).toHaveText("Bad credentials! Please try again! Make sure that you've registered."); |
| 21 | + await expect(errorMessage).toHaveText( |
| 22 | + "Bad credentials! Please try again! Make sure that you've registered." |
| 23 | + ); |
21 | 24 | }); |
22 | 25 |
|
23 | | -test('check-form-validation-for-invalid-user-or-password', async ({ page }) => { |
24 | | - |
| 26 | +// Validate the form with invalid credentials |
| 27 | +test('Verify form validation for invalid credentials', async ({ page }) => { |
25 | 28 | await page.goto('https://qa-practice.netlify.app/auth_ecommerce'); |
26 | 29 |
|
| 30 | + // Fill the form with invalid email and password |
27 | 31 | await page.locator('#email').fill('test@gmail.com'); |
28 | | - |
29 | 32 | await page.locator('#password').fill('test@123'); |
30 | | - |
31 | 33 | await page.getByRole('button', { name: 'Submit' }).click(); |
32 | 34 |
|
33 | | - const errorMessage = await page.getByText('Bad credentials! Please try'); |
34 | | - |
| 35 | + // Check if the error message is displayed |
| 36 | + const errorMessage = page.getByText('Bad credentials! Please try'); |
35 | 37 | await expect(errorMessage).toBeVisible(); |
36 | | - |
37 | | - await expect(errorMessage).toHaveText("Bad credentials! Please try again! Make sure that you've registered."); |
38 | | - |
| 38 | + await expect(errorMessage).toHaveText( |
| 39 | + "Bad credentials! Please try again! Make sure that you've registered." |
| 40 | + ); |
39 | 41 | }); |
40 | 42 |
|
41 | | -test('check-form-for-valid-user-or-password', async ({ page }) => { |
42 | | - |
| 43 | +// Validate login functionality with valid credentials |
| 44 | +test('Verify login with valid credentials', async ({ page }) => { |
43 | 45 | await page.goto('https://qa-practice.netlify.app/auth_ecommerce'); |
44 | 46 |
|
| 47 | + // Fill the form with valid email and password |
45 | 48 | await page.locator('#email').fill('admin@admin.com'); |
46 | | - |
47 | 49 | await page.locator('#password').fill('admin123'); |
48 | | - |
49 | 50 | await page.getByRole('button', { name: 'Submit' }).click(); |
50 | 51 |
|
51 | | - const shoppingCart = await page.locator('text=SHOPPING CART'); |
52 | | - |
| 52 | + // Verify the presence of the shopping cart page |
| 53 | + const shoppingCart = page.locator('text=SHOPPING CART'); |
53 | 54 | await expect(shoppingCart).toBeVisible(); |
54 | | - |
55 | | - await expect(shoppingCart).toHaveText("SHOPPING CART"); |
56 | | - |
| 55 | + await expect(shoppingCart).toHaveText('SHOPPING CART'); |
57 | 56 | }); |
0 commit comments