Skip to content

Commit

Permalink
feat: add demo entry
Browse files Browse the repository at this point in the history
  • Loading branch information
doodlewind committed May 21, 2024
1 parent 5572ab1 commit e212520
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"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",
"demo": "playwright test --debug --config=playwright.demo.config.ts",
"test": "playwright test",
"shutdown": "./scripts/shutdown.sh",
"test:headed": "playwright test --debug",
"clean": "pnpm --filter @notesuite/server clean"
},
Expand Down
16 changes: 16 additions & 0 deletions playwright.demo.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { PlaywrightTestConfig } from 'playwright/test';

const config: PlaywrightTestConfig = {
testDir: 'tests',
use: {
browserName: 'chromium',
},
projects: [
{
name: 'demo',
testMatch: 'tests/common/demo.ts',
},
],
};

export default config;
12 changes: 12 additions & 0 deletions scripts/shutdown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

killport() {
if [ -z "$1" ]; then
echo "Usage: killport <port>"
return 1
fi
kill $(lsof -i :$1 | grep node | awk '{print $2}')
}

killport 5173
killport 3000
5 changes: 5 additions & 0 deletions tests/common/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,18 @@ class WebAgentInterface {
}
}

class DesktopAgentInterface {
constructor(private agent: TestAgent) {}
}

class MockAgentInterface {
constructor(private agent: TestAgent) {}
}

export class TestAgent {
runner = new AppRunner();
web = new WebAgentInterface(this);
desktop = new DesktopAgentInterface(this);
mock = new MockAgentInterface(this);

workspaceId = '';
Expand Down
20 changes: 20 additions & 0 deletions tests/common/demo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { test } from 'playwright/test';
import { TestAgent } from './agent.js';

test('demo', async ({ page }) => {
const agent = new TestAgent();
await agent.start({
name: 'demo',
webPort: 5173,
backendPort: 3000,
});
await page.goto(agent.web.baseUrl);
// await page.pause();

await agent.web.createWorkspace(page, 'hello');
await agent.web.createDoc(page, 'First Doc');
await agent.web.createDoc(page, 'Second Doc');
await agent.web.createDoc(page, 'Third Doc');
// await page.pause();
// await agent.stop();
});

0 comments on commit e212520

Please sign in to comment.