diff --git a/.changeset/sour-spiders-pay.md b/.changeset/sour-spiders-pay.md new file mode 100644 index 0000000000000..ef3ce2ee8be48 --- /dev/null +++ b/.changeset/sour-spiders-pay.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Fixes the enpoints `GET /api/apps/:id` and `GET /api/apps/:id/status` not returning app's data diff --git a/apps/meteor/ee/server/apps/communication/rest.ts b/apps/meteor/ee/server/apps/communication/rest.ts index c8b7fc9d0872f..32282c78d15cc 100644 --- a/apps/meteor/ee/server/apps/communication/rest.ts +++ b/apps/meteor/ee/server/apps/communication/rest.ts @@ -817,7 +817,7 @@ export class AppsRestApi { } return API.v1.success({ - app: formatAppInstanceForRest(app), + app: await formatAppInstanceForRest(app), }); }, async post() { @@ -1261,11 +1261,11 @@ export class AppsRestApi { ':id/status', { authRequired: true, permissionsRequired: ['manage-apps'] }, { - get() { + async get() { const prl = manager.getOneById(this.urlParams.id); if (prl) { - return API.v1.success({ status: prl.getStatus() }); + return API.v1.success({ status: await prl.getStatus() }); } return API.v1.notFound(`No App found by the id of: ${this.urlParams.id}`); }, diff --git a/apps/meteor/tests/data/apps/apps-data.ts b/apps/meteor/tests/data/apps/apps-data.ts index 30bc3e92b1441..ba6a69bba103f 100644 --- a/apps/meteor/tests/data/apps/apps-data.ts +++ b/apps/meteor/tests/data/apps/apps-data.ts @@ -1,6 +1,6 @@ import type { Path } from '@rocket.chat/rest-typings'; -export const APP_URL = 'https://github.com/RocketChat/Apps.RocketChat.Tester/raw/master/dist/appsrocketchattester_0.1.1.zip?raw=true'; +export const APP_URL = 'https://github.com/RocketChat/Apps.RocketChat.Tester/raw/master/dist/appsrocketchattester_0.3.0.zip?raw=true'; export const APP_NAME = 'Apps.RocketChat.Tester'; type PathWithoutPrefix = TPath extends `/apps${infer U}` ? U : never; diff --git a/apps/meteor/tests/e2e/fixtures/insert-apps.ts b/apps/meteor/tests/e2e/fixtures/insert-apps.ts index 80214074049b6..eaa370e67f1d7 100644 --- a/apps/meteor/tests/e2e/fixtures/insert-apps.ts +++ b/apps/meteor/tests/e2e/fixtures/insert-apps.ts @@ -1,10 +1,9 @@ import { request } from '@playwright/test'; import { Users } from './userStates'; +import { APP_URL } from '../../data/apps/apps-data'; import { BASE_API_URL, BASE_URL } from '../config/constants'; -const APP_URL = 'https://github.com/RocketChat/Apps.RocketChat.Tester/blob/master/dist/appsrocketchattester_0.1.0.zip?raw=true'; - export default async function insertApp(): Promise { const api = await request.newContext(); diff --git a/apps/meteor/tests/end-to-end/apps/installation.ts b/apps/meteor/tests/end-to-end/apps/installation.ts index fc1ea2a0d7f35..4fac049bcae93 100644 --- a/apps/meteor/tests/end-to-end/apps/installation.ts +++ b/apps/meteor/tests/end-to-end/apps/installation.ts @@ -2,7 +2,7 @@ import { expect } from 'chai'; import { after, before, describe, it } from 'mocha'; import { getCredentials, request, credentials, api } from '../../data/api-data'; -import { APP_URL, apps } from '../../data/apps/apps-data'; +import { APP_URL, APP_NAME, apps } from '../../data/apps/apps-data'; import { cleanupApps } from '../../data/apps/helper'; import { updatePermission } from '../../data/permissions.helper'; import { getUserByUsername } from '../../data/users.helper'; @@ -17,6 +17,8 @@ describe('Apps - Installation', () => { after(() => Promise.all([cleanupApps(), updatePermission('manage-apps', ['admin'])])); + let app: any; + describe('[Installation]', () => { it('should throw an error when trying to install an app and the apps framework is enabled but the user does not have the permission', (done) => { void updatePermission('manage-apps', []).then(() => { @@ -51,6 +53,8 @@ describe('Apps - Installation', () => { expect(res.body.app).to.have.a.property('id'); expect(res.body.app).to.have.a.property('version'); expect(res.body.app).to.have.a.property('status').and.to.be.equal('auto_enabled'); + + app = res.body.app; }) .end(done); }); @@ -71,6 +75,8 @@ describe('Apps - Installation', () => { expect(res.body.app).to.have.a.property('id'); expect(res.body.app).to.have.a.property('version'); expect(res.body.app).to.have.a.property('status').and.to.be.equal('initialized'); + + app = res.body.app; }) .end(done); }); @@ -82,6 +88,34 @@ describe('Apps - Installation', () => { }) .then(done); }); + it('should successfully get app details by id', (done) => { + void request + .get(apps(`/${app.id}`)) + .set(credentials) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.a.property('success', true); + expect(res.body).to.have.a.property('app'); + expect(res.body.app).to.have.a.property('name', APP_NAME); + expect(res.body.app).to.have.a.property('version'); + expect(res.body.app).to.have.a.property('status'); + }) + .end(done); + }); + it('should successfully get app status by id', (done) => { + void request + .get(apps(`/${app.id}/status`)) + .set(credentials) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.a.property('success', true); + expect(res.body).to.have.a.property('status'); + expect(res.body.status).to.not.be.empty; + }) + .end(done); + }); (IS_EE ? describe : describe.skip)('Slash commands registration', () => { it('should have created the "test-simple" slash command successfully', (done) => { void request