Skip to content

Commit 5510e96

Browse files
committed
Add loginTests file and 2 Test scenarios
1 parent 5d94300 commit 5510e96

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/loginTests.spec.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// @ts-check
2+
const { test, expect } = require('@playwright/test');
3+
4+
test.beforeEach(async ({ page }, testInfo) => {
5+
console.log(`Running ${testInfo.title}`);
6+
// Go to Conduit Page
7+
await page.goto('https://demo.realworld.io/#/');
8+
});
9+
10+
test('User can Login with VALID User', async ({ page }) => {
11+
// Go to Sign In page, enter login info and login
12+
await page.getByText('Sign in').click();
13+
await page.getByPlaceholder('Email').type('qaportfolioaz@gmail.com');
14+
await page.getByPlaceholder('Password').type('Loveqa!123');
15+
await page.getByRole('button', { name: 'Sign In' }).click();
16+
17+
// Verify the user logged in successfully
18+
await expect(page.getByRole('link', { name: 'Your Feed' })).toHaveText('Your Feed');
19+
await expect(page.getByRole('link', { name: 'Global Feed' })).toHaveText('Global Feed');
20+
});
21+
22+
test('User cannot login with INVALID User - Error appears', async ({ page }) => {
23+
24+
// Go to Sign In page, enter login info for an INVALID user and click Sign In
25+
await page.getByText('Sign in').click();
26+
await page.getByPlaceholder('Email').type('abc@gmail.com');
27+
await page.getByPlaceholder('Password').type('abc');
28+
await page.getByRole('button', { name: 'Sign In' }).click();
29+
30+
// Verify Error Message appears
31+
await expect(page.getByText('email or password is invalid')).toBeVisible();
32+
});

0 commit comments

Comments
 (0)