Skip to content

Commit

Permalink
fix: filtering on gameserverId when searching module installations
Browse files Browse the repository at this point in the history
  • Loading branch information
niekcandaele committed Dec 29, 2024
1 parent c05ea96 commit b03529d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/app-api/src/controllers/Module/installations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ModuleInstallationSearchInputAllowedFilters extends AllowedFilters {
moduleId: string[];
@IsOptional()
@IsUUID('4', { each: true })
gameServerId: string[];
gameserverId: string[];
}

class ModuleInstallationSearchInputDTO extends ITakaroQuery<ModuleInstallationSearchInputAllowedFilters> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { IntegrationTest, expect, SetupGameServerPlayers } from '@takaro/test';
import { randomUUID } from 'crypto';

const group = 'Bug repros';

const tests = [
new IntegrationTest<SetupGameServerPlayers.ISetupData>({
group,
snapshot: false,
setup: SetupGameServerPlayers.setup,
name: 'When searching module installs, filtering by gameserverId works properly',
/**
* Install a module on server A
* Search for installs on server A -> should return 1 result
* Then search for installs on server B -> should return 0 results
*/
test: async function () {
const module = (await this.client.module.moduleControllerCreate({ name: randomUUID() })).data.data;
const gameServerA = this.setupData.gameServer1;
const gameServerB = this.setupData.gameServer2;

await this.client.module.moduleInstallationsControllerInstallModule({
gameServerId: gameServerA.id,
versionId: module.latestVersion.id,
});

const installsA = await this.client.module.moduleInstallationsControllerGetInstalledModules({
filters: { gameserverId: [gameServerA.id] },
});
const installsB = await this.client.module.moduleInstallationsControllerGetInstalledModules({
filters: { gameserverId: [gameServerB.id] },
});

expect(installsA.data.data.length).to.equal(1);
expect(installsB.data.data.length).to.equal(0);
},
}),
];

describe(group, function () {
tests.forEach((test) => {
test.run();
});
});
2 changes: 1 addition & 1 deletion packages/lib-apiclient/src/generated/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5413,7 +5413,7 @@ export interface ModuleInstallationSearchInputAllowedFilters {
* @type {Array<string>}
* @memberof ModuleInstallationSearchInputAllowedFilters
*/
'gameServerId'?: Array<string>;
'gameserverId'?: Array<string>;
/**
*
* @type {Array<string>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const Route = createFileRoute('/_auth/gameserver/$gameServerId/modules')(
context.queryClient.ensureQueryData(modulesQueryOptions()),
context.queryClient.ensureQueryData(
moduleInstallationsOptions({
filters: { gameServerId: [params.gameServerId] },
filters: { gameserverId: [params.gameServerId] },
}),
),
]);
Expand Down Expand Up @@ -56,7 +56,7 @@ export function Component() {
},
{
...moduleInstallationsOptions({
filters: { gameServerId: [gameServerId] },
filters: { gameserverId: [gameServerId] },
}),
initialData: loaderData.installations,
},
Expand Down

0 comments on commit b03529d

Please sign in to comment.