Skip to content

Commit

Permalink
Allow test data toggle to be clicked (#7479)
Browse files Browse the repository at this point in the history
* Add the disabled class instead of the disabled property

* Add test for condition set test data

* Use computed property for css class

* Use array syntax for class instead of computed value

* Fix .getByTitle locators to use .getByLabel instead

---------

Co-authored-by: Scott Bell <[email protected]>
Co-authored-by: John Hill <[email protected]>
  • Loading branch information
3 people authored Feb 28, 2024
1 parent dc9bd8b commit 7d25c96
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ test.describe('Basic Condition Set Use', () => {
}) => {
const exampleTelemetry = await createExampleTelemetryObject(page);

await page.getByTitle('Show selected item in tree').click();
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();
Expand Down Expand Up @@ -378,4 +378,83 @@ test.describe('Basic Condition Set Use', () => {
await page.goto(conditionSet.url);
await expect(outputValue).toHaveText('---');
});

test('ConditionSet has correct outputs when test data is enabled', 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 two conditions
await page.locator('#addCondition').click();
await page.locator('#addCondition').click();
await page.locator('#conditionCollection').getByRole('textbox').nth(0).fill('First Condition');
await page.locator('#conditionCollection').getByRole('textbox').nth(1).fill('Second Condition');

// 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);

// Modify First Criterion
const firstCriterionTelemetry = page.locator(
'[aria-label="Criterion Telemetry Selection"] >> nth=0'
);
firstCriterionTelemetry.selectOption({ label: exampleTelemetry.name });
const firstCriterionMetadata = page.locator(
'[aria-label="Criterion Metadata Selection"] >> nth=0'
);
firstCriterionMetadata.selectOption({ label: 'Sine' });
const firstCriterionComparison = page.locator(
'[aria-label="Criterion Comparison Selection"] >> nth=0'
);
firstCriterionComparison.selectOption({ label: 'is greater than or equal to' });
const firstCriterionInput = page.locator('[aria-label="Criterion Input"] >> nth=0');
await firstCriterionInput.fill('0');

// Modify Second Criterion
const secondCriterionTelemetry = page.locator(
'[aria-label="Criterion Telemetry Selection"] >> nth=1'
);
await secondCriterionTelemetry.selectOption({ label: exampleTelemetry.name });

const secondCriterionMetadata = page.locator(
'[aria-label="Criterion Metadata Selection"] >> nth=1'
);
await secondCriterionMetadata.selectOption({ label: 'Sine' });

const secondCriterionComparison = page.locator(
'[aria-label="Criterion Comparison Selection"] >> nth=1'
);
await secondCriterionComparison.selectOption({ label: 'is less than' });

const secondCriterionInput = page.locator('[aria-label="Criterion Input"] >> nth=1');
await secondCriterionInput.fill('0');

// Enable test data
await page.getByLabel('Apply Test Data').nth(1).click();
const testDataTelemetry = page.locator('[aria-label="Test Data Telemetry Selection"] >> nth=0');
await testDataTelemetry.selectOption({ label: exampleTelemetry.name });

const testDataMetadata = page.locator('[aria-label="Test Data Metadata Selection"] >> nth=0');
await testDataMetadata.selectOption({ label: 'Sine' });

const testInput = page.locator('[aria-label="Test Data Input"] >> nth=0');
await testInput.fill('0');

// Validate that the condition set is evaluating and outputting
// the correct value when the underlying telemetry subscription is active.
let outputValue = page.locator('[aria-label="Current Output Value"]');
await expect(outputValue).toHaveText('false');

await page.goto(exampleTelemetry.url);
});
});
16 changes: 8 additions & 8 deletions e2e/tests/functional/plugins/notebook/notebook.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ test.describe('Notebook entry tests', () => {
await page.goto(notebookObject.url);

// Reveal the notebook in the tree
await page.getByTitle('Show selected item in tree').click();
await page.getByLabel('Show selected item in tree').click();

await page
.getByRole('treeitem', { name: overlayPlot.name })
Expand All @@ -332,7 +332,7 @@ test.describe('Notebook entry tests', () => {
await page.goto(notebookObject.url);

// Reveal the notebook in the tree
await page.getByTitle('Show selected item in tree').click();
await page.getByLabel('Show selected item in tree').click();

await nbUtils.enterTextEntry(page, 'Entry to drop into');
await page
Expand Down Expand Up @@ -377,7 +377,7 @@ test.describe('Notebook entry tests', () => {
await page.goto(notebookObject.url);

// Reveal the notebook in the tree
await page.getByTitle('Show selected item in tree').click();
await page.getByLabel('Show selected item in tree').click();

await nbUtils.enterTextEntry(page, `This should be a link: ${TEST_LINK} is it?`);

Expand All @@ -404,7 +404,7 @@ test.describe('Notebook entry tests', () => {
await page.goto(notebookObject.url);

// Reveal the notebook in the tree
await page.getByTitle('Show selected item in tree').click();
await page.getByLabel('Show selected item in tree').click();

await nbUtils.enterTextEntry(page, `This should NOT be a link: ${TEST_LINK} is it?`);

Expand All @@ -421,7 +421,7 @@ test.describe('Notebook entry tests', () => {
await page.goto(notebookObject.url);

// Reveal the notebook in the tree
await page.getByTitle('Show selected item in tree').click();
await page.getByLabel('Show selected item in tree').click();

await nbUtils.enterTextEntry(page, `This should NOT be a link: ${TEST_LINK} is it?`);

Expand All @@ -438,7 +438,7 @@ test.describe('Notebook entry tests', () => {
await page.goto(notebookObject.url);

// Reveal the notebook in the tree
await page.getByTitle('Show selected item in tree').click();
await page.getByLabel('Show selected item in tree').click();

await nbUtils.enterTextEntry(page, `This should be a link: ${INVALID_TEST_LINK} is it?`);

Expand All @@ -455,7 +455,7 @@ test.describe('Notebook entry tests', () => {
await page.goto(notebookObject.url);

// Reveal the notebook in the tree
await page.getByTitle('Show selected item in tree').click();
await page.getByLabel('Show selected item in tree').click();

await nbUtils.enterTextEntry(page, `This should be a link: ${TEST_LINK} is it?`);

Expand Down Expand Up @@ -483,7 +483,7 @@ test.describe('Notebook entry tests', () => {
await page.goto(notebookObject.url);

// Reveal the notebook in the tree
await page.getByTitle('Show selected item in tree').click();
await page.getByLabel('Show selected item in tree').click();

await nbUtils.enterTextEntry(
page,
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/functional/recentObjects.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ test.describe('Recent Objects', () => {

// Navigate to the clock and reveal it in the tree
await page.goto(clock.url);
await page.getByTitle('Show selected item in tree').click();
await page.getByLabel('Show selected item in tree').click();

// Right click the clock and create an alias using the "link" context menu action
const clockTreeItem = page
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/functional/tree.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test.describe('Main Tree', () => {
type: 'Folder'
});

await page.getByTitle('Show selected item in tree').click();
await page.getByLabel('Show selected item in tree').click();

const clock = await createDomainObjectWithDefaults(page, {
type: 'Clock',
Expand Down
17 changes: 13 additions & 4 deletions src/plugins/condition/components/TestData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
<div class="c-cs__header-label c-section__label">Test Data</div>
</div>
<div v-if="expanded" class="c-cs__content">
<div class="c-cs__test-data__controls c-cdef__controls" :disabled="!telemetry.length">
<div :class="['c-cs__test-data__controls c-cdef__controls', { disabled: !telemetry.length }]">
<label class="c-toggle-switch">
<input type="checkbox" :checked="isApplied" @change="applyTestData" />
<span class="c-toggle-switch__slider"></span>
<span class="c-toggle-switch__slider" aria-label="Apply Test Data"></span>
<span class="c-toggle-switch__label">Apply Test Data</span>
</label>
</div>
Expand All @@ -47,7 +47,11 @@
<span class="c-cs-test__label">Set</span>
<span class="c-cs-test__controls">
<span class="c-cdef__control">
<select v-model="testInput.telemetry" @change="updateMetadata(testInput)">
<select
v-model="testInput.telemetry"
aria-label="Test Data Telemetry Selection"
@change="updateMetadata(testInput)"
>
<option value="">- Select Telemetry -</option>
<option
v-for="(telemetryOption, index) in telemetry"
Expand All @@ -59,7 +63,11 @@
</select>
</span>
<span v-if="testInput.telemetry" class="c-cdef__control">
<select v-model="testInput.metadata" @change="updateTestData">
<select
v-model="testInput.metadata"
aria-label="Test Data Metadata Selection"
@change="updateTestData"
>
<option value="">- Select Field -</option>
<option
v-for="(option, index) in telemetryMetadataOptions[getId(testInput.telemetry)]"
Expand All @@ -76,6 +84,7 @@
placeholder="Enter test input"
type="text"
class="c-cdef__control__input"
aria-label="Test Data Input"
@change="updateTestData"
/>
</span>
Expand Down

0 comments on commit 7d25c96

Please sign in to comment.