Skip to content

Commit 1a3aeaa

Browse files
committed
fix: clean before test
1 parent 8f94fdb commit 1a3aeaa

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"dev:web": "pnpm --filter @notesuite/client dev & pnpm --filter @notesuite/common dev",
1010
"dev:server": "pnpm --filter @notesuite/server start",
1111
"dev:client": "pnpm --filter @notesuite/client tauri dev & pnpm --filter @notesuite/common dev",
12-
"test": "playwright test --debug",
13-
"test:clean": "pnpm clean && pnpm test",
12+
"test": "playwright test",
13+
"test:headed": "playwright test --debug",
1414
"clean": "pnpm --filter @notesuite/server clean"
1515
},
1616
"devDependencies": {

packages/server/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export function initWSServer(context: AppContext) {
6868

6969
wss.on('connection', (ws, request) => {
7070
setupWSConnection(ws, request, { gc: true });
71-
console.log('doc count', [...docs.keys()].length);
71+
// console.log('doc count', [...docs.keys()].length);
7272
});
7373

7474
const { activeWorkspaceId } = context.db.data;

tests/basic.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ test.describe('basic test', () => {
88
webPort: 5173,
99
backendPort: 3000,
1010
};
11+
let workspaceId = '';
1112
test.beforeAll(() => agent.start(options));
1213

1314
test('local server works', async ({ page }) => {
@@ -21,6 +22,12 @@ test.describe('basic test', () => {
2122
await page.getByPlaceholder('Workspace name').fill('hello');
2223
await page.getByRole('button', { name: 'Create' }).click();
2324
await expect(page.getByText('Test Client')).toBeVisible();
25+
26+
const currentUrl = page.url();
27+
const parts = currentUrl.split('/');
28+
const id = parts[parts.length - 1];
29+
expect(id).not.toBe('');
30+
workspaceId = id;
2431
});
2532

2633
test.afterAll(() => agent.stop());

tests/common/agent.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export class TestAgent {
3232

3333
async start(options: StartOptions) {
3434
this.options = options;
35+
await this.runner.clean();
3536
await Promise.all([
3637
this.runner.startServer(options.backendPort, options.name),
3738
this.runner.startWeb(options.webPort, options.backendPort),

tests/common/runner.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,24 @@ export class AppRunner {
88
this.webProcess = null;
99
}
1010

11+
async clean() {
12+
await /** @type {Promise<void>} */ (
13+
new Promise((resolve, reject) => {
14+
const process = spawn('pnpm', ['clean'], {
15+
stdio: 'inherit',
16+
});
17+
18+
process.on('error', err => reject(err));
19+
process.on('close', code => {
20+
if (code !== 0) {
21+
reject(new Error(`Clean process exited with code ${code}`));
22+
}
23+
resolve();
24+
});
25+
})
26+
);
27+
}
28+
1129
/**
1230
* @param {number} port
1331
* @param {string} instanceName

0 commit comments

Comments
 (0)