This repository has been archived by the owner on Jul 12, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
59d96fa
commit ea0a5d0
Showing
5 changed files
with
203 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default { | ||
default: { | ||
require: ["e2e/steps/*.ts"], | ||
format: ["pretty"], | ||
paths: ["e2e/features/*.feature"], | ||
parallel: 1, | ||
requireModule: ["ts-node/register"], | ||
publishQuiet: true, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,42 @@ | ||
import { | ||
test, | ||
expect, | ||
chromium, | ||
Page, | ||
Browser, | ||
BrowserContext, | ||
} from "@playwright/test"; | ||
import { Given, When, Then } from "@cucumber/cucumber"; | ||
import { Browser, BrowserContext, Page, chromium, expect } from "@playwright/test"; | ||
import { LoginPage } from "../pages/login.page"; | ||
|
||
test.describe("Login Feature", () => { | ||
let page: Page; | ||
let browser: Browser | BrowserContext; | ||
let loginPage: LoginPage; | ||
let page: Page; | ||
let browser: Browser | BrowserContext; | ||
let loginPage: LoginPage; | ||
|
||
test.beforeAll(async () => { | ||
browser = await chromium.launch(); | ||
page = await browser.newPage(); | ||
loginPage = new LoginPage(page, browser); | ||
}); | ||
|
||
test("should log in with valid credentials", async () => { | ||
await loginPage.goto(); | ||
await loginPage.setEmail("[email protected]"); | ||
await loginPage.setPassword("P@ssw0rd"); | ||
await loginPage.clickSubmit(); | ||
Given("a logged out user on the login page", async function () { | ||
browser = await chromium.launch({ headless: true }); | ||
const context = await browser.newContext(); | ||
page = await context.newPage(); | ||
loginPage = new LoginPage(page, browser); | ||
await loginPage.goto(); | ||
}); | ||
|
||
const homeText = await loginPage.isHomePage(); | ||
expect(homeText).toBe("Home"); | ||
}); | ||
When("the user logs in with valid credentials", async function () { | ||
await loginPage.setEmail("[email protected]"); | ||
await loginPage.setPassword("valid-password"); | ||
await loginPage.clickSubmit(); | ||
}); | ||
|
||
test("should display error with invalid credentials", async () => { | ||
await loginPage.goto(); | ||
await loginPage.setEmail("[email protected]"); | ||
await loginPage.setPassword("wrongpassword"); | ||
When( | ||
"the user logs in with invalid credentials like email {string} and password {string}", | ||
async function (email: string, password: string) { | ||
await loginPage.setEmail(email); | ||
await loginPage.setPassword(password); | ||
await loginPage.clickSubmit(); | ||
} | ||
); | ||
|
||
const isErrorDisplayed = await loginPage.isErrorDisplayed(); | ||
expect(isErrorDisplayed).toBeTruthy(); | ||
}); | ||
Then("they log in successfully", async function () { | ||
const headingText = await loginPage.isHomePage(); | ||
expect(headingText).toBe("Welcome to Rookie Shop"); | ||
await browser.close(); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await browser.close(); | ||
}); | ||
Then("login error message should be displayed", async function () { | ||
const isErrorVisible = await loginPage.isErrorDisplayed(); | ||
expect(isErrorVisible).toBe(true); | ||
await browser.close(); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters