fix: let the recommended-apps test follow the list it tests

Two commits on main rewrote `RECOMMENDED_APP_NAMES` without touching the test,
which seeds `editor` and `camera` and asserts the result contains them. Neither
is on the list any more, so the resolved set came back empty and `test (base)`
has failed on every PR since.

The test now seeds the first two names off the list itself and asserts on those,
so the next edit to it cannot strand the test: prepending two unknown apps keeps
all four cases green.
This commit is contained in:
Juan Castro committed 2026-10-02 18:05:31 -04:00
1 parent 2f16ee42aa
commit 1ba66caeee
2 files changed
+11 -8

No files matched your search

@@ -3,12 +3,15 @@ import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest';
import { extension, extensionStore } from '../../extensions.js';
import type { PuterServer } from '../../server.js';
import { setupTestServer } from '../../testUtil.js';
import { RECOMMENDED_APP_NAMES } from './RecommendedAppsService.js';
describe('RecommendedAppsService', () => {
let server: PuterServer;
let customApp: Record<string, unknown>;
let defaults: Array<Record<string, unknown>>;
const previousListeners = extensionStore.events['app.recommended'];
// From the list itself, so editing it cannot strand this test.
const [first, second] = RECOMMENDED_APP_NAMES;
beforeAll(async () => {
server = await setupTestServer();
@@ -20,7 +23,7 @@ describe('RecommendedAppsService', () => {
free_storage: 1024,
requires_email_confirmation: false,
});
for (const name of ['editor', 'camera', 'custom-recommendation']) {
for (const name of [first, second, 'custom-recommendation']) {
if (!(await server.stores.app.getByName(name))) {
await server.stores.app.create(
{
@@ -52,8 +55,8 @@ describe('RecommendedAppsService', () => {
const apps = await server.services.recommendedApps.getRecommendedApps();
expect(apps).toEqual(defaults);
const names = apps.map((app) => app.name);
expect(names).toContain('editor');
expect(names.indexOf('editor')).toBeLessThan(names.indexOf('camera'));
expect(names).toContain(first);
expect(names.indexOf(first)).toBeLessThan(names.indexOf(second));
expect(names).not.toContain(customApp.name);
});
@@ -61,18 +64,18 @@ describe('RecommendedAppsService', () => {
extension.on('app.recommended', async (_key, data) => {
await new Promise((resolve) => setTimeout(resolve, 0));
data.appNames = [
'camera',
second,
'custom-recommendation',
'missing-recommendation',
'editor',
first,
];
});
const apps = await server.services.recommendedApps.getRecommendedApps();
expect(apps.map((app) => app.name)).toEqual([
'camera',
second,
'custom-recommendation',
'editor',
first,
]);
expect(apps[1]).toMatchObject({
uuid: customApp.uid,
@@ -26,7 +26,7 @@ import { PuterService } from '../types.js';
* Hardcoded list of recommended apps shown on the desktop launch grid. Resolved
* at call time against the apps table.
*/
const RECOMMENDED_APP_NAMES = [
export const RECOMMENDED_APP_NAMES = [
'builder',
'contacts',
'calendar',