mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 18:34:09 +00:00
Merge pull request #3319 from liketrek/codex/trip-tags-desktop-polish
Add custom trip tags and refine the desktop interface
This commit is contained in:
@@ -130,6 +130,7 @@ const UNNUMBERED = [
|
||||
'Migration20200101046620_a_journey_link_can_ask_for_a_password_and_run_out',
|
||||
'Migration20200101046630_a_journey_gathers_comments_and_followers',
|
||||
'Migration20200101046640_bahrain_flights_keep_bahrain_time',
|
||||
'Migration20200101046650_trips_can_carry_custom_tags',
|
||||
];
|
||||
// The last step the positional runner ever had; planLegacyBaseline refuses a
|
||||
// schema_version past it.
|
||||
|
||||
@@ -98,7 +98,9 @@ describe('ReservationsRepository — CL1 (findRaw, existing method reused by cal
|
||||
// test-sql-allow: the legacy statement is the oracle the repository read is held to.
|
||||
const legacy = testDb.prepare('SELECT * FROM trips WHERE id = ?').get(trip.id);
|
||||
|
||||
expect(typed).toEqual(legacy);
|
||||
const { tags_json, ...tripFields } = legacy as Record<string, unknown>;
|
||||
expect(tags_json).toBeNull();
|
||||
expect(typed).toEqual({ ...tripFields, tags: [] });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -13,6 +13,10 @@ import type { EntityData } from '@mikro-orm/core';
|
||||
|
||||
import { afterAll, beforeAll, beforeEach, describe, expect, it } from 'vitest';
|
||||
|
||||
function expectedTrip({ tags_json, ...fields }: Record<string, unknown>) {
|
||||
return { ...fields, tags: typeof tags_json === 'string' ? JSON.parse(tags_json) : [] };
|
||||
}
|
||||
|
||||
const testDb = createSnapshotTestDb();
|
||||
let t: TestOrm;
|
||||
let trips: TripsRepository;
|
||||
@@ -238,7 +242,7 @@ describe('TripsRepository — TripMembersService / TripReadModelService (Plan 3c
|
||||
// test-sql-allow: the legacy statement is the oracle the repository read is held to.
|
||||
const legacyRow = testDb.prepare('SELECT * FROM trips WHERE id = ?').get(trip.id);
|
||||
const row = await trips.findRaw(trip.id);
|
||||
expect(row).toEqual(legacyRow);
|
||||
expect(row).toEqual(expectedTrip(legacyRow as Record<string, unknown>));
|
||||
expect(row?.feed_token).toBe('secret-token');
|
||||
});
|
||||
|
||||
@@ -329,7 +333,7 @@ describe('TripsRepository.findForViewer / listForUser / activeTrip (Plan 3c Task
|
||||
)
|
||||
.get({ userId: owner.id, tripId: trip.id });
|
||||
const row = await trips.findForViewer(trip.id, owner.id);
|
||||
expect(row).toEqual(legacyOwner);
|
||||
expect(row).toEqual(expectedTrip(legacyOwner as Record<string, unknown>));
|
||||
// createTrip's own start_date/end_date span already generates 5 days;
|
||||
// the two explicit createDay calls above add 2 more, for 7 total.
|
||||
expect(row).toMatchObject({
|
||||
@@ -356,7 +360,7 @@ describe('TripsRepository.findForViewer / listForUser / activeTrip (Plan 3c Task
|
||||
)
|
||||
.get({ userId: member.id, tripId: trip.id });
|
||||
const memberRow = await trips.findForViewer(trip.id, member.id);
|
||||
expect(memberRow).toEqual(legacyMember);
|
||||
expect(memberRow).toEqual(expectedTrip(legacyMember as Record<string, unknown>));
|
||||
expect(memberRow).toMatchObject({ is_owner: 0, day_count: 7, place_count: 3, shared_count: 1 });
|
||||
});
|
||||
|
||||
@@ -376,7 +380,7 @@ describe('TripsRepository.findForViewer / listForUser / activeTrip (Plan 3c Task
|
||||
)
|
||||
.get({ userId: owner.id, tripId: trip.id });
|
||||
const row = await trips.findForViewer(trip.id, owner.id);
|
||||
expect(row).toEqual(legacy);
|
||||
expect(row).toEqual(expectedTrip(legacy as Record<string, unknown>));
|
||||
expect(row).toMatchObject({
|
||||
description: null,
|
||||
start_date: null,
|
||||
@@ -429,7 +433,7 @@ describe('TripsRepository.findForViewer / listForUser / activeTrip (Plan 3c Task
|
||||
)
|
||||
.all({ userId: owner.id });
|
||||
const rows = await trips.listForUser(owner.id, null);
|
||||
expect(rows).toEqual(legacy);
|
||||
expect(rows).toEqual(legacy.map((row) => expectedTrip(row as Record<string, unknown>)));
|
||||
expect(rows.map((r) => r.id).sort()).toEqual([owned.id, shared.id, archived.id].sort());
|
||||
});
|
||||
|
||||
@@ -450,7 +454,9 @@ describe('TripsRepository.findForViewer / listForUser / activeTrip (Plan 3c Task
|
||||
`,
|
||||
)
|
||||
.all({ userId: owner.id, archived: 1 });
|
||||
expect(await trips.listForUser(owner.id, 1)).toEqual(legacyArchived);
|
||||
expect(await trips.listForUser(owner.id, 1)).toEqual(
|
||||
legacyArchived.map((row) => expectedTrip(row as Record<string, unknown>)),
|
||||
);
|
||||
expect((await trips.listForUser(owner.id, 1)).map((r) => r.id)).toEqual([archived.id]);
|
||||
expect((await trips.listForUser(owner.id, 0)).map((r) => r.id)).toEqual([active.id]);
|
||||
});
|
||||
@@ -1082,7 +1088,7 @@ describe('TripsRepository.listOwnedOrMember — AT1 parity with the legacy state
|
||||
const legacy = testDb.prepare(LEGACY_OWNED_OR_MEMBER).all(caller.id, caller.id, caller.id);
|
||||
const rows = await trips.listOwnedOrMember(caller.id);
|
||||
|
||||
expect(rows).toEqual(legacy);
|
||||
expect(rows).toEqual(legacy.map((row) => expectedTrip(row as Record<string, unknown>)));
|
||||
expect(rows.map((r) => r.id)).toEqual([memberOf.id, owned.id]);
|
||||
});
|
||||
|
||||
|
||||
@@ -298,6 +298,26 @@ describe('Tool: update_trip', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('updates dashboard tags by name while preserving unrelated tags', async () => {
|
||||
const { user } = await makeUser(orm);
|
||||
const trip = await makeTrip(orm, user.id, { title: 'Weekend' });
|
||||
await withHarness(user.id, async (h) => {
|
||||
await h.client.callTool({ name: 'update_trip', arguments: { tripId: trip.id, tags: ['Work', 'Family'] } });
|
||||
const result = await h.client.callTool({
|
||||
name: 'update_trip',
|
||||
arguments: { tripId: trip.id, remove_tags: ['work'], add_tags: [' FAMILY ', 'City break'] },
|
||||
});
|
||||
expect(parseToolResult(result)).toMatchObject({ trip: { title: 'Weekend', tags: ['Family', 'City break'] } });
|
||||
expect(broadcastMock).toHaveBeenCalledWith(
|
||||
trip.id,
|
||||
'trip:updated',
|
||||
expect.objectContaining({
|
||||
trip: expect.objectContaining({ tags: ['Family', 'City break'] }),
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('broadcasts trip:updated event', async () => {
|
||||
const { user } = await makeUser(orm);
|
||||
const trip = await makeTrip(orm, user.id);
|
||||
|
||||
@@ -66,8 +66,8 @@ describe('the contract table', () => {
|
||||
expect(fields).toEqual([...contract.columns, ...contract.derived]);
|
||||
});
|
||||
|
||||
it('OUTCONTRACT-UNIT-004 a trip withholds its feed token and a user exposes four fields', () => {
|
||||
expect(contractOf('trip').withheld).toEqual(['feed_token']);
|
||||
it('OUTCONTRACT-UNIT-004 a trip withholds its feed token and stored tag data', () => {
|
||||
expect(contractOf('trip').withheld).toEqual(['feed_token', 'tags_json']);
|
||||
expect(pluginEntityFields('user')).toEqual(['id', 'username', 'display_name', 'avatar']);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user