Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions static/src/js/components/ProjectCollections/ProjectHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export const ProjectHeader = memo(() => {
<input
className="project-header__title"
name="projectName"
aria-label="Project name"
value={name}
onFocus={handleOnFocus}
onChange={onInputChange}
Expand All @@ -192,7 +193,7 @@ export const ProjectHeader = memo(() => {
<button
type="button"
className="project-header__button project-header__button--submit"
label="Submit project name"
aria-label="Submit project name"
data-testid="submit_button"
onClick={handleNameSubmit}
>
Expand All @@ -205,7 +206,7 @@ export const ProjectHeader = memo(() => {
<button
type="button"
className="project-header__button project-header__button--edit"
label="Edit project name"
aria-label="Edit project name"
data-testid="edit_button"
onClick={handleEditClick}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,17 +444,17 @@ describe('ProjectHeader component', () => {
test('when the state is editing the submit button is visible', async () => {
const { user } = setup()

await user.click(screen.getByRole('textbox'))
await user.click(screen.getByRole('textbox', { name: 'Project name' }))

expect(screen.getByTestId('submit_button')).toBeInTheDocument()
expect(screen.queryByTestId('edit_button')).not.toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Submit project name' })).toBeInTheDocument()
expect(screen.queryByRole('button', { name: 'Edit project name' })).not.toBeInTheDocument()
})

test('when the state is not editing the edit button is visible', async () => {
setup()

expect(screen.queryByTestId('submit_button')).not.toBeInTheDocument()
expect(screen.getByTestId('edit_button')).toBeInTheDocument()
expect(screen.queryByRole('button', { name: 'Submit project name' })).not.toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Edit project name' })).toBeInTheDocument()
})

test('focusing on project name and pressing enter enables editing', async () => {
Expand Down