From f16f3878b4272b440a6371de635d0c61a1494e6c Mon Sep 17 00:00:00 2001 From: Alexandre Bodin Date: Mon, 2 Sep 2024 16:15:53 +0200 Subject: [PATCH] chore: add compat test --- .../database/v4-self-ref-compat.test.api.js | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/api/core/database/v4-self-ref-compat.test.api.js diff --git a/tests/api/core/database/v4-self-ref-compat.test.api.js b/tests/api/core/database/v4-self-ref-compat.test.api.js new file mode 100644 index 0000000000..0194e51e54 --- /dev/null +++ b/tests/api/core/database/v4-self-ref-compat.test.api.js @@ -0,0 +1,50 @@ +'use strict'; + +// Test an API with all the possible filed types and simple filterings (no deep filtering, no relations) +const { createStrapiInstance } = require('api-tests/strapi'); +const { createTestBuilder } = require('api-tests/builder'); + +const builder = createTestBuilder(); +let strapi; + +const testCT = { + displayName: 'test', + singularName: 'test', + pluralName: 'tests', + kind: 'collectionType', + attributes: { + children: { + type: 'relation', + relation: 'manyToMany', + target: 'api::test.test', + inversedBy: 'parents', + }, + parents: { + type: 'relation', + relation: 'manyToMany', + target: 'api::test.test', + inversedBy: 'children', // intentionnaly wrong to validate retro compatibility + }, + }, +}; + +describe('v4-self-ref-compat', () => { + beforeAll(async () => { + await builder.addContentType(testCT).build(); + + strapi = await createStrapiInstance(); + }); + + afterAll(async () => { + await strapi.destroy(); + await builder.cleanup(); + }); + + test('2 tables are created', async () => { + const hasFirstTable = await strapi.db.getConnection().schema.hasTable('tests_children_lnk'); + const hasSecondTable = await strapi.db.getConnection().schema.hasTable('tests_parents_lnk'); + + expect(hasFirstTable).toBe(true); + expect(hasSecondTable).toBe(true); + }); +});