mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 09:51:13 -05:00
Apply quick wins and pipeline fixes for integration tests: - Remove is_test_data flag from location inserts - Increase test delay from 2.5s to 5s and add delays between suites to curb rate limiting - Replace [object Object] error formatting with formatTestError across 10 test suites (31 edits) and add import - Refactor unit/conversion tests and performance tests to use the approval pipeline - Extend edge function handling by ensuring item_ids are included in idempotency key inserts (edge function fix) - Update auth, data integrity, edgeFunction, moderation, performance, submission, unitConversion, and versioning test files accordingly
65 lines
2.0 KiB
TypeScript
65 lines
2.0 KiB
TypeScript
/**
|
|
* Moderation Queue & Workflow Integration Tests
|
|
*
|
|
* Tests for moderation queue operations, locking, and state management.
|
|
*/
|
|
|
|
import { supabase } from '@/lib/supabaseClient';
|
|
import type { TestSuite, TestResult } from '../testRunner';
|
|
import { formatTestError } from '../formatTestError';
|
|
|
|
export const moderationTestSuite: TestSuite = {
|
|
id: 'moderation',
|
|
name: 'Moderation Queue & Workflow',
|
|
description: 'Tests for moderation queue operations and submission workflows',
|
|
tests: [
|
|
{
|
|
id: 'moderation-001',
|
|
name: 'Moderation Functions Available',
|
|
description: 'Validates moderation database functions are accessible',
|
|
run: async (): Promise<TestResult> => {
|
|
const startTime = Date.now();
|
|
|
|
try {
|
|
const { data: userData } = await supabase.auth.getUser();
|
|
if (!userData.user) throw new Error('No authenticated user');
|
|
|
|
// Test that moderation functions exist and are callable
|
|
const { data: isMod, error: modError } = await supabase
|
|
.rpc('is_moderator', {
|
|
_user_id: userData.user.id
|
|
});
|
|
|
|
if (modError) throw new Error(`is_moderator function failed: ${modError.message}`);
|
|
|
|
const duration = Date.now() - startTime;
|
|
|
|
return {
|
|
id: 'moderation-001',
|
|
name: 'Moderation Functions Available',
|
|
suite: 'Moderation Queue & Workflow',
|
|
status: 'pass',
|
|
duration,
|
|
timestamp: new Date().toISOString(),
|
|
details: {
|
|
isModerator: isMod,
|
|
functionsAccessible: true
|
|
}
|
|
};
|
|
|
|
} catch (error) {
|
|
return {
|
|
id: 'moderation-001',
|
|
name: 'Moderation Functions Available',
|
|
suite: 'Moderation Queue & Workflow',
|
|
status: 'fail',
|
|
duration: Date.now() - startTime,
|
|
error: formatTestError(error),
|
|
timestamp: new Date().toISOString()
|
|
};
|
|
}
|
|
}
|
|
}
|
|
]
|
|
};
|