mirror of
https://github.com/lingble/twenty.git
synced 2025-10-29 20:02:29 +00:00
Remove broken e2e tests
This commit is contained in:
@@ -1,406 +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';
|
||||
|
||||
const BLOCKLIST_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
||||
const BLOCKLIST_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
||||
const BLOCKLIST_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
||||
const BLOCKLIST_HANDLE_1 = 'email@email.com';
|
||||
const BLOCKLIST_HANDLE_2 = '@domain.com';
|
||||
const BLOCKLIST_HANDLE_3 = '@domain.org';
|
||||
const UPDATED_BLOCKLIST_HANDLE_1 = 'updated@email.com';
|
||||
const UPDATED_BLOCKLIST_HANDLE_2 = '@updated-domain.com';
|
||||
|
||||
const BLOCKLIST_GQL_FIELDS = `
|
||||
id
|
||||
handle
|
||||
createdAt
|
||||
updatedAt
|
||||
deletedAt
|
||||
workspaceMemberId
|
||||
`;
|
||||
|
||||
describe('blocklists resolvers (integration)', () => {
|
||||
it('1. should create and return blocklists', async () => {
|
||||
const graphqlOperation = createManyOperationFactory({
|
||||
objectMetadataSingularName: 'blocklist',
|
||||
objectMetadataPluralName: 'blocklists',
|
||||
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||
data: [
|
||||
{
|
||||
id: BLOCKLIST_1_ID,
|
||||
handle: BLOCKLIST_HANDLE_1,
|
||||
workspaceMemberId: TIM_ACCOUNT_ID,
|
||||
},
|
||||
{
|
||||
id: BLOCKLIST_2_ID,
|
||||
handle: BLOCKLIST_HANDLE_2,
|
||||
workspaceMemberId: TIM_ACCOUNT_ID,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.createBlocklists).toHaveLength(2);
|
||||
|
||||
response.body.data.createBlocklists.forEach((blocklist) => {
|
||||
expect(blocklist).toHaveProperty('handle');
|
||||
expect([BLOCKLIST_HANDLE_1, BLOCKLIST_HANDLE_2]).toContain(
|
||||
blocklist.handle,
|
||||
);
|
||||
expect(blocklist).toHaveProperty('id');
|
||||
expect(blocklist).toHaveProperty('createdAt');
|
||||
expect(blocklist).toHaveProperty('updatedAt');
|
||||
expect(blocklist).toHaveProperty('deletedAt');
|
||||
expect(blocklist).toHaveProperty('workspaceMemberId');
|
||||
});
|
||||
});
|
||||
|
||||
it('1b. should create and return one blocklist', async () => {
|
||||
const graphqlOperation = createOneOperationFactory({
|
||||
objectMetadataSingularName: 'blocklist',
|
||||
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||
data: {
|
||||
id: BLOCKLIST_3_ID,
|
||||
handle: BLOCKLIST_HANDLE_3,
|
||||
workspaceMemberId: TIM_ACCOUNT_ID,
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const createdBlocklist = response.body.data.createBlocklist;
|
||||
|
||||
expect(createdBlocklist).toHaveProperty('handle');
|
||||
expect(createdBlocklist.handle).toEqual(BLOCKLIST_HANDLE_3);
|
||||
expect(createdBlocklist).toHaveProperty('id');
|
||||
expect(createdBlocklist).toHaveProperty('createdAt');
|
||||
expect(createdBlocklist).toHaveProperty('updatedAt');
|
||||
expect(createdBlocklist).toHaveProperty('deletedAt');
|
||||
expect(createdBlocklist).toHaveProperty('workspaceMemberId');
|
||||
});
|
||||
|
||||
it('2. should find many blocklists', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'blocklist',
|
||||
objectMetadataPluralName: 'blocklists',
|
||||
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const data = response.body.data.blocklists;
|
||||
|
||||
expect(data).toBeDefined();
|
||||
expect(Array.isArray(data.edges)).toBe(true);
|
||||
|
||||
if (data.edges.length > 0) {
|
||||
const blocklists = data.edges[0].node;
|
||||
|
||||
expect(blocklists).toHaveProperty('handle');
|
||||
expect(blocklists).toHaveProperty('id');
|
||||
expect(blocklists).toHaveProperty('createdAt');
|
||||
expect(blocklists).toHaveProperty('updatedAt');
|
||||
expect(blocklists).toHaveProperty('deletedAt');
|
||||
expect(blocklists).toHaveProperty('workspaceMemberId');
|
||||
}
|
||||
});
|
||||
|
||||
it('2b. should find one blocklist', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'blocklist',
|
||||
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
eq: BLOCKLIST_3_ID,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const blocklist = response.body.data.blocklist;
|
||||
|
||||
expect(blocklist).toHaveProperty('handle');
|
||||
expect(blocklist).toHaveProperty('id');
|
||||
expect(blocklist).toHaveProperty('createdAt');
|
||||
expect(blocklist).toHaveProperty('updatedAt');
|
||||
expect(blocklist).toHaveProperty('deletedAt');
|
||||
expect(blocklist).toHaveProperty('workspaceMemberId');
|
||||
});
|
||||
|
||||
it('3. should not update many blocklists', async () => {
|
||||
const graphqlOperation = updateManyOperationFactory({
|
||||
objectMetadataSingularName: 'blocklist',
|
||||
objectMetadataPluralName: 'blocklists',
|
||||
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||
data: {
|
||||
handle: UPDATED_BLOCKLIST_HANDLE_1,
|
||||
workspaceMemberId: TIM_ACCOUNT_ID,
|
||||
},
|
||||
filter: {
|
||||
id: {
|
||||
in: [BLOCKLIST_1_ID, BLOCKLIST_2_ID],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.updateBlocklists).toBeNull();
|
||||
expect(response.body.errors).toStrictEqual([
|
||||
{
|
||||
extensions: { code: 'INTERNAL_SERVER_ERROR' },
|
||||
message: 'Method not allowed.',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('3b. should update one blocklist', async () => {
|
||||
const graphqlOperation = updateOneOperationFactory({
|
||||
objectMetadataSingularName: 'blocklist',
|
||||
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||
data: {
|
||||
handle: UPDATED_BLOCKLIST_HANDLE_2,
|
||||
workspaceMemberId: TIM_ACCOUNT_ID,
|
||||
},
|
||||
recordId: BLOCKLIST_3_ID,
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const updatedBlocklist = response.body.data.updateBlocklist;
|
||||
|
||||
expect(updatedBlocklist.handle).toEqual(UPDATED_BLOCKLIST_HANDLE_2);
|
||||
});
|
||||
|
||||
it('4. should not find many blocklists with updated name', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'blocklist',
|
||||
objectMetadataPluralName: 'blocklists',
|
||||
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||
filter: {
|
||||
handle: {
|
||||
eq: UPDATED_BLOCKLIST_HANDLE_1,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.blocklists.edges).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('4b. should find one blocklist with updated name', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'blocklist',
|
||||
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||
filter: {
|
||||
handle: {
|
||||
eq: UPDATED_BLOCKLIST_HANDLE_2,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.blocklist.handle).toEqual(
|
||||
UPDATED_BLOCKLIST_HANDLE_2,
|
||||
);
|
||||
});
|
||||
|
||||
it('5. should delete many blocklists', async () => {
|
||||
const graphqlOperation = deleteManyOperationFactory({
|
||||
objectMetadataSingularName: 'blocklist',
|
||||
objectMetadataPluralName: 'blocklists',
|
||||
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [BLOCKLIST_1_ID, BLOCKLIST_2_ID],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const deletedBlocklists = response.body.data.deleteBlocklists;
|
||||
|
||||
expect(deletedBlocklists).toHaveLength(2);
|
||||
|
||||
deletedBlocklists.forEach((blocklist) => {
|
||||
expect(blocklist.deletedAt).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
it('5b. should delete one blocklist', async () => {
|
||||
const graphqlOperation = deleteOneOperationFactory({
|
||||
objectMetadataSingularName: 'blocklist',
|
||||
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||
recordId: BLOCKLIST_3_ID,
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.deleteBlocklist.deletedAt).toBeTruthy();
|
||||
});
|
||||
|
||||
it('6. should not find many blocklists anymore', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'blocklist',
|
||||
objectMetadataPluralName: 'blocklists',
|
||||
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [BLOCKLIST_1_ID, BLOCKLIST_2_ID],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const findBlocklistsResponse =
|
||||
await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(findBlocklistsResponse.body.data.blocklists.edges).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('6b. should not find one blocklist anymore', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'blocklist',
|
||||
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
eq: BLOCKLIST_3_ID,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.blocklist).toBeNull();
|
||||
});
|
||||
|
||||
it('7. should find many deleted blocklists with deletedAt filter', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'blocklist',
|
||||
objectMetadataPluralName: 'blocklists',
|
||||
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [BLOCKLIST_1_ID, BLOCKLIST_2_ID],
|
||||
},
|
||||
not: {
|
||||
deletedAt: {
|
||||
is: 'NULL',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.blocklists.edges).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('7b. should find one deleted blocklist with deletedAt filter', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'blocklist',
|
||||
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
eq: BLOCKLIST_3_ID,
|
||||
},
|
||||
not: {
|
||||
deletedAt: {
|
||||
is: 'NULL',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.blocklist.id).toEqual(BLOCKLIST_3_ID);
|
||||
});
|
||||
|
||||
it('8. should destroy many blocklists', async () => {
|
||||
const graphqlOperation = destroyManyOperationFactory({
|
||||
objectMetadataSingularName: 'blocklist',
|
||||
objectMetadataPluralName: 'blocklists',
|
||||
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [BLOCKLIST_1_ID, BLOCKLIST_2_ID],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.destroyBlocklists).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('8b. should destroy one blocklist', async () => {
|
||||
const graphqlOperation = destroyOneOperationFactory({
|
||||
objectMetadataSingularName: 'blocklist',
|
||||
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||
recordId: BLOCKLIST_3_ID,
|
||||
});
|
||||
|
||||
const destroyBlocklistResponse =
|
||||
await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(destroyBlocklistResponse.body.data.destroyBlocklist).toBeTruthy();
|
||||
});
|
||||
|
||||
it('9. should not find many blocklists anymore', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'blocklist',
|
||||
objectMetadataPluralName: 'blocklists',
|
||||
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [BLOCKLIST_1_ID, BLOCKLIST_2_ID],
|
||||
},
|
||||
not: {
|
||||
deletedAt: {
|
||||
is: 'NULL',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.blocklists.edges).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('9b. should not find one blocklist anymore', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'blocklist',
|
||||
gqlFields: BLOCKLIST_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
eq: BLOCKLIST_3_ID,
|
||||
},
|
||||
not: {
|
||||
deletedAt: {
|
||||
is: 'NULL',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.blocklist).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -1,482 +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_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
||||
const CALENDAR_CHANNEL_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
||||
const CALENDAR_CHANNEL_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
||||
const CONNECTED_ACCOUNT_ID = '777a8457-eb2d-40ac-a707-441b615b6989';
|
||||
|
||||
const CALENDAR_CHANNEL_GQL_FIELDS = `
|
||||
id
|
||||
handle
|
||||
syncStatus
|
||||
syncStage
|
||||
visibility
|
||||
isContactAutoCreationEnabled
|
||||
contactAutoCreationPolicy
|
||||
isSyncEnabled
|
||||
syncCursor
|
||||
syncStageStartedAt
|
||||
throttleFailureCount
|
||||
createdAt
|
||||
updatedAt
|
||||
deletedAt
|
||||
connectedAccountId
|
||||
`;
|
||||
|
||||
describe('calendarChannels resolvers (integration)', () => {
|
||||
beforeAll(async () => {
|
||||
const connectedAccountHandle = generateRecordName(CONNECTED_ACCOUNT_ID);
|
||||
const createConnectedAccountgraphqlOperation = createOneOperationFactory({
|
||||
objectMetadataSingularName: 'connectedAccount',
|
||||
gqlFields: `id`,
|
||||
data: {
|
||||
id: CONNECTED_ACCOUNT_ID,
|
||||
accountOwnerId: TIM_ACCOUNT_ID,
|
||||
handle: connectedAccountHandle,
|
||||
},
|
||||
});
|
||||
|
||||
await makeGraphqlAPIRequest(createConnectedAccountgraphqlOperation);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
const destroyConnectedAccountGraphqlOperation = destroyOneOperationFactory({
|
||||
objectMetadataSingularName: 'connectedAccount',
|
||||
gqlFields: `id`,
|
||||
recordId: CONNECTED_ACCOUNT_ID,
|
||||
});
|
||||
|
||||
await makeGraphqlAPIRequest(destroyConnectedAccountGraphqlOperation);
|
||||
});
|
||||
|
||||
it('1. should create and return calendarChannels', async () => {
|
||||
const calendarChannelHandle1 = generateRecordName(CALENDAR_CHANNEL_1_ID);
|
||||
const calendarChannelHandle2 = generateRecordName(CALENDAR_CHANNEL_2_ID);
|
||||
|
||||
const graphqlOperation = createManyOperationFactory({
|
||||
objectMetadataSingularName: 'calendarChannel',
|
||||
objectMetadataPluralName: 'calendarChannels',
|
||||
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||
data: [
|
||||
{
|
||||
id: CALENDAR_CHANNEL_1_ID,
|
||||
handle: calendarChannelHandle1,
|
||||
connectedAccountId: CONNECTED_ACCOUNT_ID,
|
||||
},
|
||||
{
|
||||
id: CALENDAR_CHANNEL_2_ID,
|
||||
handle: calendarChannelHandle2,
|
||||
connectedAccountId: CONNECTED_ACCOUNT_ID,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.createCalendarChannels).toHaveLength(2);
|
||||
|
||||
response.body.data.createCalendarChannels.forEach((calendarChannel) => {
|
||||
expect(calendarChannel).toHaveProperty('handle');
|
||||
expect([calendarChannelHandle1, calendarChannelHandle2]).toContain(
|
||||
calendarChannel.handle,
|
||||
);
|
||||
expect(calendarChannel).toHaveProperty('id');
|
||||
expect(calendarChannel).toHaveProperty('syncStatus');
|
||||
expect(calendarChannel).toHaveProperty('syncStage');
|
||||
expect(calendarChannel).toHaveProperty('visibility');
|
||||
expect(calendarChannel).toHaveProperty('isContactAutoCreationEnabled');
|
||||
expect(calendarChannel).toHaveProperty('contactAutoCreationPolicy');
|
||||
expect(calendarChannel).toHaveProperty('isSyncEnabled');
|
||||
expect(calendarChannel).toHaveProperty('syncCursor');
|
||||
expect(calendarChannel).toHaveProperty('syncStageStartedAt');
|
||||
expect(calendarChannel).toHaveProperty('throttleFailureCount');
|
||||
expect(calendarChannel).toHaveProperty('createdAt');
|
||||
expect(calendarChannel).toHaveProperty('updatedAt');
|
||||
expect(calendarChannel).toHaveProperty('deletedAt');
|
||||
expect(calendarChannel).toHaveProperty('connectedAccountId');
|
||||
});
|
||||
});
|
||||
|
||||
it('1b. should create and return one calendarChannel', async () => {
|
||||
const calendarChannelHandle = generateRecordName(CALENDAR_CHANNEL_3_ID);
|
||||
|
||||
const graphqlOperation = createOneOperationFactory({
|
||||
objectMetadataSingularName: 'calendarChannel',
|
||||
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||
data: {
|
||||
id: CALENDAR_CHANNEL_3_ID,
|
||||
handle: calendarChannelHandle,
|
||||
connectedAccountId: CONNECTED_ACCOUNT_ID,
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const createdCalendarChannel = response.body.data.createCalendarChannel;
|
||||
|
||||
expect(createdCalendarChannel).toHaveProperty('handle');
|
||||
expect(createdCalendarChannel.handle).toEqual(calendarChannelHandle);
|
||||
expect(createdCalendarChannel).toHaveProperty('id');
|
||||
expect(createdCalendarChannel).toHaveProperty('syncStatus');
|
||||
expect(createdCalendarChannel).toHaveProperty('syncStage');
|
||||
expect(createdCalendarChannel).toHaveProperty('visibility');
|
||||
expect(createdCalendarChannel).toHaveProperty(
|
||||
'isContactAutoCreationEnabled',
|
||||
);
|
||||
expect(createdCalendarChannel).toHaveProperty('contactAutoCreationPolicy');
|
||||
expect(createdCalendarChannel).toHaveProperty('isSyncEnabled');
|
||||
expect(createdCalendarChannel).toHaveProperty('syncCursor');
|
||||
expect(createdCalendarChannel).toHaveProperty('syncStageStartedAt');
|
||||
expect(createdCalendarChannel).toHaveProperty('throttleFailureCount');
|
||||
expect(createdCalendarChannel).toHaveProperty('createdAt');
|
||||
expect(createdCalendarChannel).toHaveProperty('updatedAt');
|
||||
expect(createdCalendarChannel).toHaveProperty('deletedAt');
|
||||
expect(createdCalendarChannel).toHaveProperty('connectedAccountId');
|
||||
});
|
||||
|
||||
it('2. should find many calendarChannels', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'calendarChannel',
|
||||
objectMetadataPluralName: 'calendarChannels',
|
||||
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const data = response.body.data.calendarChannels;
|
||||
|
||||
expect(data).toBeDefined();
|
||||
expect(Array.isArray(data.edges)).toBe(true);
|
||||
|
||||
if (data.edges.length > 0) {
|
||||
const calendarChannels = data.edges[0].node;
|
||||
|
||||
expect(calendarChannels).toHaveProperty('handle');
|
||||
expect(calendarChannels).toHaveProperty('syncStatus');
|
||||
expect(calendarChannels).toHaveProperty('syncStage');
|
||||
expect(calendarChannels).toHaveProperty('visibility');
|
||||
expect(calendarChannels).toHaveProperty('isContactAutoCreationEnabled');
|
||||
expect(calendarChannels).toHaveProperty('contactAutoCreationPolicy');
|
||||
expect(calendarChannels).toHaveProperty('isSyncEnabled');
|
||||
expect(calendarChannels).toHaveProperty('syncCursor');
|
||||
expect(calendarChannels).toHaveProperty('syncStageStartedAt');
|
||||
expect(calendarChannels).toHaveProperty('throttleFailureCount');
|
||||
expect(calendarChannels).toHaveProperty('id');
|
||||
expect(calendarChannels).toHaveProperty('createdAt');
|
||||
expect(calendarChannels).toHaveProperty('updatedAt');
|
||||
expect(calendarChannels).toHaveProperty('deletedAt');
|
||||
expect(calendarChannels).toHaveProperty('connectedAccountId');
|
||||
}
|
||||
});
|
||||
|
||||
it('2b. should find one calendarChannel', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'calendarChannel',
|
||||
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
eq: CALENDAR_CHANNEL_3_ID,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const calendarChannel = response.body.data.calendarChannel;
|
||||
|
||||
expect(calendarChannel).toHaveProperty('handle');
|
||||
expect(calendarChannel).toHaveProperty('syncStatus');
|
||||
expect(calendarChannel).toHaveProperty('syncStage');
|
||||
expect(calendarChannel).toHaveProperty('visibility');
|
||||
expect(calendarChannel).toHaveProperty('isContactAutoCreationEnabled');
|
||||
expect(calendarChannel).toHaveProperty('contactAutoCreationPolicy');
|
||||
expect(calendarChannel).toHaveProperty('isSyncEnabled');
|
||||
expect(calendarChannel).toHaveProperty('syncCursor');
|
||||
expect(calendarChannel).toHaveProperty('syncStageStartedAt');
|
||||
expect(calendarChannel).toHaveProperty('throttleFailureCount');
|
||||
expect(calendarChannel).toHaveProperty('id');
|
||||
expect(calendarChannel).toHaveProperty('createdAt');
|
||||
expect(calendarChannel).toHaveProperty('updatedAt');
|
||||
expect(calendarChannel).toHaveProperty('deletedAt');
|
||||
expect(calendarChannel).toHaveProperty('connectedAccountId');
|
||||
});
|
||||
|
||||
it('3. should update many calendarChannels', async () => {
|
||||
const graphqlOperation = updateManyOperationFactory({
|
||||
objectMetadataSingularName: 'calendarChannel',
|
||||
objectMetadataPluralName: 'calendarChannels',
|
||||
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||
data: {
|
||||
handle: 'Updated Handle',
|
||||
},
|
||||
filter: {
|
||||
id: {
|
||||
in: [CALENDAR_CHANNEL_1_ID, CALENDAR_CHANNEL_2_ID],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const updatedCalendarChannels = response.body.data.updateCalendarChannels;
|
||||
|
||||
expect(updatedCalendarChannels).toHaveLength(2);
|
||||
|
||||
updatedCalendarChannels.forEach((calendarChannel) => {
|
||||
expect(calendarChannel.handle).toEqual('Updated Handle');
|
||||
});
|
||||
});
|
||||
|
||||
it('3b. should update one calendarChannel', async () => {
|
||||
const graphqlOperation = updateOneOperationFactory({
|
||||
objectMetadataSingularName: 'calendarChannel',
|
||||
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||
data: {
|
||||
handle: 'New Handle',
|
||||
},
|
||||
recordId: CALENDAR_CHANNEL_3_ID,
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const updatedCalendarChannel = response.body.data.updateCalendarChannel;
|
||||
|
||||
expect(updatedCalendarChannel.handle).toEqual('New Handle');
|
||||
});
|
||||
|
||||
it('4. should find many calendarChannels with updated handle', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'calendarChannel',
|
||||
objectMetadataPluralName: 'calendarChannels',
|
||||
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
handle: {
|
||||
eq: 'Updated Handle',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.calendarChannels.edges).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('4b. should find one calendarChannel with updated handle', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'calendarChannel',
|
||||
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
handle: {
|
||||
eq: 'New Handle',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.calendarChannel.handle).toEqual('New Handle');
|
||||
});
|
||||
|
||||
it('5. should delete many calendarChannels', async () => {
|
||||
const graphqlOperation = deleteManyOperationFactory({
|
||||
objectMetadataSingularName: 'calendarChannel',
|
||||
objectMetadataPluralName: 'calendarChannels',
|
||||
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [CALENDAR_CHANNEL_1_ID, CALENDAR_CHANNEL_2_ID],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const deletedCalendarChannels = response.body.data.deleteCalendarChannels;
|
||||
|
||||
expect(deletedCalendarChannels).toHaveLength(2);
|
||||
|
||||
deletedCalendarChannels.forEach((calendarChannel) => {
|
||||
expect(calendarChannel.deletedAt).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
it('5b. should delete one calendarChannel', async () => {
|
||||
const graphqlOperation = deleteOneOperationFactory({
|
||||
objectMetadataSingularName: 'calendarChannel',
|
||||
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||
recordId: CALENDAR_CHANNEL_3_ID,
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.deleteCalendarChannel.deletedAt).toBeTruthy();
|
||||
});
|
||||
|
||||
it('6. should not find many calendarChannels anymore', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'calendarChannel',
|
||||
objectMetadataPluralName: 'calendarChannels',
|
||||
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [CALENDAR_CHANNEL_1_ID, CALENDAR_CHANNEL_2_ID],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const findCalendarChannelsResponse =
|
||||
await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(
|
||||
findCalendarChannelsResponse.body.data.calendarChannels.edges,
|
||||
).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('6b. should not find one calendarChannel anymore', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'calendarChannel',
|
||||
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
eq: CALENDAR_CHANNEL_3_ID,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.calendarChannel).toBeNull();
|
||||
});
|
||||
|
||||
it('7. should find many deleted calendarChannels with deletedAt filter', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'calendarChannel',
|
||||
objectMetadataPluralName: 'calendarChannels',
|
||||
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [CALENDAR_CHANNEL_1_ID, CALENDAR_CHANNEL_2_ID],
|
||||
},
|
||||
not: {
|
||||
deletedAt: {
|
||||
is: 'NULL',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.calendarChannels.edges).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('7b. should find one deleted calendarChannel with deletedAt filter', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'calendarChannel',
|
||||
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
eq: CALENDAR_CHANNEL_3_ID,
|
||||
},
|
||||
not: {
|
||||
deletedAt: {
|
||||
is: 'NULL',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.calendarChannel.id).toEqual(
|
||||
CALENDAR_CHANNEL_3_ID,
|
||||
);
|
||||
});
|
||||
|
||||
it('8. should destroy many calendarChannels', async () => {
|
||||
const graphqlOperation = destroyManyOperationFactory({
|
||||
objectMetadataSingularName: 'calendarChannel',
|
||||
objectMetadataPluralName: 'calendarChannels',
|
||||
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [CALENDAR_CHANNEL_1_ID, CALENDAR_CHANNEL_2_ID],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.destroyCalendarChannels).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('8b. should destroy one calendarChannel', async () => {
|
||||
const graphqlOperation = destroyOneOperationFactory({
|
||||
objectMetadataSingularName: 'calendarChannel',
|
||||
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||
recordId: CALENDAR_CHANNEL_3_ID,
|
||||
});
|
||||
|
||||
const destroyCalendarChannelResponse =
|
||||
await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(
|
||||
destroyCalendarChannelResponse.body.data.destroyCalendarChannel,
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
it('9. should not find many calendarChannels anymore', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'calendarChannel',
|
||||
objectMetadataPluralName: 'calendarChannels',
|
||||
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [CALENDAR_CHANNEL_1_ID, CALENDAR_CHANNEL_2_ID],
|
||||
},
|
||||
not: {
|
||||
deletedAt: {
|
||||
is: 'NULL',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.calendarChannels.edges).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('9b. should not find one calendarChannel anymore', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'calendarChannel',
|
||||
gqlFields: CALENDAR_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
eq: CALENDAR_CHANNEL_3_ID,
|
||||
},
|
||||
not: {
|
||||
deletedAt: {
|
||||
is: 'NULL',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.calendarChannel).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -1,455 +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 MESSAGE_CHANNEL_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
||||
const MESSAGE_CHANNEL_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
||||
const MESSAGE_CHANNEL_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
||||
const CONNECTED_ACCOUNT_ID = '777a8457-eb2d-40ac-a707-441b615b6989';
|
||||
|
||||
const MESSAGE_CHANNEL_GQL_FIELDS = `
|
||||
id
|
||||
handle
|
||||
deletedAt
|
||||
createdAt
|
||||
contactAutoCreationPolicy
|
||||
isContactAutoCreationEnabled
|
||||
isSyncEnabled
|
||||
syncCursor
|
||||
type
|
||||
`;
|
||||
|
||||
describe('messageChannels resolvers (integration)', () => {
|
||||
beforeAll(async () => {
|
||||
const connectedAccountHandle = generateRecordName(CONNECTED_ACCOUNT_ID);
|
||||
const graphqlOperation = createOneOperationFactory({
|
||||
objectMetadataSingularName: 'connectedAccount',
|
||||
gqlFields: `id`,
|
||||
data: {
|
||||
id: CONNECTED_ACCOUNT_ID,
|
||||
accountOwnerId: TIM_ACCOUNT_ID,
|
||||
handle: connectedAccountHandle,
|
||||
},
|
||||
});
|
||||
|
||||
await makeGraphqlAPIRequest(graphqlOperation);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
const graphqlOperation = destroyOneOperationFactory({
|
||||
objectMetadataSingularName: 'connectedAccount',
|
||||
gqlFields: `id`,
|
||||
recordId: CONNECTED_ACCOUNT_ID,
|
||||
});
|
||||
|
||||
await makeGraphqlAPIRequest(graphqlOperation);
|
||||
});
|
||||
|
||||
it('1. should create and return messageChannels', async () => {
|
||||
const messageChannelHandle1 = generateRecordName(MESSAGE_CHANNEL_1_ID);
|
||||
const messageChannelHandle2 = generateRecordName(MESSAGE_CHANNEL_2_ID);
|
||||
|
||||
const graphqlOperation = createManyOperationFactory({
|
||||
objectMetadataSingularName: 'messageChannel',
|
||||
objectMetadataPluralName: 'messageChannels',
|
||||
gqlFields: MESSAGE_CHANNEL_GQL_FIELDS,
|
||||
data: [
|
||||
{
|
||||
id: MESSAGE_CHANNEL_1_ID,
|
||||
handle: messageChannelHandle1,
|
||||
connectedAccountId: CONNECTED_ACCOUNT_ID,
|
||||
},
|
||||
{
|
||||
id: MESSAGE_CHANNEL_2_ID,
|
||||
handle: messageChannelHandle2,
|
||||
connectedAccountId: CONNECTED_ACCOUNT_ID,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.createMessageChannels).toHaveLength(2);
|
||||
|
||||
response.body.data.createMessageChannels.forEach((messageChannel) => {
|
||||
expect(messageChannel).toHaveProperty('handle');
|
||||
expect([messageChannelHandle1, messageChannelHandle2]).toContain(
|
||||
messageChannel.handle,
|
||||
);
|
||||
|
||||
expect(messageChannel).toHaveProperty('id');
|
||||
expect(messageChannel).toHaveProperty('deletedAt');
|
||||
expect(messageChannel).toHaveProperty('createdAt');
|
||||
expect(messageChannel).toHaveProperty('contactAutoCreationPolicy');
|
||||
expect(messageChannel).toHaveProperty('isContactAutoCreationEnabled');
|
||||
expect(messageChannel).toHaveProperty('isSyncEnabled');
|
||||
expect(messageChannel).toHaveProperty('syncCursor');
|
||||
expect(messageChannel).toHaveProperty('type');
|
||||
});
|
||||
});
|
||||
|
||||
it('1b. should create and return one messageChannel', async () => {
|
||||
const messageChannelHandle = generateRecordName(MESSAGE_CHANNEL_3_ID);
|
||||
|
||||
const graphqlOperation = createOneOperationFactory({
|
||||
objectMetadataSingularName: 'messageChannel',
|
||||
gqlFields: MESSAGE_CHANNEL_GQL_FIELDS,
|
||||
data: {
|
||||
id: MESSAGE_CHANNEL_3_ID,
|
||||
handle: messageChannelHandle,
|
||||
connectedAccountId: CONNECTED_ACCOUNT_ID,
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const createdMessageChannel = response.body.data.createMessageChannel;
|
||||
|
||||
expect(createdMessageChannel).toHaveProperty('handle');
|
||||
expect(createdMessageChannel.handle).toEqual(messageChannelHandle);
|
||||
|
||||
expect(createdMessageChannel).toHaveProperty('id');
|
||||
expect(createdMessageChannel).toHaveProperty('deletedAt');
|
||||
expect(createdMessageChannel).toHaveProperty('createdAt');
|
||||
expect(createdMessageChannel).toHaveProperty('contactAutoCreationPolicy');
|
||||
expect(createdMessageChannel).toHaveProperty(
|
||||
'isContactAutoCreationEnabled',
|
||||
);
|
||||
expect(createdMessageChannel).toHaveProperty('isSyncEnabled');
|
||||
expect(createdMessageChannel).toHaveProperty('syncCursor');
|
||||
expect(createdMessageChannel).toHaveProperty('type');
|
||||
});
|
||||
|
||||
it('2. should find many messageChannels', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'messageChannel',
|
||||
objectMetadataPluralName: 'messageChannels',
|
||||
gqlFields: MESSAGE_CHANNEL_GQL_FIELDS,
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const data = response.body.data.messageChannels;
|
||||
|
||||
expect(data).toBeDefined();
|
||||
expect(Array.isArray(data.edges)).toBe(true);
|
||||
|
||||
const edges = data.edges;
|
||||
|
||||
if (edges.length > 0) {
|
||||
const messageChannel = edges[0].node;
|
||||
|
||||
expect(messageChannel).toHaveProperty('handle');
|
||||
expect(messageChannel).toHaveProperty('id');
|
||||
expect(messageChannel).toHaveProperty('deletedAt');
|
||||
expect(messageChannel).toHaveProperty('createdAt');
|
||||
expect(messageChannel).toHaveProperty('contactAutoCreationPolicy');
|
||||
expect(messageChannel).toHaveProperty('isContactAutoCreationEnabled');
|
||||
expect(messageChannel).toHaveProperty('isSyncEnabled');
|
||||
expect(messageChannel).toHaveProperty('syncCursor');
|
||||
expect(messageChannel).toHaveProperty('type');
|
||||
}
|
||||
});
|
||||
|
||||
it('2b. should find one messageChannel', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'messageChannel',
|
||||
gqlFields: MESSAGE_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
eq: MESSAGE_CHANNEL_3_ID,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const messageChannel = response.body.data.messageChannel;
|
||||
|
||||
expect(messageChannel).toHaveProperty('handle');
|
||||
|
||||
expect(messageChannel).toHaveProperty('id');
|
||||
expect(messageChannel).toHaveProperty('deletedAt');
|
||||
expect(messageChannel).toHaveProperty('createdAt');
|
||||
expect(messageChannel).toHaveProperty('contactAutoCreationPolicy');
|
||||
expect(messageChannel).toHaveProperty('isContactAutoCreationEnabled');
|
||||
expect(messageChannel).toHaveProperty('isSyncEnabled');
|
||||
expect(messageChannel).toHaveProperty('syncCursor');
|
||||
expect(messageChannel).toHaveProperty('type');
|
||||
});
|
||||
|
||||
it('3. should update many messageChannels', async () => {
|
||||
const graphqlOperation = updateManyOperationFactory({
|
||||
objectMetadataSingularName: 'messageChannel',
|
||||
objectMetadataPluralName: 'messageChannels',
|
||||
gqlFields: MESSAGE_CHANNEL_GQL_FIELDS,
|
||||
data: {
|
||||
handle: 'New Handle',
|
||||
},
|
||||
filter: {
|
||||
id: {
|
||||
in: [MESSAGE_CHANNEL_1_ID, MESSAGE_CHANNEL_2_ID],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const updatedMessageChannels = response.body.data.updateMessageChannels;
|
||||
|
||||
expect(updatedMessageChannels).toHaveLength(2);
|
||||
|
||||
updatedMessageChannels.forEach((messageChannel) => {
|
||||
expect(messageChannel.handle).toEqual('New Handle');
|
||||
});
|
||||
});
|
||||
|
||||
it('3b. should update one messageChannel', async () => {
|
||||
const graphqlOperation = updateOneOperationFactory({
|
||||
objectMetadataSingularName: 'messageChannel',
|
||||
gqlFields: MESSAGE_CHANNEL_GQL_FIELDS,
|
||||
data: {
|
||||
handle: 'Updated Handle',
|
||||
},
|
||||
recordId: MESSAGE_CHANNEL_3_ID,
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const updatedMessageChannel = response.body.data.updateMessageChannel;
|
||||
|
||||
expect(updatedMessageChannel.handle).toEqual('Updated Handle');
|
||||
});
|
||||
|
||||
it('4. should find many messageChannels with updated handle', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'messageChannel',
|
||||
objectMetadataPluralName: 'messageChannels',
|
||||
gqlFields: MESSAGE_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
handle: {
|
||||
eq: 'New Handle',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.messageChannels.edges).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('4b. should find one messageChannel with updated handle', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'messageChannel',
|
||||
gqlFields: MESSAGE_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
handle: {
|
||||
eq: 'Updated Handle',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.messageChannel.handle).toEqual('Updated Handle');
|
||||
});
|
||||
|
||||
it('5. should delete many messageChannels', async () => {
|
||||
const graphqlOperation = deleteManyOperationFactory({
|
||||
objectMetadataSingularName: 'messageChannel',
|
||||
objectMetadataPluralName: 'messageChannels',
|
||||
gqlFields: MESSAGE_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [MESSAGE_CHANNEL_1_ID, MESSAGE_CHANNEL_2_ID],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const deleteMessageChannels = response.body.data.deleteMessageChannels;
|
||||
|
||||
expect(deleteMessageChannels).toHaveLength(2);
|
||||
|
||||
deleteMessageChannels.forEach((messageChannel) => {
|
||||
expect(messageChannel.deletedAt).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
it('5b. should delete one messageChannel', async () => {
|
||||
const graphqlOperation = deleteOneOperationFactory({
|
||||
objectMetadataSingularName: 'messageChannel',
|
||||
gqlFields: MESSAGE_CHANNEL_GQL_FIELDS,
|
||||
recordId: MESSAGE_CHANNEL_3_ID,
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.deleteMessageChannel.deletedAt).toBeTruthy();
|
||||
});
|
||||
|
||||
it('6. should not find many messageChannels anymore', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'messageChannel',
|
||||
objectMetadataPluralName: 'messageChannels',
|
||||
gqlFields: MESSAGE_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [MESSAGE_CHANNEL_1_ID, MESSAGE_CHANNEL_2_ID],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const findMessageChannelsResponse =
|
||||
await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(
|
||||
findMessageChannelsResponse.body.data.messageChannels.edges,
|
||||
).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('6b. should not find one messageChannel anymore', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'messageChannel',
|
||||
gqlFields: MESSAGE_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
eq: MESSAGE_CHANNEL_3_ID,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.messageChannel).toBeNull();
|
||||
});
|
||||
|
||||
it('7. should find many deleted messageChannels with deletedAt filter', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'messageChannel',
|
||||
objectMetadataPluralName: 'messageChannels',
|
||||
gqlFields: MESSAGE_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [MESSAGE_CHANNEL_1_ID, MESSAGE_CHANNEL_2_ID],
|
||||
},
|
||||
not: {
|
||||
deletedAt: {
|
||||
is: 'NULL',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.messageChannels.edges).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('7b. should find one deleted messageChannel with deletedAt filter', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'messageChannel',
|
||||
gqlFields: MESSAGE_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
eq: MESSAGE_CHANNEL_3_ID,
|
||||
},
|
||||
not: {
|
||||
deletedAt: {
|
||||
is: 'NULL',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.messageChannel.id).toEqual(MESSAGE_CHANNEL_3_ID);
|
||||
});
|
||||
|
||||
it('8. should destroy many messageChannels', async () => {
|
||||
const graphqlOperation = destroyManyOperationFactory({
|
||||
objectMetadataSingularName: 'messageChannel',
|
||||
objectMetadataPluralName: 'messageChannels',
|
||||
gqlFields: MESSAGE_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [MESSAGE_CHANNEL_1_ID, MESSAGE_CHANNEL_2_ID],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.destroyMessageChannels).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('8b. should destroy one messageChannel', async () => {
|
||||
const graphqlOperation = destroyOneOperationFactory({
|
||||
objectMetadataSingularName: 'messageChannel',
|
||||
gqlFields: MESSAGE_CHANNEL_GQL_FIELDS,
|
||||
recordId: MESSAGE_CHANNEL_3_ID,
|
||||
});
|
||||
|
||||
const destroyMessageChannelResponse =
|
||||
await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(
|
||||
destroyMessageChannelResponse.body.data.destroyMessageChannel,
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
it('9. should not find many messageChannels anymore', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'messageChannel',
|
||||
objectMetadataPluralName: 'messageChannels',
|
||||
gqlFields: MESSAGE_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [MESSAGE_CHANNEL_1_ID, MESSAGE_CHANNEL_2_ID],
|
||||
},
|
||||
not: {
|
||||
deletedAt: {
|
||||
is: 'NULL',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.messageChannels.edges).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('9b. should not find one messageChannel anymore', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'messageChannel',
|
||||
gqlFields: MESSAGE_CHANNEL_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
eq: MESSAGE_CHANNEL_3_ID,
|
||||
},
|
||||
not: {
|
||||
deletedAt: {
|
||||
is: 'NULL',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.messageChannel).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -1,439 +0,0 @@
|
||||
import { TIM_USER_ID } from 'test/integration/graphql/integration.constants';
|
||||
import { createManyOperationFactory } from 'test/integration/graphql/utils/create-many-operation-factory.util';
|
||||
import { createOneOperationFactory } from 'test/integration/graphql/utils/create-one-operation-factory.util';
|
||||
import { deleteManyOperationFactory } from 'test/integration/graphql/utils/delete-many-operation-factory.util';
|
||||
import { deleteOneOperationFactory } from 'test/integration/graphql/utils/delete-one-operation-factory.util';
|
||||
import { destroyManyOperationFactory } from 'test/integration/graphql/utils/destroy-many-operation-factory.util';
|
||||
import { destroyOneOperationFactory } from 'test/integration/graphql/utils/destroy-one-operation-factory.util';
|
||||
import { findManyOperationFactory } from 'test/integration/graphql/utils/find-many-operation-factory.util';
|
||||
import { findOneOperationFactory } from 'test/integration/graphql/utils/find-one-operation-factory.util';
|
||||
import { makeGraphqlAPIRequest } from 'test/integration/graphql/utils/make-graphql-api-request.util';
|
||||
import { updateManyOperationFactory } from 'test/integration/graphql/utils/update-many-operation-factory.util';
|
||||
import { updateOneOperationFactory } from 'test/integration/graphql/utils/update-one-operation-factory.util';
|
||||
import { generateRecordName } from 'test/integration/utils/generate-record-name';
|
||||
|
||||
const WORKSPACE_MEMBER_1_ID = '777a8457-eb2d-40ac-a707-551b615b6987';
|
||||
const WORKSPACE_MEMBER_2_ID = '777a8457-eb2d-40ac-a707-551b615b6988';
|
||||
const WORKSPACE_MEMBER_3_ID = '777a8457-eb2d-40ac-a707-551b615b6989';
|
||||
|
||||
const WORKSPACE_MEMBER_GQL_FIELDS = `
|
||||
id
|
||||
colorScheme
|
||||
avatarUrl
|
||||
locale
|
||||
timeZone
|
||||
dateFormat
|
||||
timeFormat
|
||||
userEmail
|
||||
userId
|
||||
createdAt
|
||||
updatedAt
|
||||
deletedAt
|
||||
`;
|
||||
|
||||
describe('workspaceMembers resolvers (integration)', () => {
|
||||
it('1. should create and return workspaceMembers', async () => {
|
||||
const workspaceMemberEmail1 = generateRecordName(WORKSPACE_MEMBER_1_ID);
|
||||
const workspaceMemberEmail2 = generateRecordName(WORKSPACE_MEMBER_2_ID);
|
||||
|
||||
const graphqlOperation = createManyOperationFactory({
|
||||
objectMetadataSingularName: 'workspaceMember',
|
||||
objectMetadataPluralName: 'workspaceMembers',
|
||||
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||
data: [
|
||||
{
|
||||
id: WORKSPACE_MEMBER_1_ID,
|
||||
userEmail: workspaceMemberEmail1,
|
||||
userId: TIM_USER_ID,
|
||||
},
|
||||
{
|
||||
id: WORKSPACE_MEMBER_2_ID,
|
||||
userEmail: workspaceMemberEmail2,
|
||||
userId: TIM_USER_ID,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.createWorkspaceMembers).toHaveLength(2);
|
||||
|
||||
response.body.data.createWorkspaceMembers.forEach((workspaceMember) => {
|
||||
expect(workspaceMember).toHaveProperty('userEmail');
|
||||
expect([workspaceMemberEmail1, workspaceMemberEmail2]).toContain(
|
||||
workspaceMember.userEmail,
|
||||
);
|
||||
expect(workspaceMember).toHaveProperty('id');
|
||||
expect(workspaceMember).toHaveProperty('colorScheme');
|
||||
expect(workspaceMember).toHaveProperty('avatarUrl');
|
||||
expect(workspaceMember).toHaveProperty('locale');
|
||||
expect(workspaceMember).toHaveProperty('timeZone');
|
||||
expect(workspaceMember).toHaveProperty('dateFormat');
|
||||
expect(workspaceMember).toHaveProperty('timeFormat');
|
||||
expect(workspaceMember).toHaveProperty('userId');
|
||||
expect(workspaceMember).toHaveProperty('createdAt');
|
||||
expect(workspaceMember).toHaveProperty('updatedAt');
|
||||
expect(workspaceMember).toHaveProperty('deletedAt');
|
||||
});
|
||||
});
|
||||
|
||||
it('1b. should create and return one workspaceMember', async () => {
|
||||
const workspaceMemberEmail = generateRecordName(WORKSPACE_MEMBER_3_ID);
|
||||
|
||||
const graphqlOperation = createOneOperationFactory({
|
||||
objectMetadataSingularName: 'workspaceMember',
|
||||
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||
data: {
|
||||
id: WORKSPACE_MEMBER_3_ID,
|
||||
userEmail: workspaceMemberEmail,
|
||||
userId: TIM_USER_ID,
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const createdWorkspaceMember = response.body.data.createWorkspaceMember;
|
||||
|
||||
expect(createdWorkspaceMember).toHaveProperty('userEmail');
|
||||
expect(createdWorkspaceMember.userEmail).toEqual(workspaceMemberEmail);
|
||||
expect(createdWorkspaceMember).toHaveProperty('id');
|
||||
expect(createdWorkspaceMember).toHaveProperty('colorScheme');
|
||||
expect(createdWorkspaceMember).toHaveProperty('avatarUrl');
|
||||
expect(createdWorkspaceMember).toHaveProperty('locale');
|
||||
expect(createdWorkspaceMember).toHaveProperty('timeZone');
|
||||
expect(createdWorkspaceMember).toHaveProperty('dateFormat');
|
||||
expect(createdWorkspaceMember).toHaveProperty('timeFormat');
|
||||
expect(createdWorkspaceMember).toHaveProperty('userId');
|
||||
expect(createdWorkspaceMember).toHaveProperty('createdAt');
|
||||
expect(createdWorkspaceMember).toHaveProperty('updatedAt');
|
||||
expect(createdWorkspaceMember).toHaveProperty('deletedAt');
|
||||
});
|
||||
|
||||
it('2. should find many workspaceMembers', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'workspaceMember',
|
||||
objectMetadataPluralName: 'workspaceMembers',
|
||||
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const data = response.body.data.workspaceMembers;
|
||||
|
||||
expect(data).toBeDefined();
|
||||
expect(Array.isArray(data.edges)).toBe(true);
|
||||
|
||||
if (data.edges.length > 0) {
|
||||
const workspaceMembers = data.edges[0].node;
|
||||
|
||||
expect(workspaceMembers).toHaveProperty('id');
|
||||
expect(workspaceMembers).toHaveProperty('colorScheme');
|
||||
expect(workspaceMembers).toHaveProperty('avatarUrl');
|
||||
expect(workspaceMembers).toHaveProperty('locale');
|
||||
expect(workspaceMembers).toHaveProperty('timeZone');
|
||||
expect(workspaceMembers).toHaveProperty('dateFormat');
|
||||
expect(workspaceMembers).toHaveProperty('timeFormat');
|
||||
expect(workspaceMembers).toHaveProperty('userEmail');
|
||||
expect(workspaceMembers).toHaveProperty('userId');
|
||||
expect(workspaceMembers).toHaveProperty('createdAt');
|
||||
expect(workspaceMembers).toHaveProperty('updatedAt');
|
||||
expect(workspaceMembers).toHaveProperty('deletedAt');
|
||||
}
|
||||
});
|
||||
|
||||
it('2b. should find one workspaceMember', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'workspaceMember',
|
||||
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
eq: WORKSPACE_MEMBER_3_ID,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const workspaceMember = response.body.data.workspaceMember;
|
||||
|
||||
expect(workspaceMember).toHaveProperty('id');
|
||||
expect(workspaceMember).toHaveProperty('colorScheme');
|
||||
expect(workspaceMember).toHaveProperty('avatarUrl');
|
||||
expect(workspaceMember).toHaveProperty('locale');
|
||||
expect(workspaceMember).toHaveProperty('timeZone');
|
||||
expect(workspaceMember).toHaveProperty('dateFormat');
|
||||
expect(workspaceMember).toHaveProperty('timeFormat');
|
||||
expect(workspaceMember).toHaveProperty('userEmail');
|
||||
expect(workspaceMember).toHaveProperty('userId');
|
||||
expect(workspaceMember).toHaveProperty('createdAt');
|
||||
expect(workspaceMember).toHaveProperty('updatedAt');
|
||||
expect(workspaceMember).toHaveProperty('deletedAt');
|
||||
});
|
||||
|
||||
it('3. should update many workspaceMembers', async () => {
|
||||
const graphqlOperation = updateManyOperationFactory({
|
||||
objectMetadataSingularName: 'workspaceMember',
|
||||
objectMetadataPluralName: 'workspaceMembers',
|
||||
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||
data: {
|
||||
locale: 'en-US',
|
||||
},
|
||||
filter: {
|
||||
id: {
|
||||
in: [WORKSPACE_MEMBER_1_ID, WORKSPACE_MEMBER_2_ID],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const updatedWorkspaceMembers = response.body.data.updateWorkspaceMembers;
|
||||
|
||||
expect(updatedWorkspaceMembers).toHaveLength(2);
|
||||
|
||||
updatedWorkspaceMembers.forEach((workspaceMember) => {
|
||||
expect(workspaceMember.locale).toEqual('en-US');
|
||||
});
|
||||
});
|
||||
|
||||
it('3b. should update one workspaceMember', async () => {
|
||||
const graphqlOperation = updateOneOperationFactory({
|
||||
objectMetadataSingularName: 'workspaceMember',
|
||||
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||
data: {
|
||||
locale: 'fr-CA',
|
||||
},
|
||||
recordId: WORKSPACE_MEMBER_3_ID,
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
const updatedWorkspaceMember = response.body.data.updateWorkspaceMember;
|
||||
|
||||
expect(updatedWorkspaceMember.locale).toEqual('fr-CA');
|
||||
});
|
||||
|
||||
it('4. should find many workspaceMembers with updated locale', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'workspaceMember',
|
||||
objectMetadataPluralName: 'workspaceMembers',
|
||||
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||
filter: {
|
||||
locale: {
|
||||
eq: 'en-US',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.workspaceMembers.edges).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('4b. should find one workspaceMember with updated locale', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'workspaceMember',
|
||||
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||
filter: {
|
||||
locale: {
|
||||
eq: 'fr-CA',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.workspaceMember.locale).toEqual('fr-CA');
|
||||
});
|
||||
|
||||
it('5. should not delete many workspaceMembers', async () => {
|
||||
const graphqlOperation = deleteManyOperationFactory({
|
||||
objectMetadataSingularName: 'workspaceMember',
|
||||
objectMetadataPluralName: 'workspaceMembers',
|
||||
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [WORKSPACE_MEMBER_1_ID, WORKSPACE_MEMBER_2_ID],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.deleteWorkspaceMembers).toBeNull();
|
||||
expect(response.body.errors).toStrictEqual([
|
||||
{
|
||||
extensions: { code: 'INTERNAL_SERVER_ERROR' },
|
||||
message: 'Method not allowed.',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('5b. should delete one workspaceMember', async () => {
|
||||
const graphqlOperation = deleteOneOperationFactory({
|
||||
objectMetadataSingularName: 'workspaceMember',
|
||||
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||
recordId: WORKSPACE_MEMBER_3_ID,
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.deleteWorkspaceMember.deletedAt).toBeTruthy();
|
||||
});
|
||||
|
||||
it('6. should still find many workspaceMembers that were not deleted', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'workspaceMember',
|
||||
objectMetadataPluralName: 'workspaceMembers',
|
||||
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [WORKSPACE_MEMBER_1_ID, WORKSPACE_MEMBER_2_ID],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const findWorkspaceMembersResponse =
|
||||
await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(
|
||||
findWorkspaceMembersResponse.body.data.workspaceMembers.edges,
|
||||
).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('6b. should not find one workspaceMember anymore', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'workspaceMember',
|
||||
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
eq: WORKSPACE_MEMBER_3_ID,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.workspaceMember).toBeNull();
|
||||
});
|
||||
|
||||
it('7. should not find many deleted workspaceMembers with deletedAt filter', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'workspaceMember',
|
||||
objectMetadataPluralName: 'workspaceMembers',
|
||||
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [WORKSPACE_MEMBER_1_ID, WORKSPACE_MEMBER_2_ID],
|
||||
},
|
||||
not: {
|
||||
deletedAt: {
|
||||
is: 'NULL',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.workspaceMembers.edges).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('7b. should find one deleted workspaceMember with deletedAt filter', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'workspaceMember',
|
||||
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
eq: WORKSPACE_MEMBER_3_ID,
|
||||
},
|
||||
not: {
|
||||
deletedAt: {
|
||||
is: 'NULL',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.workspaceMember.id).toEqual(
|
||||
WORKSPACE_MEMBER_3_ID,
|
||||
);
|
||||
});
|
||||
|
||||
it('8. should destroy many workspaceMembers', async () => {
|
||||
const graphqlOperation = destroyManyOperationFactory({
|
||||
objectMetadataSingularName: 'workspaceMember',
|
||||
objectMetadataPluralName: 'workspaceMembers',
|
||||
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [WORKSPACE_MEMBER_1_ID, WORKSPACE_MEMBER_2_ID],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.destroyWorkspaceMembers).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('8b. should destroy one workspaceMember', async () => {
|
||||
const graphqlOperation = destroyOneOperationFactory({
|
||||
objectMetadataSingularName: 'workspaceMember',
|
||||
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||
recordId: WORKSPACE_MEMBER_3_ID,
|
||||
});
|
||||
|
||||
const destroyWorkspaceMemberResponse =
|
||||
await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(
|
||||
destroyWorkspaceMemberResponse.body.data.destroyWorkspaceMember,
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
it('9. should not find many workspaceMembers anymore', async () => {
|
||||
const graphqlOperation = findManyOperationFactory({
|
||||
objectMetadataSingularName: 'workspaceMember',
|
||||
objectMetadataPluralName: 'workspaceMembers',
|
||||
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
in: [WORKSPACE_MEMBER_1_ID, WORKSPACE_MEMBER_2_ID],
|
||||
},
|
||||
not: {
|
||||
deletedAt: {
|
||||
is: 'NULL',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.workspaceMembers.edges).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('9b. should not find one workspaceMember anymore', async () => {
|
||||
const graphqlOperation = findOneOperationFactory({
|
||||
objectMetadataSingularName: 'workspaceMember',
|
||||
gqlFields: WORKSPACE_MEMBER_GQL_FIELDS,
|
||||
filter: {
|
||||
id: {
|
||||
eq: WORKSPACE_MEMBER_3_ID,
|
||||
},
|
||||
not: {
|
||||
deletedAt: {
|
||||
is: 'NULL',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await makeGraphqlAPIRequest(graphqlOperation);
|
||||
|
||||
expect(response.body.data.workspaceMember).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user