mirror of
https://github.com/nasa/openmct.git
synced 2024-12-18 20:57:53 +00:00
Domain object properties validation not working always (#4893)
* Domain object properties validation not working always #4849 * stub of a test * set local execution to chrome * skip visual test * use input event for changes and throttle update. * moved file to correct location * fixed e2e tests. Co-authored-by: unlikelyzero <jchill2@gmail.com> Co-authored-by: John Hill <john.c.hill@nasa.gov>
This commit is contained in:
parent
67234c70a4
commit
482d8f392c
161
e2e/tests/example/generator/SinewaveLimitProvider.e2e.spec.js
Normal file
161
e2e/tests/example/generator/SinewaveLimitProvider.e2e.spec.js
Normal file
@ -0,0 +1,161 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2022, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
/*
|
||||
This test suite is dedicated to tests which verify the basic operations surrounding conditionSets.
|
||||
*/
|
||||
|
||||
const { test, expect } = require('@playwright/test');
|
||||
|
||||
test.describe('Sine Wave Generator', () => {
|
||||
test('Create new Sine Wave Generator Object and validate create Form Logic', async ({ page }) => {
|
||||
//Go to baseURL
|
||||
await page.goto('/', { waitUntil: 'networkidle' });
|
||||
|
||||
//Click the Create button
|
||||
await page.click('button:has-text("Create")');
|
||||
|
||||
// Click Sine Wave Generator
|
||||
await page.click('text=Sine Wave Generator');
|
||||
|
||||
// Verify that the each required field has required indicator
|
||||
// Title
|
||||
await expect(page.locator('.c-form-row__state-indicator').first()).toHaveClass(['c-form-row__state-indicator req']);
|
||||
|
||||
// Verify that the Notes row does not have a required indicator
|
||||
await expect(page.locator('.c-form__section div:nth-child(3) .form-row .c-form-row__state-indicator')).not.toContain('.req');
|
||||
|
||||
// Period
|
||||
await expect(page.locator('.c-form__section div:nth-child(4) .form-row .c-form-row__state-indicator')).toHaveClass(['c-form-row__state-indicator req']);
|
||||
|
||||
// Amplitude
|
||||
await expect(page.locator('.c-form__section div:nth-child(5) .form-row .c-form-row__state-indicator')).toHaveClass(['c-form-row__state-indicator req']);
|
||||
|
||||
// Offset
|
||||
await expect(page.locator('.c-form__section div:nth-child(6) .form-row .c-form-row__state-indicator')).toHaveClass(['c-form-row__state-indicator req']);
|
||||
|
||||
// Data Rate
|
||||
await expect(page.locator('.c-form__section div:nth-child(7) .form-row .c-form-row__state-indicator')).toHaveClass(['c-form-row__state-indicator req']);
|
||||
|
||||
// Phase
|
||||
await expect(page.locator('.c-form__section div:nth-child(8) .form-row .c-form-row__state-indicator')).toHaveClass(['c-form-row__state-indicator req']);
|
||||
|
||||
// Randomness
|
||||
await expect(page.locator('.c-form__section div:nth-child(9) .form-row .c-form-row__state-indicator')).toHaveClass(['c-form-row__state-indicator req']);
|
||||
|
||||
// Verify that by removing value from required text field shows invalid indicator
|
||||
await page.locator('text=Properties Title Notes Period Amplitude Offset Data Rate (hz) Phase (radians) Ra >> input[type="text"]').fill('');
|
||||
await expect(page.locator('.c-form-row__state-indicator').first()).toHaveClass(['c-form-row__state-indicator req invalid']);
|
||||
|
||||
// Verify that by adding value to empty required text field changes invalid to valid indicator
|
||||
await page.locator('text=Properties Title Notes Period Amplitude Offset Data Rate (hz) Phase (radians) Ra >> input[type="text"]').fill('non empty');
|
||||
await expect(page.locator('.c-form-row__state-indicator').first()).toHaveClass(['c-form-row__state-indicator req valid']);
|
||||
|
||||
// Verify that by removing value from required number field shows invalid indicator
|
||||
await page.locator('.field.control.l-input-sm input').first().fill('');
|
||||
await expect(page.locator('.c-form__section div:nth-child(4) .form-row .c-form-row__state-indicator')).toHaveClass(['c-form-row__state-indicator req invalid']);
|
||||
|
||||
// Verify that by adding value to empty required number field changes invalid to valid indicator
|
||||
await page.locator('.field.control.l-input-sm input').first().fill('3');
|
||||
await expect(page.locator('.c-form__section div:nth-child(4) .form-row .c-form-row__state-indicator')).toHaveClass(['c-form-row__state-indicator req valid']);
|
||||
|
||||
// Verify that can change value of number field by up/down arrows keys
|
||||
// Click .field.control.l-input-sm input >> nth=0
|
||||
await page.locator('.field.control.l-input-sm input').first().click();
|
||||
// Press ArrowUp 3 times to change value from 3 to 6
|
||||
await page.locator('.field.control.l-input-sm input').first().press('ArrowUp');
|
||||
await page.locator('.field.control.l-input-sm input').first().press('ArrowUp');
|
||||
await page.locator('.field.control.l-input-sm input').first().press('ArrowUp');
|
||||
|
||||
const value = await page.locator('.field.control.l-input-sm input').first().inputValue();
|
||||
await expect(value).toBe('6');
|
||||
|
||||
// Click .c-form-row__state-indicator.grows
|
||||
await page.locator('.c-form-row__state-indicator.grows').click();
|
||||
|
||||
// Click text=Properties Title Notes Period Amplitude Offset Data Rate (hz) Phase (radians) Ra >> input[type="text"]
|
||||
await page.locator('text=Properties Title Notes Period Amplitude Offset Data Rate (hz) Phase (radians) Ra >> input[type="text"]').click();
|
||||
|
||||
// Click .c-form-row__state-indicator >> nth=0
|
||||
await page.locator('.c-form-row__state-indicator').first().click();
|
||||
|
||||
// Fill text=Properties Title Notes Period Amplitude Offset Data Rate (hz) Phase (radians) Ra >> input[type="text"]
|
||||
await page.locator('text=Properties Title Notes Period Amplitude Offset Data Rate (hz) Phase (radians) Ra >> input[type="text"]').fill('New Sine Wave Generator');
|
||||
|
||||
// Double click div:nth-child(4) .form-row .c-form-row__controls
|
||||
await page.locator('div:nth-child(4) .form-row .c-form-row__controls').dblclick();
|
||||
|
||||
// Click .field.control.l-input-sm input >> nth=0
|
||||
await page.locator('.field.control.l-input-sm input').first().click();
|
||||
|
||||
// Click div:nth-child(4) .form-row .c-form-row__state-indicator
|
||||
await page.locator('div:nth-child(4) .form-row .c-form-row__state-indicator').click();
|
||||
|
||||
// Click .field.control.l-input-sm input >> nth=0
|
||||
await page.locator('.field.control.l-input-sm input').first().click();
|
||||
|
||||
// Click .field.control.l-input-sm input >> nth=0
|
||||
await page.locator('.field.control.l-input-sm input').first().click();
|
||||
|
||||
// Click div:nth-child(5) .form-row .c-form-row__controls .form-control .field input
|
||||
await page.locator('div:nth-child(5) .form-row .c-form-row__controls .form-control .field input').click();
|
||||
|
||||
// Click div:nth-child(5) .form-row .c-form-row__controls .form-control .field input
|
||||
await page.locator('div:nth-child(5) .form-row .c-form-row__controls .form-control .field input').click();
|
||||
|
||||
// Click div:nth-child(5) .form-row .c-form-row__controls .form-control .field input
|
||||
await page.locator('div:nth-child(5) .form-row .c-form-row__controls .form-control .field input').click();
|
||||
|
||||
// Click div:nth-child(6) .form-row .c-form-row__controls .form-control .field input
|
||||
await page.locator('div:nth-child(6) .form-row .c-form-row__controls .form-control .field input').click();
|
||||
|
||||
// Double click div:nth-child(7) .form-row .c-form-row__controls .form-control .field input
|
||||
await page.locator('div:nth-child(7) .form-row .c-form-row__controls .form-control .field input').dblclick();
|
||||
|
||||
// Click div:nth-child(7) .form-row .c-form-row__state-indicator
|
||||
await page.locator('div:nth-child(7) .form-row .c-form-row__state-indicator').click();
|
||||
|
||||
// Click div:nth-child(7) .form-row .c-form-row__controls .form-control .field input
|
||||
await page.locator('div:nth-child(7) .form-row .c-form-row__controls .form-control .field input').click();
|
||||
|
||||
// Fill div:nth-child(7) .form-row .c-form-row__controls .form-control .field input
|
||||
await page.locator('div:nth-child(7) .form-row .c-form-row__controls .form-control .field input').fill('3');
|
||||
|
||||
//Click text=OK
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
page.click('text=OK')
|
||||
]);
|
||||
|
||||
// Verify that the Sine Wave Generator is displayed and correct
|
||||
// Verify object properties
|
||||
await expect(page.locator('.l-browse-bar__object-name')).toContainText('New Sine Wave Generator');
|
||||
|
||||
// Verify canvas rendered
|
||||
await page.locator('canvas').nth(1).click({
|
||||
position: {
|
||||
x: 341,
|
||||
y: 28
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
@ -150,3 +150,24 @@ test('Visual - Time Conductor start time is less than end time', async ({ page }
|
||||
await page.waitForTimeout(VISUAL_GRACE_PERIOD);
|
||||
await percySnapshot(page, 'End time error');
|
||||
});
|
||||
|
||||
test('Visual - Sine Wave Generator Form', async ({ page }) => {
|
||||
//Go to baseURL
|
||||
await page.goto('/', { waitUntil: 'networkidle' });
|
||||
|
||||
//Click the Create button
|
||||
await page.click('button:has-text("Create")');
|
||||
|
||||
// Click text=Sine Wave Generator
|
||||
await page.click('text=Sine Wave Generator');
|
||||
|
||||
await page.waitForTimeout(VISUAL_GRACE_PERIOD);
|
||||
await percySnapshot(page, 'Default Sine Wave Generator Form');
|
||||
|
||||
await page.locator('.field.control.l-input-sm input').first().click();
|
||||
await page.locator('.field.control.l-input-sm input').first().fill('');
|
||||
|
||||
// Validate red x mark
|
||||
await page.waitForTimeout(VISUAL_GRACE_PERIOD);
|
||||
await percySnapshot(page, 'removed amplitude property value');
|
||||
});
|
||||
|
@ -89,7 +89,7 @@
|
||||
"test:coverage": "cross-env NODE_OPTIONS=\"--max_old_space_size=4096\" COVERAGE=true karma start --single-run",
|
||||
"test:coverage:firefox": "cross-env NODE_OPTIONS=\"--max_old_space_size=4096\" karma start --single-run --browsers=FirefoxHeadless",
|
||||
"test:e2e:ci": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome smoke default condition timeConductor",
|
||||
"test:e2e:local": "npx playwright test --config=e2e/playwright-local.config.js",
|
||||
"test:e2e:local": "npx playwright test --config=e2e/playwright-local.config.js --project=chrome",
|
||||
"test:e2e:visual": "percy exec --config ./e2e/.percy.yml -- npx playwright test --config=e2e/playwright-visual.config.js default",
|
||||
"test:e2e:full": "npx playwright test --config=e2e/playwright-ci.config.js",
|
||||
"test:watch": "cross-env NODE_OPTIONS=\"--max_old_space_size=4096\" karma start --no-single-run",
|
||||
|
@ -30,13 +30,15 @@
|
||||
:min="model.min"
|
||||
:max="model.max"
|
||||
:step="model.step"
|
||||
@blur="blur()"
|
||||
@input="updateText()"
|
||||
>
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { throttle } from 'lodash';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
model: {
|
||||
@ -49,8 +51,12 @@ export default {
|
||||
field: this.model.value
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.updateText = throttle(this.updateText.bind(this), 200);
|
||||
},
|
||||
methods: {
|
||||
blur() {
|
||||
updateText() {
|
||||
console.log('updateText', this.field);
|
||||
const data = {
|
||||
model: this.model,
|
||||
value: this.field
|
||||
|
@ -28,7 +28,7 @@
|
||||
<textarea v-model="field"
|
||||
type="text"
|
||||
:size="model.size"
|
||||
@blur="blur()"
|
||||
@input="updateText()"
|
||||
>
|
||||
</textarea>
|
||||
</span>
|
||||
@ -36,6 +36,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { throttle } from 'lodash';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
model: {
|
||||
@ -48,8 +50,11 @@ export default {
|
||||
field: this.model.value
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.updateText = throttle(this.updateText.bind(this), 500);
|
||||
},
|
||||
methods: {
|
||||
blur() {
|
||||
updateText() {
|
||||
const data = {
|
||||
model: this.model,
|
||||
value: this.field
|
||||
|
@ -28,13 +28,15 @@
|
||||
<input v-model="field"
|
||||
type="text"
|
||||
:size="model.size"
|
||||
@blur="blur()"
|
||||
@input="updateText()"
|
||||
>
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { throttle } from 'lodash';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
model: {
|
||||
@ -47,8 +49,11 @@ export default {
|
||||
field: this.model.value
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.updateText = throttle(this.updateText.bind(this), 500);
|
||||
},
|
||||
methods: {
|
||||
blur() {
|
||||
updateText() {
|
||||
const data = {
|
||||
model: this.model,
|
||||
value: this.field
|
||||
|
Loading…
Reference in New Issue
Block a user