Merge remote-tracking branch 'origin/main'

This commit is contained in:
MartinBraquet
2025-11-15 16:12:36 +01:00
8 changed files with 61 additions and 93 deletions

View File

@@ -2,6 +2,7 @@ import { getUser } from "api/get-user";
import { createSupabaseDirectClient } from "shared/supabase/init";
import { toUserAPIResponse } from "common/api/user-types";
import { convertUser } from "common/supabase/users";
import { APIError } from "common/src/api/utils";
jest.mock("shared/supabase/init");
jest.mock("common/supabase/users");

View File

@@ -50,6 +50,7 @@
"@capacitor/assets": "3.0.5",
"@capacitor/cli": "7.4.4",
"@faker-js/faker": "10.1.0",
"@types/jest": "29.2.4",
"@testing-library/dom": "^10.0.0",
"@testing-library/jest-dom": "^6.6.4",
"@testing-library/react": "^16.3.0",
@@ -63,11 +64,13 @@
"eslint": "8.57.0",
"eslint-plugin-lodash": "^7.4.0",
"eslint-plugin-unused-imports": "4.1.4",
"jest": "29.3.1",
"nodemon": "2.0.20",
"prettier": "3.6.2",
"prettier-plugin-sql": "0.19.2",
"prettier-plugin-tailwindcss": "^0.2.1",
"ts-node": "10.9.1",
"ts-jest": "29.0.3",
"tsc-alias": "1.8.2",
"tsconfig-paths": "4.2.0",
"tsx": "4.20.6",

View File

@@ -6,7 +6,7 @@ export default defineConfig({
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [['html', {outputFolder: `tests/reports/playwright-report`, open: 'on-falure'}]],
reporter: [['html', {outputFolder: `tests/reports/playwright-report`, open: 'on-failure'}]],
use: {
baseURL: 'http://localhost:3000',
trace: 'on-first-retry',

View File

@@ -1,15 +1,25 @@
import { test as base, APIRequestContext, request } from '@playwright/test';
import { createSupabaseDirectClient } from "../../../../backend/shared/src/supabase/init";
export type TestOptions = {
apiContextPage: APIRequestContext,
backendPage: {
api: APIRequestContext,
db: any
}
}
export const test = base.extend<TestOptions>({
apiContextPage: async ({}, use) => {
backendPage: async ({}, use) => {
const apiContext = await request.newContext({
baseURL: 'https://api.compassmeet.com'
});
await use(apiContext)
const helpers = {
api: apiContext,
db: createSupabaseDirectClient()
}
await use(helpers)
await apiContext.dispose();
},
})

View File

@@ -1,14 +0,0 @@
import { test, expect } from "../fixtures/base";
test('Check API health', async ({apiContextPage}) => {
const responseHealth = await apiContextPage.get('/health');
expect(responseHealth.status()).toBe(200)
const responseBody = await responseHealth.json()
console.log(JSON.stringify(responseBody, null, 2));
});
test.afterAll(async ({apiContextPage}) => {
await apiContextPage?.dispose();
})

View File

@@ -0,0 +1,10 @@
import { test, expect } from "../../fixtures/base";
test('Check API health', async ({backendPage}) => {
const responseHealth = await backendPage.api.get('/health');
expect(responseHealth.status()).toBe(200)
// const responseBody = await responseHealth.json()
// console.log(JSON.stringify(responseBody, null, 2));
});

View File

@@ -1,78 +1,9 @@
import {expect, test } from '@playwright/test';
import { createSupabaseDirectClient } from "../../../../backend/shared/src/supabase/init";
test('View database', async () => {
// const dbClient = createSupabaseDirectClient()
// const queryUserID = `
// SELECT p.*
// FROM public.profiles AS p
// WHERE id = $1
// `;
// const queryTableColumns = `
// SELECT
// column_name,
// data_type,
// character_maximum_length,
// is_nullable,
// column_default
// FROM information_schema.columns
// WHERE table_schema = 'public'
// AND table_name ='profiles'
// ORDER BY ordinal_position;
// `;
// const queryTableColumnsNullable = `
// SELECT
// column_name,
// data_type,
// character_maximum_length,
// column_default
// FROM information_schema.columns
// WHERE table_schema = 'public'
// AND table_name =$1
// AND is_nullable = $2
// ORDER BY ordinal_position;
// `;
// const queryInsertUserProfile = `
// INSERT INTO profiles (name, username)
// VALUES ($1, $2)
// RETURNING *;
// `;
// const queryInsertUsers = `
// INSERT INTO profiles (id, bio)
// VALUES ($1, $2)
// RETURNING *;
// `;
// const rows = await dbClient.query(
// queryInsertUsers,
// [
// 'JFTZOhrBagPk',
// {
// "type": "doc",
// "content": [
// {
// "type": "paragraph",
// "content": [
// {
// "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.",
// "type": "text"
// }
// ]
// }
// ]
// }
// ]
// )
// console.log("Type of: ",typeof(rows));
// console.log("Number of rows: ",rows.length);
// console.log(JSON.stringify(await rows, null, 2));
import {expect, test } from '../fixtures/base';
import { databaseUtils } from "../utils/database";
test('View database', async ({backendPage}) => {
const userAccount = await databaseUtils.findUserByName(backendPage, 'Franklin Buckridge')
const userProfile = await databaseUtils.findProfileById(backendPage, userAccount.id)
console.log(userAccount);
})

View File

@@ -0,0 +1,27 @@
class DatabaseTestingUtilities {
findUserByName = async (page: any, name: string) => {
const queryUserById = `
SELECT p.*
FROM public.users AS p
WHERE name = $1
`;
const userResults = await page.db.query(queryUserById,[name])
return userResults[0]
}
findProfileById = async (page: any, user_id: string) => {
const queryProfileById = `
SELECT
p.*,
TO_CHAR(p.created_time, 'Mon DD, YYYY HH12:MI AM') as created_date,
TO_CHAR(p.last_modification_time, 'Mon DD, YYYY HH12:MI AM') as modified_date
FROM public.profiles AS p
WHERE user_id = $1
`;
const profileResults = await page.db.query(queryProfileById,[user_id])
return profileResults[0]
}
}
export const databaseUtils = new DatabaseTestingUtilities();