Skip to content

Commit

Permalink
update e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gatzjames committed Jun 4, 2024
1 parent 5b8a921 commit 1b123bf
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ test.describe('Environment Editor', async () => {
await page.getByLabel('Request Collection').getByTestId('New Request').press('Enter');

// Add number variable to request body
await page.getByRole('tab', { name: 'Plain' }).click();
await page.getByRole('tab', { name: 'Body' }).click();
await page.locator('pre').filter({ hasText: '_.exampleObject.anotherNumber' }).press('Enter');

await page.getByTestId('CodeEditor').getByRole('textbox').press('Enter');
Expand Down
14 changes: 7 additions & 7 deletions packages/insomnia-smoke-test/tests/smoke/graphql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ test('can render schema and send GraphQL requests', async ({ app, page }) => {

// Open the graphql request
await page.getByLabel('Request Collection').getByTestId('GraphQL request').press('Enter');
await page.getByRole('tab', { name: 'GraphQL' }).click();
await page.getByRole('tab', { name: 'Body' }).click();
// Assert the schema is fetched after switching to GraphQL request
await expect(page.locator('.graphql-editor__meta')).toContainText('schema fetched just now');
await expect(page.getByText('Schema fetched just now')).toBeVisible();

// Assert schema documentation stuff
await page.getByRole('button', { name: 'schema' }).click();
Expand Down Expand Up @@ -63,9 +63,9 @@ test('can render schema and send GraphQL requests with object variables', async

// Open the graphql request
await page.getByLabel('Request Collection').getByTestId('GraphQL request with variables').press('Enter');
await page.getByRole('tab', { name: 'GraphQL' }).click();
await page.getByRole('tab', { name: 'Body' }).click();
// Assert the schema is fetched after switching to GraphQL request
await expect(page.locator('.graphql-editor__meta')).toContainText('schema fetched just now');
await expect(page.getByText('Schema fetched just now')).toBeVisible();

// Assert schema documentation stuff
await page.getByRole('button', { name: 'schema' }).click();
Expand Down Expand Up @@ -105,9 +105,9 @@ test('can render numeric environment', async ({ app, page }) => {

// Open the graphql request
await page.getByLabel('Request Collection').getByTestId('GraphQL request with number').press('Enter');
await page.getByRole('tab', { name: 'GraphQL' }).click();
await page.getByRole('tab', { name: 'Body' }).click();
// Assert the schema is fetched after switching to GraphQL request
await expect(page.locator('.graphql-editor__meta')).toContainText('schema fetched just now');
await expect(page.getByText('Schema fetched just now')).toBeVisible();

// Assert schema documentation stuff
await page.getByRole('button', { name: 'schema' }).click();
Expand Down Expand Up @@ -144,7 +144,7 @@ test('can send GraphQL requests after editing and prettifying query', async ({ a
await page.getByLabel('Request Collection').getByTestId('GraphQL request').press('Enter');

// Edit and prettify query
await page.getByRole('tab', { name: 'GraphQL' }).click();
await page.getByRole('tab', { name: 'Body' }).click();
await page.locator('pre[role="presentation"]:has-text("bearer")').click();
await page.locator('.app').press('Enter');
await page.locator('text=Prettify GraphQL').click();
Expand Down
3 changes: 2 additions & 1 deletion packages/insomnia-smoke-test/tests/smoke/oauth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ test('can make oauth2 requests', async ({ app, page }) => {
await expect(responseBody).toContainText('"sub": "admin"');

// Navigate to the OAuth2 Tab and refresh the token from there
await page.getByRole('tab', { name: 'OAuth 2' }).click();
await page.getByRole('tab', { name: 'Auth' }).click();
await expect(page.getByRole('button', { name: 'OAuth 2.0' })).toBeVisible();

const tokenInput = page.locator('[for="Access-Token"] > input');
const prevToken = await tokenInput.inputValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,13 @@ test.describe('pre-request features tests', async () => {
// set request body
await page.getByRole('tab', { name: 'Body' }).click();
await page.getByRole('button', { name: 'Body' }).click();
await page.getByRole('menuitem', { name: 'JSON' }).click();
await page.getByRole('option', { name: 'JSON' }).click();

const bodyEditor = page.getByTestId('CodeEditor').getByRole('textbox');
await bodyEditor.fill('{ "rawBody": {{ _.rawBody }}, "urlencodedBody": {{ _.urlencodedBody }}, "gqlBody": {{ _.gqlBody }}, "fileBody": {{ _.fileBody }}, "formdataBody": {{ _.formdataBody }} }');

// enter script
await page.getByTestId('pre-request-script-tab').click();
await page.getByRole('tab', { name: 'Scripts' }).click();
const preRequestScriptEditor = page.getByTestId('CodeEditor').getByRole('textbox');
await preRequestScriptEditor.fill(`
const rawReq = {
Expand Down Expand Up @@ -500,10 +500,10 @@ test.describe('unhappy paths', async () => {
// set request body
await page.getByRole('tab', { name: 'Body' }).click();
await page.getByRole('button', { name: 'Body' }).click();
await page.getByRole('menuitem', { name: 'JSON' }).click();
await page.getByRole('option', { name: 'JSON' }).click();

// enter script
await page.getByTestId('pre-request-script-tab').click();
await page.getByRole('tab', { name: 'Scripts' }).click();
const preRequestScriptEditor = page.getByTestId('CodeEditor').getByRole('textbox');
await preRequestScriptEditor.fill(tc.preReqScript);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ test('Request tabs', async ({ page }) => {
await page.getByRole('menuitemradio', { name: 'HTTP Request' }).press('Enter');
await page.getByRole('tab', { name: 'Body' }).click();
await page.getByRole('button', { name: 'Body' }).click();
await page.getByRole('menuitem', { name: 'JSON' }).click();
await page.getByRole('option', { name: 'JSON' }).click();
await page.getByRole('tab', { name: 'Auth' }).click();
await page.getByRole('button', { name: 'Auth' }).click();
await page.getByRole('menuitem', { name: 'OAuth 1.0' }).click();
await page.getByRole('tab', { name: 'Parameters' }).click();
await page.getByLabel('OAuth 1.0', { exact: true }).click();
await page.getByRole('tab', { name: 'Params' }).click();
await page.getByRole('tab', { name: 'Headers' }).click();
await page.getByRole('tab', { name: 'Docs' }).click();
await page.locator('text=Add Description').click();
Expand All @@ -26,11 +26,11 @@ test('WS tabs', async ({ page }) => {

await page.getByLabel('Create in collection').click();
await page.getByRole('menuitemradio', { name: 'WebSocket Request' }).click();
await page.getByRole('tab', { name: 'JSON' }).click();
await page.getByLabel('Websocket request pane tabs').getByRole('button', { name: 'JSON' }).click();
await page.getByRole('menuitem', { name: 'JSON' }).click();
await page.getByRole('tab', { name: 'Body' }).click();
await page.getByRole('button', { name: 'JSON' }).click();
await page.getByRole('option', { name: 'JSON' }).click();
await page.getByRole('tab', { name: 'Auth' }).click();
await page.getByRole('tab', { name: 'Parameters' }).click();
await page.getByRole('tab', { name: 'Params' }).click();
await page.getByRole('tab', { name: 'Headers' }).click();
await page.getByRole('tab', { name: 'Docs' }).click();
await page.getByRole('button', { name: 'Add Description' }).click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ export const GraphQLEditor: FC<Props> = ({
const canShowSchema = schema && !schemaIsFetching && !schemaFetchError && schemaLastFetchTime > 0;
return (
<>
<Toolbar className="w-full flex-shrink-0 h-[--line-height-sm] border-b border-solid border-[--hl-md] flex items-center px-2">
<Toolbar aria-label='GraphQL toolbar' className="w-full flex-shrink-0 h-[--line-height-sm] border-b border-solid border-[--hl-md] flex items-center px-2">
<Dropdown
aria-label='Operations Dropdown'
isDisabled={!state.operations.length}
Expand Down Expand Up @@ -577,7 +577,7 @@ export const GraphQLEditor: FC<Props> = ({
</Dropdown>
</Toolbar>
<PanelGroup direction={'vertical'}>
<Panel minSize={20} defaultSize={60}>
<Panel id="GraphQL Editor" minSize={20} defaultSize={60}>
<CodeEditor
id="graphql-editor"
ref={editorRef}
Expand All @@ -596,7 +596,7 @@ export const GraphQLEditor: FC<Props> = ({
/>
</Panel>
<PanelResizeHandle className={'w-full h-[1px] bg-[--hl-md]'} />
<Panel className='flex flex-col' minSize={20}>
<Panel id="GraphQL Variables editor" className='flex flex-col' minSize={20}>
<Heading className="w-full px-2 text-[--hl] select-none flex-shrink-0 h-[--line-height-sm] border-b border-solid border-[--hl-md] flex items-center">
Query Variables
<HelpTooltip className="space-left">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export const WebSocketRequestPane: FC<Props> = ({ environment }) => {
className='flex-shrink-0 h-full flex items-center justify-between cursor-pointer gap-2 outline-none select-none px-3 py-1 text-[--hl] aria-selected:text-[--color-font] hover:bg-[--hl-sm] hover:text-[--color-font] aria-selected:bg-[--hl-xs] aria-selected:focus:bg-[--hl-sm] aria-selected:hover:bg-[--hl-sm] focus:bg-[--hl-sm] transition-colors duration-300'
id='params'
>
<span>Parameters</span>
<span>Params</span>
{parametersCount > 0 && (
<span className='p-1 min-w-6 h-6 flex items-center justify-center text-xs rounded-lg border border-solid border-[--hl]'>
{parametersCount}
Expand Down

0 comments on commit 1b123bf

Please sign in to comment.