From ea9947cab5eb36aefb189767022ed04ebf9f7db5 Mon Sep 17 00:00:00 2001 From: Shefali Joshi Date: Tue, 5 Nov 2024 12:53:28 -0800 Subject: [PATCH] Use the disabled attribute on a valid element - the button. (#7914) * Use the disabled attribute on a valid tag - the button. * Add e2e test to check for add criteria button being enabled * Improve test * Check for add criteria button to have attribute disabled * Remove focused test --- .../conditionSetOperations.e2e.spec.js | 35 +++++++++++++++++++ .../condition/components/ConditionItem.vue | 4 ++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/e2e/tests/functional/plugins/conditionSet/conditionSetOperations.e2e.spec.js b/e2e/tests/functional/plugins/conditionSet/conditionSetOperations.e2e.spec.js index 5cd5d86d25..c3a65a20e7 100644 --- a/e2e/tests/functional/plugins/conditionSet/conditionSetOperations.e2e.spec.js +++ b/e2e/tests/functional/plugins/conditionSet/conditionSetOperations.e2e.spec.js @@ -287,6 +287,41 @@ test.describe('Basic Condition Set Use', () => { description: 'https://github.com/nasa/openmct/issues/7484' }); }); + + test('ConditionSet has add criteria button enabled/disabled when composition is and is not available', async ({ + page + }) => { + const exampleTelemetry = await createExampleTelemetryObject(page); + + await page.getByLabel('Show selected item in tree').click(); + await page.goto(conditionSet.url); + // Change the object to edit mode + await page.getByLabel('Edit Object').click(); + + // Create a condition + await page.locator('#addCondition').click(); + await page.locator('#conditionCollection').getByRole('textbox').nth(0).fill('First Condition'); + + // Validate that the add criteria button is disabled + await expect(page.getByLabel('Add Criteria - Disabled')).toHaveAttribute('disabled'); + + // Add Telemetry to ConditionSet + const sineWaveGeneratorTreeItem = page + .getByRole('tree', { + name: 'Main Tree' + }) + .getByRole('treeitem', { + name: exampleTelemetry.name + }); + const conditionCollection = page.locator('#conditionCollection'); + await sineWaveGeneratorTreeItem.dragTo(conditionCollection); + + // Validate that the add criteria button is enabled and adds a new criterion + await expect(page.getByLabel('Add Criteria - Enabled')).not.toHaveAttribute('disabled'); + await page.getByLabel('Add Criteria - Enabled').click(); + const numOfUnnamedCriteria = await page.getByLabel('Criterion Telemetry Selection').count(); + expect(numOfUnnamedCriteria).toEqual(2); + }); }); test.describe('Condition Set Composition', () => { diff --git a/src/plugins/condition/components/ConditionItem.vue b/src/plugins/condition/components/ConditionItem.vue index dd42a58316..b24045c59a 100644 --- a/src/plugins/condition/components/ConditionItem.vue +++ b/src/plugins/condition/components/ConditionItem.vue @@ -160,8 +160,10 @@
-
+