chat.cy.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // eslint-disable-next-line @typescript-eslint/triple-slash-reference
  2. /// <reference path="../support/index.d.ts" />
  3. // These tests run through the chat flow.
  4. describe('Settings', () => {
  5. // Wait for 2 seconds after all tests to fix an issue with Cypress's video recording missing the last few frames
  6. after(() => {
  7. // eslint-disable-next-line cypress/no-unnecessary-waiting
  8. cy.wait(2000);
  9. });
  10. beforeEach(() => {
  11. // Login as the admin user
  12. cy.loginAdmin();
  13. // Visit the home page
  14. cy.visit('/');
  15. });
  16. context('Ollama', () => {
  17. it('user can select a model', () => {
  18. // Click on the model selector
  19. cy.get('button[aria-label="Select a model"]').click();
  20. // Select the first model
  21. cy.get('div[role="option"][data-value]').first().click();
  22. });
  23. it('user can perform text chat', () => {
  24. // Click on the model selector
  25. cy.get('button[aria-label="Select a model"]').click();
  26. // Select the first model
  27. cy.get('div[role="option"][data-value]').first().click();
  28. // Type a message
  29. cy.get('#chat-textarea').type('Hi, what can you do? A single sentence only please.', {
  30. force: true
  31. });
  32. // Send the message
  33. cy.get('button[type="submit"]').click();
  34. // User's message should be visible
  35. cy.get('.chat-user').should('exist');
  36. // Wait for the response
  37. cy.get('.chat-assistant', { timeout: 120_000 }) // .chat-assistant is created after the first token is received
  38. .find('div[aria-label="Generation Info"]', { timeout: 120_000 }) // Generation Info is created after the stop token is received
  39. .should('exist');
  40. });
  41. });
  42. });