diff --git a/e2e/tests/example/generator/SinewaveLimitProvider.e2e.spec.js b/e2e/tests/example/generator/SinewaveLimitProvider.e2e.spec.js new file mode 100644 index 0000000000..fc8101c9ef --- /dev/null +++ b/e2e/tests/example/generator/SinewaveLimitProvider.e2e.spec.js @@ -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 + } + }); + }); +}); diff --git a/e2e/tests/visual/default.spec.js b/e2e/tests/visual/default.spec.js index 383e57b076..2ad857f92d 100644 --- a/e2e/tests/visual/default.spec.js +++ b/e2e/tests/visual/default.spec.js @@ -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'); +}); diff --git a/package.json b/package.json index 27ad55db6e..fadea1347f 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/api/forms/components/controls/NumberField.vue b/src/api/forms/components/controls/NumberField.vue index 6a8bfef5ec..77a27795b6 100644 --- a/src/api/forms/components/controls/NumberField.vue +++ b/src/api/forms/components/controls/NumberField.vue @@ -30,13 +30,15 @@ :min="model.min" :max="model.max" :step="model.step" - @blur="blur()" + @input="updateText()" >