Skip to content

Commit e4c5fed

Browse files
move triggers and functions tests
1 parent b3dcc93 commit e4c5fed

File tree

2 files changed

+180
-146
lines changed

2 files changed

+180
-146
lines changed

tests/e2e/tests/critical-path/triggers-and-functions/libraries.e2e.ts

Lines changed: 1 addition & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,23 @@ import {
66
TriggersAndFunctionsLibrariesPage
77
} from '../../../pageObjects';
88
import { commonUrl, ossStandaloneRedisGears } from '../../../helpers/conf';
9-
import { FunctionsSections, LibrariesSections, MonacoEditorInputs, rte } from '../../../helpers/constants';
9+
import { rte } from '../../../helpers/constants';
1010
import { DatabaseAPIRequests } from '../../../helpers/api/api-database';
11-
import { TriggersAndFunctionLibrary } from '../../../interfaces/triggers-and-functions';
12-
import { CommonElementsActions } from '../../../common-actions/common-elements-actions';
1311
import { Common } from '../../../helpers/common';
14-
import { APIKeyRequests } from '../../../helpers/api/api-keys';
1512

1613
const browserPage = new BrowserPage();
1714
const databaseHelper = new DatabaseHelper();
1815
const databaseAPIRequests = new DatabaseAPIRequests();
19-
const apiKeyRequests = new APIKeyRequests();
2016
const triggersAndFunctionsLibrariesPage = new TriggersAndFunctionsLibrariesPage();
2117
const triggersAndFunctionsFunctionsPage = new TriggersAndFunctionsFunctionsPage();
2218

2319
const libraryName = Common.generateWord(5);
24-
const streamKeyName = Common.generateWord(5);
2520

2621
const filePathes = {
2722
upload: path.join('..', '..', '..', 'test-data', 'triggers-and-functions', 'library.txt'),
2823
invoke: path.join('..', '..', '..', 'test-data', 'triggers-and-functions', 'invoke_function.txt')
2924
};
3025

