From ff4e965d7eda26bba429b007023cc72fe08f2a8a Mon Sep 17 00:00:00 2001 From: May Shech Date: Sun, 4 Feb 2024 13:36:41 +0200 Subject: [PATCH 01/22] update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 96d0c5d..6ec8186 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "dev": "next dev", - "build": "npm run prisma:generate && npm run build-storybook && NODE_ENV=production next build", + "build": "npm run docker:local:up && npm run prisma:generate && npm run build-storybook && NODE_ENV=production next build", "start": "next start", "format": "npx prettier --write .", "lint": "next lint", From 7b382cc1727ff08ef85cefae873466f209cf7a63 Mon Sep 17 00:00:00 2001 From: May Shech Date: Sun, 4 Feb 2024 13:37:59 +0200 Subject: [PATCH 02/22] nvm --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6ec8186..96d0c5d 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "dev": "next dev", - "build": "npm run docker:local:up && npm run prisma:generate && npm run build-storybook && NODE_ENV=production next build", + "build": "npm run prisma:generate && npm run build-storybook && NODE_ENV=production next build", "start": "next start", "format": "npx prettier --write .", "lint": "next lint", From cac4d06ccce43d401987aefe90085548c35f39aa Mon Sep 17 00:00:00 2001 From: May Shech Date: Sun, 4 Feb 2024 14:18:45 +0200 Subject: [PATCH 03/22] Update README.md (#1) --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ff2e89a..0391c81 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,10 @@ -This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). +
+vercel +GitHub issues +GitHub pull requests +contributors +
+ ## Getting Started From a8ed712b733d8738401b8ee7aeaa2be71d9cc060 Mon Sep 17 00:00:00 2001 From: May Shech Date: Sun, 4 Feb 2024 14:50:58 +0200 Subject: [PATCH 04/22] checking something --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 96d0c5d..773ba16 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "dev": "next dev", - "build": "npm run prisma:generate && npm run build-storybook && NODE_ENV=production next build", + "build": "npm run prisma:generate && npm run prisma:migrate && npm run build-storybook && NODE_ENV=production next build", "start": "next start", "format": "npx prettier --write .", "lint": "next lint", From e6f2c6d32d616681b7f34f2755f3db459ecaef14 Mon Sep 17 00:00:00 2001 From: May Shech Date: Sun, 4 Feb 2024 15:00:28 +0200 Subject: [PATCH 05/22] fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 773ba16..84a200f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "dev": "next dev", - "build": "npm run prisma:generate && npm run prisma:migrate && npm run build-storybook && NODE_ENV=production next build", + "build": "npm run prisma:generate && npm run migrate:postgres && npm run build-storybook && NODE_ENV=production next build", "start": "next start", "format": "npx prettier --write .", "lint": "next lint", From 11b9aabceab8e80b66600ee4861c070762b78ff2 Mon Sep 17 00:00:00 2001 From: May Shech Date: Sun, 4 Feb 2024 15:03:22 +0200 Subject: [PATCH 06/22] default --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 84a200f..9067fc2 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "dev": "next dev", - "build": "npm run prisma:generate && npm run migrate:postgres && npm run build-storybook && NODE_ENV=production next build", + "build": "npm run prisma:generate && npm run build-storybook && NODE_ENV=production next build", "start": "next start", "format": "npx prettier --write .", "lint": "next lint", From 78b0aa0797694e645cf0faf087ec16eeed44e86a Mon Sep 17 00:00:00 2001 From: May Shech Date: Sun, 4 Feb 2024 17:40:48 +0200 Subject: [PATCH 07/22] checking this one --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9067fc2..2ed33fc 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "dev": "next dev", - "build": "npm run prisma:generate && npm run build-storybook && NODE_ENV=production next build", + "build": "npm run prisma:generate && prisma migrate dev && npm run build-storybook && NODE_ENV=production next build", "start": "next start", "format": "npx prettier --write .", "lint": "next lint", From 1c128bc18ef0840d4de7051bc40a26992e218081 Mon Sep 17 00:00:00 2001 From: May Shech Date: Sun, 4 Feb 2024 17:48:49 +0200 Subject: [PATCH 08/22] testing --- prisma/schema.prisma | 1 + 1 file changed, 1 insertion(+) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 880e651..afbdd6e 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -8,6 +8,7 @@ generator client { datasource db { provider = "postgresql" url = env("DATABASE_URL") + directUrl = env("POSTGRES_URL_NON_POOLING") // uses a direct connection } enum Provider { From 111988c63597c5c1036545a7230f02613d565559 Mon Sep 17 00:00:00 2001 From: May Shech Date: Sun, 4 Feb 2024 23:33:07 +0200 Subject: [PATCH 09/22] Integrated tests (#2) * Integrated tests * Added new test * fix * added env to webServer * npm run dev * changed the user to me for now --- .github/workflows/playwright.yml | 27 +++++++++++ .gitignore | 6 ++- package-lock.json | 68 +++++++++++++++++++++++++-- package.json | 2 + playwright.config.ts | 80 ++++++++++++++++++++++++++++++++ src/api/email.ts | 1 + src/consts.ts | 12 +++++ tests/Auth/auth.spec.ts | 18 +++++++ 8 files changed, 209 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/playwright.yml create mode 100644 playwright.config.ts create mode 100644 tests/Auth/auth.spec.ts diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 0000000..90b6b70 --- /dev/null +++ b/.github/workflows/playwright.yml @@ -0,0 +1,27 @@ +name: Playwright Tests +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install dependencies + run: npm ci + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Run Playwright tests + run: npx playwright test + - uses: actions/upload-artifact@v3 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/.gitignore b/.gitignore index ec3dbb3..4a1c16b 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,8 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts -storybook* \ No newline at end of file +storybook* +/test-results/ +/playwright-report/ +/blob-report/ +/playwright/.cache/ diff --git a/package-lock.json b/package-lock.json index 5893fc7..3871f7b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "bcrypt": "^5.1.1", "crypto": "^1.0.1", "date-fns": "^3.3.0", + "dotenv": "^16.4.1", "jsonwebtoken": "^9.0.2", "next": "14.0.4", "next-auth": "^4.24.5", @@ -29,6 +30,7 @@ "zod": "^3.22.4" }, "devDependencies": { + "@playwright/test": "^1.41.2", "@storybook/addon-essentials": "^7.6.10", "@storybook/addon-interactions": "^7.6.10", "@storybook/addon-links": "^7.6.10", @@ -3466,6 +3468,21 @@ "node": ">=14" } }, + "node_modules/@playwright/test": { + "version": "1.41.2", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.41.2.tgz", + "integrity": "sha512-qQB9h7KbibJzrDpkXkYvsmiDJK14FULCCZgEcoe2AvFAS64oCirWTwzTlAYEbKaRxWs5TFesE1Na6izMv3HfGg==", + "dev": true, + "dependencies": { + "playwright": "1.41.2" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=16" + } + }, "node_modules/@pmmmwh/react-refresh-webpack-plugin": { "version": "0.5.11", "resolved": "https://registry.npmjs.org/@pmmmwh/react-refresh-webpack-plugin/-/react-refresh-webpack-plugin-0.5.11.tgz", @@ -9600,10 +9617,9 @@ } }, "node_modules/dotenv": { - "version": "16.3.2", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.2.tgz", - "integrity": "sha512-HTlk5nmhkm8F6JcdXvHIzaorzCoziNQT9mGxLPVXW8wJF1TiGSL60ZGB4gHWabHOaMmWmhvk2/lPHfnBiT78AQ==", - "dev": true, + "version": "16.4.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.1.tgz", + "integrity": "sha512-CjA3y+Dr3FyFDOAMnxZEGtnW9KBR2M0JvvUtXNW+dYJL5ROWxP9DUHCwgFqpMk0OXCc0ljhaNTr2w/kutYIcHQ==", "engines": { "node": ">=12" }, @@ -14976,6 +14992,50 @@ "node": ">=10" } }, + "node_modules/playwright": { + "version": "1.41.2", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.41.2.tgz", + "integrity": "sha512-v0bOa6H2GJChDL8pAeLa/LZC4feoAMbSQm1/jF/ySsWWoaNItvrMP7GEkvEEFyCTUYKMxjQKaTSg5up7nR6/8A==", + "dev": true, + "dependencies": { + "playwright-core": "1.41.2" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.41.2", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.41.2.tgz", + "integrity": "sha512-VaTvwCA4Y8kxEe+kfm2+uUUw5Lubf38RxF7FpBxLPmGe5sdNkSg5e3ChEigaGrX7qdqT3pt2m/98LiyvU2x6CA==", + "dev": true, + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/playwright/node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/pnp-webpack-plugin": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/pnp-webpack-plugin/-/pnp-webpack-plugin-1.7.0.tgz", diff --git a/package.json b/package.json index 2ed33fc..20df8ba 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "bcrypt": "^5.1.1", "crypto": "^1.0.1", "date-fns": "^3.3.0", + "dotenv": "^16.4.1", "jsonwebtoken": "^9.0.2", "next": "14.0.4", "next-auth": "^4.24.5", @@ -38,6 +39,7 @@ "zod": "^3.22.4" }, "devDependencies": { + "@playwright/test": "^1.41.2", "@storybook/addon-essentials": "^7.6.10", "@storybook/addon-interactions": "^7.6.10", "@storybook/addon-links": "^7.6.10", diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 0000000..458c09e --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,80 @@ +import { defineConfig, devices } from '@playwright/test'; +import dotenv from 'dotenv'; +import path from 'path'; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); +dotenv.config({ path: path.resolve(__dirname, '.', '.env.local') }); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + testDir: './tests', + /* Run tests in files in parallel */ + fullyParallel: true, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: !!process.env.CI, + /* Retry on CI only */ + retries: process.env.CI ? 2 : 0, + /* Opt out of parallel tests on CI. */ + workers: process.env.CI ? 1 : undefined, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: 'html', + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Base URL to use in actions like `await page.goto('/')`. */ + baseURL: 'http://localhost:3000', + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'on-first-retry', + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] }, + }, + + // { + // name: 'firefox', + // use: { ...devices['Desktop Firefox'] }, + // }, + + // { + // name: 'webkit', + // use: { ...devices['Desktop Safari'] }, + // }, + + /* Test against mobile viewports. */ + // { + // name: 'Mobile Chrome', + // use: { ...devices['Pixel 5'] }, + // }, + // { + // name: 'Mobile Safari', + // use: { ...devices['iPhone 12'] }, + // }, + + /* Test against branded browsers. */ + // { + // name: 'Microsoft Edge', + // use: { ...devices['Desktop Edge'], channel: 'msedge' }, + // }, + // { + // name: 'Google Chrome', + // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, + // }, + ], + + /* Run your local dev server before starting the tests */ + webServer: { + command: 'npm run dev', + url: 'http://localhost:3000', + reuseExistingServer: !process.env.CI, + }, +}); diff --git a/src/api/email.ts b/src/api/email.ts index 06da9dc..d976d70 100644 --- a/src/api/email.ts +++ b/src/api/email.ts @@ -11,6 +11,7 @@ export const SendInviteEmail = async ( subject: string, ): Promise => { try { + console.log('Sending email to:', email); // TODO: change from address to actual platform email - need to purchasedomain. currently not developed const sendResponse = await resend.emails.send({ from: SenderString, diff --git a/src/consts.ts b/src/consts.ts index dfe6194..90a1c17 100644 --- a/src/consts.ts +++ b/src/consts.ts @@ -1,5 +1,9 @@ +import { Role } from '@prisma/client'; + export const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; +export const baseURL = 'http://localhost:3000'; + export enum Routes { AUTH = '/auth', DASHBOARD = '/dashboard', @@ -11,3 +15,11 @@ export enum Endpoints { AUTH = '/auth', TASKS = '/tasks', } + +export const User = { + email: 'may74@gmail.com', + password: '123123', + name: 'test', + teamName: 'test', + Role: Role.ADMIN, +}; diff --git a/tests/Auth/auth.spec.ts b/tests/Auth/auth.spec.ts new file mode 100644 index 0000000..10688e2 --- /dev/null +++ b/tests/Auth/auth.spec.ts @@ -0,0 +1,18 @@ +import { Routes, baseURL, User } from '@/consts'; +import { test, expect } from '@playwright/test'; + +test.beforeEach(async ({ page }) => { + await page.goto(baseURL); +}); + +test('login test without signup', async ({ page }) => { + // Expect a title "to contain" a substring. + await page.getByPlaceholder('Email').fill(User.email); + await page.getByPlaceholder('Password').fill(User.password); + await page.getByRole('button', { name: 'Log in' }).click(); + await page.waitForURL(Routes.DASHBOARD); + expect(page.url()).toBe(baseURL + Routes.DASHBOARD); + expect(await page.getByRole('button', { name: 'Logout' }).textContent()).toBe( + 'Logout', + ); +}); From 7b017e3fe37c8df7a967aac5c06b1390742da081 Mon Sep 17 00:00:00 2001 From: May Shech Date: Sun, 4 Feb 2024 23:49:23 +0200 Subject: [PATCH 10/22] looking for something --- .github/workflows/playwright.yml | 45 +++++++++++++++++++------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 90b6b70..6eb5595 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,27 +1,36 @@ name: Playwright Tests on: push: - branches: [ main, master ] + branches: [main, master] pull_request: - branches: [ main, master ] + branches: [main, master] jobs: test: + services: + postgres: + image: postgres:13 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + ports: + - 5432:5432 timeout-minutes: 60 runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 - - name: Install dependencies - run: npm ci - - name: Install Playwright Browsers - run: npx playwright install --with-deps - - name: Run Playwright tests - run: npx playwright test - - uses: actions/upload-artifact@v3 - if: always() - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install dependencies + run: npm ci + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Run Playwright tests + run: npx playwright test + - uses: actions/upload-artifact@v3 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 From 9990b0260fa6bd2dad6772d9425c350a50ee4b1d Mon Sep 17 00:00:00 2001 From: May Shech Date: Sun, 4 Feb 2024 23:51:58 +0200 Subject: [PATCH 11/22] a little change --- .github/workflows/playwright.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 6eb5595..7ab5cbe 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -28,6 +28,11 @@ jobs: run: npx playwright install --with-deps - name: Run Playwright tests run: npx playwright test + env: + # The hostname used to communicate with the PostgreSQL service container + POSTGRES_HOST: postgres + # The default PostgreSQL port + POSTGRES_PORT: 5432 - uses: actions/upload-artifact@v3 if: always() with: From 4f2d525912aede3fc153601d3f571165cc436e7f Mon Sep 17 00:00:00 2001 From: May Shech Date: Sun, 4 Feb 2024 23:55:28 +0200 Subject: [PATCH 12/22] added a new test --- tests/Auth/auth.spec.ts | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/tests/Auth/auth.spec.ts b/tests/Auth/auth.spec.ts index 10688e2..338ec21 100644 --- a/tests/Auth/auth.spec.ts +++ b/tests/Auth/auth.spec.ts @@ -5,14 +5,20 @@ test.beforeEach(async ({ page }) => { await page.goto(baseURL); }); -test('login test without signup', async ({ page }) => { - // Expect a title "to contain" a substring. - await page.getByPlaceholder('Email').fill(User.email); - await page.getByPlaceholder('Password').fill(User.password); - await page.getByRole('button', { name: 'Log in' }).click(); - await page.waitForURL(Routes.DASHBOARD); - expect(page.url()).toBe(baseURL + Routes.DASHBOARD); - expect(await page.getByRole('button', { name: 'Logout' }).textContent()).toBe( - 'Logout', - ); +// test('login test without signup', async ({ page }) => { +// // Expect a title "to contain" a substring. +// await page.getByPlaceholder('Email').fill(User.email); +// await page.getByPlaceholder('Password').fill(User.password); +// await page.getByRole('button', { name: 'Log in' }).click(); +// await page.waitForURL(Routes.DASHBOARD); +// expect(page.url()).toBe(baseURL + Routes.DASHBOARD); +// expect(await page.getByRole('button', { name: 'Logout' }).textContent()).toBe( +// 'Logout', +// ); +// }); + +test('load login page', async ({ page }) => { + await page.goto(baseURL + Routes.AUTH); + expect(page.url()).toBe(baseURL + Routes.AUTH); + expect(await page.title()).toBe('Management System'); }); From 9541cf2dbef18da5023494f2a53fc80f9bd66fc2 Mon Sep 17 00:00:00 2001 From: May Shech Date: Mon, 5 Feb 2024 00:23:11 +0200 Subject: [PATCH 13/22] added another test --- src/consts.ts | 3 +- tests/Auth/auth.spec.ts | 66 +++++++++++++++++++++++++++++++++-------- 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/src/consts.ts b/src/consts.ts index 90a1c17..5eb6985 100644 --- a/src/consts.ts +++ b/src/consts.ts @@ -15,9 +15,8 @@ export enum Endpoints { AUTH = '/auth', TASKS = '/tasks', } - export const User = { - email: 'may74@gmail.com', + email: 'test@gmail.com', password: '123123', name: 'test', teamName: 'test', diff --git a/tests/Auth/auth.spec.ts b/tests/Auth/auth.spec.ts index 338ec21..f5d08c1 100644 --- a/tests/Auth/auth.spec.ts +++ b/tests/Auth/auth.spec.ts @@ -1,24 +1,66 @@ import { Routes, baseURL, User } from '@/consts'; import { test, expect } from '@playwright/test'; +import prisma from '../../lib/prismadb'; +import bcrypt from 'bcrypt'; +import { Provider } from '@prisma/client'; test.beforeEach(async ({ page }) => { await page.goto(baseURL); }); -// test('login test without signup', async ({ page }) => { -// // Expect a title "to contain" a substring. -// await page.getByPlaceholder('Email').fill(User.email); -// await page.getByPlaceholder('Password').fill(User.password); -// await page.getByRole('button', { name: 'Log in' }).click(); -// await page.waitForURL(Routes.DASHBOARD); -// expect(page.url()).toBe(baseURL + Routes.DASHBOARD); -// expect(await page.getByRole('button', { name: 'Logout' }).textContent()).toBe( -// 'Logout', -// ); -// }); - test('load login page', async ({ page }) => { await page.goto(baseURL + Routes.AUTH); expect(page.url()).toBe(baseURL + Routes.AUTH); expect(await page.title()).toBe('Management System'); }); + +test('check db', async () => { + const users = await prisma.user.findMany(); + console.log(users); + expect(users).toBeTruthy(); +}); + +test('create static user in db', async () => { + const passwordHash = bcrypt.hashSync(User.password, 10); + const user = await prisma.user.create({ + data: { + email: User.email, + fullName: User.name, + passwordHash: passwordHash, + lastLogin: new Date(), + role: User.Role, + provider: Provider.EMAIL, + }, + select: { + id: true, + email: true, + fullName: true, + passwordHash: true, + lastLogin: true, + teamId: true, + role: true, + }, + }); + const team = await prisma.team.create({ + data: { + name: User.teamName, + users: { + connect: { + id: user.id, + }, + }, + }, + }); +}); + +test('login test without signup', async ({ page }) => { + // Expect a title "to contain" a substring. + await page.getByPlaceholder('Email').fill(User.email); + await page.getByPlaceholder('Password').fill(User.password); + await page.getByRole('button', { name: 'Log in' }).click(); + await page.waitForURL(Routes.DASHBOARD); + expect(page.url()).toBe(baseURL + Routes.DASHBOARD); + expect(await page.getByRole('button', { name: 'Logout' }).textContent()).toBe( + 'Logout', + ); +}); From 10285b5cdd5a1d49a6fcfeb33b3eeba3e3a12594 Mon Sep 17 00:00:00 2001 From: May Shech Date: Mon, 5 Feb 2024 00:37:41 +0200 Subject: [PATCH 14/22] Hope its working now --- .github/workflows/playwright.yml | 1 + tests/Auth/auth.spec.ts | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 7ab5cbe..637fbcf 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -33,6 +33,7 @@ jobs: POSTGRES_HOST: postgres # The default PostgreSQL port POSTGRES_PORT: 5432 + DATABASE_URL: ${{ secrets.DATABASE_URL }} - uses: actions/upload-artifact@v3 if: always() with: diff --git a/tests/Auth/auth.spec.ts b/tests/Auth/auth.spec.ts index f5d08c1..e78819f 100644 --- a/tests/Auth/auth.spec.ts +++ b/tests/Auth/auth.spec.ts @@ -16,7 +16,6 @@ test('load login page', async ({ page }) => { test('check db', async () => { const users = await prisma.user.findMany(); - console.log(users); expect(users).toBeTruthy(); }); From af1ef13b1ab199f40be4b080ea93cb81725603c2 Mon Sep 17 00:00:00 2001 From: May Shech Date: Mon, 5 Feb 2024 00:43:42 +0200 Subject: [PATCH 15/22] lets check --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 637fbcf..2626b5a 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -25,7 +25,7 @@ jobs: - name: Install dependencies run: npm ci - name: Install Playwright Browsers - run: npx playwright install --with-deps + run: npm run build && npx playwright install --with-deps - name: Run Playwright tests run: npx playwright test env: From 8f4b26556f2158568630816caa179d4fc19bc06b Mon Sep 17 00:00:00 2001 From: May Shech Date: Mon, 5 Feb 2024 00:46:58 +0200 Subject: [PATCH 16/22] should work --- .github/workflows/playwright.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 2626b5a..45af0ef 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -34,6 +34,7 @@ jobs: # The default PostgreSQL port POSTGRES_PORT: 5432 DATABASE_URL: ${{ secrets.DATABASE_URL }} + POSTGRES_URL_NON_POOLING: ${{ secrets.POSTGRES_URL_NON_POOLING }} - uses: actions/upload-artifact@v3 if: always() with: From d42fc8d2f4c983f1208a976a9392595d2561fbac Mon Sep 17 00:00:00 2001 From: May Shech Date: Mon, 5 Feb 2024 00:54:43 +0200 Subject: [PATCH 17/22] last chance for today --- .github/workflows/playwright.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 45af0ef..6d45ff0 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -26,6 +26,9 @@ jobs: run: npm ci - name: Install Playwright Browsers run: npm run build && npx playwright install --with-deps + env: + DATABASE_URL: ${{ secrets.DATABASE_URL }} + POSTGRES_URL_NON_POOLING: ${{ secrets.POSTGRES_URL_NON_POOLING }} - name: Run Playwright tests run: npx playwright test env: @@ -34,7 +37,7 @@ jobs: # The default PostgreSQL port POSTGRES_PORT: 5432 DATABASE_URL: ${{ secrets.DATABASE_URL }} - POSTGRES_URL_NON_POOLING: ${{ secrets.POSTGRES_URL_NON_POOLING }} + - uses: actions/upload-artifact@v3 if: always() with: From aad2d4443b561c6417358bafa8fec9660ce9ee83 Mon Sep 17 00:00:00 2001 From: May Shech Date: Mon, 5 Feb 2024 00:58:45 +0200 Subject: [PATCH 18/22] added vercel secrets --- .github/workflows/playwright.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 6d45ff0..bb53f23 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -29,6 +29,8 @@ jobs: env: DATABASE_URL: ${{ secrets.DATABASE_URL }} POSTGRES_URL_NON_POOLING: ${{ secrets.POSTGRES_URL_NON_POOLING }} + VERCEL_EMAIL_API_KEY: ${{ secrets.VERCEL_EMAIL_API_KEY }} + VERCEL_EMAIL_SENDER: ${{ secrets.VERCEL_EMAIL_SENDER }} - name: Run Playwright tests run: npx playwright test env: From 8910679cd46ecc34e1e8a4ae79a840625ed3f2a3 Mon Sep 17 00:00:00 2001 From: May Shech Date: Mon, 5 Feb 2024 01:08:44 +0200 Subject: [PATCH 19/22] changed the style --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index bb53f23..95459a6 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -32,7 +32,7 @@ jobs: VERCEL_EMAIL_API_KEY: ${{ secrets.VERCEL_EMAIL_API_KEY }} VERCEL_EMAIL_SENDER: ${{ secrets.VERCEL_EMAIL_SENDER }} - name: Run Playwright tests - run: npx playwright test + run: npx playwright test --workers=2 --debug --reporter=list env: # The hostname used to communicate with the PostgreSQL service container POSTGRES_HOST: postgres From dd434c128f9515ba329174adc6f0b225b767a4ce Mon Sep 17 00:00:00 2001 From: May Shech Date: Mon, 5 Feb 2024 01:14:13 +0200 Subject: [PATCH 20/22] should work now , and goodnight to me --- .github/workflows/playwright.yml | 2 +- playwright.config.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 95459a6..cc12434 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -32,7 +32,7 @@ jobs: VERCEL_EMAIL_API_KEY: ${{ secrets.VERCEL_EMAIL_API_KEY }} VERCEL_EMAIL_SENDER: ${{ secrets.VERCEL_EMAIL_SENDER }} - name: Run Playwright tests - run: npx playwright test --workers=2 --debug --reporter=list + run: npx playwright test --workers=1 --reporter=list env: # The hostname used to communicate with the PostgreSQL service container POSTGRES_HOST: postgres diff --git a/playwright.config.ts b/playwright.config.ts index 458c09e..6da7e53 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -15,7 +15,7 @@ dotenv.config({ path: path.resolve(__dirname, '.', '.env.local') }); export default defineConfig({ testDir: './tests', /* Run tests in files in parallel */ - fullyParallel: true, + fullyParallel: false, /* Fail the build on CI if you accidentally left test.only in the source code. */ forbidOnly: !!process.env.CI, /* Retry on CI only */ From dfc4c51fcfef32006520c82fa98adb5a6ae4566d Mon Sep 17 00:00:00 2001 From: May Shech Date: Mon, 5 Feb 2024 01:17:49 +0200 Subject: [PATCH 21/22] will check it later --- tests/Auth/auth.spec.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/Auth/auth.spec.ts b/tests/Auth/auth.spec.ts index e78819f..8635049 100644 --- a/tests/Auth/auth.spec.ts +++ b/tests/Auth/auth.spec.ts @@ -52,14 +52,14 @@ test('create static user in db', async () => { }); }); -test('login test without signup', async ({ page }) => { - // Expect a title "to contain" a substring. - await page.getByPlaceholder('Email').fill(User.email); - await page.getByPlaceholder('Password').fill(User.password); - await page.getByRole('button', { name: 'Log in' }).click(); - await page.waitForURL(Routes.DASHBOARD); - expect(page.url()).toBe(baseURL + Routes.DASHBOARD); - expect(await page.getByRole('button', { name: 'Logout' }).textContent()).toBe( - 'Logout', - ); -}); +// test('login test without signup', async ({ page }) => { +// // Expect a title "to contain" a substring. +// await page.getByPlaceholder('Email').fill(User.email); +// await page.getByPlaceholder('Password').fill(User.password); +// await page.getByRole('button', { name: 'Log in' }).click(); +// await page.waitForURL(Routes.DASHBOARD); +// expect(page.url()).toBe(baseURL + Routes.DASHBOARD); +// expect(await page.getByRole('button', { name: 'Logout' }).textContent()).toBe( +// 'Logout', +// ); +// }); From 30e5e4ac2b6389a060ba07c04b119a51de8a8de5 Mon Sep 17 00:00:00 2001 From: May Shech Date: Mon, 5 Feb 2024 15:33:31 +0200 Subject: [PATCH 22/22] new test --- tests/Auth/auth.spec.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/Auth/auth.spec.ts b/tests/Auth/auth.spec.ts index 8635049..e78819f 100644 --- a/tests/Auth/auth.spec.ts +++ b/tests/Auth/auth.spec.ts @@ -52,14 +52,14 @@ test('create static user in db', async () => { }); }); -// test('login test without signup', async ({ page }) => { -// // Expect a title "to contain" a substring. -// await page.getByPlaceholder('Email').fill(User.email); -// await page.getByPlaceholder('Password').fill(User.password); -// await page.getByRole('button', { name: 'Log in' }).click(); -// await page.waitForURL(Routes.DASHBOARD); -// expect(page.url()).toBe(baseURL + Routes.DASHBOARD); -// expect(await page.getByRole('button', { name: 'Logout' }).textContent()).toBe( -// 'Logout', -// ); -// }); +test('login test without signup', async ({ page }) => { + // Expect a title "to contain" a substring. + await page.getByPlaceholder('Email').fill(User.email); + await page.getByPlaceholder('Password').fill(User.password); + await page.getByRole('button', { name: 'Log in' }).click(); + await page.waitForURL(Routes.DASHBOARD); + expect(page.url()).toBe(baseURL + Routes.DASHBOARD); + expect(await page.getByRole('button', { name: 'Logout' }).textContent()).toBe( + 'Logout', + ); +});