From a93988523ea442e14e792f0c909bcf796f3aa998 Mon Sep 17 00:00:00 2001 From: Jason Thomas Date: Thu, 19 Dec 2024 14:11:19 -0700 Subject: [PATCH] Fix playwright test --- .../targets/INST/procedures/screens.rb | 14 ++++---- .../targets/INST2/procedures/screens.py | 14 ++++---- playwright/tests/script-runner/api.spec.ts | 36 +++++++++++-------- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/procedures/screens.rb b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/procedures/screens.rb index cf120f99dc..bd7fbee842 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/procedures/screens.rb +++ b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/procedures/screens.rb @@ -5,15 +5,15 @@ puts definition wait(1) display_screen("INST", "ADCS") -wait(3) +wait(2) display_screen("INST", "HS", 400, 0) -wait(3) +wait(2) clear_screen("INST", "ADCS") -wait(3) +wait(2) display_screen("INST", "IMAGE") -wait(3) +wait(2) clear_all_screens() -wait(3) +wait(2) definition = ' SCREEN AUTO AUTO 1.0 @@ -23,11 +23,11 @@ END ' local_screen("TEST", definition) -wait(3) +wait(2) clear_all_screens() create_screen("INST", "TEST", definition) display_screen("INST", "TEST") -wait(3) +wait(2) clear_all_screens() delete_screen("INST", "TEST") display_screen("INST", "TEST") # Expected to fail because new screen was deleted diff --git a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/procedures/screens.py b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/procedures/screens.py index bddc10a8e4..02fd244418 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/procedures/screens.py +++ b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/procedures/screens.py @@ -5,15 +5,15 @@ print(definition) wait(1) display_screen("INST2", "ADCS") -wait(3) +wait(2) display_screen("INST2", "HS", 400, 0) -wait(3) +wait(2) clear_screen("INST2", "ADCS") -wait(3) +wait(2) display_screen("INST2", "IMAGE") -wait(3) +wait(2) clear_all_screens() -wait(3) +wait(2) definition = """ SCREEN AUTO AUTO 1.0 @@ -23,11 +23,11 @@ END """ local_screen("TEST", definition) -wait(3) +wait(2) clear_all_screens() create_screen("INST2", "TEST", definition) display_screen("INST2", "TEST") -wait(3) +wait(2) clear_all_screens() delete_screen("INST2", "TEST") display_screen("INST2", "TEST") # Expected to fail because new screen was deleted diff --git a/playwright/tests/script-runner/api.spec.ts b/playwright/tests/script-runner/api.spec.ts index 0c05b5219c..a67c26a724 100644 --- a/playwright/tests/script-runner/api.spec.ts +++ b/playwright/tests/script-runner/api.spec.ts @@ -257,7 +257,7 @@ test('test python metadata apis', async ({ page, utils }) => { ) }) -async function testScreenApis(page, utils, filename) { +async function testScreenApis(page, utils, filename, target) { await openFile(page, utils, filename) await page.locator('[data-test=start-button]').click() await expect(page.locator('[data-test=state] input')).toHaveValue( @@ -268,24 +268,32 @@ async function testScreenApis(page, utils, filename) { ) await expect(page.locator('[data-test=state] input')).toHaveValue('running') // script displays INST ADCS - await page.getByText('INST ADCS', { exact: true }).toBeVisible() + await expect(page.getByText(`${target} ADCS`, { exact: true })).toBeVisible() // script displays INST HS - await page.getByText('INST HS', { exact: true }).toBeVisible() + await expect(page.getByText(`${target} HS`, { exact: true })).toBeVisible() // script calls clear_screen("INST", "ADCS") - await page.getByText('INST ADCS', { exact: true }).not.toBeVisible() + await expect( + page.getByText(`${target} ADCS`, { exact: true }), + ).not.toBeVisible() // script displays INST IMAGE - await page.getByText('INST IMAGE', { exact: true }).toBeVisible() + await expect(page.getByText(`${target} IMAGE`, { exact: true })).toBeVisible() // script calls clear_all_screens() - await page.getByText('INST HS', { exact: true }).not.toBeVisible() - await page.getByText('INST IMAGE', { exact: true }).not.toBeVisible() + await expect( + page.getByText(`${target} HS`, { exact: true }), + ).not.toBeVisible() + await expect( + page.getByText(`${target} IMAGE`, { exact: true }), + ).not.toBeVisible() // script creates local screen "TEST" - await page.getByText('LOCAL TEST', { exact: true }).toBeVisible() + await expect(page.getByText('LOCAL TEST', { exact: true })).toBeVisible() // script calls clear_all_screens() - await page.getByText('LOCAL TEST', { exact: true }).not.toBeVisible() + await expect(page.getByText('LOCAL TEST', { exact: true })).not.toBeVisible() // script creates local screen "INST TEST" - await page.getByText('INST TEST', { exact: true }).toBeVisible() + await expect(page.getByText(`${target} TEST`, { exact: true })).toBeVisible() // script calls clear_all_screens() - await page.getByText('INST TEST', { exact: true }).not.toBeVisible() + await expect( + page.getByText(`${target} TEST`, { exact: true }), + ).not.toBeVisible() // script deletes INST TEST and tries to display it which results in error await expect(page.locator('[data-test=state] input')).toHaveValue('error', { timeout: 20000, @@ -296,12 +304,12 @@ async function testScreenApis(page, utils, filename) { }) } -test.only('test ruby screen apis', async ({ page, utils }) => { - await testScreenApis(page, utils, 'screens.rb') +test('test ruby screen apis', async ({ page, utils }) => { + await testScreenApis(page, utils, 'screens.rb', 'INST') }) test('test python screen apis', async ({ page, utils }) => { - await testScreenApis(page, utils, 'screens.py') + await testScreenApis(page, utils, 'screens.py', 'INST2') }) test('test python numpy import', async ({ page, utils }) => {