Skip to content

Commit 0ac315b

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents bbfbd2d + 6b11e6b commit 0ac315b

File tree

8 files changed

+61
-93
lines changed

8 files changed

+61
-93
lines changed

backend/api/tests/unit/get-users.unit.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { getUser } from "api/get-user";
22
import { createSupabaseDirectClient } from "shared/supabase/init";
33
import { toUserAPIResponse } from "common/api/user-types";
44
import { convertUser } from "common/supabase/users";
5+
import { APIError } from "common/src/api/utils";
56

67
jest.mock("shared/supabase/init");
78
jest.mock("common/supabase/users");

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"@capacitor/assets": "3.0.5",
5151
"@capacitor/cli": "7.4.4",
5252
"@faker-js/faker": "10.1.0",
53+
"@types/jest": "29.2.4",
5354
"@testing-library/dom": "^10.0.0",
5455
"@testing-library/jest-dom": "^6.6.4",
5556
"@testing-library/react": "^16.3.0",
@@ -63,11 +64,13 @@
6364
"eslint": "8.57.0",
6465
"eslint-plugin-lodash": "^7.4.0",
6566
"eslint-plugin-unused-imports": "4.1.4",
67+
"jest": "29.3.1",
6668
"nodemon": "2.0.20",
6769
"prettier": "3.6.2",
6870
"prettier-plugin-sql": "0.19.2",
6971
"prettier-plugin-tailwindcss": "^0.2.1",
7072
"ts-node": "10.9.1",
73+
"ts-jest": "29.0.3",
7174
"tsc-alias": "1.8.2",
7275
"tsconfig-paths": "4.2.0",
7376
"tsx": "4.20.6",

playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default defineConfig({
66
forbidOnly: !!process.env.CI,
77
retries: process.env.CI ? 2 : 0,
88
workers: process.env.CI ? 1 : undefined,
9-
reporter: [['html', {outputFolder: `tests/reports/playwright-report`, open: 'on-falure'}]],
9+
reporter: [['html', {outputFolder: `tests/reports/playwright-report`, open: 'on-failure'}]],
1010
use: {
1111
baseURL: 'http://localhost:3000',
1212
trace: 'on-first-retry',

tests/e2e/backend/fixtures/base.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
import { test as base, APIRequestContext, request } from '@playwright/test';
2+
import { createSupabaseDirectClient } from "../../../../backend/shared/src/supabase/init";
23

34
export type TestOptions = {
4-
apiContextPage: APIRequestContext,
5+
backendPage: {
6+
api: APIRequestContext,
7+
db: any
8+
}
59
}
610

711
export const test = base.extend<TestOptions>({
8-
apiContextPage: async ({}, use) => {
12+
backendPage: async ({}, use) => {
913
const apiContext = await request.newContext({
1014
baseURL: 'https://api.compassmeet.com'
1115
});
12-
await use(apiContext)
16+
17+
const helpers = {
18+
api: apiContext,
19+
db: createSupabaseDirectClient()
20+
}
21+
await use(helpers)
22+
await apiContext.dispose();
1323
},
1424
})
1525

tests/e2e/backend/specs/api.test.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { test, expect } from "../../fixtures/base";
2+
3+
test('Check API health', async ({backendPage}) => {
4+
const responseHealth = await backendPage.api.get('/health');
5+
expect(responseHealth.status()).toBe(200)
6+
7+
// const responseBody = await responseHealth.json()
8+
// console.log(JSON.stringify(responseBody, null, 2));
9+
10+
});

tests/e2e/backend/specs/db.test.ts

Lines changed: 6 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,9 @@
1-
import {expect, test } from '@playwright/test';
2-
import { createSupabaseDirectClient } from "../../../../backend/shared/src/supabase/init";
3-
4-
test('View database', async () => {
5-
// const dbClient = createSupabaseDirectClient()
6-
// const queryUserID = `
7-
// SELECT p.*
8-
// FROM public.profiles AS p
9-
// WHERE id = $1
10-
// `;
11-
12-
// const queryTableColumns = `
13-
// SELECT
14-
// column_name,
15-
// data_type,
16-
// character_maximum_length,
17-
// is_nullable,
18-
// column_default
19-
// FROM information_schema.columns
20-
// WHERE table_schema = 'public'
21-
// AND table_name ='profiles'
22-
// ORDER BY ordinal_position;
23-
// `;
24-
25-
// const queryTableColumnsNullable = `
26-
// SELECT
27-
// column_name,
28-
// data_type,
29-
// character_maximum_length,
30-
// column_default
31-
// FROM information_schema.columns
32-
// WHERE table_schema = 'public'
33-
// AND table_name =$1
34-
// AND is_nullable = $2
35-
// ORDER BY ordinal_position;
36-
// `;
37-
38-
// const queryInsertUserProfile = `
39-
// INSERT INTO profiles (name, username)
40-
// VALUES ($1, $2)
41-
// RETURNING *;
42-
// `;
43-
44-
// const queryInsertUsers = `
45-
// INSERT INTO profiles (id, bio)
46-
// VALUES ($1, $2)
47-
// RETURNING *;
48-
// `;
49-
50-
51-
// const rows = await dbClient.query(
52-
// queryInsertUsers,
53-
// [
54-
// 'JFTZOhrBagPk',
55-
// {
56-
// "type": "doc",
57-
// "content": [
58-
// {
59-
// "type": "paragraph",
60-
// "content": [
61-
// {
62-
// "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
63-
// "type": "text"
64-
// }
65-
// ]
66-
// }
67-
// ]
68-
// }
69-
// ]
70-
// )
71-
72-
// console.log("Type of: ",typeof(rows));
73-
// console.log("Number of rows: ",rows.length);
74-
75-
// console.log(JSON.stringify(await rows, null, 2));
1+
import {expect, test } from '../fixtures/base';
2+
import { databaseUtils } from "../utils/database";
763

4+
test('View database', async ({backendPage}) => {
5+
const userAccount = await databaseUtils.findUserByName(backendPage, 'Franklin Buckridge')
6+
const userProfile = await databaseUtils.findProfileById(backendPage, userAccount.id)
7+
console.log(userAccount);
778

789
})
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
class DatabaseTestingUtilities {
2+
findUserByName = async (page: any, name: string) => {
3+
const queryUserById = `
4+
SELECT p.*
5+
FROM public.users AS p
6+
WHERE name = $1
7+
`;
8+
const userResults = await page.db.query(queryUserById,[name])
9+
return userResults[0]
10+
}
11+
12+
findProfileById = async (page: any, user_id: string) => {
13+
const queryProfileById = `
14+
SELECT
15+
p.*,
16+
TO_CHAR(p.created_time, 'Mon DD, YYYY HH12:MI AM') as created_date,
17+
TO_CHAR(p.last_modification_time, 'Mon DD, YYYY HH12:MI AM') as modified_date
18+
FROM public.profiles AS p
19+
WHERE user_id = $1
20+
`;
21+
const profileResults = await page.db.query(queryProfileById,[user_id])
22+
return profileResults[0]
23+
}
24+
25+
}
26+
27+
export const databaseUtils = new DatabaseTestingUtilities();

0 commit comments

Comments
 (0)