From 0bee0d2aacb5c74cd9b44e217bf86486b468348c Mon Sep 17 00:00:00 2001 From: JewelTee Date: Wed, 7 Aug 2024 19:13:32 +0800 Subject: [PATCH] adding new tests --- .../playwright/tests/chg_pwd_attempt.spec.js | 27 +++++++++++++++++ .../tests/delete_account_error.spec.js | 22 ++++++++++++++ packages/playwright/tests/empty_email.spec.js | 16 ++++++++++ .../playwright/tests/empty_email_pwd.spec.js | 17 +++++++++++ packages/playwright/tests/incorr_pwd.spec.js | 16 ++++++++++ .../playwright/tests/invld_add_item.spec.js | 30 +++++++++++++++++++ .../tests/invld_pack_create.spec.js | 23 ++++++++++++++ .../playwright/tests/login_empty_pwd.spec.js | 14 +++++++++ .../tests/login_incorr_email.spec.js | 16 ++++++++++ .../playwright/tests/reg_empty_name.spec.js | 19 ++++++++++++ .../tests/upd_prof_empty_name.spec.js | 22 ++++++++++++++ .../playwright/tests/wrong_pwd_fmt.spec.js | 16 ++++++++++ 12 files changed, 238 insertions(+) create mode 100644 packages/playwright/tests/chg_pwd_attempt.spec.js create mode 100644 packages/playwright/tests/delete_account_error.spec.js create mode 100644 packages/playwright/tests/empty_email.spec.js create mode 100644 packages/playwright/tests/empty_email_pwd.spec.js create mode 100644 packages/playwright/tests/incorr_pwd.spec.js create mode 100644 packages/playwright/tests/invld_add_item.spec.js create mode 100644 packages/playwright/tests/invld_pack_create.spec.js create mode 100644 packages/playwright/tests/login_empty_pwd.spec.js create mode 100644 packages/playwright/tests/login_incorr_email.spec.js create mode 100644 packages/playwright/tests/reg_empty_name.spec.js create mode 100644 packages/playwright/tests/upd_prof_empty_name.spec.js create mode 100644 packages/playwright/tests/wrong_pwd_fmt.spec.js diff --git a/packages/playwright/tests/chg_pwd_attempt.spec.js b/packages/playwright/tests/chg_pwd_attempt.spec.js new file mode 100644 index 000000000..98a962712 --- /dev/null +++ b/packages/playwright/tests/chg_pwd_attempt.spec.js @@ -0,0 +1,27 @@ +import { test, expect } from '@playwright/test'; +test.setTimeout(60000); + +test('change password with mismatched new password and confirmation shows error message', async ({ page }) => { + await page.goto('https://packrat.world/'); + await page.getByRole('link', { name: 'Get Started' }).click(); + await page.getByLabel('Email').click(); + await page.getByLabel('Email').fill('zoot3@email.com'); + await page.getByLabel('Password').click(); + await page.getByLabel('Password').fill('12345678'); + await page.getByRole('button', { name: 'Sign In' }).click(); + await page.getByRole('button', { name: 'Menu' }).hover(); + await page.getByRole('button', { name: ' Profile' }).click(); + await page.goto('https://packrat.world/profile'); + await page.getByRole('button', { name: '󰢻' }).click(); + await page.getByLabel('Old password').click(); + await page.getByLabel('Old password').fill('12345678)') + await page.getByLabel('New password', { exact: true }).click(); + await page.getByLabel('New password', { exact: true }).fill('87654321'); + await page.getByLabel('Confirm new password').click(); + await page.getByLabel('Confirm new password').fill('98765432'); + await page.getByRole('button', { name: 'Change password' }).click(); + + // Verify the error message for invalid email format + const passwordErrorMessage = page.locator('text=New password and confirmation must match'); + await expect(passwordErrorMessage).toBeVisible({ timeout: 50000 }); // Adjust the timeout as needed + }); \ No newline at end of file diff --git a/packages/playwright/tests/delete_account_error.spec.js b/packages/playwright/tests/delete_account_error.spec.js new file mode 100644 index 000000000..73adcafdb --- /dev/null +++ b/packages/playwright/tests/delete_account_error.spec.js @@ -0,0 +1,22 @@ +import { test, expect } from '@playwright/test'; +test.setTimeout(60000); + +test('delete account error', async ({ page }) => { + await page.goto('https://packrat.world/'); + await page.getByRole('link', { name: 'Get Started' }).click(); + await page.getByLabel('Email').click(); + await page.getByLabel('Email').fill('zoot3@email.com'); + await page.getByLabel('Password').click(); + await page.getByLabel('Password').fill('12345678'); + await page.getByRole('button', { name: 'Sign In' }).click(); + await page.getByRole('button', { name: 'Menu' }).hover(); + await page.getByRole('button', { name: ' Profile' }).click(); + await page.goto('https://packrat.world/profile'); + await page.getByRole('button', { name: '󰢻' }).click(); + await page.getByRole('button', { name: 'Delete account' }).click(); + + + // Verify the error message for invalid email format + const emailErrorMessage = page.locator('text= Invalid literal value, expected "delete"'); + await expect(emailErrorMessage).toBeVisible({ timeout: 50000 }); // Adjust the timeout as needed + }); diff --git a/packages/playwright/tests/empty_email.spec.js b/packages/playwright/tests/empty_email.spec.js new file mode 100644 index 000000000..a8a7fe807 --- /dev/null +++ b/packages/playwright/tests/empty_email.spec.js @@ -0,0 +1,16 @@ +import { test, expect } from '@playwright/test'; + +test('invalid login with empty email shows error message', async ({ page }) => { + await page.goto('https://packrat.pages.dev/'); + await page.getByRole('link', { name: 'Get Started' }).click(); + + await page.locator('input[type="email"]').click(); + await page.locator('input[type="email"]').fill(""); + await page.locator('input[type="password"]').click(); + await page.locator('input[type="password"]').fill('12345678'); + await page.getByRole('button', { name: 'Sign In' }).click(); + + // Verify the error message for invalid email format +const emailErrorMessage = page.locator('text=Email is required'); +await expect(emailErrorMessage).toBeVisible({ timeout: 50000 }); // Adjust the timeout as needed +}); diff --git a/packages/playwright/tests/empty_email_pwd.spec.js b/packages/playwright/tests/empty_email_pwd.spec.js new file mode 100644 index 000000000..ea8486653 --- /dev/null +++ b/packages/playwright/tests/empty_email_pwd.spec.js @@ -0,0 +1,17 @@ +import { test, expect } from '@playwright/test'; + +test('invalid login with empty fields shows error message', async ({ page }) => { + await page.goto('https://packrat.world/'); + await page.getByRole('link', { name: 'Get Started' }).click(); + + await page.getByRole('button', { name: 'Sign In' }).click(); + + +// Verify the error message for invalid email format +const emailErrorMessage = page.locator('text=Email is required'); +await expect(emailErrorMessage).toBeVisible({ timeout: 50000 }); // Adjust the timeout as needed + +// Verify the error message for invalid email format +const passwordErrorMessage = page.locator('text=Password is required'); +await expect(passwordErrorMessage).toBeVisible({ timeout: 50000 }); // Adjust the timeout as needed +}); diff --git a/packages/playwright/tests/incorr_pwd.spec.js b/packages/playwright/tests/incorr_pwd.spec.js new file mode 100644 index 000000000..8121bef54 --- /dev/null +++ b/packages/playwright/tests/incorr_pwd.spec.js @@ -0,0 +1,16 @@ +import { test, expect } from '@playwright/test'; + +test('invalid login with incorrect password shows error message', async ({ page }) => { + await page.goto('https://packrat.world//'); + await page.getByRole('link', { name: 'Get Started' }).click(); + + await page.locator('input[type="email"]').click(); + await page.locator('input[type="email"]').fill('zoot3@email.com'); + await page.locator('input[type="password"]').click(); + await page.locator('input[type="password"]').fill('1234567'); + await page.getByRole('button', { name: 'Sign In' }).click(); + + // Verify the error message for invalid email format +const passwordErrorMessage = page.locator('text=User not found'); +await expect(passwordErrorMessage).toBeVisible({ timeout: 50000 }); // Adjust the timeout as needed +}); \ No newline at end of file diff --git a/packages/playwright/tests/invld_add_item.spec.js b/packages/playwright/tests/invld_add_item.spec.js new file mode 100644 index 000000000..f8e8c182d --- /dev/null +++ b/packages/playwright/tests/invld_add_item.spec.js @@ -0,0 +1,30 @@ +import { test, expect } from '@playwright/test'; + +test('Add Item without item name shows required error', async ({ page }) => { + test.setTimeout(60000); + await page.goto('https://packrat.world/'); + await page.getByRole('link', { name: 'Get Started' }).click(); + await page.getByLabel('Email').click(); + await page.getByLabel('Email').fill('zoot3@email.com'); + await page.getByLabel('Password').click(); + await page.getByLabel('Password').fill('12345678'); + await page.getByRole('button', { name: 'Sign In' }).click(); + await page.getByRole('button', { name: 'Menu' }).hover(); + await page.getByRole('button', { name: 'Packs' }).click(); + await page.goto('https://packrat.world/packs'); + await page.getByRole('link', { name: 'Quantity field' }).click(); + await page.getByRole('button', { name: 'Add Item' }).click(); + await page.getByPlaceholder('Item Name').fill(''); + await page.getByPlaceholder('Weight').click(); + await page.getByPlaceholder('Weight').fill('0.5'); + await page.getByPlaceholder('Quantity').click(); + await page.getByPlaceholder('Quantity').fill('1'); + await page.getByLabel('Essentials').click(); + await page.getByRole('button', { name: 'Add Item' }).click(); + + // Verify the error message for the empty item name + const itemNameErrorMessage = page.locator('text=Required'); + await expect(itemNameErrorMessage).toBeVisible({ timeout: 10000 }); // Adjust the timeout as needed +}); + + diff --git a/packages/playwright/tests/invld_pack_create.spec.js b/packages/playwright/tests/invld_pack_create.spec.js new file mode 100644 index 000000000..7fa8fb939 --- /dev/null +++ b/packages/playwright/tests/invld_pack_create.spec.js @@ -0,0 +1,23 @@ +import { test, expect } from '@playwright/test'; + +test('Add Pack without name shows error message', async ({ page }) => { + await page.goto('https://packrat.world/'); + await page.getByRole('link', { name: 'Get Started' }).click(); + await page.getByLabel('Email').click(); + await page.getByLabel('Email').fill('zoot3@email.com'); + await page.getByLabel('Password').click(); + await page.getByLabel('Password').fill('12345678'); + await page.getByRole('button', { name: 'Sign In' }).click(); + await page.getByText('Create a Pack').click(); + await page.getByPlaceholder('Name').click(); + await page.getByPlaceholder('Name').fill(''); + await page.getByRole('switch').click(); + await page.getByRole('button', { name: 'Add Pack' }).click(); + + + // Verify the error message for the empty name field + const nameErrorMessage = page.locator('text=String must contain at least 1 character(s)'); + await expect(nameErrorMessage).toBeVisible({ timeout: 10000 }); // Adjust the timeout as needed +}); + + diff --git a/packages/playwright/tests/login_empty_pwd.spec.js b/packages/playwright/tests/login_empty_pwd.spec.js new file mode 100644 index 000000000..c85845497 --- /dev/null +++ b/packages/playwright/tests/login_empty_pwd.spec.js @@ -0,0 +1,14 @@ +import { test, expect } from '@playwright/test'; + +test('invalid login with empty password format shows error message', async ({ page }) => { + await page.goto('https://packrat.world/'); + await page.getByRole('link', { name: 'Get Started' }).click(); + + await page.locator('input[type="email"]').click(); + await page.locator('input[type="email"]').fill("zoot3@email.com"); + await page.getByRole('button', { name: 'Sign In' }).click(); + + // Verify the error message for invalid email format +const passwordErrorMessage = page.locator('text=Password is required'); +await expect(passwordErrorMessage).toBeVisible({ timeout: 50000 }); // Adjust the timeout as needed +}); diff --git a/packages/playwright/tests/login_incorr_email.spec.js b/packages/playwright/tests/login_incorr_email.spec.js new file mode 100644 index 000000000..47aa184ba --- /dev/null +++ b/packages/playwright/tests/login_incorr_email.spec.js @@ -0,0 +1,16 @@ +import { test, expect } from '@playwright/test'; + +test('invalid login with incorrect email shows error message', async ({ page }) => { + await page.goto('https://packrat.pages.dev/'); + await page.getByRole('link', { name: 'Get Started' }).click(); + + await page.locator('input[type="email"]').click(); + await page.locator('input[type="email"]').fill('zoot@email.com'); + await page.locator('input[type="password"]').click(); + await page.locator('input[type="password"]').fill('12345678'); + await page.getByRole('button', { name: 'Sign In' }).click(); + + // Verify the error message for invalid email format + const emailErrorMessage = page.locator('text=User not found'); + await expect(emailErrorMessage).toBeVisible({ timeout: 50000 }); // Adjust the timeout as needed + }); \ No newline at end of file diff --git a/packages/playwright/tests/reg_empty_name.spec.js b/packages/playwright/tests/reg_empty_name.spec.js new file mode 100644 index 000000000..e61fd9ff1 --- /dev/null +++ b/packages/playwright/tests/reg_empty_name.spec.js @@ -0,0 +1,19 @@ +import { test, expect } from '@playwright/test'; + +test('Register new account name field empty', async ({ page }) => { + await page.goto('https://packrat.world/'); + await page.getByRole('link', { name: 'Get Started' }).click(); + await page.getByRole('link', { name: 'Don\'t have an account? Sign up' }).click(); + await page.locator('input[type="email"]').click(); + await page.locator('input[type="email"]').fill('admin123@email.com'); + await page.getByRole('textbox').nth(2).click(); + await page.getByRole('textbox').nth(2).fill('admin123'); + await page.locator('input[type="password"]').click(); + await page.locator('input[type="password"]').fill('12345678'); + await page.getByRole('button', { name: 'Sign Up' }).click(); + + // Verify the error message for the empty name field + const nameErrorMessage = page.locator('text=Required'); + await expect(nameErrorMessage).toBeVisible({ timeout: 10000 }); // Adjust the timeout as needed +}); + diff --git a/packages/playwright/tests/upd_prof_empty_name.spec.js b/packages/playwright/tests/upd_prof_empty_name.spec.js new file mode 100644 index 000000000..4e6d901e2 --- /dev/null +++ b/packages/playwright/tests/upd_prof_empty_name.spec.js @@ -0,0 +1,22 @@ +import { test, expect } from '@playwright/test'; + +test('Update profile without name shows error message', async ({ page }) => { + await page.goto('https://packrat.world/'); + await page.getByRole('link', { name: 'Get Started' }).click(); + await page.getByLabel('Email').click(); + await page.getByLabel('Email').fill('zoot3@email.com'); + await page.getByLabel('Password').click(); + await page.getByLabel('Password').fill('12345678'); + await page.getByRole('button', { name: 'Sign In' }).click(); + await page.getByRole('button', { name: 'Menu' }).hover(); + await page.getByRole('button', { name: ' Profile' }).click(); + await page.goto('https://packrat.world/profile'); + await page.getByRole('button', { name: '󰢻' }).click(); + await page.locator('#name').click(); + await page.locator('#name').fill(''); + await page.getByRole('button', { name: 'Update profile' }).click(); + + // Verify the error message for the empty name field + const nameErrorMessage = page.locator('text=String must contain at least 1 character(s)'); + await expect(nameErrorMessage).toBeVisible({ timeout: 10000 }); // Adjust the timeout as needed +}); \ No newline at end of file diff --git a/packages/playwright/tests/wrong_pwd_fmt.spec.js b/packages/playwright/tests/wrong_pwd_fmt.spec.js new file mode 100644 index 000000000..808b73acc --- /dev/null +++ b/packages/playwright/tests/wrong_pwd_fmt.spec.js @@ -0,0 +1,16 @@ +import { test, expect } from '@playwright/test'; + +test('invalid login with wrong password format shows error message', async ({ page }) => { + await page.goto('https://packrat.world/'); + await page.getByRole('link', { name: 'Get Started' }).click(); + + await page.locator('input[type="email"]').click(); + await page.locator('input[type="email"]').fill('zoot3@email.com'); + await page.locator('input[type="password"]').click(); + await page.locator('input[type="password"]').fill('12345'); + await page.getByRole('button', { name: 'Sign In' }).click(); + + // Verify the error message for invalid email format + const passwordErrorMessage = page.locator('text=String must contain at least 7 character(s)'); + await expect(passwordErrorMessage).toBeVisible({ timeout: 50000 }); // Adjust the timeout as needed +});