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
4 changes: 4 additions & 0 deletions src/modules/auth/stores/auth.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export const useAuthStore = defineStore('auth', {
getters: {
isLoggedIn: (state) => !!state.cookieExpire,
authStatus: (state) => state.status,
// Beta capacity from the public auth config: cap/remaining are null when uncapped; betaCapped is true only when a numeric cap is set.
signupCap: (state) => state.serverConfig?.sign?.cap ?? null,
seatsRemaining: (state) => state.serverConfig?.sign?.remaining ?? null,
betaCapped: (state) => state.serverConfig?.sign?.cap != null,
Comment on lines +66 to +69
},

actions: {
Expand Down
28 changes: 28 additions & 0 deletions src/modules/auth/tests/auth.store.unit.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,31 @@ describe('Auth Store', () => {
});
});
});

describe('auth store — beta seat getters', () => {
beforeEach(() => setActivePinia(createPinia()));

it('uncapped serverConfig → cap null, remaining null, betaCapped false', () => {
const store = useAuthStore();
store.serverConfig = { sign: { in: true, up: false, cap: null, remaining: null } };
expect(store.signupCap).toBeNull();
expect(store.seatsRemaining).toBeNull();
expect(store.betaCapped).toBe(false);
});

it('capped serverConfig → exposes cap + remaining, betaCapped true', () => {
const store = useAuthStore();
store.serverConfig = { sign: { in: true, up: false, cap: 50, remaining: 40 } };
expect(store.signupCap).toBe(50);
expect(store.seatsRemaining).toBe(40);
expect(store.betaCapped).toBe(true);
});

it('missing serverConfig → safe nulls', () => {
const store = useAuthStore();
store.serverConfig = null;
expect(store.signupCap).toBeNull();
expect(store.seatsRemaining).toBeNull();
expect(store.betaCapped).toBe(false);
});
});
Loading