Skip to content

Commit e5eb697

Browse files
committed
Merge branch 'develop'
2 parents af2dba7 + e9d44ba commit e5eb697

File tree

171 files changed

+6476
-3608
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+6476
-3608
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
node_modules/
2+
.idea/compiler.xml
3+
.idea/vcs.xml
4+
.idea/modules.xml
25

.idea/modules.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

.idea/vcs.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.idea/voxxrin3.iml

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cloud/firestore/firestore.default.rules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ service cloud.firestore {
5656
allow read: if true;
5757
allow write: if false;
5858
}
59+
match /roomsStats-allInOne/self {
60+
allow read: if true;
61+
allow write: if false;
62+
}
5963

6064
match /organizer-space/{secretOrganizerToken} {
6165
allow get: if true;

cloud/firestore/firestore.default.rules.spec.ts

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import {
22
assertFails,
33
assertSucceeds,
4-
initializeTestEnvironment, RulesTestContext,
5-
RulesTestEnvironment,
4+
initializeTestEnvironment,
5+
type RulesTestEnvironment,
66
} from "@firebase/rules-unit-testing"
77
import {initializeApp as initializeAppAsAdmin} from "firebase-admin/app";
88
import {getFirestore as getFirestoreAsAdmin} from "firebase-admin/firestore";
9-
import {User} from '../../shared/user.firestore'
109
import * as fs from "fs";
1110
import { setDoc, doc, collection, getDocs, getDoc, updateDoc, deleteDoc } from "firebase/firestore";
12-
import {ISODatetime} from "../../shared/type-utils";
1311
import {match} from "ts-pattern";
1412

1513

@@ -60,6 +58,7 @@ beforeAll(async () => {
6058
adminFirestore.doc('/events/an-event/event-descriptor/self').set({ title: `A super event` }),
6159
adminFirestore.doc('/events/an-event/talksStats-allInOne/self').set({ "12345": { id: `12345`, totalFavoritesCount: 0 } }),
6260
adminFirestore.doc('/events/an-event/talksStats/12345').set({ id: `12345`, totalFavoritesCount: 0 }),
61+
adminFirestore.doc('/events/an-event/roomsStats-allInOne/self').set({ "12345": { roomId: `12345`, capacityFillingRatio: 0, recordedAt: "2024-03-28T11:58:10Z", persistedAt: "2024-03-28T12:00:00Z" } }),
6362
adminFirestore.doc('/events/an-event/last-updates/self').set({ favorites: '2023-09-01T00:00:00Z' }),
6463
adminFirestore.doc('/events/an-event/talks/1234').set({ id: '1234', title: 'A super talk' }),
6564
adminFirestore.doc('/events/an-event/talks/1234/feedbacks-access/1f0b405a-c3ba-46df-8d02-cce03bc34e5d').set({ }),
@@ -96,6 +95,7 @@ afterAll(async () => {
9695
adminFirestore.doc(`/events/an-event/last-updates/self`).delete(),
9796
adminFirestore.doc(`/events/an-event/talksStats-allInOne/self`).delete(),
9897
adminFirestore.doc(`/events/an-event/talksStats/12345`).delete(),
98+
adminFirestore.doc(`/events/an-event/roomsStats-allInOne/self`).delete(),
9999
adminFirestore.doc(`/events/an-event/event-descriptor/self`).delete(),
100100
adminFirestore.doc(`/events/an-event/days/monday`).delete(),
101101
adminFirestore.doc(`/events/an-event/organizer-space/6c902c52-9c6d-4d54-b6f2-20814d2f8472/daily-ratings/monday`).delete(),
@@ -450,7 +450,7 @@ const COLLECTIONS: CollectionDescriptor[] = [{
450450
}
451451
}, {
452452
name: "/event-family-tokens",
453-
aroundTests: (userContext: UserContext) => ({
453+
aroundTests: (_: UserContext) => ({
454454
beforeEach: [],
455455
afterEach: [],
456456
}),
@@ -473,7 +473,7 @@ const COLLECTIONS: CollectionDescriptor[] = [{
473473
}
474474
}, {
475475
name: "/public-tokens",
476-
aroundTests: (userContext: UserContext) => ({
476+
aroundTests: (_: UserContext) => ({
477477
beforeEach: [],
478478
afterEach: [],
479479
}),
@@ -496,7 +496,7 @@ const COLLECTIONS: CollectionDescriptor[] = [{
496496
}
497497
}, {
498498
name: "/crawlers",
499-
aroundTests: (userContext: UserContext) => ({
499+
aroundTests: (_: UserContext) => ({
500500
beforeEach: [],
501501
afterEach: [],
502502
}),
@@ -519,7 +519,7 @@ const COLLECTIONS: CollectionDescriptor[] = [{
519519
}
520520
}, {
521521
name: "/schema-migrations",
522-
aroundTests: (userContext: UserContext) => ({
522+
aroundTests: (_: UserContext) => ({
523523
beforeEach: [],
524524
afterEach: [],
525525
}),
@@ -542,7 +542,7 @@ const COLLECTIONS: CollectionDescriptor[] = [{
542542
}
543543
}, {
544544
name: "/events",
545-
aroundTests: (userContext: UserContext) => ({
545+
aroundTests: (_: UserContext) => ({
546546
beforeEach: [],
547547
afterEach: [],
548548
}),
@@ -565,7 +565,7 @@ const COLLECTIONS: CollectionDescriptor[] = [{
565565
}
566566
}, {
567567
name: "/events/{eventId}/days",
568-
aroundTests: (userContext: UserContext) => ({
568+
aroundTests: (_: UserContext) => ({
569569
beforeEach: [],
570570
afterEach: [],
571571
}),
@@ -588,7 +588,7 @@ const COLLECTIONS: CollectionDescriptor[] = [{
588588
}
589589
}, {
590590
name: "/events/{eventId}/event-descriptor",
591-
aroundTests: (userContext: UserContext) => ({
591+
aroundTests: (_: UserContext) => ({
592592
beforeEach: [],
593593
afterEach: [],
594594
}),
@@ -611,7 +611,7 @@ const COLLECTIONS: CollectionDescriptor[] = [{
611611
}
612612
}, {
613613
name: "/events/{eventId}/talksStats",
614-
aroundTests: (userContext: UserContext) => ({
614+
aroundTests: (_: UserContext) => ({
615615
beforeEach: [],
616616
afterEach: [],
617617
}),
@@ -634,7 +634,7 @@ const COLLECTIONS: CollectionDescriptor[] = [{
634634
}
635635
}, {
636636
name: "/events/{eventId}/talksStats-allInOne",
637-
aroundTests: (userContext: UserContext) => ({
637+
aroundTests: (_: UserContext) => ({
638638
beforeEach: [],
639639
afterEach: [],
640640
}),
@@ -655,9 +655,32 @@ const COLLECTIONS: CollectionDescriptor[] = [{
655655
await assertFails(deleteDoc(doc(userContext.context().firestore(), '/events/an-event/talksStats-allInOne/self')));
656656
})
657657
}
658+
}, {
659+
name: "/events/{eventId}/roomsStats-allInOne",
660+
aroundTests: (_: UserContext) => ({
661+
beforeEach: [],
662+
afterEach: [],
663+
}),
664+
tests: (userContext: UserContext) => {
665+
it(`As ${userContext.name}, I should be able to LIST events' all-in-one rooms stats`, async () => {
666+
await assertFails(getDocs(collection(userContext.context().firestore(), '/events/an-event/roomsStats-allInOne')));
667+
})
668+
it(`As ${userContext.name}, I should be able to GET events' all-in-one rooms stats`, async () => {
669+
await assertSucceeds(getDoc(doc(userContext.context().firestore(), '/events/an-event/roomsStats-allInOne/self')));
670+
})
671+
it(`As ${userContext.name}, I should not be able to CREATE events' all-in-one rooms stats`, async () => {
672+
await assertFails(setDoc(doc(userContext.context().firestore(), '/events/another-event/roomsStats-allInOne/self'), { "12345": { roomId: `12345`, capacityFillingRatio: 0.5, recordedAt: "2024-03-28T11:58:10Z", persistedAt: "2024-03-28T12:00:00Z" } }));
673+
})
674+
it(`As ${userContext.name}, I should not be able to UPDATE events' all-in-one rooms stats`, async () => {
675+
await assertFails(updateDoc(doc(userContext.context().firestore(), '/events/an-event/roomsStats-allInOne/self'), { "12345": { roomId: `12345`, capacityFillingRatio: 1, recordedAt: "2024-03-28T11:58:10Z", persistedAt: "2024-03-28T12:00:00Z" } }));
676+
})
677+
it(`As ${userContext.name}, I should not be able to DELETE events' all-in-one rooms stats`, async () => {
678+
await assertFails(deleteDoc(doc(userContext.context().firestore(), '/events/an-event/roomsStats-allInOne/self')));
679+
})
680+
}
658681
}, {
659682
name: "/events/{eventId}/organizer-space",
660-
aroundTests: (userContext: UserContext) => ({
683+
aroundTests: (_: UserContext) => ({
661684
beforeEach: [],
662685
afterEach: [],
663686
}),
@@ -680,7 +703,7 @@ const COLLECTIONS: CollectionDescriptor[] = [{
680703
}
681704
}, {
682705
name: "/events/{eventId}/organizer-space/6c902c52-9c6d-4d54-b6f2-20814d2f8472/ratings",
683-
aroundTests: (userContext: UserContext) => ({
706+
aroundTests: (_: UserContext) => ({
684707
beforeEach: [],
685708
afterEach: [],
686709
}),
@@ -703,7 +726,7 @@ const COLLECTIONS: CollectionDescriptor[] = [{
703726
}
704727
}, {
705728
name: "/events/{eventId}/organizer-space/6c902c52-9c6d-4d54-b6f2-20814d2f8472/daily-ratings",
706-
aroundTests: (userContext: UserContext) => ({
729+
aroundTests: (_: UserContext) => ({
707730
beforeEach: [],
708731
afterEach: [],
709732
}),
@@ -726,7 +749,7 @@ const COLLECTIONS: CollectionDescriptor[] = [{
726749
}
727750
}, {
728751
name: "/events/{eventId}/last-updates",
729-
aroundTests: (userContext: UserContext) => ({
752+
aroundTests: (_: UserContext) => ({
730753
beforeEach: [],
731754
afterEach: [],
732755
}),
@@ -749,7 +772,7 @@ const COLLECTIONS: CollectionDescriptor[] = [{
749772
}
750773
}, {
751774
name: "/events/{eventId}/talks",
752-
aroundTests: (userContext: UserContext) => ({
775+
aroundTests: (_: UserContext) => ({
753776
beforeEach: [],
754777
afterEach: [],
755778
}),
@@ -772,7 +795,7 @@ const COLLECTIONS: CollectionDescriptor[] = [{
772795
}
773796
}, {
774797
name: "/events/{eventId}/talks/{talkId}/feedbacks-access",
775-
aroundTests: (userContext: UserContext) => ({
798+
aroundTests: (_: UserContext) => ({
776799
beforeEach: [],
777800
afterEach: [],
778801
}),
@@ -795,7 +818,7 @@ const COLLECTIONS: CollectionDescriptor[] = [{
795818
}
796819
}, {
797820
name: "/events/{eventId}/talks/{talkId}/feedbacks-access/{secretFeedbackViewerToken}/feedbacks",
798-
aroundTests: (userContext: UserContext) => ({
821+
aroundTests: (_: UserContext) => ({
799822
beforeEach: [],
800823
afterEach: [],
801824
}),

0 commit comments

Comments
 (0)