Skip to content

Commit

Permalink
Merge branch 'develop' into fix-script-val-gen
Browse files Browse the repository at this point in the history
  • Loading branch information
ihexxa authored May 27, 2024
2 parents 8f74f2d + 9f0bd8b commit 393e0ef
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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();
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ 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);
await page.getByPlaceholder('Search and switch between').fill('send js');
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ 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();

Check failure on line 54 in packages/insomnia-smoke-test/tests/smoke/pre-request-script-window.test.ts

View workflow job for this annotation

GitHub Actions / Test

[Smoke] › smoke/pre-request-script-window.test.ts:34:7 › test hidden window handling › handle hidden browser window getting closed

1) [Smoke] › smoke/pre-request-script-window.test.ts:34:7 › test hidden window handling › handle hidden browser window getting closed TimeoutError: locator.click: Timeout 30000ms exceeded. Call log: - waiting for getByText('Timeout: Running script took too long') 52 | await page.getByTestId('request-pane').getByRole('button', { name: 'Send', exact: true }).click(); 53 | > 54 | await page.getByText('Timeout: Running script took too long').click(); | ^ 55 | await page.getByRole('tab', { name: 'Timeline' }).click(); 56 | await page.getByRole('tab', { name: 'Preview ' }).click(); 57 | const windows = await app.windows(); at /home/runner/work/insomnia/insomnia/packages/insomnia-smoke-test/tests/smoke/pre-request-script-window.test.ts:54:67
await page.getByRole('tab', { name: 'Timeline' }).click();
await page.getByRole('tab', { name: 'Preview ' }).click();
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();
});
Expand All @@ -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');
Expand Down
8 changes: 4 additions & 4 deletions packages/insomnia/src/ui/components/command-palette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ const CommandPaletteCombobox = ({ close }: { close: () => void }) => {
{getMethodShortHand(request.item)}
</span>
) : isWebSocketRequest(request.item) ? (
<span className="w-10 flex-shrink-0 flex text-[0.65rem] rounded-sm border border-solid border-[--hl-sm] items-center justify-center text-[--color-font-notice] bg-[rgba(var(--color-notice-rgb),0.5)]">
<span className="w-10 flex-shrink-0 flex text-[0.65rem] rounded-sm border border-solid border-[--hl-sm] items-center justify-center text-[--color-font-notice] bg-[rgba(var(--color-notice-rgb),0.5)]">
WS
</span>
) : isGrpcRequest(request.item) && (
<span className="w-10 flex-shrink-0 flex text-[0.65rem] rounded-sm border border-solid border-[--hl-sm] items-center justify-center text-[--color-font-info] bg-[rgba(var(--color-info-rgb),0.5)]">
<span className="w-10 flex-shrink-0 flex text-[0.65rem] rounded-sm border border-solid border-[--hl-sm] items-center justify-center text-[--color-font-info] bg-[rgba(var(--color-info-rgb),0.5)]">
gRPC
</span>
),
Expand Down Expand Up @@ -293,11 +293,11 @@ const CommandPaletteCombobox = ({ close }: { close: () => void }) => {
{getMethodShortHand(request.item)}
</span>
) : isWebSocketRequest(request.item) ? (
<span className="w-10 flex-shrink-0 flex text-[0.65rem] rounded-sm border border-solid border-[--hl-sm] items-center justify-center text-[--color-font-notice] bg-[rgba(var(--color-notice-rgb),0.5)]">
<span className="w-10 flex-shrink-0 flex text-[0.65rem] rounded-sm border border-solid border-[--hl-sm] items-center justify-center text-[--color-font-notice] bg-[rgba(var(--color-notice-rgb),0.5)]">
WS
</span>
) : isGrpcRequest(request.item) && (
<span className="w-10 flex-shrink-0 flex text-[0.65rem] rounded-sm border border-solid border-[--hl-sm] items-center justify-center text-[--color-font-info] bg-[rgba(var(--color-info-rgb),0.5)]">
<span className="w-10 flex-shrink-0 flex text-[0.65rem] rounded-sm border border-solid border-[--hl-sm] items-center justify-center text-[--color-font-info] bg-[rgba(var(--color-info-rgb),0.5)]">
gRPC
</span>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const RequestGroupRow: FC<{
return (
<li key={requestGroup._id} className="flex flex-col">
<div className="flex items-center gap-2 p-2">
<Checkbox isIndeterminate={isIndeterminate} slot={null} isSelected={isSelected} onChange={isSelected => handleSetItemSelected(requestGroup._id, isSelected)} className="group p-0 flex items-center h-full">
<Checkbox aria-label={requestGroup.name} isIndeterminate={isIndeterminate} slot={null} isSelected={isSelected} onChange={isSelected => handleSetItemSelected(requestGroup._id, isSelected)} className="group p-0 flex items-center h-full">
<div className="w-4 h-4 rounded flex items-center justify-center transition-colors group-data-[selected]:bg-[--hl-xs] group-focus:ring-2 ring-1 ring-[--hl-sm]">
<Icon icon={isIndeterminate ? 'minus' : 'check'} className='opacity-0 group-data-[selected]:opacity-100 group-data-[indeterminate]:opacity-100 group-data-[selected]:text-[--color-success] w-3 h-3' />
</div>
Expand Down Expand Up @@ -78,6 +78,7 @@ export const RequestRow: FC<{
<li className="flex items-center gap-2 p-2">
<Checkbox
slot={null}
aria-label={request.name}
isSelected={isSelected}
onChange={isSelected => {
handleSetItemSelected(request._id, isSelected);
Expand Down
19 changes: 15 additions & 4 deletions packages/insomnia/src/ui/routes/debug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<GridListItem
className="group outline-none absolute top-0 left-0 select-none w-full"
textValue={item.doc.name}
textValue={label}
data-testid={item.doc.name}
style={{
height: `${virtualItem.size}`,
Expand All @@ -1106,6 +1115,8 @@ export const Debug: FC = () => {
<Button slot="drag" className="hidden" />
{isRequest(item.doc) && (
<span
aria-hidden
role="presentation"
className={
`w-10 flex-shrink-0 flex text-[0.65rem] rounded-sm border border-solid border-[--hl-sm] items-center justify-center
${{
Expand All @@ -1123,12 +1134,12 @@ export const Debug: FC = () => {
</span>
)}
{isWebSocketRequest(item.doc) && (
<span className="w-10 flex-shrink-0 flex text-[0.65rem] rounded-sm border border-solid border-[--hl-sm] items-center justify-center text-[--color-font-notice] bg-[rgba(var(--color-notice-rgb),0.5)]">
<span aria-hidden role="presentation" className="w-10 flex-shrink-0 flex text-[0.65rem] rounded-sm border border-solid border-[--hl-sm] items-center justify-center text-[--color-font-notice] bg-[rgba(var(--color-notice-rgb),0.5)]">
WS
</span>
)}
{isGrpcRequest(item.doc) && (
<span className="w-10 flex-shrink-0 flex text-[0.65rem] rounded-sm border border-solid border-[--hl-sm] items-center justify-center text-[--color-font-info] bg-[rgba(var(--color-info-rgb),0.5)]">
<span aria-hidden role="presentation" className="w-10 flex-shrink-0 flex text-[0.65rem] rounded-sm border border-solid border-[--hl-sm] items-center justify-center text-[--color-font-info] bg-[rgba(var(--color-info-rgb),0.5)]">
gRPC
</span>
)}
Expand All @@ -1141,7 +1152,7 @@ export const Debug: FC = () => {
<EditableInput
value={getRequestNameOrFallback(item.doc)}
name="request name"
ariaLabel="request name"
ariaLabel={label}
className="px-1 flex-1"
onSingleClick={() => {
if (item && isRequestGroup(item.doc)) {
Expand Down

0 comments on commit 393e0ef

Please sign in to comment.