mirror of
https://github.com/jjbrunton/Sauci.git
synced 2026-11-01 18:19:43 +00:00
Merge remote-tracking branch 'origin/master' into task/self-hosted-backend
# Conflicts: # apps/mobile/app/(app)/onboarding.tsx # apps/mobile/src/__tests__/stores/packsStore.test.ts # apps/mobile/src/features/profile/hooks/useProfileSettings.ts # apps/mobile/src/store/packsStore.ts
This commit is contained in:
commit
be20391788
77 files changed
+48548
-671
No files matched your search
@@ -0,0 +1,46 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { CONTENT_STATUS_LABELS } from '@/lib/contentReviewStatus';
|
||||
|
||||
const { update } = vi.hoisted(() => ({ update: vi.fn() }));
|
||||
|
||||
vi.mock('@/hooks/useAuditedSupabase', () => ({
|
||||
auditedSupabase: { update },
|
||||
}));
|
||||
|
||||
import { updateContentReviewStatus } from './contentReviews';
|
||||
|
||||
describe('catalogue review labels', () => {
|
||||
it('uses archive language for reversible removals', () => {
|
||||
expect(CONTENT_STATUS_LABELS).toEqual({
|
||||
unreviewed: 'Needs review',
|
||||
allowed: 'Allowed',
|
||||
archived: 'Archived',
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
update.mockReset();
|
||||
update.mockResolvedValue({ data: null, error: null });
|
||||
});
|
||||
|
||||
it('writes a trimmed, audited review decision', async () => {
|
||||
await updateContentReviewStatus(
|
||||
'question_packs',
|
||||
'pack-1',
|
||||
'archived',
|
||||
' Store compliance review ',
|
||||
);
|
||||
|
||||
expect(update).toHaveBeenCalledWith('question_packs', 'pack-1', {
|
||||
content_status: 'archived',
|
||||
content_review_reason: 'Store compliance review',
|
||||
});
|
||||
});
|
||||
|
||||
it('rejects an empty reason before writing', async () => {
|
||||
await expect(
|
||||
updateContentReviewStatus('questions', 'question-1', 'allowed', ' '),
|
||||
).rejects.toThrow('A review reason is required');
|
||||
expect(update).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { ContentReviewStatus } from '@sauci/shared';
|
||||
import { auditedSupabase } from '@/hooks/useAuditedSupabase';
|
||||
export { CONTENT_STATUS_LABELS } from '@/lib/contentReviewStatus';
|
||||
|
||||
export type ReviewableContentTable =
|
||||
| 'categories'
|
||||
| 'question_packs'
|
||||
| 'questions'
|
||||
| 'dare_packs'
|
||||
| 'dares';
|
||||
|
||||
export async function updateContentReviewStatus(
|
||||
table: ReviewableContentTable,
|
||||
id: string,
|
||||
status: ContentReviewStatus,
|
||||
reason: string,
|
||||
): Promise<void> {
|
||||
const normalizedReason = reason.trim();
|
||||
if (!normalizedReason) {
|
||||
throw new Error('A review reason is required');
|
||||
}
|
||||
|
||||
const { error } = await auditedSupabase.update(table, id, {
|
||||
content_status: status,
|
||||
content_review_reason: normalizedReason,
|
||||
});
|
||||
|
||||
if (error) throw error;
|
||||
}
|
||||
Reference in new issue
Block a user