Skip to content

Commit 91edd19

Browse files
committed
registration implementation
1 parent 5ea480b commit 91edd19

File tree

9 files changed

+92
-7
lines changed

9 files changed

+92
-7
lines changed

cucumber.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@ module.exports = {
1010

1111
requireModule: ['ts-node/register'],
1212

13+
formatOptions: {
14+
snippetInterface: "async-await"
15+
},
16+
1317
paths: ['tests/features/**/*.feature'],
1418

1519
publishQuiet: true,
1620

17-
format: ['progress', 'html:cucumber-report.html']
21+
format: ['progress', 'html:cucumber-report.html'],
22+
"dryRun": false
1823

1924
}
2025

package-lock.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
"test-tag": "npx playwright test --grep @tagName",
1010
"test-smoke": "npx playwright test --grep @smoke",
1111
"report": "npx playwright show-report"
12-
},
12+
},
1313
"keywords": [],
1414
"author": "Amine",
1515
"license": "ISC",
1616
"description": "",
1717
"devDependencies": {
1818
"@cucumber/cucumber": "^12.2.0",
19+
"@faker-js/faker": "^9.9.0",
1920
"@playwright/test": "^1.56.0",
2021
"@types/cucumber": "^6.0.1",
2122
"@types/node": "^24.7.2",

playwright.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ export default defineConfig({
3131
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
3232
trace: "on-first-retry",
3333
headless: false,
34-
screenshot: 'only-on-failure'
34+
screenshot: "only-on-failure",
35+
// viewport: null,
36+
// launchOptions: {
37+
// args: ["--start-maximized"], // opens browser maximized
38+
// },
3539
},
3640

3741
/* Configure projects for major browsers */

tests/features/login.feature

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ Feature: User Login
55
When user enters valid username and password
66
And user click the login button
77
Then user should see the user dashboard
8-
98
# Scenario: Verify unsuccessful login with invalid password
109
# Given user navigates to the login page
1110
# When user enters invalid username or password
1211
# And user click the login button
13-
# Then user should see an error message
14-
12+
# Then user should see an error message "Invalid email or password"
1513
# Scenario: Verify unsuccessful login with invalid username and password
1614
# Given user navigates to the login page
1715
# When user enters invalid username and password
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@wip
2+
Feature: User registration
3+
In order to access the application
4+
As a new user
5+
I want to register with valid details
6+
7+
Scenario: Successful user registration with valid data
8+
Given the user is on the registration page
9+
When the user fills the registration form with valid details
10+
And clicks the register button
11+
Then the user should be redirected to the login page

tests/hooks/hooks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ After(async function (this: CustomWorld) {
2020
if (this.page) await this.page.close();
2121
if (this.browser) await this.browser.close();
2222
});
23+

tests/steps/login.steps.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//import { page } from "./world";
21
import settings from "../config/settings.json"; // adjust path if needed
32
import { Given, When, Then } from "@cucumber/cucumber";
43
import { expect } from "@playwright/test";

tests/steps/registration.steps.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import settings from "../config/settings.json"; // adjust path if needed
2+
import { Given, When, Then } from "@cucumber/cucumber";
3+
import { expect } from "@playwright/test";
4+
import { faker } from "@faker-js/faker/locale/en"; // Import faker with a specific locale
5+
6+
Given("the user is on the registration page", async function () {
7+
await this.page.goto(settings.REGISTRATION_URL);
8+
});
9+
10+
When(
11+
"the user fills the registration form with valid details",
12+
async function () {
13+
let firstName = this.page.locator("#first_name");
14+
let lastName = this.page.locator("#last_name");
15+
let dob = this.page.locator("#dob");
16+
let street = this.page.locator("#street");
17+
let postalCode = this.page.locator("#postal_code");
18+
let city = this.page.locator("#city");
19+
let state = this.page.locator("#state");
20+
let phone = this.page.locator("#phone");
21+
let email = this.page.locator("#email");
22+
let password = this.page.locator("#password");
23+
let countryDropdown = this.page.locator("select#country");
24+
25+
//fill in form details
26+
await firstName.fill(faker.person.firstName());
27+
await lastName.fill(faker.person.lastName());
28+
await dob.fill("1990-01-01");
29+
await street.fill(faker.location.streetAddress());
30+
await postalCode.fill(faker.location.zipCode());
31+
await city.fill(faker.location.city());
32+
await state.fill(faker.location.state());
33+
await countryDropdown.selectOption({ label: "Canada" });
34+
const phoneNumber = faker.string.numeric(10); // generates a string exactly 10 digits long
35+
await phone.fill(phoneNumber);
36+
await email.fill(faker.internet.email());
37+
await password.fill(settings.PASSWORD);
38+
}
39+
);
40+
41+
When("clicks the register button", async function () {
42+
await this.page.locator("//button[@type='submit']").click();
43+
});
44+
45+
Then("the user should be redirected to the login page", async function () {
46+
expect(this.page.url()).toBe(settings.LOGIN_URL);
47+
expect(await this.page.locator("h3").textContent()).toBe("Login");
48+
});

0 commit comments

Comments
 (0)