-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Josh Ladieu <ladieu@broadinstitute.org> Co-authored-by: Nick Watts <1156625+nawatts@users.noreply.github.com>
- Loading branch information
1 parent
07b7274
commit aaac3c8
Showing
11 changed files
with
319 additions
and
67 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
62 changes: 0 additions & 62 deletions
62
src/workspace-data/data-table/entity-service/RenameColumnModal.js
This file was deleted.
Oops, something went wrong.
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
128 changes: 128 additions & 0 deletions
128
src/workspace-data/data-table/shared/RenameColumnModal.test.ts
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,128 @@ | ||
import { screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { h } from 'react-hyperscript-helpers'; | ||
import { renderWithAppContexts as render } from 'src/testing/test-utils'; | ||
|
||
import { RenameColumnModal, RenameColumnModalProps } from './RenameColumnModal'; | ||
|
||
const defaultRenameColumnModalProps: RenameColumnModalProps = { | ||
onDismiss: () => {}, | ||
onSuccess: () => {}, | ||
entityType: 'defaultEntityType', | ||
attributeNames: ['attribute1', 'attribute2'], | ||
oldAttributeName: 'attribute1', | ||
dataProvider: { providerName: 'Entity Service' }, | ||
}; | ||
|
||
describe('RenameColumnModal', () => { | ||
it('Errors on invalid characters in column name', async () => { | ||
// Arrange | ||
const renameProps = { ...defaultRenameColumnModalProps }; | ||
// const user = userEvent.setup(); | ||
// Act | ||
const renameModal = render(h(RenameColumnModal, renameProps)); | ||
// User enters name with %^#@ | ||
const input = screen.getByLabelText(/New Name/); | ||
await userEvent.type(input, 'b@d ch@r@cter$'); | ||
// Assert | ||
expect(renameModal.getByText(/Column name may only contain alphanumeric characters/)); | ||
}); | ||
|
||
it('Errors on reserved word for column name in GCP', async () => { | ||
// Arrange | ||
const renameProps = { ...defaultRenameColumnModalProps }; | ||
// Act | ||
const renameModal = render(h(RenameColumnModal, renameProps)); | ||
// User enters defaultEntityType_id | ||
const input = screen.getByLabelText(/New Name/); | ||
await userEvent.type(input, 'defaultEntityType_id'); | ||
// Assert | ||
expect(renameModal.getByText(/Column name cannot be/)); | ||
}); | ||
|
||
it('Does not error on GCP reserved word in azure', async () => { | ||
// Arrange | ||
const renameProps = { ...defaultRenameColumnModalProps, dataProvider: { providerName: 'WDS' } }; | ||
// Act | ||
const renameModal = render(h(RenameColumnModal, renameProps)); | ||
// User enters defaultEntityType_id | ||
const input = screen.getByLabelText(/New Name/); | ||
await userEvent.type(input, 'defaultEntityType_id'); | ||
// Assert | ||
expect(renameModal.queryByText(/Column name cannot be/)).toBeNull(); | ||
}); | ||
|
||
it('Errors on existing name for column name', async () => { | ||
// Arrange | ||
const renameProps = { ...defaultRenameColumnModalProps }; | ||
// Act | ||
const renameModal = render(h(RenameColumnModal, renameProps)); | ||
// User enters 'attribute2' | ||
const input = screen.getByLabelText(/New Name/); | ||
await userEvent.type(input, 'attribute2'); | ||
// Assert | ||
expect(renameModal.getByText(/already exists as an attribute name/)); | ||
}); | ||
|
||
it('Errors on column name starting with sys_ in azure', async () => { | ||
// Arrange | ||
const renameProps = { ...defaultRenameColumnModalProps, dataProvider: { providerName: 'WDS' } }; | ||
// Act | ||
const renameModal = render(h(RenameColumnModal, renameProps)); | ||
// User enters 'attribute2' | ||
const input = screen.getByLabelText(/New Name/); | ||
await userEvent.type(input, 'sys_attribute'); | ||
// Assert | ||
expect(renameModal.getByText(/Column name cannot start with "sys_"/)); | ||
}); | ||
|
||
it('Does not errors on column name starting with sys_ in gcp', async () => { | ||
// Arrange | ||
const renameProps = { ...defaultRenameColumnModalProps }; | ||
// Act | ||
const renameModal = render(h(RenameColumnModal, renameProps)); | ||
// User enters 'attribute2' | ||
const input = screen.getByLabelText(/New Name/); | ||
await userEvent.type(input, 'sys_attribute'); | ||
// Assert | ||
expect(renameModal.queryByText(/Column name cannot start with "sys_"/)).toBeNull(); | ||
}); | ||
|
||
it('Does not allow colons in azure', async () => { | ||
// Arrange | ||
const renameProps = { ...defaultRenameColumnModalProps, dataProvider: { providerName: 'WDS' } }; | ||
// Act | ||
const renameModal = render(h(RenameColumnModal, renameProps)); | ||
// User enters 'attribute2' | ||
const input = screen.getByLabelText(/New Name/); | ||
await userEvent.type(input, 'namespace:attribute'); | ||
// Assert | ||
expect(renameModal.getByText(/Column name may only contain alphanumeric characters, underscores, and dashes./)); | ||
}); | ||
|
||
it('Allows a single colon in gcp', async () => { | ||
// Arrange | ||
const renameProps = { ...defaultRenameColumnModalProps }; | ||
// Act | ||
const renameModal = render(h(RenameColumnModal, renameProps)); | ||
// User enters 'attribute2' | ||
const input = screen.getByLabelText(/New Name/); | ||
await userEvent.type(input, 'namespace:attribute'); | ||
// Assert | ||
expect( | ||
renameModal.queryByText(/Column name may only contain alphanumeric characters, underscores, and dashes./) | ||
).toBeNull(); | ||
}); | ||
|
||
it('Does not allow multiple colons in gcp', async () => { | ||
// Arrange | ||
const renameProps = { ...defaultRenameColumnModalProps }; | ||
// Act | ||
const renameModal = render(h(RenameColumnModal, renameProps)); | ||
// User enters 'attribute2' | ||
const input = screen.getByLabelText(/New Name/); | ||
await userEvent.type(input, 'namespace:attribute:colon'); | ||
// Assert | ||
expect(renameModal.getByText(/Column name may only include a single colon/)); | ||
}); | ||
}); |
Oops, something went wrong.