0373bb578b
* [INS-1697] Create WebSocket Request (#5041)
* add fail safe
Co-authored-by: Mark Kim <mark.kim@konghq.com>
* Websockets IPC API (#5044)
* add url to ws-request model
* fix webSocketRequest typo and add url
* add websocket api and expose it through preload ipc
* add typings
Co-authored-by: Mark Kim <mark.kim@konghq.com>
* [INS-1701] Create/Close Websocket Connection (#5046)
* add websocket action bar and its components
* remove comments
* clean up
* reflect on the electron api
* remove unused files
* import name change
* add styling
* remove commet
* add suggested changes
* remove default value
* Add WebSocketRequest to sidebar and update types (#5048)
* [INS-1700] Delete Websocket Request (#5055)
* add websocket actions dropdown
* add actions to websocket request in sidebar
* [INS-1703] Display WebSocket messages - first pass (#5054)
* Update event types to improve inference
* Update websocket response pane to fetch/subscribe and display the events
* [INS-1693] Add WS echo server for smoke tests (#5050)
Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>
* fix sidebar unit tests (#5064)
* [INS-1776] adds `ws` dependency explicitly (#5066)
* [INS-1702] WebSocket Send Message (#5052)
* add initial changes for websocket message
* add abstraction for db operation and websocket operation
* remove console
* add rename
* add basic testing
* add basic testing
* add unit tests
* add form event type
* add comments
* disallow exporting context directly
* add suggested changes
* refresh the query
* using useDeepCompareEffect
* rename variable
* add mock
* clean up
* clean up
* correct the file name
* add some changes
* removing nedb-context and its hooks
* remove database changes for event sending
* [INS-1778] Fix Global Module Typing Issue (#5065)
* fix typings
* add jest import
* [INS-1703] View WebSocket Messages (#5074)
* save changes
* add styles and move files around
* remove unused code
* clean up some components
* add clean up
* add timestamp component
* add unit tests
* add case
* add style changes
* [INS-1786] WebSocket headers tab (#5080)
* first ui pass
* extract and wire up bulk editor
* raise ready state, move send
* add upgrade header debug logs
* can pass header to websocket upgrade
* implement readOnly headers
* add upgrade event and sent headers
* clean up
* fill out http upgrade into the event
* change upgrade message
* read only headers while connected
* remove upgrade event
* revert bulk editor change
* fix header editable toggle
* add nunjucks todos
* improve readOnly implementation
* disable codemirror/nunjucks for websocket headers
* take calculated headers out of the data model
* move hardcoded default headers down the tree
* fix request url rendering issue
* removed spammy warning
* clarify prop name
* refine pair typing
* change placeholder
* remove readOnly header property
* fix readOnly header layout
* Update packages/insomnia/src/ui/components/dropdowns/websocket-request-actions-dropdown.tsx
* Show HTTP->WS upgrade (handshake) (#5091)
* first pass as event
* add handshake ui
* add timeline tab
* simplify ResponseTimelineViewer
* transform res debug modal to change timeline props
* decouple timeline fetching from timeline component
* timeline ui pass
* record headers in request and response models
* can view timeline history
* write timeline to file
* some timeline
* can persist event logs
* put interface beside usage
* add note
* add event log history
* remove table event row
* tidying up
* make ws colors match
* enable multiple open connections
* close open connections at app exit
* remove old test
* Update packages/insomnia/src/models/request-version.ts
* fix type
* default readystate
* fix preview css scroll
Co-authored-by: James Gatz <jamesgatzos@gmail.com>
* INS-1788: Add control flow to improve responsiveness. (#5094)
* INS-1788: Add control flow for responsiveness.
This prevents events from flooding the UI thread entirely.
* Add additional code comments.
* fixup: webSocketEvent -> webSocketEvents
* display response headers (#5102)
* Show errors in timeline (#5100)
* remove unused context provider
* show errors in event tab
* updates timeline with message and close
* clean up
* show errors in timeline
* fix WebSocket capitalisation
* make timeline reader specific to ws
* write outbound messages to the timeline
* fix type
* Make the head row sticky in the events table (#5103)
* Add client certificate support to websocket connections (#5112)
* [INS-1810] close connection on response change (#5104)
* close ws connection when response is changed
* add delete logic for the queue mapg
* set error response to active response
* useRef for CodeEditor
* extract closeRequest
* use requestId to eliminate inconsistencies
* refactor extract clean up methods
* timeline feedback
* change type annotation
* fix type
* Revert "use requestId to eliminate inconsistencies"
This reverts commit
|
||
---|---|---|
.. | ||
cli | ||
fixtures | ||
playwright | ||
server | ||
tests | ||
.eslintignore | ||
.eslintrc.js | ||
.gitignore | ||
.npmrc | ||
jest.config.js | ||
package-lock.json | ||
package.json | ||
playwright.config.ts | ||
README.md | ||
tsconfig.build.json | ||
tsconfig.json |
Insomnia Smoke Tests
This project contains the smoke testing suite for Insomnia and Inso.
Tests for the Electron app are written using Playwright while tests for the CLI use execa.
Structure
Folder | Purpose |
---|---|
/cli |
tests for inso |
/tests |
tests for Insomnia |
/playwright |
test helpers |
/server |
Express server used by the tests |
/fixtures |
data used by tests and the server |
Run Insomnia smoke tests
Development method
In one terminal run the watcher
npm run watch:app # Run watcher
In a second terminal run/debug/step through smoke tests
# Run tests
npm run test:smoke:dev
# Run individual tests
npm run test:smoke:dev -- oauth
# Debug tests with playwright logs
DEBUG=pw:api npm run test:smoke:dev
# Debug tests with insomnia console logs
DEBUG=pw:browser npm run test:smoke:dev
# Debug tests with webserver console logs
DEBUG=pw:WebServer npm run test:smoke:dev
# Step through tests with playwright inspector
PWDEBUG=1 npm run test:smoke:dev
Build and package methods
It's possible to run the smoke tests for:
- A
build
, the JS bundle that is loaded into an electron client - A
package
, the executable binary (e.g..dmg
or.exe
)
For build
:
# Transpile js bundle
npm run app-build
# Run tests
npm run test:smoke:build
For package
:
# Build executable in /packages/insomnia/dist
npm run app-package
# Run tests
npm run test:smoke:package
Each of the above commands will automatically run the Express server, so you do not need to take any extra steps.
Show trace viewer
Each time you run a playwright test a trace.zip will be generated, this is useful for debugging CI. docs
# Open a trace viewer for a given test output
npx playwright show-trace packages/insomnia-smoke-test/screenshots/app-can-send-requests/trace.zip
# Alternatively you can upload this trace to https://trace.playwright.dev/
Using the Playwright VS Code extension
You can also use the playwright extension to run and debug tests directly from VS Code.
With the extension installed, in a terminal, run the watcher
npm run watch:app
You can now run and debug playwright tests, either from the Testing
tab, or by going into one of the test files and clicking the run button.
If no tests appear, you may need to run "Refresh playwright tests". This can be done from the command palette, or by using the button at the top of the Testing
tab.
Run Inso CLI smoke tests
# Package the Inso CLI binaries
npm run inso-package
# Run CLI tests
npm run test:smoke:cli
Write Inso CLI smoke tests
In order to run CLI tests for development, open two terminal tabs in packages/insomnia-smoke-test
:
# In the first tab, serve the Express API
npm run serve
# In the second tab, run the Inso CLI tests
npm run cli
This will allow you to write and monitor the server separately from each test, speeding up the development cycle.
Debug Inso CLI api test in watch mode
This is helpful for debugging failing api tests and changing the send-request abstraction
From project root, in seperate terminals:
# start smoke test api
npm run serve --prefix packages/insomnia-smoke-test
# build send-request
npm run build:sr --prefix packages/insomnia
# watch inso
npm run start --prefix packages/insomnia-inso
# run api test
$PWD/packages/insomnia-inso/bin/inso run test "Echo Test Suite" --src $PWD/packages/insomnia-smoke-test/fixtures/inso-nedb --env Dev --verbose
General guidelines
Data
Individual tests will automatically run against a clean Insomnia data directory to keep data isolated.
Dependencies
A test should not depend on any external services unless absolutely necessary. If a particular endpoint is required (eg. for authentication or a specific content type), implement a new endpoint in /server
.
Working with fixtures
How to update the inso-nedb fixture
In order to update the inso-nedb fixutre you need to launch Insomnia using the inso-nedb directory. To do this, set the INSOMNIA_DATA_PATH environment variable and launch from the command line.
MacOS
INSOMNIA_DATA_PATH=packages/insomnia-smoke-test/fixtures/inso-nedb /Applications/Insomnia.app/Contents/MacOS/Insomnia
Linux
TODO
Windows
TODO
After making your changes, be sure to relaunch the app one more time from the command line, so that Insomnia compacts the database. The .gitignore file will explicity ignore certain database files, to keep the directory size down and avoid prevent data leakage in case you are signed in to the app when launching with this database.
How to run inso with the inso-nedb fixture locally?
Set the --src packages/insomnia-smoke-test/fixtures/inso-nedb
flag
# if installed globally
inso --src ...
# using the package bin
./packages/insomnia-inso/bin/inso --src ...
# using a binary
./packages/insomnia-inso/binaries/insomnia-inso --src ...