Compare commits

...

46 commits

Author SHA1 Message Date
28b9737bfa fix(test): fix testing ci workflow and clean up docker
All checks were successful
container-scan / Container Scan (pull_request) Successful in 7m11s
docker-build / docker (pull_request) Successful in 8m2s
tests / Tests (pull_request) Successful in 8m32s
2025-05-20 08:36:14 +02:00
af38d2148c fix(tests): start server for e2e tests 2025-05-20 08:35:59 +02:00
8bfc08d9f9 chore(ci): improve docker cleanup 2025-05-20 08:35:58 +02:00
0a0f27bd1f chore(ci): run e2e tests in workflow 2025-05-20 08:35:58 +02:00
a443909103 chore(ci): docker cleanup 2025-05-20 08:35:58 +02:00
11d98e63ae test(e2e): test login page 2025-05-20 08:35:57 +02:00
99601eaeb7 chore: add testing workflow 2025-05-20 08:35:13 +02:00
dc6d3a7161 test: theme-picker 2025-05-20 08:35:13 +02:00
71c93afad7 test: icon-button 2025-05-20 08:35:13 +02:00
7ed463f59b test: helper functions 2025-05-20 08:35:13 +02:00
b05c9df72f test: initialize cypress e2e testing library 2025-05-20 08:35:10 +02:00
98912d0bfc chore(deps): update dependency tw-animate-css to v1.3.0
All checks were successful
container-scan / Container Scan (push) Successful in 5m1s
docker-build / docker (push) Successful in 1m29s
2025-05-19 22:01:03 +00:00
29525355a1 chore(deps): update dependency tailwindcss to v4.1.7
All checks were successful
container-scan / Container Scan (push) Successful in 5m7s
docker-build / docker (push) Successful in 7m2s
2025-05-19 21:00:45 +00:00
72164ae8e0 Merge pull request 'feat: set up database / orm' (#39)
All checks were successful
container-scan / Container Scan (push) Successful in 2m16s
docker-build / docker (push) Successful in 6m45s
Reviewed-on: #39
Reviewed-by: Maximilian Liebmann <lima@noreply.git.dominikstahl.dev>
2025-05-19 20:16:31 +00:00
efbc44b311 chore: prima init migration 2025-05-19 20:16:31 +00:00
147f75cd84 chore: update prisma 2025-05-19 20:16:31 +00:00
2e662d2634 fix: package.json and yarn.lock 2025-05-19 20:16:31 +00:00
8984f1996b fix: update dependencies in yarn.lock 2025-05-19 20:16:31 +00:00
221557d92d fix: update eslint config to include additional ignore patterns 2025-05-19 20:16:31 +00:00
daf1d50fd0 chore: update dockerfile for prisma 2025-05-19 20:16:31 +00:00
1a48bb0370 fix: yarn.lock 2025-05-19 20:16:31 +00:00
ec37fd1375 style: format files 2025-05-19 20:16:31 +00:00
514254b407 fix: update prisma import paths and adjust .gitignore for generated files 2025-05-19 20:16:31 +00:00
8ef0ea17d4 feat: set up prisma db 2025-05-19 20:16:31 +00:00
9f8dd69987 fix: change User -> username to name 2025-05-19 20:16:31 +00:00
049be0820d feat: add prisma.schema content 2025-05-19 20:16:31 +00:00
bfb550eba0 Merge pull request 'fix: add entrypoint.sh and prisma folder to docker container' (#69)
All checks were successful
container-scan / Container Scan (push) Successful in 1m52s
docker-build / docker (push) Successful in 3m20s
Reviewed-on: #69
2025-05-19 16:53:32 +00:00
5d828a1d1c
fix: add entrypoint.sh and prisma folder to docker container
All checks were successful
container-scan / Container Scan (pull_request) Successful in 1m51s
docker-build / docker (pull_request) Successful in 2m52s
2025-05-19 18:35:50 +02:00
604abd7448 Merge pull request 'chore: prepare docker container for prisma database' (#68)
All checks were successful
container-scan / Container Scan (push) Successful in 2m1s
docker-build / docker (push) Successful in 3m23s
Reviewed-on: #68
Reviewed-by: Maximilian Liebmann <lima@noreply.git.dominikstahl.dev>
2025-05-19 15:23:27 +00:00
904547b50f chore: prepare docker container for prisma database
All checks were successful
container-scan / Container Scan (pull_request) Successful in 1m54s
docker-build / docker (pull_request) Successful in 3m7s
2025-05-19 15:14:01 +00:00
29e7d47546 Merge pull request 'chore: use alpine runner container' (#63)
All checks were successful
container-scan / Container Scan (push) Successful in 1m44s
docker-build / docker (push) Successful in 2m49s
Reviewed-on: #63
Reviewed-by: Maximilian Liebmann <lima@noreply.git.dominikstahl.dev>
2025-05-19 15:13:41 +00:00
2f320e924e
chore: use alpine runner container
All checks were successful
container-scan / Container Scan (pull_request) Successful in 1m23s
docker-build / docker (pull_request) Successful in 4m1s
Use nodejs alpine as the container image to run the app in.
Also adds a shell into the container.

Fixes the problem with prisma not starting in the container because it was compiled for a different version of openssl 3.3.x
2025-05-19 16:58:22 +02:00
6bd4abb1ef chore(deps): update dependency @types/node to v22.15.19
All checks were successful
container-scan / Container Scan (push) Successful in 2m59s
docker-build / docker (push) Successful in 1m19s
2025-05-19 01:01:06 +00:00
6f8e50eb44 chore(deps): update gcr.io/distroless/nodejs22-debian12:nonroot docker digest to 595dcd8
All checks were successful
container-scan / Container Scan (push) Successful in 3m36s
docker-build / docker (push) Successful in 1m19s
2025-05-19 00:00:22 +00:00
100147f257 chore(deps): update dependency tw-animate-css to v1.3.0
All checks were successful
container-scan / Container Scan (push) Successful in 2m34s
docker-build / docker (push) Successful in 1m5s
2025-05-16 20:01:34 +00:00
6ca26e4f5b chore(deps): update dependency eslint to v9.27.0
All checks were successful
container-scan / Container Scan (push) Successful in 2m51s
docker-build / docker (push) Successful in 4m29s
2025-05-16 19:02:12 +00:00
6f0f9bd02a chore(deps): update gcr.io/distroless/nodejs22-debian12:nonroot docker digest to 92c2a6c
All checks were successful
container-scan / Container Scan (push) Successful in 1m50s
docker-build / docker (push) Successful in 4m26s
2025-05-16 18:00:36 +00:00
98f19cd398 chore(deps): update dependency prisma to v6.8.2
All checks were successful
container-scan / Container Scan (push) Successful in 2m44s
docker-build / docker (push) Successful in 4m45s
2025-05-16 17:00:51 +00:00
1e9712a2dc chore(deps): update ghcr.io/di0ik/forgejo_runner_container:main docker digest to c66a37d
All checks were successful
container-scan / Container Scan (push) Successful in 1m23s
docker-build / docker (push) Successful in 1m2s
2025-05-16 08:01:46 +00:00
9d9d575331 chore(deps): update node.js to 152270c
All checks were successful
container-scan / Container Scan (push) Successful in 1m20s
docker-build / docker (push) Successful in 1m11s
2025-05-16 01:00:22 +00:00
86d08cc199 chore(deps): update node.js to f0a2ea7
All checks were successful
container-scan / Container Scan (push) Successful in 1m32s
docker-build / docker (push) Successful in 1m15s
2025-05-15 22:00:21 +00:00
25c02fd30c chore(deps): update dependency prisma to v6.8.1
All checks were successful
container-scan / Container Scan (push) Successful in 2m31s
docker-build / docker (push) Successful in 1m5s
2025-05-15 20:01:00 +00:00
621957969b chore(deps): update node.js to 2145b76
All checks were successful
container-scan / Container Scan (push) Successful in 2m49s
docker-build / docker (push) Successful in 1m12s
2025-05-15 16:00:37 +00:00
f4a351f6b6 chore(deps): update tailwindcss monorepo to v4.1.7
All checks were successful
container-scan / Container Scan (push) Successful in 2m41s
docker-build / docker (push) Successful in 1m11s
2025-05-15 15:01:38 +00:00
96fb81dd7e chore(deps): update dependency prisma to v6.8.0
All checks were successful
container-scan / Container Scan (push) Successful in 2m23s
docker-build / docker (push) Successful in 1m9s
2025-05-15 14:01:10 +00:00
04ac3dd2e0 chore(deps): update docker/build-push-action digest to 1dc7386
All checks were successful
container-scan / Container Scan (push) Successful in 2m42s
docker-build / docker (push) Successful in 4m9s
2025-05-15 13:00:26 +00:00
32 changed files with 2309 additions and 1385 deletions

View file

@ -1,2 +1,7 @@
.next
node_modules
prisma/*.db*
data
README.md
*.env*
.yarn

View file

@ -1,4 +1,4 @@
DATABASE_URL=
DATABASE_URL="file:./dev.db"
AUTH_SECRET= # Added by `npx auth`. Read more: https://cli.authjs.dev

6
.env.test Normal file
View file

@ -0,0 +1,6 @@
AUTH_SECRET="auth_secret"
AUTH_URL="http://127.0.0.1:3000"
HOSTNAME="127.0.0.1"
DATABASE_URL="file:./dev.db"
AUTH_AUTHENTIK_ID="id"
AUTH_AUTHENTIK_ISSUER="issuer"

View file

@ -9,7 +9,7 @@ jobs:
name: Container Scan
runs-on: docker
container:
image: ghcr.io/di0ik/forgejo_runner_container:main@sha256:672aee9a5dfc35531db3a218ad9486eb5c5d7d9ac10bdcba13110470c10403ee
image: ghcr.io/di0ik/forgejo_runner_container:main@sha256:c66a37d9af18f8f0f34d16890082bc08d842d52ff2a2bc36d993e3d347b498ac
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
@ -32,6 +32,7 @@ jobs:
path: trivy-report.json
- name: Clean up Docker
if: always()
run: |
docker buildx prune --filter=until=48h -f
docker image rm meetup_trivy
docker system prune -af
docker volume prune -f

View file

@ -13,7 +13,7 @@ jobs:
docker:
runs-on: docker
container:
image: ghcr.io/di0ik/forgejo_runner_container:main@sha256:672aee9a5dfc35531db3a218ad9486eb5c5d7d9ac10bdcba13110470c10403ee
image: ghcr.io/di0ik/forgejo_runner_container:main@sha256:c66a37d9af18f8f0f34d16890082bc08d842d52ff2a2bc36d993e3d347b498ac
steps:
- name: Login to Docker Hub
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3
@ -40,7 +40,7 @@ jobs:
echo "REPO=$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]')" >>${GITHUB_ENV}
- name: Build and push (pull_request)
uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6
uses: docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0 # v6
if: github.event_name == 'pull_request'
with:
push: true
@ -48,7 +48,7 @@ jobs:
cache-from: type=registry,ref=git.dominikstahl.dev/${{ env.REPO }}:buildcache
- name: Build and push (push_tag)
uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6
uses: docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0 # v6
if: github.event_name == 'push' && github.ref_type == 'tag'
with:
push: true
@ -56,7 +56,7 @@ jobs:
cache-from: type=registry,ref=git.dominikstahl.dev/${{ env.REPO }}:buildcache
- name: Build and push (push_branch)
uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6
uses: docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0 # v6
if: github.event_name == 'push' && github.ref_type == 'branch'
with:
push: true
@ -65,5 +65,7 @@ jobs:
cache-to: type=registry,ref=git.dominikstahl.dev/${{ env.REPO }}:buildcache,mode=max
- name: Clean up Docker
if: always()
run: |
docker buildx prune --filter=until=48h -f
docker system prune -af
docker volume prune -f

34
.github/workflows/tests.yml vendored Normal file
View file

@ -0,0 +1,34 @@
name: tests
on:
push:
branches:
- main
- renovate/*
pull_request:
jobs:
tests:
name: Tests
runs-on: docker
container:
image: cypress/browsers:latest
options: --user 1001
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Enable corepack
run: corepack enable
- name: Cypress run (e2e)
uses: https://github.com/cypress-io/github-action@v6
with:
build: yarn cypress:build
start: yarn cypress:start_server
e2e: true
wait-on: 'http://127.0.0.1:3000'
- name: Cypress run (component)
uses: https://github.com/cypress-io/github-action@v6
with:
component: true
install: false

11
.gitignore vendored
View file

@ -33,6 +33,7 @@ yarn-error.log*
# env files (can opt-in for committing if needed)
.env*
!.env.example
!.env.test
# vercel
.vercel
@ -40,3 +41,13 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
# database
/prisma/*.db*
src/generated/prisma
data
# cypress
cypress/videos
cypress/screenshots
cypress/coverage

View file

@ -1,4 +1,4 @@
FROM node:22-alpine@sha256:ad1aedbcc1b0575074a91ac146d6956476c1f9985994810e4ee02efd932a68fd AS base
FROM node:22-alpine@sha256:152270cd4bd094d216a84cbc3c5eb1791afb05af00b811e2f0f04bdc6c473602 AS base
# ----- Dependencies -----
FROM base AS deps
@ -15,19 +15,24 @@ WORKDIR /app
RUN corepack enable
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN yarn prisma:generate
RUN yarn build
# ----- Runner -----
FROM gcr.io/distroless/nodejs22-debian12:nonroot@sha256:7461370c8473cfcbf5def249423d5e8301b0e6b98cb256b3c8707f0201c2ea4a AS runner
FROM base AS runner
WORKDIR /app
RUN yarn add prisma -D
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/prisma ./prisma
COPY entrypoint.sh ./
LABEL org.opencontainers.image.source="https://git.dominikstahl.dev/DHBW-WE/MeetUp"
LABEL org.opencontainers.image.title="MeetUp"
@ -36,4 +41,4 @@ LABEL org.opencontainers.image.description="A web application for managing meetu
EXPOSE 3000
ENV HOSTNAME="0.0.0.0"
CMD ["server.js"]
CMD ["/bin/ash", "entrypoint.sh"]

16
cypress.config.ts Normal file
View file

@ -0,0 +1,16 @@
import { defineConfig } from 'cypress';
export default defineConfig({
component: {
devServer: {
framework: 'next',
bundler: 'webpack',
},
},
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});

31
cypress/e2e/login.cy.ts Normal file
View file

@ -0,0 +1,31 @@
describe('login', () => {
it('loads', () => {
cy.visit('http://127.0.0.1:3000/');
cy.getBySel('login-header').should('exist');
});
it('shows login form', () => {
cy.visit('http://127.0.0.1:3000/');
cy.getBySel('login-form').should('exist');
cy.getBySel('email-input').should('exist');
cy.getBySel('password-input').should('exist');
cy.getBySel('login-button').should('exist');
});
it('shows sso button', () => {
cy.visit('http://127.0.0.1:3000/');
cy.getBySel('sso-login-button_authentik').should('exist');
});
it('allows login', () => {
cy.visit('http://127.0.0.1:3000/');
cy.getBySel('email-input').type('test@example.com');
cy.getBySel('password-input').type('password');
cy.getBySel('login-button').click();
cy.url().should('include', '/home');
});
});

View file

@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}

View file

@ -0,0 +1,62 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
Cypress.Commands.add('getBySel', (selector, ...args) => {
return cy.get(`[data-cy=${selector}]`, ...args);
});
Cypress.Commands.add('getBySelLike', (selector, ...args) => {
return cy.get(`[data-cy*=${selector}]`, ...args);
});
declare global {
namespace Cypress {
interface Chainable {
getBySel(
selector: string,
...args: any[]
): Chainable<JQuery<HTMLElement>>;
getBySelLike(
selector: string,
...args: any[]
): Chainable<JQuery<HTMLElement>>;
}
}
}
export {};

View file

@ -0,0 +1,14 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<title>Components App</title>
<!-- Used by Next.js to inject CSS. -->
<div id="__next_css__DO_NOT_USE__"></div>
</head>
<body>
<div data-cy-root></div>
</body>
</html>

View file

@ -0,0 +1,38 @@
// ***********************************************************
// This example support/component.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
import '@/app/globals.css';
// Import commands.js using ES2015 syntax:
import './commands';
import { mount } from 'cypress/react';
// Augment the Cypress namespace to include type definitions for
// your custom command.
// Alternatively, can be defined in cypress/support/component.d.ts
// with a <reference path="./component" /> at the top of your spec.
declare global {
namespace Cypress {
interface Chainable {
mount: typeof mount;
}
}
}
Cypress.Commands.add('mount', mount);
// Example use:
// cy.mount(<MyComponent />)

17
cypress/support/e2e.ts Normal file
View file

@ -0,0 +1,17 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands';

10
entrypoint.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
echo "Running start script with user $(whoami) and NODE_ENV $NODE_ENV"
if [ "$NODE_ENV" == "production" ]; then
if [ -d "prisma/migrations" ]; then
echo "Running Prisma migrations"
npx prisma migrate deploy
fi
fi
exec node server.js

View file

@ -11,6 +11,9 @@ const compat = new FlatCompat({
const eslintConfig = [
...compat.extends('next/core-web-vitals', 'next/typescript', 'prettier'),
{
ignores: ['src/generated/**', '.next/**', 'public/**'],
},
];
export default eslintConfig;

View file

@ -5,16 +5,27 @@
"scripts": {
"dev": "next dev --turbopack",
"build": "prettier --check . && next build",
"start": "next start",
"start": "node .next/standalone/server.js",
"lint": "next lint",
"format": "prettier --write ."
"format": "prettier --write .",
"cypress:build": "prettier --check . && NODE_ENV=test next build",
"cypress:start_server": "cp .env.test .next/standalone && cp public .next/standalone/ -r && cp .next/static/ .next/standalone/.next/ -r && NODE_ENV=test HOSTNAME=\"0.0.0.0\" dotenv -e .env.test -- node .next/standalone/server.js",
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"prisma:migrate": "dotenv -e .env.local -- prisma migrate dev",
"prisma:generate": "dotenv -e .env.local -- prisma generate",
"prisma:studio": "dotenv -e .env.local -- prisma studio",
"prisma:db:push": "dotenv -e .env.local -- prisma db push",
"prisma:migrate:reset": "dotenv -e .env.local -- prisma migrate reset"
},
"dependencies": {
"@auth/prisma-adapter": "^2.9.1",
"@fortawesome/fontawesome-svg-core": "^6.7.2",
"@fortawesome/free-brands-svg-icons": "^6.7.2",
"@fortawesome/free-regular-svg-icons": "^6.7.2",
"@fortawesome/free-solid-svg-icons": "^6.7.2",
"@fortawesome/react-fontawesome": "^0.2.2",
"@prisma/client": "^6.8.2",
"@radix-ui/react-dropdown-menu": "^2.1.14",
"@radix-ui/react-hover-card": "^1.1.13",
"@radix-ui/react-label": "^2.1.6",
@ -36,18 +47,20 @@
},
"devDependencies": {
"@eslint/eslintrc": "3.3.1",
"@tailwindcss/postcss": "4.1.6",
"@types/node": "22.15.18",
"@tailwindcss/postcss": "4.1.7",
"@types/node": "22.15.19",
"@types/react": "19.1.4",
"@types/react-dom": "19.1.5",
"eslint": "9.26.0",
"cypress": "14.3.3",
"dotenv-cli": "8.0.0",
"eslint": "9.27.0",
"eslint-config-next": "15.3.2",
"eslint-config-prettier": "10.1.5",
"postcss": "8.5.3",
"prettier": "3.5.3",
"prisma": "6.7.0",
"tailwindcss": "4.1.6",
"tw-animate-css": "1.2.9",
"prisma": "6.8.2",
"tailwindcss": "4.1.7",
"tw-animate-css": "1.3.0",
"typescript": "5.8.3"
},
"packageManager": "yarn@4.9.1"

View file

@ -0,0 +1,298 @@
-- CreateTable
CREATE TABLE "users" (
"id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"first_name" TEXT,
"last_name" TEXT,
"email" TEXT NOT NULL,
"email_verified" DATETIME,
"password_hash" TEXT,
"image" TEXT,
"timezone" TEXT NOT NULL DEFAULT 'UTC',
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" DATETIME NOT NULL
);
-- CreateTable
CREATE TABLE "accounts" (
"id" TEXT NOT NULL PRIMARY KEY,
"user_id" TEXT NOT NULL,
"type" TEXT NOT NULL,
"provider" TEXT NOT NULL,
"provider_account_id" TEXT NOT NULL,
"refresh_token" TEXT,
"access_token" TEXT,
"expires_at" INTEGER,
"token_type" TEXT,
"scope" TEXT,
"id_token" TEXT,
"session_state" TEXT,
CONSTRAINT "accounts_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "sessions" (
"id" TEXT NOT NULL PRIMARY KEY,
"session_token" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"expires" DATETIME NOT NULL,
CONSTRAINT "sessions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "verification_tokens" (
"identifier" TEXT NOT NULL,
"token" TEXT NOT NULL,
"expires" DATETIME NOT NULL
);
-- CreateTable
CREATE TABLE "authenticators" (
"user_id" TEXT NOT NULL,
"credential_id" TEXT NOT NULL,
"provider_account_id" TEXT NOT NULL,
"credential_public_key" TEXT NOT NULL,
"counter" INTEGER NOT NULL,
"credential_device_type" TEXT NOT NULL,
"credential_backed_up" BOOLEAN NOT NULL,
"transports" TEXT,
PRIMARY KEY ("user_id", "credential_id"),
CONSTRAINT "authenticators_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "friendships" (
"user_id_1" TEXT NOT NULL,
"user_id_2" TEXT NOT NULL,
"status" TEXT NOT NULL DEFAULT 'PENDING',
"requested_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"accepted_at" DATETIME,
PRIMARY KEY ("user_id_1", "user_id_2"),
CONSTRAINT "friendships_user_id_1_fkey" FOREIGN KEY ("user_id_1") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "friendships_user_id_2_fkey" FOREIGN KEY ("user_id_2") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "groups" (
"id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"description" TEXT,
"creator_id" TEXT NOT NULL,
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" DATETIME NOT NULL,
CONSTRAINT "groups_creator_id_fkey" FOREIGN KEY ("creator_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "group_members" (
"group_id" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"role" TEXT NOT NULL DEFAULT 'MEMBER',
"added_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY ("group_id", "user_id"),
CONSTRAINT "group_members_group_id_fkey" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "group_members_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "blocked_slots" (
"id" TEXT NOT NULL PRIMARY KEY,
"user_id" TEXT NOT NULL,
"start_time" DATETIME NOT NULL,
"end_time" DATETIME NOT NULL,
"reason" TEXT,
"is_recurring" BOOLEAN NOT NULL DEFAULT false,
"rrule" TEXT,
"recurrence_end_date" DATETIME,
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" DATETIME NOT NULL,
CONSTRAINT "blocked_slots_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "meetings" (
"id" TEXT NOT NULL PRIMARY KEY,
"title" TEXT NOT NULL,
"description" TEXT,
"start_time" DATETIME NOT NULL,
"end_time" DATETIME NOT NULL,
"organizer_id" TEXT NOT NULL,
"location" TEXT,
"status" TEXT NOT NULL DEFAULT 'CONFIRMED',
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" DATETIME NOT NULL,
CONSTRAINT "meetings_organizer_id_fkey" FOREIGN KEY ("organizer_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "meeting_participants" (
"meeting_id" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"status" TEXT NOT NULL DEFAULT 'PENDING',
"added_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY ("meeting_id", "user_id"),
CONSTRAINT "meeting_participants_meeting_id_fkey" FOREIGN KEY ("meeting_id") REFERENCES "meetings" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "meeting_participants_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "notifications" (
"id" TEXT NOT NULL PRIMARY KEY,
"user_id" TEXT NOT NULL,
"type" TEXT NOT NULL,
"related_entity_type" TEXT,
"related_entity_id" TEXT,
"message" TEXT NOT NULL,
"is_read" BOOLEAN NOT NULL DEFAULT false,
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "notifications_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "user_notification_preferences" (
"user_id" TEXT NOT NULL,
"notification_type" TEXT NOT NULL,
"email_enabled" BOOLEAN NOT NULL DEFAULT false,
"updated_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY ("user_id", "notification_type"),
CONSTRAINT "user_notification_preferences_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "email_queue" (
"id" TEXT NOT NULL PRIMARY KEY,
"user_id" TEXT NOT NULL,
"subject" TEXT NOT NULL,
"body_html" TEXT NOT NULL,
"body_text" TEXT,
"status" TEXT NOT NULL DEFAULT 'PENDING',
"scheduled_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"attempts" INTEGER NOT NULL DEFAULT 0,
"last_attempt_at" DATETIME,
"sent_at" DATETIME,
"error_message" TEXT,
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" DATETIME NOT NULL,
CONSTRAINT "email_queue_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "calendar_export_tokens" (
"id" TEXT NOT NULL PRIMARY KEY,
"user_id" TEXT NOT NULL,
"token" TEXT NOT NULL,
"scope" TEXT NOT NULL DEFAULT 'MEETINGS_ONLY',
"is_active" BOOLEAN NOT NULL DEFAULT true,
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"last_accessed_at" DATETIME,
CONSTRAINT "calendar_export_tokens_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "calendar_subscriptions" (
"id" TEXT NOT NULL PRIMARY KEY,
"user_id" TEXT NOT NULL,
"feed_url" TEXT NOT NULL,
"name" TEXT,
"color" TEXT,
"is_enabled" BOOLEAN NOT NULL DEFAULT true,
"last_synced_at" DATETIME,
"last_sync_error" TEXT,
"sync_frequency_minutes" INTEGER DEFAULT 60,
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" DATETIME NOT NULL,
CONSTRAINT "calendar_subscriptions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "external_events" (
"id" TEXT NOT NULL PRIMARY KEY,
"subscription_id" TEXT NOT NULL,
"ical_uid" TEXT NOT NULL,
"summary" TEXT,
"description" TEXT,
"start_time" DATETIME NOT NULL,
"end_time" DATETIME NOT NULL,
"is_all_day" BOOLEAN NOT NULL DEFAULT false,
"location" TEXT,
"rrule" TEXT,
"dtstamp" DATETIME,
"sequence" INTEGER,
"show_as_free" BOOLEAN NOT NULL DEFAULT false,
"last_fetched_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "external_events_subscription_id_fkey" FOREIGN KEY ("subscription_id") REFERENCES "calendar_subscriptions" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateIndex
CREATE UNIQUE INDEX "users_name_key" ON "users"("name");
-- CreateIndex
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");
-- CreateIndex
CREATE UNIQUE INDEX "accounts_provider_provider_account_id_key" ON "accounts"("provider", "provider_account_id");
-- CreateIndex
CREATE UNIQUE INDEX "sessions_session_token_key" ON "sessions"("session_token");
-- CreateIndex
CREATE UNIQUE INDEX "verification_tokens_identifier_token_key" ON "verification_tokens"("identifier", "token");
-- CreateIndex
CREATE INDEX "idx_friendships_user2_status" ON "friendships"("user_id_2", "status");
-- CreateIndex
CREATE INDEX "groups_creator_id_idx" ON "groups"("creator_id");
-- CreateIndex
CREATE INDEX "group_members_user_id_idx" ON "group_members"("user_id");
-- CreateIndex
CREATE INDEX "blocked_slots_user_id_start_time_end_time_idx" ON "blocked_slots"("user_id", "start_time", "end_time");
-- CreateIndex
CREATE INDEX "blocked_slots_user_id_is_recurring_idx" ON "blocked_slots"("user_id", "is_recurring");
-- CreateIndex
CREATE INDEX "meetings_start_time_end_time_idx" ON "meetings"("start_time", "end_time");
-- CreateIndex
CREATE INDEX "meetings_organizer_id_idx" ON "meetings"("organizer_id");
-- CreateIndex
CREATE INDEX "meetings_status_idx" ON "meetings"("status");
-- CreateIndex
CREATE INDEX "idx_participants_user_status" ON "meeting_participants"("user_id", "status");
-- CreateIndex
CREATE INDEX "idx_notifications_user_read_time" ON "notifications"("user_id", "is_read", "created_at");
-- CreateIndex
CREATE INDEX "idx_email_queue_pending_jobs" ON "email_queue"("status", "scheduled_at");
-- CreateIndex
CREATE INDEX "idx_email_queue_user_history" ON "email_queue"("user_id", "created_at");
-- CreateIndex
CREATE UNIQUE INDEX "calendar_export_tokens_token_key" ON "calendar_export_tokens"("token");
-- CreateIndex
CREATE INDEX "calendar_export_tokens_user_id_idx" ON "calendar_export_tokens"("user_id");
-- CreateIndex
CREATE INDEX "calendar_subscriptions_user_id_is_enabled_idx" ON "calendar_subscriptions"("user_id", "is_enabled");
-- CreateIndex
CREATE INDEX "external_events_subscription_id_start_time_end_time_idx" ON "external_events"("subscription_id", "start_time", "end_time");
-- CreateIndex
CREATE INDEX "external_events_subscription_id_show_as_free_idx" ON "external_events"("subscription_id", "show_as_free");
-- CreateIndex
CREATE UNIQUE INDEX "external_events_subscription_id_ical_uid_key" ON "external_events"("subscription_id", "ical_uid");

View file

@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (e.g., Git)
provider = "sqlite"

View file

@ -6,10 +6,354 @@
generator client {
provider = "prisma-client-js"
output = "../generated/prisma"
output = "../src/generated/prisma"
}
datasource db {
provider = "postgresql"
provider = "sqlite"
url = env("DATABASE_URL")
}
enum participant_status {
PENDING
ACCEPTED
DECLINED
TENTATIVE
}
enum meeting_status {
TENTATIVE
CONFIRMED
CANCELLED
}
enum friendship_status {
PENDING
ACCEPTED
DECLINED
BLOCKED
}
enum notification_type {
FRIEND_REQUEST
FRIEND_ACCEPT
MEETING_INVITE
MEETING_UPDATE
MEETING_CANCEL
MEETING_REMINDER
GROUP_MEMBER_ADDED
CALENDAR_SYNC_ERROR
}
enum group_member_role {
ADMIN
MEMBER
}
enum calendar_export_scope {
MEETINGS_ONLY
MEETINGS_AND_BLOCKED
BLOCKED_ONLY
}
enum email_queue_status {
PENDING
PROCESSING
SENT
FAILED
CANCELLED
}
model User {
id String @id @default(cuid())
name String @unique
first_name String?
last_name String?
email String @unique
emailVerified DateTime? @map("email_verified")
password_hash String?
image String?
timezone String @default("UTC")
created_at DateTime @default(now())
updated_at DateTime @updatedAt
accounts Account[]
sessions Session[]
authenticators Authenticator[]
friendships1 Friendship[] @relation("FriendshipUser1")
friendships2 Friendship[] @relation("FriendshipUser2")
groupsCreated Group[] @relation("GroupCreator")
groupMembers GroupMember[]
blockedSlots BlockedSlot[]
meetingsOrg Meeting[] @relation("MeetingOrganizer")
meetingParts MeetingParticipant[]
notifications Notification[]
notifPrefs UserNotificationPreference[]
emailQueue EmailQueue[]
calendarTokens CalendarExportToken[]
subscriptions CalendarSubscription[]
@@map("users")
}
model Account {
id String @id @default(cuid())
userId String @map("user_id")
type String
provider String
providerAccountId String @map("provider_account_id")
refresh_token String?
access_token String?
expires_at Int?
token_type String?
scope String?
id_token String?
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
@@map("accounts")
}
model Session {
id String @id @default(cuid())
sessionToken String @unique @map("session_token")
userId String @map("user_id")
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@map("sessions")
}
model VerificationToken {
identifier String
token String
expires DateTime
@@unique([identifier, token])
@@map("verification_tokens")
}
model Authenticator {
user_id String
credential_id String
provider_account_id String
credential_public_key String
counter Int
credential_device_type String
credential_backed_up Boolean
transports String?
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
@@id([user_id, credential_id])
@@map("authenticators")
}
model Friendship {
user_id_1 String
user_id_2 String
status friendship_status @default(PENDING)
requested_at DateTime @default(now())
accepted_at DateTime?
user1 User @relation("FriendshipUser1", fields: [user_id_1], references: [id])
user2 User @relation("FriendshipUser2", fields: [user_id_2], references: [id])
@@id([user_id_1, user_id_2])
@@index([user_id_2, status], name: "idx_friendships_user2_status")
@@map("friendships")
}
model Group {
id String @id @default(cuid())
name String
description String?
creator_id String
created_at DateTime @default(now())
updated_at DateTime @updatedAt
creator User @relation("GroupCreator", fields: [creator_id], references: [id])
members GroupMember[]
@@index([creator_id])
@@map("groups")
}
model GroupMember {
group_id String
user_id String
role group_member_role @default(MEMBER)
added_at DateTime @default(now())
group Group @relation(fields: [group_id], references: [id])
user User @relation(fields: [user_id], references: [id])
@@id([group_id, user_id])
@@index([user_id])
@@map("group_members")
}
model BlockedSlot {
id String @id @default(cuid())
user_id String
start_time DateTime
end_time DateTime
reason String?
is_recurring Boolean @default(false)
rrule String?
recurrence_end_date DateTime?
created_at DateTime @default(now())
updated_at DateTime @updatedAt
user User @relation(fields: [user_id], references: [id])
@@index([user_id, start_time, end_time])
@@index([user_id, is_recurring])
@@map("blocked_slots")
}
model Meeting {
id String @id @default(cuid())
title String
description String?
start_time DateTime
end_time DateTime
organizer_id String
location String?
status meeting_status @default(CONFIRMED)
created_at DateTime @default(now())
updated_at DateTime @updatedAt
organizer User @relation("MeetingOrganizer", fields: [organizer_id], references: [id])
participants MeetingParticipant[]
@@index([start_time, end_time])
@@index([organizer_id])
@@index([status])
@@map("meetings")
}
model MeetingParticipant {
meeting_id String
user_id String
status participant_status @default(PENDING)
added_at DateTime @default(now())
meeting Meeting @relation(fields: [meeting_id], references: [id])
user User @relation(fields: [user_id], references: [id])
@@id([meeting_id, user_id])
@@index([user_id, status], name: "idx_participants_user_status")
@@map("meeting_participants")
}
model Notification {
id String @id @default(cuid())
user_id String
type notification_type
related_entity_type String?
related_entity_id String?
message String
is_read Boolean @default(false)
created_at DateTime @default(now())
user User @relation(fields: [user_id], references: [id])
@@index([user_id, is_read, created_at], name: "idx_notifications_user_read_time")
@@map("notifications")
}
model UserNotificationPreference {
user_id String
notification_type notification_type
email_enabled Boolean @default(false)
updated_at DateTime @default(now())
user User @relation(fields: [user_id], references: [id])
@@id([user_id, notification_type])
@@map("user_notification_preferences")
}
model EmailQueue {
id String @id @default(cuid())
user_id String
subject String
body_html String
body_text String?
status email_queue_status @default(PENDING)
scheduled_at DateTime @default(now())
attempts Int @default(0)
last_attempt_at DateTime?
sent_at DateTime?
error_message String?
created_at DateTime @default(now())
updated_at DateTime @updatedAt
user User @relation(fields: [user_id], references: [id])
@@index([status, scheduled_at], name: "idx_email_queue_pending_jobs")
@@index([user_id, created_at], name: "idx_email_queue_user_history")
@@map("email_queue")
}
model CalendarExportToken {
id String @id @default(cuid())
user_id String
token String @unique
scope calendar_export_scope @default(MEETINGS_ONLY)
is_active Boolean @default(true)
created_at DateTime @default(now())
last_accessed_at DateTime?
user User @relation(fields: [user_id], references: [id])
@@index([user_id])
@@map("calendar_export_tokens")
}
model CalendarSubscription {
id String @id @default(cuid())
user_id String
feed_url String
name String?
color String?
is_enabled Boolean @default(true)
last_synced_at DateTime?
last_sync_error String?
sync_frequency_minutes Int? @default(60)
created_at DateTime @default(now())
updated_at DateTime @updatedAt
user User @relation(fields: [user_id], references: [id])
externalEvents ExternalEvent[]
@@index([user_id, is_enabled])
@@map("calendar_subscriptions")
}
model ExternalEvent {
id String @id @default(cuid())
subscription_id String
ical_uid String
summary String?
description String?
start_time DateTime
end_time DateTime
is_all_day Boolean @default(false)
location String?
rrule String?
dtstamp DateTime?
sequence Int?
show_as_free Boolean @default(false)
last_fetched_at DateTime @default(now())
subscription CalendarSubscription @relation(fields: [subscription_id], references: [id])
@@unique([subscription_id, ical_uid], name: "uq_external_event_sub_uid")
@@index([subscription_id, start_time, end_time])
@@index([subscription_id, show_as_free])
@@map("external_events")
}

View file

@ -30,7 +30,9 @@ export default async function LoginPage() {
<div>
<Card className='w-[350px] max-w-screen'>
<CardHeader>
<CardTitle className='text-lg text-center'>Login</CardTitle>
<CardTitle className='text-lg text-center' data-cy='login-header'>
Login
</CardTitle>
</CardHeader>
<CardContent className='gap-6 flex flex-col'>
<LoginForm />
@ -42,6 +44,7 @@ export default async function LoginPage() {
key={provider.id}
provider={provider.id}
providerDisplayName={provider.name}
data-cy={'sso-login-button_' + provider.name.toLowerCase()}
/>
))}
</CardContent>

View file

@ -5,6 +5,9 @@ import Credentials from 'next-auth/providers/credentials';
import Authentik from 'next-auth/providers/authentik';
import { PrismaAdapter } from '@auth/prisma-adapter';
import { prisma } from '@/prisma';
const providers: Provider[] = [
!process.env.DISABLE_PASSWORD_LOGIN &&
Credentials({
@ -34,6 +37,7 @@ export const providerMap = providers
export const { handlers, signIn, signOut, auth } = NextAuth({
providers,
adapter: PrismaAdapter(prisma),
session: {
strategy: 'jwt',
},

View file

@ -0,0 +1,24 @@
/* eslint-disable @typescript-eslint/no-unused-expressions */
import React from 'react';
import { IconButton } from './icon-button';
import { faOpenid } from '@fortawesome/free-brands-svg-icons';
describe('<IconButton />', () => {
it('renders', () => {
cy.mount(<IconButton icon={faOpenid}>Button</IconButton>);
});
it('is clickable', () => {
const onClick = cy.stub();
cy.mount(
<IconButton icon={faOpenid} onClick={onClick} data-cy='icon-button'>
Button
</IconButton>,
);
cy.getBySel('icon-button')
.click()
.then(() => {
expect(onClick).to.be.calledOnce;
});
});
});

View file

@ -7,13 +7,14 @@ export default function LabeledInput({
placeholder,
value,
name,
...props
}: {
type: 'text' | 'email' | 'password';
label: string;
placeholder?: string;
name: string;
value?: string;
name?: string;
}) {
} & React.InputHTMLAttributes<HTMLInputElement>) {
return (
<div className='flex flex-col gap-1'>
<Label htmlFor={name}>{label}</Label>
@ -24,6 +25,7 @@ export default function LabeledInput({
defaultValue={value}
id={name}
name={name}
{...props}
/>
</div>
);

View file

@ -10,6 +10,7 @@ export default function LoginForm() {
return (
<form
className='flex flex-col gap-5 w-full'
data-cy='login-form'
action={async (formData) => {
'use server';
try {
@ -27,17 +28,20 @@ export default function LoginForm() {
label='E-Mail or Username'
placeholder='What you are known as.'
name='email'
data-cy='email-input'
/>
<LabeledInput
type='password'
label='Password'
placeholder="Let's hope you remember it."
name='password'
data-cy='password-input'
/>
<Button
className='hover:bg-blue-600 hover:text-white'
type='submit'
variant='secondary'
data-cy='login-button'
>
Login
</Button>

View file

@ -5,10 +5,11 @@ import { faOpenid } from '@fortawesome/free-brands-svg-icons';
export default function SSOLogin({
provider,
providerDisplayName,
...props
}: {
provider: string;
providerDisplayName: string;
}) {
} & React.HTMLProps<HTMLFormElement>) {
return (
<form
className='flex flex-col items-center gap-4 w-full'
@ -16,6 +17,7 @@ export default function SSOLogin({
'use server';
await signIn(provider);
}}
{...props}
>
<IconButton
className='w-full'

View file

@ -0,0 +1,41 @@
import React from 'react';
import { ThemePicker } from '@/components/user/theme-picker';
import { ThemeProvider } from '../theme-provider';
describe('<ThemePicker />', () => {
it('renders', () => {
cy.mount(<ThemePicker />);
});
it('toggle open and close', () => {
cy.mount(<ThemePicker />);
cy.getBySel('theme-picker').click();
cy.getBySel('theme-picker-content').should('exist');
cy.get('html').click();
cy.getBySel('theme-picker-content').should('not.exist');
});
it('enable dark mode', () => {
cy.mount(
<ThemeProvider>
<ThemePicker />
</ThemeProvider>,
);
cy.getBySel('theme-picker').click();
cy.getBySel('dark-theme').click();
cy.get('html').should('have.attr', 'data-theme', 'dark');
});
it('enable light mode', () => {
cy.mount(
<ThemeProvider>
<ThemePicker />
</ThemeProvider>,
);
cy.getBySel('theme-picker').click();
cy.getBySel('light-theme').click();
cy.get('html').should('have.attr', 'data-theme', 'light');
});
});

View file

@ -18,20 +18,26 @@ export function ThemePicker() {
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant='outline' size='icon'>
<Button variant='outline' size='icon' data-cy='theme-picker'>
<Sun className='h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0' />
<Moon className='absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100' />
<span className='sr-only'>Toggle theme</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align='end'>
<DropdownMenuItem onClick={() => setTheme('light')}>
<DropdownMenuContent align='end' data-cy='theme-picker-content'>
<DropdownMenuItem
onClick={() => setTheme('light')}
data-cy='light-theme'
>
Light
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setTheme('dark')}>
<DropdownMenuItem onClick={() => setTheme('dark')} data-cy='dark-theme'>
Dark
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setTheme('system')}>
<DropdownMenuItem
onClick={() => setTheme('system')}
data-cy='system-theme'
>
System
</DropdownMenuItem>
</DropdownMenuContent>

7
src/prisma.ts Normal file
View file

@ -0,0 +1,7 @@
import { PrismaClient } from '@/generated/prisma';
const globalForPrisma = globalThis as unknown as { prisma: PrismaClient };
export const prisma = globalForPrisma.prisma || new PrismaClient();
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;

View file

@ -20,7 +20,8 @@
],
"paths": {
"@/*": ["./src/*"]
}
},
"types": ["node", "cypress"]
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]

2614
yarn.lock

File diff suppressed because it is too large Load diff