@@ -776,5 +776,194 @@ describe('Sequence Diagram Special Cases', () => {
776776 ) ;
777777 } ) ;
778778 } ) ;
779+
780+ describe ( 'Participant Stereotypes with Aliases' , ( ) => {
781+ it ( 'should render participants with stereotypes and aliases' , ( ) => {
782+ imgSnapshotTest (
783+ `sequenceDiagram
784+ participant API@{ "type" : "boundary" } as Public API
785+ participant Auth@{ "type" : "control" } as Auth Controller
786+ participant DB@{ "type" : "database" } as User Database
787+ participant Cache@{ "type" : "entity" } as Cache Layer
788+ API ->> Auth: Authenticate request
789+ Auth ->> DB: Query user
790+ DB -->> Auth: User data
791+ Auth ->> Cache: Store session
792+ Cache -->> Auth: Confirmed
793+ Auth -->> API: Token` ,
794+ { look : 'classic' , sequence : { diagramMarginX : 50 , diagramMarginY : 10 } }
795+ ) ;
796+ } ) ;
797+
798+ it ( 'should render actors with stereotypes and aliases' , ( ) => {
799+ imgSnapshotTest (
800+ `sequenceDiagram
801+ actor U@{ "type" : "actor" } as End User
802+ actor A@{ "type" : "boundary" } as API Gateway
803+ actor S@{ "type" : "control" } as Service Layer
804+ actor D@{ "type" : "database" } as Data Store
805+ U ->> A: Send request
806+ A ->> S: Process
807+ S ->> D: Persist
808+ D -->> S: Success
809+ S -->> A: Response
810+ A -->> U: Result` ,
811+ { look : 'classic' , sequence : { diagramMarginX : 50 , diagramMarginY : 10 } }
812+ ) ;
813+ } ) ;
814+
815+ it ( 'should render mixed participants and actors with stereotypes and aliases' , ( ) => {
816+ imgSnapshotTest (
817+ `sequenceDiagram
818+ actor Client@{ "type" : "actor" } AS Mobile Client
819+ participant Gateway@{ "type" : "boundary" } as API Gateway
820+ participant OrderSvc@{ "type" : "control" } as Order Service
821+ participant Queue@{ "type" : "queue" } as Message Queue
822+ participant DB@{ "type" : "database" } as Order Database
823+ participant Logs@{ "type" : "collections" } as Audit Logs
824+ Client ->> Gateway: Place order
825+ Gateway ->> OrderSvc: Validate order
826+ OrderSvc ->> Queue: Queue for processing as well
827+ OrderSvc ->> DB: Save order
828+ OrderSvc ->> Logs: Log transaction
829+ Queue -->> OrderSvc: Processing started AS Well
830+ DB -->> OrderSvc: Order saved
831+ Logs -->> OrderSvc: Logged
832+ OrderSvc -->> Gateway: Order confirmed
833+ Gateway -->> Client: Confirmation` ,
834+ { look : 'classic' , sequence : { diagramMarginX : 50 , diagramMarginY : 10 } }
835+ ) ;
836+ } ) ;
837+
838+ it ( 'should render stereotypes with aliases in boxes' , ( ) => {
839+ imgSnapshotTest (
840+ `sequenceDiagram
841+ box rgb(200,220,255) Frontend Layer
842+ actor User@{ "type" : "actor" } as End User
843+ participant UI@{ "type" : "boundary" } as User Interface
844+ end
845+ box rgb(255,220,200) Backend Layer
846+ participant API@{ "type" : "boundary" } as REST API
847+ participant Svc@{ "type" : "control" } as Business Logic
848+ end
849+ box rgb(220,255,200) Data Layer
850+ participant DB@{ "type" : "database" } as Primary DB
851+ participant Cache@{ "type" : "entity" } as Cache Store
852+ end
853+ User ->> UI: Click button
854+ UI ->> API: HTTP request
855+ API ->> Svc: Process
856+ Svc ->> Cache: Check cache
857+ Cache -->> Svc: Cache miss
858+ Svc ->> DB: Query data
859+ DB -->> Svc: Data
860+ Svc ->> Cache: Update cache
861+ Svc -->> API: Response
862+ API -->> UI: Data
863+ UI -->> User: Display` ,
864+ { look : 'classic' , sequence : { diagramMarginX : 50 , diagramMarginY : 10 } }
865+ ) ;
866+ } ) ;
867+
868+ it ( 'should render stereotypes with aliases and complex interactions' , ( ) => {
869+ imgSnapshotTest (
870+ `sequenceDiagram
871+ participant Web@{ "type" : "boundary" } as Web Portal
872+ participant Auth@{ "type" : "control" } as Auth Service
873+ participant UserDB@{ "type" : "database" } as User DB
874+ participant Queue@{ "type" : "queue" } as Event Queue
875+ participant Audit@{ "type" : "collections" } as Audit Trail
876+ Web ->> Auth: Login request
877+ activate Auth
878+ Auth ->> UserDB: Verify credentials
879+ activate UserDB
880+ UserDB -->> Auth: User found
881+ deactivate UserDB
882+ alt Valid credentials
883+ Auth ->> Queue: Publish login event
884+ Auth ->> Audit: Log success
885+ par Parallel processing
886+ Queue -->> Auth: Event queued
887+ and
888+ Audit -->> Auth: Logged
889+ end
890+ Auth -->> Web: Success token
891+ else Invalid credentials
892+ Auth ->> Audit: Log failure
893+ Audit -->> Auth: Logged
894+ Auth --x Web: Access denied
895+ end
896+ deactivate Auth
897+ Note over Web,Audit: All interactions logged` ,
898+ { look : 'classic' , sequence : { diagramMarginX : 50 , diagramMarginY : 10 } }
899+ ) ;
900+ } ) ;
901+ } ) ;
902+
903+ describe ( 'Participant Inline Alias in Config' , ( ) => {
904+ it ( 'should render participants with inline alias in config object' , ( ) => {
905+ imgSnapshotTest (
906+ `sequenceDiagram
907+ participant API@{ "type" : "boundary", "alias": "Public API" }
908+ participant Auth@{ "type" : "control", "alias": "Auth Service" }
909+ participant DB@{ "type" : "database", "alias": "User DB" }
910+ API ->> Auth: Login request
911+ Auth ->> DB: Query user
912+ DB -->> Auth: User data
913+ Auth -->> API: Token` ,
914+ { look : 'classic' , sequence : { diagramMarginX : 50 , diagramMarginY : 10 } }
915+ ) ;
916+ } ) ;
917+
918+ it ( 'should render actors with inline alias in config object' , ( ) => {
919+ imgSnapshotTest (
920+ `sequenceDiagram
921+ actor U@{ "type" : "actor", "alias": "End User" }
922+ actor G@{ "type" : "boundary", "alias": "Gateway" }
923+ actor S@{ "type" : "control", "alias": "Service" }
924+ U ->> G: Request
925+ G ->> S: Process
926+ S -->> G: Response
927+ G -->> U: Result` ,
928+ { look : 'classic' , sequence : { diagramMarginX : 50 , diagramMarginY : 10 } }
929+ ) ;
930+ } ) ;
931+
932+ it ( 'should handle mixed inline and external alias syntax' , ( ) => {
933+ imgSnapshotTest (
934+ `sequenceDiagram
935+ participant A@{ "type" : "boundary", "alias": "Service A" }
936+ participant B@{ "type" : "control" } as Service B
937+ participant C@{ "type" : "database" }
938+ A ->> B: Request
939+ B ->> C: Query
940+ C -->> B: Data
941+ B -->> A: Response` ,
942+ { look : 'classic' , sequence : { diagramMarginX : 50 , diagramMarginY : 10 } }
943+ ) ;
944+ } ) ;
945+
946+ it ( 'should prioritize external alias over inline alias' , ( ) => {
947+ imgSnapshotTest (
948+ `sequenceDiagram
949+ participant API@{ "type" : "boundary", "alias": "Internal Name" } as External Name
950+ participant DB@{ "type" : "database", "alias": "Internal DB" } AS External DB
951+ API ->> DB: Query
952+ DB -->> API: Result` ,
953+ { look : 'classic' , sequence : { diagramMarginX : 50 , diagramMarginY : 10 } }
954+ ) ;
955+ } ) ;
956+
957+ it ( 'should render inline alias with only alias field (no type)' , ( ) => {
958+ imgSnapshotTest (
959+ `sequenceDiagram
960+ participant API@{ "alias": "Public API" }
961+ participant Auth@{ "alias": "Auth Service" }
962+ API ->> Auth: Request
963+ Auth -->> API: Response` ,
964+ { look : 'classic' , sequence : { diagramMarginX : 50 , diagramMarginY : 10 } }
965+ ) ;
966+ } ) ;
967+ } ) ;
779968 } ) ;
780969} ) ;
0 commit comments