Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix perspective-workspace non-unique generated slotid bug #925

Merged
merged 1 commit into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/perspective-workspace/src/js/workspace/workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,11 @@ export class PerspectiveWorkspace extends DiscreteSplitPanel {
}

_gen_id() {
return `PERSPECTIVE_GENERATED_ID_${ID_COUNTER++}`;
let genId = `PERSPECTIVE_GENERATED_ID_${ID_COUNTER++}`;
if (this.element.querySelector(`[slot=${genId}]`)) {
genId = this._gen_id();
}
return genId;
}

_createNode(slotname) {
Expand Down
35 changes: 35 additions & 0 deletions packages/perspective-workspace/test/js/integration/restore.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,41 @@ utils.with_server({paths: PATHS}, () => {
},
{wait_for_update: false, timeout: 30000}
);

test.capture(
"restore workspace with viewers with generated slotids",

async page => {
const config = {
viewers: {
PERSPECTIVE_GENERATED_ID_0: {table: "superstore", name: "Test", "row-pivots": ["State"], columns: ["Sales", "Profit"]}
},
detail: {
main: {
currentIndex: 0,
type: "tab-area",
widgets: ["PERSPECTIVE_GENERATED_ID_0"]
}
}
};

await page.evaluate(config => {
const workspace = document.getElementById("workspace");
workspace.restore(config);
}, config);

await page.waitForSelector("perspective-workspace > perspective-viewer:not([updating])");

await page.evaluate(() => {
const workspace = document.getElementById("workspace").workspace;
const widget = workspace.getAllWidgets()[0];
workspace.duplicate(widget);
});

await page.waitForSelector("perspective-workspace > perspective-viewer:not([updating])");
},
{wait_for_update: false, timeout: 30000}
);
},
{root: TEST_ROOT}
);
Expand Down
5 changes: 3 additions & 2 deletions packages/perspective-workspace/test/results/linux.docker.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
"index_restore_workspace_with_detail_only": "1168e9bee0eec492dfd5f50b2e087d84",
"index_restore_workspace_with_master_only": "13ff739449bf9745d43f9af8bfc67c7c",
"index_restore_workspace_with_master_and_detail": "aafccad40bfe1a921c220da2a0e07a30",
"__GIT_COMMIT__": "362140e29c4b9ef392e3e3550dab1d09d2e7cc57",
"__GIT_COMMIT__": "ed38f93b69ace120dd6be13d68905b2b3c6bfa4f",
"index_HTML_Create_One": "9db49888a923c083fec35c90723fbf0f",
"index_HTML_Create_Multiple": "9bf849cb0f3d724baa79df4ccfedb913",
"index_HTML_Create_multiple_with_names": "0bed0974e891d51eb400070f99f78189",
"index_removeChild_Remove_One": "3d8e42bea464280934900433dde0d4de",
"index_appendChild_Create_One": "9db49888a923c083fec35c90723fbf0f",
"index_appendChild_Create_multiple": "418ec5fe318631be277300adbc0f958c",
"index_appendChild_With_name": "1168e9bee0eec492dfd5f50b2e087d84",
"index_appendChild_Without_slot": "9db49888a923c083fec35c90723fbf0f"
"index_appendChild_Without_slot": "9db49888a923c083fec35c90723fbf0f",
"index_restore_workspace_with_viewers_with_generated_slotids": "995ca0415729b7396b9c6c481a2e2218"
}