Skip to content

Commit

Permalink
fix: correct handling of the case where comparison scenario is not va…
Browse files Browse the repository at this point in the history
…lid for one side (#451)

Fixes #450
  • Loading branch information
chrispcampbell authored Mar 25, 2024
1 parent 9bbf693 commit a9d2e34
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 11 deletions.
9 changes: 9 additions & 0 deletions examples/sample-check-bundle/src/graphs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ export function getGraphSpecs(modelVersion: number, outputVars: Map<DatasetKey,

const graphSpecs: BundleGraphSpec[] = []
for (let i = 1; i <= 8; i++) {
if (i === 1 && modelVersion === 1) {
// Simulate the case where a graph is not included in version 1 but is added
// in version 2
continue
} else if (i === 2 && modelVersion === 2) {
// Simulate the case where a graph is included in version 1 but is removed
// in version 2
continue
}
graphSpecs.push(graphSpec(`${i}`, `Sample Graph ${i}`))
}

Expand Down
19 changes: 19 additions & 0 deletions examples/sample-check-tests/src/comparisons/comparisons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,36 @@
#
# Variable does not exist in left or right (unknown input)
- scenario:
id: input_q_at_90
title: Input Q (unknown)
subtitle: at 90
with: Input Q
at: 90

# Variable exists in left+right, but value is invalid in left+right
- scenario:
id: input_a_at_666
title: Input A
subtitle: at 666
with: Input A
at: 666

# Scenario group that includes error scenarios from above
- scenario_group:
id: G1
title: Scenario Group 3
scenarios:
- scenario_ref: input_q_at_90
- scenario_ref: input_a_at_666

# View group refers to scenario that has unknown inputs
- view_group:
title: Group 3 (errors are expected)
scenarios:
- scenario_group_ref: G1
graphs:
- '3'
- '4'
# TODO: Input ID exists in both left and right, but with different variable names

# TODO: Input ID exists in both left and right, but with different min/max
16 changes: 14 additions & 2 deletions packages/check-ui-shell/src/components/graphs/context-graph-vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,26 @@ export class ContextGraphViewModel {
this.datasetClass = `dataset-color-${bundle === 'right' ? '1' : '0'}`
if (graphSpec) {
const scenarioSpec = bundle === 'right' ? scenario.specR : scenario.specL
this.linkItems = b.model.getGraphLinksForScenario(scenarioSpec, graphSpec.id)
this.requestKey = `context-graph::${requestId++}::${bundle}::${graphSpec.id}::${scenario.key}`
if (scenarioSpec !== undefined) {
this.linkItems = b.model.getGraphLinksForScenario(scenarioSpec, graphSpec.id)
this.requestKey = `context-graph::${requestId++}::${bundle}::${graphSpec.id}::${scenario.key}`
} else {
this.linkItems = []
}
this.writableContent = writable(undefined)
this.content = this.writableContent
}
}

requestData(): void {
if (this.requestKey === undefined) {
// The request key is undefined when the scenario is invalid or unavailable for the
// requested side; in this case, we can set the flags and return early
this.dataRequested = true
this.dataLoaded = true
return
}

if (this.dataRequested) {
return
}
Expand Down
24 changes: 15 additions & 9 deletions packages/check-ui-shell/src/components/graphs/context-graph.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,20 @@ include context-graph.pug
+if('viewModel.graphSpec')
.graph-and-info
.graph-title(class!='{viewModel.datasetClass}') { @html viewModel.graphSpec.title }
.graph-container
Lazy(bind:visible!='{visible}')
+if('$content')
Graph(viewModel!='{$content.graphData}' config!='{graphConfig}')
Legend(graphSpec!='{viewModel.graphSpec}')
+links
+if('viewModel.requestKey')
.graph-container
Lazy(bind:visible!='{visible}')
+if('$content && $content.graphData')
Graph(viewModel!='{$content.graphData}' config!='{graphConfig}')
Legend(graphSpec!='{viewModel.graphSpec}')
+links
+else
.message.not-shown
span Graph not shown: scenario is invalid in&nbsp;
span(class!='{viewModel.datasetClass}') { viewModel.bundleName }
+else
.message
span Not included in&nbsp;
.message.not-included
span Graph not included in&nbsp;
span(class!='{viewModel.datasetClass}') { viewModel.bundleName }

</template>
Expand Down Expand Up @@ -122,8 +127,9 @@ $graph-height: 20rem
min-height: $graph-height
align-items: center
justify-content: center
background-color: #555
color: #aaa
&.not-included
background-color: #555
.link-container
display: flex
Expand Down

0 comments on commit a9d2e34

Please sign in to comment.