chore: sanitize file path when saving (#99)

Fixes https://github.com/microsoft/playwright-mcp/issues/96
This commit is contained in:
Pavel Feldman 2025-03-31 15:01:58 -07:00 committed by GitHub
parent aeb4cf65e9
commit d316441142
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 32 additions and 7 deletions

View file

@ -81,15 +81,14 @@ export const test = baseTest.extend<Fixtures>({
type Response = Awaited<ReturnType<Client['callTool']>>;
export const expect = baseExpect.extend({
toHaveTextContent(response: Response, content: string | string[]) {
toHaveTextContent(response: Response, content: string | RegExp) {
const isNot = this.isNot;
try {
content = Array.isArray(content) ? content : [content];
const texts = (response.content as any).map(c => c.text);
const text = (response.content as any)[0].text;
if (isNot)
baseExpect(texts).not.toEqual(content);
baseExpect(text).not.toMatch(content);
else
baseExpect(texts).toEqual(content);
baseExpect(text).toMatch(content);
} catch (e) {
return {
pass: isNot,