Skip to content

Commit

Permalink
Merge branch 'main' into achalmers/kw-fn-sketches
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchalmers committed Jan 31, 2025
2 parents 57f3cd1 + 4ff07dd commit 057face
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
45 changes: 44 additions & 1 deletion e2e/playwright/sketch-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ test.describe('Sketch tests', () => {
|> hole(screwHole, %)
|> extrude(length = thickness)
part002 = startSketchOn('-XZ')
part002 = startSketchOn('-XZ')
${startProfileAt3}
|> xLine(width / 4, %)
|> tangentialArcTo([width / 2, 0], %)
Expand Down Expand Up @@ -1410,3 +1410,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()
})
})
8 changes: 8 additions & 0 deletions src/clientSideScene/ClientSideSceneComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ export const ClientSideScene = ({
'mouseup',
toSync(sceneInfra.onMouseUp, reportRejection)
)
sceneEntitiesManager
.tearDownSketch()
.then(() => {
// no op
})
.catch((e) => {
console.error(e)
})
}
}, [])

Expand Down
1 change: 1 addition & 0 deletions src/components/RouteProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export function RouteProvider({ children }: { children: ReactNode }) {
const [first, setFirstState] = useState(true)
const navigation = useNavigation()
const location = useLocation()

useEffect(() => {
// On initialization, the react-router-dom does not send a 'loading' state event.
// it sends an idle event first.
Expand Down

0 comments on commit 057face

Please sign in to comment.