refactor(browser): make sessionName optional, add selector filter, deduplicate session setup

- sessionName is now optional in open/exec; skips session restore when omitted
- add selector param to open: returns outerHTML or textContent of matched element
- extract session restore logic into private setupSession() to remove duplication
- replace per-exception instanceof checks with single HttpException base class check
- embed label into InternalServerErrorException message instead of logging separately
- update MCP tool schemas and HTTP DTOs to reflect optional sessionName and new selector
- add integration tests: sessionless open/exec, selector, selector+readerMode
This commit is contained in:
2026-04-08 11:10:08 +03:00
parent f1dadc602a
commit f0437d9390
7 changed files with 109 additions and 86 deletions
+10 -1
View File
@@ -1,6 +1,15 @@
const mockElement = {
outerHTML: '<div id="mock">mock content</div>',
textContent: 'mock content',
};
export class JSDOM {
constructor(public html: string, public options?: any) {}
get window() {
return { document: {} };
return {
document: {
querySelector: (_selector: string) => mockElement,
},
};
}
}