mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 11:01:15 +00:00
fix: Add missing indices on sqlite (#6673)
* fix: enforce tag name uniqueness on sqlite * rename migration and add other missing indices * add tags tests
This commit is contained in:
@@ -24,7 +24,8 @@ export type EndpointGroup =
|
||||
| 'sourceControl'
|
||||
| 'eventBus'
|
||||
| 'license'
|
||||
| 'variables';
|
||||
| 'variables'
|
||||
| 'tags';
|
||||
|
||||
export interface SetupProps {
|
||||
applyAuth?: boolean;
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
NodesController,
|
||||
OwnerController,
|
||||
PasswordResetController,
|
||||
TagsController,
|
||||
UsersController,
|
||||
} from '@/controllers';
|
||||
import { setupAuthMiddlewares } from '@/middlewares';
|
||||
@@ -261,6 +262,14 @@ export const setupTestServer = ({
|
||||
logger,
|
||||
}),
|
||||
);
|
||||
break;
|
||||
case 'tags':
|
||||
registerController(
|
||||
app,
|
||||
config,
|
||||
new TagsController({ config, externalHooks, repositories }),
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
38
packages/cli/test/integration/tags.api.test.ts
Normal file
38
packages/cli/test/integration/tags.api.test.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import * as Db from '@/Db';
|
||||
import * as utils from './shared/utils/';
|
||||
import * as testDb from './shared/testDb';
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
|
||||
let authOwnerAgent: SuperAgentTest;
|
||||
const testServer = utils.setupTestServer({ endpointGroups: ['tags'] });
|
||||
|
||||
beforeAll(async () => {
|
||||
const globalOwnerRole = await testDb.getGlobalOwnerRole();
|
||||
const ownerShell = await testDb.createUserShell(globalOwnerRole);
|
||||
authOwnerAgent = testServer.authAgentFor(ownerShell);
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
await testDb.truncate(['Tag']);
|
||||
});
|
||||
|
||||
describe('POST /tags', () => {
|
||||
test('should create tag', async () => {
|
||||
const resp = await authOwnerAgent.post('/tags').send({ name: 'test' });
|
||||
expect(resp.statusCode).toBe(200);
|
||||
|
||||
const dbTag = await Db.collections.Tag.findBy({ name: 'test' });
|
||||
expect(dbTag.length === 1);
|
||||
});
|
||||
|
||||
test('should not create duplicate tag', async () => {
|
||||
const newTag = Db.collections.Tag.create({ name: 'test' });
|
||||
await Db.collections.Tag.save(newTag);
|
||||
|
||||
const resp = await authOwnerAgent.post('/tags').send({ name: 'test' });
|
||||
expect(resp.status).toBe(500);
|
||||
|
||||
const dbTag = await Db.collections.Tag.findBy({ name: 'test' });
|
||||
expect(dbTag.length).toBe(1);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user