Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow test data toggle to be clicked #7479

Merged
merged 7 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions e2e/tests/functional/plugins/conditionSet/conditionSet.e2e.spec.js
Original file line number Diff line number Diff line change
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.getByTitle('Show selected item in tree').click();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't possible to do with linting, but we cannot use .getByTitle since title's aren't compatible with screen readers or on mobile

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. We're doing this everywhere in our tests. Perhaps it needs a separate PR to change it in one go?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I've just done that in this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They just added a linting rule for us to get away from this

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'
);
secondCriterionTelemetry.selectOption({ label: exampleTelemetry.name });

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

const secondCriterionComparison = page.locator(
'[aria-label="Criterion Comparison Selection"] >> nth=1'
);
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');
testDataTelemetry.selectOption({ label: exampleTelemetry.name });

const testDataMetadata = page.locator('[aria-label="Test Data Metadata Selection"] >> nth=0');
testDataMetadata.selectOption({ label: 'Sine' });
shefalijoshi marked this conversation as resolved.
Show resolved Hide resolved

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);
});
});
26 changes: 22 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="testDataClass">
shefalijoshi marked this conversation as resolved.
Show resolved Hide resolved
<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>

Check warning on line 37 in src/plugins/condition/components/TestData.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/condition/components/TestData.vue#L37

Added line #L37 was not covered by tests
<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)"
>

Check warning on line 54 in src/plugins/condition/components/TestData.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/condition/components/TestData.vue#L54

Added line #L54 was not covered by tests
<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"

Check warning on line 69 in src/plugins/condition/components/TestData.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/condition/components/TestData.vue#L68-L69

Added lines #L68 - L69 were not covered by tests
>
<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"

Check warning on line 87 in src/plugins/condition/components/TestData.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/condition/components/TestData.vue#L87

Added line #L87 was not covered by tests
@change="updateTestData"
/>
</span>
Expand Down Expand Up @@ -136,6 +145,15 @@
telemetryMetadataOptions: {}
};
},
computed: {
testDataClass() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@charlesh88 can you check to see that this is how we want to do this disabled

let cssClass = 'c-cs__test-data__controls c-cdef__controls';
if (!this.telemetry.length) {
cssClass = `${cssClass} disabled`;
}
return cssClass;
}
},
watch: {
isEditing(editing) {
if (!editing) {
Expand Down
Loading