mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 12:31:26 -05:00
Add remaining approval tests
Expand approvalPipelineTests with 12 tests: park/ride updates, composites, photo galleries, edge cases (locks, invalid refs, banned users), and versioning. Include helpers for photo submissions and direct entity creation, plus photo gallery support and invalid temp-ref handling.
This commit is contained in:
@@ -601,3 +601,96 @@ export async function createRideDirectly(
|
||||
tracker.track('rides', ride.id);
|
||||
return ride.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create test photo gallery submission
|
||||
*/
|
||||
export async function createTestPhotoGallerySubmission(
|
||||
entityId: string,
|
||||
entityType: 'park' | 'ride',
|
||||
photoCount: number,
|
||||
userId: string,
|
||||
tracker: TestDataTracker
|
||||
): Promise<{ submissionId: string; itemId: string }> {
|
||||
// Create content submission first
|
||||
const { data: submission, error: submissionError } = await supabase
|
||||
.from('content_submissions')
|
||||
.insert({
|
||||
user_id: userId,
|
||||
submission_type: 'photo_gallery',
|
||||
status: 'pending',
|
||||
is_test_data: true,
|
||||
})
|
||||
.select()
|
||||
.single();
|
||||
|
||||
if (submissionError || !submission) {
|
||||
throw new Error(`Failed to create content submission: ${submissionError?.message}`);
|
||||
}
|
||||
|
||||
tracker.track('content_submissions', submission.id);
|
||||
|
||||
// Create photo submission
|
||||
const { data: photoSubmission, error: photoSubError } = await supabase
|
||||
.from('photo_submissions')
|
||||
.insert({
|
||||
entity_id: entityId,
|
||||
entity_type: entityType,
|
||||
submission_id: submission.id,
|
||||
is_test_data: true,
|
||||
})
|
||||
.select()
|
||||
.single();
|
||||
|
||||
if (photoSubError || !photoSubmission) {
|
||||
throw new Error(`Failed to create photo submission: ${photoSubError?.message}`);
|
||||
}
|
||||
|
||||
tracker.track('photo_submissions', photoSubmission.id);
|
||||
|
||||
// Create submission item linking to photo submission
|
||||
const { data: item, error: itemError } = await supabase
|
||||
.from('submission_items')
|
||||
.insert({
|
||||
submission_id: submission.id,
|
||||
photo_submission_id: photoSubmission.id,
|
||||
item_type: 'photo_gallery',
|
||||
status: 'pending',
|
||||
is_test_data: true,
|
||||
})
|
||||
.select()
|
||||
.single();
|
||||
|
||||
if (itemError || !item) {
|
||||
throw new Error(`Failed to create submission item: ${itemError?.message}`);
|
||||
}
|
||||
|
||||
tracker.track('submission_items', item.id);
|
||||
|
||||
// Create photo submission items
|
||||
for (let i = 0; i < photoCount; i++) {
|
||||
const { data: photoItem, error: photoItemError } = await supabase
|
||||
.from('photo_submission_items')
|
||||
.insert({
|
||||
photo_submission_id: photoSubmission.id,
|
||||
cloudflare_image_id: `test-image-${Date.now()}-${i}`,
|
||||
cloudflare_image_url: `https://test.com/image-${i}.jpg`,
|
||||
caption: `Test photo ${i + 1}`,
|
||||
order_index: i,
|
||||
is_test_data: true,
|
||||
})
|
||||
.select()
|
||||
.single();
|
||||
|
||||
if (photoItemError || !photoItem) {
|
||||
throw new Error(`Failed to create photo item ${i}: ${photoItemError?.message}`);
|
||||
}
|
||||
|
||||
tracker.track('photo_submission_items', photoItem.id);
|
||||
}
|
||||
|
||||
return {
|
||||
submissionId: submission.id,
|
||||
itemId: item.id,
|
||||
};
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user