This repository has been archived by the owner on Feb 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for inspecting via websocket (#293)
* Add support for inspecting via websocket * Create URLSearchParams only on client side * Add changeset * Refactor inspector proxy into service config Refactor receiver ref into context * Add todo tests * Draft test for simulation machine * Combine inspecting substates and query params * Update changeset * Remove receiverRef from context * Clean up diff * Update .changeset/brave-shoes-flow.md Co-authored-by: Mateusz Burzyński <[email protected]>
- Loading branch information
1 parent
632f950
commit 67e24ae
Showing
3 changed files
with
61 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'xstate-viz-app': minor | ||
--- | ||
|
||
You can now inspect via WebSocket. To do that you can add the WebSocket server url as a query parameter, for example `https://stately.ai/viz?inspect&server=ws://localhost:3000` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { interpret } from 'xstate'; | ||
import { simulationMachine } from '../simulationMachine'; | ||
|
||
describe('simulationMachine', () => { | ||
const service = interpret(simulationMachine); | ||
afterEach(() => service.stop()); | ||
|
||
describe('UrlSearchParams', () => { | ||
const paramsGetSpy = jest.spyOn(URLSearchParams.prototype, 'get'); | ||
const paramsHasSpy = jest.spyOn(URLSearchParams.prototype, 'has'); | ||
|
||
describe('with no search params', () => { | ||
it('goes to state "visualizing"', () => { | ||
paramsGetSpy.mockReturnValue(null); | ||
paramsHasSpy.mockReturnValue(false); | ||
|
||
service.start(); | ||
|
||
expect(service.getSnapshot().matches('visualizing')).toBe(true); | ||
}); | ||
}); | ||
describe('with /viz?inspect', () => { | ||
it.todo('goes to state "inspecting"'); | ||
it.todo('creates a window receiver'); | ||
}); | ||
describe('with /viz?inspect&server=ws://localhost:8080', () => { | ||
it.todo('goes to state "inspecting"'); | ||
it.todo('creates a websocket receiver'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters