Skip to content

Commit 529bcc1

Browse files
authored
RI-6570 Verify edit string key operations for in the browsers module (#4731)
* added e2e test to verify whether the edit key value functionality is working fine for the string type in the browser module re #RI-6570
1 parent 2948bac commit 529bcc1

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed

tests/playwright/pageObjects/browser-page.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,4 +1693,29 @@ export class BrowserPage extends BasePage {
16931693
expect(displayedTTL).toContain('TTL:')
16941694
expect(displayedTTL).not.toContain('No limit')
16951695
}
1696+
1697+
async cancelStringKeyValueEdit(newValue: string): Promise<void> {
1698+
await this.editKeyValueButton.click()
1699+
await this.stringKeyValueInput.clear()
1700+
await this.stringKeyValueInput.fill(newValue)
1701+
await this.keyDetailsHeader.click()
1702+
}
1703+
1704+
async waitForKeyLengthToUpdate(expectedLength: string): Promise<void> {
1705+
await expect
1706+
.poll(async () => {
1707+
const keyLength = await this.getKeyLength()
1708+
return keyLength
1709+
})
1710+
.toBe(expectedLength)
1711+
}
1712+
1713+
async waitForStringValueToUpdate(expectedValue: string): Promise<void> {
1714+
await expect
1715+
.poll(async () => {
1716+
const currentValue = await this.getStringKeyValue()
1717+
return currentValue
1718+
})
1719+
.toContain(expectedValue)
1720+
}
16961721
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import { faker } from '@faker-js/faker'
2+
3+
import { BrowserPage } from '../../../pageObjects/browser-page'
4+
import { test, expect } from '../../../fixtures/test'
5+
import { ossStandaloneConfig } from '../../../helpers/conf'
6+
import {
7+
addStandaloneInstanceAndNavigateToIt,
8+
navigateToStandaloneInstance,
9+
} from '../../../helpers/utils'
10+
11+
test.describe('Browser - Edit Key Operations - String Key Editing', () => {
12+
let browserPage: BrowserPage
13+
let keyName: string
14+
let cleanupInstance: () => Promise<void>
15+
16+
test.beforeEach(async ({ page, api: { databaseService } }) => {
17+
browserPage = new BrowserPage(page)
18+
keyName = faker.string.alphanumeric(10)
19+
cleanupInstance = await addStandaloneInstanceAndNavigateToIt(
20+
page,
21+
databaseService,
22+
)
23+
24+
await navigateToStandaloneInstance(page)
25+
})
26+
27+
test.afterEach(async ({ api: { keyService } }) => {
28+
// Clean up: delete the key if it exists
29+
try {
30+
await keyService.deleteKeyByNameApi(
31+
keyName,
32+
ossStandaloneConfig.databaseName,
33+
)
34+
} catch (error) {
35+
// Key might already be deleted in test, ignore error
36+
}
37+
38+
await cleanupInstance()
39+
})
40+
41+
test('should edit string key value successfully', async ({
42+
api: { keyService },
43+
}) => {
44+
// Arrange: Create a string key
45+
const originalValue = faker.lorem.words(3)
46+
const newValue = faker.lorem.words(4)
47+
48+
await keyService.addStringKeyApi(
49+
{ keyName, value: originalValue },
50+
ossStandaloneConfig,
51+
)
52+
53+
// Open key details and verify original value
54+
await browserPage.searchByKeyName(keyName)
55+
await browserPage.openKeyDetailsByKeyName(keyName)
56+
57+
const displayedOriginalValue = await browserPage.getStringKeyValue()
58+
expect(displayedOriginalValue).toContain(originalValue)
59+
60+
// Edit the key value
61+
await browserPage.editStringKeyValue(newValue)
62+
63+
// Wait for value and length to update
64+
await browserPage.waitForStringValueToUpdate(newValue)
65+
await browserPage.waitForKeyLengthToUpdate(newValue.length.toString())
66+
})
67+
68+
test('should cancel string key value edit operation', async ({
69+
api: { keyService },
70+
}) => {
71+
// Arrange: Create a string key
72+
const originalValue = faker.lorem.words(3)
73+
const attemptedNewValue = faker.lorem.words(4)
74+
75+
await keyService.addStringKeyApi(
76+
{ keyName, value: originalValue },
77+
ossStandaloneConfig,
78+
)
79+
80+
// Open key details and verify original value
81+
await browserPage.searchByKeyName(keyName)
82+
await browserPage.openKeyDetailsByKeyName(keyName)
83+
84+
const displayedOriginalValue = await browserPage.getStringKeyValue()
85+
expect(displayedOriginalValue).toContain(originalValue)
86+
87+
// Start editing but cancel
88+
await browserPage.cancelStringKeyValueEdit(attemptedNewValue)
89+
90+
// Verify the original value is still displayed
91+
const displayedValueAfterCancel = await browserPage.getStringKeyValue()
92+
expect(displayedValueAfterCancel).toContain(originalValue)
93+
expect(displayedValueAfterCancel).not.toContain(attemptedNewValue)
94+
})
95+
})

0 commit comments

Comments
 (0)