[Fix] isLabelSyncedWithName should be nullable (#9028)
isLabelSyncedWithName should be nullable for fieldMetadata, as it is for objectMetadata. + Adding missing validation on label and name sync in fieldMetadataService for creation and update + adding metadata tests
This commit is contained in:
@ -0,0 +1,24 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
import { CreateObjectInput } from 'src/engine/metadata-modules/object-metadata/dtos/create-object.input';
|
||||
|
||||
type CreateOneObjectFactoryParams = {
|
||||
gqlFields: string;
|
||||
input?: { object: Omit<CreateObjectInput, 'workspaceId' | 'dataSourceId'> };
|
||||
};
|
||||
|
||||
export const createOneObjectMetadataFactory = ({
|
||||
gqlFields,
|
||||
input,
|
||||
}: CreateOneObjectFactoryParams) => ({
|
||||
query: gql`
|
||||
mutation CreateOneObjectMetadataItem($input: CreateOneObjectInput!) {
|
||||
createOneObject(input: $input) {
|
||||
${gqlFields}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
input,
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,30 @@
|
||||
import { createOneObjectMetadataFactory } from 'test/integration/metadata/suites/object-metadata/utils/create-one-object-metadata-factory.util';
|
||||
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
|
||||
|
||||
const LISTING_NAME_SINGULAR = 'listing';
|
||||
|
||||
const LISTING_OBJECT = {
|
||||
namePlural: 'listings',
|
||||
nameSingular: LISTING_NAME_SINGULAR,
|
||||
labelPlural: 'Listings',
|
||||
labelSingular: 'Listing',
|
||||
description: 'Listing object',
|
||||
icon: 'IconListNumbers',
|
||||
isLabelSyncedWithName: false,
|
||||
};
|
||||
|
||||
export const createListingCustomObject = async () => {
|
||||
const createObjectOperation = createOneObjectMetadataFactory({
|
||||
input: { object: LISTING_OBJECT },
|
||||
gqlFields: `
|
||||
id
|
||||
nameSingular
|
||||
`,
|
||||
});
|
||||
|
||||
const response = await makeMetadataAPIRequest(createObjectOperation);
|
||||
|
||||
return {
|
||||
objectMetadataId: response.body.data.createOneObject.id,
|
||||
};
|
||||
};
|
||||
@ -0,0 +1,20 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
type DeleteOneObjectFactoryParams = {
|
||||
idToDelete: string;
|
||||
};
|
||||
|
||||
export const deleteOneObjectMetadataItemFactory = ({
|
||||
idToDelete,
|
||||
}: DeleteOneObjectFactoryParams) => ({
|
||||
query: gql`
|
||||
mutation DeleteOneObjectMetadataItem($idToDelete: UUID!) {
|
||||
deleteOneObject(input: { id: $idToDelete }) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
idToDelete,
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,12 @@
|
||||
import { makeGraphqlAPIRequest } from 'test/integration/graphql/utils/make-graphql-api-request.util';
|
||||
import { deleteOneObjectMetadataItemFactory } from 'test/integration/metadata/suites/object-metadata/utils/delete-one-object-metadata-factory.util';
|
||||
|
||||
export const deleteOneObjectMetadataItem = async (
|
||||
objectMetadataItemId: string,
|
||||
) => {
|
||||
const graphqlOperation = deleteOneObjectMetadataItemFactory({
|
||||
idToDelete: objectMetadataItemId,
|
||||
});
|
||||
|
||||
await makeGraphqlAPIRequest(graphqlOperation);
|
||||
};
|
||||
@ -0,0 +1,30 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
type ObjectsFactoryParams = {
|
||||
gqlFields: string;
|
||||
input: {
|
||||
filter: object;
|
||||
paging: object;
|
||||
};
|
||||
};
|
||||
|
||||
export const objectsMetadataFactory = ({
|
||||
gqlFields,
|
||||
input,
|
||||
}: ObjectsFactoryParams) => ({
|
||||
query: gql`
|
||||
query ObjectsMetadata($filter: objectFilter!, $paging: CursorPaging!) {
|
||||
objects(filter: $filter, paging: $paging) {
|
||||
edges {
|
||||
node {
|
||||
${gqlFields}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
filter: input.filter,
|
||||
paging: input.paging,
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,28 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
import { UpdateObjectPayload } from 'src/engine/metadata-modules/object-metadata/dtos/update-object.input';
|
||||
|
||||
type UpdateOneObjectFactoryParams = {
|
||||
gqlFields: string;
|
||||
input: {
|
||||
idToUpdate: string;
|
||||
updatePayload: UpdateObjectPayload;
|
||||
};
|
||||
};
|
||||
|
||||
export const updateOneObjectMetadataItemFactory = ({
|
||||
gqlFields,
|
||||
input,
|
||||
}: UpdateOneObjectFactoryParams) => ({
|
||||
query: gql`
|
||||
mutation UpdateOneObjectMetadataItem($idToUpdate: UUID!, $updatePayload: UpdateObjectPayload!) {
|
||||
updateOneObject(input: {id: $idToUpdate, update: $updatePayload}) {
|
||||
${gqlFields}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
idToUpdate: input.idToUpdate,
|
||||
updatePayload: input.updatePayload,
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user