-
Notifications
You must be signed in to change notification settings - Fork 890
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow input text when exceed max length
Signed-off-by: Lin Wang <[email protected]>
- Loading branch information
Showing
8 changed files
with
127 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...plugins/workspace/public/components/workspace_form/workspace_create_action_panel.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { applicationServiceMock } from '../../../../../core/public/mocks'; | ||
import { | ||
MAX_WORKSPACE_DESCRIPTION_LENGTH, | ||
MAX_WORKSPACE_NAME_LENGTH, | ||
} from '../../../common/constants'; | ||
import { WorkspaceCreateActionPanel } from './workspace_create_action_panel'; | ||
|
||
const mockApplication = applicationServiceMock.createStartContract(); | ||
|
||
describe('WorkspaceCreateActionPanel', () => { | ||
const formId = 'workspaceForm'; | ||
const formData = { | ||
name: 'Test Workspace', | ||
description: 'This is a test workspace', | ||
}; | ||
|
||
it('should disable the "Create Workspace" button when name exceeds the maximum length', () => { | ||
const longName = 'a'.repeat(MAX_WORKSPACE_NAME_LENGTH + 1); | ||
render( | ||
<WorkspaceCreateActionPanel | ||
formId={formId} | ||
formData={{ name: longName, description: formData.description }} | ||
application={mockApplication} | ||
/> | ||
); | ||
const createButton = screen.getByText('Create workspace'); | ||
expect(createButton.closest('button')).toBeDisabled(); | ||
}); | ||
|
||
it('should disable the "Create Workspace" button when description exceeds the maximum length', () => { | ||
const longDescription = 'a'.repeat(MAX_WORKSPACE_DESCRIPTION_LENGTH + 1); | ||
render( | ||
<WorkspaceCreateActionPanel | ||
formId={formId} | ||
formData={{ name: formData.name, description: longDescription }} | ||
application={mockApplication} | ||
/> | ||
); | ||
const createButton = screen.getByText('Create workspace'); | ||
expect(createButton.closest('button')).toBeDisabled(); | ||
}); | ||
|
||
it('should enable the "Create Workspace" button when name and description are within the maximum length', () => { | ||
render( | ||
<WorkspaceCreateActionPanel | ||
formId={formId} | ||
formData={formData} | ||
application={mockApplication} | ||
/> | ||
); | ||
const createButton = screen.getByText('Create workspace'); | ||
expect(createButton.closest('button')).not.toBeDisabled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters