diff --git a/package.json b/package.json index 2336daf..61cb470 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "dev:web": "pnpm --filter @notesuite/client dev & pnpm --filter @notesuite/common dev", "dev:server": "pnpm --filter @notesuite/server start", "dev:client": "pnpm --filter @notesuite/client tauri dev & pnpm --filter @notesuite/common dev", - "test": "playwright test --debug", - "test:clean": "pnpm clean && pnpm test", + "test": "playwright test", + "test:headed": "playwright test --debug", "clean": "pnpm --filter @notesuite/server clean" }, "devDependencies": { diff --git a/packages/server/src/utils.ts b/packages/server/src/utils.ts index 7fb9699..3e67de2 100644 --- a/packages/server/src/utils.ts +++ b/packages/server/src/utils.ts @@ -68,7 +68,7 @@ export function initWSServer(context: AppContext) { wss.on('connection', (ws, request) => { setupWSConnection(ws, request, { gc: true }); - console.log('doc count', [...docs.keys()].length); + // console.log('doc count', [...docs.keys()].length); }); const { activeWorkspaceId } = context.db.data; diff --git a/tests/basic.spec.ts b/tests/basic.spec.ts index 9ad9e41..1988a3b 100644 --- a/tests/basic.spec.ts +++ b/tests/basic.spec.ts @@ -8,6 +8,7 @@ test.describe('basic test', () => { webPort: 5173, backendPort: 3000, }; + let workspaceId = ''; test.beforeAll(() => agent.start(options)); test('local server works', async ({ page }) => { @@ -21,6 +22,12 @@ test.describe('basic test', () => { await page.getByPlaceholder('Workspace name').fill('hello'); await page.getByRole('button', { name: 'Create' }).click(); await expect(page.getByText('Test Client')).toBeVisible(); + + const currentUrl = page.url(); + const parts = currentUrl.split('/'); + const id = parts[parts.length - 1]; + expect(id).not.toBe(''); + workspaceId = id; }); test.afterAll(() => agent.stop()); diff --git a/tests/common/agent.ts b/tests/common/agent.ts index d0ab869..44592be 100644 --- a/tests/common/agent.ts +++ b/tests/common/agent.ts @@ -32,6 +32,7 @@ export class TestAgent { async start(options: StartOptions) { this.options = options; + await this.runner.clean(); await Promise.all([ this.runner.startServer(options.backendPort, options.name), this.runner.startWeb(options.webPort, options.backendPort), diff --git a/tests/common/runner.js b/tests/common/runner.js index 8d17252..b186a7e 100644 --- a/tests/common/runner.js +++ b/tests/common/runner.js @@ -8,6 +8,24 @@ export class AppRunner { this.webProcess = null; } + async clean() { + await /** @type {Promise} */ ( + new Promise((resolve, reject) => { + const process = spawn('pnpm', ['clean'], { + stdio: 'inherit', + }); + + process.on('error', err => reject(err)); + process.on('close', code => { + if (code !== 0) { + reject(new Error(`Clean process exited with code ${code}`)); + } + resolve(); + }); + }) + ); + } + /** * @param {number} port * @param {string} instanceName