Fixup old tests

This commit is contained in:
Ladd Hoffman 2023-01-26 11:36:39 -06:00
parent 4789ed7499
commit db8a8ca346
6 changed files with 22 additions and 23 deletions

View File

@ -6,6 +6,7 @@ export class Action {
async log(src, dest, msg, obj, symbol = '->>') { async log(src, dest, msg, obj, symbol = '->>') {
const logObj = false; const logObj = false;
if (this.scene.sequence) {
await this.scene.sequence.log( await this.scene.sequence.log(
`${src.name} ${symbol} ${dest.name} : ${this.name} ${msg ?? ''} ${ `${src.name} ${symbol} ${dest.name} : ${this.name} ${msg ?? ''} ${
logObj && obj ? JSON.stringify(obj) : '' logObj && obj ? JSON.stringify(obj) : ''
@ -13,3 +14,4 @@ export class Action {
); );
} }
} }
}

View File

@ -44,7 +44,7 @@ export class Graph {
} }
const vertex = new Vertex(data); const vertex = new Vertex(data);
this.vertices.set(id, vertex); this.vertices.set(id, vertex);
if (this.scene.flowchart) { if (this.scene && this.scene.flowchart) {
this.scene.flowchart.log(`${id}[${label ?? id}]`); this.scene.flowchart.log(`${id}[${label ?? id}]`);
} }
return this; return this;

View File

@ -89,7 +89,7 @@ export class Scene {
async addActor(name) { async addActor(name) {
const actor = new Actor(name, this); const actor = new Actor(name, this);
if (this.sequence) { if (this.sequence) {
await this.scene.sequence.log(`participant ${name}`); await this.sequence.log(`participant ${name}`);
} }
return actor; return actor;
} }

View File

@ -18,7 +18,6 @@
<h3>Tertiary</h3> <h3>Tertiary</h3>
<ul> <ul>
<li><a href="./tests/basic.html">Basic</a></li> <li><a href="./tests/basic.html">Basic</a></li>
<li><a href="./tests/mermaid.html">Mermaid</a></li>
<li><a href="./tests/graph.html">Graph</a></li> <li><a href="./tests/graph.html">Graph</a></li>
<li><a href="./tests/debounce.html">Debounce</a></li> <li><a href="./tests/debounce.html">Debounce</a></li>
<li><a href="./tests/flowchart.html">Flowchart</a></li> <li><a href="./tests/flowchart.html">Flowchart</a></li>

View File

@ -26,14 +26,14 @@
} }
if (true) { if (true) {
const scene = new Scene('Scene 1', rootBox); const scene = new Scene('Scene 1', rootBox).withSequenceDiagram();
const webClientStatus = scene.addDisplayValue('WebClient Status'); const webClientStatus = scene.addDisplayValue('WebClient Status');
const node1Status = scene.addDisplayValue('Node 1 Status'); const node1Status = scene.addDisplayValue('Node 1 Status');
const blockchainStatus = scene.addDisplayValue('Blockchain Status'); const blockchainStatus = scene.addDisplayValue('Blockchain Status');
const webClient = scene.addActor('web client'); const webClient = await scene.addActor('web client');
const node1 = scene.addActor('node 1'); const node1 = await scene.addActor('node 1');
const blockchain = scene.addActor('blockchain'); const blockchain = await scene.addActor('blockchain');
const requestForumPage = scene.addAction('requestForumPage'); const requestForumPage = scene.addAction('requestForumPage');
const readBlockchainData = scene.addAction('readBlockchainData'); const readBlockchainData = scene.addAction('readBlockchainData');
const blockchainData = scene.addAction('blockchainData'); const blockchainData = scene.addAction('blockchainData');
@ -76,19 +76,19 @@
} }
(async function run() { (async function run() {
const scene = new Scene('Scene 2', rootBox); const scene = new Scene('Scene 2', rootBox).withSequenceDiagram();
const webClient = scene.addActor('webClient'); const webClient = await scene.addActor('webClient');
const nodes = []; const nodes = [];
const memories = []; const memories = [];
const storages = []; const storages = [];
function addNode() { async function addNode() {
const idx = nodes.length; const idx = nodes.length;
const node = scene.addActor(`node${idx}`); const node = await scene.addActor(`node${idx}`);
const memory = scene.addActor(`memory${idx}`); const memory = await scene.addActor(`memory${idx}`);
const storage = scene.addActor(`storage${idx}`); const storage = await scene.addActor(`storage${idx}`);
node.memory = memory; node.memory = memory;
node.storage = storage; node.storage = storage;
nodes.push(node); nodes.push(node);
@ -103,8 +103,8 @@
return peers[idx]; return peers[idx];
} }
addNode(); await addNode();
addNode(); await addNode();
const [ const [
seekTruth, seekTruth,

View File

@ -19,9 +19,7 @@
const rootElement = document.getElementById('forum-network'); const rootElement = document.getElementById('forum-network');
const rootBox = new Box('rootBox', rootElement).flex(); const rootBox = new Box('rootBox', rootElement).flex();
window.scene = new Scene('Forum Network test', rootBox).log( window.scene = new Scene('Forum Network test', rootBox).withSequenceDiagram();
'sequenceDiagram',
);
window.author1 = await new Expert('author1', window.scene).initialize(); window.author1 = await new Expert('author1', window.scene).initialize();
window.author2 = await new Expert('author2', window.scene).initialize(); window.author2 = await new Expert('author2', window.scene).initialize();