Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default defineConfig({
? [['list'], ['json', { outputFile: 'results.json' }]]
: [['html']],
use: {
baseURL:"https://audaf-testing.onrender.com",
trace: 'on-first-retry',
},

Expand Down
4 changes: 2 additions & 2 deletions playwright/helpers/recycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {getEmailAddressForProject} from "../utils/functions.ts"

export async function loginUser(page: Page, testInfo: any, password: string,){
const emailAddress = getEmailAddressForProject(testInfo);
await page.goto("https://audaf-testing.onrender.com")
await page.goto("/")
await page.getByPlaceholder("Enter email").click();
await page.getByPlaceholder("Enter email").fill(emailAddress);
await page.getByPlaceholder("Password").click();
Expand All @@ -26,7 +26,7 @@ export async function loginUser(page: Page, testInfo: any, password: string,){
};

export async function fillUpSignUpForm(page: Page, emailAddress: string, password: string, secondPassword: string, PicName: string, username: string){
await page.goto('https://audaf-testing.onrender.com/signup');
await page.goto('/signup');
await page.getByRole('textbox', { name: 'Password', exact: true }).click();
await page.getByRole('textbox', { name: 'Password', exact: true }).fill(password);
await page.getByRole('textbox', { name: 'Confirm Password' }).click();
Expand Down
8 changes: 4 additions & 4 deletions tests/01-createAccount.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test.describe.serial('create accounts and testing account creation with already
await page.getByRole('button', { name: 'Create Account' }).click();

// Wait for navigation to verification page
await page.waitForURL("https://audaf-testing.onrender.com/verify-email", { timeout: 30000 });
await page.waitForURL("/verify-email", { timeout: 30000 });
// trigger the email sender
await page.getByText('Send Code').click();

Expand All @@ -37,7 +37,7 @@ test.describe.serial('create accounts and testing account creation with already
await page.getByRole('button', { name: 'Complete Registration' }).click();

await expect(page.getByText('Email verified!')).toBeVisible({ timeout: 15000 });
await page.goto('https://audaf-testing.onrender.com/home');
await page.goto('/home');
await expect(page.getByText('Welcome Home, testusername!')).toBeVisible({ timeout: 15000 });

// Save the authenticated state to a file for future tests
Expand Down Expand Up @@ -88,7 +88,7 @@ test.describe.serial('create accounts and testing account creation with already

await fillUpSignUpForm(page, emailAddress, "securepassword123", "securepassword123", "ghibli-gif.gif", "testusername2" )
await page.getByRole('button', { name: 'Create Account' }).click();
await page.waitForURL("https://audaf-testing.onrender.com/verify-email", { timeout: 30000 });
await page.waitForURL("/verify-email", { timeout: 30000 });
const allMessages = await page.consoleMessages();
const uploadFailed = allMessages.some(msg => msg.text().includes("avatar upload failed"));
expect(uploadFailed).toBe(true);
Expand All @@ -103,7 +103,7 @@ test.describe.serial('create accounts and testing account creation with already
// Filling up Signup Forum
await fillUpSignUpForm(page, unverifiedEmailAddress, "securepassword123", "securepassword123", "jellyfishWallpaper.jpg", "testuserunverified" )
await page.getByRole('button', { name: 'Create Account' }).click();
await page.waitForURL("https://audaf-testing.onrender.com/verify-email", { timeout: 30000 });
await page.waitForURL("/verify-email", { timeout: 30000 });

const authFileUnverified = getAuthFileUnverified(projectName);
await page.context().storageState({ path: authFileUnverified });
Expand Down
18 changes: 9 additions & 9 deletions tests/02-authAndSecurity.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,38 @@ test.describe('Authentication and Security Tests', () => {
});

test('session with no cookies should be rejected', async ({ page }, testInfo) => {
await page.goto('https://audaf-testing.onrender.com/home');
await page.goto('/home');
await expect(page.getByText('Welcome Home, testusername!', { exact: true})).toBeVisible();
await removeCookiesFromFile(page, getAuthFileTamperedByProjectName(testInfo.project.name));
await page.goto('https://audaf-testing.onrender.com/home');
await expect(page).toHaveURL('https://audaf-testing.onrender.com/');
await page.goto('/home');
await expect(page).toHaveURL('/');
await expect(page.getByText('Welcome Back!', { exact: true})).toBeVisible();
await setUserTamperedToSameAsUser(testInfo.project.name); // Reset the tampered state to match the regular user state for further tests
});

test("session with tampered JWT-token should be rejected", async({page}, testInfo)=>{
await page.goto('https://audaf-testing.onrender.com/home');
await page.goto('/home');
await expect(page.getByText('Welcome Home, testusername!', { exact: true})).toBeVisible();
await tamperWithJWTToken(testInfo.project.name)
await page.goto('https://audaf-testing.onrender.com/home');
await page.goto('/home');
await expect(page.getByText('Welcome Home, testusername!', { exact: true})).not.toBeVisible();
await setUserTamperedToSameAsUser(testInfo.project.name);
})

test("session with expired cookies should be rejected when navigating home", async({page}, testInfo)=>{
await page.goto('https://audaf-testing.onrender.com/home');
await page.goto('/home');
await expect(page.getByText('Welcome Home, testusername!', { exact: true})).toBeVisible();
await letCookiesExpire(page);
await page.goto('https://audaf-testing.onrender.com/home');
await page.goto('/home');
await expect(page.getByText('Welcome Back!', { exact: true})).toBeVisible();
await restoreExpiredCookies(page, getAuthFileByProjectName(testInfo.project.name));
});

test("session with invalid CSRF token should be rejected", async({page}, testInfo)=>{
await page.goto('https://audaf-testing.onrender.com/home');
await page.goto('/home');
await expect(page.getByText('Welcome Home, testusername!', { exact: true})).toBeVisible();
await tamperWithCSRFToken(testInfo.project.name)
await page.goto('https://audaf-testing.onrender.com/home');
await page.goto('/home');
await expect(page.getByText('Welcome Home, testusername!', { exact: true})).not.toBeVisible();
await setUserTamperedToSameAsUser(testInfo.project.name);
})
Expand Down
27 changes: 13 additions & 14 deletions tests/03-CRUDActionsAndNavigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ test.describe.serial('CRUD Actions and Navigation', () => {
await restoreAuthState(page, authFile);
});

test('navigating home', async ({ page }, testInfo) => {
await page.goto('https://audaf-testing.onrender.com/home');
test('navigating home', async ({ page }) => {
await page.goto('/home');
await expect(page.getByText('Welcome Home, testusername!', { exact: true})).toBeVisible();
});

test("editing profile", async({page}, testInfo)=>{
await page.goto('https://audaf-testing.onrender.com/home');
test("editing profile", async({page})=>{
await page.goto('/home');
await page.getByRole('button', { name: 'Edit Profile' }).click();
await page.getByRole('textbox').click();
// trying to update profile with invalid username first
Expand All @@ -37,16 +37,15 @@ test.describe.serial('CRUD Actions and Navigation', () => {
})

test("logging out", async({page}, testInfo)=>{
await page.goto('https://audaf-testing.onrender.com/home');
await page.goto('/home');
await page.getByRole('button', { name: 'Logout' }).click();
await expect(page.getByText("Logged out successfully! Redirecting to login page...", { exact: true})).toBeVisible();
await page.context().storageState({ path: getAuthFileByProjectName(testInfo.project.name) });
await page.goto("https://audaf-testing.onrender.com/home")
await page.goto("/home")
await expect(page.getByText('Welcome Home, newUsername!', { exact: true})).not.toBeVisible();
})

test("logging in with wrong credentials", async({page}, testInfo)=>{

await loginUser(page, testInfo, 'wrongPassword')

await page.waitForTimeout(3000);
Expand All @@ -56,7 +55,7 @@ test.describe.serial('CRUD Actions and Navigation', () => {
test("resetting password with correct and incorrect verification code", async({page}, testInfo)=>{
const emailAddress = getEmailAddressForProject(testInfo);

await page.goto("https://audaf-testing.onrender.com")
await page.goto("/")
await page.getByRole('link', { name: 'Forgot Password?' }).click();
await page.getByRole('textbox', { name: 'Email Address' }).click();
// testing with wrong email first to see if the system handles it correctly
Expand All @@ -75,7 +74,7 @@ test.describe.serial('CRUD Actions and Navigation', () => {
await expect(page.getByText("Invalid code")).toBeVisible({ timeout: 10000 });
await page.getByRole('textbox', { name: 'Verification Code' }).fill(code);
await page.locator('div').filter({ hasText: /^Verify$/ }).click();
await page.waitForURL("https://audaf-testing.onrender.com/reset-password", { timeout: 30000 });
await page.waitForURL("/reset-password", { timeout: 30000 });
await page.getByRole('textbox', { name: 'New Password' }).click();
// testing with password without numberfirst to see if the system handles it correctly
await page.getByRole('textbox', { name: 'New Password' }).fill('bad');
Expand All @@ -88,7 +87,7 @@ test.describe.serial('CRUD Actions and Navigation', () => {
await page.getByRole('textbox', { name: 'Confirm Password' }).fill('newSecurePassword123');
await page.getByRole('button', { name: 'Reset Password' }).click();
await expect(page.getByText('Password reset successful! Redirecting to login page...')).toBeVisible({ timeout: 10000 });
await page.waitForURL("https://audaf-testing.onrender.com", { timeout: 30000 });
await page.waitForURL("/", { timeout: 30000 });
});

test("logging in with correct credentials and verified email", async({page}, testInfo)=>{
Expand All @@ -97,13 +96,13 @@ test.describe.serial('CRUD Actions and Navigation', () => {

await page.waitForTimeout(3000);
await expect(page.locator('form')).toBeVisible({ timeout: 10000 });
await page.waitForURL(/home|login/, { timeout: 10000 }).catch(() => {});
await page.waitForURL("/home", { timeout: 10000 }).catch(() => {});
await page.context().storageState({ path: getAuthFileByProjectName(testInfo.project.name) });
});

test("deleting test account", async({page}, testInfo)=>{
const emailAddress = getEmailAddressForProject(testInfo);
await page.goto('https://audaf-testing.onrender.com/home');
await page.goto('/home');
await page.getByRole('button', { name: 'Delete Account' }).click();
await page.getByRole('textbox', { name: 'Enter your email' }).click();
// trying to delete with wrong email and failing
Expand All @@ -113,9 +112,9 @@ test.describe.serial('CRUD Actions and Navigation', () => {
await page.getByRole('textbox', { name: 'Enter your email' }).fill(emailAddress);
await page.getByRole('button', { name: 'Yes, Delete My Account' }).click();
await expect(page.getByText("Account deleted successfully! Redirecting to login page...")).toBeVisible({timeout: 10000});
await page.waitForURL("https://audaf-testing.onrender.com");
await page.waitForURL("/");
await page.context().storageState({ path: getAuthFileByProjectName(testInfo.project.name) });
await page.goto("https://audaf-testing.onrender.com/home");
await page.goto("/home");
await expect(page.getByText('Welcome Home, newUsername!', { exact: true})).not.toBeVisible();
await loginUser(page, testInfo, "newSecurePassword123");
await expect(page.getByText("Invalid credentials")).toBeVisible();
Expand Down
2 changes: 1 addition & 1 deletion tests/04-unverifiedEmailCRUDActions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test.describe.serial('Unverified Email CRUD Actions', () => {
});

test('navigating home', async ({ page }) => {
await page.goto('https://audaf-testing.onrender.com/home');
await page.goto('/home');
await expect(page.getByText('Welcome Home, testuserunverified!', { exact: true})).not.toBeVisible();
});

Expand Down
Loading