* Tweak toaster look and feel * Add icons, tweak plus icon names * Rename commandBarMeta to commandBarConfig * Refactor command bar, add support for icons * Create a tailwind plugin for aria-pressed button state * Remove overlay from behind command bar * Clean up toolbar * Button and other style tweaks * Icon tweaks follow-up: make old icons work with new sizing * Delete unused static icons * More CSS tweaks * Small CSS tweak to project sidebar * Add command bar E2E test * fumpt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * fix typo in a comment * Fix icon padding (built version only) * Update onboarding and warning banner icons padding * Misc minor style fixes * Get Extrude opening and canceling from command bar * Iconography tweaks * Get extrude kind of working * Refactor command bar config types and organization * Move command bar configs to be co-located with each other * Start building a state machine for the command bar * Start converting command bar to state machine * Add support for multiple args, confirmation step * Submission behavior, hotkeys, code organization * Add new test for extruding from command bar * Polish step back and selection hotkeys, CSS tweaks * Loading style tweaks * Validate selection inputs, polish UX of args re-editing * Prevent submission with multiple selection on singlular arg * Remove stray console logs * Tweak test, CSS nit, remove extrude "result" argument * Fix linting warnings * Show Ctrl+/ instead of ⌘K on all platforms but Mac * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Add "Enter sketch" to command bar * fix command bar test * Fix flaky cmd bar extrude test by waiting for engine select response * Cover both button labels '⌘K' and 'Ctrl+/' in test --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
74 lines
2.1 KiB
TypeScript
74 lines
2.1 KiB
TypeScript
import { render, screen } from '@testing-library/react'
|
|
import { App } from './App'
|
|
import { describe, test, vi } from 'vitest'
|
|
import {
|
|
Route,
|
|
RouterProvider,
|
|
createMemoryRouter,
|
|
createRoutesFromElements,
|
|
} from 'react-router-dom'
|
|
import { GlobalStateProvider } from './components/GlobalStateProvider'
|
|
import CommandBarProvider from 'components/CommandBar/CommandBar'
|
|
import ModelingMachineProvider from 'components/ModelingMachineProvider'
|
|
import { BROWSER_FILE_NAME } from 'Router'
|
|
|
|
let listener: ((rect: any) => void) | undefined = undefined
|
|
;(global as any).ResizeObserver = class ResizeObserver {
|
|
constructor(ls: ((rect: any) => void) | undefined) {
|
|
listener = ls
|
|
}
|
|
observe() {}
|
|
unobserve() {}
|
|
disconnect() {}
|
|
}
|
|
|
|
describe('App tests', () => {
|
|
test('Renders the modeling app screen, including "Variables" pane.', () => {
|
|
vi.mock('react-router-dom', async () => {
|
|
const actual = (await vi.importActual('react-router-dom')) as Record<
|
|
string,
|
|
any
|
|
>
|
|
return {
|
|
...actual,
|
|
useParams: () => ({ id: BROWSER_FILE_NAME }),
|
|
useLoaderData: () => ({ code: null }),
|
|
}
|
|
})
|
|
render(
|
|
<TestWrap>
|
|
<App />
|
|
</TestWrap>
|
|
)
|
|
const linkElement = screen.getByText(/Variables/i)
|
|
expect(linkElement).toBeInTheDocument()
|
|
|
|
vi.restoreAllMocks()
|
|
})
|
|
})
|
|
|
|
function TestWrap({ children }: { children: React.ReactNode }) {
|
|
// We have to use a memory router in the testing environment,
|
|
// and we have to use the createMemoryRouter function instead of <MemoryRouter /> as of react-router v6.4:
|
|
// https://reactrouter.com/en/6.16.0/routers/picking-a-router#using-v64-data-apis
|
|
const router = createMemoryRouter(
|
|
createRoutesFromElements(
|
|
<Route
|
|
path="/file/:id"
|
|
element={
|
|
<CommandBarProvider>
|
|
<GlobalStateProvider>
|
|
<ModelingMachineProvider>{children}</ModelingMachineProvider>
|
|
</GlobalStateProvider>
|
|
</CommandBarProvider>
|
|
}
|
|
/>
|
|
),
|
|
{
|
|
initialEntries: ['/file/new'],
|
|
initialIndex: 0,
|
|
}
|
|
)
|
|
return <RouterProvider router={router} />
|
|
}
|