From 9f0bd8b0fe54e63dbfd52f49059119e1a543e6f0 Mon Sep 17 00:00:00 2001 From: James Gatz Date: Mon, 27 May 2024 09:54:37 +0200 Subject: [PATCH] feat(Accessibility): Update request lists to anounce the request name of a request on voice over (#7449) --- .../tests/critical/certificates.test.ts | 4 ++-- .../tests/smoke/command-palette.test.ts | 4 ++-- .../smoke/debug-sidebar-interactions.test.ts | 6 +++--- .../smoke/pre-request-script-window.test.ts | 12 ++++++------ .../src/ui/components/command-palette.tsx | 8 ++++---- .../modals/export-requests-modal.tsx | 3 ++- packages/insomnia/src/ui/routes/debug.tsx | 19 +++++++++++++++---- 7 files changed, 34 insertions(+), 22 deletions(-) diff --git a/packages/insomnia-smoke-test/tests/critical/certificates.test.ts b/packages/insomnia-smoke-test/tests/critical/certificates.test.ts index 66e587f0663..a7acacad673 100644 --- a/packages/insomnia-smoke-test/tests/critical/certificates.test.ts +++ b/packages/insomnia-smoke-test/tests/critical/certificates.test.ts @@ -16,7 +16,7 @@ test('can send request with custom ca root certificate', async ({ app, page }) = await page.getByLabel('Request Collection').getByTestId('sends request with certs').press('Enter'); - await page.getByRole('button', { name: 'Send' }).click(); + await page.getByRole('button', { name: 'Send', exact: true }).click(); await page.getByText('Error: SSL peer certificate or SSH remote key was not OK').click(); const fixturePath = getFixturePath('certificates'); @@ -32,7 +32,7 @@ test('can send request with custom ca root certificate', async ({ app, page }) = await page.getByRole('button', { name: 'Done' }).click(); // test request with certs - await page.getByRole('button', { name: 'Send' }).click(); + await page.getByRole('button', { name: 'Send', exact: true }).click(); await page.getByText('200 OK').click(); await page.locator('pre').filter({ hasText: '"id": "1"' }).click(); }); diff --git a/packages/insomnia-smoke-test/tests/smoke/command-palette.test.ts b/packages/insomnia-smoke-test/tests/smoke/command-palette.test.ts index 35f15297b03..4bc5faa27f9 100644 --- a/packages/insomnia-smoke-test/tests/smoke/command-palette.test.ts +++ b/packages/insomnia-smoke-test/tests/smoke/command-palette.test.ts @@ -27,7 +27,7 @@ test('Command palette - can switch between requests and workspaces', async ({ ap await page.getByRole('dialog').getByRole('button', { name: 'Import' }).click(); await page.getByLabel('Smoke tests').click(); - await page.getByTestId('sends request with cookie and get cookie in response').getByLabel('request name').click(); + await page.getByTestId('sends request with cookie and get cookie in response').getByText('GET', { exact: true }).click(); await page.getByTestId('OneLineEditor').getByText('http://127.0.0.1:4010/cookies').click(); const requestSwitchKeyboardShortcut = process.platform === 'darwin' ? 'Meta+p' : 'Control+p'; await page.locator('body').press(requestSwitchKeyboardShortcut); @@ -35,7 +35,7 @@ test('Command palette - can switch between requests and workspaces', async ({ ap await page.getByPlaceholder('Search and switch between').press('ArrowDown'); await page.getByPlaceholder('Search and switch between').press('Enter'); await page.getByTestId('OneLineEditor').getByText('http://127.0.0.1:4010/pets/').click(); - await page.getByRole('button', { name: 'Send' }).click(); + await page.getByRole('button', { name: 'Send', exact: true }).click(); await page.getByText('200 OK').click(); await page.locator('body').press(requestSwitchKeyboardShortcut); diff --git a/packages/insomnia-smoke-test/tests/smoke/debug-sidebar-interactions.test.ts b/packages/insomnia-smoke-test/tests/smoke/debug-sidebar-interactions.test.ts index 0a1b179b044..fdf006b1dfd 100644 --- a/packages/insomnia-smoke-test/tests/smoke/debug-sidebar-interactions.test.ts +++ b/packages/insomnia-smoke-test/tests/smoke/debug-sidebar-interactions.test.ts @@ -133,10 +133,10 @@ test.describe('Debug-Sidebar', async () => { }); test('Rename a request by clicking', async ({ page }) => { - await page.getByTestId('example http').getByLabel('request name').dblclick(); - await page.getByRole('textbox', { name: 'request name' }).fill('new name'); + await page.getByTestId('example http').getByLabel('GET example http', { exact: true }).dblclick(); + await page.getByRole('textbox', { name: 'GET example http' }).fill('new name'); await page.getByLabel('Request Collection').click(); - await expect(page.getByTestId('new name').getByLabel('request name')).toContainText('new name'); + await expect(page.getByTestId('new name').getByLabel('GET new name', { exact: true })).toContainText('new name'); }); test('Create a new HTTP request', async ({ page }) => { diff --git a/packages/insomnia-smoke-test/tests/smoke/pre-request-script-window.test.ts b/packages/insomnia-smoke-test/tests/smoke/pre-request-script-window.test.ts index e224ea85491..9137148f046 100644 --- a/packages/insomnia-smoke-test/tests/smoke/pre-request-script-window.test.ts +++ b/packages/insomnia-smoke-test/tests/smoke/pre-request-script-window.test.ts @@ -49,7 +49,7 @@ test.describe('test hidden window handling', async () => { await page.getByText('Pre-request Scripts').click(); await page.getByLabel('Request Collection').getByTestId('Long running task').press('Enter'); - await page.getByTestId('request-pane').getByRole('button', { name: 'Send' }).click(); + await page.getByTestId('request-pane').getByRole('button', { name: 'Send', exact: true }).click(); await page.getByText('Timeout: Running script took too long').click(); await page.getByRole('tab', { name: 'Timeline' }).click(); @@ -57,7 +57,7 @@ test.describe('test hidden window handling', async () => { const windows = await app.windows(); const hiddenWindow = windows[1]; hiddenWindow.close(); - await page.getByRole('button', { name: 'Send' }).click(); + await page.getByRole('button', { name: 'Send', exact: true }).click(); // as the hidden window is restarted, it should not show "Timeout: Hidden browser window is not responding" await page.getByText('Timeout: Running script took too long').click(); }); @@ -83,12 +83,12 @@ test.describe('test hidden window handling', async () => { // send the request with infinite loop script await page.getByText('Pre-request Scripts').click(); await page.getByLabel('Request Collection').getByTestId('infinite loop').press('Enter'); - await page.getByTestId('request-pane').getByRole('button', { name: 'Send' }).click(); + await page.getByTestId('request-pane').getByRole('button', { name: 'Send', exact: true }).click(); await page.getByText('Timeout: Hidden browser window is not responding').click(); // send the another script with normal script await page.getByLabel('Request Collection').getByTestId('simple log').press('Enter'); - await page.getByTestId('request-pane').getByRole('button', { name: 'Send' }).click(); + await page.getByTestId('request-pane').getByRole('button', { name: 'Send', exact: true }).click(); // it should still work const statusTag = page.locator('[data-testid="response-status-tag"]:visible'); @@ -118,12 +118,12 @@ test('window should be restarted if it hangs', async ({ app, page }) => { // send the request with infinite loop script await page.getByText('Pre-request Scripts').click(); await page.getByLabel('Request Collection').getByTestId('infinite loop').press('Enter'); - await page.getByTestId('request-pane').getByRole('button', { name: 'Send' }).click(); + await page.getByTestId('request-pane').getByRole('button', { name: 'Send', exact: true }).click(); await page.getByText('Timeout: Hidden browser window is not responding').click(); // send the another script with normal script await page.getByLabel('Request Collection').getByTestId('simple log').press('Enter'); - await page.getByTestId('request-pane').getByRole('button', { name: 'Send' }).click(); + await page.getByTestId('request-pane').getByRole('button', { name: 'Send', exact: true }).click(); // it should still work const statusTag = page.locator('[data-testid="response-status-tag"]:visible'); diff --git a/packages/insomnia/src/ui/components/command-palette.tsx b/packages/insomnia/src/ui/components/command-palette.tsx index abd53dcc7ef..922051d061d 100644 --- a/packages/insomnia/src/ui/components/command-palette.tsx +++ b/packages/insomnia/src/ui/components/command-palette.tsx @@ -212,11 +212,11 @@ const CommandPaletteCombobox = ({ close }: { close: () => void }) => { {getMethodShortHand(request.item)} ) : isWebSocketRequest(request.item) ? ( - + WS ) : isGrpcRequest(request.item) && ( - + gRPC ), @@ -293,11 +293,11 @@ const CommandPaletteCombobox = ({ close }: { close: () => void }) => { {getMethodShortHand(request.item)} ) : isWebSocketRequest(request.item) ? ( - + WS ) : isGrpcRequest(request.item) && ( - + gRPC ), diff --git a/packages/insomnia/src/ui/components/modals/export-requests-modal.tsx b/packages/insomnia/src/ui/components/modals/export-requests-modal.tsx index 6094d13be88..6a4d16099c4 100644 --- a/packages/insomnia/src/ui/components/modals/export-requests-modal.tsx +++ b/packages/insomnia/src/ui/components/modals/export-requests-modal.tsx @@ -44,7 +44,7 @@ export const RequestGroupRow: FC<{ return (
  • - handleSetItemSelected(requestGroup._id, isSelected)} className="group p-0 flex items-center h-full"> + handleSetItemSelected(requestGroup._id, isSelected)} className="group p-0 flex items-center h-full">
    @@ -78,6 +78,7 @@ export const RequestRow: FC<{
  • { handleSetItemSelected(request._id, isSelected); diff --git a/packages/insomnia/src/ui/routes/debug.tsx b/packages/insomnia/src/ui/routes/debug.tsx index 09c396d4f08..fd24c09d979 100644 --- a/packages/insomnia/src/ui/routes/debug.tsx +++ b/packages/insomnia/src/ui/routes/debug.tsx @@ -1086,10 +1086,19 @@ export const Debug: FC = () => { > {virtualItem => { const item = visibleCollection[virtualItem.index]; + let label = item.doc.name; + if (isRequest(item.doc)) { + label = `${getMethodShortHand(item.doc)} ${label}`; + } else if (isWebSocketRequest(item.doc)) { + label = `WS ${label}`; + } else if (isGrpcRequest(item.doc)) { + label = `gRPC ${label}`; + } + return ( {