DSingh0304 commented on code in PR #3245: URL: https://github.com/apache/apisix-dashboard/pull/3245#discussion_r2563932681
########## e2e/tests/secrets.crud-required-fields.spec.ts: ########## @@ -0,0 +1,148 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { secretsPom } from '@e2e/pom/secrets'; +import { e2eReq } from '@e2e/utils/req'; +import { test } from '@e2e/utils/test'; +import { expect } from '@playwright/test'; + +import { API_SECRETS } from '@/config/constant'; + +let createdSecretId: string; +const manager = 'vault'; + +test.describe('CRUD secret with required fields only (Vault)', () => { + test.describe.configure({ mode: 'serial' }); + + test.beforeAll(async () => { + createdSecretId = 'test-vault-secret-required'; + }); + + test.afterAll(async () => { + // cleanup: delete the secret + if (createdSecretId) { + await e2eReq.delete(`${API_SECRETS}/${manager}/${createdSecretId}`).catch(() => { + // ignore error if secret doesn't exist + }); + } + }); + + test('should create a secret with required fields', async ({ page }) => { + await test.step('create secret via UI', async () => { + await secretsPom.toIndex(page); + await secretsPom.getAddSecretBtn(page).click(); + await secretsPom.isAddPage(page); + + await page.getByLabel('ID').fill(createdSecretId); + + // Vault is default + await page.getByLabel('URI').fill('http://vault.example.com:8200'); + await page.getByLabel('Prefix').fill('/secret/test'); + await page.getByLabel('Token').fill('test-vault-token-123'); + + await secretsPom.getAddBtn(page).click(); + }); + + await test.step('verify secret appears in UI', async () => { + await secretsPom.isIndexPage(page); + const row = page.locator('tr').filter({ hasText: createdSecretId }); + await expect(row).toBeVisible(); + }); + }); + + test('should read/view the secret details', async ({ page }) => { + await test.step('navigate to secret details page and verify UI', async () => { + await secretsPom.toIndex(page); + await secretsPom.isIndexPage(page); + + // Find and click the View button for the created secret + const row = page.locator('tr').filter({ hasText: createdSecretId }); + await row.getByRole('button', { name: 'View' }).click(); + await secretsPom.isDetailPage(page); + + // Assert Vault field values using input selectors + await expect(page.getByLabel('URI')).toHaveValue('http://vault.example.com:8200'); + await expect(page.getByLabel('Prefix')).toHaveValue('/secret/test'); + await expect(page.getByLabel('Token')).toHaveValue('test-vault-token-123'); Review Comment: I've refactored this file as well to use an object map for the updates and assertions. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
