Skip to content

RI-6570 Verify edit string key operations for in the browsers module #4731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: feature/RI-6570/e2e-playwright-browser-keys-read
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions tests/playwright/pageObjects/browser-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1600,4 +1600,29 @@ export class BrowserPage extends BasePage {
await this.verifyKeyTTL(expectedTTL)
await this.closeKeyDetailsAndVerify()
}

async cancelStringKeyValueEdit(newValue: string): Promise<void> {
await this.editKeyValueButton.click()
await this.stringKeyValueInput.clear()
await this.stringKeyValueInput.fill(newValue)
await this.keyDetailsHeader.click()
}

async waitForKeyLengthToUpdate(expectedLength: string): Promise<void> {
await expect
.poll(async () => {
const keyLength = await this.getKeyLength()
return keyLength
})
.toBe(expectedLength)
}

async waitForStringValueToUpdate(expectedValue: string): Promise<void> {
await expect
.poll(async () => {
const currentValue = await this.getStringKeyValue()
return currentValue
})
.toContain(expectedValue)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { faker } from '@faker-js/faker'

import { BrowserPage } from '../../../pageObjects/browser-page'
import { test, expect } from '../../../fixtures/test'
import { ossStandaloneConfig } from '../../../helpers/conf'
import {
addStandaloneInstanceAndNavigateToIt,
navigateToStandaloneInstance,
} from '../../../helpers/utils'

test.describe('Browser - Edit Key Operations - String Key Editing', () => {
let browserPage: BrowserPage
let keyName: string
let cleanupInstance: () => Promise<void>

test.beforeEach(async ({ page, api: { databaseService } }) => {
browserPage = new BrowserPage(page)
keyName = faker.string.alphanumeric(10)
cleanupInstance = await addStandaloneInstanceAndNavigateToIt(
page,
databaseService,
)

await navigateToStandaloneInstance(page)
})

test.afterEach(async ({ api: { keyService } }) => {
// Clean up: delete the key if it exists
try {
await keyService.deleteKeyByNameApi(
keyName,
ossStandaloneConfig.databaseName,
)
} catch (error) {
// Key might already be deleted in test, ignore error
}

await cleanupInstance()
})

test('should edit string key value successfully', async ({
api: { keyService },
}) => {
// Arrange: Create a string key
const originalValue = faker.lorem.words(3)
const newValue = faker.lorem.words(4)

await keyService.addStringKeyApi(
{ keyName, value: originalValue },
ossStandaloneConfig,
)

// Open key details and verify original value
await browserPage.searchByKeyName(keyName)
await browserPage.openKeyDetailsByKeyName(keyName)

const displayedOriginalValue = await browserPage.getStringKeyValue()
expect(displayedOriginalValue).toContain(originalValue)

// Edit the key value
await browserPage.editStringKeyValue(newValue)

// Wait for value and length to update
await browserPage.waitForStringValueToUpdate(newValue)
await browserPage.waitForKeyLengthToUpdate(newValue.length.toString())
})

test('should cancel string key value edit operation', async ({
api: { keyService },
}) => {
// Arrange: Create a string key
const originalValue = faker.lorem.words(3)
const attemptedNewValue = faker.lorem.words(4)

await keyService.addStringKeyApi(
{ keyName, value: originalValue },
ossStandaloneConfig,
)

// Open key details and verify original value
await browserPage.searchByKeyName(keyName)
await browserPage.openKeyDetailsByKeyName(keyName)

const displayedOriginalValue = await browserPage.getStringKeyValue()
expect(displayedOriginalValue).toContain(originalValue)

// Start editing but cancel
await browserPage.cancelStringKeyValueEdit(attemptedNewValue)

// Verify the original value is still displayed
const displayedValueAfterCancel = await browserPage.getStringKeyValue()
expect(displayedValueAfterCancel).toContain(originalValue)
expect(displayedValueAfterCancel).not.toContain(attemptedNewValue)
})
})
Loading