experiments in a post-browser web
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

test: delete v1 extension-lifecycle spec (api.extensions admin path retired)

-123
-123
tests/desktop/extension-lifecycle.spec.ts
··· 1 - // NOTE: Tests in this describe have intra-test ordering dependencies: 2 - // validate → add → list → update (enable/disable) → remove 3 - // They must run in declared order. Under fullyParallel: false this is 4 - // guaranteed. If you ever enable per-test parallelism for this file, 5 - // refactor each test to be self-contained first. 6 - 7 - import { test, expect, DesktopApp, launchDesktopApp } from '../fixtures/desktop-app'; 8 - import { Page } from '@playwright/test'; 9 - import path from 'path'; 10 - import { fileURLToPath } from 'url'; 11 - 12 - const __filename = fileURLToPath(import.meta.url); 13 - const __dirname = path.dirname(__filename); 14 - const ROOT = path.join(__dirname, '../..'); 15 - 16 - test.describe('Extension Lifecycle @desktop', () => { 17 - let app: DesktopApp; 18 - let bgWindow: Page; 19 - 20 - const EXAMPLE_EXT_PATH = path.join(ROOT, 'features', 'example'); 21 - 22 - test.beforeAll(async () => { 23 - app = await launchDesktopApp('test-ext-lifecycle'); 24 - bgWindow = await app.getBackgroundWindow(); 25 - }); 26 - 27 - test.afterAll(async () => { 28 - if (app) await app.close(); 29 - }); 30 - 31 - test('validate extension folder', async () => { 32 - const result = await bgWindow.evaluate(async (extPath: string) => { 33 - return await (window as any).app.extensions.validateFolder(extPath); 34 - }, EXAMPLE_EXT_PATH); 35 - 36 - expect(result.success).toBe(true); 37 - expect(result.data).toBeTruthy(); 38 - expect(result.data.manifest).toBeTruthy(); 39 - expect(result.data.manifest.id || result.data.manifest.shortname || result.data.manifest.name).toBeTruthy(); 40 - }); 41 - 42 - test('add extension', async () => { 43 - // First validate to get manifest 44 - const validateResult = await bgWindow.evaluate(async (extPath: string) => { 45 - return await (window as any).app.extensions.validateFolder(extPath); 46 - }, EXAMPLE_EXT_PATH); 47 - 48 - const manifest = validateResult.data.manifest; 49 - 50 - // Add the extension 51 - const addResult = await bgWindow.evaluate(async ({ extPath, manifest }) => { 52 - return await (window as any).app.extensions.add(extPath, manifest, false); 53 - }, { extPath: EXAMPLE_EXT_PATH, manifest }); 54 - 55 - expect(addResult.success).toBe(true); 56 - expect(addResult.data).toBeTruthy(); 57 - expect(addResult.data.id).toBeTruthy(); 58 - }); 59 - 60 - test('list extensions includes added extension', async () => { 61 - const result = await bgWindow.evaluate(async () => { 62 - return await (window as any).app.extensions.getAll(); 63 - }); 64 - 65 - expect(result.success).toBe(true); 66 - expect(Array.isArray(result.data)).toBe(true); 67 - 68 - // Find the example extension 69 - const exampleExt = result.data.find((ext: any) => 70 - ext.id === 'example' || ext.path?.includes('example') 71 - ); 72 - expect(exampleExt).toBeTruthy(); 73 - }); 74 - 75 - test('update extension (enable/disable)', async () => { 76 - // Enable the extension 77 - const enableResult = await bgWindow.evaluate(async () => { 78 - return await (window as any).app.extensions.update('example', { enabled: true }); 79 - }); 80 - expect(enableResult.success).toBe(true); 81 - 82 - // Verify it's enabled (accept both boolean true and integer 1) 83 - const getResult1 = await bgWindow.evaluate(async () => { 84 - return await (window as any).app.extensions.get('example'); 85 - }); 86 - expect(getResult1.success).toBe(true); 87 - expect(getResult1.data.enabled === true || getResult1.data.enabled === 1).toBe(true); 88 - 89 - // Disable it 90 - const disableResult = await bgWindow.evaluate(async () => { 91 - return await (window as any).app.extensions.update('example', { enabled: false }); 92 - }); 93 - expect(disableResult.success).toBe(true); 94 - 95 - // Verify it's disabled 96 - const getResult2 = await bgWindow.evaluate(async () => { 97 - return await (window as any).app.extensions.get('example'); 98 - }); 99 - expect(getResult2.success).toBe(true); 100 - expect(getResult2.data.enabled === false || getResult2.data.enabled === 0).toBe(true); 101 - }); 102 - 103 - test('remove extension', async () => { 104 - const removeResult = await bgWindow.evaluate(async () => { 105 - return await (window as any).app.extensions.remove('example'); 106 - }); 107 - expect(removeResult.success).toBe(true); 108 - 109 - // Verify it's removed 110 - const getResult = await bgWindow.evaluate(async () => { 111 - return await (window as any).app.extensions.get('example'); 112 - }); 113 - expect(getResult.success).toBe(false); 114 - 115 - // Verify it's not in list 116 - const listResult = await bgWindow.evaluate(async () => { 117 - return await (window as any).app.extensions.getAll(); 118 - }); 119 - expect(listResult.success).toBe(true); 120 - const exampleExt = listResult.data.find((ext: any) => ext.id === 'example'); 121 - expect(exampleExt).toBeFalsy(); 122 - }); 123 - });