backend tests in ci, clean pg import (#71)
- run backend tests in CI - clean `pg` import - fix cyclic dependency - fix dotenv import --------- Co-authored-by: Marco Pasqualetti <24919330+marcalexiei@users.noreply.github.com>
This commit is contained in:
co-authored by
Marco Pasqualetti
parent
3fb7b37d75
commit
f64b56ae9a
@@ -33,19 +33,22 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Install Dependencies
|
||||
uses: ./.github/actions/install-dependencies
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
|
||||
- name: Run vercel-preparation.sh
|
||||
run: |
|
||||
chmod +x ./vercel-preparation.sh
|
||||
./vercel-preparation.sh
|
||||
|
||||
- name: Install Dependencies
|
||||
uses: ./.github/actions/install-dependencies
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
|
||||
- name: Build frontend
|
||||
run: pnpm --filter frontend run build
|
||||
|
||||
- name: Run backend tests
|
||||
run: pnpm --filter github-readme-stats run test
|
||||
|
||||
frontend-test-e2e:
|
||||
name: Frontend E2E test
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// @ts-check
|
||||
|
||||
/**
|
||||
* Valid owner affiliations for GitHub API queries.
|
||||
* @type {Array<string>}
|
||||
*/
|
||||
const OWNER_AFFILIATIONS = ["OWNER", "COLLABORATOR", "ORGANIZATION_MEMBER"];
|
||||
|
||||
export { OWNER_AFFILIATIONS };
|
||||
@@ -1,6 +1,8 @@
|
||||
import pkg from "pg";
|
||||
// eslint-disable-next-line import-x/no-named-as-default-member
|
||||
const { Pool } = pkg;
|
||||
/**
|
||||
* In the browser this has to be mocked to avoid runtime errors
|
||||
* @see apps/frontend/vite.config.ts
|
||||
*/
|
||||
import { Pool } from "pg";
|
||||
|
||||
export const pool = process.env.POSTGRES_URL
|
||||
? new Pool({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// @ts-check
|
||||
|
||||
import { OWNER_AFFILIATIONS } from "./ops.js";
|
||||
import { OWNER_AFFILIATIONS } from "./constants.js";
|
||||
|
||||
/**
|
||||
* @type {string} A general message to ask user to try again later.
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
|
||||
import toEmoji from "emoji-name-map";
|
||||
|
||||
import { OWNER_AFFILIATIONS } from "./constants.js";
|
||||
import { CustomError } from "./error.js";
|
||||
|
||||
const OWNER_AFFILIATIONS = ["OWNER", "COLLABORATOR", "ORGANIZATION_MEMBER"];
|
||||
|
||||
/**
|
||||
* Returns boolean if value is either "true" or "false" else the value as it is.
|
||||
*
|
||||
@@ -161,7 +160,6 @@ const buildSearchFilter = (repos = [], owners = []) => {
|
||||
};
|
||||
|
||||
export {
|
||||
OWNER_AFFILIATIONS,
|
||||
parseBoolean,
|
||||
parseArray,
|
||||
clampValue,
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from "@jest/globals";
|
||||
import axios from "axios";
|
||||
import MockAdapter from "axios-mock-adapter";
|
||||
import { dotenv } from "dotenv";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
import patInfo, { RATE_LIMIT_SECONDS } from "../api-renamed/status/pat-info.js";
|
||||
|
||||
|
||||
@@ -45,25 +45,25 @@ test("navigates between steps", async ({ page }) => {
|
||||
// We are at stage 1
|
||||
await expect(page.getByRole("heading", { level: 1 })).toContainText("Login");
|
||||
|
||||
// Go to to stage 2
|
||||
// Go to stage 2
|
||||
await page.getByRole("button", { name: "Select card" }).click();
|
||||
await expect(page.getByRole("heading", { level: 1 })).toContainText(
|
||||
"Select a Card",
|
||||
);
|
||||
|
||||
// Go to to stage 3
|
||||
// Go to stage 3
|
||||
await page.getByRole("button", { name: "Modify parameters" }).click();
|
||||
await expect(page.getByRole("heading", { level: 1 })).toContainText(
|
||||
"Modify Card Parameters",
|
||||
);
|
||||
|
||||
// Go to to stage 4
|
||||
// Go to stage 4
|
||||
await page.getByRole("button", { name: "Select theme" }).click();
|
||||
await expect(page.getByRole("heading", { level: 1 })).toContainText(
|
||||
"Choose a Theme",
|
||||
);
|
||||
|
||||
// Go to to stage 5
|
||||
// Go to stage 5
|
||||
await page.getByRole("button", { name: "Display card" }).click();
|
||||
await expect(page.getByRole("heading", { level: 1 })).toContainText(
|
||||
"Display your Card",
|
||||
|
||||
@@ -31,7 +31,10 @@ export default defineConfig({
|
||||
|
||||
react(),
|
||||
|
||||
// mock pg (postgres) package in the browser to avoid runtime errors
|
||||
/**
|
||||
* mock pg (postgres) package in the browser to avoid runtime errors
|
||||
* @see apps/backend/src/common/database.js
|
||||
*/
|
||||
{
|
||||
name: "empty-pg-package",
|
||||
resolveId(id) {
|
||||
@@ -42,7 +45,7 @@ export default defineConfig({
|
||||
},
|
||||
load(id) {
|
||||
if (id === "pg") {
|
||||
return "export default {}";
|
||||
return "export class Pool { constructor(config) {} }";
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user