Skip to content

Commit 20a6e7e

Browse files
cherry-pick Use the disabled attribute on a valid element - the button. (#7914) (#8043)
Use the disabled attribute on a valid element - the button. (#7914) * Add e2e test to check for add criteria button being enabled/disabled Co-authored-by: Shefali Joshi <[email protected]>
1 parent 3ae9d12 commit 20a6e7e

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

e2e/tests/functional/plugins/conditionSet/conditionSetOperations.e2e.spec.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,41 @@ test.describe('Basic Condition Set Use', () => {
287287
description: 'https://github.com/nasa/openmct/issues/7484'
288288
});
289289
});
290+
291+
test('ConditionSet has add criteria button enabled/disabled when composition is and is not available', async ({
292+
page
293+
}) => {
294+
const exampleTelemetry = await createExampleTelemetryObject(page);
295+
296+
await page.getByLabel('Show selected item in tree').click();
297+
await page.goto(conditionSet.url);
298+
// Change the object to edit mode
299+
await page.getByLabel('Edit Object').click();
300+
301+
// Create a condition
302+
await page.locator('#addCondition').click();
303+
await page.locator('#conditionCollection').getByRole('textbox').nth(0).fill('First Condition');
304+
305+
// Validate that the add criteria button is disabled
306+
await expect(page.getByLabel('Add Criteria - Disabled')).toHaveAttribute('disabled');
307+
308+
// Add Telemetry to ConditionSet
309+
const sineWaveGeneratorTreeItem = page
310+
.getByRole('tree', {
311+
name: 'Main Tree'
312+
})
313+
.getByRole('treeitem', {
314+
name: exampleTelemetry.name
315+
});
316+
const conditionCollection = page.locator('#conditionCollection');
317+
await sineWaveGeneratorTreeItem.dragTo(conditionCollection);
318+
319+
// Validate that the add criteria button is enabled and adds a new criterion
320+
await expect(page.getByLabel('Add Criteria - Enabled')).not.toHaveAttribute('disabled');
321+
await page.getByLabel('Add Criteria - Enabled').click();
322+
const numOfUnnamedCriteria = await page.getByLabel('Criterion Telemetry Selection').count();
323+
expect(numOfUnnamedCriteria).toEqual(2);
324+
});
290325
});
291326

292327
test.describe('Condition Set Composition', () => {

src/plugins/condition/components/ConditionItem.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,10 @@
160160
</div>
161161
</template>
162162
<div class="c-cdef__separator c-row-separator"></div>
163-
<div class="c-cdef__controls" :disabled="!telemetry.length">
163+
<div class="c-cdef__controls">
164164
<button
165+
:disabled="!telemetry.length"
166+
:aria-label="`Add Criteria - ${!telemetry.length ? 'Disabled' : 'Enabled'}`"
165167
class="c-cdef__add-criteria-button c-button c-button--labeled icon-plus"
166168
@click="addCriteria"
167169
>

0 commit comments

Comments
 (0)