test: add initial Cypress e2e test infrastructure
Smoke tests for verifying Cypress runs, plus basic API tests for health and sessions endpoints.
This commit is contained in:
12
cypress.config.js
Normal file
12
cypress.config.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const { defineConfig } = require('cypress');
|
||||
|
||||
module.exports = defineConfig({
|
||||
e2e: {
|
||||
supportFile: 'cypress/support/e2e.js',
|
||||
specPattern: 'cypress/e2e/**/*.cy.{js,ts}',
|
||||
defaultCommandTimeout: 10000,
|
||||
requestTimeout: 10000,
|
||||
video: false,
|
||||
screenshotOnRunFailure: true,
|
||||
},
|
||||
});
|
||||
30
cypress/e2e/api/health.cy.js
Normal file
30
cypress/e2e/api/health.cy.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
describe('Session Manager API', () => {
|
||||
describe('Health Check', () => {
|
||||
it('should respond to the health endpoint', () => {
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: '/api/health',
|
||||
failOnStatusCode: false,
|
||||
}).then((response) => {
|
||||
// The endpoint should exist and return a response
|
||||
expect(response.status).to.be.oneOf([200, 503]);
|
||||
expect(response.body).to.be.an('object');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Sessions API', () => {
|
||||
it('should list sessions', () => {
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: '/api/sessions',
|
||||
failOnStatusCode: false,
|
||||
}).then((response) => {
|
||||
expect(response.status).to.eq(200);
|
||||
expect(response.body).to.be.an('object');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
58
cypress/e2e/smoke.cy.js
Normal file
58
cypress/e2e/smoke.cy.js
Normal file
@@ -0,0 +1,58 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
/**
|
||||
* Smoke test to verify that the Cypress test infrastructure is
|
||||
* correctly installed and configured. These tests do NOT require
|
||||
* the lovdata-chat stack to be running.
|
||||
*/
|
||||
describe('Cypress Infrastructure Smoke Test', () => {
|
||||
it('should execute a basic assertion', () => {
|
||||
expect(true).to.be.true;
|
||||
});
|
||||
|
||||
it('should handle arrays and objects', () => {
|
||||
const session = {
|
||||
id: 'test-session-001',
|
||||
status: 'running',
|
||||
model: 'opencode/kimi-k2.5-free',
|
||||
};
|
||||
|
||||
expect(session).to.have.property('id');
|
||||
expect(session.status).to.eq('running');
|
||||
expect(session.model).to.include('kimi');
|
||||
});
|
||||
|
||||
it('should validate the allowed models whitelist structure', () => {
|
||||
const allowedModels = [
|
||||
{
|
||||
id: 'opencode/kimi-k2.5-free',
|
||||
display_name: 'Kimi K2.5',
|
||||
provider: 'zen',
|
||||
is_reasoning: false,
|
||||
is_default: true,
|
||||
},
|
||||
{
|
||||
id: 'anthropic/claude-sonnet-4-thinking',
|
||||
display_name: 'Claude Sonnet 4 (Thinking)',
|
||||
provider: 'zen',
|
||||
is_reasoning: true,
|
||||
thinking_budget_default: 10000,
|
||||
thinking_budget_max: 50000,
|
||||
},
|
||||
];
|
||||
|
||||
expect(allowedModels).to.have.length(2);
|
||||
|
||||
const defaultModel = allowedModels.find((m) => m.is_default);
|
||||
expect(defaultModel).to.exist;
|
||||
expect(defaultModel.id).to.eq('opencode/kimi-k2.5-free');
|
||||
|
||||
const reasoningModels = allowedModels.filter((m) => m.is_reasoning);
|
||||
expect(reasoningModels).to.have.length(1);
|
||||
expect(reasoningModels[0]).to.have.property('thinking_budget_default');
|
||||
expect(reasoningModels[0]).to.have.property('thinking_budget_max');
|
||||
expect(reasoningModels[0].thinking_budget_max).to.be.greaterThan(
|
||||
reasoningModels[0].thinking_budget_default
|
||||
);
|
||||
});
|
||||
});
|
||||
5
cypress/support/e2e.js
Normal file
5
cypress/support/e2e.js
Normal file
@@ -0,0 +1,5 @@
|
||||
// Cypress E2E support file
|
||||
// Add custom commands and global hooks here
|
||||
|
||||
// Prevent Cypress from failing on uncaught exceptions from the app
|
||||
Cypress.on('uncaught:exception', () => false);
|
||||
2203
package-lock.json
generated
Normal file
2203
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
25
package.json
Normal file
25
package.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "lovdata-chat",
|
||||
"version": "1.0.0",
|
||||
"description": "A web-based chat interface that allows users to interact with Large Language Models (LLMs) equipped with Norwegian legal research tools from the Lovdata MCP server.",
|
||||
"main": "index.js",
|
||||
"directories": {
|
||||
"doc": "docs"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "cypress run",
|
||||
"cypress:open": "cypress open",
|
||||
"cypress:run": "cypress run"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "ssh://git@gitea.torbjorn.org:2222/torbjorn/lovdata-chat.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"type": "commonjs",
|
||||
"devDependencies": {
|
||||
"cypress": "^15.10.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user