-
Notifications
You must be signed in to change notification settings - Fork 4
357 mediawiki platform + mediawiki settings for hivemind + enums for names #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
357 mediawiki platform + mediawiki settings for hivemind + enums for names #358
Conversation
WalkthroughThe updates primarily involve refactoring the codebase to use centralized enums for token types and platform names from the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
Files selected for processing (14)
- tests/fixtures/token.fixture.ts (1 hunks)
- tests/integration/module.test.ts (8 hunks)
- tests/integration/platform.test.ts (1 hunks)
- package.json (1 hunks)
- src/config/passport.ts (2 hunks)
- src/controllers/platform.controller.ts (17 hunks)
- src/docs/module.doc.yml (2 hunks)
- src/docs/platform.doc.yml (4 hunks)
- src/services/auth.service.ts (3 hunks)
- src/services/platform.service.ts (3 hunks)
- src/services/token.service.ts (6 hunks)
- src/validations/community.validation.ts (2 hunks)
- src/validations/module.validation.ts (3 hunks)
- src/validations/platform.validation.ts (5 hunks)
Files skipped from review due to trivial changes (1)
- package.json
Additional comments not posted (58)
__tests__/fixtures/token.fixture.ts (4)
3-3: LGTM! The import ofTokenTypeNamesfrom@togethercrew.dev/dbenhances consistency.
11-11: LGTM! The use ofTokenTypeNames.ACCESSimproves maintainability.
16-16: LGTM! The use ofTokenTypeNames.ACCESSimproves maintainability.
22-22: LGTM! The use ofTokenTypeNames.ACCESSimproves maintainability.src/config/passport.ts (2)
3-3: LGTM! The import ofTokenTypeNamesfrom@togethercrew.dev/dbenhances consistency.
19-19: LGTM! The use ofTokenTypeNames.ACCESSimproves maintainability.src/validations/community.validation.ts (2)
3-3: LGTM! The import ofPlatformNamesfrom@togethercrew.dev/dbenhances consistency.
43-43: LGTM! The use ofPlatformNames.Discordimproves maintainability.src/validations/module.validation.ts (7)
1-1: LGTM! The import ofPlatformNames,ModuleNames, andHivemindPlatformNamesfrom@togethercrew.dev/dbenhances consistency.
7-9: LGTM! The use ofModuleNamesimproves maintainability.
16-16: LGTM! The use ofModuleNamesimproves maintainability.
69-73: LGTM! The addition ofhivemindMediaWikiMetadataimproves functionality.
79-81: LGTM! The use ofHivemindPlatformNamesimproves maintainability.
86-104: LGTM! The use ofPlatformNamesimproves maintainability.
123-123: LGTM! The use ofModuleNames.Hivemindimproves maintainability.src/services/auth.service.ts (3)
7-7: LGTM! The import ofTokenTypeNamesfrom@togethercrew.dev/dbenhances consistency.
91-94: LGTM! The use ofTokenTypeNames.REFRESHimproves maintainability.
108-108: LGTM! The use ofTokenTypeNames.REFRESHimproves maintainability.src/services/token.service.ts (9)
6-6: LGTM! The import ofTokenTypeNamesfrom@togethercrew.dev/dbenhances consistency.
79-79: LGTM! The use ofTokenTypeNames.ACCESSimproves maintainability.
82-83: LGTM! The use ofTokenTypeNames.REFRESHimproves maintainability.
110-110: LGTM! The use ofTokenTypeNames.DISCORD_ACCESSimproves maintainability.
116-116: LGTM! The use ofTokenTypeNames.DISCORD_REFRESHimproves maintainability.
141-141: LGTM! The use ofTokenTypeNames.GOOGLE_ACCESSimproves maintainability.
144-144: LGTM! The use ofTokenTypeNames.GOOGLE_REFRESHimproves maintainability.
156-157: LGTM! The use ofTokenTypeNames.DISCORD_ACCESSandTokenTypeNames.DISCORD_REFRESHimproves maintainability.
187-187: LGTM! The use ofTokenTypeNames.NOTION_ACCESSimproves maintainability.src/validations/platform.validation.ts (11)
2-2: LGTM! The import ofPlatformNamesfrom@togethercrew.dev/dbenhances consistency.
6-6: LGTM! The import ofPlatformNamesfrom@togethercrew.dev/dbenhances consistency.
70-74: LGTM! The addition ofmediaWikiMetadataimproves functionality.
78-80: LGTM! The use ofPlatformNamesimproves maintainability.
85-107: LGTM! The use ofPlatformNamesimproves maintainability.
115-117: LGTM! The use ofPlatformNamesimproves maintainability.
121-121: LGTM! The use ofPlatformNamesimproves maintainability.
126-126: LGTM! The use ofPlatformNamesimproves maintainability.
135-135: LGTM! The use ofPlatformNamesimproves maintainability.
163-163: LGTM! The use ofPlatformNamesimproves maintainability.
241-244: LGTM! The use ofPlatformNames.Discordimproves maintainability.src/services/platform.service.ts (3)
8-9: LGTM! The import ofPlatformNamesfrom@togethercrew.dev/dbenhances consistency.
Line range hint
16-26: LGTM! The use ofPlatformNames.Discordimproves maintainability.
143-152: LGTM! The use ofPlatformNamesimproves maintainability.src/docs/module.doc.yml (2)
168-168: Add new platform names to the enum list.The new platform names 'notion' and 'mediaWiki' have been correctly added to the enum list.
230-236: Add metadata descriptions for the new platform 'MediaWiki'.The metadata descriptions for 'MediaWiki' have been correctly added and are consistent with the rest of the metadata descriptions.
src/controllers/platform.controller.ts (10)
20-20: ImportPlatformNamesfrom@togethercrew.dev/db.The import statement for
PlatformNameshas been correctly added.
34-34: Replace string literal 'discord' withPlatformNames.Discord.The string literal 'discord' has been correctly replaced with
PlatformNames.Discord.
45-45: Replace string literal 'twitter' withPlatformNames.Twitter.The string literal 'twitter' has been correctly replaced with
PlatformNames.Twitter.
50-50: Replace string literal 'google' withPlatformNames.Google.The string literal 'google' has been correctly replaced with
PlatformNames.Google.
67-67: Replace string literal 'github' withPlatformNames.GitHub.The string literal 'github' has been correctly replaced with
PlatformNames.GitHub.
70-70: Replace string literal 'notion' withPlatformNames.Notion.The string literal 'notion' has been correctly replaced with
PlatformNames.Notion.
94-94: Replace string literal 'discord' withPlatformNames.Discordin theconnectDiscordCallbackfunction.The string literal 'discord' has been correctly replaced with
PlatformNames.Discordin theconnectDiscordCallbackfunction.
130-130: Replace string literal 'twitter' withPlatformNames.Twitterin theconnectTwitterCallbackfunction.The string literal 'twitter' has been correctly replaced with
PlatformNames.Twitterin theconnectTwitterCallbackfunction.
172-172: Replace string literal 'google' withPlatformNames.Googlein theconnectGoogleCallbackfunction.The string literal 'google' has been correctly replaced with
PlatformNames.Googlein theconnectGoogleCallbackfunction.
208-208: Replace string literal 'github' withPlatformNames.GitHubin theconnectGithubCallbackfunction.The string literal 'github' has been correctly replaced with
PlatformNames.GitHubin theconnectGithubCallbackfunction.src/docs/platform.doc.yml (3)
7-7: Update description to include 'Notion' and 'MediaWiki'.The description has been correctly updated to include 'Notion' and 'MediaWiki'.
69-69: Add 'mediaWiki' to the enum list for platform creation.The new platform name 'mediaWiki' has been correctly added to the enum list for platform creation.
201-201: Add 'mediaWiki' to the enum list for platform retrieval.The new platform name 'mediaWiki' has been correctly added to the enum list for platform retrieval.
__tests__/integration/module.test.ts (2)
81-82: LGTM! The usage ofModuleNames.Hivemindis correct.
389-389: LGTM! The usage ofPlatformNames.Discordis correct.
| // import { analyzerAction, analyzerWindow } from '../../src/config/analyzer.statics'; | ||
| // import { Connection, Types } from 'mongoose'; | ||
| // import mongoose from 'mongoose'; | ||
| // import { ModuleNames, PlatformNames } from '@togethercrew.dev/db'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uncomment the import statement for PlatformNames.
- // import { ModuleNames, PlatformNames } from '@togethercrew.dev/db';
+ import { ModuleNames, PlatformNames } from '@togethercrew.dev/db';Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| // import { ModuleNames, PlatformNames } from '@togethercrew.dev/db'; | |
| import { ModuleNames, PlatformNames } from '@togethercrew.dev/db'; |
| // test('should return 201 and successfully create new mediaWiki platform if data is ok', async () => { | ||
| // userOne.communities = [communityOne._id]; | ||
| // communityOne.users = [userOne._id]; | ||
| // await insertCommunities([communityOne]); | ||
| // await insertUsers([userOne]); | ||
| // newPlatform = { | ||
| // name: 'mediaWiki', | ||
| // community: communityOne._id, | ||
| // metadata: { | ||
| // baseURL: 'base', | ||
| // }, | ||
| // }; | ||
| // const res = await request(app) | ||
| // .post(`/api/v1/platforms`) | ||
| // .set('Authorization', `Bearer ${userOneAccessToken}`) | ||
| // .send(newPlatform) | ||
| // .expect(httpStatus.CREATED); | ||
|
|
||
| // expect(res.body).toEqual({ | ||
| // id: expect.anything(), | ||
| // name: newPlatform.name, | ||
| // metadata: newPlatform.metadata, | ||
| // community: communityOne._id.toHexString(), | ||
| // disconnectedAt: null, | ||
| // connectedAt: expect.anything(), | ||
| // }); | ||
|
|
||
| // const dbPlatform = await Platform.findById(res.body.id); | ||
| // expect(dbPlatform).toBeDefined(); | ||
| // expect(dbPlatform).toMatchObject({ | ||
| // name: newPlatform.name, | ||
| // metadata: newPlatform.metadata, | ||
| // }); | ||
|
|
||
| // const dbCommunity = await Community.findById(res.body.community); | ||
| // expect(dbCommunity).toMatchObject({ | ||
| // id: communityOne._id.toHexString(), | ||
| // name: communityOne.name, | ||
| // avatarURL: communityOne.avatarURL, | ||
| // users: [userOne._id], | ||
| // }); | ||
| // }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uncomment the test case for creating a mediaWiki platform.
The test case for creating a mediaWiki platform is commented out. Uncomment the test case to ensure it is executed and validated.
- // test('should return 201 and successfully create new mediaWiki platform if data is ok', async () => {
- // userOne.communities = [communityOne._id];
- // communityOne.users = [userOne._id];
- // await insertCommunities([communityOne]);
- // await insertUsers([userOne]);
- // newPlatform = {
- // name: 'mediaWiki',
- // community: communityOne._id,
- // metadata: {
- // baseURL: 'base',
- // },
- // };
- // const res = await request(app)
- // .post(`/api/v1/platforms`)
- // .set('Authorization', `Bearer ${userOneAccessToken}`)
- // .send(newPlatform)
- // .expect(httpStatus.CREATED);
- //
- // expect(res.body).toEqual({
- // id: expect.anything(),
- // name: newPlatform.name,
- // metadata: newPlatform.metadata,
- // community: communityOne._id.toHexString(),
- // disconnectedAt: null,
- // connectedAt: expect.anything(),
- // });
- //
- // const dbPlatform = await Platform.findById(res.body.id);
- // expect(dbPlatform).toBeDefined();
- // expect(dbPlatform).toMatchObject({
- // name: newPlatform.name,
- // metadata: newPlatform.metadata,
- // });
- //
- // const dbCommunity = await Community.findById(res.body.community);
- // expect(dbCommunity).toMatchObject({
- // id: communityOne._id.toHexString(),
- // name: communityOne.name,
- // avatarURL: communityOne.avatarURL,
- // users: [userOne._id],
- // });
- // });
+ test('should return 201 and successfully create new mediaWiki platform if data is ok', async () => {
+ userOne.communities = [communityOne._id];
+ communityOne.users = [userOne._id];
+ await insertCommunities([communityOne]);
+ await insertUsers([userOne]);
+ newPlatform = {
+ name: 'mediaWiki',
+ community: communityOne._id,
+ metadata: {
+ baseURL: 'base',
+ },
+ };
+ const res = await request(app)
+ .post(`/api/v1/platforms`)
+ .set('Authorization', `Bearer ${userOneAccessToken}`)
+ .send(newPlatform)
+ .expect(httpStatus.CREATED);
+
+ expect(res.body).toEqual({
+ id: expect.anything(),
+ name: newPlatform.name,
+ metadata: newPlatform.metadata,
+ community: communityOne._id.toHexString(),
+ disconnectedAt: null,
+ connectedAt: expect.anything(),
+ });
+
+ const dbPlatform = await Platform.findById(res.body.id);
+ expect(dbPlatform).toBeDefined();
+ expect(dbPlatform).toMatchObject({
+ name: newPlatform.name,
+ metadata: newPlatform.metadata,
+ });
+
+ const dbCommunity = await Community.findById(res.body.community);
+ expect(dbCommunity).toMatchObject({
+ id: communityOne._id.toHexString(),
+ name: communityOne.name,
+ avatarURL: communityOne.avatarURL,
+ users: [userOne._id],
+ });
+ });Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| // test('should return 201 and successfully create new mediaWiki platform if data is ok', async () => { | |
| // userOne.communities = [communityOne._id]; | |
| // communityOne.users = [userOne._id]; | |
| // await insertCommunities([communityOne]); | |
| // await insertUsers([userOne]); | |
| // newPlatform = { | |
| // name: 'mediaWiki', | |
| // community: communityOne._id, | |
| // metadata: { | |
| // baseURL: 'base', | |
| // }, | |
| // }; | |
| // const res = await request(app) | |
| // .post(`/api/v1/platforms`) | |
| // .set('Authorization', `Bearer ${userOneAccessToken}`) | |
| // .send(newPlatform) | |
| // .expect(httpStatus.CREATED); | |
| // expect(res.body).toEqual({ | |
| // id: expect.anything(), | |
| // name: newPlatform.name, | |
| // metadata: newPlatform.metadata, | |
| // community: communityOne._id.toHexString(), | |
| // disconnectedAt: null, | |
| // connectedAt: expect.anything(), | |
| // }); | |
| // const dbPlatform = await Platform.findById(res.body.id); | |
| // expect(dbPlatform).toBeDefined(); | |
| // expect(dbPlatform).toMatchObject({ | |
| // name: newPlatform.name, | |
| // metadata: newPlatform.metadata, | |
| // }); | |
| // const dbCommunity = await Community.findById(res.body.community); | |
| // expect(dbCommunity).toMatchObject({ | |
| // id: communityOne._id.toHexString(), | |
| // name: communityOne.name, | |
| // avatarURL: communityOne.avatarURL, | |
| // users: [userOne._id], | |
| // }); | |
| // }); | |
| test('should return 201 and successfully create new mediaWiki platform if data is ok', async () => { | |
| userOne.communities = [communityOne._id]; | |
| communityOne.users = [userOne._id]; | |
| await insertCommunities([communityOne]); | |
| await insertUsers([userOne]); | |
| newPlatform = { | |
| name: 'mediaWiki', | |
| community: communityOne._id, | |
| metadata: { | |
| baseURL: 'base', | |
| }, | |
| }; | |
| const res = await request(app) | |
| .post(`/api/v1/platforms`) | |
| .set('Authorization', `Bearer ${userOneAccessToken}`) | |
| .send(newPlatform) | |
| .expect(httpStatus.CREATED); | |
| expect(res.body).toEqual({ | |
| id: expect.anything(), | |
| name: newPlatform.name, | |
| metadata: newPlatform.metadata, | |
| community: communityOne._id.toHexString(), | |
| disconnectedAt: null, | |
| connectedAt: expect.anything(), | |
| }); | |
| const dbPlatform = await Platform.findById(res.body.id); | |
| expect(dbPlatform).toBeDefined(); | |
| expect(dbPlatform).toMatchObject({ | |
| name: newPlatform.name, | |
| metadata: newPlatform.metadata, | |
| }); | |
| const dbCommunity = await Community.findById(res.body.community); | |
| expect(dbCommunity).toMatchObject({ | |
| id: communityOne._id.toHexString(), | |
| name: communityOne.name, | |
| avatarURL: communityOne.avatarURL, | |
| users: [userOne._id], | |
| }); | |
| }); |
| // test('should return 200 and successfully update hivemind module if platform is mediaWiki', async () => { | ||
| // await insertCommunities([communityOne, communityTwo, communityThree]); | ||
| // await insertUsers([userOne, userTwo]); | ||
| // await insertModules([moduleOne, moduleTwo]); | ||
|
|
||
| // updateBody.options = { | ||
| // platforms: [ | ||
| // { | ||
| // platform: platformOne._id, | ||
| // metadata: { | ||
| // pageIds: ['1'], | ||
| // }, | ||
| // name: PlatformNames.MediaWiki, | ||
| // }, | ||
| // ], | ||
| // }; | ||
| // const res = await request(app) | ||
| // .patch(`/api/v1/modules/${moduleTwo._id}`) | ||
| // .set('Authorization', `Bearer ${userOneAccessToken}`) | ||
| // .send(updateBody) | ||
| // .expect(httpStatus.OK); | ||
|
|
||
| // expect(res.body).toEqual({ | ||
| // id: moduleTwo._id.toHexString(), | ||
| // name: moduleTwo.name, | ||
| // community: communityTwo._id.toHexString(), | ||
| // options: { | ||
| // platforms: [ | ||
| // { | ||
| // _id: expect.anything(), | ||
| // platform: expect.anything(), | ||
| // metadata: { | ||
| // answering: { | ||
| // selectedChannels: ['1234'], | ||
| // }, | ||
| // learning: { | ||
| // selectedChannels: ['8765', '1234'], | ||
| // fromDate: new Date('2024-03-18T07:46:51.493+00:00').toISOString(), | ||
| // }, | ||
| // }, | ||
| // name: 'discord', | ||
| // }, | ||
| // { | ||
| // _id: expect.anything(), | ||
| // platform: platformOne._id.toHexString(), | ||
| // metadata: { | ||
| // pageIds: ['1'], | ||
| // }, | ||
| // name: PlatformNames.MediaWiki, | ||
| // }, | ||
| // ], | ||
| // }, | ||
| // }); | ||
|
|
||
| // const dbModule = await Module.findById(res.body.id); | ||
| // expect(dbModule).toBeDefined(); | ||
| // // TODO: fix below code | ||
| // // expect(dbModule?.options).toMatchObject({ | ||
| // // id: moduleOne._id.toHexString(), | ||
| // // name: moduleOne.name, | ||
| // // community: communityOne._id.toHexString(), | ||
| // // options: updateBody.options | ||
| // // }); | ||
| // }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uncomment the test case for PlatformNames.MediaWiki to ensure it is executed and validated.
- // test('should return 200 and successfully update hivemind module if platform is mediaWiki', async () => {
- // await insertCommunities([communityOne, communityTwo, communityThree]);
- // await insertUsers([userOne, userTwo]);
- // await insertModules([moduleOne, moduleTwo]);
- //
- // updateBody.options = {
- // platforms: [
- // {
- // platform: platformOne._id,
- // metadata: {
- // pageIds: ['1'],
- // },
- // name: PlatformNames.MediaWiki,
- // },
- // ],
- // };
- // const res = await request(app)
- // .patch(`/api/v1/modules/${moduleTwo._id}`)
- // .set('Authorization', `Bearer ${userOneAccessToken}`)
- // .send(updateBody)
- // .expect(httpStatus.OK);
- //
- // expect(res.body).toEqual({
- // id: moduleTwo._id.toHexString(),
- // name: moduleTwo.name,
- // community: communityTwo._id.toHexString(),
- // options: {
- // platforms: [
- // {
- // _id: expect.anything(),
- // platform: expect.anything(),
- // metadata: {
- // answering: {
- // selectedChannels: ['1234'],
- // },
- // learning: {
- // selectedChannels: ['8765', '1234'],
- // fromDate: new Date('2024-03-18T07:46:51.493+00:00').toISOString(),
- // },
- // },
- // name: 'discord',
- // },
- // {
- // _id: expect.anything(),
- // platform: platformOne._id.toHexString(),
- // metadata: {
- // pageIds: ['1'],
- // },
- // name: PlatformNames.MediaWiki,
- // },
- // ],
- // },
- // });
- //
- // const dbModule = await Module.findById(res.body.id);
- // expect(dbModule).toBeDefined();
- // // TODO: fix below code
- // // expect(dbModule?.options).toMatchObject({
- // // id: moduleOne._id.toHexString(),
- // // name: moduleOne.name,
- // // community: communityOne._id.toHexString(),
- // // options: updateBody.options
- // // });
- // });Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| // test('should return 200 and successfully update hivemind module if platform is mediaWiki', async () => { | |
| // await insertCommunities([communityOne, communityTwo, communityThree]); | |
| // await insertUsers([userOne, userTwo]); | |
| // await insertModules([moduleOne, moduleTwo]); | |
| // updateBody.options = { | |
| // platforms: [ | |
| // { | |
| // platform: platformOne._id, | |
| // metadata: { | |
| // pageIds: ['1'], | |
| // }, | |
| // name: PlatformNames.MediaWiki, | |
| // }, | |
| // ], | |
| // }; | |
| // const res = await request(app) | |
| // .patch(`/api/v1/modules/${moduleTwo._id}`) | |
| // .set('Authorization', `Bearer ${userOneAccessToken}`) | |
| // .send(updateBody) | |
| // .expect(httpStatus.OK); | |
| // expect(res.body).toEqual({ | |
| // id: moduleTwo._id.toHexString(), | |
| // name: moduleTwo.name, | |
| // community: communityTwo._id.toHexString(), | |
| // options: { | |
| // platforms: [ | |
| // { | |
| // _id: expect.anything(), | |
| // platform: expect.anything(), | |
| // metadata: { | |
| // answering: { | |
| // selectedChannels: ['1234'], | |
| // }, | |
| // learning: { | |
| // selectedChannels: ['8765', '1234'], | |
| // fromDate: new Date('2024-03-18T07:46:51.493+00:00').toISOString(), | |
| // }, | |
| // }, | |
| // name: 'discord', | |
| // }, | |
| // { | |
| // _id: expect.anything(), | |
| // platform: platformOne._id.toHexString(), | |
| // metadata: { | |
| // pageIds: ['1'], | |
| // }, | |
| // name: PlatformNames.MediaWiki, | |
| // }, | |
| // ], | |
| // }, | |
| // }); | |
| // const dbModule = await Module.findById(res.body.id); | |
| // expect(dbModule).toBeDefined(); | |
| // // TODO: fix below code | |
| // // expect(dbModule?.options).toMatchObject({ | |
| // // id: moduleOne._id.toHexString(), | |
| // // name: moduleOne.name, | |
| // // community: communityOne._id.toHexString(), | |
| // // options: updateBody.options | |
| // // }); | |
| // }); | |
| test('should return 200 and successfully update hivemind module if platform is mediaWiki', async () => { | |
| await insertCommunities([communityOne, communityTwo, communityThree]); | |
| await insertUsers([userOne, userTwo]); | |
| await insertModules([moduleOne, moduleTwo]); | |
| updateBody.options = { | |
| platforms: [ | |
| { | |
| platform: platformOne._id, | |
| metadata: { | |
| pageIds: ['1'], | |
| }, | |
| name: PlatformNames.MediaWiki, | |
| }, | |
| ], | |
| }; | |
| const res = await request(app) | |
| .patch(`/api/v1/modules/${moduleTwo._id}`) | |
| .set('Authorization', `Bearer ${userOneAccessToken}`) | |
| .send(updateBody) | |
| .expect(httpStatus.OK); | |
| expect(res.body).toEqual({ | |
| id: moduleTwo._id.toHexString(), | |
| name: moduleTwo.name, | |
| community: communityTwo._id.toHexString(), | |
| options: { | |
| platforms: [ | |
| { | |
| _id: expect.anything(), | |
| platform: expect.anything(), | |
| metadata: { | |
| answering: { | |
| selectedChannels: ['1234'], | |
| }, | |
| learning: { | |
| selectedChannels: ['8765', '1234'], | |
| fromDate: new Date('2024-03-18T07:46:51.493+00:00').toISOString(), | |
| }, | |
| }, | |
| name: 'discord', | |
| }, | |
| { | |
| _id: expect.anything(), | |
| platform: platformOne._id.toHexString(), | |
| metadata: { | |
| pageIds: ['1'], | |
| }, | |
| name: PlatformNames.MediaWiki, | |
| }, | |
| ], | |
| }, | |
| }); | |
| const dbModule = await Module.findById(res.body.id); | |
| expect(dbModule).toBeDefined(); | |
| // TODO: fix below code | |
| // expect(dbModule?.options).toMatchObject({ | |
| // id: moduleOne._id.toHexString(), | |
| // name: moduleOne.name, | |
| // community: communityOne._id.toHexString(), | |
| // options: updateBody.options | |
| // }); | |
| }); |
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Documentation