Integration test : Sync mode + db reset option + cleaning (#8376)
Run the CI integrationin sync mode and add the option to run it without db reset cleaning all the useless integration test --------- Co-authored-by: guillim <guillaume@twenty.com>
This commit is contained in:
2
.github/workflows/ci-server.yaml
vendored
2
.github/workflows/ci-server.yaml
vendored
@ -146,7 +146,7 @@ jobs:
|
|||||||
uses: ./.github/workflows/actions/nx-affected
|
uses: ./.github/workflows/actions/nx-affected
|
||||||
with:
|
with:
|
||||||
tag: scope:backend
|
tag: scope:backend
|
||||||
tasks: "test:integration"
|
tasks: "test:integration:with-db-reset"
|
||||||
- name: Server / Upload reset-logs file
|
- name: Server / Upload reset-logs file
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
|||||||
@ -14,6 +14,7 @@ const jestConfig: JestConfigWithTsJest = {
|
|||||||
globalSetup: '<rootDir>/test/integration/utils/setup-test.ts',
|
globalSetup: '<rootDir>/test/integration/utils/setup-test.ts',
|
||||||
globalTeardown: '<rootDir>/test/integration/utils/teardown-test.ts',
|
globalTeardown: '<rootDir>/test/integration/utils/teardown-test.ts',
|
||||||
testTimeout: 15000,
|
testTimeout: 15000,
|
||||||
|
maxWorkers: 1,
|
||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
...pathsToModuleNameMapper(tsConfig.compilerOptions.paths, {
|
...pathsToModuleNameMapper(tsConfig.compilerOptions.paths, {
|
||||||
prefix: '<rootDir>/../..',
|
prefix: '<rootDir>/../..',
|
||||||
|
|||||||
@ -16,10 +16,18 @@
|
|||||||
"options": {
|
"options": {
|
||||||
"cwd": "packages/twenty-server",
|
"cwd": "packages/twenty-server",
|
||||||
"commands": [
|
"commands": [
|
||||||
"NODE_ENV=test nx database:reset > reset-logs.log && NODE_ENV=test nx jest --config ./jest-integration.config.ts"
|
"NODE_ENV=test nx jest --config ./jest-integration.config.ts"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"parallel": false
|
"parallel": false,
|
||||||
|
"configurations": {
|
||||||
|
"with-db-reset": {
|
||||||
|
"cwd": "packages/twenty-server",
|
||||||
|
"commands": [
|
||||||
|
"NODE_ENV=test nx database:reset > reset-logs.log && NODE_ENV=test nx jest --config ./jest-integration.config.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"build:packageJson": {
|
"build:packageJson": {
|
||||||
"executor": "@nx/js:tsc",
|
"executor": "@nx/js:tsc",
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
|||||||
|
|
||||||
import { JwtAuthStrategy } from './jwt.auth.strategy';
|
import { JwtAuthStrategy } from './jwt.auth.strategy';
|
||||||
|
|
||||||
xdescribe('JwtAuthStrategy', () => {
|
describe('JwtAuthStrategy', () => {
|
||||||
let strategy: JwtAuthStrategy;
|
let strategy: JwtAuthStrategy;
|
||||||
|
|
||||||
let workspaceRepository: any;
|
let workspaceRepository: any;
|
||||||
|
|||||||
@ -1,404 +0,0 @@
|
|||||||
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();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,435 +0,0 @@
|
|||||||
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
|
|
||||||
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('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('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('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('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();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,421 +0,0 @@
|
|||||||
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();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,535 +0,0 @@
|
|||||||
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();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,479 +0,0 @@
|
|||||||
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_EVENT_PARTICIPANT_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
|
||||||
const CALENDAR_EVENT_PARTICIPANT_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
|
||||||
const CALENDAR_EVENT_PARTICIPANT_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
|
||||||
const CALENDAR_EVENT_ID = '777a8457-eb2d-40ac-a707-441b615b6989';
|
|
||||||
const CALENDAR_EVENT_PARTICIPANT_GQL_FIELDS = `
|
|
||||||
id
|
|
||||||
handle
|
|
||||||
displayName
|
|
||||||
isOrganizer
|
|
||||||
responseStatus
|
|
||||||
deletedAt
|
|
||||||
`;
|
|
||||||
|
|
||||||
describe('calendarEventParticipants resolvers (integration)', () => {
|
|
||||||
beforeAll(async () => {
|
|
||||||
const calendarEventTitle = generateRecordName(CALENDAR_EVENT_ID);
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEvent',
|
|
||||||
gqlFields: `id`,
|
|
||||||
data: {
|
|
||||||
id: CALENDAR_EVENT_ID,
|
|
||||||
title: calendarEventTitle,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEvent',
|
|
||||||
gqlFields: `id`,
|
|
||||||
recordId: CALENDAR_EVENT_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1. should create and return calendarEventParticipants', async () => {
|
|
||||||
const calendarEventParticipantDisplayName1 = generateRecordName(
|
|
||||||
CALENDAR_EVENT_PARTICIPANT_1_ID,
|
|
||||||
);
|
|
||||||
const calendarEventParticipantDisplayName2 = generateRecordName(
|
|
||||||
CALENDAR_EVENT_PARTICIPANT_2_ID,
|
|
||||||
);
|
|
||||||
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEventParticipant',
|
|
||||||
objectMetadataPluralName: 'calendarEventParticipants',
|
|
||||||
gqlFields: CALENDAR_EVENT_PARTICIPANT_GQL_FIELDS,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: CALENDAR_EVENT_PARTICIPANT_1_ID,
|
|
||||||
displayName: calendarEventParticipantDisplayName1,
|
|
||||||
calendarEventId: CALENDAR_EVENT_ID,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: CALENDAR_EVENT_PARTICIPANT_2_ID,
|
|
||||||
displayName: calendarEventParticipantDisplayName2,
|
|
||||||
calendarEventId: CALENDAR_EVENT_ID,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.createCalendarEventParticipants).toHaveLength(2);
|
|
||||||
|
|
||||||
response.body.data.createCalendarEventParticipants.forEach(
|
|
||||||
(calendarEventParticipant) => {
|
|
||||||
expect(calendarEventParticipant).toHaveProperty('displayName');
|
|
||||||
expect([
|
|
||||||
calendarEventParticipantDisplayName1,
|
|
||||||
calendarEventParticipantDisplayName2,
|
|
||||||
]).toContain(calendarEventParticipant.displayName);
|
|
||||||
|
|
||||||
expect(calendarEventParticipant).toHaveProperty('id');
|
|
||||||
expect(calendarEventParticipant).toHaveProperty('handle');
|
|
||||||
expect(calendarEventParticipant).toHaveProperty('isOrganizer');
|
|
||||||
expect(calendarEventParticipant).toHaveProperty('responseStatus');
|
|
||||||
expect(calendarEventParticipant).toHaveProperty('deletedAt');
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1b. should create and return one calendarEventParticipant', async () => {
|
|
||||||
const calendarEventParticipantDisplayName = generateRecordName(
|
|
||||||
CALENDAR_EVENT_PARTICIPANT_3_ID,
|
|
||||||
);
|
|
||||||
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEventParticipant',
|
|
||||||
gqlFields: CALENDAR_EVENT_PARTICIPANT_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
id: CALENDAR_EVENT_PARTICIPANT_3_ID,
|
|
||||||
displayName: calendarEventParticipantDisplayName,
|
|
||||||
calendarEventId: CALENDAR_EVENT_ID,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const createdCalendarEventParticipant =
|
|
||||||
response.body.data.createCalendarEventParticipant;
|
|
||||||
|
|
||||||
expect(createdCalendarEventParticipant).toHaveProperty('displayName');
|
|
||||||
expect(createdCalendarEventParticipant.displayName).toEqual(
|
|
||||||
calendarEventParticipantDisplayName,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(createdCalendarEventParticipant).toHaveProperty('id');
|
|
||||||
expect(createdCalendarEventParticipant).toHaveProperty('handle');
|
|
||||||
expect(createdCalendarEventParticipant).toHaveProperty('isOrganizer');
|
|
||||||
expect(createdCalendarEventParticipant).toHaveProperty('responseStatus');
|
|
||||||
expect(createdCalendarEventParticipant).toHaveProperty('deletedAt');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2. should find many calendarEventParticipants', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEventParticipant',
|
|
||||||
objectMetadataPluralName: 'calendarEventParticipants',
|
|
||||||
gqlFields: CALENDAR_EVENT_PARTICIPANT_GQL_FIELDS,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const data = response.body.data.calendarEventParticipants;
|
|
||||||
|
|
||||||
expect(data).toBeDefined();
|
|
||||||
expect(Array.isArray(data.edges)).toBe(true);
|
|
||||||
|
|
||||||
const edges = data.edges;
|
|
||||||
|
|
||||||
if (edges.length > 0) {
|
|
||||||
const calendarEventParticipants = edges[0].node;
|
|
||||||
|
|
||||||
expect(calendarEventParticipants).toHaveProperty('displayName');
|
|
||||||
expect(calendarEventParticipants).toHaveProperty('id');
|
|
||||||
expect(calendarEventParticipants).toHaveProperty('handle');
|
|
||||||
expect(calendarEventParticipants).toHaveProperty('isOrganizer');
|
|
||||||
expect(calendarEventParticipants).toHaveProperty('responseStatus');
|
|
||||||
expect(calendarEventParticipants).toHaveProperty('deletedAt');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2b. should find one calendarEventParticipant', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEventParticipant',
|
|
||||||
gqlFields: CALENDAR_EVENT_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: CALENDAR_EVENT_PARTICIPANT_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const calendarEventParticipant =
|
|
||||||
response.body.data.calendarEventParticipant;
|
|
||||||
|
|
||||||
expect(calendarEventParticipant).toHaveProperty('displayName');
|
|
||||||
|
|
||||||
expect(calendarEventParticipant).toHaveProperty('id');
|
|
||||||
expect(calendarEventParticipant).toHaveProperty('handle');
|
|
||||||
expect(calendarEventParticipant).toHaveProperty('isOrganizer');
|
|
||||||
expect(calendarEventParticipant).toHaveProperty('responseStatus');
|
|
||||||
expect(calendarEventParticipant).toHaveProperty('deletedAt');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3. should update many calendarEventParticipants', async () => {
|
|
||||||
const graphqlOperation = updateManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEventParticipant',
|
|
||||||
objectMetadataPluralName: 'calendarEventParticipants',
|
|
||||||
gqlFields: CALENDAR_EVENT_PARTICIPANT_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
displayName: 'New DisplayName',
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [
|
|
||||||
CALENDAR_EVENT_PARTICIPANT_1_ID,
|
|
||||||
CALENDAR_EVENT_PARTICIPANT_2_ID,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedcalendarEventParticipants =
|
|
||||||
response.body.data.updateCalendarEventParticipants;
|
|
||||||
|
|
||||||
expect(updatedcalendarEventParticipants).toHaveLength(2);
|
|
||||||
|
|
||||||
updatedcalendarEventParticipants.forEach((calendarEventParticipant) => {
|
|
||||||
expect(calendarEventParticipant.displayName).toEqual('New DisplayName');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3b. should update one calendarEventParticipant', async () => {
|
|
||||||
const graphqlOperation = updateOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEventParticipant',
|
|
||||||
gqlFields: CALENDAR_EVENT_PARTICIPANT_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
displayName: 'Updated DisplayName',
|
|
||||||
},
|
|
||||||
recordId: CALENDAR_EVENT_PARTICIPANT_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedcalendarEventParticipant =
|
|
||||||
response.body.data.updateCalendarEventParticipant;
|
|
||||||
|
|
||||||
expect(updatedcalendarEventParticipant.displayName).toEqual(
|
|
||||||
'Updated DisplayName',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4. should find many calendarEventParticipants with updated displayName', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEventParticipant',
|
|
||||||
objectMetadataPluralName: 'calendarEventParticipants',
|
|
||||||
gqlFields: CALENDAR_EVENT_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
displayName: {
|
|
||||||
eq: 'New DisplayName',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.calendarEventParticipants.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4b. should find one calendarEventParticipant with updated displayName', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEventParticipant',
|
|
||||||
gqlFields: CALENDAR_EVENT_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
displayName: {
|
|
||||||
eq: 'Updated DisplayName',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.calendarEventParticipant.displayName).toEqual(
|
|
||||||
'Updated DisplayName',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5. should delete many calendarEventParticipants', async () => {
|
|
||||||
const graphqlOperation = deleteManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEventParticipant',
|
|
||||||
objectMetadataPluralName: 'calendarEventParticipants',
|
|
||||||
gqlFields: CALENDAR_EVENT_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [
|
|
||||||
CALENDAR_EVENT_PARTICIPANT_1_ID,
|
|
||||||
CALENDAR_EVENT_PARTICIPANT_2_ID,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const deleteCalendarEventParticipants =
|
|
||||||
response.body.data.deleteCalendarEventParticipants;
|
|
||||||
|
|
||||||
expect(deleteCalendarEventParticipants).toHaveLength(2);
|
|
||||||
|
|
||||||
deleteCalendarEventParticipants.forEach((calendarEventParticipant) => {
|
|
||||||
expect(calendarEventParticipant.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5b. should delete one calendarEventParticipant', async () => {
|
|
||||||
const graphqlOperation = deleteOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEventParticipant',
|
|
||||||
gqlFields: CALENDAR_EVENT_PARTICIPANT_GQL_FIELDS,
|
|
||||||
recordId: CALENDAR_EVENT_PARTICIPANT_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
response.body.data.deleteCalendarEventParticipant.deletedAt,
|
|
||||||
).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6. should not find many calendarEventParticipants anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEventParticipant',
|
|
||||||
objectMetadataPluralName: 'calendarEventParticipants',
|
|
||||||
gqlFields: CALENDAR_EVENT_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [
|
|
||||||
CALENDAR_EVENT_PARTICIPANT_1_ID,
|
|
||||||
CALENDAR_EVENT_PARTICIPANT_2_ID,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const findCalendarEventParticipantsResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
findCalendarEventParticipantsResponse.body.data.calendarEventParticipants
|
|
||||||
.edges,
|
|
||||||
).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6b. should not find one calendarEventParticipant anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEventParticipant',
|
|
||||||
gqlFields: CALENDAR_EVENT_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: CALENDAR_EVENT_PARTICIPANT_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.calendarEventParticipant).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7. should find many deleted calendarEventParticipants with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEventParticipant',
|
|
||||||
objectMetadataPluralName: 'calendarEventParticipants',
|
|
||||||
gqlFields: CALENDAR_EVENT_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [
|
|
||||||
CALENDAR_EVENT_PARTICIPANT_1_ID,
|
|
||||||
CALENDAR_EVENT_PARTICIPANT_2_ID,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.calendarEventParticipants.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7b. should find one deleted calendarEventParticipant with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEventParticipant',
|
|
||||||
gqlFields: CALENDAR_EVENT_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: CALENDAR_EVENT_PARTICIPANT_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.calendarEventParticipant.id).toEqual(
|
|
||||||
CALENDAR_EVENT_PARTICIPANT_3_ID,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8. should destroy many calendarEventParticipants', async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEventParticipant',
|
|
||||||
objectMetadataPluralName: 'calendarEventParticipants',
|
|
||||||
gqlFields: CALENDAR_EVENT_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [
|
|
||||||
CALENDAR_EVENT_PARTICIPANT_1_ID,
|
|
||||||
CALENDAR_EVENT_PARTICIPANT_2_ID,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.destroyCalendarEventParticipants).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8b. should destroy one calendarEventParticipant', async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEventParticipant',
|
|
||||||
gqlFields: CALENDAR_EVENT_PARTICIPANT_GQL_FIELDS,
|
|
||||||
recordId: CALENDAR_EVENT_PARTICIPANT_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const destroyCalendarEventParticipantResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
destroyCalendarEventParticipantResponse.body.data
|
|
||||||
.destroyCalendarEventParticipant,
|
|
||||||
).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9. should not find many calendarEventParticipants anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEventParticipant',
|
|
||||||
objectMetadataPluralName: 'calendarEventParticipants',
|
|
||||||
gqlFields: CALENDAR_EVENT_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [
|
|
||||||
CALENDAR_EVENT_PARTICIPANT_1_ID,
|
|
||||||
CALENDAR_EVENT_PARTICIPANT_2_ID,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.calendarEventParticipants.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9b. should not find one calendarEventParticipant anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'calendarEventParticipant',
|
|
||||||
gqlFields: CALENDAR_EVENT_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: CALENDAR_EVENT_PARTICIPANT_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.calendarEventParticipant).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,420 +0,0 @@
|
|||||||
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 CONNECTED_ACCOUNT_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
|
||||||
const CONNECTED_ACCOUNT_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
|
||||||
const CONNECTED_ACCOUNT_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
|
||||||
const CONNECTED_ACCOUNT_GQL_FIELDS = `
|
|
||||||
id
|
|
||||||
handle
|
|
||||||
deletedAt
|
|
||||||
createdAt
|
|
||||||
provider
|
|
||||||
accessToken
|
|
||||||
scopes
|
|
||||||
`;
|
|
||||||
|
|
||||||
describe('connectedAccounts resolvers (integration)', () => {
|
|
||||||
it('1. should create and return connectedAccounts', async () => {
|
|
||||||
const connectedAccountHandle1 = generateRecordName(CONNECTED_ACCOUNT_1_ID);
|
|
||||||
const connectedAccountHandle2 = generateRecordName(CONNECTED_ACCOUNT_2_ID);
|
|
||||||
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'connectedAccount',
|
|
||||||
objectMetadataPluralName: 'connectedAccounts',
|
|
||||||
gqlFields: CONNECTED_ACCOUNT_GQL_FIELDS,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: CONNECTED_ACCOUNT_1_ID,
|
|
||||||
handle: connectedAccountHandle1,
|
|
||||||
accountOwnerId: TIM_ACCOUNT_ID,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: CONNECTED_ACCOUNT_2_ID,
|
|
||||||
handle: connectedAccountHandle2,
|
|
||||||
accountOwnerId: TIM_ACCOUNT_ID,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.createConnectedAccounts).toHaveLength(2);
|
|
||||||
|
|
||||||
response.body.data.createConnectedAccounts.forEach((connectedAccount) => {
|
|
||||||
expect(connectedAccount).toHaveProperty('handle');
|
|
||||||
expect([connectedAccountHandle1, connectedAccountHandle2]).toContain(
|
|
||||||
connectedAccount.handle,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(connectedAccount).toHaveProperty('id');
|
|
||||||
expect(connectedAccount).toHaveProperty('deletedAt');
|
|
||||||
expect(connectedAccount).toHaveProperty('createdAt');
|
|
||||||
expect(connectedAccount).toHaveProperty('provider');
|
|
||||||
expect(connectedAccount).toHaveProperty('accessToken');
|
|
||||||
expect(connectedAccount).toHaveProperty('scopes');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1b. should create and return one connectedAccount', async () => {
|
|
||||||
const connectedAccountHandle = generateRecordName(CONNECTED_ACCOUNT_3_ID);
|
|
||||||
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'connectedAccount',
|
|
||||||
gqlFields: CONNECTED_ACCOUNT_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
id: CONNECTED_ACCOUNT_3_ID,
|
|
||||||
handle: connectedAccountHandle,
|
|
||||||
accountOwnerId: TIM_ACCOUNT_ID,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const createdConnectedAccount = response.body.data.createConnectedAccount;
|
|
||||||
|
|
||||||
expect(createdConnectedAccount).toHaveProperty('handle');
|
|
||||||
expect(createdConnectedAccount.handle).toEqual(connectedAccountHandle);
|
|
||||||
|
|
||||||
expect(createdConnectedAccount).toHaveProperty('id');
|
|
||||||
expect(createdConnectedAccount).toHaveProperty('deletedAt');
|
|
||||||
expect(createdConnectedAccount).toHaveProperty('createdAt');
|
|
||||||
expect(createdConnectedAccount).toHaveProperty('provider');
|
|
||||||
expect(createdConnectedAccount).toHaveProperty('accessToken');
|
|
||||||
expect(createdConnectedAccount).toHaveProperty('scopes');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2. should find many connectedAccounts', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'connectedAccount',
|
|
||||||
objectMetadataPluralName: 'connectedAccounts',
|
|
||||||
gqlFields: CONNECTED_ACCOUNT_GQL_FIELDS,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const data = response.body.data.connectedAccounts;
|
|
||||||
|
|
||||||
expect(data).toBeDefined();
|
|
||||||
expect(Array.isArray(data.edges)).toBe(true);
|
|
||||||
|
|
||||||
const edges = data.edges;
|
|
||||||
|
|
||||||
if (edges.length > 0) {
|
|
||||||
const connectedAccounts = edges[0].node;
|
|
||||||
|
|
||||||
expect(connectedAccounts).toHaveProperty('handle');
|
|
||||||
expect(connectedAccounts).toHaveProperty('id');
|
|
||||||
expect(connectedAccounts).toHaveProperty('deletedAt');
|
|
||||||
expect(connectedAccounts).toHaveProperty('createdAt');
|
|
||||||
expect(connectedAccounts).toHaveProperty('provider');
|
|
||||||
expect(connectedAccounts).toHaveProperty('accessToken');
|
|
||||||
expect(connectedAccounts).toHaveProperty('scopes');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2b. should find one connectedAccount', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'connectedAccount',
|
|
||||||
gqlFields: CONNECTED_ACCOUNT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: CONNECTED_ACCOUNT_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const connectedAccount = response.body.data.connectedAccount;
|
|
||||||
|
|
||||||
expect(connectedAccount).toHaveProperty('handle');
|
|
||||||
|
|
||||||
expect(connectedAccount).toHaveProperty('id');
|
|
||||||
expect(connectedAccount).toHaveProperty('deletedAt');
|
|
||||||
expect(connectedAccount).toHaveProperty('createdAt');
|
|
||||||
expect(connectedAccount).toHaveProperty('provider');
|
|
||||||
expect(connectedAccount).toHaveProperty('accessToken');
|
|
||||||
expect(connectedAccount).toHaveProperty('scopes');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3. should update many connectedAccounts', async () => {
|
|
||||||
const graphqlOperation = updateManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'connectedAccount',
|
|
||||||
objectMetadataPluralName: 'connectedAccounts',
|
|
||||||
gqlFields: CONNECTED_ACCOUNT_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
handle: 'New Handle',
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [CONNECTED_ACCOUNT_1_ID, CONNECTED_ACCOUNT_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedconnectedAccounts = response.body.data.updateConnectedAccounts;
|
|
||||||
|
|
||||||
expect(updatedconnectedAccounts).toHaveLength(2);
|
|
||||||
|
|
||||||
updatedconnectedAccounts.forEach((connectedAccount) => {
|
|
||||||
expect(connectedAccount.handle).toEqual('New Handle');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3b. should update one connectedAccount', async () => {
|
|
||||||
const graphqlOperation = updateOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'connectedAccount',
|
|
||||||
gqlFields: CONNECTED_ACCOUNT_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
handle: 'Updated Handle',
|
|
||||||
},
|
|
||||||
recordId: CONNECTED_ACCOUNT_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedconnectedAccount = response.body.data.updateConnectedAccount;
|
|
||||||
|
|
||||||
expect(updatedconnectedAccount.handle).toEqual('Updated Handle');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4. should find many connectedAccounts with updated handle', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'connectedAccount',
|
|
||||||
objectMetadataPluralName: 'connectedAccounts',
|
|
||||||
gqlFields: CONNECTED_ACCOUNT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
handle: {
|
|
||||||
eq: 'New Handle',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.connectedAccounts.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4b. should find one connectedAccount with updated handle', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'connectedAccount',
|
|
||||||
gqlFields: CONNECTED_ACCOUNT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
handle: {
|
|
||||||
eq: 'Updated Handle',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.connectedAccount.handle).toEqual(
|
|
||||||
'Updated Handle',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5. should delete many connectedAccounts', async () => {
|
|
||||||
const graphqlOperation = deleteManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'connectedAccount',
|
|
||||||
objectMetadataPluralName: 'connectedAccounts',
|
|
||||||
gqlFields: CONNECTED_ACCOUNT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [CONNECTED_ACCOUNT_1_ID, CONNECTED_ACCOUNT_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const deleteConnectedAccounts = response.body.data.deleteConnectedAccounts;
|
|
||||||
|
|
||||||
expect(deleteConnectedAccounts).toHaveLength(2);
|
|
||||||
|
|
||||||
deleteConnectedAccounts.forEach((connectedAccount) => {
|
|
||||||
expect(connectedAccount.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5b. should delete one connectedAccount', async () => {
|
|
||||||
const graphqlOperation = deleteOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'connectedAccount',
|
|
||||||
gqlFields: CONNECTED_ACCOUNT_GQL_FIELDS,
|
|
||||||
recordId: CONNECTED_ACCOUNT_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.deleteConnectedAccount.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6. should not find many connectedAccounts anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'connectedAccount',
|
|
||||||
objectMetadataPluralName: 'connectedAccounts',
|
|
||||||
gqlFields: CONNECTED_ACCOUNT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [CONNECTED_ACCOUNT_1_ID, CONNECTED_ACCOUNT_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const findConnectedAccountsResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
findConnectedAccountsResponse.body.data.connectedAccounts.edges,
|
|
||||||
).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6b. should not find one connectedAccount anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'connectedAccount',
|
|
||||||
gqlFields: CONNECTED_ACCOUNT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: CONNECTED_ACCOUNT_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.connectedAccount).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7. should find many deleted connectedAccounts with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'connectedAccount',
|
|
||||||
objectMetadataPluralName: 'connectedAccounts',
|
|
||||||
gqlFields: CONNECTED_ACCOUNT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [CONNECTED_ACCOUNT_1_ID, CONNECTED_ACCOUNT_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.connectedAccounts.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7b. should find one deleted connectedAccount with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'connectedAccount',
|
|
||||||
gqlFields: CONNECTED_ACCOUNT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: CONNECTED_ACCOUNT_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.connectedAccount.id).toEqual(
|
|
||||||
CONNECTED_ACCOUNT_3_ID,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8. should destroy many connectedAccounts', async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'connectedAccount',
|
|
||||||
objectMetadataPluralName: 'connectedAccounts',
|
|
||||||
gqlFields: CONNECTED_ACCOUNT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [CONNECTED_ACCOUNT_1_ID, CONNECTED_ACCOUNT_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.destroyConnectedAccounts).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8b. should destroy one connectedAccount', async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'connectedAccount',
|
|
||||||
gqlFields: CONNECTED_ACCOUNT_GQL_FIELDS,
|
|
||||||
recordId: CONNECTED_ACCOUNT_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const destroyConnectedAccountResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
destroyConnectedAccountResponse.body.data.destroyConnectedAccount,
|
|
||||||
).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9. should not find many connectedAccounts anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'connectedAccount',
|
|
||||||
objectMetadataPluralName: 'connectedAccounts',
|
|
||||||
gqlFields: CONNECTED_ACCOUNT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [CONNECTED_ACCOUNT_1_ID, CONNECTED_ACCOUNT_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.connectedAccounts.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9b. should not find one connectedAccount anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'connectedAccount',
|
|
||||||
gqlFields: CONNECTED_ACCOUNT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: CONNECTED_ACCOUNT_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.connectedAccount).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,409 +0,0 @@
|
|||||||
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 FAVORITE_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
|
||||||
const FAVORITE_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
|
||||||
const FAVORITE_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
|
||||||
const INITIAL_FAVORITE_POSITION_1 = 1111111;
|
|
||||||
const INITIAL_FAVORITE_POSITION_2 = 2222222;
|
|
||||||
const INITIAL_FAVORITE_POSITION_3 = 3333333;
|
|
||||||
const NEW_FAVORITE_POSITION_1 = 4444444;
|
|
||||||
const NEW_FAVORITE_POSITION_2 = 5555555;
|
|
||||||
const FAVORITE_GQL_FIELDS = `
|
|
||||||
id
|
|
||||||
position
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
deletedAt
|
|
||||||
companyId
|
|
||||||
personId
|
|
||||||
`;
|
|
||||||
|
|
||||||
describe('favorites resolvers (integration)', () => {
|
|
||||||
it('1. should create and return favorites', async () => {
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'favorite',
|
|
||||||
objectMetadataPluralName: 'favorites',
|
|
||||||
gqlFields: FAVORITE_GQL_FIELDS,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: FAVORITE_1_ID,
|
|
||||||
position: INITIAL_FAVORITE_POSITION_1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: FAVORITE_2_ID,
|
|
||||||
position: INITIAL_FAVORITE_POSITION_2,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.createFavorites).toHaveLength(2);
|
|
||||||
|
|
||||||
response.body.data.createFavorites.forEach((favorite) => {
|
|
||||||
expect(favorite).toHaveProperty('position');
|
|
||||||
expect([
|
|
||||||
INITIAL_FAVORITE_POSITION_1,
|
|
||||||
INITIAL_FAVORITE_POSITION_2,
|
|
||||||
]).toContain(favorite.position);
|
|
||||||
|
|
||||||
expect(favorite).toHaveProperty('id');
|
|
||||||
expect(favorite).toHaveProperty('createdAt');
|
|
||||||
expect(favorite).toHaveProperty('updatedAt');
|
|
||||||
expect(favorite).toHaveProperty('deletedAt');
|
|
||||||
expect(favorite).toHaveProperty('companyId');
|
|
||||||
expect(favorite).toHaveProperty('personId');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1b. should create and return one favorite', async () => {
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'favorite',
|
|
||||||
gqlFields: FAVORITE_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
id: FAVORITE_3_ID,
|
|
||||||
position: INITIAL_FAVORITE_POSITION_3,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const createdFavorite = response.body.data.createFavorite;
|
|
||||||
|
|
||||||
expect(createdFavorite).toHaveProperty('position');
|
|
||||||
expect(createdFavorite.position).toEqual(INITIAL_FAVORITE_POSITION_3);
|
|
||||||
|
|
||||||
expect(createdFavorite).toHaveProperty('id');
|
|
||||||
expect(createdFavorite).toHaveProperty('createdAt');
|
|
||||||
expect(createdFavorite).toHaveProperty('updatedAt');
|
|
||||||
expect(createdFavorite).toHaveProperty('deletedAt');
|
|
||||||
expect(createdFavorite).toHaveProperty('companyId');
|
|
||||||
expect(createdFavorite).toHaveProperty('personId');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2. should find many favorites', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'favorite',
|
|
||||||
objectMetadataPluralName: 'favorites',
|
|
||||||
gqlFields: FAVORITE_GQL_FIELDS,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const data = response.body.data.favorites;
|
|
||||||
|
|
||||||
expect(data).toBeDefined();
|
|
||||||
expect(Array.isArray(data.edges)).toBe(true);
|
|
||||||
|
|
||||||
const edges = data.edges;
|
|
||||||
|
|
||||||
if (edges.length > 0) {
|
|
||||||
const favorite = edges[0].node;
|
|
||||||
|
|
||||||
expect(favorite).toHaveProperty('position');
|
|
||||||
expect(favorite).toHaveProperty('id');
|
|
||||||
expect(favorite).toHaveProperty('createdAt');
|
|
||||||
expect(favorite).toHaveProperty('updatedAt');
|
|
||||||
expect(favorite).toHaveProperty('deletedAt');
|
|
||||||
expect(favorite).toHaveProperty('companyId');
|
|
||||||
expect(favorite).toHaveProperty('personId');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2b. should find one favorite', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'favorite',
|
|
||||||
gqlFields: FAVORITE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: FAVORITE_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const favorite = response.body.data.favorite;
|
|
||||||
|
|
||||||
expect(favorite).toHaveProperty('position');
|
|
||||||
|
|
||||||
expect(favorite).toHaveProperty('id');
|
|
||||||
expect(favorite).toHaveProperty('createdAt');
|
|
||||||
expect(favorite).toHaveProperty('updatedAt');
|
|
||||||
expect(favorite).toHaveProperty('deletedAt');
|
|
||||||
expect(favorite).toHaveProperty('companyId');
|
|
||||||
expect(favorite).toHaveProperty('personId');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3. should update many favorites', async () => {
|
|
||||||
const graphqlOperation = updateManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'favorite',
|
|
||||||
objectMetadataPluralName: 'favorites',
|
|
||||||
gqlFields: FAVORITE_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
position: NEW_FAVORITE_POSITION_1,
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [FAVORITE_1_ID, FAVORITE_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedFavorites = response.body.data.updateFavorites;
|
|
||||||
|
|
||||||
expect(updatedFavorites).toHaveLength(2);
|
|
||||||
|
|
||||||
updatedFavorites.forEach((favorite) => {
|
|
||||||
expect(favorite.position).toEqual(NEW_FAVORITE_POSITION_1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3b. should update one favorite', async () => {
|
|
||||||
const graphqlOperation = updateOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'favorite',
|
|
||||||
gqlFields: FAVORITE_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
position: NEW_FAVORITE_POSITION_2,
|
|
||||||
},
|
|
||||||
recordId: FAVORITE_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedFavorite = response.body.data.updateFavorite;
|
|
||||||
|
|
||||||
expect(updatedFavorite.position).toEqual(NEW_FAVORITE_POSITION_2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4. should find many favorites with updated position', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'favorite',
|
|
||||||
objectMetadataPluralName: 'favorites',
|
|
||||||
gqlFields: FAVORITE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
position: {
|
|
||||||
eq: NEW_FAVORITE_POSITION_1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.favorites.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4b. should find one favorite with updated position', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'favorite',
|
|
||||||
gqlFields: FAVORITE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
position: {
|
|
||||||
eq: NEW_FAVORITE_POSITION_2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.favorite.position).toEqual(
|
|
||||||
NEW_FAVORITE_POSITION_2,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5. should delete many favorites', async () => {
|
|
||||||
const graphqlOperation = deleteManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'favorite',
|
|
||||||
objectMetadataPluralName: 'favorites',
|
|
||||||
gqlFields: FAVORITE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [FAVORITE_1_ID, FAVORITE_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const deleteFavorites = response.body.data.deleteFavorites;
|
|
||||||
|
|
||||||
expect(deleteFavorites).toHaveLength(2);
|
|
||||||
|
|
||||||
deleteFavorites.forEach((favorite) => {
|
|
||||||
expect(favorite.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5b. should delete one favorite', async () => {
|
|
||||||
const graphqlOperation = deleteOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'favorite',
|
|
||||||
gqlFields: FAVORITE_GQL_FIELDS,
|
|
||||||
recordId: FAVORITE_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.deleteFavorite.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6. should not find many favorites anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'favorite',
|
|
||||||
objectMetadataPluralName: 'favorites',
|
|
||||||
gqlFields: FAVORITE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [FAVORITE_1_ID, FAVORITE_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const findFavoritesResponse = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(findFavoritesResponse.body.data.favorites.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6b. should not find one favorite anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'favorite',
|
|
||||||
gqlFields: FAVORITE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: FAVORITE_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.favorite).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7. should find many deleted favorites with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'favorite',
|
|
||||||
objectMetadataPluralName: 'favorites',
|
|
||||||
gqlFields: FAVORITE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [FAVORITE_1_ID, FAVORITE_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.favorites.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7b. should find one deleted favorite with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'favorite',
|
|
||||||
gqlFields: FAVORITE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: FAVORITE_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.favorite.id).toEqual(FAVORITE_3_ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8. should destroy many favorites', async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'favorite',
|
|
||||||
objectMetadataPluralName: 'favorites',
|
|
||||||
gqlFields: FAVORITE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [FAVORITE_1_ID, FAVORITE_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.destroyFavorites).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8b. should destroy one favorite', async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'favorite',
|
|
||||||
gqlFields: FAVORITE_GQL_FIELDS,
|
|
||||||
recordId: FAVORITE_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const destroyFavoriteResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(destroyFavoriteResponse.body.data.destroyFavorite).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9. should not find many favorites anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'favorite',
|
|
||||||
objectMetadataPluralName: 'favorites',
|
|
||||||
gqlFields: FAVORITE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [FAVORITE_1_ID, FAVORITE_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.favorites.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9b. should not find one favorite anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'favorite',
|
|
||||||
gqlFields: FAVORITE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: FAVORITE_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.favorite).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,493 +0,0 @@
|
|||||||
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 MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_1_ID =
|
|
||||||
'777a8457-eb2d-40ac-a707-551b615b6987';
|
|
||||||
const MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_2_ID =
|
|
||||||
'777a8457-eb2d-40ac-a707-551b615b6988';
|
|
||||||
const MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_3_ID =
|
|
||||||
'777a8457-eb2d-40ac-a707-551b615b6989';
|
|
||||||
|
|
||||||
const MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_GQL_FIELDS = `
|
|
||||||
id
|
|
||||||
messageExternalId
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
deletedAt
|
|
||||||
messageChannelId
|
|
||||||
messageId
|
|
||||||
direction
|
|
||||||
`;
|
|
||||||
|
|
||||||
describe('messageChannelMessageAssociations resolvers (integration)', () => {
|
|
||||||
it('1. should create and return messageChannelMessageAssociations', async () => {
|
|
||||||
const messageExternalId1 = generateRecordName(
|
|
||||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_1_ID,
|
|
||||||
);
|
|
||||||
const messageExternalId2 = generateRecordName(
|
|
||||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_2_ID,
|
|
||||||
);
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageChannelMessageAssociation',
|
|
||||||
objectMetadataPluralName: 'messageChannelMessageAssociations',
|
|
||||||
gqlFields: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_GQL_FIELDS,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_1_ID,
|
|
||||||
messageExternalId: messageExternalId1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_2_ID,
|
|
||||||
messageExternalId: messageExternalId2,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
response.body.data.createMessageChannelMessageAssociations,
|
|
||||||
).toHaveLength(2);
|
|
||||||
|
|
||||||
response.body.data.createMessageChannelMessageAssociations.forEach(
|
|
||||||
(messageChannelMessageAssociation) => {
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty(
|
|
||||||
'messageExternalId',
|
|
||||||
);
|
|
||||||
expect([messageExternalId1, messageExternalId2]).toContain(
|
|
||||||
messageChannelMessageAssociation.messageExternalId,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty('id');
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty('createdAt');
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty('updatedAt');
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty('deletedAt');
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty(
|
|
||||||
'messageChannelId',
|
|
||||||
);
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty('messageId');
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty('direction');
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1b. should create and return one messageChannelMessageAssociation', async () => {
|
|
||||||
const messageExternalId3 = generateRecordName(
|
|
||||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_3_ID,
|
|
||||||
);
|
|
||||||
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageChannelMessageAssociation',
|
|
||||||
gqlFields: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
id: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_3_ID,
|
|
||||||
messageExternalId: messageExternalId3,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const createdMessageChannelMessageAssociation =
|
|
||||||
response.body.data.createMessageChannelMessageAssociation;
|
|
||||||
|
|
||||||
expect(createdMessageChannelMessageAssociation).toHaveProperty(
|
|
||||||
'messageExternalId',
|
|
||||||
);
|
|
||||||
expect(createdMessageChannelMessageAssociation.messageExternalId).toEqual(
|
|
||||||
messageExternalId3,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(createdMessageChannelMessageAssociation).toHaveProperty('id');
|
|
||||||
expect(createdMessageChannelMessageAssociation).toHaveProperty('createdAt');
|
|
||||||
expect(createdMessageChannelMessageAssociation).toHaveProperty('updatedAt');
|
|
||||||
expect(createdMessageChannelMessageAssociation).toHaveProperty('deletedAt');
|
|
||||||
expect(createdMessageChannelMessageAssociation).toHaveProperty(
|
|
||||||
'messageChannelId',
|
|
||||||
);
|
|
||||||
expect(createdMessageChannelMessageAssociation).toHaveProperty('messageId');
|
|
||||||
expect(createdMessageChannelMessageAssociation).toHaveProperty('direction');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2. should find many messageChannelMessageAssociations', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageChannelMessageAssociation',
|
|
||||||
objectMetadataPluralName: 'messageChannelMessageAssociations',
|
|
||||||
gqlFields: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_GQL_FIELDS,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const data = response.body.data.messageChannelMessageAssociations;
|
|
||||||
|
|
||||||
expect(data).toBeDefined();
|
|
||||||
expect(Array.isArray(data.edges)).toBe(true);
|
|
||||||
|
|
||||||
const edges = data.edges;
|
|
||||||
|
|
||||||
if (edges.length > 0) {
|
|
||||||
const messageChannelMessageAssociation = edges[0].node;
|
|
||||||
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty(
|
|
||||||
'messageExternalId',
|
|
||||||
);
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty('id');
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty('createdAt');
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty('updatedAt');
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty('deletedAt');
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty(
|
|
||||||
'messageChannelId',
|
|
||||||
);
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty('messageId');
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty('direction');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2b. should find one messageChannelMessageAssociation', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageChannelMessageAssociation',
|
|
||||||
gqlFields: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const messageChannelMessageAssociation =
|
|
||||||
response.body.data.messageChannelMessageAssociation;
|
|
||||||
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty(
|
|
||||||
'messageExternalId',
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty('id');
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty('createdAt');
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty('updatedAt');
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty('deletedAt');
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty('messageChannelId');
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty('messageId');
|
|
||||||
expect(messageChannelMessageAssociation).toHaveProperty('direction');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3. should update many messageChannelMessageAssociations', async () => {
|
|
||||||
const graphqlOperation = updateManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageChannelMessageAssociation',
|
|
||||||
objectMetadataPluralName: 'messageChannelMessageAssociations',
|
|
||||||
gqlFields: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
messageExternalId: 'updated-message-external-id',
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [
|
|
||||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_1_ID,
|
|
||||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_2_ID,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedmessageChannelMessageAssociations =
|
|
||||||
response.body.data.updateMessageChannelMessageAssociations;
|
|
||||||
|
|
||||||
expect(updatedmessageChannelMessageAssociations).toHaveLength(2);
|
|
||||||
|
|
||||||
updatedmessageChannelMessageAssociations.forEach(
|
|
||||||
(messageChannelMessageAssociation) => {
|
|
||||||
expect(messageChannelMessageAssociation.messageExternalId).toEqual(
|
|
||||||
'updated-message-external-id',
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3b. should update one messageChannelMessageAssociation', async () => {
|
|
||||||
const graphqlOperation = updateOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageChannelMessageAssociation',
|
|
||||||
gqlFields: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
messageExternalId: 'new-message-external-id',
|
|
||||||
},
|
|
||||||
recordId: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedmessageChannelMessageAssociation =
|
|
||||||
response.body.data.updateMessageChannelMessageAssociation;
|
|
||||||
|
|
||||||
expect(updatedmessageChannelMessageAssociation.messageExternalId).toEqual(
|
|
||||||
'new-message-external-id',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4. should find many messageChannelMessageAssociations with updated messageExternalId', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageChannelMessageAssociation',
|
|
||||||
objectMetadataPluralName: 'messageChannelMessageAssociations',
|
|
||||||
gqlFields: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
messageExternalId: {
|
|
||||||
eq: 'updated-message-external-id',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
response.body.data.messageChannelMessageAssociations.edges,
|
|
||||||
).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4b. should find one messageChannelMessageAssociation with updated messageExternalId', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageChannelMessageAssociation',
|
|
||||||
gqlFields: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
messageExternalId: {
|
|
||||||
eq: 'new-message-external-id',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
response.body.data.messageChannelMessageAssociation.messageExternalId,
|
|
||||||
).toEqual('new-message-external-id');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5. should delete many messageChannelMessageAssociations', async () => {
|
|
||||||
const graphqlOperation = deleteManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageChannelMessageAssociation',
|
|
||||||
objectMetadataPluralName: 'messageChannelMessageAssociations',
|
|
||||||
gqlFields: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [
|
|
||||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_1_ID,
|
|
||||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_2_ID,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const deleteMessageChannelMessageAssociations =
|
|
||||||
response.body.data.deleteMessageChannelMessageAssociations;
|
|
||||||
|
|
||||||
expect(deleteMessageChannelMessageAssociations).toHaveLength(2);
|
|
||||||
|
|
||||||
deleteMessageChannelMessageAssociations.forEach(
|
|
||||||
(messageChannelMessageAssociation) => {
|
|
||||||
expect(messageChannelMessageAssociation.deletedAt).toBeTruthy();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5b. should delete one messageChannelMessageAssociation', async () => {
|
|
||||||
const graphqlOperation = deleteOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageChannelMessageAssociation',
|
|
||||||
gqlFields: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_GQL_FIELDS,
|
|
||||||
recordId: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
response.body.data.deleteMessageChannelMessageAssociation.deletedAt,
|
|
||||||
).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6. should not find many messageChannelMessageAssociations anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageChannelMessageAssociation',
|
|
||||||
objectMetadataPluralName: 'messageChannelMessageAssociations',
|
|
||||||
gqlFields: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [
|
|
||||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_1_ID,
|
|
||||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_2_ID,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const findMessageChannelMessageAssociationsResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
findMessageChannelMessageAssociationsResponse.body.data
|
|
||||||
.messageChannelMessageAssociations.edges,
|
|
||||||
).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6b. should not find one messageChannelMessageAssociation anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageChannelMessageAssociation',
|
|
||||||
gqlFields: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.messageChannelMessageAssociation).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7. should find many deleted messageChannelMessageAssociations with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageChannelMessageAssociation',
|
|
||||||
objectMetadataPluralName: 'messageChannelMessageAssociations',
|
|
||||||
gqlFields: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [
|
|
||||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_1_ID,
|
|
||||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_2_ID,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
response.body.data.messageChannelMessageAssociations.edges,
|
|
||||||
).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7b. should find one deleted messageChannelMessageAssociation with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageChannelMessageAssociation',
|
|
||||||
gqlFields: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.messageChannelMessageAssociation.id).toEqual(
|
|
||||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_3_ID,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8. should destroy many messageChannelMessageAssociations', async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageChannelMessageAssociation',
|
|
||||||
objectMetadataPluralName: 'messageChannelMessageAssociations',
|
|
||||||
gqlFields: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [
|
|
||||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_1_ID,
|
|
||||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_2_ID,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
response.body.data.destroyMessageChannelMessageAssociations,
|
|
||||||
).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8b. should destroy one messageChannelMessageAssociation', async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageChannelMessageAssociation',
|
|
||||||
gqlFields: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_GQL_FIELDS,
|
|
||||||
recordId: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const destroyMessageChannelMessageAssociationResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
destroyMessageChannelMessageAssociationResponse.body.data
|
|
||||||
.destroyMessageChannelMessageAssociation,
|
|
||||||
).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9. should not find many messageChannelMessageAssociations anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageChannelMessageAssociation',
|
|
||||||
objectMetadataPluralName: 'messageChannelMessageAssociations',
|
|
||||||
gqlFields: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [
|
|
||||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_1_ID,
|
|
||||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_2_ID,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
response.body.data.messageChannelMessageAssociations.edges,
|
|
||||||
).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9b. should not find one messageChannelMessageAssociation anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageChannelMessageAssociation',
|
|
||||||
gqlFields: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.messageChannelMessageAssociation).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,466 +0,0 @@
|
|||||||
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 MESSAGE_PARTICIPANT_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
|
||||||
const MESSAGE_PARTICIPANT_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
|
||||||
const MESSAGE_PARTICIPANT_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
|
||||||
const MESSAGE_ID = '777a8457-eb2d-40ac-a707-441b615b6989';
|
|
||||||
const MESSAGE_PARTICIPANT_GQL_FIELDS = `
|
|
||||||
id
|
|
||||||
displayName
|
|
||||||
handle
|
|
||||||
role
|
|
||||||
messageId
|
|
||||||
workspaceMemberId
|
|
||||||
createdAt
|
|
||||||
deletedAt
|
|
||||||
`;
|
|
||||||
|
|
||||||
describe('messageParticipants resolvers (integration)', () => {
|
|
||||||
beforeAll(async () => {
|
|
||||||
const messageSubject = generateRecordName(MESSAGE_ID);
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'message',
|
|
||||||
gqlFields: `id`,
|
|
||||||
data: {
|
|
||||||
id: MESSAGE_ID,
|
|
||||||
subject: messageSubject,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'message',
|
|
||||||
gqlFields: `id`,
|
|
||||||
recordId: MESSAGE_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1. should create and return messageParticipants', async () => {
|
|
||||||
const messageParticipantDisplayName1 = generateRecordName(
|
|
||||||
MESSAGE_PARTICIPANT_1_ID,
|
|
||||||
);
|
|
||||||
const messageParticipantDisplayName2 = generateRecordName(
|
|
||||||
MESSAGE_PARTICIPANT_2_ID,
|
|
||||||
);
|
|
||||||
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageParticipant',
|
|
||||||
objectMetadataPluralName: 'messageParticipants',
|
|
||||||
gqlFields: MESSAGE_PARTICIPANT_GQL_FIELDS,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: MESSAGE_PARTICIPANT_1_ID,
|
|
||||||
displayName: messageParticipantDisplayName1,
|
|
||||||
messageId: MESSAGE_ID,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: MESSAGE_PARTICIPANT_2_ID,
|
|
||||||
displayName: messageParticipantDisplayName2,
|
|
||||||
messageId: MESSAGE_ID,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.createMessageParticipants).toHaveLength(2);
|
|
||||||
|
|
||||||
response.body.data.createMessageParticipants.forEach(
|
|
||||||
(messageParticipant) => {
|
|
||||||
expect(messageParticipant).toHaveProperty('displayName');
|
|
||||||
expect([
|
|
||||||
messageParticipantDisplayName1,
|
|
||||||
messageParticipantDisplayName2,
|
|
||||||
]).toContain(messageParticipant.displayName);
|
|
||||||
|
|
||||||
expect(messageParticipant).toHaveProperty('id');
|
|
||||||
expect(messageParticipant).toHaveProperty('handle');
|
|
||||||
expect(messageParticipant).toHaveProperty('role');
|
|
||||||
expect(messageParticipant).toHaveProperty('messageId');
|
|
||||||
expect(messageParticipant).toHaveProperty('workspaceMemberId');
|
|
||||||
expect(messageParticipant).toHaveProperty('createdAt');
|
|
||||||
expect(messageParticipant).toHaveProperty('deletedAt');
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1b. should create and return one messageParticipant', async () => {
|
|
||||||
const messageParticipantDisplayName = generateRecordName(
|
|
||||||
MESSAGE_PARTICIPANT_3_ID,
|
|
||||||
);
|
|
||||||
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageParticipant',
|
|
||||||
gqlFields: MESSAGE_PARTICIPANT_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
id: MESSAGE_PARTICIPANT_3_ID,
|
|
||||||
displayName: messageParticipantDisplayName,
|
|
||||||
messageId: MESSAGE_ID,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const createdMessageParticipant =
|
|
||||||
response.body.data.createMessageParticipant;
|
|
||||||
|
|
||||||
expect(createdMessageParticipant).toHaveProperty('displayName');
|
|
||||||
expect(createdMessageParticipant.displayName).toEqual(
|
|
||||||
messageParticipantDisplayName,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(createdMessageParticipant).toHaveProperty('id');
|
|
||||||
expect(createdMessageParticipant).toHaveProperty('handle');
|
|
||||||
expect(createdMessageParticipant).toHaveProperty('role');
|
|
||||||
expect(createdMessageParticipant).toHaveProperty('messageId');
|
|
||||||
expect(createdMessageParticipant).toHaveProperty('workspaceMemberId');
|
|
||||||
expect(createdMessageParticipant).toHaveProperty('createdAt');
|
|
||||||
expect(createdMessageParticipant).toHaveProperty('deletedAt');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2. should find many messageParticipants', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageParticipant',
|
|
||||||
objectMetadataPluralName: 'messageParticipants',
|
|
||||||
gqlFields: MESSAGE_PARTICIPANT_GQL_FIELDS,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const data = response.body.data.messageParticipants;
|
|
||||||
|
|
||||||
expect(data).toBeDefined();
|
|
||||||
expect(Array.isArray(data.edges)).toBe(true);
|
|
||||||
|
|
||||||
const edges = data.edges;
|
|
||||||
|
|
||||||
if (edges.length > 0) {
|
|
||||||
const messageParticipant = edges[0].node;
|
|
||||||
|
|
||||||
expect(messageParticipant).toHaveProperty('displayName');
|
|
||||||
expect(messageParticipant).toHaveProperty('id');
|
|
||||||
expect(messageParticipant).toHaveProperty('handle');
|
|
||||||
expect(messageParticipant).toHaveProperty('role');
|
|
||||||
expect(messageParticipant).toHaveProperty('messageId');
|
|
||||||
expect(messageParticipant).toHaveProperty('workspaceMemberId');
|
|
||||||
expect(messageParticipant).toHaveProperty('createdAt');
|
|
||||||
expect(messageParticipant).toHaveProperty('deletedAt');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2b. should find one messageParticipant', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageParticipant',
|
|
||||||
gqlFields: MESSAGE_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: MESSAGE_PARTICIPANT_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const messageParticipant = response.body.data.messageParticipant;
|
|
||||||
|
|
||||||
expect(messageParticipant).toHaveProperty('displayName');
|
|
||||||
|
|
||||||
expect(messageParticipant).toHaveProperty('id');
|
|
||||||
expect(messageParticipant).toHaveProperty('handle');
|
|
||||||
expect(messageParticipant).toHaveProperty('role');
|
|
||||||
expect(messageParticipant).toHaveProperty('messageId');
|
|
||||||
expect(messageParticipant).toHaveProperty('workspaceMemberId');
|
|
||||||
expect(messageParticipant).toHaveProperty('createdAt');
|
|
||||||
expect(messageParticipant).toHaveProperty('deletedAt');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3. should update many messageParticipants', async () => {
|
|
||||||
const graphqlOperation = updateManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageParticipant',
|
|
||||||
objectMetadataPluralName: 'messageParticipants',
|
|
||||||
gqlFields: MESSAGE_PARTICIPANT_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
displayName: 'New DisplayName',
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [MESSAGE_PARTICIPANT_1_ID, MESSAGE_PARTICIPANT_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedmessageParticipants =
|
|
||||||
response.body.data.updateMessageParticipants;
|
|
||||||
|
|
||||||
expect(updatedmessageParticipants).toHaveLength(2);
|
|
||||||
|
|
||||||
updatedmessageParticipants.forEach((messageParticipant) => {
|
|
||||||
expect(messageParticipant.displayName).toEqual('New DisplayName');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3b. should update one messageParticipant', async () => {
|
|
||||||
const graphqlOperation = updateOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageParticipant',
|
|
||||||
gqlFields: MESSAGE_PARTICIPANT_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
displayName: 'Updated DisplayName',
|
|
||||||
},
|
|
||||||
recordId: MESSAGE_PARTICIPANT_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedmessageParticipant =
|
|
||||||
response.body.data.updateMessageParticipant;
|
|
||||||
|
|
||||||
expect(updatedmessageParticipant.displayName).toEqual(
|
|
||||||
'Updated DisplayName',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4. should find many messageParticipants with updated displayName', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageParticipant',
|
|
||||||
objectMetadataPluralName: 'messageParticipants',
|
|
||||||
gqlFields: MESSAGE_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
displayName: {
|
|
||||||
eq: 'New DisplayName',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.messageParticipants.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4b. should find one messageParticipant with updated displayName', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageParticipant',
|
|
||||||
gqlFields: MESSAGE_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
displayName: {
|
|
||||||
eq: 'Updated DisplayName',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.messageParticipant.displayName).toEqual(
|
|
||||||
'Updated DisplayName',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5. should delete many messageParticipants', async () => {
|
|
||||||
const graphqlOperation = deleteManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageParticipant',
|
|
||||||
objectMetadataPluralName: 'messageParticipants',
|
|
||||||
gqlFields: MESSAGE_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [MESSAGE_PARTICIPANT_1_ID, MESSAGE_PARTICIPANT_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const deleteMessageParticipants =
|
|
||||||
response.body.data.deleteMessageParticipants;
|
|
||||||
|
|
||||||
expect(deleteMessageParticipants).toHaveLength(2);
|
|
||||||
|
|
||||||
deleteMessageParticipants.forEach((messageParticipant) => {
|
|
||||||
expect(messageParticipant.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5b. should delete one messageParticipant', async () => {
|
|
||||||
const graphqlOperation = deleteOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageParticipant',
|
|
||||||
gqlFields: MESSAGE_PARTICIPANT_GQL_FIELDS,
|
|
||||||
recordId: MESSAGE_PARTICIPANT_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.deleteMessageParticipant.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6. should not find many messageParticipants anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageParticipant',
|
|
||||||
objectMetadataPluralName: 'messageParticipants',
|
|
||||||
gqlFields: MESSAGE_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [MESSAGE_PARTICIPANT_1_ID, MESSAGE_PARTICIPANT_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const findMessageParticipantsResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
findMessageParticipantsResponse.body.data.messageParticipants.edges,
|
|
||||||
).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6b. should not find one messageParticipant anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageParticipant',
|
|
||||||
gqlFields: MESSAGE_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: MESSAGE_PARTICIPANT_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.messageParticipant).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7. should find many deleted messageParticipants with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageParticipant',
|
|
||||||
objectMetadataPluralName: 'messageParticipants',
|
|
||||||
gqlFields: MESSAGE_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [MESSAGE_PARTICIPANT_1_ID, MESSAGE_PARTICIPANT_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.messageParticipants.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7b. should find one deleted messageParticipant with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageParticipant',
|
|
||||||
gqlFields: MESSAGE_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: MESSAGE_PARTICIPANT_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.messageParticipant.id).toEqual(
|
|
||||||
MESSAGE_PARTICIPANT_3_ID,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8. should destroy many messageParticipants', async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageParticipant',
|
|
||||||
objectMetadataPluralName: 'messageParticipants',
|
|
||||||
gqlFields: MESSAGE_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [MESSAGE_PARTICIPANT_1_ID, MESSAGE_PARTICIPANT_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.destroyMessageParticipants).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8b. should destroy one messageParticipant', async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageParticipant',
|
|
||||||
gqlFields: MESSAGE_PARTICIPANT_GQL_FIELDS,
|
|
||||||
recordId: MESSAGE_PARTICIPANT_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const destroyMessageParticipantResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
destroyMessageParticipantResponse.body.data.destroyMessageParticipant,
|
|
||||||
).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9. should not find many messageParticipants anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageParticipant',
|
|
||||||
objectMetadataPluralName: 'messageParticipants',
|
|
||||||
gqlFields: MESSAGE_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [MESSAGE_PARTICIPANT_1_ID, MESSAGE_PARTICIPANT_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.messageParticipants.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9b. should not find one messageParticipant anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageParticipant',
|
|
||||||
gqlFields: MESSAGE_PARTICIPANT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: MESSAGE_PARTICIPANT_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.messageParticipant).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,397 +0,0 @@
|
|||||||
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 MESSAGE_THREAD_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
|
||||||
const MESSAGE_THREAD_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
|
||||||
const MESSAGE_THREAD_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
|
||||||
const UPDATED_AT_1 = new Date('10/10/2024');
|
|
||||||
const UPDATED_AT_2 = new Date('10/20/2024');
|
|
||||||
|
|
||||||
const MESSAGE_THREAD_GQL_FIELDS = `
|
|
||||||
id
|
|
||||||
updatedAt
|
|
||||||
createdAt
|
|
||||||
deletedAt
|
|
||||||
messages{
|
|
||||||
edges{
|
|
||||||
node{
|
|
||||||
id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
describe('messageThreads resolvers (integration)', () => {
|
|
||||||
it('1. should create and return messageThreads', async () => {
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageThread',
|
|
||||||
objectMetadataPluralName: 'messageThreads',
|
|
||||||
gqlFields: MESSAGE_THREAD_GQL_FIELDS,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: MESSAGE_THREAD_1_ID,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: MESSAGE_THREAD_2_ID,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.createMessageThreads).toHaveLength(2);
|
|
||||||
|
|
||||||
response.body.data.createMessageThreads.forEach((messageThread) => {
|
|
||||||
expect(messageThread).toHaveProperty('id');
|
|
||||||
expect(messageThread).toHaveProperty('updatedAt');
|
|
||||||
expect(messageThread).toHaveProperty('createdAt');
|
|
||||||
expect(messageThread).toHaveProperty('deletedAt');
|
|
||||||
expect(messageThread).toHaveProperty('messages');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1b. should create and return one messageThread', async () => {
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageThread',
|
|
||||||
gqlFields: MESSAGE_THREAD_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
id: MESSAGE_THREAD_3_ID,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const createdMessageThread = response.body.data.createMessageThread;
|
|
||||||
|
|
||||||
expect(createdMessageThread).toHaveProperty('id');
|
|
||||||
expect(createdMessageThread).toHaveProperty('updatedAt');
|
|
||||||
expect(createdMessageThread).toHaveProperty('createdAt');
|
|
||||||
expect(createdMessageThread).toHaveProperty('deletedAt');
|
|
||||||
expect(createdMessageThread).toHaveProperty('messages');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2. should find many messageThreads', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageThread',
|
|
||||||
objectMetadataPluralName: 'messageThreads',
|
|
||||||
gqlFields: MESSAGE_THREAD_GQL_FIELDS,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const data = response.body.data.messageThreads;
|
|
||||||
|
|
||||||
expect(data).toBeDefined();
|
|
||||||
expect(Array.isArray(data.edges)).toBe(true);
|
|
||||||
|
|
||||||
const edges = data.edges;
|
|
||||||
|
|
||||||
if (edges.length > 0) {
|
|
||||||
const messageThread = edges[0].node;
|
|
||||||
|
|
||||||
expect(messageThread).toHaveProperty('id');
|
|
||||||
expect(messageThread).toHaveProperty('updatedAt');
|
|
||||||
expect(messageThread).toHaveProperty('createdAt');
|
|
||||||
expect(messageThread).toHaveProperty('deletedAt');
|
|
||||||
expect(messageThread).toHaveProperty('messages');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2b. should find one messageThread', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageThread',
|
|
||||||
gqlFields: MESSAGE_THREAD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: MESSAGE_THREAD_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const messageThread = response.body.data.messageThread;
|
|
||||||
|
|
||||||
expect(messageThread).toHaveProperty('id');
|
|
||||||
expect(messageThread).toHaveProperty('updatedAt');
|
|
||||||
expect(messageThread).toHaveProperty('createdAt');
|
|
||||||
expect(messageThread).toHaveProperty('deletedAt');
|
|
||||||
expect(messageThread).toHaveProperty('messages');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3. should update many messageThreads', async () => {
|
|
||||||
const graphqlOperation = updateManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageThread',
|
|
||||||
objectMetadataPluralName: 'messageThreads',
|
|
||||||
gqlFields: MESSAGE_THREAD_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
updatedAt: UPDATED_AT_1,
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [MESSAGE_THREAD_1_ID, MESSAGE_THREAD_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedMessageThreads = response.body.data.updateMessageThreads;
|
|
||||||
|
|
||||||
expect(updatedMessageThreads).toHaveLength(2);
|
|
||||||
|
|
||||||
updatedMessageThreads.forEach((messageThread) => {
|
|
||||||
expect(messageThread.updatedAt).toEqual(UPDATED_AT_1.toISOString());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3b. should update one messageThread', async () => {
|
|
||||||
const graphqlOperation = updateOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageThread',
|
|
||||||
gqlFields: MESSAGE_THREAD_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
updatedAt: UPDATED_AT_2,
|
|
||||||
},
|
|
||||||
recordId: MESSAGE_THREAD_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedMessageThread = response.body.data.updateMessageThread;
|
|
||||||
|
|
||||||
expect(updatedMessageThread.updatedAt).toEqual(UPDATED_AT_2.toISOString());
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4. should find many messageThreads with updated updatedAt', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageThread',
|
|
||||||
objectMetadataPluralName: 'messageThreads',
|
|
||||||
gqlFields: MESSAGE_THREAD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
updatedAt: {
|
|
||||||
eq: UPDATED_AT_1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.messageThreads.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4b. should find one messageThread with updated updatedAt', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageThread',
|
|
||||||
gqlFields: MESSAGE_THREAD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
updatedAt: {
|
|
||||||
eq: UPDATED_AT_2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.messageThread.updatedAt).toEqual(
|
|
||||||
UPDATED_AT_2.toISOString(),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5. should delete many messageThreads', async () => {
|
|
||||||
const graphqlOperation = deleteManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageThread',
|
|
||||||
objectMetadataPluralName: 'messageThreads',
|
|
||||||
gqlFields: MESSAGE_THREAD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [MESSAGE_THREAD_1_ID, MESSAGE_THREAD_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const deleteMessageThreads = response.body.data.deleteMessageThreads;
|
|
||||||
|
|
||||||
expect(deleteMessageThreads).toHaveLength(2);
|
|
||||||
|
|
||||||
deleteMessageThreads.forEach((messageThread) => {
|
|
||||||
expect(messageThread.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5b. should delete one messageThread', async () => {
|
|
||||||
const graphqlOperation = deleteOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageThread',
|
|
||||||
gqlFields: MESSAGE_THREAD_GQL_FIELDS,
|
|
||||||
recordId: MESSAGE_THREAD_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.deleteMessageThread.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6. should not find many messageThreads anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageThread',
|
|
||||||
objectMetadataPluralName: 'messageThreads',
|
|
||||||
gqlFields: MESSAGE_THREAD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [MESSAGE_THREAD_1_ID, MESSAGE_THREAD_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const findMessageThreadsResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
findMessageThreadsResponse.body.data.messageThreads.edges,
|
|
||||||
).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6b. should not find one messageThread anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageThread',
|
|
||||||
gqlFields: MESSAGE_THREAD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: MESSAGE_THREAD_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.messageThread).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7. should find many deleted messageThreads with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageThread',
|
|
||||||
objectMetadataPluralName: 'messageThreads',
|
|
||||||
gqlFields: MESSAGE_THREAD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [MESSAGE_THREAD_1_ID, MESSAGE_THREAD_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.messageThreads.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7b. should find one deleted messageThread with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageThread',
|
|
||||||
gqlFields: MESSAGE_THREAD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: MESSAGE_THREAD_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.messageThread.id).toEqual(MESSAGE_THREAD_3_ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8. should destroy many messageThreads', async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageThread',
|
|
||||||
objectMetadataPluralName: 'messageThreads',
|
|
||||||
gqlFields: MESSAGE_THREAD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [MESSAGE_THREAD_1_ID, MESSAGE_THREAD_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.destroyMessageThreads).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8b. should destroy one messageThread', async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageThread',
|
|
||||||
gqlFields: MESSAGE_THREAD_GQL_FIELDS,
|
|
||||||
recordId: MESSAGE_THREAD_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const destroyMessageThreadsResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
destroyMessageThreadsResponse.body.data.destroyMessageThread,
|
|
||||||
).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9. should not find many messageThreads anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageThread',
|
|
||||||
objectMetadataPluralName: 'messageThreads',
|
|
||||||
gqlFields: MESSAGE_THREAD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [MESSAGE_THREAD_1_ID, MESSAGE_THREAD_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.messageThreads.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9b. should not find one messageThread anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'messageThread',
|
|
||||||
gqlFields: MESSAGE_THREAD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: MESSAGE_THREAD_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.messageThread).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,444 +0,0 @@
|
|||||||
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 NOTE_TARGET_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
|
||||||
const NOTE_TARGET_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
|
||||||
const NOTE_TARGET_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
|
||||||
const PERSON_1_ID = 'f875ff46-b881-41ba-973a-b9cd5345e8f0';
|
|
||||||
const PERSON_2_ID = '1fe0f78c-8c59-4ce6-ae02-56571331b252';
|
|
||||||
const NOTE_TARGET_GQL_FIELDS = `
|
|
||||||
id
|
|
||||||
createdAt
|
|
||||||
deletedAt
|
|
||||||
noteId
|
|
||||||
personId
|
|
||||||
companyId
|
|
||||||
opportunityId
|
|
||||||
person{
|
|
||||||
id
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
describe('noteTargets resolvers (integration)', () => {
|
|
||||||
beforeAll(async () => {
|
|
||||||
const personName1 = generateRecordName(PERSON_1_ID);
|
|
||||||
const personName2 = generateRecordName(PERSON_2_ID);
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'person',
|
|
||||||
objectMetadataPluralName: 'people',
|
|
||||||
gqlFields: `id`,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: PERSON_1_ID,
|
|
||||||
name: {
|
|
||||||
firstName: personName1,
|
|
||||||
lastName: personName1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: PERSON_2_ID,
|
|
||||||
name: {
|
|
||||||
firstName: personName2,
|
|
||||||
lastName: personName2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'person',
|
|
||||||
objectMetadataPluralName: 'people',
|
|
||||||
gqlFields: `id`,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [PERSON_1_ID, PERSON_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
});
|
|
||||||
it('1. should create and return noteTargets', async () => {
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'noteTarget',
|
|
||||||
objectMetadataPluralName: 'noteTargets',
|
|
||||||
gqlFields: NOTE_TARGET_GQL_FIELDS,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: NOTE_TARGET_1_ID,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: NOTE_TARGET_2_ID,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.createNoteTargets).toHaveLength(2);
|
|
||||||
|
|
||||||
response.body.data.createNoteTargets.forEach((noteTarget) => {
|
|
||||||
expect(noteTarget).toHaveProperty('id');
|
|
||||||
expect(noteTarget).toHaveProperty('createdAt');
|
|
||||||
expect(noteTarget).toHaveProperty('deletedAt');
|
|
||||||
expect(noteTarget).toHaveProperty('noteId');
|
|
||||||
expect(noteTarget).toHaveProperty('personId');
|
|
||||||
expect(noteTarget).toHaveProperty('companyId');
|
|
||||||
expect(noteTarget).toHaveProperty('opportunityId');
|
|
||||||
expect(noteTarget).toHaveProperty('person');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1b. should create and return one noteTarget', async () => {
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'noteTarget',
|
|
||||||
gqlFields: NOTE_TARGET_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
id: NOTE_TARGET_3_ID,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const createdNoteTarget = response.body.data.createNoteTarget;
|
|
||||||
|
|
||||||
expect(createdNoteTarget).toHaveProperty('id');
|
|
||||||
expect(createdNoteTarget).toHaveProperty('createdAt');
|
|
||||||
expect(createdNoteTarget).toHaveProperty('deletedAt');
|
|
||||||
expect(createdNoteTarget).toHaveProperty('noteId');
|
|
||||||
expect(createdNoteTarget).toHaveProperty('personId');
|
|
||||||
expect(createdNoteTarget).toHaveProperty('companyId');
|
|
||||||
expect(createdNoteTarget).toHaveProperty('opportunityId');
|
|
||||||
expect(createdNoteTarget).toHaveProperty('person');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2. should find many noteTargets', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'noteTarget',
|
|
||||||
objectMetadataPluralName: 'noteTargets',
|
|
||||||
gqlFields: NOTE_TARGET_GQL_FIELDS,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const data = response.body.data.noteTargets;
|
|
||||||
|
|
||||||
expect(data).toBeDefined();
|
|
||||||
expect(Array.isArray(data.edges)).toBe(true);
|
|
||||||
|
|
||||||
const edges = data.edges;
|
|
||||||
|
|
||||||
if (edges.length > 0) {
|
|
||||||
const noteTarget = edges[0].node;
|
|
||||||
|
|
||||||
expect(noteTarget).toHaveProperty('id');
|
|
||||||
expect(noteTarget).toHaveProperty('createdAt');
|
|
||||||
expect(noteTarget).toHaveProperty('deletedAt');
|
|
||||||
expect(noteTarget).toHaveProperty('noteId');
|
|
||||||
expect(noteTarget).toHaveProperty('personId');
|
|
||||||
expect(noteTarget).toHaveProperty('companyId');
|
|
||||||
expect(noteTarget).toHaveProperty('opportunityId');
|
|
||||||
expect(noteTarget).toHaveProperty('person');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2b. should find one noteTarget', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'noteTarget',
|
|
||||||
gqlFields: NOTE_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: NOTE_TARGET_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const noteTarget = response.body.data.noteTarget;
|
|
||||||
|
|
||||||
expect(noteTarget).toHaveProperty('id');
|
|
||||||
expect(noteTarget).toHaveProperty('createdAt');
|
|
||||||
expect(noteTarget).toHaveProperty('deletedAt');
|
|
||||||
expect(noteTarget).toHaveProperty('noteId');
|
|
||||||
expect(noteTarget).toHaveProperty('personId');
|
|
||||||
expect(noteTarget).toHaveProperty('companyId');
|
|
||||||
expect(noteTarget).toHaveProperty('opportunityId');
|
|
||||||
expect(noteTarget).toHaveProperty('person');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3. should update many noteTargets', async () => {
|
|
||||||
const graphqlOperation = updateManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'noteTarget',
|
|
||||||
objectMetadataPluralName: 'noteTargets',
|
|
||||||
gqlFields: NOTE_TARGET_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
personId: PERSON_1_ID,
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [NOTE_TARGET_1_ID, NOTE_TARGET_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedNoteTargets = response.body.data.updateNoteTargets;
|
|
||||||
|
|
||||||
expect(updatedNoteTargets).toHaveLength(2);
|
|
||||||
|
|
||||||
updatedNoteTargets.forEach((noteTarget) => {
|
|
||||||
expect(noteTarget.person.id).toEqual(PERSON_1_ID);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3b. should update one noteTarget', async () => {
|
|
||||||
const graphqlOperation = updateOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'noteTarget',
|
|
||||||
gqlFields: NOTE_TARGET_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
personId: PERSON_2_ID,
|
|
||||||
},
|
|
||||||
recordId: NOTE_TARGET_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedNoteTarget = response.body.data.updateNoteTarget;
|
|
||||||
|
|
||||||
expect(updatedNoteTarget.person.id).toEqual(PERSON_2_ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4. should find many noteTargets with updated personId', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'noteTarget',
|
|
||||||
objectMetadataPluralName: 'noteTargets',
|
|
||||||
gqlFields: NOTE_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
personId: {
|
|
||||||
eq: PERSON_1_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.noteTargets.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4b. should find one noteTarget with updated personId', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'noteTarget',
|
|
||||||
gqlFields: NOTE_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
personId: {
|
|
||||||
eq: PERSON_2_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.noteTarget.person.id).toEqual(PERSON_2_ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5. should delete many noteTargets', async () => {
|
|
||||||
const graphqlOperation = deleteManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'noteTarget',
|
|
||||||
objectMetadataPluralName: 'noteTargets',
|
|
||||||
gqlFields: NOTE_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [NOTE_TARGET_1_ID, NOTE_TARGET_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const deleteNoteTargets = response.body.data.deleteNoteTargets;
|
|
||||||
|
|
||||||
expect(deleteNoteTargets).toHaveLength(2);
|
|
||||||
|
|
||||||
deleteNoteTargets.forEach((noteTarget) => {
|
|
||||||
expect(noteTarget.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5b. should delete one noteTarget', async () => {
|
|
||||||
const graphqlOperation = deleteOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'noteTarget',
|
|
||||||
gqlFields: NOTE_TARGET_GQL_FIELDS,
|
|
||||||
recordId: NOTE_TARGET_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.deleteNoteTarget.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6. should not find many noteTargets anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'noteTarget',
|
|
||||||
objectMetadataPluralName: 'noteTargets',
|
|
||||||
gqlFields: NOTE_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [NOTE_TARGET_1_ID, NOTE_TARGET_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const findNoteTargetsResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(findNoteTargetsResponse.body.data.noteTargets.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6b. should not find one noteTarget anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'noteTarget',
|
|
||||||
gqlFields: NOTE_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: NOTE_TARGET_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.noteTarget).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7. should find many deleted noteTargets with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'noteTarget',
|
|
||||||
objectMetadataPluralName: 'noteTargets',
|
|
||||||
gqlFields: NOTE_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [NOTE_TARGET_1_ID, NOTE_TARGET_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.noteTargets.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7b. should find one deleted noteTarget with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'noteTarget',
|
|
||||||
gqlFields: NOTE_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: NOTE_TARGET_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.noteTarget.id).toEqual(NOTE_TARGET_3_ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8. should destroy many noteTargets', async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'noteTarget',
|
|
||||||
objectMetadataPluralName: 'noteTargets',
|
|
||||||
gqlFields: NOTE_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [NOTE_TARGET_1_ID, NOTE_TARGET_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.destroyNoteTargets).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8b. should destroy one noteTarget', async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'noteTarget',
|
|
||||||
gqlFields: NOTE_TARGET_GQL_FIELDS,
|
|
||||||
recordId: NOTE_TARGET_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const destroyNoteTargetsResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(destroyNoteTargetsResponse.body.data.destroyNoteTarget).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9. should not find many noteTargets anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'noteTarget',
|
|
||||||
objectMetadataPluralName: 'noteTargets',
|
|
||||||
gqlFields: NOTE_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [NOTE_TARGET_1_ID, NOTE_TARGET_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.noteTargets.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9b. should not find one noteTarget anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'noteTarget',
|
|
||||||
gqlFields: NOTE_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: NOTE_TARGET_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.noteTarget).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,403 +0,0 @@
|
|||||||
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 NOTE_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
|
||||||
const NOTE_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
|
||||||
const NOTE_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
|
||||||
|
|
||||||
const NOTE_GQL_FIELDS = `
|
|
||||||
id
|
|
||||||
title
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
deletedAt
|
|
||||||
body
|
|
||||||
position
|
|
||||||
`;
|
|
||||||
|
|
||||||
describe('notes resolvers (integration)', () => {
|
|
||||||
it('1. should create and return notes', async () => {
|
|
||||||
const noteTitle1 = generateRecordName(NOTE_1_ID);
|
|
||||||
const noteTitle2 = generateRecordName(NOTE_2_ID);
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'note',
|
|
||||||
objectMetadataPluralName: 'notes',
|
|
||||||
gqlFields: NOTE_GQL_FIELDS,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: NOTE_1_ID,
|
|
||||||
title: noteTitle1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: NOTE_2_ID,
|
|
||||||
title: noteTitle2,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.createNotes).toHaveLength(2);
|
|
||||||
|
|
||||||
response.body.data.createNotes.forEach((note) => {
|
|
||||||
expect(note).toHaveProperty('title');
|
|
||||||
expect([noteTitle1, noteTitle2]).toContain(note.title);
|
|
||||||
|
|
||||||
expect(note).toHaveProperty('id');
|
|
||||||
expect(note).toHaveProperty('createdAt');
|
|
||||||
expect(note).toHaveProperty('updatedAt');
|
|
||||||
expect(note).toHaveProperty('deletedAt');
|
|
||||||
expect(note).toHaveProperty('body');
|
|
||||||
expect(note).toHaveProperty('position');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1b. should create and return one note', async () => {
|
|
||||||
const noteTitle3 = generateRecordName(NOTE_3_ID);
|
|
||||||
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'note',
|
|
||||||
gqlFields: NOTE_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
id: NOTE_3_ID,
|
|
||||||
title: noteTitle3,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const createdNote = response.body.data.createNote;
|
|
||||||
|
|
||||||
expect(createdNote).toHaveProperty('title');
|
|
||||||
expect(createdNote.title).toEqual(noteTitle3);
|
|
||||||
|
|
||||||
expect(createdNote).toHaveProperty('id');
|
|
||||||
expect(createdNote).toHaveProperty('createdAt');
|
|
||||||
expect(createdNote).toHaveProperty('updatedAt');
|
|
||||||
expect(createdNote).toHaveProperty('deletedAt');
|
|
||||||
expect(createdNote).toHaveProperty('body');
|
|
||||||
expect(createdNote).toHaveProperty('position');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2. should find many notes', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'note',
|
|
||||||
objectMetadataPluralName: 'notes',
|
|
||||||
gqlFields: NOTE_GQL_FIELDS,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const data = response.body.data.notes;
|
|
||||||
|
|
||||||
expect(data).toBeDefined();
|
|
||||||
expect(Array.isArray(data.edges)).toBe(true);
|
|
||||||
|
|
||||||
const edges = data.edges;
|
|
||||||
|
|
||||||
if (edges.length > 0) {
|
|
||||||
const note = edges[0].node;
|
|
||||||
|
|
||||||
expect(note).toHaveProperty('id');
|
|
||||||
expect(note).toHaveProperty('createdAt');
|
|
||||||
expect(note).toHaveProperty('updatedAt');
|
|
||||||
expect(note).toHaveProperty('deletedAt');
|
|
||||||
expect(note).toHaveProperty('body');
|
|
||||||
expect(note).toHaveProperty('position');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2b. should find one note', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'note',
|
|
||||||
gqlFields: NOTE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: NOTE_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const note = response.body.data.note;
|
|
||||||
|
|
||||||
expect(note).toHaveProperty('title');
|
|
||||||
|
|
||||||
expect(note).toHaveProperty('id');
|
|
||||||
expect(note).toHaveProperty('createdAt');
|
|
||||||
expect(note).toHaveProperty('updatedAt');
|
|
||||||
expect(note).toHaveProperty('deletedAt');
|
|
||||||
expect(note).toHaveProperty('body');
|
|
||||||
expect(note).toHaveProperty('position');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3. should update many notes', async () => {
|
|
||||||
const graphqlOperation = updateManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'note',
|
|
||||||
objectMetadataPluralName: 'notes',
|
|
||||||
gqlFields: NOTE_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
title: 'Updated Title',
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [NOTE_1_ID, NOTE_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedNotes = response.body.data.updateNotes;
|
|
||||||
|
|
||||||
expect(updatedNotes).toHaveLength(2);
|
|
||||||
|
|
||||||
updatedNotes.forEach((note) => {
|
|
||||||
expect(note.title).toEqual('Updated Title');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3b. should update one note', async () => {
|
|
||||||
const graphqlOperation = updateOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'note',
|
|
||||||
gqlFields: NOTE_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
title: 'New Title',
|
|
||||||
},
|
|
||||||
recordId: NOTE_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedNote = response.body.data.updateNote;
|
|
||||||
|
|
||||||
expect(updatedNote.title).toEqual('New Title');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4. should find many notes with updated title', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'note',
|
|
||||||
objectMetadataPluralName: 'notes',
|
|
||||||
gqlFields: NOTE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
title: {
|
|
||||||
eq: 'Updated Title',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.notes.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4b. should find one note with updated title', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'note',
|
|
||||||
gqlFields: NOTE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
title: {
|
|
||||||
eq: 'New Title',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.note.title).toEqual('New Title');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5. should delete many notes', async () => {
|
|
||||||
const graphqlOperation = deleteManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'note',
|
|
||||||
objectMetadataPluralName: 'notes',
|
|
||||||
gqlFields: NOTE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [NOTE_1_ID, NOTE_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const deleteNotes = response.body.data.deleteNotes;
|
|
||||||
|
|
||||||
expect(deleteNotes).toHaveLength(2);
|
|
||||||
|
|
||||||
deleteNotes.forEach((note) => {
|
|
||||||
expect(note.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5b. should delete one note', async () => {
|
|
||||||
const graphqlOperation = deleteOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'note',
|
|
||||||
gqlFields: NOTE_GQL_FIELDS,
|
|
||||||
recordId: NOTE_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.deleteNote.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6. should not find many notes anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'note',
|
|
||||||
objectMetadataPluralName: 'notes',
|
|
||||||
gqlFields: NOTE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [NOTE_1_ID, NOTE_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const findNotesResponse = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(findNotesResponse.body.data.notes.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6b. should not find one note anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'note',
|
|
||||||
gqlFields: NOTE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: NOTE_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.note).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7. should find many deleted notes with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'note',
|
|
||||||
objectMetadataPluralName: 'notes',
|
|
||||||
gqlFields: NOTE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [NOTE_1_ID, NOTE_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.notes.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7b. should find one deleted note with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'note',
|
|
||||||
gqlFields: NOTE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: NOTE_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.note.id).toEqual(NOTE_3_ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8. should destroy many notes', async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'note',
|
|
||||||
objectMetadataPluralName: 'notes',
|
|
||||||
gqlFields: NOTE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [NOTE_1_ID, NOTE_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.destroyNotes).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8b. should destroy one note', async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'note',
|
|
||||||
gqlFields: NOTE_GQL_FIELDS,
|
|
||||||
recordId: NOTE_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const destroyNotesResponse = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(destroyNotesResponse.body.data.destroyNote).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9. should not find many notes anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'note',
|
|
||||||
objectMetadataPluralName: 'notes',
|
|
||||||
gqlFields: NOTE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [NOTE_1_ID, NOTE_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.notes.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9b. should not find one note anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'note',
|
|
||||||
gqlFields: NOTE_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: NOTE_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.note).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,414 +0,0 @@
|
|||||||
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 OPPORTUNITY_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
|
||||||
const OPPORTUNITY_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
|
||||||
const OPPORTUNITY_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
|
||||||
|
|
||||||
const OPPORTUNITY_GQL_FIELDS = `
|
|
||||||
id
|
|
||||||
name
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
deletedAt
|
|
||||||
searchVector
|
|
||||||
stage
|
|
||||||
position
|
|
||||||
`;
|
|
||||||
|
|
||||||
describe('opportunities resolvers (integration)', () => {
|
|
||||||
it('1. should create and return opportunities', async () => {
|
|
||||||
const opportunityName1 = generateRecordName(OPPORTUNITY_1_ID);
|
|
||||||
const opportunityName2 = generateRecordName(OPPORTUNITY_2_ID);
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'opportunity',
|
|
||||||
objectMetadataPluralName: 'opportunities',
|
|
||||||
gqlFields: OPPORTUNITY_GQL_FIELDS,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: OPPORTUNITY_1_ID,
|
|
||||||
name: opportunityName1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: OPPORTUNITY_2_ID,
|
|
||||||
name: opportunityName2,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.createOpportunities).toHaveLength(2);
|
|
||||||
|
|
||||||
response.body.data.createOpportunities.forEach((opportunity) => {
|
|
||||||
expect(opportunity).toHaveProperty('name');
|
|
||||||
expect([opportunityName1, opportunityName2]).toContain(opportunity.name);
|
|
||||||
|
|
||||||
expect(opportunity).toHaveProperty('id');
|
|
||||||
expect(opportunity).toHaveProperty('createdAt');
|
|
||||||
expect(opportunity).toHaveProperty('updatedAt');
|
|
||||||
expect(opportunity).toHaveProperty('deletedAt');
|
|
||||||
expect(opportunity).toHaveProperty('searchVector');
|
|
||||||
expect(opportunity).toHaveProperty('stage');
|
|
||||||
expect(opportunity).toHaveProperty('position');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1b. should create and return one opportunity', async () => {
|
|
||||||
const opportunityName3 = generateRecordName(OPPORTUNITY_3_ID);
|
|
||||||
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'opportunity',
|
|
||||||
gqlFields: OPPORTUNITY_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
id: OPPORTUNITY_3_ID,
|
|
||||||
name: opportunityName3,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const createdOpportunity = response.body.data.createOpportunity;
|
|
||||||
|
|
||||||
expect(createdOpportunity).toHaveProperty('name');
|
|
||||||
expect(createdOpportunity.name).toEqual(opportunityName3);
|
|
||||||
|
|
||||||
expect(createdOpportunity).toHaveProperty('id');
|
|
||||||
expect(createdOpportunity).toHaveProperty('createdAt');
|
|
||||||
expect(createdOpportunity).toHaveProperty('updatedAt');
|
|
||||||
expect(createdOpportunity).toHaveProperty('deletedAt');
|
|
||||||
expect(createdOpportunity).toHaveProperty('searchVector');
|
|
||||||
expect(createdOpportunity).toHaveProperty('stage');
|
|
||||||
expect(createdOpportunity).toHaveProperty('position');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2. should find many opportunities', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'opportunity',
|
|
||||||
objectMetadataPluralName: 'opportunities',
|
|
||||||
gqlFields: OPPORTUNITY_GQL_FIELDS,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const data = response.body.data.opportunities;
|
|
||||||
|
|
||||||
expect(data).toBeDefined();
|
|
||||||
expect(Array.isArray(data.edges)).toBe(true);
|
|
||||||
|
|
||||||
const edges = data.edges;
|
|
||||||
|
|
||||||
if (edges.length > 0) {
|
|
||||||
const opportunity = edges[0].node;
|
|
||||||
|
|
||||||
expect(opportunity).toHaveProperty('id');
|
|
||||||
expect(opportunity).toHaveProperty('createdAt');
|
|
||||||
expect(opportunity).toHaveProperty('updatedAt');
|
|
||||||
expect(opportunity).toHaveProperty('deletedAt');
|
|
||||||
expect(opportunity).toHaveProperty('searchVector');
|
|
||||||
expect(opportunity).toHaveProperty('stage');
|
|
||||||
expect(opportunity).toHaveProperty('position');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2b. should find one opportunity', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'opportunity',
|
|
||||||
gqlFields: OPPORTUNITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: OPPORTUNITY_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const opportunity = response.body.data.opportunity;
|
|
||||||
|
|
||||||
expect(opportunity).toHaveProperty('name');
|
|
||||||
|
|
||||||
expect(opportunity).toHaveProperty('id');
|
|
||||||
expect(opportunity).toHaveProperty('createdAt');
|
|
||||||
expect(opportunity).toHaveProperty('updatedAt');
|
|
||||||
expect(opportunity).toHaveProperty('deletedAt');
|
|
||||||
expect(opportunity).toHaveProperty('searchVector');
|
|
||||||
expect(opportunity).toHaveProperty('stage');
|
|
||||||
expect(opportunity).toHaveProperty('position');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3. should update many opportunities', async () => {
|
|
||||||
const graphqlOperation = updateManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'opportunity',
|
|
||||||
objectMetadataPluralName: 'opportunities',
|
|
||||||
gqlFields: OPPORTUNITY_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
name: 'Updated Name',
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [OPPORTUNITY_1_ID, OPPORTUNITY_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedOpportunities = response.body.data.updateOpportunities;
|
|
||||||
|
|
||||||
expect(updatedOpportunities).toHaveLength(2);
|
|
||||||
|
|
||||||
updatedOpportunities.forEach((opportunity) => {
|
|
||||||
expect(opportunity.name).toEqual('Updated Name');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3b. should update one opportunity', async () => {
|
|
||||||
const graphqlOperation = updateOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'opportunity',
|
|
||||||
gqlFields: OPPORTUNITY_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
name: 'New Name',
|
|
||||||
},
|
|
||||||
recordId: OPPORTUNITY_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedOpportunity = response.body.data.updateOpportunity;
|
|
||||||
|
|
||||||
expect(updatedOpportunity.name).toEqual('New Name');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4. should find many opportunities with updated name', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'opportunity',
|
|
||||||
objectMetadataPluralName: 'opportunities',
|
|
||||||
gqlFields: OPPORTUNITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
name: {
|
|
||||||
eq: 'Updated Name',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.opportunities.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4b. should find one opportunity with updated name', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'opportunity',
|
|
||||||
gqlFields: OPPORTUNITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
name: {
|
|
||||||
eq: 'New Name',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.opportunity.name).toEqual('New Name');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5. should delete many opportunities', async () => {
|
|
||||||
const graphqlOperation = deleteManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'opportunity',
|
|
||||||
objectMetadataPluralName: 'opportunities',
|
|
||||||
gqlFields: OPPORTUNITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [OPPORTUNITY_1_ID, OPPORTUNITY_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const deleteOpportunities = response.body.data.deleteOpportunities;
|
|
||||||
|
|
||||||
expect(deleteOpportunities).toHaveLength(2);
|
|
||||||
|
|
||||||
deleteOpportunities.forEach((opportunity) => {
|
|
||||||
expect(opportunity.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5b. should delete one opportunity', async () => {
|
|
||||||
const graphqlOperation = deleteOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'opportunity',
|
|
||||||
gqlFields: OPPORTUNITY_GQL_FIELDS,
|
|
||||||
recordId: OPPORTUNITY_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.deleteOpportunity.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6. should not find many opportunities anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'opportunity',
|
|
||||||
objectMetadataPluralName: 'opportunities',
|
|
||||||
gqlFields: OPPORTUNITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [OPPORTUNITY_1_ID, OPPORTUNITY_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const findOpportunitiesResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
findOpportunitiesResponse.body.data.opportunities.edges,
|
|
||||||
).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6b. should not find one opportunity anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'opportunity',
|
|
||||||
gqlFields: OPPORTUNITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: OPPORTUNITY_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.opportunity).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7. should find many deleted opportunities with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'opportunity',
|
|
||||||
objectMetadataPluralName: 'opportunities',
|
|
||||||
gqlFields: OPPORTUNITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [OPPORTUNITY_1_ID, OPPORTUNITY_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.opportunities.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7b. should find one deleted opportunity with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'opportunity',
|
|
||||||
gqlFields: OPPORTUNITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: OPPORTUNITY_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.opportunity.id).toEqual(OPPORTUNITY_3_ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8. should destroy many opportunities', async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'opportunity',
|
|
||||||
objectMetadataPluralName: 'opportunities',
|
|
||||||
gqlFields: OPPORTUNITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [OPPORTUNITY_1_ID, OPPORTUNITY_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.destroyOpportunities).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8b. should destroy one opportunity', async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'opportunity',
|
|
||||||
gqlFields: OPPORTUNITY_GQL_FIELDS,
|
|
||||||
recordId: OPPORTUNITY_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const destroyOpportunitiesResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
destroyOpportunitiesResponse.body.data.destroyOpportunity,
|
|
||||||
).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9. should not find many opportunities anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'opportunity',
|
|
||||||
objectMetadataPluralName: 'opportunities',
|
|
||||||
gqlFields: OPPORTUNITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [OPPORTUNITY_1_ID, OPPORTUNITY_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.opportunities.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9b. should not find one opportunity anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'opportunity',
|
|
||||||
gqlFields: OPPORTUNITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: OPPORTUNITY_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.opportunity).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,430 +0,0 @@
|
|||||||
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 COMPANY_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
|
||||||
const COMPANY_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
|
||||||
const COMPANY_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
|
||||||
const COMPANY_GQL_FIELDS = `
|
|
||||||
id
|
|
||||||
name
|
|
||||||
employees
|
|
||||||
idealCustomerProfile
|
|
||||||
position
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
deletedAt
|
|
||||||
accountOwnerId
|
|
||||||
tagline
|
|
||||||
workPolicy
|
|
||||||
visaSponsorship
|
|
||||||
`;
|
|
||||||
|
|
||||||
describe('companies resolvers (integration)', () => {
|
|
||||||
it('1. should create and return companies', async () => {
|
|
||||||
const companyName1 = generateRecordName(COMPANY_1_ID);
|
|
||||||
const companyName2 = generateRecordName(COMPANY_2_ID);
|
|
||||||
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'company',
|
|
||||||
objectMetadataPluralName: 'companies',
|
|
||||||
gqlFields: COMPANY_GQL_FIELDS,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: COMPANY_1_ID,
|
|
||||||
name: companyName1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: COMPANY_2_ID,
|
|
||||||
name: companyName2,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.createCompanies).toHaveLength(2);
|
|
||||||
|
|
||||||
response.body.data.createCompanies.forEach((company) => {
|
|
||||||
expect(company).toHaveProperty('name');
|
|
||||||
expect([companyName1, companyName2]).toContain(company.name);
|
|
||||||
|
|
||||||
expect(company).toHaveProperty('employees');
|
|
||||||
expect(company).toHaveProperty('idealCustomerProfile');
|
|
||||||
expect(company).toHaveProperty('position');
|
|
||||||
expect(company).toHaveProperty('id');
|
|
||||||
expect(company).toHaveProperty('createdAt');
|
|
||||||
expect(company).toHaveProperty('updatedAt');
|
|
||||||
expect(company).toHaveProperty('deletedAt');
|
|
||||||
expect(company).toHaveProperty('accountOwnerId');
|
|
||||||
expect(company).toHaveProperty('tagline');
|
|
||||||
expect(company).toHaveProperty('workPolicy');
|
|
||||||
expect(company).toHaveProperty('visaSponsorship');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1b. should create and return one company', async () => {
|
|
||||||
const companyName = generateRecordName(COMPANY_3_ID);
|
|
||||||
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'company',
|
|
||||||
gqlFields: COMPANY_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
id: COMPANY_3_ID,
|
|
||||||
name: companyName,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const createdCompany = response.body.data.createCompany;
|
|
||||||
|
|
||||||
expect(createdCompany).toHaveProperty('name');
|
|
||||||
expect(createdCompany.name).toEqual(companyName);
|
|
||||||
|
|
||||||
expect(createdCompany).toHaveProperty('employees');
|
|
||||||
expect(createdCompany).toHaveProperty('idealCustomerProfile');
|
|
||||||
expect(createdCompany).toHaveProperty('position');
|
|
||||||
expect(createdCompany).toHaveProperty('id');
|
|
||||||
expect(createdCompany).toHaveProperty('createdAt');
|
|
||||||
expect(createdCompany).toHaveProperty('updatedAt');
|
|
||||||
expect(createdCompany).toHaveProperty('deletedAt');
|
|
||||||
expect(createdCompany).toHaveProperty('accountOwnerId');
|
|
||||||
expect(createdCompany).toHaveProperty('tagline');
|
|
||||||
expect(createdCompany).toHaveProperty('workPolicy');
|
|
||||||
expect(createdCompany).toHaveProperty('visaSponsorship');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2. should find many companies', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'company',
|
|
||||||
objectMetadataPluralName: 'companies',
|
|
||||||
gqlFields: COMPANY_GQL_FIELDS,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const data = response.body.data.companies;
|
|
||||||
|
|
||||||
expect(data).toBeDefined();
|
|
||||||
expect(Array.isArray(data.edges)).toBe(true);
|
|
||||||
|
|
||||||
const edges = data.edges;
|
|
||||||
|
|
||||||
if (edges.length > 0) {
|
|
||||||
const companies = edges[0].node;
|
|
||||||
|
|
||||||
expect(companies).toHaveProperty('name');
|
|
||||||
expect(companies).toHaveProperty('employees');
|
|
||||||
expect(companies).toHaveProperty('idealCustomerProfile');
|
|
||||||
expect(companies).toHaveProperty('position');
|
|
||||||
expect(companies).toHaveProperty('id');
|
|
||||||
expect(companies).toHaveProperty('createdAt');
|
|
||||||
expect(companies).toHaveProperty('updatedAt');
|
|
||||||
expect(companies).toHaveProperty('deletedAt');
|
|
||||||
expect(companies).toHaveProperty('accountOwnerId');
|
|
||||||
expect(companies).toHaveProperty('tagline');
|
|
||||||
expect(companies).toHaveProperty('workPolicy');
|
|
||||||
expect(companies).toHaveProperty('visaSponsorship');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2b. should find one company', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'company',
|
|
||||||
gqlFields: COMPANY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: COMPANY_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const company = response.body.data.company;
|
|
||||||
|
|
||||||
expect(company).toHaveProperty('name');
|
|
||||||
|
|
||||||
expect(company).toHaveProperty('employees');
|
|
||||||
expect(company).toHaveProperty('idealCustomerProfile');
|
|
||||||
expect(company).toHaveProperty('position');
|
|
||||||
expect(company).toHaveProperty('id');
|
|
||||||
expect(company).toHaveProperty('createdAt');
|
|
||||||
expect(company).toHaveProperty('updatedAt');
|
|
||||||
expect(company).toHaveProperty('deletedAt');
|
|
||||||
expect(company).toHaveProperty('accountOwnerId');
|
|
||||||
expect(company).toHaveProperty('tagline');
|
|
||||||
expect(company).toHaveProperty('workPolicy');
|
|
||||||
expect(company).toHaveProperty('visaSponsorship');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3. should update many companies', async () => {
|
|
||||||
const graphqlOperation = updateManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'company',
|
|
||||||
objectMetadataPluralName: 'companies',
|
|
||||||
gqlFields: COMPANY_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
employees: 123,
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [COMPANY_1_ID, COMPANY_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedCompanies = response.body.data.updateCompanies;
|
|
||||||
|
|
||||||
expect(updatedCompanies).toHaveLength(2);
|
|
||||||
|
|
||||||
updatedCompanies.forEach((company) => {
|
|
||||||
expect(company.employees).toEqual(123);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3b. should update one company', async () => {
|
|
||||||
const graphqlOperation = updateOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'company',
|
|
||||||
gqlFields: COMPANY_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
employees: 122,
|
|
||||||
},
|
|
||||||
recordId: COMPANY_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedCompany = response.body.data.updateCompany;
|
|
||||||
|
|
||||||
expect(updatedCompany.employees).toEqual(122);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4. should find many companies with updated employees', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'company',
|
|
||||||
objectMetadataPluralName: 'companies',
|
|
||||||
gqlFields: COMPANY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
employees: {
|
|
||||||
eq: 123,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.companies.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4b. should find one company with updated employees', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'company',
|
|
||||||
gqlFields: COMPANY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
employees: {
|
|
||||||
eq: 122,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.company.employees).toEqual(122);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5. should delete many companies', async () => {
|
|
||||||
const graphqlOperation = deleteManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'company',
|
|
||||||
objectMetadataPluralName: 'companies',
|
|
||||||
gqlFields: COMPANY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [COMPANY_1_ID, COMPANY_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const deleteCompanies = response.body.data.deleteCompanies;
|
|
||||||
|
|
||||||
expect(deleteCompanies).toHaveLength(2);
|
|
||||||
|
|
||||||
deleteCompanies.forEach((company) => {
|
|
||||||
expect(company.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5b. should delete one company', async () => {
|
|
||||||
const graphqlOperation = deleteOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'company',
|
|
||||||
gqlFields: COMPANY_GQL_FIELDS,
|
|
||||||
recordId: COMPANY_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.deleteCompany.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6. should not find many companies anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'company',
|
|
||||||
objectMetadataPluralName: 'companies',
|
|
||||||
gqlFields: COMPANY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [COMPANY_1_ID, COMPANY_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const findCompaniesResponse = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(findCompaniesResponse.body.data.companies.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6b. should not find one company anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'company',
|
|
||||||
gqlFields: COMPANY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: COMPANY_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.company).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7. should find many deleted companies with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'company',
|
|
||||||
objectMetadataPluralName: 'companies',
|
|
||||||
gqlFields: COMPANY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [COMPANY_1_ID, COMPANY_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.companies.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7b. should find one deleted company with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'company',
|
|
||||||
gqlFields: COMPANY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: COMPANY_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.company.id).toEqual(COMPANY_3_ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8. should destroy many companies', async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'company',
|
|
||||||
objectMetadataPluralName: 'companies',
|
|
||||||
gqlFields: COMPANY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [COMPANY_1_ID, COMPANY_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.destroyCompanies).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8b. should destroy one company', async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'company',
|
|
||||||
gqlFields: COMPANY_GQL_FIELDS,
|
|
||||||
recordId: COMPANY_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const destroyCompanyResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(destroyCompanyResponse.body.data.destroyCompany).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9. should not find many companies anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'company',
|
|
||||||
objectMetadataPluralName: 'companies',
|
|
||||||
gqlFields: COMPANY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [COMPANY_1_ID, COMPANY_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.companies.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9b. should not find one company anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'company',
|
|
||||||
gqlFields: COMPANY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: COMPANY_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.company).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,444 +0,0 @@
|
|||||||
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 TASK_TARGET_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
|
||||||
const TASK_TARGET_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
|
||||||
const TASK_TARGET_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
|
||||||
const PERSON_1_ID = 'f875ff46-b881-41ba-973a-b9cd5345e8f0';
|
|
||||||
const PERSON_2_ID = '1fe0f78c-8c59-4ce6-ae02-56571331b252';
|
|
||||||
const TASK_TARGET_GQL_FIELDS = `
|
|
||||||
id
|
|
||||||
createdAt
|
|
||||||
deletedAt
|
|
||||||
rocketId
|
|
||||||
personId
|
|
||||||
companyId
|
|
||||||
opportunityId
|
|
||||||
person{
|
|
||||||
id
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
describe('taskTargets resolvers (integration)', () => {
|
|
||||||
beforeAll(async () => {
|
|
||||||
const personName1 = generateRecordName(PERSON_1_ID);
|
|
||||||
const personName2 = generateRecordName(PERSON_2_ID);
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'person',
|
|
||||||
objectMetadataPluralName: 'people',
|
|
||||||
gqlFields: `id`,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: PERSON_1_ID,
|
|
||||||
name: {
|
|
||||||
firstName: personName1,
|
|
||||||
lastName: personName1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: PERSON_2_ID,
|
|
||||||
name: {
|
|
||||||
firstName: personName2,
|
|
||||||
lastName: personName2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'person',
|
|
||||||
objectMetadataPluralName: 'people',
|
|
||||||
gqlFields: `id`,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [PERSON_1_ID, PERSON_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
});
|
|
||||||
it('1. should create and return taskTargets', async () => {
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'taskTarget',
|
|
||||||
objectMetadataPluralName: 'taskTargets',
|
|
||||||
gqlFields: TASK_TARGET_GQL_FIELDS,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: TASK_TARGET_1_ID,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: TASK_TARGET_2_ID,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.createTaskTargets).toHaveLength(2);
|
|
||||||
|
|
||||||
response.body.data.createTaskTargets.forEach((taskTarget) => {
|
|
||||||
expect(taskTarget).toHaveProperty('id');
|
|
||||||
expect(taskTarget).toHaveProperty('createdAt');
|
|
||||||
expect(taskTarget).toHaveProperty('deletedAt');
|
|
||||||
expect(taskTarget).toHaveProperty('rocketId');
|
|
||||||
expect(taskTarget).toHaveProperty('personId');
|
|
||||||
expect(taskTarget).toHaveProperty('companyId');
|
|
||||||
expect(taskTarget).toHaveProperty('opportunityId');
|
|
||||||
expect(taskTarget).toHaveProperty('person');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1b. should create and return one taskTarget', async () => {
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'taskTarget',
|
|
||||||
gqlFields: TASK_TARGET_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
id: TASK_TARGET_3_ID,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const createdTaskTarget = response.body.data.createTaskTarget;
|
|
||||||
|
|
||||||
expect(createdTaskTarget).toHaveProperty('id');
|
|
||||||
expect(createdTaskTarget).toHaveProperty('createdAt');
|
|
||||||
expect(createdTaskTarget).toHaveProperty('deletedAt');
|
|
||||||
expect(createdTaskTarget).toHaveProperty('rocketId');
|
|
||||||
expect(createdTaskTarget).toHaveProperty('personId');
|
|
||||||
expect(createdTaskTarget).toHaveProperty('companyId');
|
|
||||||
expect(createdTaskTarget).toHaveProperty('opportunityId');
|
|
||||||
expect(createdTaskTarget).toHaveProperty('person');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2. should find many taskTargets', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'taskTarget',
|
|
||||||
objectMetadataPluralName: 'taskTargets',
|
|
||||||
gqlFields: TASK_TARGET_GQL_FIELDS,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const data = response.body.data.taskTargets;
|
|
||||||
|
|
||||||
expect(data).toBeDefined();
|
|
||||||
expect(Array.isArray(data.edges)).toBe(true);
|
|
||||||
|
|
||||||
const edges = data.edges;
|
|
||||||
|
|
||||||
if (edges.length > 0) {
|
|
||||||
const taskTarget = edges[0].node;
|
|
||||||
|
|
||||||
expect(taskTarget).toHaveProperty('id');
|
|
||||||
expect(taskTarget).toHaveProperty('createdAt');
|
|
||||||
expect(taskTarget).toHaveProperty('deletedAt');
|
|
||||||
expect(taskTarget).toHaveProperty('rocketId');
|
|
||||||
expect(taskTarget).toHaveProperty('personId');
|
|
||||||
expect(taskTarget).toHaveProperty('companyId');
|
|
||||||
expect(taskTarget).toHaveProperty('opportunityId');
|
|
||||||
expect(taskTarget).toHaveProperty('person');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2b. should find one taskTarget', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'taskTarget',
|
|
||||||
gqlFields: TASK_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: TASK_TARGET_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const taskTarget = response.body.data.taskTarget;
|
|
||||||
|
|
||||||
expect(taskTarget).toHaveProperty('id');
|
|
||||||
expect(taskTarget).toHaveProperty('createdAt');
|
|
||||||
expect(taskTarget).toHaveProperty('deletedAt');
|
|
||||||
expect(taskTarget).toHaveProperty('rocketId');
|
|
||||||
expect(taskTarget).toHaveProperty('personId');
|
|
||||||
expect(taskTarget).toHaveProperty('companyId');
|
|
||||||
expect(taskTarget).toHaveProperty('opportunityId');
|
|
||||||
expect(taskTarget).toHaveProperty('person');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3. should update many taskTargets', async () => {
|
|
||||||
const graphqlOperation = updateManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'taskTarget',
|
|
||||||
objectMetadataPluralName: 'taskTargets',
|
|
||||||
gqlFields: TASK_TARGET_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
personId: PERSON_1_ID,
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [TASK_TARGET_1_ID, TASK_TARGET_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedTaskTargets = response.body.data.updateTaskTargets;
|
|
||||||
|
|
||||||
expect(updatedTaskTargets).toHaveLength(2);
|
|
||||||
|
|
||||||
updatedTaskTargets.forEach((taskTarget) => {
|
|
||||||
expect(taskTarget.person.id).toEqual(PERSON_1_ID);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3b. should update one taskTarget', async () => {
|
|
||||||
const graphqlOperation = updateOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'taskTarget',
|
|
||||||
gqlFields: TASK_TARGET_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
personId: PERSON_2_ID,
|
|
||||||
},
|
|
||||||
recordId: TASK_TARGET_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedTaskTarget = response.body.data.updateTaskTarget;
|
|
||||||
|
|
||||||
expect(updatedTaskTarget.person.id).toEqual(PERSON_2_ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4. should find many taskTargets with updated personId', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'taskTarget',
|
|
||||||
objectMetadataPluralName: 'taskTargets',
|
|
||||||
gqlFields: TASK_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
personId: {
|
|
||||||
eq: PERSON_1_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.taskTargets.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4b. should find one taskTarget with updated personId', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'taskTarget',
|
|
||||||
gqlFields: TASK_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
personId: {
|
|
||||||
eq: PERSON_2_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.taskTarget.person.id).toEqual(PERSON_2_ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5. should delete many taskTargets', async () => {
|
|
||||||
const graphqlOperation = deleteManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'taskTarget',
|
|
||||||
objectMetadataPluralName: 'taskTargets',
|
|
||||||
gqlFields: TASK_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [TASK_TARGET_1_ID, TASK_TARGET_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const deleteTaskTargets = response.body.data.deleteTaskTargets;
|
|
||||||
|
|
||||||
expect(deleteTaskTargets).toHaveLength(2);
|
|
||||||
|
|
||||||
deleteTaskTargets.forEach((taskTarget) => {
|
|
||||||
expect(taskTarget.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5b. should delete one taskTarget', async () => {
|
|
||||||
const graphqlOperation = deleteOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'taskTarget',
|
|
||||||
gqlFields: TASK_TARGET_GQL_FIELDS,
|
|
||||||
recordId: TASK_TARGET_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.deleteTaskTarget.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6. should not find many taskTargets anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'taskTarget',
|
|
||||||
objectMetadataPluralName: 'taskTargets',
|
|
||||||
gqlFields: TASK_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [TASK_TARGET_1_ID, TASK_TARGET_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const findTaskTargetsResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(findTaskTargetsResponse.body.data.taskTargets.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6b. should not find one taskTarget anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'taskTarget',
|
|
||||||
gqlFields: TASK_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: TASK_TARGET_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.taskTarget).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7. should find many deleted taskTargets with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'taskTarget',
|
|
||||||
objectMetadataPluralName: 'taskTargets',
|
|
||||||
gqlFields: TASK_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [TASK_TARGET_1_ID, TASK_TARGET_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.taskTargets.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7b. should find one deleted taskTarget with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'taskTarget',
|
|
||||||
gqlFields: TASK_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: TASK_TARGET_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.taskTarget.id).toEqual(TASK_TARGET_3_ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8. should destroy many taskTargets', async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'taskTarget',
|
|
||||||
objectMetadataPluralName: 'taskTargets',
|
|
||||||
gqlFields: TASK_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [TASK_TARGET_1_ID, TASK_TARGET_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.destroyTaskTargets).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8b. should destroy one taskTarget', async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'taskTarget',
|
|
||||||
gqlFields: TASK_TARGET_GQL_FIELDS,
|
|
||||||
recordId: TASK_TARGET_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const destroyTaskTargetsResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(destroyTaskTargetsResponse.body.data.destroyTaskTarget).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9. should not find many taskTargets anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'taskTarget',
|
|
||||||
objectMetadataPluralName: 'taskTargets',
|
|
||||||
gqlFields: TASK_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [TASK_TARGET_1_ID, TASK_TARGET_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.taskTargets.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9b. should not find one taskTarget anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'taskTarget',
|
|
||||||
gqlFields: TASK_TARGET_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: TASK_TARGET_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.taskTarget).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,403 +0,0 @@
|
|||||||
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 TASK_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
|
||||||
const TASK_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
|
||||||
const TASK_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
|
||||||
|
|
||||||
const TASK_GQL_FIELDS = `
|
|
||||||
id
|
|
||||||
title
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
deletedAt
|
|
||||||
body
|
|
||||||
position
|
|
||||||
`;
|
|
||||||
|
|
||||||
describe('tasks resolvers (integration)', () => {
|
|
||||||
it('1. should create and return tasks', async () => {
|
|
||||||
const taskTitle1 = generateRecordName(TASK_1_ID);
|
|
||||||
const taskTitle2 = generateRecordName(TASK_2_ID);
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'task',
|
|
||||||
objectMetadataPluralName: 'tasks',
|
|
||||||
gqlFields: TASK_GQL_FIELDS,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: TASK_1_ID,
|
|
||||||
title: taskTitle1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: TASK_2_ID,
|
|
||||||
title: taskTitle2,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.createTasks).toHaveLength(2);
|
|
||||||
|
|
||||||
response.body.data.createTasks.forEach((task) => {
|
|
||||||
expect(task).toHaveProperty('title');
|
|
||||||
expect([taskTitle1, taskTitle2]).toContain(task.title);
|
|
||||||
|
|
||||||
expect(task).toHaveProperty('id');
|
|
||||||
expect(task).toHaveProperty('createdAt');
|
|
||||||
expect(task).toHaveProperty('updatedAt');
|
|
||||||
expect(task).toHaveProperty('deletedAt');
|
|
||||||
expect(task).toHaveProperty('body');
|
|
||||||
expect(task).toHaveProperty('position');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1b. should create and return one task', async () => {
|
|
||||||
const taskTitle3 = generateRecordName(TASK_3_ID);
|
|
||||||
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'task',
|
|
||||||
gqlFields: TASK_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
id: TASK_3_ID,
|
|
||||||
title: taskTitle3,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const createdTask = response.body.data.createTask;
|
|
||||||
|
|
||||||
expect(createdTask).toHaveProperty('title');
|
|
||||||
expect(createdTask.title).toEqual(taskTitle3);
|
|
||||||
|
|
||||||
expect(createdTask).toHaveProperty('id');
|
|
||||||
expect(createdTask).toHaveProperty('createdAt');
|
|
||||||
expect(createdTask).toHaveProperty('updatedAt');
|
|
||||||
expect(createdTask).toHaveProperty('deletedAt');
|
|
||||||
expect(createdTask).toHaveProperty('body');
|
|
||||||
expect(createdTask).toHaveProperty('position');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2. should find many tasks', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'task',
|
|
||||||
objectMetadataPluralName: 'tasks',
|
|
||||||
gqlFields: TASK_GQL_FIELDS,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const data = response.body.data.tasks;
|
|
||||||
|
|
||||||
expect(data).toBeDefined();
|
|
||||||
expect(Array.isArray(data.edges)).toBe(true);
|
|
||||||
|
|
||||||
const edges = data.edges;
|
|
||||||
|
|
||||||
if (edges.length > 0) {
|
|
||||||
const task = edges[0].node;
|
|
||||||
|
|
||||||
expect(task).toHaveProperty('id');
|
|
||||||
expect(task).toHaveProperty('createdAt');
|
|
||||||
expect(task).toHaveProperty('updatedAt');
|
|
||||||
expect(task).toHaveProperty('deletedAt');
|
|
||||||
expect(task).toHaveProperty('body');
|
|
||||||
expect(task).toHaveProperty('position');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2b. should find one task', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'task',
|
|
||||||
gqlFields: TASK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: TASK_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const task = response.body.data.task;
|
|
||||||
|
|
||||||
expect(task).toHaveProperty('title');
|
|
||||||
|
|
||||||
expect(task).toHaveProperty('id');
|
|
||||||
expect(task).toHaveProperty('createdAt');
|
|
||||||
expect(task).toHaveProperty('updatedAt');
|
|
||||||
expect(task).toHaveProperty('deletedAt');
|
|
||||||
expect(task).toHaveProperty('body');
|
|
||||||
expect(task).toHaveProperty('position');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3. should update many tasks', async () => {
|
|
||||||
const graphqlOperation = updateManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'task',
|
|
||||||
objectMetadataPluralName: 'tasks',
|
|
||||||
gqlFields: TASK_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
title: 'Updated Title',
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [TASK_1_ID, TASK_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedTasks = response.body.data.updateTasks;
|
|
||||||
|
|
||||||
expect(updatedTasks).toHaveLength(2);
|
|
||||||
|
|
||||||
updatedTasks.forEach((task) => {
|
|
||||||
expect(task.title).toEqual('Updated Title');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3b. should update one task', async () => {
|
|
||||||
const graphqlOperation = updateOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'task',
|
|
||||||
gqlFields: TASK_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
title: 'New Title',
|
|
||||||
},
|
|
||||||
recordId: TASK_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedTask = response.body.data.updateTask;
|
|
||||||
|
|
||||||
expect(updatedTask.title).toEqual('New Title');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4. should find many tasks with updated title', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'task',
|
|
||||||
objectMetadataPluralName: 'tasks',
|
|
||||||
gqlFields: TASK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
title: {
|
|
||||||
eq: 'Updated Title',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.tasks.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4b. should find one task with updated title', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'task',
|
|
||||||
gqlFields: TASK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
title: {
|
|
||||||
eq: 'New Title',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.task.title).toEqual('New Title');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5. should delete many tasks', async () => {
|
|
||||||
const graphqlOperation = deleteManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'task',
|
|
||||||
objectMetadataPluralName: 'tasks',
|
|
||||||
gqlFields: TASK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [TASK_1_ID, TASK_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const deleteTasks = response.body.data.deleteTasks;
|
|
||||||
|
|
||||||
expect(deleteTasks).toHaveLength(2);
|
|
||||||
|
|
||||||
deleteTasks.forEach((task) => {
|
|
||||||
expect(task.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5b. should delete one task', async () => {
|
|
||||||
const graphqlOperation = deleteOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'task',
|
|
||||||
gqlFields: TASK_GQL_FIELDS,
|
|
||||||
recordId: TASK_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.deleteTask.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6. should not find many tasks anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'task',
|
|
||||||
objectMetadataPluralName: 'tasks',
|
|
||||||
gqlFields: TASK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [TASK_1_ID, TASK_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const findTasksResponse = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(findTasksResponse.body.data.tasks.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6b. should not find one task anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'task',
|
|
||||||
gqlFields: TASK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: TASK_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.task).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7. should find many deleted tasks with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'task',
|
|
||||||
objectMetadataPluralName: 'tasks',
|
|
||||||
gqlFields: TASK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [TASK_1_ID, TASK_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.tasks.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7b. should find one deleted task with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'task',
|
|
||||||
gqlFields: TASK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: TASK_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.task.id).toEqual(TASK_3_ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8. should destroy many tasks', async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'task',
|
|
||||||
objectMetadataPluralName: 'tasks',
|
|
||||||
gqlFields: TASK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [TASK_1_ID, TASK_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.destroyTasks).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8b. should destroy one task', async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'task',
|
|
||||||
gqlFields: TASK_GQL_FIELDS,
|
|
||||||
recordId: TASK_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const destroyTasksResponse = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(destroyTasksResponse.body.data.destroyTask).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9. should not find many tasks anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'task',
|
|
||||||
objectMetadataPluralName: 'tasks',
|
|
||||||
gqlFields: TASK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [TASK_1_ID, TASK_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.tasks.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9b. should not find one task anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'task',
|
|
||||||
gqlFields: TASK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: TASK_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.task).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,477 +0,0 @@
|
|||||||
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 TIMELINE_ACTIVITY_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
|
||||||
const TIMELINE_ACTIVITY_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
|
||||||
const TIMELINE_ACTIVITY_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
|
||||||
|
|
||||||
const TIMELINE_ACTIVITY_GQL_FIELDS = `
|
|
||||||
id
|
|
||||||
happensAt
|
|
||||||
name
|
|
||||||
properties
|
|
||||||
linkedRecordCachedName
|
|
||||||
linkedRecordId
|
|
||||||
linkedObjectMetadataId
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
deletedAt
|
|
||||||
workspaceMemberId
|
|
||||||
personId
|
|
||||||
companyId
|
|
||||||
opportunityId
|
|
||||||
noteId
|
|
||||||
taskId
|
|
||||||
workflowId
|
|
||||||
workflowVersionId
|
|
||||||
workflowRunId
|
|
||||||
rocketId
|
|
||||||
`;
|
|
||||||
|
|
||||||
describe('timelineActivities resolvers (integration)', () => {
|
|
||||||
it('1. should create and return timelineActivities', async () => {
|
|
||||||
const timelineActivityName1 = generateRecordName(TIMELINE_ACTIVITY_1_ID);
|
|
||||||
const timelineActivityName2 = generateRecordName(TIMELINE_ACTIVITY_2_ID);
|
|
||||||
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'timelineActivity',
|
|
||||||
objectMetadataPluralName: 'timelineActivities',
|
|
||||||
gqlFields: TIMELINE_ACTIVITY_GQL_FIELDS,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: TIMELINE_ACTIVITY_1_ID,
|
|
||||||
name: timelineActivityName1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: TIMELINE_ACTIVITY_2_ID,
|
|
||||||
name: timelineActivityName2,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.createTimelineActivities).toHaveLength(2);
|
|
||||||
|
|
||||||
response.body.data.createTimelineActivities.forEach((timelineActivity) => {
|
|
||||||
expect(timelineActivity).toHaveProperty('name');
|
|
||||||
expect([timelineActivityName1, timelineActivityName2]).toContain(
|
|
||||||
timelineActivity.name,
|
|
||||||
);
|
|
||||||
expect(timelineActivity).toHaveProperty('id');
|
|
||||||
expect(timelineActivity).toHaveProperty('happensAt');
|
|
||||||
expect(timelineActivity).toHaveProperty('properties');
|
|
||||||
expect(timelineActivity).toHaveProperty('linkedRecordCachedName');
|
|
||||||
expect(timelineActivity).toHaveProperty('linkedRecordId');
|
|
||||||
expect(timelineActivity).toHaveProperty('linkedObjectMetadataId');
|
|
||||||
expect(timelineActivity).toHaveProperty('createdAt');
|
|
||||||
expect(timelineActivity).toHaveProperty('updatedAt');
|
|
||||||
expect(timelineActivity).toHaveProperty('deletedAt');
|
|
||||||
expect(timelineActivity).toHaveProperty('workspaceMemberId');
|
|
||||||
expect(timelineActivity).toHaveProperty('personId');
|
|
||||||
expect(timelineActivity).toHaveProperty('companyId');
|
|
||||||
expect(timelineActivity).toHaveProperty('opportunityId');
|
|
||||||
expect(timelineActivity).toHaveProperty('noteId');
|
|
||||||
expect(timelineActivity).toHaveProperty('taskId');
|
|
||||||
expect(timelineActivity).toHaveProperty('workflowId');
|
|
||||||
expect(timelineActivity).toHaveProperty('workflowVersionId');
|
|
||||||
expect(timelineActivity).toHaveProperty('workflowRunId');
|
|
||||||
expect(timelineActivity).toHaveProperty('rocketId');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1b. should create and return one timelineActivity', async () => {
|
|
||||||
const timelineActivityName = generateRecordName(TIMELINE_ACTIVITY_3_ID);
|
|
||||||
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'timelineActivity',
|
|
||||||
gqlFields: TIMELINE_ACTIVITY_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
id: TIMELINE_ACTIVITY_3_ID,
|
|
||||||
name: timelineActivityName,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const createdTimelineActivity = response.body.data.createTimelineActivity;
|
|
||||||
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('name');
|
|
||||||
expect(createdTimelineActivity.name).toEqual(timelineActivityName);
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('id');
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('happensAt');
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('properties');
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('linkedRecordCachedName');
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('linkedRecordId');
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('linkedObjectMetadataId');
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('createdAt');
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('updatedAt');
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('deletedAt');
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('workspaceMemberId');
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('personId');
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('companyId');
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('opportunityId');
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('noteId');
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('taskId');
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('workflowId');
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('workflowVersionId');
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('workflowRunId');
|
|
||||||
expect(createdTimelineActivity).toHaveProperty('rocketId');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2. should find many timelineActivities', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'timelineActivity',
|
|
||||||
objectMetadataPluralName: 'timelineActivities',
|
|
||||||
gqlFields: TIMELINE_ACTIVITY_GQL_FIELDS,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const data = response.body.data.timelineActivities;
|
|
||||||
|
|
||||||
expect(data).toBeDefined();
|
|
||||||
expect(Array.isArray(data.edges)).toBe(true);
|
|
||||||
|
|
||||||
if (data.edges.length > 0) {
|
|
||||||
const timelineActivities = data.edges[0].node;
|
|
||||||
|
|
||||||
expect(timelineActivities).toHaveProperty('happensAt');
|
|
||||||
expect(timelineActivities).toHaveProperty('name');
|
|
||||||
expect(timelineActivities).toHaveProperty('properties');
|
|
||||||
expect(timelineActivities).toHaveProperty('linkedRecordCachedName');
|
|
||||||
expect(timelineActivities).toHaveProperty('linkedRecordId');
|
|
||||||
expect(timelineActivities).toHaveProperty('linkedObjectMetadataId');
|
|
||||||
expect(timelineActivities).toHaveProperty('id');
|
|
||||||
expect(timelineActivities).toHaveProperty('createdAt');
|
|
||||||
expect(timelineActivities).toHaveProperty('updatedAt');
|
|
||||||
expect(timelineActivities).toHaveProperty('deletedAt');
|
|
||||||
expect(timelineActivities).toHaveProperty('workspaceMemberId');
|
|
||||||
expect(timelineActivities).toHaveProperty('personId');
|
|
||||||
expect(timelineActivities).toHaveProperty('companyId');
|
|
||||||
expect(timelineActivities).toHaveProperty('opportunityId');
|
|
||||||
expect(timelineActivities).toHaveProperty('noteId');
|
|
||||||
expect(timelineActivities).toHaveProperty('taskId');
|
|
||||||
expect(timelineActivities).toHaveProperty('workflowId');
|
|
||||||
expect(timelineActivities).toHaveProperty('workflowVersionId');
|
|
||||||
expect(timelineActivities).toHaveProperty('workflowRunId');
|
|
||||||
expect(timelineActivities).toHaveProperty('rocketId');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2b. should find one timelineActivity', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'timelineActivity',
|
|
||||||
gqlFields: TIMELINE_ACTIVITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: TIMELINE_ACTIVITY_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const timelineActivity = response.body.data.timelineActivity;
|
|
||||||
|
|
||||||
expect(timelineActivity).toHaveProperty('happensAt');
|
|
||||||
expect(timelineActivity).toHaveProperty('name');
|
|
||||||
expect(timelineActivity).toHaveProperty('properties');
|
|
||||||
expect(timelineActivity).toHaveProperty('linkedRecordCachedName');
|
|
||||||
expect(timelineActivity).toHaveProperty('linkedRecordId');
|
|
||||||
expect(timelineActivity).toHaveProperty('linkedObjectMetadataId');
|
|
||||||
expect(timelineActivity).toHaveProperty('id');
|
|
||||||
expect(timelineActivity).toHaveProperty('createdAt');
|
|
||||||
expect(timelineActivity).toHaveProperty('updatedAt');
|
|
||||||
expect(timelineActivity).toHaveProperty('deletedAt');
|
|
||||||
expect(timelineActivity).toHaveProperty('workspaceMemberId');
|
|
||||||
expect(timelineActivity).toHaveProperty('personId');
|
|
||||||
expect(timelineActivity).toHaveProperty('companyId');
|
|
||||||
expect(timelineActivity).toHaveProperty('opportunityId');
|
|
||||||
expect(timelineActivity).toHaveProperty('noteId');
|
|
||||||
expect(timelineActivity).toHaveProperty('taskId');
|
|
||||||
expect(timelineActivity).toHaveProperty('workflowId');
|
|
||||||
expect(timelineActivity).toHaveProperty('workflowVersionId');
|
|
||||||
expect(timelineActivity).toHaveProperty('workflowRunId');
|
|
||||||
expect(timelineActivity).toHaveProperty('rocketId');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3. should update many timelineActivities', async () => {
|
|
||||||
const graphqlOperation = updateManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'timelineActivity',
|
|
||||||
objectMetadataPluralName: 'timelineActivities',
|
|
||||||
gqlFields: TIMELINE_ACTIVITY_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
name: 'Updated Name',
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [TIMELINE_ACTIVITY_1_ID, TIMELINE_ACTIVITY_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedTimelineActivities =
|
|
||||||
response.body.data.updateTimelineActivities;
|
|
||||||
|
|
||||||
expect(updatedTimelineActivities).toHaveLength(2);
|
|
||||||
|
|
||||||
updatedTimelineActivities.forEach((timelineActivity) => {
|
|
||||||
expect(timelineActivity.name).toEqual('Updated Name');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3b. should update one timelineActivity', async () => {
|
|
||||||
const graphqlOperation = updateOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'timelineActivity',
|
|
||||||
gqlFields: TIMELINE_ACTIVITY_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
name: 'New Name',
|
|
||||||
},
|
|
||||||
recordId: TIMELINE_ACTIVITY_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedTimelineActivity = response.body.data.updateTimelineActivity;
|
|
||||||
|
|
||||||
expect(updatedTimelineActivity.name).toEqual('New Name');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4. should find many timelineActivities with updated name', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'timelineActivity',
|
|
||||||
objectMetadataPluralName: 'timelineActivities',
|
|
||||||
gqlFields: TIMELINE_ACTIVITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
name: {
|
|
||||||
eq: 'Updated Name',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.timelineActivities.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4b. should find one timelineActivity with updated name', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'timelineActivity',
|
|
||||||
gqlFields: TIMELINE_ACTIVITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
name: {
|
|
||||||
eq: 'New Name',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.timelineActivity.name).toEqual('New Name');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5. should delete many timelineActivities', async () => {
|
|
||||||
const graphqlOperation = deleteManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'timelineActivity',
|
|
||||||
objectMetadataPluralName: 'timelineActivities',
|
|
||||||
gqlFields: TIMELINE_ACTIVITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [TIMELINE_ACTIVITY_1_ID, TIMELINE_ACTIVITY_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const deletedTimelineActivities =
|
|
||||||
response.body.data.deleteTimelineActivities;
|
|
||||||
|
|
||||||
expect(deletedTimelineActivities).toHaveLength(2);
|
|
||||||
|
|
||||||
deletedTimelineActivities.forEach((timelineActivity) => {
|
|
||||||
expect(timelineActivity.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5b. should delete one timelineActivity', async () => {
|
|
||||||
const graphqlOperation = deleteOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'timelineActivity',
|
|
||||||
gqlFields: TIMELINE_ACTIVITY_GQL_FIELDS,
|
|
||||||
recordId: TIMELINE_ACTIVITY_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.deleteTimelineActivity.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6. should not find many timelineActivities anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'timelineActivity',
|
|
||||||
objectMetadataPluralName: 'timelineActivities',
|
|
||||||
gqlFields: TIMELINE_ACTIVITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [TIMELINE_ACTIVITY_1_ID, TIMELINE_ACTIVITY_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const findTimelineActivitiesResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
findTimelineActivitiesResponse.body.data.timelineActivities.edges,
|
|
||||||
).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6b. should not find one timelineActivity anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'timelineActivity',
|
|
||||||
gqlFields: TIMELINE_ACTIVITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: TIMELINE_ACTIVITY_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.timelineActivity).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7. should find many deleted timelineActivities with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'timelineActivity',
|
|
||||||
objectMetadataPluralName: 'timelineActivities',
|
|
||||||
gqlFields: TIMELINE_ACTIVITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [TIMELINE_ACTIVITY_1_ID, TIMELINE_ACTIVITY_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.timelineActivities.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7b. should find one deleted timelineActivity with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'timelineActivity',
|
|
||||||
gqlFields: TIMELINE_ACTIVITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: TIMELINE_ACTIVITY_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.timelineActivity.id).toEqual(
|
|
||||||
TIMELINE_ACTIVITY_3_ID,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8. should destroy many timelineActivities', async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'timelineActivity',
|
|
||||||
objectMetadataPluralName: 'timelineActivities',
|
|
||||||
gqlFields: TIMELINE_ACTIVITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [TIMELINE_ACTIVITY_1_ID, TIMELINE_ACTIVITY_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.destroyTimelineActivities).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8b. should destroy one timelineActivity', async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'timelineActivity',
|
|
||||||
gqlFields: TIMELINE_ACTIVITY_GQL_FIELDS,
|
|
||||||
recordId: TIMELINE_ACTIVITY_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const destroyTimelineActivityResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
destroyTimelineActivityResponse.body.data.destroyTimelineActivity,
|
|
||||||
).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9. should not find many timelineActivities anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'timelineActivity',
|
|
||||||
objectMetadataPluralName: 'timelineActivities',
|
|
||||||
gqlFields: TIMELINE_ACTIVITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [TIMELINE_ACTIVITY_1_ID, TIMELINE_ACTIVITY_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.timelineActivities.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9b. should not find one timelineActivity anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'timelineActivity',
|
|
||||||
gqlFields: TIMELINE_ACTIVITY_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: TIMELINE_ACTIVITY_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.timelineActivity).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,407 +0,0 @@
|
|||||||
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 VIEW_FIELD_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
|
||||||
const VIEW_FIELD_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
|
||||||
const VIEW_FIELD_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
|
||||||
const FIELD_METADATA_ID = '20202020-0c28-43d8-8ba5-3659924d3489';
|
|
||||||
|
|
||||||
const VIEW_FIELD_GQL_FIELDS = `
|
|
||||||
id
|
|
||||||
fieldMetadataId
|
|
||||||
isVisible
|
|
||||||
size
|
|
||||||
position
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
deletedAt
|
|
||||||
viewId
|
|
||||||
`;
|
|
||||||
|
|
||||||
describe('viewFields resolvers (integration)', () => {
|
|
||||||
it('1. should create and return viewFields', async () => {
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewField',
|
|
||||||
objectMetadataPluralName: 'viewFields',
|
|
||||||
gqlFields: VIEW_FIELD_GQL_FIELDS,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: VIEW_FIELD_1_ID,
|
|
||||||
fieldMetadataId: FIELD_METADATA_ID,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: VIEW_FIELD_2_ID,
|
|
||||||
fieldMetadataId: FIELD_METADATA_ID,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.createViewFields).toHaveLength(2);
|
|
||||||
|
|
||||||
response.body.data.createViewFields.forEach((viewField) => {
|
|
||||||
expect(viewField).toHaveProperty('fieldMetadataId');
|
|
||||||
expect(viewField.fieldMetadataId).toEqual(FIELD_METADATA_ID);
|
|
||||||
expect(viewField).toHaveProperty('id');
|
|
||||||
expect(viewField).toHaveProperty('isVisible');
|
|
||||||
expect(viewField).toHaveProperty('size');
|
|
||||||
expect(viewField).toHaveProperty('position');
|
|
||||||
expect(viewField).toHaveProperty('createdAt');
|
|
||||||
expect(viewField).toHaveProperty('updatedAt');
|
|
||||||
expect(viewField).toHaveProperty('deletedAt');
|
|
||||||
expect(viewField).toHaveProperty('viewId');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1b. should create and return one viewField', async () => {
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewField',
|
|
||||||
gqlFields: VIEW_FIELD_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
id: VIEW_FIELD_3_ID,
|
|
||||||
fieldMetadataId: FIELD_METADATA_ID,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const createdViewField = response.body.data.createViewField;
|
|
||||||
|
|
||||||
expect(createdViewField).toHaveProperty('fieldMetadataId');
|
|
||||||
expect(createdViewField.fieldMetadataId).toEqual(FIELD_METADATA_ID);
|
|
||||||
expect(createdViewField).toHaveProperty('id');
|
|
||||||
expect(createdViewField).toHaveProperty('isVisible');
|
|
||||||
expect(createdViewField).toHaveProperty('size');
|
|
||||||
expect(createdViewField).toHaveProperty('position');
|
|
||||||
expect(createdViewField).toHaveProperty('createdAt');
|
|
||||||
expect(createdViewField).toHaveProperty('updatedAt');
|
|
||||||
expect(createdViewField).toHaveProperty('deletedAt');
|
|
||||||
expect(createdViewField).toHaveProperty('viewId');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2. should find many viewFields', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewField',
|
|
||||||
objectMetadataPluralName: 'viewFields',
|
|
||||||
gqlFields: VIEW_FIELD_GQL_FIELDS,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const data = response.body.data.viewFields;
|
|
||||||
|
|
||||||
expect(data).toBeDefined();
|
|
||||||
expect(Array.isArray(data.edges)).toBe(true);
|
|
||||||
|
|
||||||
if (data.edges.length > 0) {
|
|
||||||
const viewFields = data.edges[0].node;
|
|
||||||
|
|
||||||
expect(viewFields).toHaveProperty('fieldMetadataId');
|
|
||||||
expect(viewFields).toHaveProperty('isVisible');
|
|
||||||
expect(viewFields).toHaveProperty('size');
|
|
||||||
expect(viewFields).toHaveProperty('position');
|
|
||||||
expect(viewFields).toHaveProperty('id');
|
|
||||||
expect(viewFields).toHaveProperty('createdAt');
|
|
||||||
expect(viewFields).toHaveProperty('updatedAt');
|
|
||||||
expect(viewFields).toHaveProperty('deletedAt');
|
|
||||||
expect(viewFields).toHaveProperty('viewId');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2b. should find one viewField', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewField',
|
|
||||||
gqlFields: VIEW_FIELD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: VIEW_FIELD_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const viewField = response.body.data.viewField;
|
|
||||||
|
|
||||||
expect(viewField).toHaveProperty('fieldMetadataId');
|
|
||||||
expect(viewField).toHaveProperty('isVisible');
|
|
||||||
expect(viewField).toHaveProperty('size');
|
|
||||||
expect(viewField).toHaveProperty('position');
|
|
||||||
expect(viewField).toHaveProperty('id');
|
|
||||||
expect(viewField).toHaveProperty('createdAt');
|
|
||||||
expect(viewField).toHaveProperty('updatedAt');
|
|
||||||
expect(viewField).toHaveProperty('deletedAt');
|
|
||||||
expect(viewField).toHaveProperty('viewId');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3. should update many viewFields', async () => {
|
|
||||||
const graphqlOperation = updateManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewField',
|
|
||||||
objectMetadataPluralName: 'viewFields',
|
|
||||||
gqlFields: VIEW_FIELD_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
isVisible: false,
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_FIELD_1_ID, VIEW_FIELD_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedViewFields = response.body.data.updateViewFields;
|
|
||||||
|
|
||||||
expect(updatedViewFields).toHaveLength(2);
|
|
||||||
|
|
||||||
updatedViewFields.forEach((viewField) => {
|
|
||||||
expect(viewField.isVisible).toEqual(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3b. should update one viewField', async () => {
|
|
||||||
const graphqlOperation = updateOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewField',
|
|
||||||
gqlFields: VIEW_FIELD_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
isVisible: true,
|
|
||||||
},
|
|
||||||
recordId: VIEW_FIELD_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedViewField = response.body.data.updateViewField;
|
|
||||||
|
|
||||||
expect(updatedViewField.isVisible).toEqual(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4. should find many viewFields with updated visibility', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewField',
|
|
||||||
objectMetadataPluralName: 'viewFields',
|
|
||||||
gqlFields: VIEW_FIELD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
isVisible: {
|
|
||||||
eq: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewFields.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4b. should find one viewField with updated visibility', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewField',
|
|
||||||
gqlFields: VIEW_FIELD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
isVisible: {
|
|
||||||
eq: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewField.isVisible).toEqual(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5. should delete many viewFields', async () => {
|
|
||||||
const graphqlOperation = deleteManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewField',
|
|
||||||
objectMetadataPluralName: 'viewFields',
|
|
||||||
gqlFields: VIEW_FIELD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_FIELD_1_ID, VIEW_FIELD_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const deletedViewFields = response.body.data.deleteViewFields;
|
|
||||||
|
|
||||||
expect(deletedViewFields).toHaveLength(2);
|
|
||||||
|
|
||||||
deletedViewFields.forEach((viewField) => {
|
|
||||||
expect(viewField.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5b. should delete one viewField', async () => {
|
|
||||||
const graphqlOperation = deleteOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewField',
|
|
||||||
gqlFields: VIEW_FIELD_GQL_FIELDS,
|
|
||||||
recordId: VIEW_FIELD_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.deleteViewField.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6. should not find many viewFields anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewField',
|
|
||||||
objectMetadataPluralName: 'viewFields',
|
|
||||||
gqlFields: VIEW_FIELD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_FIELD_1_ID, VIEW_FIELD_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const findViewFieldsResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(findViewFieldsResponse.body.data.viewFields.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6b. should not find one viewField anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewField',
|
|
||||||
gqlFields: VIEW_FIELD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: VIEW_FIELD_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewField).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7. should find many deleted viewFields with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewField',
|
|
||||||
objectMetadataPluralName: 'viewFields',
|
|
||||||
gqlFields: VIEW_FIELD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_FIELD_1_ID, VIEW_FIELD_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewFields.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7b. should find one deleted viewField with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewField',
|
|
||||||
gqlFields: VIEW_FIELD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: VIEW_FIELD_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewField.id).toEqual(VIEW_FIELD_3_ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8. should destroy many viewFields', async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewField',
|
|
||||||
objectMetadataPluralName: 'viewFields',
|
|
||||||
gqlFields: VIEW_FIELD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_FIELD_1_ID, VIEW_FIELD_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.destroyViewFields).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8b. should destroy one viewField', async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewField',
|
|
||||||
gqlFields: VIEW_FIELD_GQL_FIELDS,
|
|
||||||
recordId: VIEW_FIELD_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const destroyViewFieldResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(destroyViewFieldResponse.body.data.destroyViewField).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9. should not find many viewFields anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewField',
|
|
||||||
objectMetadataPluralName: 'viewFields',
|
|
||||||
gqlFields: VIEW_FIELD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_FIELD_1_ID, VIEW_FIELD_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewFields.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9b. should not find one viewField anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewField',
|
|
||||||
gqlFields: VIEW_FIELD_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: VIEW_FIELD_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewField).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,407 +0,0 @@
|
|||||||
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 VIEW_FILTER_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
|
||||||
const VIEW_FILTER_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
|
||||||
const VIEW_FILTER_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
|
||||||
const FIELD_METADATA_ID = '20202020-0c28-43d8-8ba5-3659924d3489';
|
|
||||||
|
|
||||||
const VIEW_FILTER_FIELDS = `
|
|
||||||
id
|
|
||||||
fieldMetadataId
|
|
||||||
operand
|
|
||||||
value
|
|
||||||
displayValue
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
deletedAt
|
|
||||||
viewId
|
|
||||||
`;
|
|
||||||
|
|
||||||
describe('viewFilters resolvers (integration)', () => {
|
|
||||||
it('1. should create and return viewFilters', async () => {
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewFilter',
|
|
||||||
objectMetadataPluralName: 'viewFilters',
|
|
||||||
gqlFields: VIEW_FILTER_FIELDS,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: VIEW_FILTER_1_ID,
|
|
||||||
fieldMetadataId: FIELD_METADATA_ID,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: VIEW_FILTER_2_ID,
|
|
||||||
fieldMetadataId: FIELD_METADATA_ID,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.createViewFilters).toHaveLength(2);
|
|
||||||
|
|
||||||
response.body.data.createViewFilters.forEach((viewFilter) => {
|
|
||||||
expect(viewFilter).toHaveProperty('fieldMetadataId');
|
|
||||||
expect(viewFilter.fieldMetadataId).toEqual(FIELD_METADATA_ID);
|
|
||||||
expect(viewFilter).toHaveProperty('id');
|
|
||||||
expect(viewFilter).toHaveProperty('operand');
|
|
||||||
expect(viewFilter).toHaveProperty('value');
|
|
||||||
expect(viewFilter).toHaveProperty('displayValue');
|
|
||||||
expect(viewFilter).toHaveProperty('createdAt');
|
|
||||||
expect(viewFilter).toHaveProperty('updatedAt');
|
|
||||||
expect(viewFilter).toHaveProperty('deletedAt');
|
|
||||||
expect(viewFilter).toHaveProperty('viewId');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1b. should create and return one viewFilter', async () => {
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewFilter',
|
|
||||||
gqlFields: VIEW_FILTER_FIELDS,
|
|
||||||
data: {
|
|
||||||
id: VIEW_FILTER_3_ID,
|
|
||||||
fieldMetadataId: FIELD_METADATA_ID,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const createdViewFilter = response.body.data.createViewFilter;
|
|
||||||
|
|
||||||
expect(createdViewFilter).toHaveProperty('fieldMetadataId');
|
|
||||||
expect(createdViewFilter.fieldMetadataId).toEqual(FIELD_METADATA_ID);
|
|
||||||
expect(createdViewFilter).toHaveProperty('id');
|
|
||||||
expect(createdViewFilter).toHaveProperty('operand');
|
|
||||||
expect(createdViewFilter).toHaveProperty('value');
|
|
||||||
expect(createdViewFilter).toHaveProperty('displayValue');
|
|
||||||
expect(createdViewFilter).toHaveProperty('createdAt');
|
|
||||||
expect(createdViewFilter).toHaveProperty('updatedAt');
|
|
||||||
expect(createdViewFilter).toHaveProperty('deletedAt');
|
|
||||||
expect(createdViewFilter).toHaveProperty('viewId');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2. should find many viewFilters', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewFilter',
|
|
||||||
objectMetadataPluralName: 'viewFilters',
|
|
||||||
gqlFields: VIEW_FILTER_FIELDS,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const data = response.body.data.viewFilters;
|
|
||||||
|
|
||||||
expect(data).toBeDefined();
|
|
||||||
expect(Array.isArray(data.edges)).toBe(true);
|
|
||||||
|
|
||||||
if (data.edges.length > 0) {
|
|
||||||
const viewFilters = data.edges[0].node;
|
|
||||||
|
|
||||||
expect(viewFilters).toHaveProperty('fieldMetadataId');
|
|
||||||
expect(viewFilters).toHaveProperty('operand');
|
|
||||||
expect(viewFilters).toHaveProperty('value');
|
|
||||||
expect(viewFilters).toHaveProperty('displayValue');
|
|
||||||
expect(viewFilters).toHaveProperty('id');
|
|
||||||
expect(viewFilters).toHaveProperty('createdAt');
|
|
||||||
expect(viewFilters).toHaveProperty('updatedAt');
|
|
||||||
expect(viewFilters).toHaveProperty('deletedAt');
|
|
||||||
expect(viewFilters).toHaveProperty('viewId');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2b. should find one viewFilter', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewFilter',
|
|
||||||
gqlFields: VIEW_FILTER_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: VIEW_FILTER_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const viewFilter = response.body.data.viewFilter;
|
|
||||||
|
|
||||||
expect(viewFilter).toHaveProperty('fieldMetadataId');
|
|
||||||
expect(viewFilter).toHaveProperty('operand');
|
|
||||||
expect(viewFilter).toHaveProperty('value');
|
|
||||||
expect(viewFilter).toHaveProperty('displayValue');
|
|
||||||
expect(viewFilter).toHaveProperty('id');
|
|
||||||
expect(viewFilter).toHaveProperty('createdAt');
|
|
||||||
expect(viewFilter).toHaveProperty('updatedAt');
|
|
||||||
expect(viewFilter).toHaveProperty('deletedAt');
|
|
||||||
expect(viewFilter).toHaveProperty('viewId');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3. should update many viewFilters', async () => {
|
|
||||||
const graphqlOperation = updateManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewFilter',
|
|
||||||
objectMetadataPluralName: 'viewFilters',
|
|
||||||
gqlFields: VIEW_FILTER_FIELDS,
|
|
||||||
data: {
|
|
||||||
operand: 'Updated Operand',
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_FILTER_1_ID, VIEW_FILTER_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedViewFilters = response.body.data.updateViewFilters;
|
|
||||||
|
|
||||||
expect(updatedViewFilters).toHaveLength(2);
|
|
||||||
|
|
||||||
updatedViewFilters.forEach((viewFilter) => {
|
|
||||||
expect(viewFilter.operand).toEqual('Updated Operand');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3b. should update one viewFilter', async () => {
|
|
||||||
const graphqlOperation = updateOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewFilter',
|
|
||||||
gqlFields: VIEW_FILTER_FIELDS,
|
|
||||||
data: {
|
|
||||||
operand: 'Updated Operand 3',
|
|
||||||
},
|
|
||||||
recordId: VIEW_FILTER_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedViewFilter = response.body.data.updateViewFilter;
|
|
||||||
|
|
||||||
expect(updatedViewFilter.operand).toEqual('Updated Operand 3');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4. should find many viewFilters with updated operand', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewFilter',
|
|
||||||
objectMetadataPluralName: 'viewFilters',
|
|
||||||
gqlFields: VIEW_FILTER_FIELDS,
|
|
||||||
filter: {
|
|
||||||
operand: {
|
|
||||||
eq: 'Updated Operand',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewFilters.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4b. should find one viewFilter with updated operand', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewFilter',
|
|
||||||
gqlFields: VIEW_FILTER_FIELDS,
|
|
||||||
filter: {
|
|
||||||
operand: {
|
|
||||||
eq: 'Updated Operand 3',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewFilter.operand).toEqual('Updated Operand 3');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5. should delete many viewFilters', async () => {
|
|
||||||
const graphqlOperation = deleteManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewFilter',
|
|
||||||
objectMetadataPluralName: 'viewFilters',
|
|
||||||
gqlFields: VIEW_FILTER_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_FILTER_1_ID, VIEW_FILTER_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const deletedViewFilters = response.body.data.deleteViewFilters;
|
|
||||||
|
|
||||||
expect(deletedViewFilters).toHaveLength(2);
|
|
||||||
|
|
||||||
deletedViewFilters.forEach((viewFilter) => {
|
|
||||||
expect(viewFilter.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5b. should delete one viewFilter', async () => {
|
|
||||||
const graphqlOperation = deleteOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewFilter',
|
|
||||||
gqlFields: VIEW_FILTER_FIELDS,
|
|
||||||
recordId: VIEW_FILTER_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.deleteViewFilter.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6. should not find many viewFilters anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewFilter',
|
|
||||||
objectMetadataPluralName: 'viewFilters',
|
|
||||||
gqlFields: VIEW_FILTER_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_FILTER_1_ID, VIEW_FILTER_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const findViewFiltersResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(findViewFiltersResponse.body.data.viewFilters.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6b. should not find one viewFilter anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewFilter',
|
|
||||||
gqlFields: VIEW_FILTER_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: VIEW_FILTER_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewFilter).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7. should find many deleted viewFilters with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewFilter',
|
|
||||||
objectMetadataPluralName: 'viewFilters',
|
|
||||||
gqlFields: VIEW_FILTER_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_FILTER_1_ID, VIEW_FILTER_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewFilters.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7b. should find one deleted viewFilter with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewFilter',
|
|
||||||
gqlFields: VIEW_FILTER_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: VIEW_FILTER_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewFilter.id).toEqual(VIEW_FILTER_3_ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8. should destroy many viewFilters', async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewFilter',
|
|
||||||
objectMetadataPluralName: 'viewFilters',
|
|
||||||
gqlFields: VIEW_FILTER_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_FILTER_1_ID, VIEW_FILTER_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.destroyViewFilters).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8b. should destroy one viewFilter', async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewFilter',
|
|
||||||
gqlFields: VIEW_FILTER_FIELDS,
|
|
||||||
recordId: VIEW_FILTER_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const destroyViewFilterResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(destroyViewFilterResponse.body.data.destroyViewFilter).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9. should not find many viewFilters anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewFilter',
|
|
||||||
objectMetadataPluralName: 'viewFilters',
|
|
||||||
gqlFields: VIEW_FILTER_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_FILTER_1_ID, VIEW_FILTER_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewFilters.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9b. should not find one viewFilter anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewFilter',
|
|
||||||
gqlFields: VIEW_FILTER_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: VIEW_FILTER_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewFilter).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,399 +0,0 @@
|
|||||||
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 VIEW_SORT_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
|
||||||
const VIEW_SORT_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
|
||||||
const VIEW_SORT_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
|
||||||
const FIELD_METADATA_ID = '20202020-0c28-43d8-8ba5-3659924d3489';
|
|
||||||
|
|
||||||
const VIEW_SORT_GQL_FIELDS = `
|
|
||||||
id
|
|
||||||
fieldMetadataId
|
|
||||||
direction
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
deletedAt
|
|
||||||
viewId
|
|
||||||
`;
|
|
||||||
|
|
||||||
describe('viewSorts resolvers (integration)', () => {
|
|
||||||
it('1. should create and return viewSorts', async () => {
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewSort',
|
|
||||||
objectMetadataPluralName: 'viewSorts',
|
|
||||||
gqlFields: VIEW_SORT_GQL_FIELDS,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: VIEW_SORT_1_ID,
|
|
||||||
fieldMetadataId: FIELD_METADATA_ID,
|
|
||||||
direction: 'ASC',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: VIEW_SORT_2_ID,
|
|
||||||
fieldMetadataId: FIELD_METADATA_ID,
|
|
||||||
direction: 'DESC',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.createViewSorts).toHaveLength(2);
|
|
||||||
|
|
||||||
response.body.data.createViewSorts.forEach((viewSort) => {
|
|
||||||
expect(viewSort).toHaveProperty('fieldMetadataId');
|
|
||||||
expect(viewSort.fieldMetadataId).toEqual(FIELD_METADATA_ID);
|
|
||||||
expect(viewSort).toHaveProperty('direction');
|
|
||||||
expect(viewSort).toHaveProperty('id');
|
|
||||||
expect(viewSort).toHaveProperty('createdAt');
|
|
||||||
expect(viewSort).toHaveProperty('updatedAt');
|
|
||||||
expect(viewSort).toHaveProperty('deletedAt');
|
|
||||||
expect(viewSort).toHaveProperty('viewId');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1b. should create and return one viewSort', async () => {
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewSort',
|
|
||||||
gqlFields: VIEW_SORT_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
id: VIEW_SORT_3_ID,
|
|
||||||
fieldMetadataId: FIELD_METADATA_ID,
|
|
||||||
direction: 'ASC',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const createdViewSort = response.body.data.createViewSort;
|
|
||||||
|
|
||||||
expect(createdViewSort).toHaveProperty('fieldMetadataId');
|
|
||||||
expect(createdViewSort.fieldMetadataId).toEqual(FIELD_METADATA_ID);
|
|
||||||
expect(createdViewSort).toHaveProperty('direction');
|
|
||||||
expect(createdViewSort).toHaveProperty('id');
|
|
||||||
expect(createdViewSort).toHaveProperty('createdAt');
|
|
||||||
expect(createdViewSort).toHaveProperty('updatedAt');
|
|
||||||
expect(createdViewSort).toHaveProperty('deletedAt');
|
|
||||||
expect(createdViewSort).toHaveProperty('viewId');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2. should find many viewSorts', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewSort',
|
|
||||||
objectMetadataPluralName: 'viewSorts',
|
|
||||||
gqlFields: VIEW_SORT_GQL_FIELDS,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const data = response.body.data.viewSorts;
|
|
||||||
|
|
||||||
expect(data).toBeDefined();
|
|
||||||
expect(Array.isArray(data.edges)).toBe(true);
|
|
||||||
|
|
||||||
if (data.edges.length > 0) {
|
|
||||||
const viewSorts = data.edges[0].node;
|
|
||||||
|
|
||||||
expect(viewSorts).toHaveProperty('fieldMetadataId');
|
|
||||||
expect(viewSorts).toHaveProperty('direction');
|
|
||||||
expect(viewSorts).toHaveProperty('id');
|
|
||||||
expect(viewSorts).toHaveProperty('createdAt');
|
|
||||||
expect(viewSorts).toHaveProperty('updatedAt');
|
|
||||||
expect(viewSorts).toHaveProperty('deletedAt');
|
|
||||||
expect(viewSorts).toHaveProperty('viewId');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2b. should find one viewSort', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewSort',
|
|
||||||
gqlFields: VIEW_SORT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: VIEW_SORT_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const viewSort = response.body.data.viewSort;
|
|
||||||
|
|
||||||
expect(viewSort).toHaveProperty('fieldMetadataId');
|
|
||||||
expect(viewSort).toHaveProperty('direction');
|
|
||||||
expect(viewSort).toHaveProperty('id');
|
|
||||||
expect(viewSort).toHaveProperty('createdAt');
|
|
||||||
expect(viewSort).toHaveProperty('updatedAt');
|
|
||||||
expect(viewSort).toHaveProperty('deletedAt');
|
|
||||||
expect(viewSort).toHaveProperty('viewId');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3. should update many viewSorts', async () => {
|
|
||||||
const graphqlOperation = updateManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewSort',
|
|
||||||
objectMetadataPluralName: 'viewSorts',
|
|
||||||
gqlFields: VIEW_SORT_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
direction: 'DESC',
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_SORT_1_ID, VIEW_SORT_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedViewSorts = response.body.data.updateViewSorts;
|
|
||||||
|
|
||||||
expect(updatedViewSorts).toHaveLength(2);
|
|
||||||
|
|
||||||
updatedViewSorts.forEach((viewSort) => {
|
|
||||||
expect(viewSort.direction).toEqual('DESC');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3b. should update one viewSort', async () => {
|
|
||||||
const graphqlOperation = updateOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewSort',
|
|
||||||
gqlFields: VIEW_SORT_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
direction: 'ASC',
|
|
||||||
},
|
|
||||||
recordId: VIEW_SORT_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedViewSort = response.body.data.updateViewSort;
|
|
||||||
|
|
||||||
expect(updatedViewSort.direction).toEqual('ASC');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4. should find many viewSorts with updated direction', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewSort',
|
|
||||||
objectMetadataPluralName: 'viewSorts',
|
|
||||||
gqlFields: VIEW_SORT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
direction: {
|
|
||||||
eq: 'DESC',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewSorts.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4b. should find one viewSort with updated direction', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewSort',
|
|
||||||
gqlFields: VIEW_SORT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
direction: {
|
|
||||||
eq: 'ASC',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewSort.direction).toEqual('ASC');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5. should delete many viewSorts', async () => {
|
|
||||||
const graphqlOperation = deleteManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewSort',
|
|
||||||
objectMetadataPluralName: 'viewSorts',
|
|
||||||
gqlFields: VIEW_SORT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_SORT_1_ID, VIEW_SORT_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const deletedViewSorts = response.body.data.deleteViewSorts;
|
|
||||||
|
|
||||||
expect(deletedViewSorts).toHaveLength(2);
|
|
||||||
|
|
||||||
deletedViewSorts.forEach((viewSort) => {
|
|
||||||
expect(viewSort.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5b. should delete one viewSort', async () => {
|
|
||||||
const graphqlOperation = deleteOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewSort',
|
|
||||||
gqlFields: VIEW_SORT_GQL_FIELDS,
|
|
||||||
recordId: VIEW_SORT_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.deleteViewSort.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6. should not find many viewSorts anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewSort',
|
|
||||||
objectMetadataPluralName: 'viewSorts',
|
|
||||||
gqlFields: VIEW_SORT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_SORT_1_ID, VIEW_SORT_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const findViewSortsResponse = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(findViewSortsResponse.body.data.viewSorts.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6b. should not find one viewSort anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewSort',
|
|
||||||
gqlFields: VIEW_SORT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: VIEW_SORT_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewSort).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7. should find many deleted viewSorts with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewSort',
|
|
||||||
objectMetadataPluralName: 'viewSorts',
|
|
||||||
gqlFields: VIEW_SORT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_SORT_1_ID, VIEW_SORT_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewSorts.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7b. should find one deleted viewSort with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewSort',
|
|
||||||
gqlFields: VIEW_SORT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: VIEW_SORT_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewSort.id).toEqual(VIEW_SORT_3_ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8. should destroy many viewSorts', async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewSort',
|
|
||||||
objectMetadataPluralName: 'viewSorts',
|
|
||||||
gqlFields: VIEW_SORT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_SORT_1_ID, VIEW_SORT_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.destroyViewSorts).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8b. should destroy one viewSort', async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewSort',
|
|
||||||
gqlFields: VIEW_SORT_GQL_FIELDS,
|
|
||||||
recordId: VIEW_SORT_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const destroyViewSortResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(destroyViewSortResponse.body.data.destroyViewSort).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9. should not find many viewSorts anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewSort',
|
|
||||||
objectMetadataPluralName: 'viewSorts',
|
|
||||||
gqlFields: VIEW_SORT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_SORT_1_ID, VIEW_SORT_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewSorts.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9b. should not find one viewSort anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'viewSort',
|
|
||||||
gqlFields: VIEW_SORT_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: VIEW_SORT_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.viewSort).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,429 +0,0 @@
|
|||||||
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 VIEW_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
|
||||||
const VIEW_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
|
||||||
const VIEW_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
|
||||||
const OBJECT_METADATA_ID = '20202020-b374-4779-a561-80086cb2e17f';
|
|
||||||
|
|
||||||
const VIEW_GQL_FIELDS = `
|
|
||||||
id
|
|
||||||
name
|
|
||||||
objectMetadataId
|
|
||||||
type
|
|
||||||
key
|
|
||||||
icon
|
|
||||||
kanbanFieldMetadataId
|
|
||||||
position
|
|
||||||
isCompact
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
deletedAt
|
|
||||||
`;
|
|
||||||
|
|
||||||
describe('views resolvers (integration)', () => {
|
|
||||||
it('1. should create and return views', async () => {
|
|
||||||
const viewName1 = generateRecordName(VIEW_1_ID);
|
|
||||||
const viewName2 = generateRecordName(VIEW_2_ID);
|
|
||||||
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'view',
|
|
||||||
objectMetadataPluralName: 'views',
|
|
||||||
gqlFields: VIEW_GQL_FIELDS,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: VIEW_1_ID,
|
|
||||||
name: viewName1,
|
|
||||||
objectMetadataId: OBJECT_METADATA_ID,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: VIEW_2_ID,
|
|
||||||
name: viewName2,
|
|
||||||
objectMetadataId: OBJECT_METADATA_ID,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.createViews).toHaveLength(2);
|
|
||||||
|
|
||||||
response.body.data.createViews.forEach((view) => {
|
|
||||||
expect(view).toHaveProperty('name');
|
|
||||||
expect([viewName1, viewName2]).toContain(view.name);
|
|
||||||
expect(view).toHaveProperty('id');
|
|
||||||
expect(view).toHaveProperty('objectMetadataId');
|
|
||||||
expect(view).toHaveProperty('type');
|
|
||||||
expect(view).toHaveProperty('key');
|
|
||||||
expect(view).toHaveProperty('icon');
|
|
||||||
expect(view).toHaveProperty('kanbanFieldMetadataId');
|
|
||||||
expect(view).toHaveProperty('position');
|
|
||||||
expect(view).toHaveProperty('isCompact');
|
|
||||||
expect(view).toHaveProperty('createdAt');
|
|
||||||
expect(view).toHaveProperty('updatedAt');
|
|
||||||
expect(view).toHaveProperty('deletedAt');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1b. should create and return one view', async () => {
|
|
||||||
const viewName = generateRecordName(VIEW_3_ID);
|
|
||||||
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'view',
|
|
||||||
gqlFields: VIEW_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
id: VIEW_3_ID,
|
|
||||||
name: viewName,
|
|
||||||
objectMetadataId: OBJECT_METADATA_ID,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const createdView = response.body.data.createView;
|
|
||||||
|
|
||||||
expect(createdView).toHaveProperty('name');
|
|
||||||
expect(createdView.name).toEqual(viewName);
|
|
||||||
expect(createdView).toHaveProperty('id');
|
|
||||||
expect(createdView).toHaveProperty('objectMetadataId');
|
|
||||||
expect(createdView).toHaveProperty('type');
|
|
||||||
expect(createdView).toHaveProperty('key');
|
|
||||||
expect(createdView).toHaveProperty('icon');
|
|
||||||
expect(createdView).toHaveProperty('kanbanFieldMetadataId');
|
|
||||||
expect(createdView).toHaveProperty('position');
|
|
||||||
expect(createdView).toHaveProperty('isCompact');
|
|
||||||
expect(createdView).toHaveProperty('createdAt');
|
|
||||||
expect(createdView).toHaveProperty('updatedAt');
|
|
||||||
expect(createdView).toHaveProperty('deletedAt');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2. should find many views', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'view',
|
|
||||||
objectMetadataPluralName: 'views',
|
|
||||||
gqlFields: VIEW_GQL_FIELDS,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const data = response.body.data.views;
|
|
||||||
|
|
||||||
expect(data).toBeDefined();
|
|
||||||
expect(Array.isArray(data.edges)).toBe(true);
|
|
||||||
|
|
||||||
if (data.edges.length > 0) {
|
|
||||||
const views = data.edges[0].node;
|
|
||||||
|
|
||||||
expect(views).toHaveProperty('name');
|
|
||||||
expect(views).toHaveProperty('objectMetadataId');
|
|
||||||
expect(views).toHaveProperty('type');
|
|
||||||
expect(views).toHaveProperty('key');
|
|
||||||
expect(views).toHaveProperty('icon');
|
|
||||||
expect(views).toHaveProperty('kanbanFieldMetadataId');
|
|
||||||
expect(views).toHaveProperty('position');
|
|
||||||
expect(views).toHaveProperty('isCompact');
|
|
||||||
expect(views).toHaveProperty('id');
|
|
||||||
expect(views).toHaveProperty('createdAt');
|
|
||||||
expect(views).toHaveProperty('updatedAt');
|
|
||||||
expect(views).toHaveProperty('deletedAt');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2b. should find one view', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'view',
|
|
||||||
gqlFields: VIEW_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: VIEW_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const view = response.body.data.view;
|
|
||||||
|
|
||||||
expect(view).toHaveProperty('name');
|
|
||||||
expect(view).toHaveProperty('objectMetadataId');
|
|
||||||
expect(view).toHaveProperty('type');
|
|
||||||
expect(view).toHaveProperty('key');
|
|
||||||
expect(view).toHaveProperty('icon');
|
|
||||||
expect(view).toHaveProperty('kanbanFieldMetadataId');
|
|
||||||
expect(view).toHaveProperty('position');
|
|
||||||
expect(view).toHaveProperty('isCompact');
|
|
||||||
expect(view).toHaveProperty('id');
|
|
||||||
expect(view).toHaveProperty('createdAt');
|
|
||||||
expect(view).toHaveProperty('updatedAt');
|
|
||||||
expect(view).toHaveProperty('deletedAt');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3. should update many views', async () => {
|
|
||||||
const graphqlOperation = updateManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'view',
|
|
||||||
objectMetadataPluralName: 'views',
|
|
||||||
gqlFields: VIEW_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
isCompact: true,
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_1_ID, VIEW_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedViews = response.body.data.updateViews;
|
|
||||||
|
|
||||||
expect(updatedViews).toHaveLength(2);
|
|
||||||
|
|
||||||
updatedViews.forEach((view) => {
|
|
||||||
expect(view.isCompact).toEqual(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3b. should update one view', async () => {
|
|
||||||
const graphqlOperation = updateOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'view',
|
|
||||||
gqlFields: VIEW_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
isCompact: false,
|
|
||||||
},
|
|
||||||
recordId: VIEW_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedView = response.body.data.updateView;
|
|
||||||
|
|
||||||
expect(updatedView.isCompact).toEqual(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4. should find many views with updated isCompact', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'view',
|
|
||||||
objectMetadataPluralName: 'views',
|
|
||||||
gqlFields: VIEW_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
isCompact: {
|
|
||||||
eq: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.views.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4b. should find one view with updated isCompact', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'view',
|
|
||||||
gqlFields: VIEW_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
isCompact: {
|
|
||||||
eq: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.view.isCompact).toEqual(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5. should delete many views', async () => {
|
|
||||||
const graphqlOperation = deleteManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'view',
|
|
||||||
objectMetadataPluralName: 'views',
|
|
||||||
gqlFields: VIEW_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_1_ID, VIEW_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const deletedViews = response.body.data.deleteViews;
|
|
||||||
|
|
||||||
expect(deletedViews).toHaveLength(2);
|
|
||||||
|
|
||||||
deletedViews.forEach((view) => {
|
|
||||||
expect(view.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5b. should delete one view', async () => {
|
|
||||||
const graphqlOperation = deleteOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'view',
|
|
||||||
gqlFields: VIEW_GQL_FIELDS,
|
|
||||||
recordId: VIEW_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.deleteView.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6. should not find many views anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'view',
|
|
||||||
objectMetadataPluralName: 'views',
|
|
||||||
gqlFields: VIEW_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_1_ID, VIEW_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const findViewsResponse = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(findViewsResponse.body.data.views.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6b. should not find one view anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'view',
|
|
||||||
gqlFields: VIEW_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: VIEW_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.view).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7. should find many deleted views with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'view',
|
|
||||||
objectMetadataPluralName: 'views',
|
|
||||||
gqlFields: VIEW_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_1_ID, VIEW_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.views.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7b. should find one deleted view with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'view',
|
|
||||||
gqlFields: VIEW_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: VIEW_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.view.id).toEqual(VIEW_3_ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8. should destroy many views', async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'view',
|
|
||||||
objectMetadataPluralName: 'views',
|
|
||||||
gqlFields: VIEW_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_1_ID, VIEW_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.destroyViews).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8b. should destroy one view', async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'view',
|
|
||||||
gqlFields: VIEW_GQL_FIELDS,
|
|
||||||
recordId: VIEW_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const destroyViewResponse = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(destroyViewResponse.body.data.destroyView).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9. should not find many views anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'view',
|
|
||||||
objectMetadataPluralName: 'views',
|
|
||||||
gqlFields: VIEW_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [VIEW_1_ID, VIEW_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.views.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9b. should not find one view anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'view',
|
|
||||||
gqlFields: VIEW_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: VIEW_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.view).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,403 +0,0 @@
|
|||||||
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 WEBHOOK_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
|
||||||
const WEBHOOK_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
|
||||||
const WEBHOOK_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
|
||||||
|
|
||||||
const WEBHOOK_GQL_FIELDS = `
|
|
||||||
id
|
|
||||||
targetUrl
|
|
||||||
operations
|
|
||||||
description
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
deletedAt
|
|
||||||
`;
|
|
||||||
|
|
||||||
describe('webhooks resolvers (integration)', () => {
|
|
||||||
it('1. should create and return webhooks', async () => {
|
|
||||||
const webhookDescription1 = generateRecordName(WEBHOOK_1_ID);
|
|
||||||
const webhookDescription2 = generateRecordName(WEBHOOK_2_ID);
|
|
||||||
|
|
||||||
const graphqlOperation = createManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'webhook',
|
|
||||||
objectMetadataPluralName: 'webhooks',
|
|
||||||
gqlFields: WEBHOOK_GQL_FIELDS,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: WEBHOOK_1_ID,
|
|
||||||
description: webhookDescription1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: WEBHOOK_2_ID,
|
|
||||||
description: webhookDescription2,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.createWebhooks).toHaveLength(2);
|
|
||||||
|
|
||||||
response.body.data.createWebhooks.forEach((webhook) => {
|
|
||||||
expect(webhook).toHaveProperty('description');
|
|
||||||
expect([webhookDescription1, webhookDescription2]).toContain(
|
|
||||||
webhook.description,
|
|
||||||
);
|
|
||||||
expect(webhook).toHaveProperty('operations');
|
|
||||||
expect(webhook).toHaveProperty('id');
|
|
||||||
expect(webhook).toHaveProperty('targetUrl');
|
|
||||||
expect(webhook).toHaveProperty('createdAt');
|
|
||||||
expect(webhook).toHaveProperty('updatedAt');
|
|
||||||
expect(webhook).toHaveProperty('deletedAt');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('1b. should create and return one webhook', async () => {
|
|
||||||
const webhookDescription = generateRecordName(WEBHOOK_3_ID);
|
|
||||||
|
|
||||||
const graphqlOperation = createOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'webhook',
|
|
||||||
gqlFields: WEBHOOK_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
id: WEBHOOK_3_ID,
|
|
||||||
description: webhookDescription,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const createdWebhook = response.body.data.createWebhook;
|
|
||||||
|
|
||||||
expect(createdWebhook).toHaveProperty('description');
|
|
||||||
expect(createdWebhook.description).toEqual(webhookDescription);
|
|
||||||
expect(createdWebhook).toHaveProperty('operations');
|
|
||||||
expect(createdWebhook).toHaveProperty('id');
|
|
||||||
expect(createdWebhook).toHaveProperty('targetUrl');
|
|
||||||
expect(createdWebhook).toHaveProperty('createdAt');
|
|
||||||
expect(createdWebhook).toHaveProperty('updatedAt');
|
|
||||||
expect(createdWebhook).toHaveProperty('deletedAt');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2. should find many webhooks', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'webhook',
|
|
||||||
objectMetadataPluralName: 'webhooks',
|
|
||||||
gqlFields: WEBHOOK_GQL_FIELDS,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const data = response.body.data.webhooks;
|
|
||||||
|
|
||||||
expect(data).toBeDefined();
|
|
||||||
expect(Array.isArray(data.edges)).toBe(true);
|
|
||||||
|
|
||||||
if (data.edges.length > 0) {
|
|
||||||
const webhooks = data.edges[0].node;
|
|
||||||
|
|
||||||
expect(webhooks).toHaveProperty('targetUrl');
|
|
||||||
expect(webhooks).toHaveProperty('operations');
|
|
||||||
expect(webhooks).toHaveProperty('id');
|
|
||||||
expect(webhooks).toHaveProperty('description');
|
|
||||||
expect(webhooks).toHaveProperty('createdAt');
|
|
||||||
expect(webhooks).toHaveProperty('updatedAt');
|
|
||||||
expect(webhooks).toHaveProperty('deletedAt');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('2b. should find one webhook', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'webhook',
|
|
||||||
gqlFields: WEBHOOK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: WEBHOOK_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const webhook = response.body.data.webhook;
|
|
||||||
|
|
||||||
expect(webhook).toHaveProperty('targetUrl');
|
|
||||||
expect(webhook).toHaveProperty('operations');
|
|
||||||
expect(webhook).toHaveProperty('id');
|
|
||||||
expect(webhook).toHaveProperty('description');
|
|
||||||
expect(webhook).toHaveProperty('createdAt');
|
|
||||||
expect(webhook).toHaveProperty('updatedAt');
|
|
||||||
expect(webhook).toHaveProperty('deletedAt');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3. should update many webhooks', async () => {
|
|
||||||
const graphqlOperation = updateManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'webhook',
|
|
||||||
objectMetadataPluralName: 'webhooks',
|
|
||||||
gqlFields: WEBHOOK_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
description: 'Updated Description',
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [WEBHOOK_1_ID, WEBHOOK_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedWebhooks = response.body.data.updateWebhooks;
|
|
||||||
|
|
||||||
expect(updatedWebhooks).toHaveLength(2);
|
|
||||||
|
|
||||||
updatedWebhooks.forEach((webhook) => {
|
|
||||||
expect(webhook.description).toEqual('Updated Description');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('3b. should update one webhook', async () => {
|
|
||||||
const graphqlOperation = updateOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'webhook',
|
|
||||||
gqlFields: WEBHOOK_GQL_FIELDS,
|
|
||||||
data: {
|
|
||||||
description: 'New Description',
|
|
||||||
},
|
|
||||||
recordId: WEBHOOK_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const updatedWebhook = response.body.data.updateWebhook;
|
|
||||||
|
|
||||||
expect(updatedWebhook.description).toEqual('New Description');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4. should find many webhooks with updated description', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'webhook',
|
|
||||||
objectMetadataPluralName: 'webhooks',
|
|
||||||
gqlFields: WEBHOOK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
description: {
|
|
||||||
eq: 'Updated Description',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.webhooks.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('4b. should find one webhook with updated description', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'webhook',
|
|
||||||
gqlFields: WEBHOOK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
description: {
|
|
||||||
eq: 'New Description',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.webhook.description).toEqual('New Description');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5. should delete many webhooks', async () => {
|
|
||||||
const graphqlOperation = deleteManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'webhook',
|
|
||||||
objectMetadataPluralName: 'webhooks',
|
|
||||||
gqlFields: WEBHOOK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [WEBHOOK_1_ID, WEBHOOK_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
const deletedWebhooks = response.body.data.deleteWebhooks;
|
|
||||||
|
|
||||||
expect(deletedWebhooks).toHaveLength(2);
|
|
||||||
|
|
||||||
deletedWebhooks.forEach((webhook) => {
|
|
||||||
expect(webhook.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('5b. should delete one webhook', async () => {
|
|
||||||
const graphqlOperation = deleteOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'webhook',
|
|
||||||
gqlFields: WEBHOOK_GQL_FIELDS,
|
|
||||||
recordId: WEBHOOK_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.deleteWebhook.deletedAt).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6. should not find many webhooks anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'webhook',
|
|
||||||
objectMetadataPluralName: 'webhooks',
|
|
||||||
gqlFields: WEBHOOK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [WEBHOOK_1_ID, WEBHOOK_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const findWebhooksResponse = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(findWebhooksResponse.body.data.webhooks.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('6b. should not find one webhook anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'webhook',
|
|
||||||
gqlFields: WEBHOOK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: WEBHOOK_3_ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.webhook).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7. should find many deleted webhooks with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'webhook',
|
|
||||||
objectMetadataPluralName: 'webhooks',
|
|
||||||
gqlFields: WEBHOOK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [WEBHOOK_1_ID, WEBHOOK_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.webhooks.edges).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('7b. should find one deleted webhook with deletedAt filter', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'webhook',
|
|
||||||
gqlFields: WEBHOOK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: WEBHOOK_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.webhook.id).toEqual(WEBHOOK_3_ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8. should destroy many webhooks', async () => {
|
|
||||||
const graphqlOperation = destroyManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'webhook',
|
|
||||||
objectMetadataPluralName: 'webhooks',
|
|
||||||
gqlFields: WEBHOOK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [WEBHOOK_1_ID, WEBHOOK_2_ID],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.destroyWebhooks).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('8b. should destroy one webhook', async () => {
|
|
||||||
const graphqlOperation = destroyOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'webhook',
|
|
||||||
gqlFields: WEBHOOK_GQL_FIELDS,
|
|
||||||
recordId: WEBHOOK_3_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const destroyWebhookResponse =
|
|
||||||
await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(destroyWebhookResponse.body.data.destroyWebhook).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9. should not find many webhooks anymore', async () => {
|
|
||||||
const graphqlOperation = findManyOperationFactory({
|
|
||||||
objectMetadataSingularName: 'webhook',
|
|
||||||
objectMetadataPluralName: 'webhooks',
|
|
||||||
gqlFields: WEBHOOK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
in: [WEBHOOK_1_ID, WEBHOOK_2_ID],
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.webhooks.edges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('9b. should not find one webhook anymore', async () => {
|
|
||||||
const graphqlOperation = findOneOperationFactory({
|
|
||||||
objectMetadataSingularName: 'webhook',
|
|
||||||
gqlFields: WEBHOOK_GQL_FIELDS,
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
eq: WEBHOOK_3_ID,
|
|
||||||
},
|
|
||||||
not: {
|
|
||||||
deletedAt: {
|
|
||||||
is: 'NULL',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
|
||||||
|
|
||||||
expect(response.body.data.webhook).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -30,8 +30,10 @@ npx nx run twenty-server:lint # pass --fix to fix lint errors
|
|||||||
### Test
|
### Test
|
||||||
|
|
||||||
```
|
```
|
||||||
npx nx run twenty-server:test:unit
|
npx nx run twenty-server:test:unit # run unit tests
|
||||||
|
npx nx run twenty-server:test:integration # run integration tests
|
||||||
```
|
```
|
||||||
|
Note : you can run `npx nx run twenty-server:test:integration:with-db-reset` in case you need to reset the database before running the integration tests.
|
||||||
|
|
||||||
### Resetting the database
|
### Resetting the database
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user