Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sour-spiders-pay.md
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions apps/meteor/ee/server/apps/communication/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ export class AppsRestApi {
}

return API.v1.success({
app: formatAppInstanceForRest(app),
app: await formatAppInstanceForRest(app),
});
},
async post() {
Expand Down Expand Up @@ -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}`);
},
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/tests/data/apps/apps-data.ts
Original file line number Diff line number Diff line change
@@ -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> = TPath extends `/apps${infer U}` ? U : never;
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/tests/e2e/fixtures/insert-apps.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
const api = await request.newContext();

Expand Down
36 changes: 35 additions & 1 deletion apps/meteor/tests/end-to-end/apps/installation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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(() => {
Expand Down Expand Up @@ -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);
});
Expand All @@ -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);
});
Expand All @@ -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
Expand Down
Loading