forked from twentyhq/twenty
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable deletion of relation fields (twentyhq#5338)
In this PR 1. Enable deletion of relation fields in the product and via the api (migration part was missing in the api) 3. Change wording, only use "deactivate" and "delete" everywhere (and not a mix of the two + "disable", "erase")
- Loading branch information
Showing
30 changed files
with
519 additions
and
117 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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
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
15 changes: 15 additions & 0 deletions
15
...nty-front/src/modules/object-metadata/hooks/__mocks__/useDeleteOneRelationMetadataItem.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,15 @@ | ||
import { gql } from '@apollo/client'; | ||
|
||
export const query = gql` | ||
mutation DeleteOneRelationMetadataItem($idToDelete: UUID!) { | ||
deleteOneRelation(input: { id: $idToDelete }) { | ||
id | ||
} | ||
} | ||
`; | ||
|
||
export const variables = { idToDelete: 'idToDelete' }; | ||
|
||
export const responseData = { | ||
id: 'idToDelete' | ||
}; |
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
49 changes: 49 additions & 0 deletions
49
...ont/src/modules/object-metadata/hooks/__tests__/useDeleteOneRelationMetadataItem.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,49 @@ | ||
import { ReactNode } from 'react'; | ||
import { MockedProvider } from '@apollo/client/testing'; | ||
import { act, renderHook } from '@testing-library/react'; | ||
import { RecoilRoot } from 'recoil'; | ||
|
||
import { useDeleteOneRelationMetadataItem } from '@/object-metadata/hooks/useDeleteOneRelationMetadataItem'; | ||
|
||
import { | ||
query, | ||
responseData, | ||
variables, | ||
} from '../__mocks__/useDeleteOneRelationMetadataItem'; | ||
|
||
const mocks = [ | ||
{ | ||
request: { | ||
query, | ||
variables, | ||
}, | ||
result: jest.fn(() => ({ | ||
data: { | ||
deleteOneRelation: responseData, | ||
}, | ||
})), | ||
}, | ||
]; | ||
|
||
const Wrapper = ({ children }: { children: ReactNode }) => ( | ||
<RecoilRoot> | ||
<MockedProvider mocks={mocks} addTypename={false}> | ||
{children} | ||
</MockedProvider> | ||
</RecoilRoot> | ||
); | ||
|
||
describe('useDeleteOneRelationMetadataItem', () => { | ||
it('should work as expected', async () => { | ||
const { result } = renderHook(() => useDeleteOneRelationMetadataItem(), { | ||
wrapper: Wrapper, | ||
}); | ||
|
||
await act(async () => { | ||
const res = | ||
await result.current.deleteOneRelationMetadataItem('idToDelete'); | ||
|
||
expect(res.data).toEqual({ deleteOneRelation: responseData }); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.