76e144e85a
# Introduction Removing old standard objects `messageChannel` and `messageFolder` and `calendarChannel` --------- Co-authored-by: Cursor <cursoragent@cursor.com>
140 lines
4.4 KiB
TypeScript
140 lines
4.4 KiB
TypeScript
import { gql } from 'graphql-tag';
|
|
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
|
|
|
|
import { MESSAGE_CHANNEL_DATA_SEED_IDS } from 'src/engine/workspace-manager/dev-seeder/core/constants/message-channel-seed-ids.constant';
|
|
import { MESSAGE_FOLDER_DATA_SEED_IDS } from 'src/engine/workspace-manager/dev-seeder/core/constants/message-folder-seed-ids.constant';
|
|
|
|
describe('messageFolderResolver (e2e)', () => {
|
|
describe('myMessageFolders', () => {
|
|
it('should return only the current user message folders', async () => {
|
|
const response = await makeMetadataAPIRequest({
|
|
query: gql`
|
|
query MyMessageFolders {
|
|
myMessageFolders {
|
|
id
|
|
name
|
|
isSynced
|
|
messageChannelId
|
|
}
|
|
}
|
|
`,
|
|
});
|
|
|
|
expect(response.status).toBe(200);
|
|
expect(response.body.errors).toBeUndefined();
|
|
|
|
const folders = response.body.data.myMessageFolders;
|
|
const folderIds = folders.map((folder: { id: string }) => folder.id);
|
|
|
|
expect(folderIds).toContain(MESSAGE_FOLDER_DATA_SEED_IDS.JANE_INBOX);
|
|
expect(folderIds).toContain(MESSAGE_FOLDER_DATA_SEED_IDS.JANE_SENT);
|
|
expect(folderIds).not.toContain(MESSAGE_FOLDER_DATA_SEED_IDS.JONY_INBOX);
|
|
});
|
|
|
|
it('should filter by messageChannelId', async () => {
|
|
const response = await makeMetadataAPIRequest({
|
|
query: gql`
|
|
query MyMessageFolders($messageChannelId: UUID) {
|
|
myMessageFolders(messageChannelId: $messageChannelId) {
|
|
id
|
|
name
|
|
}
|
|
}
|
|
`,
|
|
variables: {
|
|
messageChannelId: MESSAGE_CHANNEL_DATA_SEED_IDS.JANE,
|
|
},
|
|
});
|
|
|
|
expect(response.status).toBe(200);
|
|
expect(response.body.errors).toBeUndefined();
|
|
|
|
const folders = response.body.data.myMessageFolders;
|
|
const folderIds = folders.map((folder: { id: string }) => folder.id);
|
|
|
|
expect(folderIds).toContain(MESSAGE_FOLDER_DATA_SEED_IDS.JANE_INBOX);
|
|
expect(folderIds).not.toContain(MESSAGE_FOLDER_DATA_SEED_IDS.JONY_INBOX);
|
|
});
|
|
|
|
it('should deny filtering by another user messageChannelId', async () => {
|
|
const response = await makeMetadataAPIRequest({
|
|
query: gql`
|
|
query MyMessageFolders($messageChannelId: UUID) {
|
|
myMessageFolders(messageChannelId: $messageChannelId) {
|
|
id
|
|
}
|
|
}
|
|
`,
|
|
variables: {
|
|
messageChannelId: MESSAGE_CHANNEL_DATA_SEED_IDS.JONY,
|
|
},
|
|
});
|
|
|
|
expect(response.status).toBe(200);
|
|
expect(response.body.errors?.[0]?.extensions?.code).toBe('FORBIDDEN');
|
|
});
|
|
|
|
it('should not expose hidden fields', async () => {
|
|
const response = await makeMetadataAPIRequest({
|
|
query: gql`
|
|
query MyMessageFolders {
|
|
myMessageFolders {
|
|
id
|
|
syncCursor
|
|
}
|
|
}
|
|
`,
|
|
});
|
|
|
|
expect(response.status).toBe(200);
|
|
expect(response.body.errors).toBeDefined();
|
|
});
|
|
});
|
|
|
|
describe('updateMessageFolder', () => {
|
|
it('should allow updating own folder isSynced', async () => {
|
|
const response = await makeMetadataAPIRequest({
|
|
query: gql`
|
|
mutation UpdateMessageFolder($input: UpdateMessageFolderInput!) {
|
|
updateMessageFolder(input: $input) {
|
|
id
|
|
isSynced
|
|
}
|
|
}
|
|
`,
|
|
variables: {
|
|
input: {
|
|
id: MESSAGE_FOLDER_DATA_SEED_IDS.JANE_INBOX,
|
|
update: { isSynced: false },
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(response.status).toBe(200);
|
|
expect(response.body.errors).toBeUndefined();
|
|
expect(response.body.data.updateMessageFolder.isSynced).toBe(false);
|
|
});
|
|
|
|
it('should deny updating another user folder', async () => {
|
|
const response = await makeMetadataAPIRequest({
|
|
query: gql`
|
|
mutation UpdateMessageFolder($input: UpdateMessageFolderInput!) {
|
|
updateMessageFolder(input: $input) {
|
|
id
|
|
}
|
|
}
|
|
`,
|
|
variables: {
|
|
input: {
|
|
id: MESSAGE_FOLDER_DATA_SEED_IDS.JONY_INBOX,
|
|
update: { isSynced: false },
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(response.status).toBe(200);
|
|
expect(response.body.errors?.[0]?.extensions?.code).toBe('FORBIDDEN');
|
|
});
|
|
});
|
|
});
|