Skip to content

Commit ff433a1

Browse files
Natallia HarshunovaOrKoN
authored andcommitted
Refactor test, add issues test description and learn more links
1 parent 000d9d3 commit ff433a1

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

tests/tools/console.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {afterEach, before, beforeEach, describe, it} from 'node:test';
88

99
import {setIssuesEnabled} from '../../src/features.js';
1010
import {loadIssueDescriptions} from '../../src/issue-descriptions.js';
11+
import {McpResponse} from '../../src/McpResponse.js';
1112
import {
1213
getConsoleMessage,
1314
listConsoleMessages,
@@ -128,12 +129,6 @@ describe('console', () => {
128129
});
129130

130131
describe('get_console_message', () => {
131-
beforeEach(() => {
132-
setIssuesEnabled(true);
133-
});
134-
afterEach(() => {
135-
setIssuesEnabled(false);
136-
});
137132
it('gets a specific console message', async () => {
138133
await withBrowser(async (response, context) => {
139134
const page = await context.newPage();
@@ -164,7 +159,7 @@ describe('console', () => {
164159
setIssuesEnabled(false);
165160
});
166161

167-
it('lists issues', async () => {
162+
it('gets issue details', async () => {
168163
await withBrowser(async (response, context) => {
169164
const page = await context.newPage();
170165
const issuePromise = new Promise<void>(resolve => {
@@ -175,18 +170,23 @@ describe('console', () => {
175170
await page.setContent('<input type="text" name="username" />');
176171
await issuePromise;
177172
await listConsoleMessages.handler({params: {}}, response, context);
173+
const response2 = new McpResponse();
178174
await getConsoleMessage.handler(
179175
{params: {msgid: 1}},
180-
response,
176+
response2,
181177
context,
182178
);
183-
const formattedResponse = await response.handle('test', context);
179+
const formattedResponse = await response2.handle('test', context);
184180
const textContent = formattedResponse[0] as {text: string};
185-
assert.ok(
186-
textContent.text.includes(
187-
"Message: issue> An element doesn't have an autocomplete attribute",
188-
),
189-
);
181+
const learnMoreLinks =
182+
'[HTML attribute: autocomplete](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#values)';
183+
const detailsDescription =
184+
"A form field has an `id` or `name` attribute that the browser's autofill recognizes. However, it doesn't have an `autocomplete` attribute assigned. This might prevent the browser from correctly autofilling the form.\n\nTo fix this issue, provide an `autocomplete` attribute.";
185+
const title =
186+
"Message: issue> An element doesn't have an autocomplete attribute";
187+
assert.ok(textContent.text.includes(title));
188+
assert.ok(textContent.text.includes(detailsDescription));
189+
assert.ok(textContent.text.includes(learnMoreLinks));
190190
});
191191
});
192192
});

0 commit comments

Comments
 (0)