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,10 +6,12 @@ export class Action {
async log(src, dest, msg, obj, symbol = '->>') {
const logObj = false;
await this.scene.sequence.log(
`${src.name} ${symbol} ${dest.name} : ${this.name} ${msg ?? ''} ${
logObj && obj ? JSON.stringify(obj) : ''
}`,
);
if (this.scene.sequence) {
await this.scene.sequence.log(
`${src.name} ${symbol} ${dest.name} : ${this.name} ${msg ?? ''} ${
logObj && obj ? JSON.stringify(obj) : ''
}`,
);
}
}
}

View File

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

View File

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

View File

@ -18,7 +18,6 @@
<h3>Tertiary</h3>
<ul>
<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/debounce.html">Debounce</a></li>
<li><a href="./tests/flowchart.html">Flowchart</a></li>

View File

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

View File

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