Skip to content

Commit

Permalink
export prisma client from server
Browse files Browse the repository at this point in the history
  • Loading branch information
vincanger committed Mar 18, 2024
1 parent e8115ec commit 5544f2a
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 89 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,14 @@ jobs:
cd app
cp .env.server.example .env.server
- name: Install Playwright tests
run: |
cd app
npm install @playwright/test
- name: Set up Playwright
run: |
cd app
cd ../e2e-tests
npx playwright install --with-deps
- name: Run Playwright tests
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
cd app
DEBUG=pw:webserver npx playwright test e2e-tests
DEBUG=pw:webserver npx playwright test
60 changes: 0 additions & 60 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"name": "opensaas",
"scripts": {

},
"scripts": {},
"dependencies": {
"@aws-sdk/client-s3": "^3.523.0",
"@aws-sdk/s3-request-presigner": "^3.523.0",
Expand All @@ -29,7 +27,6 @@
"zod": "3.22.4"
},
"devDependencies": {
"@playwright/test": "^1.42.0",
"@types/express": "^4.17.13",
"@types/node": "^18.0.0",
"@types/react": "^18.0.37",
Expand All @@ -38,4 +35,4 @@
"typescript": "^5.1.0",
"vite": "^4.3.9"
}
}
}
3 changes: 3 additions & 0 deletions app/src/server/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { PrismaClient } from '@prisma/client';

export const prisma = new PrismaClient();
151 changes: 151 additions & 0 deletions e2e-tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions e2e-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "e2e-tests",
"version": "1.0.0",
"description": "e2e-tests for opensaas.sh",
"main": "ci-start-app.js",
"directories": {
"test": "tests"
},
"scripts": {
"test": "npx playwright test"
},
"author": "",
"license": "ISC",
"dependencies": {
"@playwright/test": "^1.42.1"
},
"devDependencies": {
"@types/node": "^18.0.0",
"prisma": "^5.11.0"
}
}
7 changes: 2 additions & 5 deletions e2e-tests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ import { defineConfig, devices } from '@playwright/test';
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './playwright/tests',
outputDir: './playwright/test-results',
// put playwright-report in the playwright folder
reporter: [['html', { outputFolder: 'playwright/reports' }]],
// reporter: [['html', { outputFolder: 'playwright/reports' }]],
testDir: './tests',
outputDir: './test-results',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
Expand Down
20 changes: 11 additions & 9 deletions e2e-tests/tests/paidUserTests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ test('Demo App: add tasks & generate schedule', async ({ loggedInPage }) => {
expect(generateScheduleButton).toBeTruthy();

await Promise.all([
loggedInPage.waitForRequest(
(req) => req.url().includes('operations/generate-gpt-response') && req.method() === 'POST'
),
loggedInPage.waitForResponse((response) => {
if (response.url().includes('/operations/generate-gpt-response') && response.status() === 200) {
return true;
}
return false;
}),
loggedInPage
.waitForRequest((req) => req.url().includes('operations/generate-gpt-response') && req.method() === 'POST')
.catch((err) => console.error(err.message)),
loggedInPage
.waitForResponse((response) => {
if (response.url().includes('/operations/generate-gpt-response') && response.status() === 200) {
return true;
}
return false;
})
.catch((err) => console.error(err.message)),
// We already started waiting before we perform the click that triggers the API calls. So now we just perform the click
generateScheduleButton.click(),
]);
Expand Down
4 changes: 1 addition & 3 deletions e2e-tests/tests/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { test as base, type Page } from '@playwright/test';
import { PrismaClient } from '@prisma/client';
import { prisma } from '../../app/src/server/utils';
import { randomUUID } from 'crypto';

export const prisma = new PrismaClient();

export type User = {
id?: number;
username: string;
Expand Down

0 comments on commit 5544f2a

Please sign in to comment.