2023-08-18 10:27:01 -04:00
|
|
|
import { fireEvent, render, screen } from '@testing-library/react'
|
|
|
|
import { BrowserRouter } from 'react-router-dom'
|
|
|
|
import ProjectSidebarMenu from './ProjectSidebarMenu'
|
2024-02-11 12:59:00 +11:00
|
|
|
import { type ProjectWithEntryPointMetadata } from 'lib/types'
|
2024-02-15 14:14:14 -05:00
|
|
|
import { SettingsAuthStateProvider } from './SettingsAuthStateProvider'
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* 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>
2023-12-13 12:49:01 -05:00
|
|
|
import CommandBarProvider from './CommandBar/CommandBar'
|
2023-12-18 06:15:26 -05:00
|
|
|
import { APP_NAME } from 'lib/constants'
|
2023-08-18 10:27:01 -04:00
|
|
|
|
|
|
|
const now = new Date()
|
|
|
|
const projectWellFormed = {
|
|
|
|
name: 'Simple Box',
|
|
|
|
path: '/some/path/Simple Box',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
name: 'main.kcl',
|
|
|
|
path: '/some/path/Simple Box/main.kcl',
|
|
|
|
},
|
|
|
|
],
|
2023-10-16 13:28:41 -04:00
|
|
|
entrypointMetadata: {
|
2023-08-18 10:27:01 -04:00
|
|
|
accessedAt: now,
|
|
|
|
blksize: 32,
|
|
|
|
blocks: 32,
|
|
|
|
createdAt: now,
|
|
|
|
dev: 1,
|
|
|
|
gid: 1,
|
|
|
|
ino: 1,
|
|
|
|
isDir: false,
|
|
|
|
isFile: true,
|
|
|
|
isSymlink: false,
|
|
|
|
mode: 1,
|
|
|
|
modifiedAt: now,
|
|
|
|
nlink: 1,
|
|
|
|
permissions: { readonly: false, mode: 1 },
|
|
|
|
rdev: 1,
|
|
|
|
size: 32,
|
|
|
|
uid: 1,
|
|
|
|
},
|
|
|
|
} satisfies ProjectWithEntryPointMetadata
|
|
|
|
|
|
|
|
describe('ProjectSidebarMenu tests', () => {
|
|
|
|
test('Renders the project name', () => {
|
|
|
|
render(
|
|
|
|
<BrowserRouter>
|
2023-09-27 15:42:16 -07:00
|
|
|
<CommandBarProvider>
|
2024-02-15 14:14:14 -05:00
|
|
|
<SettingsAuthStateProvider>
|
2023-09-27 15:42:16 -07:00
|
|
|
<ProjectSidebarMenu project={projectWellFormed} />
|
2024-02-15 14:14:14 -05:00
|
|
|
</SettingsAuthStateProvider>
|
2023-09-27 15:42:16 -07:00
|
|
|
</CommandBarProvider>
|
2023-08-18 10:27:01 -04:00
|
|
|
</BrowserRouter>
|
|
|
|
)
|
|
|
|
|
|
|
|
fireEvent.click(screen.getByTestId('project-sidebar-toggle'))
|
|
|
|
|
|
|
|
expect(screen.getByTestId('projectName')).toHaveTextContent(
|
|
|
|
projectWellFormed.name
|
|
|
|
)
|
|
|
|
expect(screen.getByTestId('createdAt')).toHaveTextContent(
|
|
|
|
`Created ${now.toLocaleDateString()}`
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('Renders app name if given no project', () => {
|
|
|
|
render(
|
|
|
|
<BrowserRouter>
|
2023-09-27 15:42:16 -07:00
|
|
|
<CommandBarProvider>
|
2024-02-15 14:14:14 -05:00
|
|
|
<SettingsAuthStateProvider>
|
2023-09-27 15:42:16 -07:00
|
|
|
<ProjectSidebarMenu />
|
2024-02-15 14:14:14 -05:00
|
|
|
</SettingsAuthStateProvider>
|
2023-09-27 15:42:16 -07:00
|
|
|
</CommandBarProvider>
|
2023-08-18 10:27:01 -04:00
|
|
|
</BrowserRouter>
|
|
|
|
)
|
|
|
|
|
|
|
|
fireEvent.click(screen.getByTestId('project-sidebar-toggle'))
|
|
|
|
|
2023-12-18 06:15:26 -05:00
|
|
|
expect(screen.getByTestId('projectName')).toHaveTextContent(APP_NAME)
|
2023-08-18 10:27:01 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
test('Renders as a link if set to do so', () => {
|
|
|
|
render(
|
|
|
|
<BrowserRouter>
|
2023-09-27 15:42:16 -07:00
|
|
|
<CommandBarProvider>
|
2024-02-15 14:14:14 -05:00
|
|
|
<SettingsAuthStateProvider>
|
2023-09-27 15:42:16 -07:00
|
|
|
<ProjectSidebarMenu
|
|
|
|
project={projectWellFormed}
|
|
|
|
renderAsLink={true}
|
|
|
|
/>
|
2024-02-15 14:14:14 -05:00
|
|
|
</SettingsAuthStateProvider>
|
2023-09-27 15:42:16 -07:00
|
|
|
</CommandBarProvider>
|
2023-08-18 10:27:01 -04:00
|
|
|
</BrowserRouter>
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(screen.getByTestId('project-sidebar-link')).toBeInTheDocument()
|
|
|
|
expect(screen.getByTestId('project-sidebar-link-name')).toHaveTextContent(
|
|
|
|
projectWellFormed.name
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|