Skip to content

Commit

Permalink
Update e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zorin95670 committed Nov 18, 2024
1 parent f7dfba5 commit b1ad553
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 1 deletion.
57 changes: 57 additions & 0 deletions tests/e2e/features/Configurations.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Feature: Test roundtrip of the application: Configurations

################## List configurations ##################
## 101 Should display all plugins and associated handler
## 102 Should display all handlers configurations

################## Action on handler and plugin #################
## 201 Should successfully create a plugin with an handler
## 202 Should successfully update a plugin with an handler
## 203 Should successfully delete a plugin with an handler

Scenario: Roundtrip about Configurations
Given I visit the '/'
And I set viewport size to '1536' px for width and '960' px for height

When I click on '[data-cy="drawer_item_ai"]'
Then I expect current url is '/ai'

####################################################
################## List configurations #############
####################################################

## 101 Should display all plugins and associated handler
And I expect '[data-cy="default-AI-configuration-card"] [data-cy="select-plugin1"]' exists
And I expect '[data-cy="default-AI-configuration-card"] [data-cy="select-plugin1"]' is "handler1"
And I expect '[data-cy="default-AI-configuration-card"] [data-cy="select-plugin2"]' exists
And I expect '[data-cy="default-AI-configuration-card"] [data-cy="select-plugin2"]' is "handler2"

## 102 Should display all handlers configurations
And I expect '[data-cy="handler1_custom-AI-configuration-card"]' exists
And I expect field '[data-cy="input_handler1_key1"]' is 'value1'
And I expect '[data-cy="expansion-item_handler1_plugin1"]' exists
And I expect '[data-cy="expansion-item_handler1_plugin2"]' exists

And I expect '[data-cy="handler2_custom-AI-configuration-card"]' exists
And I expect field '[data-cy="input_handler2_key2"]' is 'value2'
And I expect '[data-cy="expansion-item_handler2_plugin1"]' exists
And I expect '[data-cy="expansion-item_handler2_plugin2"]' exists

####################################################
################## Action on handler and plugin ####
####################################################

## 201 Should successfully create a plugin with an handler
When I set on '[data-cy="input-new-plugin-name"]' text 'plugin3'
And I select '[data-cy="item_handler1"]' in '[data-cy="select-new-plugin-handler"]'
And I click on '[data-cy="default-AI-configuration-card"] [data-cy="button_save-plugin"]'
Then I expect 'positive' toast to appear with text 'Configuration is added.'

## 202 Should successfully update a plugin with an handler
When I select '[data-cy="item_handler2"]' in '[data-cy="select-plugin1"]'
And I click on '[data-cy="default-AI-configuration-card"] [data-cy="button_update"]'
Then I expect 'positive' toast to appear with text 'Configuration is updated.'

## 203 Should successfully delete a plugin with an handler
When I click on '[data-cy="default-AI-configuration-card"] [data-cy="button_plugin1_delete"]'
Then I expect 'positive' toast to appear with text 'Configuration is deleted.'
1 change: 0 additions & 1 deletion tests/e2e/features/Secrets.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ Feature: Test roundtrip of the application: Secrets
## 101 Should display all secrets
And I expect '[data-cy="secrets_table"] tbody tr' appear 2 times on screen
And I expect '[data-cy="secrets_table"] tbody tr:nth-child(1) td.secret-key' is 'SONAR_TOKEN'

And I expect '[data-cy="secrets_table"] tbody tr:nth-child(2) td.secret-key' is 'GEMINI_TOKEN'

####################################################
Expand Down
100 changes: 100 additions & 0 deletions tests/e2e/support/step_definitions/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,54 @@ const secret2 = {
updateDate: '2024-10-23T15:00:00.000+00:00',
};

const configurations = [{
id: 'id_1',
handler: '',
key: 'plugin.preferences.plugin1',
value: 'handler1',
}, {
id: 'id_2',
handler: '',
key: 'plugin.preferences.plugin2',
value: 'handler2',
}, {
id: 'id_3',
handler: 'handler1',
key: 'key1',
value: 'value1',
}, {
id: 'id_4',
handler: 'handler2',
key: 'key2',
value: 'value2',
}];
const descriptions = {
handler1: [{
handler: 'handler1',
key: 'key1',
type: 'text',
values: [],
defaultValue: 'value',
label: 'Label',
title: 'Title',
description: 'Description',
pluginDependent: false,
required: true,
}],
handler2: [{
handler: 'handler2',
key: 'key2',
type: 'text',
values: [],
defaultValue: 'value',
label: 'Label',
title: 'Title',
description: 'Description',
pluginDependent: false,
required: true,
}],
};

/**
* User-specific intercepts
*/
Expand Down Expand Up @@ -1011,12 +1059,64 @@ function setSecretIntercepts() {
});
}

/**
* Configuration-specific intercepts
*/
function setConfigurationIntercepts() {
cy.intercept('GET', '/api/ai/configurations', (request) => {
request.reply({
statusCode: 200,
body: {
...defaultResponse,
content: configurations,
},
});
});

cy.intercept('GET', '/api/ai/proxy/descriptions', (request) => {
request.reply({
statusCode: 200,
body: descriptions,
});
});

cy.intercept('POST', '/api/ai/configurations', (request) => {
request.reply({
statusCode: 200,
body: {
id: '1',
},
});
});

cy.intercept('PUT', '/api/ai/configurations', (request) => {
request.reply({
statusCode: 200,
body: [],
});
});

cy.intercept('PUT', '/api/ai/configurations/*', (request) => {
request.reply({
statusCode: 200,
body: {
id: '1',
},
});
});

cy.intercept('DELETE', '/api/ai/configurations/*', (request) => {
request.reply({ statusCode: 204 });
});
}

Before(() => {
setUserIntercepts();
setGroupIntercepts();
setRoleIntercepts();
setLibraryIntercepts();
setSecretIntercepts();
setConfigurationIntercepts();

cy.intercept('GET', '/api/permissions', {
statusCode: 200,
Expand Down

0 comments on commit b1ad553

Please sign in to comment.