Skip to content

Commit

Permalink
Use a different KB name on each run
Browse files Browse the repository at this point in the history
  • Loading branch information
mpellerin42 committed Dec 19, 2023
1 parent b588fd1 commit 000db35
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
1 change: 0 additions & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ module.exports = defineConfig({
require('cypress-mochawesome-reporter/plugin')(on);
},
env: {
KB_NAME: 'backend-really-sucks',
STANDALONE_KB_NAME: 'standalone-kb',
NUCLIA_DB_ADMIN_URL: 'http://0.0.0.0:8080/admin',
}
Expand Down
26 changes: 13 additions & 13 deletions cypress/e2e/1-basic/kb-creation-flow.cy.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
/// <reference types="cypress" />

import { goTo, goToManageAccount, KB_NAME, onlyPermanentKb } from '../../support/common';
import { goTo, goToManageAccount, onlyPermanentKb } from '../../support/common';

describe('KB creation flow', () => {
before(() => {
onlyPermanentKb();

});

it('should allow to create a new kb', () => {
it('should allow to create a new kb and then delete it', () => {
const newKbName = `new-kb-${Date.now()}`;
cy.login();

// creation test
goToManageAccount();
goTo('go-to-account-kbs');
cy.get('[data-cy="add-kb"]').click();
cy.get('app-kb-add [formcontrolname="title"] input').type(KB_NAME);
cy.get('app-kb-add [formcontrolname="title"] input').type(newKbName);
cy.get('app-kb-add [formcontrolname="description"] textarea').type('Some kb');
cy.get('app-kb-add').contains('Next').click();
cy.get('app-kb-add').contains('Save').click();
cy.get(`[data-cy="${KB_NAME}-link"]`, { timeout: 10000 }).should('contain', KB_NAME);
cy.get(`[data-cy="${KB_NAME}-link"]`).click();
cy.location('pathname').should('equal', `/at/testing/europe-1/${KB_NAME}`);
cy.get('app-kb-switch').should('contain', KB_NAME);
});
cy.get(`[data-cy="${newKbName}-link"]`, { timeout: 10000 }).should('contain', newKbName);
cy.get(`[data-cy="${newKbName}-link"]`).click();
cy.location('pathname').should('equal', `/at/testing/europe-1/${newKbName}`);
cy.get('app-kb-switch').should('contain', newKbName);

it('should allow to delete the kb', () => {
cy.loginToNewKb();
// Deletion test
goToManageAccount();
goTo('go-to-account-kbs');
cy.get(`[data-cy="${KB_NAME}-link"]`).contains(KB_NAME);
cy.get(`[data-cy="${KB_NAME}-delete"]`).click();
cy.get(`[data-cy="${newKbName}-link"]`).contains(newKbName);
cy.get(`[data-cy="${newKbName}-delete"]`).click();
cy.get('[qa="confirmation-dialog-confirm-button"]').click();
cy.get('.account-kbs-list .account-kb').should('have.length', 2);
});
Expand Down
3 changes: 1 addition & 2 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// ***********************************************


import { emptyKb, KB_NAME } from './common';
import { emptyKb } from './common';
function login(kbName = 'permanent') {
cy.visit(`/`, {
onBeforeLoad(win) {
Expand All @@ -24,7 +24,6 @@ function login(kbName = 'permanent') {

// -- This is a parent command --
Cypress.Commands.add('login', () => login());
Cypress.Commands.add('loginToNewKb', () => login(KB_NAME));
Cypress.Commands.add('loginToEmptyKb', () => login(emptyKb.name));


Expand Down
1 change: 0 additions & 1 deletion cypress/support/common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { closeButton, nucliaSearchResultsSelector, viewerSelector } from '../e2e/selectors/widget-selectors';

export const KB_NAME = `new-kb-${Cypress.env('KB_NAME')}`;
export const STANDALONE_KB_NAME = `${Cypress.env('STANDALONE_KB_NAME')}`;
export const STANDALONE_HEADER = {
'X-NUCLIADB-ROLES': 'MANAGER'
Expand Down

0 comments on commit 000db35

Please sign in to comment.