Skip to content

Commit fd16a02

Browse files
committed
feat: update test cases
- remove test cases as per new requirements - update tests due to website changes
1 parent ac6c10a commit fd16a02

File tree

1 file changed

+8
-30
lines changed

1 file changed

+8
-30
lines changed

tests/auth.spec.ts

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ test.beforeAll('setup: create test user if not exists', async ({ browser }) => {
3838
await page.goto('/register.php');
3939

4040
// Try to create the test user
41-
await page.fill('input[name="name"]', TEST_USER_NAME);
41+
await page.fill('input[name="first_name"]', TEST_USER_NAME);
42+
await page.fill('input[name="last_name"]', TEST_USER_NAME);
4243
await page.fill('input[name="email"]', TEST_USER_EMAIL);
4344
await page.fill('input[name="password"]', TEST_USER_PASSWORD);
4445

@@ -56,7 +57,8 @@ test.beforeAll('setup: create test user if not exists', async ({ browser }) => {
5657
function generateUniqueUser() {
5758
const uniqueId = `${Date.now()}-${crypto.randomBytes(4).toString('hex')}`;
5859
return {
59-
name: `TestUser-${uniqueId}`,
60+
first_name: `${uniqueId}`,
61+
last_name: `TestUser`,
6062
email: `test+${uniqueId}@example.com`,
6163
password: 'Password123!'
6264
};
@@ -70,7 +72,8 @@ test.describe("User Registration", () => {
7072
const user = generateUniqueUser();
7173

7274
// Fill in registration form with unique email
73-
await page.fill('input[name="name"]', user.name);
75+
await page.fill('input[name="first_name"]', user.first_name);
76+
await page.fill('input[name="last_name"]', user.last_name);
7477
await page.fill('input[name="email"]', user.email);
7578
await page.fill('input[name="password"]', user.password);
7679
await page.getByRole('button', { name: 'Create Account' }).click();
@@ -80,25 +83,13 @@ test.describe("User Registration", () => {
8083
// Comment: Lacks Success Response
8184
});
8285

83-
test('users cannot register with duplicate name', async ({ page }) => {
84-
await page.goto('/register.php');
85-
86-
const user = generateUniqueUser();
87-
88-
await page.fill('input[name="name"]', TEST_USER_NAME);
89-
await page.fill('input[name="email"]', user.email);
90-
await page.fill('input[name="password"]', user.password);
91-
await page.getByRole('button', { name: 'Create Account' }).click();
92-
93-
await expect(page.locator('.alert-danger')).toContainText(/.*name is already used/i);
94-
});
95-
9686
test('users cannot register with duplicate email', async ({ page }) => {
9787
await page.goto('/register.php');
9888

9989
const user = generateUniqueUser();
10090

101-
await page.fill('input[name="name"]', user.name);
91+
await page.fill('input[name="first_name"]', user.first_name);
92+
await page.fill('input[name="last_name"]', user.last_name);
10293
await page.fill('input[name="email"]', TEST_USER_EMAIL);
10394
await page.fill('input[name="password"]', user.password);
10495
await page.getByRole('button', { name: 'Create Account' }).click();
@@ -129,19 +120,6 @@ test.describe("User Login", () => {
129120
await expect(page.locator('.alert-danger')).toContainText(/invalid.*credentials|incorrect.*email.*password|login.*failed/i);
130121
await expect(page).toHaveURL(/login/);
131122
});
132-
133-
test('several login attempts should warn / lockout user', async ({ page }) => {
134-
await page.goto('/login.php');
135-
136-
for (let i = 0; i < 10; i++) {
137-
await page.fill('input[name="email"]', TEST_USER_EMAIL!);
138-
await page.fill('input[name="password"]', 'wrongpassword123');
139-
await page.getByRole('button', { name: 'Login' }).click();
140-
}
141-
142-
await expect(page.locator('.alert-warning')).toContainText(/too many.*attempts|account.*locked|try again later/i);
143-
await expect(page).toHaveURL(/login/);
144-
});
145123
})
146124

147125
test.describe("Role Based Access Control", () => {

0 commit comments

Comments
 (0)