From afbb55ed5b489d50b1c763d5de0fe12471dc8f6a Mon Sep 17 00:00:00 2001 From: Jason Thomas Date: Fri, 1 Nov 2024 18:14:56 -0600 Subject: [PATCH] Fix playwright --- .../controllers/trigger_group_controller.rb | 3 +- .../src/tools/CommandSender/CommandSender.vue | 2 +- .../src/tools/ScriptRunner/ScriptRunner.vue | 61 +++++++++---------- playwright/tests/admin/microservices.spec.ts | 30 ++++++--- playwright/tests/admin/plugins.spec.ts | 6 +- playwright/tests/admin/targets.spec.ts | 16 +++-- playwright/tests/command-sender.spec.ts | 2 +- 7 files changed, 66 insertions(+), 54 deletions(-) diff --git a/openc3-cosmos-cmd-tlm-api/app/controllers/trigger_group_controller.rb b/openc3-cosmos-cmd-tlm-api/app/controllers/trigger_group_controller.rb index bcd89cbc4..fe7b30d2f 100644 --- a/openc3-cosmos-cmd-tlm-api/app/controllers/trigger_group_controller.rb +++ b/openc3-cosmos-cmd-tlm-api/app/controllers/trigger_group_controller.rb @@ -20,8 +20,7 @@ # This file may also be used under the terms of a commercial license # if purchased from OpenC3, Inc. -require 'openc3/topics/autonomic_topic' -require 'openc3/models/activity_model' +require 'openc3/models/trigger_group_model' class TriggerGroupController < ApplicationController def initialize diff --git a/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdsender/src/tools/CommandSender/CommandSender.vue b/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdsender/src/tools/CommandSender/CommandSender.vue index c3c0390dc..b312c10eb 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdsender/src/tools/CommandSender/CommandSender.vue +++ b/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdsender/src/tools/CommandSender/CommandSender.vue @@ -603,7 +603,7 @@ export default { this.screenName = 'CMDSENDER' let screenDefinition = 'SCREEN AUTO AUTO 1.0\n' for (const item of command.related_items) { - screenDefinition += `LABELVALUE '${command.related_items[i][0]}' '${command.related_items[i][1]}' '${command.related_items[i][2]}' WITH_UNITS 20\n` + screenDefinition += `LABELVALUE '${item[0]}' '${item[1]}' '${item[2]}' WITH_UNITS 20\n` } this.screenDefinition = screenDefinition } else { diff --git a/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-scriptrunner/src/tools/ScriptRunner/ScriptRunner.vue b/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-scriptrunner/src/tools/ScriptRunner/ScriptRunner.vue index a79deb099..a34aa68af 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-scriptrunner/src/tools/ScriptRunner/ScriptRunner.vue +++ b/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-scriptrunner/src/tools/ScriptRunner/ScriptRunner.vue @@ -1004,31 +1004,8 @@ export default { mounted: async function () { this.editor = ace.edit(this.$refs.editor) this.editor.setTheme('ace/theme/twilight') - // Public apis in api_shared but not in OpenC3Api - const api_shared = [ - 'check', - 'check_raw', - 'check_formatted', - 'check_with_units', - 'check_exception', - 'check_tolerance', - 'check_expression', - 'wait', - 'wait_tolerance', - 'wait_expression', - 'wait_check', - 'wait_check_tolerance', - 'wait_check_expression', - 'wait_packet', - 'wait_check_packet', - 'disable_instrumentation', - 'set_line_delay', - 'get_line_delay', - 'set_max_output', - 'get_max_output', - ] - const openC3RubyMode = this.buildOpenC3RubyMode(api_shared) - const openC3PythonMode = this.buildOpenC3PythonMode(api_shared) + const openC3RubyMode = this.buildOpenC3RubyMode() + const openC3PythonMode = this.buildOpenC3PythonMode() this.openC3RubyMode = new openC3RubyMode() this.openC3PythonMode = new openC3PythonMode() this.editor.session.setMode(this.openC3RubyMode) @@ -1184,7 +1161,29 @@ export default { let apis = Object.getOwnPropertyNames(OpenC3Api.prototype) .filter((a) => a !== 'constructor') .filter((a) => a !== 'exec') - .concat(api_shared) + // Add the Public apis in api_shared but not in OpenC3Api + .concat([ + 'check', + 'check_raw', + 'check_formatted', + 'check_with_units', + 'check_exception', + 'check_tolerance', + 'check_expression', + 'wait', + 'wait_tolerance', + 'wait_expression', + 'wait_check', + 'wait_check_tolerance', + 'wait_check_expression', + 'wait_packet', + 'wait_check_packet', + 'disable_instrumentation', + 'set_line_delay', + 'get_line_delay', + 'set_max_output', + 'get_max_output', + ]) let regex = new RegExp(`(\\b${apis.join('\\b|\\b')}\\b)`) let OpenC3HighlightRules = function () { HighlightRules.call(this) @@ -1211,10 +1210,10 @@ export default { this.foldingRules = new FoldMode() this.indentKeywords = this.foldingRules.indentKeywords } - return Mode + return [oop, Mode] }, - buildOpenC3RubyMode(api_shared) { - let Mode = this.buildLanguageMode( + buildOpenC3RubyMode() { + const [oop, Mode] = this.buildLanguageMode( ace.require('ace/mode/ruby_highlight_rules').RubyHighlightRules, ace.require('ace/mode/folding/ruby').FoldMode, ) @@ -1225,8 +1224,8 @@ export default { }).call(Mode.prototype) return Mode }, - buildOpenC3PythonMode(api_shared) { - let Mode = this.buildLanguageMode( + buildOpenC3PythonMode() { + const [oop, Mode] = this.buildLanguageMode( ace.require('ace/mode/python_highlight_rules').PythonHighlightRules, ace.require('ace/mode/folding/pythonic').FoldMode, ) diff --git a/playwright/tests/admin/microservices.spec.ts b/playwright/tests/admin/microservices.spec.ts index d1bfd3440..faea7dc53 100644 --- a/playwright/tests/admin/microservices.spec.ts +++ b/playwright/tests/admin/microservices.spec.ts @@ -1,5 +1,5 @@ /* -# Copyright 2023 OpenC3, Inc +# Copyright 2024 OpenC3, Inc # All Rights Reserved. # # This program is free software; you can modify and/or redistribute it @@ -24,23 +24,33 @@ test.use({ test('displays microservice names', async ({ page, utils }) => { // There are 9 microservices per target so look for the INST2 list - expect(await page.getByRole('list')).toContainText('DEFAULT__CLEANUP__INST2') - expect(await page.getByRole('list')).toContainText( + await expect(page.locator('[data-test="microserviceList"]')).toContainText( + 'DEFAULT__CLEANUP__INST2', + ) + await expect(page.locator('[data-test="microserviceList"]')).toContainText( 'DEFAULT__COMMANDLOG__INST2', ) - expect(await page.getByRole('list')).toContainText( + await expect(page.locator('[data-test="microserviceList"]')).toContainText( 'DEFAULT__DECOMCMDLOG__INST2', ) - expect(await page.getByRole('list')).toContainText('DEFAULT__DECOMLOG__INST2') - expect(await page.getByRole('list')).toContainText('DEFAULT__DECOM__INST2') - expect(await page.getByRole('list')).toContainText( + await expect(page.locator('[data-test="microserviceList"]')).toContainText( + 'DEFAULT__DECOMLOG__INST2', + ) + await expect(page.locator('[data-test="microserviceList"]')).toContainText( + 'DEFAULT__DECOM__INST2', + ) + await expect(page.locator('[data-test="microserviceList"]')).toContainText( 'DEFAULT__INTERFACE__INST2_INT', ) - expect(await page.getByRole('list')).toContainText('DEFAULT__MULTI__INST2') - expect(await page.getByRole('list')).toContainText( + await expect(page.locator('[data-test="microserviceList"]')).toContainText( + 'DEFAULT__MULTI__INST2', + ) + await expect(page.locator('[data-test="microserviceList"]')).toContainText( 'DEFAULT__PACKETLOG__INST2', ) - expect(await page.getByRole('list')).toContainText('DEFAULT__REDUCER__INST2') + await expect(page.locator('[data-test="microserviceList"]')).toContainText( + 'DEFAULT__REDUCER__INST2', + ) }) test('displays microservice details', async ({ page, utils }) => { diff --git a/playwright/tests/admin/plugins.spec.ts b/playwright/tests/admin/plugins.spec.ts index 8ea9a42c4..76019129a 100644 --- a/playwright/tests/admin/plugins.spec.ts +++ b/playwright/tests/admin/plugins.spec.ts @@ -538,14 +538,14 @@ test.describe(() => { await page.goto('/tools/tlmviewer') await expect(page.locator('.v-app-bar')).toContainText('Telemetry Viewer') await page.locator('rux-icon-apps').getByRole('img').click() - await page.locator('div[role="button"]:has-text("Select Target")').click() - await page.locator(`.v-list-item__title:text-is("NEW_TGT")`).click() + await page.locator('[data-test=select-target] i').click() + await page.getByRole('option', { name: 'NEW_TGT', exact: true }).click() await utils.sleep(500) await page.locator('[data-test=new-screen]').click() await expect( page.locator(`.v-toolbar:has-text("New Screen")`), ).toBeVisible() - await page.locator('[data-test=new-screen-name]').fill('NEW_SCREEN') + await page.locator('[data-test=new-screen-name] input').fill('NEW_SCREEN') await page.getByRole('button', { name: 'Save' }).click() await expect( page.locator(`.v-toolbar:has-text("NEW_TGT NEW_SCREEN")`), diff --git a/playwright/tests/admin/targets.spec.ts b/playwright/tests/admin/targets.spec.ts index d0ea13014..41862c873 100644 --- a/playwright/tests/admin/targets.spec.ts +++ b/playwright/tests/admin/targets.spec.ts @@ -23,12 +23,16 @@ test.use({ }) test('displays target names and associated plugin', async ({ page, utils }) => { - expect(await page.getByRole('list')).toContainText('INST') - expect(await page.getByRole('list')).toContainText('INST2') - expect(await page.getByRole('list')).toContainText('SYSTEM') - expect(await page.getByRole('list')).toContainText('EXAMPLE') - expect(await page.getByRole('list')).toContainText('TEMPLATED') - expect(await page.getByRole('list')).toContainText( + await expect(page.locator('[data-test="targetList"]')).toContainText('INST') + await expect(page.locator('[data-test="targetList"]')).toContainText('INST2') + await expect(page.locator('[data-test="targetList"]')).toContainText('SYSTEM') + await expect(page.locator('[data-test="targetList"]')).toContainText( + 'EXAMPLE', + ) + await expect(page.locator('[data-test="targetList"]')).toContainText( + 'TEMPLATED', + ) + await expect(page.locator('[data-test="targetList"]')).toContainText( /Plugin: openc3-cosmos-demo-\d{1,2}\.\d{1,2}\.\d{1,2}/, ) }) diff --git a/playwright/tests/command-sender.spec.ts b/playwright/tests/command-sender.spec.ts index 2ed159e8a..8645dad1e 100644 --- a/playwright/tests/command-sender.spec.ts +++ b/playwright/tests/command-sender.spec.ts @@ -543,7 +543,7 @@ test('shows ignored parameters', async ({ page, utils }) => { // Thus we send the INST SET PARAMS command which has a parameter conversion, // check the raw buffer, then send it with parameter conversions disabled, // and re-check the raw buffer for a change. -test('disable parameter conversions', async ({ page, utils }) => { +test.only('disable parameter conversions', async ({ page, utils }) => { await page.locator('[data-test="clear-history"]').click() await utils.selectTargetPacketItem('INST', 'SETPARAMS') await page.locator('[data-test="select-send"]').click()