27 lines
1.2 KiB
TypeScript
27 lines
1.2 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { trpcCall } from '../lib/trpc';
|
|
|
|
// Read-only const checks (docs/region-test-cases.txt §4b semantics).
|
|
async function essentialConsts(regionId: number, boundId?: number) {
|
|
const r = await trpcCall(null, 'common.essentialConsts', boundId == null ? { regionId } : { regionId, boundId });
|
|
if (r.error) throw new Error(`essentialConsts failed: ${r.error.message}`);
|
|
return r.result.data;
|
|
}
|
|
|
|
test('region 1 serves legacy key shape (no r- prefix)', async () => {
|
|
const d = await essentialConsts(1);
|
|
expect(d.cachePathPrefix).toBe('');
|
|
expect(typeof d.freeDeliveryThreshold).toBe('number');
|
|
expect(typeof d.isFlashDeliveryEnabled).toBe('boolean');
|
|
});
|
|
|
|
test('non-1 regions serve typed values with r-<id>/ prefix', async () => {
|
|
const regions = await trpcCall(null, 'common.getRegions', undefined);
|
|
const list = regions.result.data.regions.filter((r: any) => r.id !== 1);
|
|
expect(list.length).toBeGreaterThan(0);
|
|
for (const r of list.slice(0, 3)) {
|
|
const d = await essentialConsts(r.id);
|
|
expect(d.cachePathPrefix).toBe(`r-${r.id}/`);
|
|
expect(typeof d.freeDeliveryThreshold).toBe('number');
|
|
}
|
|
});
|