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
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,15 @@ jobs:
NEXT_PUBLIC_SUPABASE_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_KEY }}
run: |
npx nyc --reporter=lcov yarn --cwd=web serve &
npx nyc --reporter=lcov yarn --cwd=backend/api dev &
npx wait-on http://localhost:3000
npx playwright test tests/e2e
SERVER_PID=$(fuser -k 3000/tcp)
echo $SERVER_PID
kill $SERVER_PID
SERVER_PID=$(fuser -k 8088/tcp)
echo $SERVER_PID
kill $SERVER_PID

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
Expand Down
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"test:coverage": "yarn workspaces run test --coverage",
"test:watch": "yarn workspaces run test --watch",
"test:update": "yarn workspaces run test --updateSnapshot",
"test:e2e": "./scripts/e2e.sh",
"playwright": "playwright test",
"playwright:ui": "playwright test --ui",
"playwright:debug": "playwright test --debug",
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'] },
// },
],
});

});
4 changes: 4 additions & 0 deletions scripts/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ export NEXT_PUBLIC_API_URL=localhost:8088
export NEXT_PUBLIC_FIREBASE_ENV=DEV

npx nyc --reporter=lcov yarn --cwd=web serve &
npx nyc --reporter=lcov yarn --cwd=backend/api dev &
npx wait-on http://localhost:3000
npx playwright test tests/e2e
SERVER_PID=$(fuser -k 3000/tcp)
echo $SERVER_PID
kill $SERVER_PID

SERVER_PID=$(fuser -k 8088/tcp)
echo $SERVER_PID
kill $SERVER_PID
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',
};
24 changes: 24 additions & 0 deletions tests/e2e/web/fixtures/signInFixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { test as base, Page, expect } 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 page.waitForURL('/');

expect(page.url()).not.toContain('/signin')

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.