Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

# Playwright
/tests/reports/playwright-report
/tests/e2e/web/.auth/

# next.js
/.next/
Expand Down
9 changes: 6 additions & 3 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig, devices } from '@playwright/test';
import path from 'path';

export default defineConfig({
testDir: './tests/e2e',
Expand All @@ -13,8 +14,9 @@ export default defineConfig({
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
name: 'main',
use: {
...devices['Desktop Chrome'], },
},
// {
// name: 'firefox',
Expand All @@ -25,4 +27,5 @@ export default defineConfig({
// use: { ...devices['Desktop Safari'] },
// },
],
});

});
Empty file removed tests/e2e/web/.auth/.keep
Empty file.
5 changes: 5 additions & 0 deletions tests/e2e/web/TESTING_CONFIG.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const config = {
BASE_URL: 'http://localhost:3000',
DEFAULT_LOGIN: '[email protected]',
DEFAULT_PASSWORD: 'defaultPassword',
};
20 changes: 20 additions & 0 deletions tests/e2e/web/fixtures/signInFixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { test as base, Page } from '@playwright/test';
import { SignInPage } from '../pages/signInPage';
import { config } from '../TESTING_CONFIG';

export const test = base.extend<{
authenticatedPage: Page;
}>({
authenticatedPage: async ({ page }, use) => {
const signInPage = new SignInPage(page);

await page.goto('/signin');
await signInPage.fillEmailField(config.DEFAULT_LOGIN);
await signInPage.fillPasswprdField(config.DEFAULT_PASSWORD);
await signInPage.clickSignInWithEmailButton();

await page.waitForLoadState('networkidle');

await use(page);
},
});
Empty file removed tests/e2e/web/pageManager/.keep
Empty file.
Empty file removed tests/e2e/web/pages/.keep
Empty file.
42 changes: 42 additions & 0 deletions tests/e2e/web/pages/signInPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { expect, Locator, Page } from '@playwright/test';

//sets up of all the functions that signin tests will use.
export class SignInPage{
private readonly signInLink: Locator;
private readonly emailField: Locator;
private readonly passwordField: Locator;
private readonly signInWithEmailButton: Locator;
private readonly signInWithGoogleButton: Locator;

constructor(public readonly page: Page) {
this.signInLink=page.getByRole('link', { name: 'Sign in' });
this.emailField=page.getByLabel('Email');
this.passwordField=page.getByLabel('Password');
this.signInWithEmailButton=page.getByRole('button',{name: 'Sign in With Email'});
this.signInWithGoogleButton=page.getByRole('button',{name: 'Google'});
}

async clickSignInText() {
await this.signInLink.click();
}

async clickSignInWithEmailButton() {
await this.signInWithEmailButton.click();
}

async clickSignInWithEGoogleButton() {
await this.signInWithGoogleButton.click();
}

async fillEmailField(email: string) {
await expect(this.emailField).toBeVisible();
await this.emailField.fill(email);
}

async fillPasswprdField(password: string) {
await expect(this.passwordField).toBeVisible();
await this.passwordField.fill(password);
}

}

Empty file removed tests/e2e/web/specs/.keep
Empty file.
10 changes: 10 additions & 0 deletions tests/e2e/web/specs/postSignIn.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { expect } from '@playwright/test';
import { test } from '../fixtures/signInFixture';

test('should be logged in and see settings page', async ({ authenticatedPage }) => {
await authenticatedPage.goto('/settings');

await expect(
authenticatedPage.getByRole('heading', { name: 'Theme' })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test still errors out here. Not sure why right now.


  1) [main] › tests/e2e/web/specs/postSignIn.spec.ts:4:5 › should be logged in and see settings page 
    Error: expect(locator).toBeVisible() failed
    Locator:  getByRole('heading', { name: 'Theme' })
    Expected: visible
    Received: <element(s) not found>
    Timeout:  5000ms
    Call log:
      - Expect "toBeVisible" with timeout 5000ms
      - waiting for getByRole('heading', { name: 'Theme' })
       7 |   await expect(
       8 |     authenticatedPage.getByRole('heading', { name: 'Theme' })
    >  9 |   ).toBeVisible();
         |     ^
      10 | });
        at /home/runner/work/Compass/Compass/tests/e2e/web/specs/postSignIn.spec.ts:9:5
    Error Context: test-results/web-specs-postSignIn-shoul-5e404-ed-in-and-see-settings-page-main/error-context.md

).toBeVisible();
});
9 changes: 0 additions & 9 deletions tests/e2e/web/specs/some.test.ts

This file was deleted.

Loading