Fix: Clearing sketch DOM elements after redirecting to the home page (#4965)
* fix: clear the previous DOM elements after page redirect * fix: removed await delay since it can take awhile to destroy the sketch * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * fix: added E2E test which actually caught a logic bug, moved the logic to the correct location * fix: removing unused import * fix: push main back... * fix: restoring code to old state * fix: moved cleanup code * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -34,7 +34,7 @@ test.describe('Sketch tests', () => {
|
|||||||
screwRadius = 3
|
screwRadius = 3
|
||||||
wireRadius = 2
|
wireRadius = 2
|
||||||
wireOffset = 0.5
|
wireOffset = 0.5
|
||||||
|
|
||||||
screwHole = startSketchOn('XY')
|
screwHole = startSketchOn('XY')
|
||||||
${startProfileAt1}
|
${startProfileAt1}
|
||||||
|> arc({
|
|> arc({
|
||||||
@ -42,7 +42,7 @@ test.describe('Sketch tests', () => {
|
|||||||
angleStart = 0,
|
angleStart = 0,
|
||||||
angleEnd = 360
|
angleEnd = 360
|
||||||
}, %)
|
}, %)
|
||||||
|
|
||||||
part001 = startSketchOn('XY')
|
part001 = startSketchOn('XY')
|
||||||
${startProfileAt2}
|
${startProfileAt2}
|
||||||
|> xLine(width * .5, %)
|
|> xLine(width * .5, %)
|
||||||
@ -51,7 +51,7 @@ test.describe('Sketch tests', () => {
|
|||||||
|> close(%)
|
|> close(%)
|
||||||
|> hole(screwHole, %)
|
|> hole(screwHole, %)
|
||||||
|> extrude(thickness, %)
|
|> extrude(thickness, %)
|
||||||
|
|
||||||
part002 = startSketchOn('-XZ')
|
part002 = startSketchOn('-XZ')
|
||||||
${startProfileAt3}
|
${startProfileAt3}
|
||||||
|> xLine(width / 4, %)
|
|> xLine(width / 4, %)
|
||||||
@ -1063,7 +1063,7 @@ test.describe('Sketch tests', () => {
|
|||||||
`lugHeadLength = 0.25
|
`lugHeadLength = 0.25
|
||||||
lugDiameter = 0.5
|
lugDiameter = 0.5
|
||||||
lugLength = 2
|
lugLength = 2
|
||||||
|
|
||||||
fn lug = (origin, length, diameter, plane) => {
|
fn lug = (origin, length, diameter, plane) => {
|
||||||
lugSketch = startSketchOn(plane)
|
lugSketch = startSketchOn(plane)
|
||||||
|> startProfileAt([origin[0] + lugDiameter / 2, origin[1]], %)
|
|> startProfileAt([origin[0] + lugDiameter / 2, origin[1]], %)
|
||||||
@ -1072,10 +1072,10 @@ test.describe('Sketch tests', () => {
|
|||||||
|> yLineTo(0, %)
|
|> yLineTo(0, %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> revolve({ axis = "Y" }, %)
|
|> revolve({ axis = "Y" }, %)
|
||||||
|
|
||||||
return lugSketch
|
return lugSketch
|
||||||
}
|
}
|
||||||
|
|
||||||
lug([0, 0], 10, .5, "XY")`
|
lug([0, 0], 10, .5, "XY")`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -1127,14 +1127,14 @@ test.describe('Sketch tests', () => {
|
|||||||
`fn in2mm = (inches) => {
|
`fn in2mm = (inches) => {
|
||||||
return inches * 25.4
|
return inches * 25.4
|
||||||
}
|
}
|
||||||
|
|
||||||
const railTop = in2mm(.748)
|
const railTop = in2mm(.748)
|
||||||
const railSide = in2mm(.024)
|
const railSide = in2mm(.024)
|
||||||
const railBaseWidth = in2mm(.612)
|
const railBaseWidth = in2mm(.612)
|
||||||
const railWideWidth = in2mm(.835)
|
const railWideWidth = in2mm(.835)
|
||||||
const railBaseLength = in2mm(.200)
|
const railBaseLength = in2mm(.200)
|
||||||
const railClampable = in2mm(.200)
|
const railClampable = in2mm(.200)
|
||||||
|
|
||||||
const rail = startSketchOn('XZ')
|
const rail = startSketchOn('XZ')
|
||||||
|> startProfileAt([
|
|> startProfileAt([
|
||||||
-railTop / 2,
|
-railTop / 2,
|
||||||
@ -1405,3 +1405,46 @@ test.describe(`Click based selection don't brick the app when clicked out of ran
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Regression test for https://github.com/KittyCAD/modeling-app/issues/4372
|
||||||
|
test.describe('Redirecting to home page and back to the original file should clear sketch DOM elements', () => {
|
||||||
|
test('Can redirect to home page and back to original file and have a cleared DOM', async ({
|
||||||
|
context,
|
||||||
|
page,
|
||||||
|
scene,
|
||||||
|
toolbar,
|
||||||
|
editor,
|
||||||
|
homePage,
|
||||||
|
}) => {
|
||||||
|
// We seed the scene with a single offset plane
|
||||||
|
await context.addInitScript(() => {
|
||||||
|
localStorage.setItem(
|
||||||
|
'persistCode',
|
||||||
|
` sketch001 = startSketchOn('XZ')
|
||||||
|
|> startProfileAt([256.85, 14.41], %)
|
||||||
|
|> lineTo([0, 211.07], %)
|
||||||
|
`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
await homePage.goToModelingScene()
|
||||||
|
await scene.waitForExecutionDone()
|
||||||
|
|
||||||
|
const [objClick] = scene.makeMouseHelpers(634, 274)
|
||||||
|
await objClick()
|
||||||
|
|
||||||
|
// Enter sketch mode
|
||||||
|
await toolbar.editSketch()
|
||||||
|
|
||||||
|
await expect(page.getByText('323.49')).toBeVisible()
|
||||||
|
|
||||||
|
// Open navigation side bar
|
||||||
|
await page.getByTestId('project-sidebar-toggle').click()
|
||||||
|
const goToHome = page.getByRole('button', {
|
||||||
|
name: 'Go to Home',
|
||||||
|
})
|
||||||
|
|
||||||
|
await goToHome.click()
|
||||||
|
await homePage.openProject('testDefault')
|
||||||
|
await expect(page.getByText('323.49')).not.toBeVisible()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
@ -124,6 +124,14 @@ export const ClientSideScene = ({
|
|||||||
'mouseup',
|
'mouseup',
|
||||||
toSync(sceneInfra.onMouseUp, reportRejection)
|
toSync(sceneInfra.onMouseUp, reportRejection)
|
||||||
)
|
)
|
||||||
|
sceneEntitiesManager
|
||||||
|
.tearDownSketch()
|
||||||
|
.then(() => {
|
||||||
|
// no op
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
console.error(e)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ export function RouteProvider({ children }: { children: ReactNode }) {
|
|||||||
const [first, setFirstState] = useState(true)
|
const [first, setFirstState] = useState(true)
|
||||||
const navigation = useNavigation()
|
const navigation = useNavigation()
|
||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// On initialization, the react-router-dom does not send a 'loading' state event.
|
// On initialization, the react-router-dom does not send a 'loading' state event.
|
||||||
// it sends an idle event first.
|
// it sends an idle event first.
|
||||||
|
Reference in New Issue
Block a user