mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-29 08:00:06 +00:00
place-contrib: settle the second CI round
- The plugin RPC fallback tests build PlacesRpc with its origin bookkeeping. - The e2e guard and contract cases send their requests one after another; the test server reset connections opened all at once. - The job's two cron registrations are tagged @txIndependent: neither writes. - The panel draws its fold head itself instead of importing it from pages/.
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import type { PlaceContribField, PlaceContribState } from '@trek/shared';
|
||||
import { HeartHandshake, Undo2 } from 'lucide-react';
|
||||
import { ChevronRight, HeartHandshake, Undo2 } from 'lucide-react';
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from '../../i18n';
|
||||
import FoldSummary from '../../pages/admin/FoldSummary';
|
||||
import type { TranslationFn } from '../../types';
|
||||
import { getApiErrorMessage } from '../../utils/apiError';
|
||||
import { StatusPill } from '../Settings/settingsKit';
|
||||
@@ -156,11 +155,18 @@ export default function PlaceContribPanel() {
|
||||
|
||||
{(agreed || state.consent.decision === 'off') && (
|
||||
<details className="group overflow-hidden rounded-[12px] border border-edge-faint bg-surface-card">
|
||||
<FoldSummary>
|
||||
{/* The admin page's fold head (pages/admin/FoldSummary), which a component cannot import. */}
|
||||
<summary className="flex cursor-pointer list-none items-center gap-2.5 px-3.5 py-2.5 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[color:var(--text-primary)] [&::-webkit-details-marker]:hidden">
|
||||
<ChevronRight
|
||||
size={15}
|
||||
strokeWidth={2}
|
||||
className="flex-none text-content-faint transition-transform group-open:rotate-90"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span className="font-medium text-content" style={fs(12.5, 'body')}>
|
||||
{t('admin.contribute.log.title')}
|
||||
</span>
|
||||
</FoldSummary>
|
||||
</summary>
|
||||
<div className="flex flex-col gap-3 border-t border-edge-faint p-3">
|
||||
<PlaceContribLog />
|
||||
<button
|
||||
|
||||
@@ -24,6 +24,7 @@ export class PlaceContribJob implements OnApplicationBootstrap {
|
||||
private readonly registrar: CronRegistrarService,
|
||||
) {}
|
||||
|
||||
/** @txIndependent two schedules, each registered on its own; neither touches the database. */
|
||||
onApplicationBootstrap(): void {
|
||||
if (!this.registrar.isEnabled()) return;
|
||||
this.registrar.register('place-contrib-send', SEND_SCHEDULE, () => this.send());
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import { AuditLog } from '../../src/db/entities/AuditLog.entity';
|
||||
import { PlaceContribLog } from '../../src/db/entities/PlaceContribLog.entity';
|
||||
import { servicesConfig } from '../../src/nest/app-config/tokens';
|
||||
import { inOrder } from '../../src/nest/common/in-order';
|
||||
import { TrekExceptionFilter } from '../../src/nest/common/trek-exception.filter';
|
||||
import { ZodValidationPipe } from '../../src/nest/common/zod-validation.pipe';
|
||||
import { PlaceContribModule } from '../../src/nest/place-contrib/place-contrib.module';
|
||||
@@ -91,12 +92,11 @@ describe('the guards', () => {
|
||||
() => request(server).get(`${BASE}/log`),
|
||||
() => request(server).post(`${BASE}/withdraw`).send({ confirm: true }),
|
||||
];
|
||||
await Promise.all(
|
||||
routes.map(async (route) => {
|
||||
expect((await route()).status).toBe(401);
|
||||
expect((await route().set(as(USER))).status).toBe(403);
|
||||
}),
|
||||
);
|
||||
// One after another: the test server resets connections opened all at once.
|
||||
await inOrder(routes, async (route) => {
|
||||
expect((await route()).status).toBe(401);
|
||||
expect((await route().set(as(USER))).status).toBe(403);
|
||||
});
|
||||
expect(fetchMock).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -153,12 +153,10 @@ describe('the state and the decisions', () => {
|
||||
{ action: 'agree', termsVersion: 1, fields: { website: true } },
|
||||
{ action: 'fields', fields: FIELDS, withdraw: 'yes' },
|
||||
];
|
||||
await Promise.all(
|
||||
bodies.map(async (body) => {
|
||||
const res = await request(server).put(`${BASE}/decision`).set(as(ADMIN)).send(body);
|
||||
expect(res.status, JSON.stringify(body)).toBe(400);
|
||||
}),
|
||||
);
|
||||
await inOrder(bodies, async (body) => {
|
||||
const res = await request(server).put(`${BASE}/decision`).set(as(ADMIN)).send(body);
|
||||
expect(res.status, JSON.stringify(body)).toBe(400);
|
||||
});
|
||||
});
|
||||
|
||||
it('PCE2E-014: "Not now" answers when the prompt comes back for this admin', async () => {
|
||||
|
||||
@@ -33,6 +33,9 @@ import type { EntityManager } from '@mikro-orm/core';
|
||||
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
|
||||
/** The origin bookkeeping a place write does after it; these cases never reach it. */
|
||||
const ORIGINS = { record: vi.fn(), recordImported: vi.fn(), valuesBefore: vi.fn(() => null) } as never;
|
||||
|
||||
const req = (method: string, params: Record<string, unknown> = {}): RpcRequest => ({
|
||||
k: 'req',
|
||||
id: 'x',
|
||||
@@ -195,7 +198,7 @@ describe('a service that says no becomes a refusal, not a crash', () => {
|
||||
'p',
|
||||
ALL,
|
||||
makeDeps(),
|
||||
createTestPluginRegistry([new PlacesRpc(places, journey, realtime(), guards)]),
|
||||
createTestPluginRegistry([new PlacesRpc(places, journey, realtime(), guards, ORIGINS)]),
|
||||
);
|
||||
expect(err(await host.dispatch(req('places.delete', { tripId: 1, placeId: 7 }), 42)).message).toBe(
|
||||
'no place 7 on trip 1',
|
||||
@@ -408,7 +411,7 @@ describe('every schema-validated method rejects a payload its schema refuses', (
|
||||
{ get: () => vi.fn(() => ({ id: 1, trip: { id: 1 }, updatedTrip: { id: 1 }, reservation: { id: 1 } })) },
|
||||
) as never;
|
||||
const registry = createTestPluginRegistry([
|
||||
new PlacesRpc(anything, anything, realtime(), guards),
|
||||
new PlacesRpc(anything, anything, realtime(), guards, anything),
|
||||
new DaysRpc(anything, realtime(), guards, anything),
|
||||
new PackingRpc(anything, realtime(), guards),
|
||||
new TripsRpc(anything, anything, anything, anything, realtime(), guards, anything, anything, em),
|
||||
|
||||
Reference in New Issue
Block a user