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
1 change: 1 addition & 0 deletions backend/api/tests/unit/get-users.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,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",
Expand All @@ -64,11 +65,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",
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
16 changes: 13 additions & 3 deletions tests/e2e/backend/fixtures/base.ts
Original file line number Diff line number Diff line change
@@ -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();
},
})

Expand Down
14 changes: 0 additions & 14 deletions tests/e2e/backend/specs/api.test.ts

This file was deleted.

10 changes: 10 additions & 0 deletions tests/e2e/backend/specs/api/api.test.ts
Original file line number Diff line number Diff line change
@@ -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));

});
81 changes: 6 additions & 75 deletions tests/e2e/backend/specs/db.test.ts
Original file line number Diff line number Diff line change
@@ -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);

})
27 changes: 27 additions & 0 deletions tests/e2e/backend/utils/database.ts
Original file line number Diff line number Diff line change
@@ -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();