@advanced-rest-client/api-console-extension
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -27,5 +27,2 @@ { | ||
}, | ||
"permissions": [ | ||
"tabs" | ||
], | ||
"host_permissions": [ | ||
@@ -32,0 +29,0 @@ "http://*/*", |
{ | ||
"name": "@advanced-rest-client/api-console-extension", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "API Console extension to proxy HTTP requests to the documented API.", | ||
@@ -37,3 +37,3 @@ "type": "module", | ||
"@playwright/test": "^1.22.2", | ||
"@types/chrome": "^0.0.190", | ||
"@types/chrome": "^0.0.200", | ||
"@web/dev-server": "^0.1.31", | ||
@@ -40,0 +40,0 @@ "eslint": "^8.13.0", |
@@ -35,7 +35,5 @@ import { test as base, chromium, expect } from '@playwright/test'; | ||
test('initializes the app through the content script', async ({ page }) => { | ||
// page.on('console', console.log) | ||
await page.goto('./index.html'); | ||
const attr = await page.locator('#request').getAttribute('hidden'); | ||
expect(attr).toBeNull(); | ||
console.log(page.context().serviceWorkers()); | ||
}); | ||
@@ -128,2 +126,28 @@ }); | ||
}); | ||
test('proxies a File request', async () => { | ||
const response = /** @type IApiConsoleHttpResponse */ (await proxy.proxyEvent('https://httpbin.org/post', 'POST', 'x-test: test-value\ncontent-type: text/plain', 'File')); | ||
expect(response).toHaveProperty('responseData'); | ||
expect(response).toHaveProperty('stats'); | ||
expect(response).toHaveProperty('id'); | ||
expect(response).toHaveProperty('request'); | ||
const { stats, request } = response; | ||
const data = /** @type IApiConsoleHttpResponseData */ (response.responseData); | ||
expect(data).toHaveProperty('response'); | ||
expect(data).toHaveProperty('responseText'); | ||
expect(data).toHaveProperty('responseType', 'text'); | ||
expect(data).toHaveProperty('responseURL', 'https://httpbin.org/post'); | ||
expect(data).toHaveProperty('status', 200); | ||
expect(data).toHaveProperty('statusText'); | ||
expect(data).toHaveProperty('headers'); | ||
expect(stats).toHaveProperty('loadingTime'); | ||
expect(stats).toHaveProperty('startTime'); | ||
expect(request).toHaveProperty('id', response.id); | ||
expect(request).toHaveProperty('url', 'https://httpbin.org/post'); | ||
const body = JSON.parse(data.response); | ||
const headers = new Headers(body.headers) | ||
expect(headers.get('x-test')).toEqual('test-value'); | ||
expect(headers.get('content-type')).toContain('text/plain'); | ||
expect(body.data).toEqual('test file contents'); | ||
}); | ||
}); | ||
@@ -130,0 +154,0 @@ |
@@ -43,3 +43,3 @@ /** @typedef {import('../../src/types').ISafePayload} ISafePayload */ | ||
const result = await this.page.evaluate(([url, method, headers, payload]) => { | ||
/** @type string | ISafePayload | FormData | undefined */ | ||
/** @type string | ISafePayload | FormData | File | undefined */ | ||
let finalPayload = payload; | ||
@@ -50,2 +50,5 @@ if (finalPayload === 'FormData') { | ||
finalPayload.set('file-field', new File(['file value'], 'file.txt', { type: 'text/plain' })); | ||
} else if (finalPayload === 'File') { | ||
const contents = new Blob(['test file contents'], { type: 'text/plain' }); | ||
finalPayload = new File([contents], 'contents.txt'); | ||
} | ||
@@ -52,0 +55,0 @@ const e = new CustomEvent('api-request', { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
223261
3078