Add snapshot tests for sequence-diagram package#2
Merged
Conversation
Co-authored-by: kanushka <24244523+kanushka@users.noreply.github.com>
Co-authored-by: kanushka <24244523+kanushka@users.noreply.github.com>
Co-authored-by: kanushka <24244523+kanushka@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix issue with snapshot test for sequence diagram
Add snapshot tests for sequence-diagram package
Oct 16, 2025
kanushka
approved these changes
Oct 16, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The sequence-diagram package was missing snapshot tests for regression testing, unlike its sibling packages bi-diagram and component-diagram which already have comprehensive snapshot test coverage (see issues wso2#1391 and wso2#1392).
Solution
This PR adds snapshot tests for the sequence-diagram package following the same approach used in bi-diagram and component-diagram packages.
Changes
Testing Infrastructure
jest.config.jswith proper module resolution for workspace packages (@wso2/ui-toolkit, @wso2/ballerina-core, @wso2/syntax-tree)babel.config.jsfor transpiling TypeScript and React codejest.env.tsandmatchMedia.ts) to mock browser APIs (ResizeObserver, canvas context, getBoundingClientRect)Test Implementation
Created
src/test/Diagram.test.tsxwith 10 comprehensive snapshot tests covering:The test implementation:
src/test/__snapshots__/Diagram.test.tsx.snapTest Data
Added
sample-with-return.jsontest data file from the issue description, which includes:Results
✅ All 10 tests pass successfully
✅ Tests run in ~13.6 seconds
✅ Snapshots properly generated (197KB snapshot file)
✅ Test scripts added:
test,test:watch,test:updateSnapshotsExample Test Output
This implementation ensures consistency with the existing test patterns in bi-diagram and component-diagram packages, enabling regression testing for the sequence-diagram component.
Fixes wso2#1394
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
downloads.sentry-cdn.comesm.ubuntu.comIf you need me to access, download, or install something from one of these locations, you can either:
Original prompt
let's fix this issue. @wso2/product-ballerina-integratorwso2/issues/1394 use these PRs and use same approach to create snapshot test
@wso2/product-ballerina-integratorwso2/issues/1391
@wso2/product-ballerina-integratorwso2/issues/1392
this is sample seaquance diagram input
{
"participants": [
{
"id": "33785",
"name": "httpClient",
"kind": "ENDPOINT",
"moduleName": "test_sample",
"location": {
"fileName": "connections.bal",
"startLine": {
"line": 2,
"offset": 0
},
"endLine": {
"line": 2,
"offset": 57
}
},
"viewState": {
"bBox": {
"x": 440,
"y": 0,
"h": 40,
"w": 160
},
"xIndex": 2,
"lifelineHeight": 99
}
},
{
"id": "37174",
"name": "get",
"kind": "FUNCTION",
"moduleName": "test_sample",
"nodes": [
{
"interactionType": "ENDPOINT_CALL",
"targetId": "33785",
"kind": "INTERACTION",
"properties": {
"name": {
"type": "string",
"value": "get"
},
"expr": {
"type": "http:Client",
"value": "httpClient"
},
"params": [
{
"type": "string",
"value": ""path""
}
],
"value": {
"type": "json|http:ClientError",
"value": "var1"
}
},
"location": {
"fileName": "main.bal",
"startLine": {
"line": 7,
"offset": 30
},
"endLine": {
"line": 7,
"offset": 53
}
},
"viewStates": [
{
"callNodeId": "participant-37174",
"bBox": {
"x": 0,
"y": 0,
"h": 0,
"w": 0
},
"points": {
"start": {
"bBox": {
"x": 220,
"y": 68,
"h": 20,
"w": 20
},
"participantId": "37174"
},
"end": {
"bBox": {
"x": 440,
"y": 68,
"h": 20,
"w": 20
},
"participantId": "33785"
},
"returnStart": {
"bBox": {
"x": 440,
"y": 96,
"h": 20,
"w": 20
},
"participantId": "33785"
},
"returnEnd": {
"bBox": {
"x": 220,
"y": 96,
"h": 20,
"w": 20
},
"participantId": "37174"
}
}
}
]
},
{
"kind": "RETURN",
"branches": [],
"properties": {
"value": {
"type": "http:BadRequest"
}
},
"location": {
...
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.