mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-12 23:31:02 +00:00
51af575c9a
A right-click, click or drag on a repeated world copy reported the longitude it has on that copy (274.9 for -85.1). The place was saved there, the geocoder found nothing, and a route to a place on the real world ran across the whole map (#2976). Longitudes are now brought back onto [-180, 180] where the map hands them out (Leaflet and GL), where they are stored (places, booking endpoints, collection places, so REST, MCP, plugin RPC and importers alike) and before reverse geocoding. A migration moves the ones already stored. Leaflet draws a layer at its literal longitude only, so a trip from Los Angeles to Auckland had its pins at opposite ends of the world while the flight ran off the edge to the next copy (#2975). A trip that crosses the antimeridian is now drawn in one longitude frame, seamed in the widest stretch it leaves empty, so pins, routes, flights and every overlay lie on one copy and the map opens across the Pacific. Every other trip has no frame and draws exactly as before. The GL day fit also takes the short way. A new install now starts with Journey and Collections switched on, next to the trip addons (all but Road trip), Atlas, Vacay and the Naver import that already were. Existing installs keep their addons as they are. Closes #2975 Closes #2976
75 lines
2.8 KiB
TypeScript
75 lines
2.8 KiB
TypeScript
/**
|
|
* `Migration20200101046360_a_new_install_starts_with_more_addons_on`: a new
|
|
* install (no account yet) starts with Journey and Collections on; an existing
|
|
* install keeps every addon exactly as it was.
|
|
*/
|
|
import { DEFAULT_ADDONS } from '../../../src/db/seeders/AddonSeeder';
|
|
import { createMigrationOrm, migrateTo, pendingNames, rawExec, rawQuery } from '../../helpers/migration-step';
|
|
import type { MikroORM } from '@mikro-orm/sqlite';
|
|
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
const TARGET = 'Migration20200101046360_a_new_install_starts_with_more_addons_on';
|
|
|
|
interface AddonRow {
|
|
id: string;
|
|
enabled: number;
|
|
}
|
|
|
|
async function ormBeforeTarget(): Promise<MikroORM> {
|
|
const orm = await createMigrationOrm();
|
|
const names = await pendingNames(orm);
|
|
const idx = names.indexOf(TARGET);
|
|
expect(idx).toBeGreaterThan(0);
|
|
await migrateTo(orm, names[idx - 1]);
|
|
return orm;
|
|
}
|
|
|
|
const addons = (orm: MikroORM) => rawQuery<AddonRow>(orm, 'SELECT id, enabled FROM addons ORDER BY id');
|
|
|
|
describe('a new install starts with more addons on', () => {
|
|
it('ADDON-NEW-001: a new install has Journey and Collections switched on and nothing else touched', async () => {
|
|
const orm = await ormBeforeTarget();
|
|
try {
|
|
const before = await addons(orm);
|
|
expect(before).toContainEqual({ id: 'journey', enabled: 0 });
|
|
expect(before).toContainEqual({ id: 'collections', enabled: 0 });
|
|
|
|
await migrateTo(orm, TARGET);
|
|
|
|
expect(await addons(orm)).toEqual(
|
|
before.map((row) => (row.id === 'journey' || row.id === 'collections' ? { ...row, enabled: 1 } : row)),
|
|
);
|
|
} finally {
|
|
await orm.close(true);
|
|
}
|
|
}, 30000);
|
|
|
|
it('ADDON-NEW-002: an existing install keeps every addon as it was', async () => {
|
|
const orm = await ormBeforeTarget();
|
|
try {
|
|
await rawExec(
|
|
orm,
|
|
`INSERT INTO users (id, username, email, password_hash) VALUES (1, 'admin', 'admin@test', 'x')`,
|
|
);
|
|
const before = await addons(orm);
|
|
|
|
await migrateTo(orm, TARGET);
|
|
|
|
expect(await addons(orm)).toEqual(before);
|
|
expect(before).toContainEqual({ id: 'journey', enabled: 0 });
|
|
expect(before).toContainEqual({ id: 'collections', enabled: 0 });
|
|
} finally {
|
|
await orm.close(true);
|
|
}
|
|
}, 30000);
|
|
|
|
it('ADDON-NEW-004: the seeder writes every trip addon but Road trip, Journey, Collections, Atlas, Vacay and Naver on', () => {
|
|
const enabled = (id: string) => DEFAULT_ADDONS.find((addon) => addon.id === id)?.enabled;
|
|
for (const addon of DEFAULT_ADDONS.filter((a) => a.type === 'trip')) {
|
|
expect([addon.id, addon.enabled]).toEqual([addon.id, addon.id === 'roadtrip' ? 0 : 1]);
|
|
}
|
|
for (const id of ['journey', 'collections', 'atlas', 'vacay', 'naver_list_import']) expect(enabled(id)).toBe(1);
|
|
});
|
|
});
|