test(workbench): verify exported package contract

This commit is contained in:
que01 committed 2026-09-02 17:52:54 +08:00
1 parent fcb07b8396
commit 58f59c8a45
1 file changed
+20
+20
View File
@@ -1,4 +1,6 @@
import fs from 'node:fs';
import { expect, test } from '@playwright/test'; import { expect, test } from '@playwright/test';
import { strFromU8, unzipSync } from 'fflate';
test.describe('workbench editing shell', () => { test.describe('workbench editing shell', () => {
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
@@ -74,6 +76,24 @@ test.describe('workbench editing shell', () => {
await expect(page.getByText('已保存并重新生成')).toBeVisible({ timeout: 30_000 }); await expect(page.getByText('已保存并重新生成')).toBeVisible({ timeout: 30_000 });
}); });
test('exports a package that satisfies the native-road contract', async ({ page }) => {
const downloadPromise = page.waitForEvent('download');
await page.getByRole('link', { name: '导出道路包' }).click();
const download = await downloadPromise;
expect(download.suggestedFilename()).toBe('e2e-fengshu-er-road.native-road.zip');
const archivePath = await download.path();
expect(archivePath).toBeTruthy();
const entries = unzipSync(fs.readFileSync(archivePath!));
const names = Object.keys(entries);
const manifest = JSON.parse(strFromU8(entries['manifest.json']));
expect(manifest).toMatchObject({ areaId: 'e2e-fengshu-er-road', contract: 'native-road-package/v1.1' });
expect(names).toContain('compiled.json');
expect(names).toContain('traffic-signal-assemblies.json');
expect(names).toContain('traffic-signals.json');
expect(names.some((name) => name.includes('override') || name.endsWith('.osm'))).toBe(false);
expect(JSON.parse(strFromU8(entries['compiled.json']))).not.toHaveProperty('source');
});
test('exposes the edit-only history controls without changing browse controls', async ({ page }) => { test('exposes the edit-only history controls without changing browse controls', async ({ page }) => {
await expect(page.getByRole('button', { name: '撤销' })).toHaveCount(0); await expect(page.getByRole('button', { name: '撤销' })).toHaveCount(0);
await page.getByRole('switch', { name: '编辑模式' }).check(); await page.getByRole('switch', { name: '编辑模式' }).check();