82 lines
2.0 KiB
TypeScript
82 lines
2.0 KiB
TypeScript
import { INestApplication } from '@nestjs/common';
|
|
import { Test, TestingModule } from '@nestjs/testing';
|
|
import { AccessMode, ToolStatus } from '@prisma/client';
|
|
import { randomUUID } from 'crypto';
|
|
import request from 'supertest';
|
|
import { AppModule } from '../src/app.module';
|
|
import { PrismaService } from '../src/prisma/prisma.service';
|
|
|
|
describe('Tool launch none mode (e2e)', () => {
|
|
let app: INestApplication;
|
|
let prisma: PrismaService;
|
|
let categoryId = '';
|
|
let toolId = '';
|
|
|
|
beforeAll(async () => {
|
|
const moduleFixture: TestingModule = await Test.createTestingModule({
|
|
imports: [AppModule],
|
|
}).compile();
|
|
|
|
app = moduleFixture.createNestApplication();
|
|
await app.init();
|
|
prisma = app.get(PrismaService);
|
|
});
|
|
|
|
beforeEach(async () => {
|
|
categoryId = `cat_${randomUUID().replace(/-/g, '')}`;
|
|
toolId = `tool_${randomUUID().replace(/-/g, '')}`;
|
|
|
|
await prisma.category.create({
|
|
data: {
|
|
id: categoryId,
|
|
name: `Category ${toolId}`,
|
|
},
|
|
});
|
|
|
|
await prisma.tool.create({
|
|
data: {
|
|
id: toolId,
|
|
name: 'Preview Tool',
|
|
slug: `preview-${randomUUID().slice(0, 8)}`,
|
|
categoryId,
|
|
description: 'Preview only tool',
|
|
accessMode: AccessMode.none,
|
|
versionOverride: 'preview-1',
|
|
status: ToolStatus.published,
|
|
updatedAt: '2026-04-14',
|
|
},
|
|
});
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await prisma.tool.deleteMany({
|
|
where: {
|
|
id: toolId,
|
|
},
|
|
});
|
|
await prisma.category.deleteMany({
|
|
where: {
|
|
id: categoryId,
|
|
},
|
|
});
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await app.close();
|
|
});
|
|
|
|
function getHttpServer(): Parameters<typeof request>[0] {
|
|
return app.getHttpServer() as Parameters<typeof request>[0];
|
|
}
|
|
|
|
it('returns 409 when launching a none mode tool', async () => {
|
|
await request(getHttpServer())
|
|
.post(`/tools/${toolId}/launch`)
|
|
.send({
|
|
channel: 'official',
|
|
clientVersion: 'web-1.0.0',
|
|
})
|
|
.expect(409);
|
|
});
|
|
});
|