31-
const LIBRARIES_LIST = [
32-
{ name: 'Function1', type: LibrariesSections.Functions },
33-
{ name: 'function2', type: LibrariesSections.Functions },
34-
{ name: 'AsyncFunction', type: LibrariesSections.Functions },
35-
{ name: 'StreamTrigger', type: LibrariesSections.StreamFunctions },
36-
{ name: 'ClusterFunction', type: LibrariesSections.ClusterFunctions },
37-
{ name: 'keySpaceTrigger', type: LibrariesSections.KeyspaceTriggers }
38-
];
39-
4026
fixture `Triggers and Functions`
4127
.meta({ type: 'critical_path', rte: rte.standalone })
4228
.page(commonUrl)
@@ -48,114 +34,6 @@ fixture `Triggers and Functions`
4834
await browserPage.Cli.sendCommandInCli(`TFUNCTION DELETE ${libraryName}`);
4935
await databaseAPIRequests.deleteStandaloneDatabaseApi(ossStandaloneRedisGears);
5036
});
51-
52-
test('Verify that when user can see added library', async t => {
53-
54-
const item = { name: libraryName, user: 'default', pending: 0, totalFunctions: 1 } as TriggersAndFunctionLibrary;
55-
const command = `TFUNCTION LOAD "#!js api_version=1.0 name=${libraryName}\\n redis.registerFunction(\'foo\', ()=>{return \'bar\'})"`;
56-
await browserPage.Cli.sendCommandInCli(command);
57-
await t.click(browserPage.NavigationPanel.triggeredFunctionsButton);
58-
await t.click(triggersAndFunctionsFunctionsPage.librariesLink);
59-
const row = await triggersAndFunctionsLibrariesPage.getLibraryItem(libraryName);
60-
await t.expect(row.name).eql(item.name, 'library name is unexpected');
61-
await t.expect(row.user).eql(item.user, 'user name is unexpected');
62-
await t.expect(row.pending).eql(item.pending, 'user name is unexpected');
63-
await t.expect(row.totalFunctions).eql(item.totalFunctions, 'user name is unexpected');
64-
});
65-
66-
test('Verify that library details is displayed', async t => {
67-
const command = `TFUNCTION LOAD "#!js api_version=1.0 name=${libraryName}\\n
68-
redis.registerFunction('${LIBRARIES_LIST[0].name}', function(){});
69-
redis.registerFunction('${LIBRARIES_LIST[1].name}', function(){});
70-
redis.registerAsyncFunction('${LIBRARIES_LIST[2].name}', function(){});
71-
redis.registerStreamTrigger('${LIBRARIES_LIST[3].name}', 'name', function(){});
72-
redis.registerClusterFunction('${LIBRARIES_LIST[4].name}', async function(){});
73-
redis.registerKeySpaceTrigger('${LIBRARIES_LIST[5].name}','',function(){});"`;
74-
75-
await browserPage.Cli.sendCommandInCli(command);
76-
77-
await t.click(browserPage.NavigationPanel.triggeredFunctionsButton);
78-
await t.click(triggersAndFunctionsFunctionsPage.librariesLink);
79-
await t.click(await triggersAndFunctionsLibrariesPage.getLibraryNameSelector(libraryName));
80-
81-
for (const { name, type } of LIBRARIES_LIST) {
82-
await t.expect(await triggersAndFunctionsLibrariesPage.getFunctionsByName(type, name).exists).ok(`library is not displayed in ${type} section`);
83-
}
84-
});
85-
86-
test('Verify that user can modify code', async t => {
87-
const command = `TFUNCTION LOAD "#!js api_version=1.0 name=${libraryName}\\n redis.registerFunction(\'foo\', ()=>{return \'bar\'});"`;
88-
const commandUpdatedPart1 = `#!js api_version=1.0 name=${libraryName}`;
89-
const commandUpdatedPart2 = ' redis.registerFunction(\'foo\', ()=>{return \'bar new\'});';
90-
const configuration = '{"redisgears_2.lock-redis-timeout": 1000}';
91-
92-
await browserPage.Cli.sendCommandInCli(command);
93-
await t.click(browserPage.NavigationPanel.triggeredFunctionsButton);
94-
await t.click(triggersAndFunctionsFunctionsPage.librariesLink);
95-
await t.click(await triggersAndFunctionsLibrariesPage.getLibraryNameSelector(libraryName));
96-
await t.click(triggersAndFunctionsLibrariesPage.editMonacoButton);
97-
await triggersAndFunctionsLibrariesPage.sendTextToMonaco(MonacoEditorInputs.Library, commandUpdatedPart1, commandUpdatedPart2);
98-
await t.click(triggersAndFunctionsLibrariesPage.acceptButton);
99-
await t.expect(
100-
(await triggersAndFunctionsLibrariesPage.getTextFromMonaco())).eql(commandUpdatedPart1 + commandUpdatedPart2), 'code was not updated';
101-
102-
await t.click(await triggersAndFunctionsLibrariesPage.configurationLink);
103-
await t.click(triggersAndFunctionsLibrariesPage.editMonacoButton);
104-
await triggersAndFunctionsLibrariesPage.sendTextToMonaco(MonacoEditorInputs.LibraryConfiguration, configuration);
105-
await t.click(triggersAndFunctionsLibrariesPage.acceptButton);
106-
await t.expect(
107-
(await triggersAndFunctionsLibrariesPage.getTextFromMonaco())).eql(configuration, 'configuration was not added');
108-
});
109-
110-
test('Verify that function details is displayed', async t => {
111-
const command = `TFUNCTION LOAD "#!js api_version=1.0 name=${libraryName}\\n
112-
redis.registerAsyncFunction('${LIBRARIES_LIST[2].name}', function(client){
113-
return client.call('ping');},{flags: [redis.functionFlags.RAW_ARGUMENTS]});"`;
114-
const functionDetails = { libraryName: libraryName, isAsync: 'isAsync:Yes', flag: 'raw-arguments' };
115-
116-
await browserPage.Cli.sendCommandInCli(command);
117-
await t.click(browserPage.NavigationPanel.triggeredFunctionsButton);
118-
await t.click(await triggersAndFunctionsFunctionsPage.getFunctionsNameSelector(LIBRARIES_LIST[2].name));
119-
let fieldsAndValue = await triggersAndFunctionsFunctionsPage.getFieldsAndValuesBySection(FunctionsSections.General);
120-
await t.expect(fieldsAndValue).contains(functionDetails.libraryName, 'library name is not corrected');
121-
await t.expect(fieldsAndValue).contains(functionDetails.isAsync, 'async is not corrected');
122-
123-
fieldsAndValue = await triggersAndFunctionsFunctionsPage.getFieldsAndValuesBySection(FunctionsSections.Flag);
124-
await t.expect(fieldsAndValue).contains(functionDetails.flag, 'flag name is not displayed');
125-
});
126-
test('Verify that library and functions can be deleted', async t => {
127-
128-
const libraryName2 = `${libraryName}2`;
129-
const command1 = `TFUNCTION LOAD "#!js api_version=1.0 name=${libraryName}\\n redis.registerFunction(\'${LIBRARIES_LIST[0].name}\', ()=>{return \'bar\'})"`;
130-
const command2 = `TFUNCTION LOAD "#!js api_version=1.0 name=${libraryName2}\\n redis.registerFunction(\'${LIBRARIES_LIST[1].name}\', ()=>{return \'bar\'})"`;
131-
await browserPage.Cli.sendCommandInCli(command1);
132-
await browserPage.Cli.sendCommandInCli(command2);
133-
await t.click(await browserPage.NavigationPanel.triggeredFunctionsButton);
134-
await t.click(await triggersAndFunctionsFunctionsPage.librariesLink);
135-
await triggersAndFunctionsLibrariesPage.deleteLibraryByName(libraryName2);
136-
await t.expect(await triggersAndFunctionsLibrariesPage.getLibraryNameSelector(libraryName2).exists).notOk(`the library ${libraryName2} was not deleted`);
137-
await t.click(triggersAndFunctionsLibrariesPage.functionsLink);
138-
await t.expect(await triggersAndFunctionsFunctionsPage.getFunctionsNameSelector(LIBRARIES_LIST[1].name).exists).notOk(`the functions ${LIBRARIES_LIST[1].name} was not deleted`);
139-
});
140-
test('Verify that library can be uploaded', async t => {
141-
const configuration = '{"redisgears_2.lock-redis-timeout": 1000}';
142-
const functionNameFromFile = 'function';
143-
const libNameFromFile = 'lib';
144-
145-
await t.click(browserPage.NavigationPanel.triggeredFunctionsButton);
146-
await t.expect(triggersAndFunctionsFunctionsPage.noLibrariesLink.exists).ok('no libraries title is displayed');
147-
await t.click(triggersAndFunctionsFunctionsPage.librariesLink);
148-
await t.click(triggersAndFunctionsLibrariesPage.addLibraryButton);
149-
await t.setFilesToUpload(triggersAndFunctionsLibrariesPage.uploadInput, [filePathes.upload]);
150-
const uploadedText = await triggersAndFunctionsLibrariesPage.getTextFromMonaco();
151-
await t.expect(uploadedText.length).gte(1, 'file was not uploaded');
152-
await CommonElementsActions.checkCheckbox(triggersAndFunctionsLibrariesPage.addConfigurationCheckBox, true);
153-
await triggersAndFunctionsLibrariesPage.sendTextToMonaco(MonacoEditorInputs.Configuration, configuration);
154-
await t.click(await triggersAndFunctionsLibrariesPage.addLibrarySubmitButton);
155-
await t.expect(triggersAndFunctionsLibrariesPage.getLibraryNameSelector(libNameFromFile).exists).ok('the library was not added');
156-
await t.expect(triggersAndFunctionsLibrariesPage.getFunctionsByName(LibrariesSections.Functions, functionNameFromFile).exists).ok('the library information was not opened');
157-
});
158-
15937
test('Verify that function can be invoked', async t => {
16038
const functionNameFromFile = 'function';
16139
const libNameFromFile = 'lib';
@@ -177,26 +55,3 @@ test('Verify that function can be invoked', async t => {
17755
await t.expect(await triggersAndFunctionsFunctionsPage.Cli.getExecutedCommandTextByIndex()).eql(expectedCommand);
17856
await t.click(triggersAndFunctionsFunctionsPage.Cli.cliCollapseButton);
17957
});
180-
181-
test.after(async() => {
182-
await apiKeyRequests.deleteKeyByNameApi(streamKeyName, ossStandaloneRedisGears.databaseName);
183-
await browserPage.Cli.sendCommandInCli(`TFUNCTION DELETE ${libraryName}`);
184-
await databaseAPIRequests.deleteStandaloneDatabaseApi(ossStandaloneRedisGears);
185-
})('Verify that user can open a Stream key from function', async t => {
186-
const command1 = `#!js api_version=1.0 name=${libraryName}`;
187-
const command2 = `redis.registerStreamTrigger('${LIBRARIES_LIST[3].name}', 'name', function(){});`;
188-
189-
await browserPage.addStreamKey(streamKeyName, 'keyField', 'keyValue');
190-
await t.click(browserPage.NavigationPanel.triggeredFunctionsButton);
191-
await t.click(triggersAndFunctionsFunctionsPage.librariesLink);
192-
await t.click(triggersAndFunctionsLibrariesPage.addLibraryButton);
193-
await triggersAndFunctionsLibrariesPage.sendTextToMonaco(MonacoEditorInputs.Code, command1, command2);
194-
await t.click(triggersAndFunctionsLibrariesPage.addLibrarySubmitButton);
195-
await t.click(triggersAndFunctionsLibrariesPage.functionsLink);
196-
await t.click(triggersAndFunctionsFunctionsPage.getFunctionsNameSelector(LIBRARIES_LIST[3].name));
197-
await t.click(triggersAndFunctionsFunctionsPage.invokeButton);
198-
await t.typeText(triggersAndFunctionsFunctionsPage.keyNameStreamFunctions, `${streamKeyName}*`);
199-
await t.click(triggersAndFunctionsFunctionsPage.findKeyButton);
200-
await t.expect(await browserPage.isKeyIsDisplayedInTheList(streamKeyName)).ok('The stream key is not opened');
201-
await t.expect(browserPage.keyDetailsBadge.exists).ok('The key details is not opened');
202-
});

0 commit comments

Comments
 (0)