|
1 | 1 | import { rte } from '../../../helpers/constants';
|
2 |
| -import { deleteDatabase, acceptTermsAddDatabaseOrConnectToRedisStack } from '../../../helpers/database'; |
| 2 | +import { acceptLicenseTermsAndAddDatabaseApi } from '../../../helpers/database'; |
3 | 3 | import { BrowserPage } from '../../../pageObjects';
|
4 | 4 | import { commonUrl, ossStandaloneConfig } from '../../../helpers/conf';
|
5 |
| -import { Chance } from 'chance'; |
| 5 | +import { Common } from '../../../helpers/common'; |
| 6 | +import { deleteStandaloneDatabaseApi } from '../../../helpers/api/api-database'; |
6 | 7 |
|
7 | 8 | const browserPage = new BrowserPage();
|
8 |
| -const chance = new Chance(); |
| 9 | +const common = new Common(); |
9 | 10 |
|
10 |
| -let keyName = chance.word({ length: 10 }); |
| 11 | +const keyTTL = '2147476121'; |
| 12 | +const keyValueBefore = 'ValueBeforeEdit!'; |
| 13 | +const keyValueAfter = 'ValueAfterEdit!'; |
| 14 | +let keyName = common.generateWord(10); |
11 | 15 |
|
12 | 16 | fixture `Edit Key values verification`
|
13 |
| - .meta({ type: 'smoke' }) |
| 17 | + .meta({ type: 'smoke', rte: rte.standalone }) |
14 | 18 | .page(commonUrl)
|
15 |
| - .beforeEach(async () => { |
16 |
| - await acceptTermsAddDatabaseOrConnectToRedisStack(ossStandaloneConfig, ossStandaloneConfig.databaseName); |
| 19 | + .beforeEach(async() => { |
| 20 | + await acceptLicenseTermsAndAddDatabaseApi(ossStandaloneConfig, ossStandaloneConfig.databaseName); |
17 | 21 | })
|
18 |
| - .afterEach(async () => { |
| 22 | + .afterEach(async() => { |
19 | 23 | //Clear and delete database
|
20 | 24 | await browserPage.deleteKeyByName(keyName);
|
21 |
| - await deleteDatabase(ossStandaloneConfig.databaseName); |
22 |
| - }) |
23 |
| -test |
24 |
| - .meta({ rte: rte.standalone }) |
25 |
| - ('Verify that user can edit String value', async t => { |
26 |
| - keyName = chance.word({ length: 10 }); |
27 |
| - const keyTTL = '2147476121'; |
28 |
| - const keyValueBefore = 'StringValueBeforeEdit!'; |
29 |
| - const keyValueAfter = 'StringValueBeforeEdit!'; |
30 |
| - |
31 |
| - //Add string key |
32 |
| - await browserPage.addStringKey(keyName, keyValueBefore, keyTTL); |
33 |
| - //Check the key value before edit |
34 |
| - let keyValueFromDetails = await browserPage.getStringKeyValue(); |
35 |
| - await t.expect(keyValueFromDetails).contains(keyValueBefore, 'The value of the key'); |
36 |
| - //Edit String key value |
37 |
| - await browserPage.editStringKeyValue(keyValueAfter); |
38 |
| - //Check the key value after edit |
39 |
| - keyValueFromDetails = await browserPage.getStringKeyValue(); |
40 |
| - await t.expect(keyValueFromDetails).contains(keyValueAfter, 'The value of the key'); |
| 25 | + await deleteStandaloneDatabaseApi(ossStandaloneConfig); |
41 | 26 | });
|
| 27 | +test('Verify that user can edit String value', async t => { |
| 28 | + keyName = common.generateWord(10); |
| 29 | + //Add string key |
| 30 | + await browserPage.addStringKey(keyName, keyValueBefore, keyTTL); |
| 31 | + //Check the key value before edit |
| 32 | + let keyValue = await browserPage.getStringKeyValue(); |
| 33 | + await t.expect(keyValue).contains(keyValueBefore, 'The value is incorrect'); |
| 34 | + //Edit String key value |
| 35 | + await browserPage.editStringKeyValue(keyValueAfter); |
| 36 | + //Check the key value after edit |
| 37 | + keyValue = await browserPage.getStringKeyValue(); |
| 38 | + await t.expect(keyValue).contains(keyValueAfter, 'Edited value is incorrect'); |
| 39 | +}); |
| 40 | +test('Verify that user can edit Zset Key member', async t => { |
| 41 | + keyName = common.generateWord(10); |
| 42 | + const scoreBefore = '5'; |
| 43 | + const scoreAfter = '10'; |
| 44 | + //Add zset key |
| 45 | + await browserPage.addZSetKey(keyName, scoreBefore, keyTTL, keyValueBefore); |
| 46 | + //Check the key score before edit |
| 47 | + let zsetScore = await browserPage.getZsetKeyScore(); |
| 48 | + await t.expect(zsetScore).eql(scoreBefore, 'Score is incorrect'); |
| 49 | + //Edit Zset key score |
| 50 | + await browserPage.editZsetKeyScore(scoreAfter); |
| 51 | + //Check Zset key score after edit |
| 52 | + zsetScore = await browserPage.getZsetKeyScore(); |
| 53 | + await t.expect(zsetScore).contains(scoreAfter, 'Score is not edited'); |
| 54 | +}); |
| 55 | +test('Verify that user can edit Hash Key field', async t => { |
| 56 | + const fieldName = 'test'; |
| 57 | + keyName = common.generateWord(10); |
| 58 | + //Add Hash key |
| 59 | + await browserPage.addHashKey(keyName, keyTTL, fieldName, keyValueBefore); |
| 60 | + //Check the key value before edit |
| 61 | + let keyValue = await browserPage.getHashKeyValue(); |
| 62 | + await t.expect(keyValue).eql(keyValueBefore, 'The value is incorrect'); |
| 63 | + //Edit Hash key value |
| 64 | + await browserPage.editHashKeyValue(keyValueAfter); |
| 65 | + //Check Hash key value after edit |
| 66 | + keyValue = await browserPage.getHashKeyValue(); |
| 67 | + await t.expect(keyValue).contains(keyValueAfter, 'Edited value is incorrect'); |
| 68 | +}); |
| 69 | +test('Verify that user can edit List Key element', async t => { |
| 70 | + keyName = common.generateWord(10); |
| 71 | + //Add List key |
| 72 | + await browserPage.addListKey(keyName, keyTTL, keyValueBefore); |
| 73 | + //Check the key value before edit |
| 74 | + let keyValue = await browserPage.getListKeyValue(); |
| 75 | + await t.expect(keyValue).eql(keyValueBefore, 'The value is incorrect'); |
| 76 | + //Edit List key value |
| 77 | + await browserPage.editListKeyValue(keyValueAfter); |
| 78 | + //Check List key value after edit |
| 79 | + keyValue = await browserPage.getListKeyValue(); |
| 80 | + await t.expect(keyValue).contains(keyValueAfter, 'Edited value is incorrect'); |
| 81 | +}); |
| 82 | +test('Verify that user can edit JSON Key value', async t => { |
| 83 | + const jsonValueBefore = '{"name":"xyz"}'; |
| 84 | + const jsonEditedValue = '"xyz test"'; |
| 85 | + const jsonValueAfter = '{name:"xyz test"}'; |
| 86 | + keyName = common.generateWord(10); |
| 87 | + //Add JSON key with json object |
| 88 | + await browserPage.addJsonKey(keyName, jsonValueBefore, keyTTL); |
| 89 | + //Check the key value before edit |
| 90 | + await t.expect(await browserPage.getJsonKeyValue()).eql('{name:"xyz"}', 'The value is incorrect'); |
| 91 | + //Edit JSON key value |
| 92 | + await browserPage.editJsonKeyValue(jsonEditedValue); |
| 93 | + //Check JSON key value after edit |
| 94 | + await t.expect(await browserPage.getJsonKeyValue()).contains(jsonValueAfter, 'Edited value is incorrect'); |
| 95 | +}); |
0 commit comments