Repository: directus/directus
File: tests/blackbox/tests/db/routes/collections/crud.test.ts (TypeScript)

Code before:
							// Assert
							if (userKey === USER.ADMIN.KEY) {
								expect(response.statusCode).toBe(200);

								expect(response.body.data).toEqual({
									collection: TEST_COLLECTION_NAME,
									meta: expect.objectContaining({
										collection: TEST_COLLECTION_NAME,
									}),
									schema: expect.objectContaining({
										name: TEST_COLLECTION_NAME,
									}),
								});

								expect(await db.schema.hasTable(TEST_COLLECTION_NAME)).toBe(true);
								expect(await db.schema.hasColumn(TEST_COLLECTION_NAME, fieldName)).toBe(true);
								expect(await db.schema.hasColumn(TEST_COLLECTION_NAME, 'id')).toBe(true);
							} else {
								expect(response.statusCode).toBe(403);
							}
						});
					});
				});
			});

			describe('Creates a new collection with fields including primary key', () => {
				TEST_USERS.forEach((userKey) => {
					describe(USER[userKey].NAME, () => {
						it.each(vendors)('%s', async (vendor) => {
							// Setup
							const db = databases.get(vendor)!;
							currentVendor = vendor;
							const pkName = `id_${pkType}`;
							const fieldName = `name_${pkType}`;

							const fields: any = [
								{
									field: fieldName,
									type: 'string',
									meta: { interface: 'input', special: null },
								},
							];

							switch (pkType) {
								case 'uuid':
									fields.push({
										field: pkName,
										type: 'uuid',
										meta: { hidden: true, readonly: true, interface: 'input', special: ['uuid'] },
										schema: { is_primary_key: true, length: 36, has_auto_increment: false },
									});

Review comment (suggestion):
```suggestion
			describe('Creates a new collection with specified primary key in fields array', () => {
```

Code after:
									}),
									schema: expect.objectContaining({
										name: TEST_COLLECTION_NAME,
									}),
								});

								expect(await db.schema.hasTable(TEST_COLLECTION_NAME)).toBe(true);
								expect(await db.schema.hasColumn(TEST_COLLECTION_NAME, 'id')).toBe(true);
							} else {
								expect(response.statusCode).toBe(403);
							}
						});
					});
				});
			});

			describe('Creates a new collection with auto created primary key when no primary key is in the fields array', () => {
				TEST_USERS.forEach((userKey) => {
					describe(USER[userKey].NAME, () => {
						it.each(vendors)('%s', async (vendor) => {
							// Setup
							const db = databases.get(vendor)!;
							currentVendor = vendor;
							const fieldName = `name_${pkType}`;

							const fields = [
								{
									field: fieldName,
									type: 'string',
									meta: { interface: 'input', special: null },
								},
							];

							// Action
							const response = await request(getUrl(vendor))
								.post('/collections')
								.send({ collection: TEST_COLLECTION_NAME, meta: {}, schema: {}, fields })
								.set('Authorization', `Bearer ${USER[userKey].TOKEN}`);

							// Assert
							if (userKey === USER.ADMIN.KEY) {
								expect(response.statusCode).toBe(200);

								expect(response.body.data).toEqual({
									collection: TEST_COLLECTION_NAME,
									meta: expect.objectContaining({
										collection: TEST_COLLECTION_NAME,
									}),
									schema: expect.objectContaining({
										name: TEST_COLLECTION_NAME,
									}),