|
| 1 | +import * as fs from 'fs'; |
| 2 | +import { join as joinPath } from 'path'; |
1 | 3 | import { DatabaseHelper } from '../../../../helpers/database';
|
2 | 4 | import { Common } from '../../../../helpers/common';
|
3 | 5 | import { rte } from '../../../../helpers/constants';
|
4 | 6 | import { BrowserPage } from '../../../../pageObjects';
|
5 |
| -import { commonUrl, ossStandaloneConfig } from '../../../../helpers/conf'; |
| 7 | +import { commonUrl, fileDownloadPath, ossStandaloneConfig } from '../../../../helpers/conf'; |
6 | 8 | import { DatabaseAPIRequests } from '../../../../helpers/api/api-database';
|
7 | 9 | import { APIKeyRequests } from '../../../../helpers/api/api-keys';
|
| 10 | +import { StringKeyParameters } from '../../../../pageObjects/browser-page'; |
| 11 | +import { DatabasesActions } from '../../../../common-actions/databases-actions'; |
8 | 12 |
|
9 | 13 | const browserPage = new BrowserPage();
|
10 | 14 | const databaseHelper = new DatabaseHelper();
|
11 | 15 | const databaseAPIRequests = new DatabaseAPIRequests();
|
12 | 16 | const apiKeyRequests = new APIKeyRequests();
|
| 17 | +const databasesActions = new DatabasesActions(); |
13 | 18 |
|
14 | 19 | let keyName = Common.generateWord(10);
|
| 20 | +let bigKeyName = Common.generateWord(10); |
| 21 | +let foundStringDownloadedFiles = 0; |
| 22 | +const downloadedFile = 'string_value'; |
15 | 23 |
|
16 | 24 | fixture `Cases with large data`
|
17 | 25 | .meta({ type: 'critical_path', rte: rte.standalone })
|
@@ -46,3 +54,70 @@ test('Verify that user can see relevant information about key size', async t =>
|
46 | 54 | await t.expect(keySizeText).contains('KB', 'Key measure not correct');
|
47 | 55 | await t.expect(+keySize).gt(10, 'Key size value not correct');
|
48 | 56 | });
|
| 57 | +test |
| 58 | + .before(async() => { |
| 59 | + await databaseHelper.acceptLicenseTermsAndAddDatabaseApi(ossStandaloneConfig); |
| 60 | + }) |
| 61 | + .after(async() => { |
| 62 | + // Clear and delete database |
| 63 | + await apiKeyRequests.deleteKeyByNameApi(keyName, ossStandaloneConfig.databaseName); |
| 64 | + await apiKeyRequests.deleteKeyByNameApi(bigKeyName, ossStandaloneConfig.databaseName); |
| 65 | + await databaseAPIRequests.deleteStandaloneDatabaseApi(ossStandaloneConfig); |
| 66 | + // Delete downloaded file |
| 67 | + const foundDownloadedFiles = await databasesActions.findFilesByFileStarts(fileDownloadPath, downloadedFile); |
| 68 | + fs.unlinkSync(joinPath(fileDownloadPath, foundDownloadedFiles[0])); |
| 69 | + })('Verify that user can download String key value as txt file when it has > 5000 characters', async t => { |
| 70 | + const disabledEditTooltip = 'Load the entire value to edit it'; |
| 71 | + const disabledFormattersTooltip = 'Load the entire value to select a format'; |
| 72 | + keyName = Common.generateWord(10); |
| 73 | + bigKeyName = Common.generateWord(10); |
| 74 | + // Create string key with 5000 characters |
| 75 | + const length = 5000; |
| 76 | + const keyValue = Common.generateWord(length); |
| 77 | + const stringKeyParameters: StringKeyParameters = { |
| 78 | + keyName: keyName, |
| 79 | + value: keyValue |
| 80 | + }; |
| 81 | + const bigStringKeyParameters: StringKeyParameters = { |
| 82 | + keyName: bigKeyName, |
| 83 | + value: keyValue + 1 |
| 84 | + }; |
| 85 | + |
| 86 | + await apiKeyRequests.addStringKeyApi(stringKeyParameters, ossStandaloneConfig); |
| 87 | + await apiKeyRequests.addStringKeyApi(bigStringKeyParameters, ossStandaloneConfig); |
| 88 | + await browserPage.reloadPage(); |
| 89 | + await browserPage.openKeyDetails(keyName); |
| 90 | + await t.expect(browserPage.loadAllBtn.exists).notOk('Load All button displayed for 5000 length String key'); |
| 91 | + await t.expect(browserPage.downloadAllValueBtn.exists).notOk('Download All button displayed for 5000 length String key'); |
| 92 | + |
| 93 | + await browserPage.openKeyDetails(bigKeyName); |
| 94 | + await t.expect(browserPage.editKeyValueButton.hasAttribute('disabled')).ok('Edit button not disabled for String > 5000'); |
| 95 | + await t.expect(browserPage.formatSwitcher.hasAttribute('disabled')).ok('Formatters control not disabled for String > 5000'); |
| 96 | + |
| 97 | + // Verify that user can see "Load the entire value to edit it." tooltip when hovering on disabled edit button before loading all |
| 98 | + await t.hover(browserPage.editKeyValueButton.parent()); |
| 99 | + await t.expect(browserPage.tooltip.textContent).eql(disabledEditTooltip, 'Edit button tooltip contains invalid message'); |
| 100 | + |
| 101 | + // Verify that user can see "Load the entire value to select a format." tooltip when hovering on disabled formatters button before loading all |
| 102 | + await t.hover(browserPage.formatSwitcher); |
| 103 | + await t.expect(browserPage.tooltip.textContent).eql(disabledFormattersTooltip, 'Edit button tooltip contains invalid message'); |
| 104 | + |
| 105 | + // Verify that user can see String key value with only 5000 characters uploaded if length is more than 5000 |
| 106 | + await t.expect((await browserPage.stringKeyValueInput.textContent).length).eql(stringKeyParameters.value.length, 'String key > 5000 value is fully loaded by default'); |
| 107 | + |
| 108 | + await t.click(browserPage.loadAllBtn); |
| 109 | + // Verify that user can see "Load all" button for String Key with more than 5000 characters and see full value by clicking on it |
| 110 | + await t.expect((await browserPage.stringKeyValueInput.textContent).length).eql(bigStringKeyParameters.value.length, 'String key > 5000 value is not fully loaded after clicking Load All'); |
| 111 | + await t.expect(browserPage.editKeyValueButton.hasAttribute('disabled')).notOk('Edit button disabled for String > 5000 which is fully loaded'); |
| 112 | + await t.expect(browserPage.formatSwitcher.hasAttribute('disabled')).notOk('Formatters control disabled for String > 5000 which is fully loaded'); |
| 113 | + |
| 114 | + // Verify that user can see not fully loaded String key with > 5000 characters after clicking on Refresh button |
| 115 | + await t.click(browserPage.refreshKeyButton); |
| 116 | + await t.expect(browserPage.loadAllBtn.exists).ok('Load All button not displayed for 5000 length String key after Refresh'); |
| 117 | + |
| 118 | + // Verify that user can download String key value as txt file when it has > 5000 characters |
| 119 | + await t.click(browserPage.downloadAllValueBtn); |
| 120 | + // Verify that user can see default file name is “string_value” when downloading String key value |
| 121 | + foundStringDownloadedFiles = await databasesActions.getFileCount(fileDownloadPath, downloadedFile); |
| 122 | + await t.expect(foundStringDownloadedFiles).gt(0, 'String value file not saved'); |
| 123 | + }); |
0 commit comments