Skip to content

Commit e212520

Browse files
committed
feat: add demo entry
1 parent 5572ab1 commit e212520

File tree

5 files changed

+55
-0
lines changed

5 files changed

+55
-0
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
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+
"demo": "playwright test --debug --config=playwright.demo.config.ts",
1213
"test": "playwright test",
14+
"shutdown": "./scripts/shutdown.sh",
1315
"test:headed": "playwright test --debug",
1416
"clean": "pnpm --filter @notesuite/server clean"
1517
},

playwright.demo.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { PlaywrightTestConfig } from 'playwright/test';
2+
3+
const config: PlaywrightTestConfig = {
4+
testDir: 'tests',
5+
use: {
6+
browserName: 'chromium',
7+
},
8+
projects: [
9+
{
10+
name: 'demo',
11+
testMatch: 'tests/common/demo.ts',
12+
},
13+
],
14+
};
15+
16+
export default config;

scripts/shutdown.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
killport() {
4+
if [ -z "$1" ]; then
5+
echo "Usage: killport <port>"
6+
return 1
7+
fi
8+
kill $(lsof -i :$1 | grep node | awk '{print $2}')
9+
}
10+
11+
killport 5173
12+
killport 3000

tests/common/agent.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,18 @@ class WebAgentInterface {
5858
}
5959
}
6060

61+
class DesktopAgentInterface {
62+
constructor(private agent: TestAgent) {}
63+
}
64+
6165
class MockAgentInterface {
6266
constructor(private agent: TestAgent) {}
6367
}
6468

6569
export class TestAgent {
6670
runner = new AppRunner();
6771
web = new WebAgentInterface(this);
72+
desktop = new DesktopAgentInterface(this);
6873
mock = new MockAgentInterface(this);
6974

7075
workspaceId = '';

tests/common/demo.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { test } from 'playwright/test';
2+
import { TestAgent } from './agent.js';
3+
4+
test('demo', async ({ page }) => {
5+
const agent = new TestAgent();
6+
await agent.start({
7+
name: 'demo',
8+
webPort: 5173,
9+
backendPort: 3000,
10+
});
11+
await page.goto(agent.web.baseUrl);
12+
// await page.pause();
13+
14+
await agent.web.createWorkspace(page, 'hello');
15+
await agent.web.createDoc(page, 'First Doc');
16+
await agent.web.createDoc(page, 'Second Doc');
17+
await agent.web.createDoc(page, 'Third Doc');
18+
// await page.pause();
19+
// await agent.stop();
20+
});

0 commit comments

Comments
 (0)