Repository: directus/directus
File: tests/blackbox/tests/db/routes/items/no-relation.test.ts (TypeScript)

Code before:
								},
								group: true,
							},
						},
					});

					// Assert
					expect(response.statusCode).toBe(200);
					expect(response.body.data.length).toBe(dates.length);

					for (const item of response.body.data) {
						expect(dates.map((d) => new Date(d).getFullYear())).toContain(Number(item.date_published_year));
						expect(parseInt(item.count.id)).toBe(2);
					}

					expect(gqlResponse.statusCode).toBe(200);
					expect(gqlResponse.body.data[queryKey].length).toBe(dates.length);

					for (const item of gqlResponse.body.data[queryKey]) {
						expect(dates.map((d) => new Date(d).getFullYear())).toContain(Number(item.group.date_published_year));
						expect(parseInt(item.count.id)).toBe(2);
					}
				});
			});

			describe('group by multiple fields', () => {
				it.each(vendors)('%s', async (vendor) => {
					// Setup
					const artistName = 'aggregate-group-multiple-field';
					const groups = ['admin', 'editor', 'viewer'] as const;
					const dates = ['2024-02-01', '2025-02-02', '2026-02-03'] as const;
					const artists = [];

					for (let i = 0; i < 6; i++) {
						const artist = {
							...createArtist(pkType),
							name: artistName,
							date_published: dates[i % dates.length],
							group: groups[i % groups.length],
						};

						artists.push(artist);
					}

					await CreateItem(vendor, { collection: localCollectionArtists, item: artists });

					// Action
					const response = await request(getUrl(vendor))
						.get(`/items/${localCollectionArtists}`)
						.query({
							aggregate: {

Review comment (suggestion):
Optional: we could strengthen the multi-group BB test by mixing a regular field with a function field - e.g. `groupBy: ['group', 'year(date_published)']` - since that's the path most likely to regress. Not blocking though.

Code after:
								},
								group: true,
							},
						},
					});

					// Assert
					expect(response.statusCode).toBe(200);
					expect(response.body.data.length).toBe(dates.length);

					for (const item of response.body.data) {
						expect(dates.map((d) => new Date(d).getFullYear())).toContain(Number(item.date_published_year));
						expect(parseInt(item.count.id)).toBe(2);
					}

					expect(gqlResponse.statusCode).toBe(200);
					expect(gqlResponse.body.data[queryKey].length).toBe(dates.length);

					for (const item of gqlResponse.body.data[queryKey]) {
						expect(dates.map((d) => new Date(d).getFullYear())).toContain(Number(item.group.date_published_year));
						expect(parseInt(item.count.id)).toBe(2);
					}
				});
			});

			describe('group by multiple regular fields', () => {
				it.each(vendors)('%s', async (vendor) => {
					// Setup
					const artistName = 'aggregate-group-multiple-field';
					const groups = ['admin', 'editor', 'viewer'] as const;
					const dates = ['2024-02-01', '2025-02-02', '2026-02-03'] as const;
					const artists = [];

					for (let i = 0; i < 6; i++) {
						const artist = {
							...createArtist(pkType),
							name: artistName,
							date_published: dates[i % dates.length],
							group: groups[i % groups.length],
						};

						artists.push(artist);
					}

					await CreateItem(vendor, { collection: localCollectionArtists, item: artists });

					// Action
					const response = await request(getUrl(vendor))
						.get(`/items/${localCollectionArtists}`)
						.query({
							aggregate: {