|
| 1 | +/** |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | +import { sslsPom } from '@e2e/pom/ssls'; |
| 18 | +import { test } from '@e2e/utils/test'; |
| 19 | +import { uiCheckLabels, uiFillLabels } from '@e2e/utils/ui/labels'; |
| 20 | +import { expect } from '@playwright/test'; |
| 21 | + |
| 22 | +const testLabels = { |
| 23 | + env: 'test', |
| 24 | + version: 'v1', |
| 25 | + team: 'e2e', |
| 26 | +}; |
| 27 | + |
| 28 | +const additionalLabels = { |
| 29 | + stage: 'production', |
| 30 | + region: 'us-west', |
| 31 | +}; |
| 32 | + |
| 33 | +test('should support labels functionality in SSL forms', async ({ page }) => { |
| 34 | + await sslsPom.toIndex(page); |
| 35 | + await sslsPom.isIndexPage(page); |
| 36 | + |
| 37 | + await sslsPom.getAddSSLBtn(page).click(); |
| 38 | + await sslsPom.isAddPage(page); |
| 39 | + |
| 40 | + await test.step('verify labels field is present and functional', async () => { |
| 41 | + // Verify Labels field is present |
| 42 | + const labelsField = page.getByRole('textbox', { name: 'Labels' }); |
| 43 | + await expect(labelsField).toBeVisible(); |
| 44 | + await expect(labelsField).toBeEnabled(); |
| 45 | + }); |
| 46 | + |
| 47 | + await test.step('test adding labels functionality', async () => { |
| 48 | + // Add multiple labels |
| 49 | + await uiFillLabels(page, testLabels); |
| 50 | + |
| 51 | + // Verify labels are displayed after addition |
| 52 | + await uiCheckLabels(page, testLabels); |
| 53 | + }); |
| 54 | + |
| 55 | + await test.step('test adding additional labels', async () => { |
| 56 | + // Add more labels to test multiple labels functionality |
| 57 | + await uiFillLabels(page, additionalLabels); |
| 58 | + |
| 59 | + // Verify all labels (original + additional) are displayed |
| 60 | + const allLabels = { ...testLabels, ...additionalLabels }; |
| 61 | + await uiCheckLabels(page, allLabels); |
| 62 | + }); |
| 63 | + |
| 64 | + await test.step('verify labels persist in form', async () => { |
| 65 | + // Fill some other fields to verify labels persist |
| 66 | + await page.getByLabel('SNI', { exact: true }).fill('test.example.com'); |
| 67 | + |
| 68 | + // Verify labels are still there |
| 69 | + const allLabels = { ...testLabels, ...additionalLabels }; |
| 70 | + await uiCheckLabels(page, allLabels); |
| 71 | + }); |
| 72 | + |
| 73 | + await test.step('verify labels field behavior', async () => { |
| 74 | + // Test that labels field clears after adding a label |
| 75 | + const labelsField = page.getByRole('textbox', { name: 'Labels' }); |
| 76 | + |
| 77 | + // Add another label |
| 78 | + await labelsField.click(); |
| 79 | + await labelsField.fill('new:label'); |
| 80 | + await labelsField.press('Enter'); |
| 81 | + |
| 82 | + // Verify the input field is cleared after adding |
| 83 | + await expect(labelsField).toHaveValue(''); |
| 84 | + |
| 85 | + // Verify the new label is displayed |
| 86 | + await expect(page.getByText('new:label')).toBeVisible(); |
| 87 | + }); |
| 88 | +}); |
0 commit comments