mirror of
https://github.com/lingble/twenty.git
synced 2025-10-30 12:22:29 +00:00
This PR was created by [GitStart](https://gitstart.com/) to address the requirements from this ticket: [TWNTY-7526](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-7526). --- ### Description For workspace members, the deletion of multiple members is a special case that is not permitted by the method for regular users. As a result, we ensure that multiple deletions are not processed. For certain tests, both an account ID and a user ID are required. We are utilizing Tim's account for all testing purposes, as specified by the token in `jest-integration.config.ts`. To streamline this process, we have defined a constant to store and reference the account ID and user ID during testing.Refs #7526 ### Dem  Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
0a28c15747
commit
5ad8ff81f9
@@ -1 +1,3 @@
|
|||||||
export const TIM_ACCOUNT_ID = '20202020-0687-4c41-b707-ed1bfca972a7';
|
export const TIM_ACCOUNT_ID = '20202020-0687-4c41-b707-ed1bfca972a7';
|
||||||
|
|
||||||
|
export const TIM_USER_ID = '20202020-9e3b-46d4-a556-88b9ddc2b034';
|
||||||
|
|||||||
@@ -0,0 +1,404 @@
|
|||||||
|
import { createManyOperationFactory } from 'test/integration/graphql/utils/create-many-operation-factory.util';
|
||||||
|
import { createOneOperationFactory } from 'test/integration/graphql/utils/create-one-operation-factory.util';
|
||||||
|
import { deleteManyOperationFactory } from 'test/integration/graphql/utils/delete-many-operation-factory.util';
|
||||||
|
import { deleteOneOperationFactory } from 'test/integration/graphql/utils/delete-one-operation-factory.util';
|
||||||
|
import { destroyManyOperationFactory } from 'test/integration/graphql/utils/destroy-many-operation-factory.util';
|
||||||
|
import { destroyOneOperationFactory } from 'test/integration/graphql/utils/destroy-one-operation-factory.util';
|
||||||
|
import { findManyOperationFactory } from 'test/integration/graphql/utils/find-many-operation-factory.util';
|
||||||
|
import { findOneOperationFactory } from 'test/integration/graphql/utils/find-one-operation-factory.util';
|
||||||
|
import { makeGraphqlAPIRequest } from 'test/integration/graphql/utils/make-graphql-api-request.util';
|
||||||
|
import { updateManyOperationFactory } from 'test/integration/graphql/utils/update-many-operation-factory.util';
|
||||||
|
import { updateOneOperationFactory } from 'test/integration/graphql/utils/update-one-operation-factory.util';
|
||||||
|
import { generateRecordName } from 'test/integration/utils/generate-record-name';
|
||||||
|
|
||||||
|
const API_KEY_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
||||||
|
const API_KEY_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
||||||
|
const API_KEY_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
||||||
|
const API_KEY_GQL_FIELDS = `
|
||||||
|
id
|
||||||
|
name
|
||||||
|
expiresAt
|
||||||
|
revokedAt
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
deletedAt
|
||||||
|
`;
|
||||||
|
|
||||||
|
describe('apiKeys resolvers (integration)', () => {
|
||||||
|
it('1. should create and return API keys', async () => {
|
||||||
|
const apiKeyName1 = generateRecordName(API_KEY_1_ID);
|
||||||
|
const apiKeyName2 = generateRecordName(API_KEY_2_ID);
|
||||||
|
|
||||||
|
const graphqlOperation = createManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'apiKey',
|
||||||
|
objectMetadataPluralName: 'apiKeys',
|
||||||
|
gqlFields: API_KEY_GQL_FIELDS,
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: API_KEY_1_ID,
|
||||||
|
name: apiKeyName1,
|
||||||
|
expiresAt: new Date(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: API_KEY_2_ID,
|
||||||
|
name: apiKeyName2,
|
||||||
|
expiresAt: new Date(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.createApiKeys).toHaveLength(2);
|
||||||
|
|
||||||
|
response.body.data.createApiKeys.forEach((apiKey) => {
|
||||||
|
expect(apiKey).toHaveProperty('name');
|
||||||
|
expect([apiKeyName1, apiKeyName2]).toContain(apiKey.name);
|
||||||
|
expect(apiKey).toHaveProperty('expiresAt');
|
||||||
|
expect(apiKey).toHaveProperty('revokedAt');
|
||||||
|
expect(apiKey).toHaveProperty('id');
|
||||||
|
expect(apiKey).toHaveProperty('createdAt');
|
||||||
|
expect(apiKey).toHaveProperty('updatedAt');
|
||||||
|
expect(apiKey).toHaveProperty('deletedAt');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('1b. should create and return one API key', async () => {
|
||||||
|
const apiKeyName = generateRecordName(API_KEY_3_ID);
|
||||||
|
|
||||||
|
const graphqlOperation = createOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'apiKey',
|
||||||
|
gqlFields: API_KEY_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
id: API_KEY_3_ID,
|
||||||
|
name: apiKeyName,
|
||||||
|
expiresAt: new Date(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const createdApiKey = response.body.data.createApiKey;
|
||||||
|
|
||||||
|
expect(createdApiKey).toHaveProperty('name');
|
||||||
|
expect(createdApiKey.name).toEqual(apiKeyName);
|
||||||
|
expect(createdApiKey).toHaveProperty('expiresAt');
|
||||||
|
expect(createdApiKey).toHaveProperty('revokedAt');
|
||||||
|
expect(createdApiKey).toHaveProperty('id');
|
||||||
|
expect(createdApiKey).toHaveProperty('createdAt');
|
||||||
|
expect(createdApiKey).toHaveProperty('updatedAt');
|
||||||
|
expect(createdApiKey).toHaveProperty('deletedAt');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('2. should find many API keys', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'apiKey',
|
||||||
|
objectMetadataPluralName: 'apiKeys',
|
||||||
|
gqlFields: API_KEY_GQL_FIELDS,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const data = response.body.data.apiKeys;
|
||||||
|
|
||||||
|
expect(data).toBeDefined();
|
||||||
|
expect(Array.isArray(data.edges)).toBe(true);
|
||||||
|
|
||||||
|
const edges = data.edges;
|
||||||
|
|
||||||
|
if (edges.length > 0) {
|
||||||
|
const apiKeys = edges[0].node;
|
||||||
|
|
||||||
|
expect(apiKeys).toHaveProperty('name');
|
||||||
|
expect(apiKeys).toHaveProperty('expiresAt');
|
||||||
|
expect(apiKeys).toHaveProperty('revokedAt');
|
||||||
|
expect(apiKeys).toHaveProperty('id');
|
||||||
|
expect(apiKeys).toHaveProperty('createdAt');
|
||||||
|
expect(apiKeys).toHaveProperty('updatedAt');
|
||||||
|
expect(apiKeys).toHaveProperty('deletedAt');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('2b. should find one API key', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'apiKey',
|
||||||
|
gqlFields: API_KEY_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: API_KEY_3_ID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const apiKey = response.body.data.apiKey;
|
||||||
|
|
||||||
|
expect(apiKey).toHaveProperty('name');
|
||||||
|
expect(apiKey).toHaveProperty('expiresAt');
|
||||||
|
expect(apiKey).toHaveProperty('revokedAt');
|
||||||
|
expect(apiKey).toHaveProperty('id');
|
||||||
|
expect(apiKey).toHaveProperty('createdAt');
|
||||||
|
expect(apiKey).toHaveProperty('updatedAt');
|
||||||
|
expect(apiKey).toHaveProperty('deletedAt');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('3. should update many API keys', async () => {
|
||||||
|
const graphqlOperation = updateManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'apiKey',
|
||||||
|
objectMetadataPluralName: 'apiKeys',
|
||||||
|
gqlFields: API_KEY_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
name: 'Updated Name',
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [API_KEY_1_ID, API_KEY_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const updatedApiKeys = response.body.data.updateApiKeys;
|
||||||
|
|
||||||
|
expect(updatedApiKeys).toHaveLength(2);
|
||||||
|
|
||||||
|
updatedApiKeys.forEach((apiKey) => {
|
||||||
|
expect(apiKey.name).toEqual('Updated Name');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('3b. should update one API key', async () => {
|
||||||
|
const graphqlOperation = updateOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'apiKey',
|
||||||
|
gqlFields: API_KEY_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
name: 'New Name',
|
||||||
|
},
|
||||||
|
recordId: API_KEY_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const updatedApiKey = response.body.data.updateApiKey;
|
||||||
|
|
||||||
|
expect(updatedApiKey.name).toEqual('New Name');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('4. should find many API keys with updated name', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'apiKey',
|
||||||
|
objectMetadataPluralName: 'apiKeys',
|
||||||
|
gqlFields: API_KEY_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
name: {
|
||||||
|
eq: 'Updated Name',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.apiKeys.edges).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('4b. should find one API key with updated name', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'apiKey',
|
||||||
|
gqlFields: API_KEY_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
name: {
|
||||||
|
eq: 'New Name',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.apiKey.name).toEqual('New Name');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('5. should delete many API keys', async () => {
|
||||||
|
const graphqlOperation = deleteManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'apiKey',
|
||||||
|
objectMetadataPluralName: 'apiKeys',
|
||||||
|
gqlFields: API_KEY_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [API_KEY_1_ID, API_KEY_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const deletedApiKeys = response.body.data.deleteApiKeys;
|
||||||
|
|
||||||
|
expect(deletedApiKeys).toHaveLength(2);
|
||||||
|
|
||||||
|
deletedApiKeys.forEach((apiKey) => {
|
||||||
|
expect(apiKey.deletedAt).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('5b. should delete one API key', async () => {
|
||||||
|
const graphqlOperation = deleteOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'apiKey',
|
||||||
|
gqlFields: API_KEY_GQL_FIELDS,
|
||||||
|
recordId: API_KEY_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.deleteApiKey.deletedAt).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('6. should not find many API keys anymore', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'apiKey',
|
||||||
|
objectMetadataPluralName: 'apiKeys',
|
||||||
|
gqlFields: API_KEY_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [API_KEY_1_ID, API_KEY_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const findApiKeysResponse = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(findApiKeysResponse.body.data.apiKeys.edges).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('6b. should not find one API key anymore', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'apiKey',
|
||||||
|
gqlFields: API_KEY_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: API_KEY_3_ID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.apiKey).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('7. should find many deleted API keys with deletedAt filter', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'apiKey',
|
||||||
|
objectMetadataPluralName: 'apiKeys',
|
||||||
|
gqlFields: API_KEY_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [API_KEY_1_ID, API_KEY_2_ID],
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.apiKeys.edges).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('7b. should find one deleted API key with deletedAt filter', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'apiKey',
|
||||||
|
gqlFields: API_KEY_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: API_KEY_3_ID,
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.apiKey.id).toEqual(API_KEY_3_ID);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('8. should destroy many API keys', async () => {
|
||||||
|
const graphqlOperation = destroyManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'apiKey',
|
||||||
|
objectMetadataPluralName: 'apiKeys',
|
||||||
|
gqlFields: API_KEY_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [API_KEY_1_ID, API_KEY_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.destroyApiKeys).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('8b. should destroy one API key', async () => {
|
||||||
|
const graphqlOperation = destroyOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'apiKey',
|
||||||
|
gqlFields: API_KEY_GQL_FIELDS,
|
||||||
|
recordId: API_KEY_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const destroyApiKeyResponse = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(destroyApiKeyResponse.body.data.destroyApiKey).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('9. should not find many API keys anymore', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'apiKey',
|
||||||
|
objectMetadataPluralName: 'apiKeys',
|
||||||
|
gqlFields: API_KEY_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [API_KEY_1_ID, API_KEY_2_ID],
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.apiKeys.edges).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('9b. should not find one API key anymore', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'apiKey',
|
||||||
|
gqlFields: API_KEY_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: API_KEY_3_ID,
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.apiKey).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,440 @@
|
|||||||
|
import { TIM_ACCOUNT_ID } from 'test/integration/graphql/integration.constants';
|
||||||
|
import { createManyOperationFactory } from 'test/integration/graphql/utils/create-many-operation-factory.util';
|
||||||
|
import { createOneOperationFactory } from 'test/integration/graphql/utils/create-one-operation-factory.util';
|
||||||
|
import { deleteManyOperationFactory } from 'test/integration/graphql/utils/delete-many-operation-factory.util';
|
||||||
|
import { deleteOneOperationFactory } from 'test/integration/graphql/utils/delete-one-operation-factory.util';
|
||||||
|
import { destroyManyOperationFactory } from 'test/integration/graphql/utils/destroy-many-operation-factory.util';
|
||||||
|
import { destroyOneOperationFactory } from 'test/integration/graphql/utils/destroy-one-operation-factory.util';
|
||||||
|
import { findManyOperationFactory } from 'test/integration/graphql/utils/find-many-operation-factory.util';
|
||||||
|
import { findOneOperationFactory } from 'test/integration/graphql/utils/find-one-operation-factory.util';
|
||||||
|
import { makeGraphqlAPIRequest } from 'test/integration/graphql/utils/make-graphql-api-request.util';
|
||||||
|
import { updateManyOperationFactory } from 'test/integration/graphql/utils/update-many-operation-factory.util';
|
||||||
|
import { updateOneOperationFactory } from 'test/integration/graphql/utils/update-one-operation-factory.util';
|
||||||
|
import { generateRecordName } from 'test/integration/utils/generate-record-name';
|
||||||
|
|
||||||
|
const ATTACHMENT_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
||||||
|
const ATTACHMENT_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
||||||
|
const ATTACHMENT_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
||||||
|
|
||||||
|
const ATTACHMENT_GQL_FIELDS = `
|
||||||
|
id
|
||||||
|
name
|
||||||
|
fullPath
|
||||||
|
type
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
deletedAt
|
||||||
|
authorId
|
||||||
|
activityId
|
||||||
|
taskId
|
||||||
|
noteId
|
||||||
|
personId
|
||||||
|
companyId
|
||||||
|
opportunityId
|
||||||
|
`;
|
||||||
|
|
||||||
|
describe('attachments resolvers (integration)', () => {
|
||||||
|
it('1. should create and return multiple attachments', async () => {
|
||||||
|
const attachmentName1 = generateRecordName(ATTACHMENT_1_ID);
|
||||||
|
const attachmentName2 = generateRecordName(ATTACHMENT_2_ID);
|
||||||
|
|
||||||
|
const graphqlOperation = createManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'attachment',
|
||||||
|
objectMetadataPluralName: 'attachments',
|
||||||
|
gqlFields: ATTACHMENT_GQL_FIELDS,
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: ATTACHMENT_1_ID,
|
||||||
|
name: attachmentName1,
|
||||||
|
authorId: TIM_ACCOUNT_ID,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: ATTACHMENT_2_ID,
|
||||||
|
name: attachmentName2,
|
||||||
|
authorId: TIM_ACCOUNT_ID,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.createAttachments).toHaveLength(2);
|
||||||
|
|
||||||
|
response.body.data.createAttachments.forEach((attachment) => {
|
||||||
|
expect(attachment).toHaveProperty('name');
|
||||||
|
expect([attachmentName1, attachmentName2]).toContain(attachment.name);
|
||||||
|
expect(attachment).toHaveProperty('fullPath');
|
||||||
|
expect(attachment).toHaveProperty('type');
|
||||||
|
expect(attachment).toHaveProperty('id');
|
||||||
|
expect(attachment).toHaveProperty('createdAt');
|
||||||
|
expect(attachment).toHaveProperty('updatedAt');
|
||||||
|
expect(attachment).toHaveProperty('deletedAt');
|
||||||
|
expect(attachment).toHaveProperty('authorId');
|
||||||
|
expect(attachment).toHaveProperty('activityId');
|
||||||
|
expect(attachment).toHaveProperty('taskId');
|
||||||
|
expect(attachment).toHaveProperty('noteId');
|
||||||
|
expect(attachment).toHaveProperty('personId');
|
||||||
|
expect(attachment).toHaveProperty('companyId');
|
||||||
|
expect(attachment).toHaveProperty('opportunityId');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('2. should create and return one attachment', async () => {
|
||||||
|
const attachmentName = generateRecordName(ATTACHMENT_3_ID);
|
||||||
|
|
||||||
|
const graphqlOperation = createOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'attachment',
|
||||||
|
gqlFields: ATTACHMENT_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
id: ATTACHMENT_3_ID,
|
||||||
|
name: attachmentName,
|
||||||
|
authorId: TIM_ACCOUNT_ID,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const createdAttachment = response.body.data.createAttachment;
|
||||||
|
|
||||||
|
expect(createdAttachment).toHaveProperty('name', attachmentName);
|
||||||
|
expect(createdAttachment).toHaveProperty('fullPath');
|
||||||
|
expect(createdAttachment).toHaveProperty('type');
|
||||||
|
expect(createdAttachment).toHaveProperty('id');
|
||||||
|
expect(createdAttachment).toHaveProperty('createdAt');
|
||||||
|
expect(createdAttachment).toHaveProperty('updatedAt');
|
||||||
|
expect(createdAttachment).toHaveProperty('deletedAt');
|
||||||
|
expect(createdAttachment).toHaveProperty('authorId');
|
||||||
|
expect(createdAttachment).toHaveProperty('activityId');
|
||||||
|
expect(createdAttachment).toHaveProperty('taskId');
|
||||||
|
expect(createdAttachment).toHaveProperty('noteId');
|
||||||
|
expect(createdAttachment).toHaveProperty('personId');
|
||||||
|
expect(createdAttachment).toHaveProperty('companyId');
|
||||||
|
expect(createdAttachment).toHaveProperty('opportunityId');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('2. should find many attachments', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'attachment',
|
||||||
|
objectMetadataPluralName: 'attachments',
|
||||||
|
gqlFields: ATTACHMENT_GQL_FIELDS,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const data = response.body.data.attachments;
|
||||||
|
|
||||||
|
expect(data).toBeDefined();
|
||||||
|
expect(Array.isArray(data.edges)).toBe(true);
|
||||||
|
|
||||||
|
if (data.edges.length > 0) {
|
||||||
|
const attachments = data.edges[0].node;
|
||||||
|
|
||||||
|
expect(attachments).toHaveProperty('name');
|
||||||
|
expect(attachments).toHaveProperty('fullPath');
|
||||||
|
expect(attachments).toHaveProperty('type');
|
||||||
|
expect(attachments).toHaveProperty('id');
|
||||||
|
expect(attachments).toHaveProperty('createdAt');
|
||||||
|
expect(attachments).toHaveProperty('updatedAt');
|
||||||
|
expect(attachments).toHaveProperty('deletedAt');
|
||||||
|
expect(attachments).toHaveProperty('authorId');
|
||||||
|
expect(attachments).toHaveProperty('activityId');
|
||||||
|
expect(attachments).toHaveProperty('taskId');
|
||||||
|
expect(attachments).toHaveProperty('noteId');
|
||||||
|
expect(attachments).toHaveProperty('personId');
|
||||||
|
expect(attachments).toHaveProperty('companyId');
|
||||||
|
expect(attachments).toHaveProperty('opportunityId');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('2b. should find one attachment', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'attachment',
|
||||||
|
gqlFields: ATTACHMENT_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: ATTACHMENT_3_ID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const attachment = response.body.data.attachment;
|
||||||
|
|
||||||
|
expect(attachment).toHaveProperty('name');
|
||||||
|
expect(attachment).toHaveProperty('fullPath');
|
||||||
|
expect(attachment).toHaveProperty('type');
|
||||||
|
expect(attachment).toHaveProperty('id');
|
||||||
|
expect(attachment).toHaveProperty('createdAt');
|
||||||
|
expect(attachment).toHaveProperty('updatedAt');
|
||||||
|
expect(attachment).toHaveProperty('deletedAt');
|
||||||
|
expect(attachment).toHaveProperty('authorId');
|
||||||
|
expect(attachment).toHaveProperty('activityId');
|
||||||
|
expect(attachment).toHaveProperty('taskId');
|
||||||
|
expect(attachment).toHaveProperty('noteId');
|
||||||
|
expect(attachment).toHaveProperty('personId');
|
||||||
|
expect(attachment).toHaveProperty('companyId');
|
||||||
|
expect(attachment).toHaveProperty('opportunityId');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('3. should update many attachments', async () => {
|
||||||
|
const graphqlOperation = updateManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'attachment',
|
||||||
|
objectMetadataPluralName: 'attachments',
|
||||||
|
gqlFields: ATTACHMENT_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
name: 'Updated Name',
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [ATTACHMENT_1_ID, ATTACHMENT_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const updatedAttachments = response.body.data.updateAttachments;
|
||||||
|
|
||||||
|
expect(updatedAttachments).toHaveLength(2);
|
||||||
|
|
||||||
|
updatedAttachments.forEach((attachment) => {
|
||||||
|
expect(attachment.name).toEqual('Updated Name');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('3b. should update one attachment', async () => {
|
||||||
|
const graphqlOperation = updateOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'attachment',
|
||||||
|
gqlFields: ATTACHMENT_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
name: 'New Name',
|
||||||
|
},
|
||||||
|
recordId: ATTACHMENT_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const updatedAttachment = response.body.data.updateAttachment;
|
||||||
|
|
||||||
|
expect(updatedAttachment.name).toEqual('New Name');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('4. should find many attachments with updated name', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'attachment',
|
||||||
|
objectMetadataPluralName: 'attachments',
|
||||||
|
gqlFields: ATTACHMENT_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
name: {
|
||||||
|
eq: 'Updated Name',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.attachments.edges).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('4b. should find one attachment with updated name', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'attachment',
|
||||||
|
gqlFields: ATTACHMENT_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
name: {
|
||||||
|
eq: 'New Name',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.attachment.name).toEqual('New Name');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('5. should delete many attachments', async () => {
|
||||||
|
const graphqlOperation = deleteManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'attachment',
|
||||||
|
objectMetadataPluralName: 'attachments',
|
||||||
|
gqlFields: ATTACHMENT_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [ATTACHMENT_1_ID, ATTACHMENT_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const deletedAttachments = response.body.data.deleteAttachments;
|
||||||
|
|
||||||
|
expect(deletedAttachments).toHaveLength(2);
|
||||||
|
|
||||||
|
deletedAttachments.forEach((attachment) => {
|
||||||
|
expect(attachment.deletedAt).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('5b. should delete one attachment', async () => {
|
||||||
|
const graphqlOperation = deleteOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'attachment',
|
||||||
|
gqlFields: ATTACHMENT_GQL_FIELDS,
|
||||||
|
recordId: ATTACHMENT_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.deleteAttachment.deletedAt).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('6. should not find many attachments anymore', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'attachment',
|
||||||
|
objectMetadataPluralName: 'attachments',
|
||||||
|
gqlFields: ATTACHMENT_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [ATTACHMENT_1_ID, ATTACHMENT_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const findAttachmentsResponse =
|
||||||
|
await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(findAttachmentsResponse.body.data.attachments.edges).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('6b. should not find one attachment anymore', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'attachment',
|
||||||
|
gqlFields: ATTACHMENT_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: ATTACHMENT_3_ID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.attachment).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('7. should find many deleted attachments with deletedAt filter', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'attachment',
|
||||||
|
objectMetadataPluralName: 'attachments',
|
||||||
|
gqlFields: ATTACHMENT_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [ATTACHMENT_1_ID, ATTACHMENT_2_ID],
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.attachments.edges).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('7b. should find one deleted attachment with deletedAt filter', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'attachment',
|
||||||
|
gqlFields: ATTACHMENT_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: ATTACHMENT_3_ID,
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.attachment.id).toEqual(ATTACHMENT_3_ID);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('8. should destroy many attachments', async () => {
|
||||||
|
const graphqlOperation = destroyManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'attachment',
|
||||||
|
objectMetadataPluralName: 'attachments',
|
||||||
|
gqlFields: ATTACHMENT_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [ATTACHMENT_1_ID, ATTACHMENT_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.destroyAttachments).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('8b. should destroy one attachment', async () => {
|
||||||
|
const graphqlOperation = destroyOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'attachment',
|
||||||
|
gqlFields: ATTACHMENT_GQL_FIELDS,
|
||||||
|
recordId: ATTACHMENT_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const destroyAttachmentResponse =
|
||||||
|
await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(destroyAttachmentResponse.body.data.destroyAttachment).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('9. should not find many attachments anymore', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'attachment',
|
||||||
|
objectMetadataPluralName: 'attachments',
|
||||||
|
gqlFields: ATTACHMENT_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [ATTACHMENT_1_ID, ATTACHMENT_2_ID],
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.attachments.edges).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('9b. should not find one attachment anymore', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'attachment',
|
||||||
|
gqlFields: ATTACHMENT_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: ATTACHMENT_3_ID,
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.attachment).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,421 @@
|
|||||||
|
import { createManyOperationFactory } from 'test/integration/graphql/utils/create-many-operation-factory.util';
|
||||||
|
import { createOneOperationFactory } from 'test/integration/graphql/utils/create-one-operation-factory.util';
|
||||||
|
import { deleteManyOperationFactory } from 'test/integration/graphql/utils/delete-many-operation-factory.util';
|
||||||
|
import { deleteOneOperationFactory } from 'test/integration/graphql/utils/delete-one-operation-factory.util';
|
||||||
|
import { destroyManyOperationFactory } from 'test/integration/graphql/utils/destroy-many-operation-factory.util';
|
||||||
|
import { destroyOneOperationFactory } from 'test/integration/graphql/utils/destroy-one-operation-factory.util';
|
||||||
|
import { findManyOperationFactory } from 'test/integration/graphql/utils/find-many-operation-factory.util';
|
||||||
|
import { findOneOperationFactory } from 'test/integration/graphql/utils/find-one-operation-factory.util';
|
||||||
|
import { makeGraphqlAPIRequest } from 'test/integration/graphql/utils/make-graphql-api-request.util';
|
||||||
|
import { updateManyOperationFactory } from 'test/integration/graphql/utils/update-many-operation-factory.util';
|
||||||
|
import { updateOneOperationFactory } from 'test/integration/graphql/utils/update-one-operation-factory.util';
|
||||||
|
import { generateRecordName } from 'test/integration/utils/generate-record-name';
|
||||||
|
|
||||||
|
const AUDIT_LOG_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
||||||
|
const AUDIT_LOG_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
||||||
|
const AUDIT_LOG_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
||||||
|
|
||||||
|
const AUDIT_LOG_GQL_FIELDS = `
|
||||||
|
id
|
||||||
|
name
|
||||||
|
properties
|
||||||
|
context
|
||||||
|
objectName
|
||||||
|
objectMetadataId
|
||||||
|
recordId
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
deletedAt
|
||||||
|
workspaceMemberId
|
||||||
|
`;
|
||||||
|
|
||||||
|
describe('auditLogs resolvers (integration)', () => {
|
||||||
|
it('1. should create and return auditLogs', async () => {
|
||||||
|
const auditLogName1 = generateRecordName(AUDIT_LOG_1_ID);
|
||||||
|
const auditLogName2 = generateRecordName(AUDIT_LOG_2_ID);
|
||||||
|
|
||||||
|
const graphqlOperation = createManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'auditLog',
|
||||||
|
objectMetadataPluralName: 'auditLogs',
|
||||||
|
gqlFields: AUDIT_LOG_GQL_FIELDS,
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: AUDIT_LOG_1_ID,
|
||||||
|
name: auditLogName1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: AUDIT_LOG_2_ID,
|
||||||
|
name: auditLogName2,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.createAuditLogs).toHaveLength(2);
|
||||||
|
|
||||||
|
response.body.data.createAuditLogs.forEach((auditLog) => {
|
||||||
|
expect(auditLog).toHaveProperty('name');
|
||||||
|
expect([auditLogName1, auditLogName2]).toContain(auditLog.name);
|
||||||
|
expect(auditLog).toHaveProperty('properties');
|
||||||
|
expect(auditLog).toHaveProperty('context');
|
||||||
|
expect(auditLog).toHaveProperty('objectName');
|
||||||
|
expect(auditLog).toHaveProperty('objectMetadataId');
|
||||||
|
expect(auditLog).toHaveProperty('recordId');
|
||||||
|
expect(auditLog).toHaveProperty('id');
|
||||||
|
expect(auditLog).toHaveProperty('createdAt');
|
||||||
|
expect(auditLog).toHaveProperty('updatedAt');
|
||||||
|
expect(auditLog).toHaveProperty('deletedAt');
|
||||||
|
expect(auditLog).toHaveProperty('workspaceMemberId');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('1b. should create and return one auditLog', async () => {
|
||||||
|
const auditLogName = generateRecordName(AUDIT_LOG_3_ID);
|
||||||
|
|
||||||
|
const graphqlOperation = createOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'auditLog',
|
||||||
|
gqlFields: AUDIT_LOG_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
id: AUDIT_LOG_3_ID,
|
||||||
|
name: auditLogName,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const createdAuditLog = response.body.data.createAuditLog;
|
||||||
|
|
||||||
|
expect(createdAuditLog).toHaveProperty('name');
|
||||||
|
expect(createdAuditLog.name).toEqual(auditLogName);
|
||||||
|
expect(createdAuditLog).toHaveProperty('properties');
|
||||||
|
expect(createdAuditLog).toHaveProperty('context');
|
||||||
|
expect(createdAuditLog).toHaveProperty('objectName');
|
||||||
|
expect(createdAuditLog).toHaveProperty('objectMetadataId');
|
||||||
|
expect(createdAuditLog).toHaveProperty('recordId');
|
||||||
|
expect(createdAuditLog).toHaveProperty('id');
|
||||||
|
expect(createdAuditLog).toHaveProperty('createdAt');
|
||||||
|
expect(createdAuditLog).toHaveProperty('updatedAt');
|
||||||
|
expect(createdAuditLog).toHaveProperty('deletedAt');
|
||||||
|
expect(createdAuditLog).toHaveProperty('workspaceMemberId');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('2. should find many auditLogs', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'auditLog',
|
||||||
|
objectMetadataPluralName: 'auditLogs',
|
||||||
|
gqlFields: AUDIT_LOG_GQL_FIELDS,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const data = response.body.data.auditLogs;
|
||||||
|
|
||||||
|
expect(data).toBeDefined();
|
||||||
|
expect(Array.isArray(data.edges)).toBe(true);
|
||||||
|
|
||||||
|
if (data.edges.length > 0) {
|
||||||
|
const auditLogs = data.edges[0].node;
|
||||||
|
|
||||||
|
expect(auditLogs).toHaveProperty('name');
|
||||||
|
expect(auditLogs).toHaveProperty('properties');
|
||||||
|
expect(auditLogs).toHaveProperty('context');
|
||||||
|
expect(auditLogs).toHaveProperty('objectName');
|
||||||
|
expect(auditLogs).toHaveProperty('objectMetadataId');
|
||||||
|
expect(auditLogs).toHaveProperty('recordId');
|
||||||
|
expect(auditLogs).toHaveProperty('id');
|
||||||
|
expect(auditLogs).toHaveProperty('createdAt');
|
||||||
|
expect(auditLogs).toHaveProperty('updatedAt');
|
||||||
|
expect(auditLogs).toHaveProperty('deletedAt');
|
||||||
|
expect(auditLogs).toHaveProperty('workspaceMemberId');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('2b. should find one auditLog', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'auditLog',
|
||||||
|
gqlFields: AUDIT_LOG_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: AUDIT_LOG_3_ID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const auditLog = response.body.data.auditLog;
|
||||||
|
|
||||||
|
expect(auditLog).toHaveProperty('name');
|
||||||
|
expect(auditLog).toHaveProperty('properties');
|
||||||
|
expect(auditLog).toHaveProperty('context');
|
||||||
|
expect(auditLog).toHaveProperty('objectName');
|
||||||
|
expect(auditLog).toHaveProperty('objectMetadataId');
|
||||||
|
expect(auditLog).toHaveProperty('recordId');
|
||||||
|
expect(auditLog).toHaveProperty('id');
|
||||||
|
expect(auditLog).toHaveProperty('createdAt');
|
||||||
|
expect(auditLog).toHaveProperty('updatedAt');
|
||||||
|
expect(auditLog).toHaveProperty('deletedAt');
|
||||||
|
expect(auditLog).toHaveProperty('workspaceMemberId');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('3. should update many auditLogs', async () => {
|
||||||
|
const graphqlOperation = updateManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'auditLog',
|
||||||
|
objectMetadataPluralName: 'auditLogs',
|
||||||
|
gqlFields: AUDIT_LOG_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
name: 'Updated Name',
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [AUDIT_LOG_1_ID, AUDIT_LOG_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const updatedAuditLogs = response.body.data.updateAuditLogs;
|
||||||
|
|
||||||
|
expect(updatedAuditLogs).toHaveLength(2);
|
||||||
|
|
||||||
|
updatedAuditLogs.forEach((auditLog) => {
|
||||||
|
expect(auditLog.name).toEqual('Updated Name');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('3b. should update one auditLog', async () => {
|
||||||
|
const graphqlOperation = updateOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'auditLog',
|
||||||
|
gqlFields: AUDIT_LOG_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
name: 'New Name',
|
||||||
|
},
|
||||||
|
recordId: AUDIT_LOG_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const updatedAuditLog = response.body.data.updateAuditLog;
|
||||||
|
|
||||||
|
expect(updatedAuditLog.name).toEqual('New Name');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('4. should find many auditLogs with updated name', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'auditLog',
|
||||||
|
objectMetadataPluralName: 'auditLogs',
|
||||||
|
gqlFields: AUDIT_LOG_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
name: {
|
||||||
|
eq: 'Updated Name',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.auditLogs.edges).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('4b. should find one auditLog with updated name', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'auditLog',
|
||||||
|
gqlFields: AUDIT_LOG_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
name: {
|
||||||
|
eq: 'New Name',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.auditLog.name).toEqual('New Name');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('5. should delete many auditLogs', async () => {
|
||||||
|
const graphqlOperation = deleteManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'auditLog',
|
||||||
|
objectMetadataPluralName: 'auditLogs',
|
||||||
|
gqlFields: AUDIT_LOG_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [AUDIT_LOG_1_ID, AUDIT_LOG_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const deletedAuditLogs = response.body.data.deleteAuditLogs;
|
||||||
|
|
||||||
|
expect(deletedAuditLogs).toHaveLength(2);
|
||||||
|
|
||||||
|
deletedAuditLogs.forEach((auditLog) => {
|
||||||
|
expect(auditLog.deletedAt).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('5b. should delete one auditLog', async () => {
|
||||||
|
const graphqlOperation = deleteOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'auditLog',
|
||||||
|
gqlFields: AUDIT_LOG_GQL_FIELDS,
|
||||||
|
recordId: AUDIT_LOG_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.deleteAuditLog.deletedAt).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('6. should not find many auditLogs anymore', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'auditLog',
|
||||||
|
objectMetadataPluralName: 'auditLogs',
|
||||||
|
gqlFields: AUDIT_LOG_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [AUDIT_LOG_1_ID, AUDIT_LOG_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const findAuditLogsResponse = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(findAuditLogsResponse.body.data.auditLogs.edges).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('6b. should not find one auditLog anymore', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'auditLog',
|
||||||
|
gqlFields: AUDIT_LOG_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: AUDIT_LOG_3_ID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.auditLog).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('7. should find many deleted auditLogs with deletedAt filter', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'auditLog',
|
||||||
|
objectMetadataPluralName: 'auditLogs',
|
||||||
|
gqlFields: AUDIT_LOG_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [AUDIT_LOG_1_ID, AUDIT_LOG_2_ID],
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.auditLogs.edges).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('7b. should find one deleted auditLog with deletedAt filter', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'auditLog',
|
||||||
|
gqlFields: AUDIT_LOG_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: AUDIT_LOG_3_ID,
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.auditLog.id).toEqual(AUDIT_LOG_3_ID);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('8. should destroy many auditLogs', async () => {
|
||||||
|
const graphqlOperation = destroyManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'auditLog',
|
||||||
|
objectMetadataPluralName: 'auditLogs',
|
||||||
|
gqlFields: AUDIT_LOG_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [AUDIT_LOG_1_ID, AUDIT_LOG_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.destroyAuditLogs).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('8b. should destroy one auditLog', async () => {
|
||||||
|
const graphqlOperation = destroyOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'auditLog',
|
||||||
|
gqlFields: AUDIT_LOG_GQL_FIELDS,
|
||||||
|
recordId: AUDIT_LOG_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const destroyAuditLogResponse =
|
||||||
|
await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(destroyAuditLogResponse.body.data.destroyAuditLog).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('9. should not find many auditLogs anymore', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'auditLog',
|
||||||
|
objectMetadataPluralName: 'auditLogs',
|
||||||
|
gqlFields: AUDIT_LOG_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [AUDIT_LOG_1_ID, AUDIT_LOG_2_ID],
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.auditLogs.edges).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('9b. should not find one auditLog anymore', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'auditLog',
|
||||||
|
gqlFields: AUDIT_LOG_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: AUDIT_LOG_3_ID,
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.auditLog).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,406 @@
|
|||||||
|
import { TIM_ACCOUNT_ID } from 'test/integration/graphql/integration.constants';
|
||||||
|
import { createManyOperationFactory } from 'test/integration/graphql/utils/create-many-operation-factory.util';
|
||||||
|
import { createOneOperationFactory } from 'test/integration/graphql/utils/create-one-operation-factory.util';
|
||||||
|
import { deleteManyOperationFactory } from 'test/integration/graphql/utils/delete-many-operation-factory.util';
|
||||||
|
import { deleteOneOperationFactory } from 'test/integration/graphql/utils/delete-one-operation-factory.util';
|
||||||
|
import { destroyManyOperationFactory } from 'test/integration/graphql/utils/destroy-many-operation-factory.util';
|
||||||
|
import { destroyOneOperationFactory } from 'test/integration/graphql/utils/destroy-one-operation-factory.util';
|
||||||
|
import { findManyOperationFactory } from 'test/integration/graphql/utils/find-many-operation-factory.util';
|
||||||
|
import { findOneOperationFactory } from 'test/integration/graphql/utils/find-one-operation-factory.util';
|
||||||
|
import { makeGraphqlAPIRequest } from 'test/integration/graphql/utils/make-graphql-api-request.util';
|
||||||
|
import { updateManyOperationFactory } from 'test/integration/graphql/utils/update-many-operation-factory.util';
|
||||||
|
import { updateOneOperationFactory } from 'test/integration/graphql/utils/update-one-operation-factory.util';
|
||||||
|
|
||||||
|
const BLOCKLIST_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
||||||
|
const BLOCKLIST_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
||||||
|
const BLOCKLIST_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
||||||
|
const BLOCKLIST_HANDLE_1 = 'email@email.com';
|
||||||
|
const BLOCKLIST_HANDLE_2 = '@domain.com';
|
||||||
|
const BLOCKLIST_HANDLE_3 = '@domain.org';
|
||||||
|
const UPDATED_BLOCKLIST_HANDLE_1 = 'updated@email.com';
|
||||||
|
const UPDATED_BLOCKLIST_HANDLE_2 = '@updated-domain.com';
|
||||||
|
|
||||||
|
const BLOCKLIST_GQL_FIELDS = `
|
||||||
|
id
|
||||||
|
handle
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
deletedAt
|
||||||
|
workspaceMemberId
|
||||||
|
`;
|
||||||
|
|
||||||
|
describe('blocklists resolvers (integration)', () => {
|
||||||
|
it('1. should create and return blocklists', async () => {
|
||||||
|
const graphqlOperation = createManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'blocklist',
|
||||||
|
objectMetadataPluralName: 'blocklists',
|
||||||
|
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: BLOCKLIST_1_ID,
|
||||||
|
handle: BLOCKLIST_HANDLE_1,
|
||||||
|
workspaceMemberId: TIM_ACCOUNT_ID,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: BLOCKLIST_2_ID,
|
||||||
|
handle: BLOCKLIST_HANDLE_2,
|
||||||
|
workspaceMemberId: TIM_ACCOUNT_ID,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.createBlocklists).toHaveLength(2);
|
||||||
|
|
||||||
|
response.body.data.createBlocklists.forEach((blocklist) => {
|
||||||
|
expect(blocklist).toHaveProperty('handle');
|
||||||
|
expect([BLOCKLIST_HANDLE_1, BLOCKLIST_HANDLE_2]).toContain(
|
||||||
|
blocklist.handle,
|
||||||
|
);
|
||||||
|
expect(blocklist).toHaveProperty('id');
|
||||||
|
expect(blocklist).toHaveProperty('createdAt');
|
||||||
|
expect(blocklist).toHaveProperty('updatedAt');
|
||||||
|
expect(blocklist).toHaveProperty('deletedAt');
|
||||||
|
expect(blocklist).toHaveProperty('workspaceMemberId');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('1b. should create and return one blocklist', async () => {
|
||||||
|
const graphqlOperation = createOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'blocklist',
|
||||||
|
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
id: BLOCKLIST_3_ID,
|
||||||
|
handle: BLOCKLIST_HANDLE_3,
|
||||||
|
workspaceMemberId: TIM_ACCOUNT_ID,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const createdBlocklist = response.body.data.createBlocklist;
|
||||||
|
|
||||||
|
expect(createdBlocklist).toHaveProperty('handle');
|
||||||
|
expect(createdBlocklist.handle).toEqual(BLOCKLIST_HANDLE_3);
|
||||||
|
expect(createdBlocklist).toHaveProperty('id');
|
||||||
|
expect(createdBlocklist).toHaveProperty('createdAt');
|
||||||
|
expect(createdBlocklist).toHaveProperty('updatedAt');
|
||||||
|
expect(createdBlocklist).toHaveProperty('deletedAt');
|
||||||
|
expect(createdBlocklist).toHaveProperty('workspaceMemberId');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('2. should find many blocklists', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'blocklist',
|
||||||
|
objectMetadataPluralName: 'blocklists',
|
||||||
|
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const data = response.body.data.blocklists;
|
||||||
|
|
||||||
|
expect(data).toBeDefined();
|
||||||
|
expect(Array.isArray(data.edges)).toBe(true);
|
||||||
|
|
||||||
|
if (data.edges.length > 0) {
|
||||||
|
const blocklists = data.edges[0].node;
|
||||||
|
|
||||||
|
expect(blocklists).toHaveProperty('handle');
|
||||||
|
expect(blocklists).toHaveProperty('id');
|
||||||
|
expect(blocklists).toHaveProperty('createdAt');
|
||||||
|
expect(blocklists).toHaveProperty('updatedAt');
|
||||||
|
expect(blocklists).toHaveProperty('deletedAt');
|
||||||
|
expect(blocklists).toHaveProperty('workspaceMemberId');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('2b. should find one blocklist', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'blocklist',
|
||||||
|
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: BLOCKLIST_3_ID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const blocklist = response.body.data.blocklist;
|
||||||
|
|
||||||
|
expect(blocklist).toHaveProperty('handle');
|
||||||
|
expect(blocklist).toHaveProperty('id');
|
||||||
|
expect(blocklist).toHaveProperty('createdAt');
|
||||||
|
expect(blocklist).toHaveProperty('updatedAt');
|
||||||
|
expect(blocklist).toHaveProperty('deletedAt');
|
||||||
|
expect(blocklist).toHaveProperty('workspaceMemberId');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('3. should not update many blocklists', async () => {
|
||||||
|
const graphqlOperation = updateManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'blocklist',
|
||||||
|
objectMetadataPluralName: 'blocklists',
|
||||||
|
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
handle: UPDATED_BLOCKLIST_HANDLE_1,
|
||||||
|
workspaceMemberId: TIM_ACCOUNT_ID,
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [BLOCKLIST_1_ID, BLOCKLIST_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.updateBlocklists).toBeNull();
|
||||||
|
expect(response.body.errors).toStrictEqual([
|
||||||
|
{
|
||||||
|
extensions: { code: 'INTERNAL_SERVER_ERROR' },
|
||||||
|
message: 'Method not allowed.',
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('3b. should update one blocklist', async () => {
|
||||||
|
const graphqlOperation = updateOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'blocklist',
|
||||||
|
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
handle: UPDATED_BLOCKLIST_HANDLE_2,
|
||||||
|
workspaceMemberId: TIM_ACCOUNT_ID,
|
||||||
|
},
|
||||||
|
recordId: BLOCKLIST_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const updatedBlocklist = response.body.data.updateBlocklist;
|
||||||
|
|
||||||
|
expect(updatedBlocklist.handle).toEqual(UPDATED_BLOCKLIST_HANDLE_2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('4. should not find many blocklists with updated name', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'blocklist',
|
||||||
|
objectMetadataPluralName: 'blocklists',
|
||||||
|
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
handle: {
|
||||||
|
eq: UPDATED_BLOCKLIST_HANDLE_1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.blocklists.edges).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('4b. should find one blocklist with updated name', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'blocklist',
|
||||||
|
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
handle: {
|
||||||
|
eq: UPDATED_BLOCKLIST_HANDLE_2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.blocklist.handle).toEqual(
|
||||||
|
UPDATED_BLOCKLIST_HANDLE_2,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('5. should delete many blocklists', async () => {
|
||||||
|
const graphqlOperation = deleteManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'blocklist',
|
||||||
|
objectMetadataPluralName: 'blocklists',
|
||||||
|
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [BLOCKLIST_1_ID, BLOCKLIST_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const deletedBlocklists = response.body.data.deleteBlocklists;
|
||||||
|
|
||||||
|
expect(deletedBlocklists).toHaveLength(2);
|
||||||
|
|
||||||
|
deletedBlocklists.forEach((blocklist) => {
|
||||||
|
expect(blocklist.deletedAt).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('5b. should delete one blocklist', async () => {
|
||||||
|
const graphqlOperation = deleteOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'blocklist',
|
||||||
|
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||||
|
recordId: BLOCKLIST_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.deleteBlocklist.deletedAt).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('6. should not find many blocklists anymore', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'blocklist',
|
||||||
|
objectMetadataPluralName: 'blocklists',
|
||||||
|
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [BLOCKLIST_1_ID, BLOCKLIST_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const findBlocklistsResponse =
|
||||||
|
await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(findBlocklistsResponse.body.data.blocklists.edges).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('6b. should not find one blocklist anymore', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'blocklist',
|
||||||
|
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: BLOCKLIST_3_ID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.blocklist).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('7. should find many deleted blocklists with deletedAt filter', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'blocklist',
|
||||||
|
objectMetadataPluralName: 'blocklists',
|
||||||
|
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [BLOCKLIST_1_ID, BLOCKLIST_2_ID],
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.blocklists.edges).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('7b. should find one deleted blocklist with deletedAt filter', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'blocklist',
|
||||||
|
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: BLOCKLIST_3_ID,
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.blocklist.id).toEqual(BLOCKLIST_3_ID);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('8. should destroy many blocklists', async () => {
|
||||||
|
const graphqlOperation = destroyManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'blocklist',
|
||||||
|
objectMetadataPluralName: 'blocklists',
|
||||||
|
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [BLOCKLIST_1_ID, BLOCKLIST_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.destroyBlocklists).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('8b. should destroy one blocklist', async () => {
|
||||||
|
const graphqlOperation = destroyOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'blocklist',
|
||||||
|
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||||
|
recordId: BLOCKLIST_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const destroyBlocklistResponse =
|
||||||
|
await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(destroyBlocklistResponse.body.data.destroyBlocklist).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('9. should not find many blocklists anymore', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'blocklist',
|
||||||
|
objectMetadataPluralName: 'blocklists',
|
||||||
|
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [BLOCKLIST_1_ID, BLOCKLIST_2_ID],
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.blocklists.edges).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('9b. should not find one blocklist anymore', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'blocklist',
|
||||||
|
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: BLOCKLIST_3_ID,
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.blocklist).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,535 @@
|
|||||||
|
import { TIM_ACCOUNT_ID } from 'test/integration/graphql/integration.constants';
|
||||||
|
import { createManyOperationFactory } from 'test/integration/graphql/utils/create-many-operation-factory.util';
|
||||||
|
import { createOneOperationFactory } from 'test/integration/graphql/utils/create-one-operation-factory.util';
|
||||||
|
import { deleteManyOperationFactory } from 'test/integration/graphql/utils/delete-many-operation-factory.util';
|
||||||
|
import { deleteOneOperationFactory } from 'test/integration/graphql/utils/delete-one-operation-factory.util';
|
||||||
|
import { destroyManyOperationFactory } from 'test/integration/graphql/utils/destroy-many-operation-factory.util';
|
||||||
|
import { destroyOneOperationFactory } from 'test/integration/graphql/utils/destroy-one-operation-factory.util';
|
||||||
|
import { findManyOperationFactory } from 'test/integration/graphql/utils/find-many-operation-factory.util';
|
||||||
|
import { findOneOperationFactory } from 'test/integration/graphql/utils/find-one-operation-factory.util';
|
||||||
|
import { makeGraphqlAPIRequest } from 'test/integration/graphql/utils/make-graphql-api-request.util';
|
||||||
|
import { updateManyOperationFactory } from 'test/integration/graphql/utils/update-many-operation-factory.util';
|
||||||
|
import { updateOneOperationFactory } from 'test/integration/graphql/utils/update-one-operation-factory.util';
|
||||||
|
import { generateRecordName } from 'test/integration/utils/generate-record-name';
|
||||||
|
|
||||||
|
const CALENDAR_CHANNEL_EVENT_ASSOCIATION_1_ID =
|
||||||
|
'777a8457-eb2d-40ac-a707-551b615b6987';
|
||||||
|
const CALENDAR_CHANNEL_EVENT_ASSOCIATION_2_ID =
|
||||||
|
'777a8457-eb2d-40ac-a707-551b615b6988';
|
||||||
|
const CALENDAR_CHANNEL_EVENT_ASSOCIATION_3_ID =
|
||||||
|
'777a8457-eb2d-40ac-a707-551b615b6989';
|
||||||
|
const CALENDAR_EVENT_ID = '777a8457-eb2d-40ac-a707-221b615b6989';
|
||||||
|
const CALENDAR_CHANNEL_ID = '777a8457-eb2d-40ac-a707-331b615b6989';
|
||||||
|
const CONNECTED_ACCOUNT_ID = '777a8457-eb2d-40ac-a707-441b615b6989';
|
||||||
|
|
||||||
|
const CALENDAR_CHANNEL_EVENT_ASSOCIATION_GQL_FIELDS = `
|
||||||
|
id
|
||||||
|
eventExternalId
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
deletedAt
|
||||||
|
calendarChannelId
|
||||||
|
calendarEventId
|
||||||
|
`;
|
||||||
|
|
||||||
|
describe('calendarChannelEventAssociations resolvers (integration)', () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
const connectedAccountHandle = generateRecordName(CONNECTED_ACCOUNT_ID);
|
||||||
|
const createConnectedAccountgraphqlOperation = createOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'connectedAccount',
|
||||||
|
gqlFields: `id`,
|
||||||
|
data: {
|
||||||
|
id: CONNECTED_ACCOUNT_ID,
|
||||||
|
accountOwnerId: TIM_ACCOUNT_ID,
|
||||||
|
handle: connectedAccountHandle,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const calendarChannelHandle = generateRecordName(CALENDAR_CHANNEL_ID);
|
||||||
|
const createCalendarChannelgraphqlOperation = createOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
gqlFields: `id`,
|
||||||
|
data: {
|
||||||
|
id: CALENDAR_CHANNEL_ID,
|
||||||
|
handle: calendarChannelHandle,
|
||||||
|
connectedAccountId: CONNECTED_ACCOUNT_ID,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const calendarEventTitle = generateRecordName(CALENDAR_EVENT_ID);
|
||||||
|
const createCalendarEventgraphqlOperation = createOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarEvent',
|
||||||
|
gqlFields: `id`,
|
||||||
|
data: {
|
||||||
|
id: CALENDAR_EVENT_ID,
|
||||||
|
title: calendarEventTitle,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await makeGraphqlAPIRequest(createConnectedAccountgraphqlOperation);
|
||||||
|
|
||||||
|
await makeGraphqlAPIRequest(createCalendarChannelgraphqlOperation);
|
||||||
|
await makeGraphqlAPIRequest(createCalendarEventgraphqlOperation);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
const destroyConnectedAccountGraphqlOperation = destroyOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'connectedAccount',
|
||||||
|
gqlFields: `id`,
|
||||||
|
recordId: CONNECTED_ACCOUNT_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const destroyCalendarChannelGraphqlOperation = destroyOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
gqlFields: `id`,
|
||||||
|
recordId: CALENDAR_CHANNEL_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const destroyCalendarEventGraphqlOperation = destroyOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarEvent',
|
||||||
|
gqlFields: `id`,
|
||||||
|
recordId: CALENDAR_EVENT_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
await makeGraphqlAPIRequest(destroyConnectedAccountGraphqlOperation);
|
||||||
|
await makeGraphqlAPIRequest(destroyCalendarChannelGraphqlOperation);
|
||||||
|
await makeGraphqlAPIRequest(destroyCalendarEventGraphqlOperation);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('1. should create and return calendarChannelEventAssociations', async () => {
|
||||||
|
const eventExternalId1 = generateRecordName(
|
||||||
|
CALENDAR_CHANNEL_EVENT_ASSOCIATION_1_ID,
|
||||||
|
);
|
||||||
|
const eventExternalId2 = generateRecordName(
|
||||||
|
CALENDAR_CHANNEL_EVENT_ASSOCIATION_2_ID,
|
||||||
|
);
|
||||||
|
|
||||||
|
const graphqlOperation = createManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannelEventAssociation',
|
||||||
|
objectMetadataPluralName: 'calendarChannelEventAssociations',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_EVENT_ASSOCIATION_GQL_FIELDS,
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: CALENDAR_CHANNEL_EVENT_ASSOCIATION_1_ID,
|
||||||
|
eventExternalId: eventExternalId1,
|
||||||
|
calendarChannelId: CALENDAR_CHANNEL_ID,
|
||||||
|
calendarEventId: CALENDAR_EVENT_ID,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: CALENDAR_CHANNEL_EVENT_ASSOCIATION_2_ID,
|
||||||
|
eventExternalId: eventExternalId2,
|
||||||
|
calendarChannelId: CALENDAR_CHANNEL_ID,
|
||||||
|
calendarEventId: CALENDAR_EVENT_ID,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
response.body.data.createCalendarChannelEventAssociations,
|
||||||
|
).toHaveLength(2);
|
||||||
|
|
||||||
|
response.body.data.createCalendarChannelEventAssociations.forEach(
|
||||||
|
(association) => {
|
||||||
|
expect(association).toHaveProperty('eventExternalId');
|
||||||
|
expect([eventExternalId1, eventExternalId2]).toContain(
|
||||||
|
association.eventExternalId,
|
||||||
|
);
|
||||||
|
expect(association).toHaveProperty('id');
|
||||||
|
expect(association).toHaveProperty('createdAt');
|
||||||
|
expect(association).toHaveProperty('updatedAt');
|
||||||
|
expect(association).toHaveProperty('deletedAt');
|
||||||
|
expect(association).toHaveProperty('calendarChannelId');
|
||||||
|
expect(association).toHaveProperty('calendarEventId');
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('1b. should create and return one calendarChannelEventAssociation', async () => {
|
||||||
|
const eventExternalId = generateRecordName(
|
||||||
|
CALENDAR_CHANNEL_EVENT_ASSOCIATION_3_ID,
|
||||||
|
);
|
||||||
|
|
||||||
|
const graphqlOperation = createOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannelEventAssociation',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_EVENT_ASSOCIATION_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
id: CALENDAR_CHANNEL_EVENT_ASSOCIATION_3_ID,
|
||||||
|
eventExternalId: eventExternalId,
|
||||||
|
calendarChannelId: CALENDAR_CHANNEL_ID,
|
||||||
|
calendarEventId: CALENDAR_EVENT_ID,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const createdAssociation =
|
||||||
|
response.body.data.createCalendarChannelEventAssociation;
|
||||||
|
|
||||||
|
expect(createdAssociation).toHaveProperty('eventExternalId');
|
||||||
|
expect(createdAssociation.eventExternalId).toEqual(eventExternalId);
|
||||||
|
expect(createdAssociation).toHaveProperty('id');
|
||||||
|
expect(createdAssociation).toHaveProperty('createdAt');
|
||||||
|
expect(createdAssociation).toHaveProperty('updatedAt');
|
||||||
|
expect(createdAssociation).toHaveProperty('deletedAt');
|
||||||
|
expect(createdAssociation).toHaveProperty('calendarChannelId');
|
||||||
|
expect(createdAssociation).toHaveProperty('calendarEventId');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('2. should find many calendarChannelEventAssociations', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannelEventAssociation',
|
||||||
|
objectMetadataPluralName: 'calendarChannelEventAssociations',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_EVENT_ASSOCIATION_GQL_FIELDS,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const data = response.body.data.calendarChannelEventAssociations;
|
||||||
|
|
||||||
|
expect(data).toBeDefined();
|
||||||
|
expect(Array.isArray(data.edges)).toBe(true);
|
||||||
|
|
||||||
|
if (data.edges.length > 0) {
|
||||||
|
const associations = data.edges[0].node;
|
||||||
|
|
||||||
|
expect(associations).toHaveProperty('eventExternalId');
|
||||||
|
expect(associations).toHaveProperty('id');
|
||||||
|
expect(associations).toHaveProperty('createdAt');
|
||||||
|
expect(associations).toHaveProperty('updatedAt');
|
||||||
|
expect(associations).toHaveProperty('deletedAt');
|
||||||
|
expect(associations).toHaveProperty('calendarChannelId');
|
||||||
|
expect(associations).toHaveProperty('calendarEventId');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('2b. should find one calendarChannelEventAssociation', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannelEventAssociation',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_EVENT_ASSOCIATION_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: CALENDAR_CHANNEL_EVENT_ASSOCIATION_3_ID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const association = response.body.data.calendarChannelEventAssociation;
|
||||||
|
|
||||||
|
expect(association).toHaveProperty('eventExternalId');
|
||||||
|
expect(association).toHaveProperty('id');
|
||||||
|
expect(association).toHaveProperty('createdAt');
|
||||||
|
expect(association).toHaveProperty('updatedAt');
|
||||||
|
expect(association).toHaveProperty('deletedAt');
|
||||||
|
expect(association).toHaveProperty('calendarChannelId');
|
||||||
|
expect(association).toHaveProperty('calendarEventId');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('3. should update many calendarChannelEventAssociations', async () => {
|
||||||
|
const graphqlOperation = updateManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannelEventAssociation',
|
||||||
|
objectMetadataPluralName: 'calendarChannelEventAssociations',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_EVENT_ASSOCIATION_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
eventExternalId: 'updated-message-external-id',
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [
|
||||||
|
CALENDAR_CHANNEL_EVENT_ASSOCIATION_1_ID,
|
||||||
|
CALENDAR_CHANNEL_EVENT_ASSOCIATION_2_ID,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const updatedAssociations =
|
||||||
|
response.body.data.updateCalendarChannelEventAssociations;
|
||||||
|
|
||||||
|
expect(updatedAssociations).toHaveLength(2);
|
||||||
|
|
||||||
|
updatedAssociations.forEach((association) => {
|
||||||
|
expect(association.eventExternalId).toEqual(
|
||||||
|
'updated-message-external-id',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('3b. should update one calendarChannelEventAssociation', async () => {
|
||||||
|
const graphqlOperation = updateOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannelEventAssociation',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_EVENT_ASSOCIATION_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
eventExternalId: 'new-message-external-id',
|
||||||
|
},
|
||||||
|
recordId: CALENDAR_CHANNEL_EVENT_ASSOCIATION_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const updatedAssociation =
|
||||||
|
response.body.data.updateCalendarChannelEventAssociation;
|
||||||
|
|
||||||
|
expect(updatedAssociation.eventExternalId).toEqual(
|
||||||
|
'new-message-external-id',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('4. should find many calendarChannelEventAssociations with updated eventExternalId', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannelEventAssociation',
|
||||||
|
objectMetadataPluralName: 'calendarChannelEventAssociations',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_EVENT_ASSOCIATION_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
eventExternalId: {
|
||||||
|
eq: 'updated-message-external-id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
response.body.data.calendarChannelEventAssociations.edges,
|
||||||
|
).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('4b. should find one calendarChannelEventAssociation with updated eventExternalId', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannelEventAssociation',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_EVENT_ASSOCIATION_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
eventExternalId: {
|
||||||
|
eq: 'new-message-external-id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
response.body.data.calendarChannelEventAssociation.eventExternalId,
|
||||||
|
).toEqual('new-message-external-id');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('5. should delete many calendarChannelEventAssociations', async () => {
|
||||||
|
const graphqlOperation = deleteManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannelEventAssociation',
|
||||||
|
objectMetadataPluralName: 'calendarChannelEventAssociations',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_EVENT_ASSOCIATION_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [
|
||||||
|
CALENDAR_CHANNEL_EVENT_ASSOCIATION_1_ID,
|
||||||
|
CALENDAR_CHANNEL_EVENT_ASSOCIATION_2_ID,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const deletedAssociations =
|
||||||
|
response.body.data.deleteCalendarChannelEventAssociations;
|
||||||
|
|
||||||
|
expect(deletedAssociations).toHaveLength(2);
|
||||||
|
|
||||||
|
deletedAssociations.forEach((association) => {
|
||||||
|
expect(association.deletedAt).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('5b. should delete one calendarChannelEventAssociation', async () => {
|
||||||
|
const graphqlOperation = deleteOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannelEventAssociation',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_EVENT_ASSOCIATION_GQL_FIELDS,
|
||||||
|
recordId: CALENDAR_CHANNEL_EVENT_ASSOCIATION_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
response.body.data.deleteCalendarChannelEventAssociation.deletedAt,
|
||||||
|
).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('6. should not find many calendarChannelEventAssociations anymore', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannelEventAssociation',
|
||||||
|
objectMetadataPluralName: 'calendarChannelEventAssociations',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_EVENT_ASSOCIATION_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [
|
||||||
|
CALENDAR_CHANNEL_EVENT_ASSOCIATION_1_ID,
|
||||||
|
CALENDAR_CHANNEL_EVENT_ASSOCIATION_2_ID,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const findAssociationsResponse =
|
||||||
|
await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
findAssociationsResponse.body.data.calendarChannelEventAssociations.edges,
|
||||||
|
).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('6b. should not find one calendarChannelEventAssociation anymore', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannelEventAssociation',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_EVENT_ASSOCIATION_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: CALENDAR_CHANNEL_EVENT_ASSOCIATION_3_ID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.calendarChannelEventAssociation).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('7. should find many deleted calendarChannelEventAssociations with deletedAt filter', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannelEventAssociation',
|
||||||
|
objectMetadataPluralName: 'calendarChannelEventAssociations',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_EVENT_ASSOCIATION_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [
|
||||||
|
CALENDAR_CHANNEL_EVENT_ASSOCIATION_1_ID,
|
||||||
|
CALENDAR_CHANNEL_EVENT_ASSOCIATION_2_ID,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
response.body.data.calendarChannelEventAssociations.edges,
|
||||||
|
).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('7b. should find one deleted calendarChannelEventAssociation with deletedAt filter', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannelEventAssociation',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_EVENT_ASSOCIATION_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: CALENDAR_CHANNEL_EVENT_ASSOCIATION_3_ID,
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.calendarChannelEventAssociation.id).toEqual(
|
||||||
|
CALENDAR_CHANNEL_EVENT_ASSOCIATION_3_ID,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('8. should destroy many calendarChannelEventAssociations', async () => {
|
||||||
|
const graphqlOperation = destroyManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannelEventAssociation',
|
||||||
|
objectMetadataPluralName: 'calendarChannelEventAssociations',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_EVENT_ASSOCIATION_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [
|
||||||
|
CALENDAR_CHANNEL_EVENT_ASSOCIATION_1_ID,
|
||||||
|
CALENDAR_CHANNEL_EVENT_ASSOCIATION_2_ID,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
response.body.data.destroyCalendarChannelEventAssociations,
|
||||||
|
).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('8b. should destroy one calendarChannelEventAssociation', async () => {
|
||||||
|
const graphqlOperation = destroyOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannelEventAssociation',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_EVENT_ASSOCIATION_GQL_FIELDS,
|
||||||
|
recordId: CALENDAR_CHANNEL_EVENT_ASSOCIATION_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const destroyAssociationResponse =
|
||||||
|
await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
destroyAssociationResponse.body.data
|
||||||
|
.destroyCalendarChannelEventAssociation,
|
||||||
|
).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('9. should not find many calendarChannelEventAssociations anymore', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannelEventAssociation',
|
||||||
|
objectMetadataPluralName: 'calendarChannelEventAssociations',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_EVENT_ASSOCIATION_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [
|
||||||
|
CALENDAR_CHANNEL_EVENT_ASSOCIATION_1_ID,
|
||||||
|
CALENDAR_CHANNEL_EVENT_ASSOCIATION_2_ID,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
response.body.data.calendarChannelEventAssociations.edges,
|
||||||
|
).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('9b. should not find one calendarChannelEventAssociation anymore', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannelEventAssociation',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_EVENT_ASSOCIATION_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: CALENDAR_CHANNEL_EVENT_ASSOCIATION_3_ID,
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.calendarChannelEventAssociation).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,482 @@
|
|||||||
|
import { TIM_ACCOUNT_ID } from 'test/integration/graphql/integration.constants';
|
||||||
|
import { createManyOperationFactory } from 'test/integration/graphql/utils/create-many-operation-factory.util';
|
||||||
|
import { createOneOperationFactory } from 'test/integration/graphql/utils/create-one-operation-factory.util';
|
||||||
|
import { deleteManyOperationFactory } from 'test/integration/graphql/utils/delete-many-operation-factory.util';
|
||||||
|
import { deleteOneOperationFactory } from 'test/integration/graphql/utils/delete-one-operation-factory.util';
|
||||||
|
import { destroyManyOperationFactory } from 'test/integration/graphql/utils/destroy-many-operation-factory.util';
|
||||||
|
import { destroyOneOperationFactory } from 'test/integration/graphql/utils/destroy-one-operation-factory.util';
|
||||||
|
import { findManyOperationFactory } from 'test/integration/graphql/utils/find-many-operation-factory.util';
|
||||||
|
import { findOneOperationFactory } from 'test/integration/graphql/utils/find-one-operation-factory.util';
|
||||||
|
import { makeGraphqlAPIRequest } from 'test/integration/graphql/utils/make-graphql-api-request.util';
|
||||||
|
import { updateManyOperationFactory } from 'test/integration/graphql/utils/update-many-operation-factory.util';
|
||||||
|
import { updateOneOperationFactory } from 'test/integration/graphql/utils/update-one-operation-factory.util';
|
||||||
|
import { generateRecordName } from 'test/integration/utils/generate-record-name';
|
||||||
|
|
||||||
|
const CALENDAR_CHANNEL_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
||||||
|
const CALENDAR_CHANNEL_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
||||||
|
const CALENDAR_CHANNEL_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
||||||
|
const CONNECTED_ACCOUNT_ID = '777a8457-eb2d-40ac-a707-441b615b6989';
|
||||||
|
|
||||||
|
const CALENDAR_CHANNEL_GQL_FIELDS = `
|
||||||
|
id
|
||||||
|
handle
|
||||||
|
syncStatus
|
||||||
|
syncStage
|
||||||
|
visibility
|
||||||
|
isContactAutoCreationEnabled
|
||||||
|
contactAutoCreationPolicy
|
||||||
|
isSyncEnabled
|
||||||
|
syncCursor
|
||||||
|
syncStageStartedAt
|
||||||
|
throttleFailureCount
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
deletedAt
|
||||||
|
connectedAccountId
|
||||||
|
`;
|
||||||
|
|
||||||
|
describe('calendarChannels resolvers (integration)', () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
const connectedAccountHandle = generateRecordName(CONNECTED_ACCOUNT_ID);
|
||||||
|
const createConnectedAccountgraphqlOperation = createOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'connectedAccount',
|
||||||
|
gqlFields: `id`,
|
||||||
|
data: {
|
||||||
|
id: CONNECTED_ACCOUNT_ID,
|
||||||
|
accountOwnerId: TIM_ACCOUNT_ID,
|
||||||
|
handle: connectedAccountHandle,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await makeGraphqlAPIRequest(createConnectedAccountgraphqlOperation);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
const destroyConnectedAccountGraphqlOperation = destroyOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'connectedAccount',
|
||||||
|
gqlFields: `id`,
|
||||||
|
recordId: CONNECTED_ACCOUNT_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
await makeGraphqlAPIRequest(destroyConnectedAccountGraphqlOperation);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('1. should create and return calendarChannels', async () => {
|
||||||
|
const calendarChannelHandle1 = generateRecordName(CALENDAR_CHANNEL_1_ID);
|
||||||
|
const calendarChannelHandle2 = generateRecordName(CALENDAR_CHANNEL_2_ID);
|
||||||
|
|
||||||
|
const graphqlOperation = createManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
objectMetadataPluralName: 'calendarChannels',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: CALENDAR_CHANNEL_1_ID,
|
||||||
|
handle: calendarChannelHandle1,
|
||||||
|
connectedAccountId: CONNECTED_ACCOUNT_ID,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: CALENDAR_CHANNEL_2_ID,
|
||||||
|
handle: calendarChannelHandle2,
|
||||||
|
connectedAccountId: CONNECTED_ACCOUNT_ID,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.createCalendarChannels).toHaveLength(2);
|
||||||
|
|
||||||
|
response.body.data.createCalendarChannels.forEach((calendarChannel) => {
|
||||||
|
expect(calendarChannel).toHaveProperty('handle');
|
||||||
|
expect([calendarChannelHandle1, calendarChannelHandle2]).toContain(
|
||||||
|
calendarChannel.handle,
|
||||||
|
);
|
||||||
|
expect(calendarChannel).toHaveProperty('id');
|
||||||
|
expect(calendarChannel).toHaveProperty('syncStatus');
|
||||||
|
expect(calendarChannel).toHaveProperty('syncStage');
|
||||||
|
expect(calendarChannel).toHaveProperty('visibility');
|
||||||
|
expect(calendarChannel).toHaveProperty('isContactAutoCreationEnabled');
|
||||||
|
expect(calendarChannel).toHaveProperty('contactAutoCreationPolicy');
|
||||||
|
expect(calendarChannel).toHaveProperty('isSyncEnabled');
|
||||||
|
expect(calendarChannel).toHaveProperty('syncCursor');
|
||||||
|
expect(calendarChannel).toHaveProperty('syncStageStartedAt');
|
||||||
|
expect(calendarChannel).toHaveProperty('throttleFailureCount');
|
||||||
|
expect(calendarChannel).toHaveProperty('createdAt');
|
||||||
|
expect(calendarChannel).toHaveProperty('updatedAt');
|
||||||
|
expect(calendarChannel).toHaveProperty('deletedAt');
|
||||||
|
expect(calendarChannel).toHaveProperty('connectedAccountId');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('1b. should create and return one calendarChannel', async () => {
|
||||||
|
const calendarChannelHandle = generateRecordName(CALENDAR_CHANNEL_3_ID);
|
||||||
|
|
||||||
|
const graphqlOperation = createOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
id: CALENDAR_CHANNEL_3_ID,
|
||||||
|
handle: calendarChannelHandle,
|
||||||
|
connectedAccountId: CONNECTED_ACCOUNT_ID,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const createdCalendarChannel = response.body.data.createCalendarChannel;
|
||||||
|
|
||||||
|
expect(createdCalendarChannel).toHaveProperty('handle');
|
||||||
|
expect(createdCalendarChannel.handle).toEqual(calendarChannelHandle);
|
||||||
|
expect(createdCalendarChannel).toHaveProperty('id');
|
||||||
|
expect(createdCalendarChannel).toHaveProperty('syncStatus');
|
||||||
|
expect(createdCalendarChannel).toHaveProperty('syncStage');
|
||||||
|
expect(createdCalendarChannel).toHaveProperty('visibility');
|
||||||
|
expect(createdCalendarChannel).toHaveProperty(
|
||||||
|
'isContactAutoCreationEnabled',
|
||||||
|
);
|
||||||
|
expect(createdCalendarChannel).toHaveProperty('contactAutoCreationPolicy');
|
||||||
|
expect(createdCalendarChannel).toHaveProperty('isSyncEnabled');
|
||||||
|
expect(createdCalendarChannel).toHaveProperty('syncCursor');
|
||||||
|
expect(createdCalendarChannel).toHaveProperty('syncStageStartedAt');
|
||||||
|
expect(createdCalendarChannel).toHaveProperty('throttleFailureCount');
|
||||||
|
expect(createdCalendarChannel).toHaveProperty('createdAt');
|
||||||
|
expect(createdCalendarChannel).toHaveProperty('updatedAt');
|
||||||
|
expect(createdCalendarChannel).toHaveProperty('deletedAt');
|
||||||
|
expect(createdCalendarChannel).toHaveProperty('connectedAccountId');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('2. should find many calendarChannels', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
objectMetadataPluralName: 'calendarChannels',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const data = response.body.data.calendarChannels;
|
||||||
|
|
||||||
|
expect(data).toBeDefined();
|
||||||
|
expect(Array.isArray(data.edges)).toBe(true);
|
||||||
|
|
||||||
|
if (data.edges.length > 0) {
|
||||||
|
const calendarChannels = data.edges[0].node;
|
||||||
|
|
||||||
|
expect(calendarChannels).toHaveProperty('handle');
|
||||||
|
expect(calendarChannels).toHaveProperty('syncStatus');
|
||||||
|
expect(calendarChannels).toHaveProperty('syncStage');
|
||||||
|
expect(calendarChannels).toHaveProperty('visibility');
|
||||||
|
expect(calendarChannels).toHaveProperty('isContactAutoCreationEnabled');
|
||||||
|
expect(calendarChannels).toHaveProperty('contactAutoCreationPolicy');
|
||||||
|
expect(calendarChannels).toHaveProperty('isSyncEnabled');
|
||||||
|
expect(calendarChannels).toHaveProperty('syncCursor');
|
||||||
|
expect(calendarChannels).toHaveProperty('syncStageStartedAt');
|
||||||
|
expect(calendarChannels).toHaveProperty('throttleFailureCount');
|
||||||
|
expect(calendarChannels).toHaveProperty('id');
|
||||||
|
expect(calendarChannels).toHaveProperty('createdAt');
|
||||||
|
expect(calendarChannels).toHaveProperty('updatedAt');
|
||||||
|
expect(calendarChannels).toHaveProperty('deletedAt');
|
||||||
|
expect(calendarChannels).toHaveProperty('connectedAccountId');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('2b. should find one calendarChannel', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: CALENDAR_CHANNEL_3_ID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const calendarChannel = response.body.data.calendarChannel;
|
||||||
|
|
||||||
|
expect(calendarChannel).toHaveProperty('handle');
|
||||||
|
expect(calendarChannel).toHaveProperty('syncStatus');
|
||||||
|
expect(calendarChannel).toHaveProperty('syncStage');
|
||||||
|
expect(calendarChannel).toHaveProperty('visibility');
|
||||||
|
expect(calendarChannel).toHaveProperty('isContactAutoCreationEnabled');
|
||||||
|
expect(calendarChannel).toHaveProperty('contactAutoCreationPolicy');
|
||||||
|
expect(calendarChannel).toHaveProperty('isSyncEnabled');
|
||||||
|
expect(calendarChannel).toHaveProperty('syncCursor');
|
||||||
|
expect(calendarChannel).toHaveProperty('syncStageStartedAt');
|
||||||
|
expect(calendarChannel).toHaveProperty('throttleFailureCount');
|
||||||
|
expect(calendarChannel).toHaveProperty('id');
|
||||||
|
expect(calendarChannel).toHaveProperty('createdAt');
|
||||||
|
expect(calendarChannel).toHaveProperty('updatedAt');
|
||||||
|
expect(calendarChannel).toHaveProperty('deletedAt');
|
||||||
|
expect(calendarChannel).toHaveProperty('connectedAccountId');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('3. should update many calendarChannels', async () => {
|
||||||
|
const graphqlOperation = updateManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
objectMetadataPluralName: 'calendarChannels',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
handle: 'Updated Handle',
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [CALENDAR_CHANNEL_1_ID, CALENDAR_CHANNEL_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const updatedCalendarChannels = response.body.data.updateCalendarChannels;
|
||||||
|
|
||||||
|
expect(updatedCalendarChannels).toHaveLength(2);
|
||||||
|
|
||||||
|
updatedCalendarChannels.forEach((calendarChannel) => {
|
||||||
|
expect(calendarChannel.handle).toEqual('Updated Handle');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('3b. should update one calendarChannel', async () => {
|
||||||
|
const graphqlOperation = updateOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
handle: 'New Handle',
|
||||||
|
},
|
||||||
|
recordId: CALENDAR_CHANNEL_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const updatedCalendarChannel = response.body.data.updateCalendarChannel;
|
||||||
|
|
||||||
|
expect(updatedCalendarChannel.handle).toEqual('New Handle');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('4. should find many calendarChannels with updated handle', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
objectMetadataPluralName: 'calendarChannels',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
handle: {
|
||||||
|
eq: 'Updated Handle',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.calendarChannels.edges).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('4b. should find one calendarChannel with updated handle', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
handle: {
|
||||||
|
eq: 'New Handle',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.calendarChannel.handle).toEqual('New Handle');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('5. should delete many calendarChannels', async () => {
|
||||||
|
const graphqlOperation = deleteManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
objectMetadataPluralName: 'calendarChannels',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [CALENDAR_CHANNEL_1_ID, CALENDAR_CHANNEL_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const deletedCalendarChannels = response.body.data.deleteCalendarChannels;
|
||||||
|
|
||||||
|
expect(deletedCalendarChannels).toHaveLength(2);
|
||||||
|
|
||||||
|
deletedCalendarChannels.forEach((calendarChannel) => {
|
||||||
|
expect(calendarChannel.deletedAt).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('5b. should delete one calendarChannel', async () => {
|
||||||
|
const graphqlOperation = deleteOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||||
|
recordId: CALENDAR_CHANNEL_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.deleteCalendarChannel.deletedAt).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('6. should not find many calendarChannels anymore', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
objectMetadataPluralName: 'calendarChannels',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [CALENDAR_CHANNEL_1_ID, CALENDAR_CHANNEL_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const findCalendarChannelsResponse =
|
||||||
|
await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
findCalendarChannelsResponse.body.data.calendarChannels.edges,
|
||||||
|
).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('6b. should not find one calendarChannel anymore', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: CALENDAR_CHANNEL_3_ID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.calendarChannel).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('7. should find many deleted calendarChannels with deletedAt filter', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
objectMetadataPluralName: 'calendarChannels',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [CALENDAR_CHANNEL_1_ID, CALENDAR_CHANNEL_2_ID],
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.calendarChannels.edges).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('7b. should find one deleted calendarChannel with deletedAt filter', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: CALENDAR_CHANNEL_3_ID,
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.calendarChannel.id).toEqual(
|
||||||
|
CALENDAR_CHANNEL_3_ID,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('8. should destroy many calendarChannels', async () => {
|
||||||
|
const graphqlOperation = destroyManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
objectMetadataPluralName: 'calendarChannels',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [CALENDAR_CHANNEL_1_ID, CALENDAR_CHANNEL_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.destroyCalendarChannels).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('8b. should destroy one calendarChannel', async () => {
|
||||||
|
const graphqlOperation = destroyOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||||
|
recordId: CALENDAR_CHANNEL_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const destroyCalendarChannelResponse =
|
||||||
|
await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
destroyCalendarChannelResponse.body.data.destroyCalendarChannel,
|
||||||
|
).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('9. should not find many calendarChannels anymore', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
objectMetadataPluralName: 'calendarChannels',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [CALENDAR_CHANNEL_1_ID, CALENDAR_CHANNEL_2_ID],
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.calendarChannels.edges).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('9b. should not find one calendarChannel anymore', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'calendarChannel',
|
||||||
|
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: CALENDAR_CHANNEL_3_ID,
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.calendarChannel).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,439 @@
|
|||||||
|
import { TIM_USER_ID } from 'test/integration/graphql/integration.constants';
|
||||||
|
import { createManyOperationFactory } from 'test/integration/graphql/utils/create-many-operation-factory.util';
|
||||||
|
import { createOneOperationFactory } from 'test/integration/graphql/utils/create-one-operation-factory.util';
|
||||||
|
import { deleteManyOperationFactory } from 'test/integration/graphql/utils/delete-many-operation-factory.util';
|
||||||
|
import { deleteOneOperationFactory } from 'test/integration/graphql/utils/delete-one-operation-factory.util';
|
||||||
|
import { destroyManyOperationFactory } from 'test/integration/graphql/utils/destroy-many-operation-factory.util';
|
||||||
|
import { destroyOneOperationFactory } from 'test/integration/graphql/utils/destroy-one-operation-factory.util';
|
||||||
|
import { findManyOperationFactory } from 'test/integration/graphql/utils/find-many-operation-factory.util';
|
||||||
|
import { findOneOperationFactory } from 'test/integration/graphql/utils/find-one-operation-factory.util';
|
||||||
|
import { makeGraphqlAPIRequest } from 'test/integration/graphql/utils/make-graphql-api-request.util';
|
||||||
|
import { updateManyOperationFactory } from 'test/integration/graphql/utils/update-many-operation-factory.util';
|
||||||
|
import { updateOneOperationFactory } from 'test/integration/graphql/utils/update-one-operation-factory.util';
|
||||||
|
import { generateRecordName } from 'test/integration/utils/generate-record-name';
|
||||||
|
|
||||||
|
const WORKSPACE_MEMBER_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
||||||
|
const WORKSPACE_MEMBER_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
||||||
|
const WORKSPACE_MEMBER_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
||||||
|
|
||||||
|
const WORKSPACE_MEMBER_GQL_FIELDS = `
|
||||||
|
id
|
||||||
|
colorScheme
|
||||||
|
avatarUrl
|
||||||
|
locale
|
||||||
|
timeZone
|
||||||
|
dateFormat
|
||||||
|
timeFormat
|
||||||
|
userEmail
|
||||||
|
userId
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
deletedAt
|
||||||
|
`;
|
||||||
|
|
||||||
|
describe('workspaceMembers resolvers (integration)', () => {
|
||||||
|
it('1. should create and return workspaceMembers', async () => {
|
||||||
|
const workspaceMemberEmail1 = generateRecordName(WORKSPACE_MEMBER_1_ID);
|
||||||
|
const workspaceMemberEmail2 = generateRecordName(WORKSPACE_MEMBER_2_ID);
|
||||||
|
|
||||||
|
const graphqlOperation = createManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'workspaceMember',
|
||||||
|
objectMetadataPluralName: 'workspaceMembers',
|
||||||
|
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: WORKSPACE_MEMBER_1_ID,
|
||||||
|
userEmail: workspaceMemberEmail1,
|
||||||
|
userId: TIM_USER_ID,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: WORKSPACE_MEMBER_2_ID,
|
||||||
|
userEmail: workspaceMemberEmail2,
|
||||||
|
userId: TIM_USER_ID,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.createWorkspaceMembers).toHaveLength(2);
|
||||||
|
|
||||||
|
response.body.data.createWorkspaceMembers.forEach((workspaceMember) => {
|
||||||
|
expect(workspaceMember).toHaveProperty('userEmail');
|
||||||
|
expect([workspaceMemberEmail1, workspaceMemberEmail2]).toContain(
|
||||||
|
workspaceMember.userEmail,
|
||||||
|
);
|
||||||
|
expect(workspaceMember).toHaveProperty('id');
|
||||||
|
expect(workspaceMember).toHaveProperty('colorScheme');
|
||||||
|
expect(workspaceMember).toHaveProperty('avatarUrl');
|
||||||
|
expect(workspaceMember).toHaveProperty('locale');
|
||||||
|
expect(workspaceMember).toHaveProperty('timeZone');
|
||||||
|
expect(workspaceMember).toHaveProperty('dateFormat');
|
||||||
|
expect(workspaceMember).toHaveProperty('timeFormat');
|
||||||
|
expect(workspaceMember).toHaveProperty('userId');
|
||||||
|
expect(workspaceMember).toHaveProperty('createdAt');
|
||||||
|
expect(workspaceMember).toHaveProperty('updatedAt');
|
||||||
|
expect(workspaceMember).toHaveProperty('deletedAt');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('1b. should create and return one workspaceMember', async () => {
|
||||||
|
const workspaceMemberEmail = generateRecordName(WORKSPACE_MEMBER_3_ID);
|
||||||
|
|
||||||
|
const graphqlOperation = createOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'workspaceMember',
|
||||||
|
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
id: WORKSPACE_MEMBER_3_ID,
|
||||||
|
userEmail: workspaceMemberEmail,
|
||||||
|
userId: TIM_USER_ID,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const createdWorkspaceMember = response.body.data.createWorkspaceMember;
|
||||||
|
|
||||||
|
expect(createdWorkspaceMember).toHaveProperty('userEmail');
|
||||||
|
expect(createdWorkspaceMember.userEmail).toEqual(workspaceMemberEmail);
|
||||||
|
expect(createdWorkspaceMember).toHaveProperty('id');
|
||||||
|
expect(createdWorkspaceMember).toHaveProperty('colorScheme');
|
||||||
|
expect(createdWorkspaceMember).toHaveProperty('avatarUrl');
|
||||||
|
expect(createdWorkspaceMember).toHaveProperty('locale');
|
||||||
|
expect(createdWorkspaceMember).toHaveProperty('timeZone');
|
||||||
|
expect(createdWorkspaceMember).toHaveProperty('dateFormat');
|
||||||
|
expect(createdWorkspaceMember).toHaveProperty('timeFormat');
|
||||||
|
expect(createdWorkspaceMember).toHaveProperty('userId');
|
||||||
|
expect(createdWorkspaceMember).toHaveProperty('createdAt');
|
||||||
|
expect(createdWorkspaceMember).toHaveProperty('updatedAt');
|
||||||
|
expect(createdWorkspaceMember).toHaveProperty('deletedAt');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('2. should find many workspaceMembers', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'workspaceMember',
|
||||||
|
objectMetadataPluralName: 'workspaceMembers',
|
||||||
|
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const data = response.body.data.workspaceMembers;
|
||||||
|
|
||||||
|
expect(data).toBeDefined();
|
||||||
|
expect(Array.isArray(data.edges)).toBe(true);
|
||||||
|
|
||||||
|
if (data.edges.length > 0) {
|
||||||
|
const workspaceMembers = data.edges[0].node;
|
||||||
|
|
||||||
|
expect(workspaceMembers).toHaveProperty('id');
|
||||||
|
expect(workspaceMembers).toHaveProperty('colorScheme');
|
||||||
|
expect(workspaceMembers).toHaveProperty('avatarUrl');
|
||||||
|
expect(workspaceMembers).toHaveProperty('locale');
|
||||||
|
expect(workspaceMembers).toHaveProperty('timeZone');
|
||||||
|
expect(workspaceMembers).toHaveProperty('dateFormat');
|
||||||
|
expect(workspaceMembers).toHaveProperty('timeFormat');
|
||||||
|
expect(workspaceMembers).toHaveProperty('userEmail');
|
||||||
|
expect(workspaceMembers).toHaveProperty('userId');
|
||||||
|
expect(workspaceMembers).toHaveProperty('createdAt');
|
||||||
|
expect(workspaceMembers).toHaveProperty('updatedAt');
|
||||||
|
expect(workspaceMembers).toHaveProperty('deletedAt');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('2b. should find one workspaceMember', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'workspaceMember',
|
||||||
|
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: WORKSPACE_MEMBER_3_ID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const workspaceMember = response.body.data.workspaceMember;
|
||||||
|
|
||||||
|
expect(workspaceMember).toHaveProperty('id');
|
||||||
|
expect(workspaceMember).toHaveProperty('colorScheme');
|
||||||
|
expect(workspaceMember).toHaveProperty('avatarUrl');
|
||||||
|
expect(workspaceMember).toHaveProperty('locale');
|
||||||
|
expect(workspaceMember).toHaveProperty('timeZone');
|
||||||
|
expect(workspaceMember).toHaveProperty('dateFormat');
|
||||||
|
expect(workspaceMember).toHaveProperty('timeFormat');
|
||||||
|
expect(workspaceMember).toHaveProperty('userEmail');
|
||||||
|
expect(workspaceMember).toHaveProperty('userId');
|
||||||
|
expect(workspaceMember).toHaveProperty('createdAt');
|
||||||
|
expect(workspaceMember).toHaveProperty('updatedAt');
|
||||||
|
expect(workspaceMember).toHaveProperty('deletedAt');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('3. should update many workspaceMembers', async () => {
|
||||||
|
const graphqlOperation = updateManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'workspaceMember',
|
||||||
|
objectMetadataPluralName: 'workspaceMembers',
|
||||||
|
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
locale: 'en-US',
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [WORKSPACE_MEMBER_1_ID, WORKSPACE_MEMBER_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const updatedWorkspaceMembers = response.body.data.updateWorkspaceMembers;
|
||||||
|
|
||||||
|
expect(updatedWorkspaceMembers).toHaveLength(2);
|
||||||
|
|
||||||
|
updatedWorkspaceMembers.forEach((workspaceMember) => {
|
||||||
|
expect(workspaceMember.locale).toEqual('en-US');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('3b. should update one workspaceMember', async () => {
|
||||||
|
const graphqlOperation = updateOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'workspaceMember',
|
||||||
|
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||||
|
data: {
|
||||||
|
locale: 'fr-CA',
|
||||||
|
},
|
||||||
|
recordId: WORKSPACE_MEMBER_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
const updatedWorkspaceMember = response.body.data.updateWorkspaceMember;
|
||||||
|
|
||||||
|
expect(updatedWorkspaceMember.locale).toEqual('fr-CA');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('4. should find many workspaceMembers with updated locale', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'workspaceMember',
|
||||||
|
objectMetadataPluralName: 'workspaceMembers',
|
||||||
|
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
locale: {
|
||||||
|
eq: 'en-US',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.workspaceMembers.edges).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('4b. should find one workspaceMember with updated locale', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'workspaceMember',
|
||||||
|
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
locale: {
|
||||||
|
eq: 'fr-CA',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.workspaceMember.locale).toEqual('fr-CA');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('5. should not delete many workspaceMembers', async () => {
|
||||||
|
const graphqlOperation = deleteManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'workspaceMember',
|
||||||
|
objectMetadataPluralName: 'workspaceMembers',
|
||||||
|
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [WORKSPACE_MEMBER_1_ID, WORKSPACE_MEMBER_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.deleteWorkspaceMembers).toBeNull();
|
||||||
|
expect(response.body.errors).toStrictEqual([
|
||||||
|
{
|
||||||
|
extensions: { code: 'INTERNAL_SERVER_ERROR' },
|
||||||
|
message: 'Method not allowed.',
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('5b. should delete one workspaceMember', async () => {
|
||||||
|
const graphqlOperation = deleteOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'workspaceMember',
|
||||||
|
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||||
|
recordId: WORKSPACE_MEMBER_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.deleteWorkspaceMember.deletedAt).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('6. should still find many workspaceMembers that were not deleted', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'workspaceMember',
|
||||||
|
objectMetadataPluralName: 'workspaceMembers',
|
||||||
|
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [WORKSPACE_MEMBER_1_ID, WORKSPACE_MEMBER_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const findWorkspaceMembersResponse =
|
||||||
|
await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
findWorkspaceMembersResponse.body.data.workspaceMembers.edges,
|
||||||
|
).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('6b. should not find one workspaceMember anymore', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'workspaceMember',
|
||||||
|
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: WORKSPACE_MEMBER_3_ID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.workspaceMember).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('7. should not find many deleted workspaceMembers with deletedAt filter', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'workspaceMember',
|
||||||
|
objectMetadataPluralName: 'workspaceMembers',
|
||||||
|
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [WORKSPACE_MEMBER_1_ID, WORKSPACE_MEMBER_2_ID],
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.workspaceMembers.edges).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('7b. should find one deleted workspaceMember with deletedAt filter', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'workspaceMember',
|
||||||
|
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: WORKSPACE_MEMBER_3_ID,
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.workspaceMember.id).toEqual(
|
||||||
|
WORKSPACE_MEMBER_3_ID,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('8. should destroy many workspaceMembers', async () => {
|
||||||
|
const graphqlOperation = destroyManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'workspaceMember',
|
||||||
|
objectMetadataPluralName: 'workspaceMembers',
|
||||||
|
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [WORKSPACE_MEMBER_1_ID, WORKSPACE_MEMBER_2_ID],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.destroyWorkspaceMembers).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('8b. should destroy one workspaceMember', async () => {
|
||||||
|
const graphqlOperation = destroyOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'workspaceMember',
|
||||||
|
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||||
|
recordId: WORKSPACE_MEMBER_3_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const destroyWorkspaceMemberResponse =
|
||||||
|
await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
destroyWorkspaceMemberResponse.body.data.destroyWorkspaceMember,
|
||||||
|
).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('9. should not find many workspaceMembers anymore', async () => {
|
||||||
|
const graphqlOperation = findManyOperationFactory({
|
||||||
|
objectMetadataSingularName: 'workspaceMember',
|
||||||
|
objectMetadataPluralName: 'workspaceMembers',
|
||||||
|
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: [WORKSPACE_MEMBER_1_ID, WORKSPACE_MEMBER_2_ID],
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.workspaceMembers.edges).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('9b. should not find one workspaceMember anymore', async () => {
|
||||||
|
const graphqlOperation = findOneOperationFactory({
|
||||||
|
objectMetadataSingularName: 'workspaceMember',
|
||||||
|
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||||
|
filter: {
|
||||||
|
id: {
|
||||||
|
eq: WORKSPACE_MEMBER_3_ID,
|
||||||
|
},
|
||||||
|
not: {
|
||||||
|
deletedAt: {
|
||||||
|
is: 'NULL',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||||
|
|
||||||
|
expect(response.body.data.workspaceMember).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user