Skip to content

Commit 52842b2

Browse files
ledouxmledouxm
andauthored
feat: add e2e tests (#66)
* wip: start full test env before tests * wip * fix: use playwright webserser * fix: optimize realm-template.json * fix: before merge --------- Co-authored-by: ledouxm <mledoux@mledoux.fr>
1 parent d07710a commit 52842b2

32 files changed

Lines changed: 701 additions & 249 deletions

.env.test

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
FRONTEND_PORT=3010
2+
BACKEND_PORT=3011
3+
POWERSYNC_PORT=3012
4+
KEYCLOAK_PORT=3013
5+
DB_PORT=3014
6+
MINIO_SERVER_PORT=3015
7+
MINIO_CONSOLE_PORT=3016
8+
MAILPIT_PORT=3017
9+
MAILPIT_WEB_PORT=3018
10+
HEALTHCHECK_PORT=3019
11+
12+
JWT_SECRET=9999999999999999999999999999999999999999999999999999999999999999
13+
JWT_REFRESH_SECRET=0000000000000000000000000000000000000000000000000000000000000000
14+
15+
# DB
16+
POSTGRES_PORT=${DB_PORT}
17+
POSTGRES_HOST=localhost
18+
POSTGRES_USER=postgres
19+
POSTGRES_PASSWORD=password
20+
POSTGRES_DB=patrinotes-test
21+
DATABASE_REQUIRE_SSL=false
22+
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:${POSTGRES_PORT}/${POSTGRES_DB}
23+
24+
# S3
25+
MINIO_SECRET_KEY=aws-access-key
26+
MINIO_ACCESS_KEY_ID=aws-secret-key
27+
MINIO_BUCKET=patrinotes-test
28+
MINIO_URL=http://localhost:9000
29+
30+
# MINIO
31+
MINIO_USER=admin
32+
MINIO_PASSWORD=password
33+
34+
# POWERSYNC
35+
PS_DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@pg:5432/patrinotes-test
36+
PS_JWT_SECRET=${JWT_SECRET}
37+
38+
# KEYCLOAK
39+
KEYCLOAK_ADMIN=admin
40+
KEYCLOAK_ADMIN_PASSWORD=keycloakpassword
41+
KEYCLOAK_DB=keycloak
42+
43+
AUTH_CLIENT_ID=patrinotes-test
44+
AUTH_CLIENT_SECRET=auth-client-secret-test
45+
AUTH_ADMIN_CLIENT_ID=patrinotes-admin-test
46+
AUTH_ADMIN_CLIENT_SECRET=auth-admin-client-secret-test
47+
48+
DATAGOUV_API=https://data.culture.gouv.fr/api/explore/v2.1/catalog/datasets
49+
50+
# SMTP
51+
SMTP_PORT=${MAILPIT_PORT}
52+
SMTP_WEB_PORT=${MAILPIT_WEB_PORT}
53+
54+
# BACKEND
55+
PORT=${BACKEND_PORT}
56+
57+
FRONTEND_URL=http://localhost:${FRONTEND_PORT}
58+
EMAIL_HOST=mailpit:${SMTP_PORT}
59+
EMAIL_PORT=${SMTP_PORT}
60+
EMAIL_USER=aaaaaaaaaaaaa
61+
EMAIL_PASSWORD=bbbbbbbbbbb
62+
63+
EMAIL_EMITTER=noreply@patrinotes-test.com
64+
65+
66+
# FRONTEND
67+
VITE_BACKEND_URL=http://localhost:${BACKEND_PORT}
68+
VITE_POWERSYNC_URL=http://localhost:${POWERSYNC_PORT}
69+
VITE_AUTH_URL=http://localhost:${KEYCLOAK_PORT}
70+
VITE_AUTH_CLIENT_ID=${AUTH_CLIENT_ID}
71+
VITE_AUTH_REALM=master
72+
VITE_ALERTES_MH_ENABLED=true

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.sh text eol=lf

db/0000_bright_stone_men.sql

Lines changed: 146 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,177 +1,198 @@
1-
21
CREATE TABLE "atdatabases_migrations_version" (
3-
"id" integer PRIMARY KEY NOT NULL,
4-
"version" text
2+
"id" integer PRIMARY KEY NOT NULL,
3+
"version" text
54
);
65
--> statement-breakpoint
76
CREATE TABLE "atdatabases_migrations_applied" (
8-
"id" bigserial PRIMARY KEY NOT NULL,
9-
"index" integer NOT NULL,
10-
"name" text NOT NULL,
11-
"script" text NOT NULL,
12-
"applied_at" timestamp with time zone NOT NULL,
13-
"ignored_error" text,
14-
"obsolete" boolean NOT NULL
7+
"id" bigserial PRIMARY KEY NOT NULL,
8+
"index" integer NOT NULL,
9+
"name" text NOT NULL,
10+
"script" text NOT NULL,
11+
"applied_at" timestamp
12+
with
13+
time zone NOT NULL,
14+
"ignored_error" text,
15+
"obsolete" boolean NOT NULL
1516
);
1617
--> statement-breakpoint
1718
CREATE TABLE "user" (
18-
"id" text PRIMARY KEY NOT NULL,
19-
"name" text NOT NULL,
20-
"udap_id" text NOT NULL
19+
"id" text PRIMARY KEY NOT NULL,
20+
"name" text NOT NULL,
21+
"udap_id" text NOT NULL
2122
);
2223
--> statement-breakpoint
2324
CREATE TABLE "internal_user" (
24-
"id" text PRIMARY KEY NOT NULL,
25-
"email" text NOT NULL,
26-
"role" text NOT NULL,
27-
"password" text NOT NULL,
28-
"temporaryLink" text,
29-
"temporaryLinkExpiresAt" text,
30-
"userId" text NOT NULL
25+
"id" text PRIMARY KEY NOT NULL,
26+
"email" text NOT NULL,
27+
"role" text NOT NULL,
28+
"password" text NOT NULL,
29+
"temporaryLink" text,
30+
"temporaryLinkExpiresAt" text,
31+
"userId" text NOT NULL
3132
);
3233
--> statement-breakpoint
3334
CREATE TABLE "delegation" (
34-
"id" text PRIMARY KEY NOT NULL,
35-
"createdBy" text NOT NULL,
36-
"delegatedTo" text NOT NULL
35+
"id" text PRIMARY KEY NOT NULL,
36+
"createdBy" text NOT NULL,
37+
"delegatedTo" text NOT NULL
3738
);
3839
--> statement-breakpoint
39-
CREATE TABLE "whitelist" (
40-
"email" text PRIMARY KEY NOT NULL
41-
);
40+
CREATE TABLE "whitelist" ( "email" text PRIMARY KEY NOT NULL );
4241
--> statement-breakpoint
4342
CREATE TABLE "service_instructeurs" (
44-
"id" text PRIMARY KEY NOT NULL,
45-
"full_name" text NOT NULL,
46-
"short_name" text NOT NULL,
47-
"email" text,
48-
"tel" text,
49-
"udap_id" text
43+
"id" text PRIMARY KEY NOT NULL,
44+
"full_name" text NOT NULL,
45+
"short_name" text NOT NULL,
46+
"email" text,
47+
"tel" text,
48+
"udap_id" text
5049
);
5150
--> statement-breakpoint
5251
CREATE TABLE "clause_v2" (
53-
"id" text PRIMARY KEY NOT NULL,
54-
"key" text NOT NULL,
55-
"value" text NOT NULL,
56-
"position" integer,
57-
"udap_id" text,
58-
"text" text NOT NULL
52+
"id" text PRIMARY KEY NOT NULL,
53+
"key" text NOT NULL,
54+
"value" text NOT NULL,
55+
"position" integer,
56+
"udap_id" text,
57+
"text" text NOT NULL
5958
);
6059
--> statement-breakpoint
6160
CREATE TABLE "pdf_snapshot" (
62-
"id" text PRIMARY KEY NOT NULL,
63-
"report_id" text,
64-
"html" text,
65-
"report" text,
66-
"user_id" text
61+
"id" text PRIMARY KEY NOT NULL,
62+
"report_id" text,
63+
"html" text,
64+
"report" text,
65+
"user_id" text
6766
);
6867
--> statement-breakpoint
6968
CREATE TABLE "tmp_pictures" (
70-
"id" text PRIMARY KEY NOT NULL,
71-
"reportId" text,
72-
"createdAt" timestamp
69+
"id" text PRIMARY KEY NOT NULL,
70+
"reportId" text,
71+
"createdAt" timestamp
7372
);
7473
--> statement-breakpoint
7574
CREATE TABLE "picture_lines" (
76-
"id" text PRIMARY KEY NOT NULL,
77-
"pictureId" text,
78-
"lines" text NOT NULL,
79-
"createdAt" timestamp
75+
"id" text PRIMARY KEY NOT NULL,
76+
"pictureId" text,
77+
"lines" text NOT NULL,
78+
"createdAt" timestamp
8079
);
8180
--> statement-breakpoint
8281
CREATE TABLE "pictures" (
83-
"id" text PRIMARY KEY NOT NULL,
84-
"reportId" text,
85-
"url" text,
86-
"createdAt" timestamp,
87-
"finalUrl" text
82+
"id" text PRIMARY KEY NOT NULL,
83+
"reportId" text,
84+
"url" text,
85+
"createdAt" timestamp,
86+
"finalUrl" text
8887
);
8988
--> statement-breakpoint
9089
CREATE TABLE "transactions" (
91-
"id" text PRIMARY KEY NOT NULL,
92-
"op_id" integer NOT NULL,
93-
"tx_id" integer,
94-
"entity_id" text NOT NULL,
95-
"type" text NOT NULL,
96-
"op" text NOT NULL,
97-
"data" text,
98-
"user_id" text NOT NULL,
99-
"created_at" timestamp,
100-
"error" text
90+
"id" text PRIMARY KEY NOT NULL,
91+
"op_id" integer NOT NULL,
92+
"tx_id" integer,
93+
"entity_id" text NOT NULL,
94+
"type" text NOT NULL,
95+
"op" text NOT NULL,
96+
"data" text,
97+
"user_id" text NOT NULL,
98+
"created_at" timestamp,
99+
"error" text
101100
);
102101
--> statement-breakpoint
103102
CREATE TABLE "report" (
104-
"id" text PRIMARY KEY NOT NULL,
105-
"title" text,
106-
"projectDescription" text,
107-
"redactedBy" text,
108-
"meetDate" timestamp,
109-
"applicantName" text,
110-
"applicantAddress" text,
111-
"projectCadastralRef" text,
112-
"projectSpaceType" text,
113-
"decision" text,
114-
"precisions" text,
115-
"contacts" text,
116-
"furtherInformation" text,
117-
"createdBy" text NOT NULL,
118-
"createdAt" timestamp NOT NULL,
119-
"serviceInstructeur" text,
120-
"pdf" text,
121-
"disabled" boolean,
122-
"udap_id" text,
123-
"redactedById" text,
124-
"applicantEmail" text,
125-
"city" text,
126-
"zipCode" text
103+
"id" text PRIMARY KEY NOT NULL,
104+
"title" text,
105+
"projectDescription" text,
106+
"redactedBy" text,
107+
"meetDate" timestamp,
108+
"applicantName" text,
109+
"applicantAddress" text,
110+
"projectCadastralRef" text,
111+
"projectSpaceType" text,
112+
"decision" text,
113+
"precisions" text,
114+
"contacts" text,
115+
"furtherInformation" text,
116+
"createdBy" text NOT NULL,
117+
"createdAt" timestamp NOT NULL,
118+
"serviceInstructeur" text,
119+
"pdf" text,
120+
"disabled" boolean,
121+
"udap_id" text,
122+
"redactedById" text,
123+
"applicantEmail" text,
124+
"city" text,
125+
"zipCode" text
127126
);
128127
--> statement-breakpoint
129128
CREATE TABLE "sent_email" (
130-
"id" text PRIMARY KEY NOT NULL,
131-
"report_id" text,
132-
"sent_to" text NOT NULL,
133-
"sent_at" timestamp NOT NULL,
134-
"udap_id" text NOT NULL
129+
"id" text PRIMARY KEY NOT NULL,
130+
"report_id" text,
131+
"sent_to" text NOT NULL,
132+
"sent_at" timestamp NOT NULL,
133+
"udap_id" text NOT NULL
135134
);
136135
--> statement-breakpoint
137136
CREATE TABLE "suggested_email" (
138-
"id" text PRIMARY KEY NOT NULL,
139-
"email" text NOT NULL,
140-
"udap_id" text NOT NULL,
141-
CONSTRAINT "suggested_email_email_key" UNIQUE("email")
137+
"id" text PRIMARY KEY NOT NULL,
138+
"email" text NOT NULL,
139+
"udap_id" text NOT NULL,
140+
CONSTRAINT "suggested_email_email_key" UNIQUE ("email")
142141
);
143142
--> statement-breakpoint
144143
CREATE TABLE "udap" (
145-
"id" text PRIMARY KEY NOT NULL,
146-
"department" text NOT NULL,
147-
"completeCoords" text,
148-
"visible" boolean,
149-
"name" text,
150-
"address" text,
151-
"zipCode" text,
152-
"city" text,
153-
"phone" text,
154-
"email" text,
155-
"marianne_text" text,
156-
"drac_text" text,
157-
"udap_text" text,
158-
"dept_number" text
144+
"id" text PRIMARY KEY NOT NULL,
145+
"department" text NOT NULL,
146+
"completeCoords" text,
147+
"visible" boolean,
148+
"name" text,
149+
"address" text,
150+
"zipCode" text,
151+
"city" text,
152+
"phone" text,
153+
"email" text,
154+
"marianne_text" text,
155+
"drac_text" text,
156+
"udap_text" text,
157+
"dept_number" text
159158
);
160159
--> statement-breakpoint
161160
CREATE TABLE "user_settings" (
162-
"id" text PRIMARY KEY NOT NULL,
163-
"user_id" text,
164-
"default_emails" text,
165-
"udap_id" text
166-
);
167-
--> statement-breakpoint
168-
ALTER TABLE "user" ADD CONSTRAINT "user_udap_id_fkey" FOREIGN KEY ("udap_id") REFERENCES "public"."udap"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
169-
ALTER TABLE "internal_user" ADD CONSTRAINT "internal_user_userId_fkey" FOREIGN KEY ("userId") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
170-
ALTER TABLE "delegation" ADD CONSTRAINT "delegation_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
171-
ALTER TABLE "delegation" ADD CONSTRAINT "delegation_delegatedTo_fkey" FOREIGN KEY ("delegatedTo") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
172-
ALTER TABLE "tmp_pictures" ADD CONSTRAINT "tmp_pictures_reportId_fkey" FOREIGN KEY ("reportId") REFERENCES "public"."report"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
173-
ALTER TABLE "pictures" ADD CONSTRAINT "pictures_reportId_fkey" FOREIGN KEY ("reportId") REFERENCES "public"."report"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
174-
ALTER TABLE "report" ADD CONSTRAINT "report_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
161+
"id" text PRIMARY KEY NOT NULL,
162+
"user_id" text,
163+
"default_emails" text,
164+
"udap_id" text
165+
);
166+
--> statement-breakpoint
167+
ALTER TABLE "user" ADD CONSTRAINT "user_udap_id_fkey" FOREIGN KEY ("udap_id") REFERENCES "public"."udap"("id") ON DELETE set null ON UPDATE no action;
168+
--> statement-breakpoint
169+
ALTER TABLE "internal_user" ADD CONSTRAINT "internal_user_userId_fkey" FOREIGN KEY ("userId") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;
170+
--> statement-breakpoint
171+
ALTER TABLE "delegation" ADD CONSTRAINT "delegation_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;
172+
--> statement-breakpoint
173+
ALTER TABLE "delegation" ADD CONSTRAINT "delegation_delegatedTo_fkey" FOREIGN KEY ("delegatedTo") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;
174+
--> statement-breakpoint
175+
ALTER TABLE "tmp_pictures" ADD CONSTRAINT "tmp_pictures_reportId_fkey" FOREIGN KEY ("reportId") REFERENCES "public"."report"("id") ON DELETE cascade ON UPDATE no action;
176+
--> statement-breakpoint
177+
ALTER TABLE "pictures" ADD CONSTRAINT "pictures_reportId_fkey" FOREIGN KEY ("reportId") REFERENCES "public"."report"("id") ON DELETE cascade ON UPDATE no action;
178+
--> statement-breakpoint
179+
ALTER TABLE "report" ADD CONSTRAINT "report_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;
180+
--> statement-breakpoint
175181
ALTER TABLE "sent_email" ADD CONSTRAINT "sent_email_report_id_fkey" FOREIGN KEY ("report_id") REFERENCES "public"."report"("id") ON DELETE no action ON UPDATE no action;
176182

177-
CREATE PUBLICATION powersync FOR TABLE "user", "delegation", "service_instructeurs", "clause_v2", "pdf_snapshot", "tmp_pictures", "picture_lines", "pictures", "transactions", "report", "sent_email", "suggested_email", "udap", "user_settings";
183+
ALTER PUBLICATION powersync
184+
ADD
185+
TABLE "user",
186+
"delegation",
187+
"service_instructeurs",
188+
"clause_v2",
189+
"pdf_snapshot",
190+
"tmp_pictures",
191+
"picture_lines",
192+
"pictures",
193+
"transactions",
194+
"report",
195+
"sent_email",
196+
"suggested_email",
197+
"udap",
198+
"user_settings";

0 commit comments

Comments
 (0)