Skip to content

Commit

Permalink
Do not alter paths data when loading through d3js (#7026)
Browse files Browse the repository at this point in the history
* d3-sankey alters the object passed into it. we must copy the object we pass to it

* save a path in a test

* don't rely on being able to query the toast when testing if paths saved
  • Loading branch information
pauldambra authored Nov 10, 2021
1 parent fb148d6 commit 33f2399
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cypress/integration/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ describe('Paths', () => {

cy.get('[data-attr=paths-viz]').should('exist')
})

it('can save paths', () => {
cy.get('[data-attr="insight-edit-button"]').should('not.exist')
cy.get('[data-attr="insight-save-button"]').click()
cy.get('[data-attr="insight-edit-button"]').should('exist')
})
})
5 changes: 4 additions & 1 deletion frontend/src/scenes/paths/NewPaths.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ export function NewPaths({ dashboardItemId = null, color = 'white' }: PathsProps

const svg = createCanvas(width, height)
const sankey = createSankey(width, height)
const { nodes, links } = sankey(paths)
const { nodes, links } = sankey({
nodes: paths.nodes.map((d) => ({ ...d })),
links: paths.links.map((d) => ({ ...d })),
})

setPathItemCards(
nodes.map((node: PathNodeData) => ({ ...node, visible: node.y1 - node.y0 > HIDE_PATH_CARD_HEIGHT }))
Expand Down

0 comments on commit 33f2399

Please sign in to comment.