collab/mermaid/cypress/integration/rendering/c4.spec.jsblame
View source
6dd74de1import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
6dd74de2
6dd74de3describe('C4 diagram', () => {
6dd74de4 it('C4.1 should render a simple C4Context diagram', () => {
6dd74de5 imgSnapshotTest(
6dd74de6 `
6dd74de7 C4Context
6dd74de8 accTitle: C4 context demo
6dd74de9 accDescr: Many large C4 diagrams
6dd74de10
6dd74de11 title System Context diagram for Internet Banking System
6dd74de12
6dd74de13 Enterprise_Boundary(b0, "BankBoundary0") {
6dd74de14 Person(customerA, "Banking Customer A", "A customer of the bank, with personal bank accounts.")
6dd74de15
6dd74de16 System(SystemAA, "Internet Banking System", "Allows customers to view information about their bank accounts, and make payments.")
6dd74de17
6dd74de18 Enterprise_Boundary(b1, "BankBoundary") {
6dd74de19 System_Ext(SystemC, "E-mail system", "The internal Microsoft Exchange e-mail system.")
6dd74de20 }
6dd74de21 }
6dd74de22
6dd74de23 BiRel(customerA, SystemAA, "Uses")
6dd74de24 Rel(SystemAA, SystemC, "Sends e-mails", "SMTP")
6dd74de25 Rel(SystemC, customerA, "Sends e-mails to")
6dd74de26
6dd74de27 UpdateElementStyle(customerA, $fontColor="red", $bgColor="grey", $borderColor="red")
6dd74de28 UpdateRelStyle(customerA, SystemAA, $textColor="blue", $lineColor="blue", $offsetX="5")
6dd74de29 UpdateRelStyle(SystemC, customerA, $textColor="red", $lineColor="red", $offsetX="-50", $offsetY="20")
6dd74de30 `,
6dd74de31 {}
6dd74de32 );
6dd74de33 });
6dd74de34 it('C4.2 should render a simple C4Container diagram', () => {
6dd74de35 imgSnapshotTest(
6dd74de36 `
6dd74de37 C4Container
6dd74de38 title Container diagram for Internet Banking System
6dd74de39
6dd74de40 System_Ext(email_system, "E-Mail System", "The internal Microsoft Exchange system", $tags="v1.0")
6dd74de41 Person(customer, Customer, "A customer of the bank, with personal bank accounts", $tags="v1.0")
6dd74de42
6dd74de43 Container_Boundary(c1, "Internet Banking") {
6dd74de44 Container(spa, "Single-Page App", "JavaScript, Angular", "Provides all the Internet banking functionality to customers via their web browser")
6dd74de45 }
6dd74de46
6dd74de47 Rel(customer, spa, "Uses", "HTTPS")
6dd74de48 Rel(email_system, customer, "Sends e-mails to")
6dd74de49 `,
6dd74de50 {}
6dd74de51 );
6dd74de52 });
6dd74de53 it('C4.3 should render a simple C4Component diagram', () => {
6dd74de54 imgSnapshotTest(
6dd74de55 `
6dd74de56 C4Component
6dd74de57 title Component diagram for Internet Banking System - API Application
6dd74de58
6dd74de59 Container(spa, "Single Page Application", "javascript and angular", "Provides all the internet banking functionality to customers via their web browser.")
6dd74de60
6dd74de61 Container_Boundary(api, "API Application") {
6dd74de62 Component(sign, "Sign In Controller", "MVC Rest Controller", "Allows users to sign in to the internet banking system")
6dd74de63 }
6dd74de64
6dd74de65 Rel_Back(spa, sign, "Uses", "JSON/HTTPS")
6dd74de66 UpdateRelStyle(spa, sign, $offsetY="-40")
6dd74de67 `,
6dd74de68 {}
6dd74de69 );
6dd74de70 });
6dd74de71 it('C4.4 should render a simple C4Dynamic diagram', () => {
6dd74de72 imgSnapshotTest(
6dd74de73 `
6dd74de74 C4Dynamic
6dd74de75 title Dynamic diagram for Internet Banking System - API Application
6dd74de76
6dd74de77 ContainerDb(c4, "Database", "Relational Database Schema", "Stores user registration information, hashed authentication credentials, access logs, etc.")
6dd74de78 Container(c1, "Single-Page Application", "JavaScript and Angular", "Provides all of the Internet banking functionality to customers via their web browser.")
6dd74de79 Container_Boundary(b, "API Application") {
6dd74de80 Component(c3, "Security Component", "Spring Bean", "Provides functionality Related to signing in, changing passwords, etc.")
6dd74de81 Component(c2, "Sign In Controller", "Spring MVC Rest Controller", "Allows users to sign in to the Internet Banking System.")
6dd74de82 }
6dd74de83 Rel(c1, c2, "Submits credentials to", "JSON/HTTPS")
6dd74de84 Rel(c2, c3, "Calls isAuthenticated() on")
6dd74de85 Rel(c3, c4, "select * from users where username = ?", "JDBC")
6dd74de86
6dd74de87 UpdateRelStyle(c1, c2, $textColor="red", $offsetY="-40")
6dd74de88 UpdateRelStyle(c2, c3, $textColor="red", $offsetX="-40", $offsetY="60")
6dd74de89 UpdateRelStyle(c3, c4, $textColor="red", $offsetY="-40", $offsetX="10")
6dd74de90 `,
6dd74de91 {}
6dd74de92 );
6dd74de93 });
6dd74de94 it('C4.5 should render a simple C4Deployment diagram', () => {
6dd74de95 imgSnapshotTest(
6dd74de96 `
6dd74de97 C4Deployment
6dd74de98 title Deployment Diagram for Internet Banking System - Live
6dd74de99
6dd74de100 Deployment_Node(mob, "Customer's mobile device", "Apple IOS or Android"){
6dd74de101 Container(mobile, "Mobile App", "Xamarin", "Provides a limited subset of the Internet Banking functionality to customers via their mobile device.")
6dd74de102 }
6dd74de103
6dd74de104 Deployment_Node(plc, "Big Bank plc", "Big Bank plc data center"){
6dd74de105 Deployment_Node(dn, "bigbank-api*** x8", "Ubuntu 16.04 LTS"){
6dd74de106 Deployment_Node(apache, "Apache Tomcat", "Apache Tomcat 8.x"){
6dd74de107 Container(api, "API Application", "Java and Spring MVC", "Provides Internet Banking functionality via a JSON/HTTPS API.")
6dd74de108 }
6dd74de109 }
6dd74de110 }
6dd74de111
6dd74de112 Rel(mobile, api, "Makes API calls to", "json/HTTPS")
6dd74de113 `,
6dd74de114 {}
6dd74de115 );
6dd74de116 });
6dd74de117 it('C4.6 should render C4Context diagram with ComponentQueue_Ext', () => {
6dd74de118 imgSnapshotTest(
6dd74de119 `
6dd74de120 C4Context
6dd74de121 title System Context diagram with ComponentQueue_Ext
6dd74de122
6dd74de123 Enterprise_Boundary(b0, "BankBoundary0") {
6dd74de124 Person(customerA, "Banking Customer A", "A customer of the bank, with personal bank accounts.")
6dd74de125
6dd74de126 System(SystemAA, "Internet Banking System", "Allows customers to view information about their bank accounts, and make payments.")
6dd74de127
6dd74de128 Enterprise_Boundary(b1, "BankBoundary") {
6dd74de129 ComponentQueue_Ext(msgQueue, "Message Queue", "RabbitMQ", "External message queue system for processing banking transactions")
6dd74de130 System_Ext(SystemC, "E-mail system", "The internal Microsoft Exchange e-mail system.")
6dd74de131 }
6dd74de132 }
6dd74de133
6dd74de134 BiRel(customerA, SystemAA, "Uses")
6dd74de135 Rel(SystemAA, msgQueue, "Sends messages to")
6dd74de136 Rel(SystemAA, SystemC, "Sends e-mails", "SMTP")
6dd74de137 `,
6dd74de138 {}
6dd74de139 );
6dd74de140 });
6dd74de141});