Skip to content

Commit

Permalink
add method to detect opened sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
xzhou82 committed Jan 2, 2025
1 parent c7a0ef3 commit a6f2066
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
8 changes: 6 additions & 2 deletions client/mass/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,12 @@ export const plotInit = getCompInit(MassPlot)

function setRenderers(self) {
self.initUi = function (opts) {
const holder = opts.holder
// opts.holder is "sandbox" obj: {app_div, body, header, header_row, id}
// opts={app, chartType:str, holder, id, debug}

const holder = opts.holder // "sandbox" obj: {app_div, body, header, header_row, id}

// since chartType is already given in constructor opts, create test id with chart type as a simple way to identify the box
opts.holder.app_div.attr('data-testid', 'sjpp-massplot-sandbox-' + opts.chartType)

holder.header.style('padding', 0)

Expand Down
16 changes: 11 additions & 5 deletions client/mass/test/nav.integration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,27 @@ tape.only('chart buttons', function (test) {
}
}
})
function runTests(nav) {
async function runTests(nav) {
for (const btn of nav.Inner.components.charts.Inner.dom.btns._groups[0]) {
// btn is native dom element, not d3-wrapped
if (btn.style.display == 'none') {
// hidden button means the chart is not supported in termdbtest
continue
}
/* chart button is visible
evaluate what happens after clicking it, based on the type of chart
this test is hardcoded for termdbtest; any customizations to chart buttons must be reflected here
evaluate what happens after clicking it, based on the innerHTML of each button;
if a chart name is customized in termdbtest, the test must be updated here
must not trigger click before all if(), this will cause all previous temporary menu items to disappear
*/
if (btn.innerHTML == 'Data Dictionary') {
btn.dispatchEvent(new Event('click'))
// todo: identify if a new sandbox labeled "Data Dictionary" is created
await detectOne({
elem: nav.Inner.app.Inner.dom.plotDiv.node(),
selector: '[data-testid=sjpp-massplot-sandbox-dictionary]'
})
test.pass('dictionary sandbox found')
// todo: delete sandbox
continue
}
if (btn.innerHTML == 'Summary Plot') {
Expand All @@ -102,6 +107,7 @@ tape.only('chart buttons', function (test) {
console.log('TODO: need test cover for chart button', btn.innerHTML)
}
//if (test._ok) nav.Inner.app.destroy()
console.log(nav)
test.end()
}
})
Expand Down

0 comments on commit a6f2066

Please sign in to comment.