diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c1ae927e..78626fe6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,7 +127,7 @@ jobs: path: | site viz - - name: Archive Javascript app + - name: Archive linux electron app uses: actions/upload-artifact@v4 with: name: linux @@ -193,7 +193,11 @@ jobs: webapp-playwright-test: needs: [cli-and-doc, webapp-ubuntu] - if: github.ref == 'refs/heads/master' + # run only on master OR when the PR is _not_ a draft + # TODO: improve this? + if: | + github.ref == 'refs/heads/master' || + github.event.pull_request.draft == false timeout-minutes: 75 runs-on: ubuntu-latest steps: @@ -225,6 +229,15 @@ jobs: ' > lighttpd.conf lighttpd -f lighttpd.conf -D & sleep 10 && curl -i http://127.0.0.1:12345/index.html # test + - name: Download electron app + uses: actions/download-artifact@v4 + with: + name: linux + - name: Setup electron app + run: >- + tar xzf Kappapp.tar.gz + mkdir -p build + mv Kappapp ./build/ - name: Run Playwright tests run: DEBUG=pw:webserver npx playwright test --retries=3 --trace retain-on-first-failure - uses: actions/upload-artifact@v4 diff --git a/gui/resources/JsSim.css b/gui/resources/JsSim.css index 06a556f95..5983d6f73 100644 --- a/gui/resources/JsSim.css +++ b/gui/resources/JsSim.css @@ -174,7 +174,7 @@ rect { stroke-width: 2; } } .plot-legend-swatch { stroke-width : 1; } -.plot-tick-proof { } +/* .plot-tick-proof { } */ .contact-tooltip { position: fixed; z-index: 10; padding: 2px; border-style: solid; diff --git a/playwright.config.ts b/playwright.config.ts index 39d4554bd..561bd1a50 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,5 +1,7 @@ import { defineConfig, devices } from '@playwright/test'; +import type { TestOptions } from './tests/playwright/project_electron_param'; + /** * Read environment variables from file. * https://github.com/motdotla/dotenv @@ -11,7 +13,7 @@ import { defineConfig, devices } from '@playwright/test'; /** * See https://playwright.dev/docs/test-configuration. */ -export default defineConfig({ +export default defineConfig({ testDir: './tests/playwright', /* Run tests in files in parallel */ fullyParallel: true, @@ -33,6 +35,7 @@ export default defineConfig({ }, /* Configure projects for major browsers */ + // See https://playwright.dev/docs/test-parameterize#parameterized-projects for electron param definition projects: [ { name: 'chromium', @@ -44,6 +47,11 @@ export default defineConfig({ use: { ...devices['Desktop Firefox'] }, }, + { + name: 'electron', + use: { run_in_electron: true }, + }, + // TODO: try making the app work on webkit /* { diff --git a/tests/playwright/README.md b/tests/playwright/README.md index 771360579..afc9bc970 100644 --- a/tests/playwright/README.md +++ b/tests/playwright/README.md @@ -24,3 +24,11 @@ UPDATE_EXPORTS=true npx playwright test --update-snapshots UPDATE_EXPORTS=true npx playwright test --update-snapshots --project firefox UPDATE_EXPORTS=true npx playwright test procedure.spec.ts:449 --update-snapshots ``` + +### Electron + +Local tests with electron need to have access to the actual screen, it seems. +So they should be run with `-j 1` to have a single worker, and the electron window has to stay visible at least. + +Downloads open a dialog that is not handled by playwright, so there is no testing of electron downloads. +They may be enabled and completed manually by changing the boolean in `project_electron_param.ts` (untested). diff --git a/tests/playwright/procedure.spec.ts b/tests/playwright/procedure.spec.ts index 96ccd82f2..4c495e22a 100644 --- a/tests/playwright/procedure.spec.ts +++ b/tests/playwright/procedure.spec.ts @@ -2,8 +2,10 @@ // Note: trace snapshots that should be taken by playwright are not (absent on right of ui `npx playwright test --ui`) // TODO: test with embedded Kasim? deprecate it? +// TODO: split this in multiple files? -import { test, expect, type Page } from '@playwright/test'; +import { expect, type Page } from '@playwright/test'; +import { test, RUN_DOWNLOADS_IN_ELECTRON } from './project_electron_param'; import * as utils from './webapp_utils'; @@ -25,8 +27,15 @@ const causality_slide_10_ka = '//www.di.ens.fr/~feret/teaching/2023-2024/MPRI.2. test.describe('Editor tab', () => { - test('editor', async ({ page }) => { - await utils.open_app_with_model(page, abc_ka); + test('open_file_from_url', async ({ page, run_in_electron }) => { + test.skip(run_in_electron, "Not relevant in electron: opening url would use the server instead of the electron app."); + + await utils.open_app_with_model(page, abc_ka, run_in_electron, false); + }); + + + test('editor', async ({ page, run_in_electron }) => { + await utils.open_app_with_model(page, abc_ka, run_in_electron); const editor = page.locator('#editor-panel').getByRole('textbox'); async function editor_to_line(n: number): Promise { @@ -40,9 +49,9 @@ test.describe('Editor tab', () => { await editor_to_line(21); // Make a syntax error await editor.press('Backspace'); - // (useless comment to match brackets { {) + // (useless comment to match brackets in editor { ) await utils.expect_error(page, [ - " « 1/1 » [abc.ka] invalid internal state or missing '}' " + " « 1/1 » [model.ka] invalid internal state or missing '}' " ]); await editor_cancel(); await utils.expect_no_error(page); @@ -50,7 +59,7 @@ test.describe('Editor tab', () => { await editor.fill('\n%agent: D(a{u p})'); await utils.expect_error(page, [ - " « 1/1 » [abc.ka] Dead agent D " + " « 1/1 » [model.ka] Dead agent D " ]); await editor_to_line(25); @@ -61,7 +70,7 @@ test.describe('Editor tab', () => { await editor.fill("\n'd' D(a{p}) -> D(a{u}) @ 1"); // await page.locator('#panel_preferences_message_nav_inc_id').click(); await utils.expect_error(page, [ - " « 1/1 » [abc.ka] Dead rule 'd' " + " « 1/1 » [model.ka] Dead rule 'd' " ]); await editor_cancel(); await editor_cancel(); @@ -69,8 +78,8 @@ test.describe('Editor tab', () => { await utils.expect_no_error(page); }); - test('contact_map', async ({ page, browserName }) => { - await utils.open_app_with_model(page, abc_ka); + test('contact_map', async ({ page, run_in_electron, browserName }) => { + await utils.open_app_with_model(page, abc_ka, run_in_electron); const contact_map = page.locator('#map-container'); await expect.soft(contact_map).toHaveScreenshot(); await page.getByRole('checkbox', { name: 'Interactive Mode' }).check(); @@ -88,19 +97,21 @@ test.describe('Editor tab', () => { await page.getByRole('button', { name: 'Reset Zoom' }).click(); await expect.soft(contact_map).toHaveScreenshot(); - await utils.testExports(page, '#export_contact-export', 'map', ['svg', 'json'], undefined, browserName); - if (browserName != "chromium") { - await utils.testExports(page, '#export_contact-export', 'map', ['png'], undefined, browserName); - // TODO: pngs doesn't match on CI's chromium. check if we can test them in some way + if (!run_in_electron || RUN_DOWNLOADS_IN_ELECTRON) { + await utils.testExports(page, '#export_contact-export', 'map', ['svg', 'json'], undefined, browserName); + if (browserName != "chromium") { + await utils.testExports(page, '#export_contact-export', 'map', ['png'], undefined, browserName); + // TODO: pngs doesn't match on CI's chromium. check if we can test them in some way + } } }); - test('influences', async ({ page }) => { + test('influences', async ({ page, run_in_electron }) => { const opts_screen = { maxDiffPixels: 60 } const opts_screen_lenient = { maxDiffPixels: 150, threshold: 0.4 } - await utils.open_app_with_model(page, abc_ka); + await utils.open_app_with_model(page, abc_ka, run_in_electron); await page.locator('#navinfluences').click(); const table = page.locator('#influences-table'); @@ -129,15 +140,17 @@ test.describe('Editor tab', () => { await page.getByRole('button', { name: 'Previous' }).click(); await expect.soft(table).toHaveScreenshot(); //export - await utils.testExports(page, '#export_influence-export', 'influences', ['json']); + if (!run_in_electron || RUN_DOWNLOADS_IN_ELECTRON) { + await utils.testExports(page, '#export_influence-export', 'influences', ['json']); + } }); function constraint_locator(page: Page, n: number) { return (page.locator('#constraints > .panel-scroll > div > .panel-body').nth(n)); } - test('constraints_and_polymers_1', async ({ page }) => { - await utils.open_app_with_model(page, abc_ka); + test('constraints_and_polymers_1', async ({ page, run_in_electron }) => { + await utils.open_app_with_model(page, abc_ka, run_in_electron); await page.locator('#navconstraints').click(); await expect.soft(constraint_locator(page, 0)).toHaveText( `A(c) => [ A(c[.]) v A(c[x1.C]) v A(c[x2.C]) ] @@ -159,8 +172,8 @@ C(x2) => [ C(x2{u}) v C(x2{p}) ] ); }); - test('constraints_and_polymers_2', async ({ page }) => { - await utils.open_app_with_model(page, poly_ka); + test('constraints_and_polymers_2', async ({ page, run_in_electron }) => { + await utils.open_app_with_model(page, poly_ka, run_in_electron); await page.locator('#navpolymers').click(); await expect.soft(page.getByRole('paragraph')).toHaveText( `The following bonds may form arbitrary long chains of agents: @@ -176,8 +189,8 @@ A(c[1]),C(a[1]) `); }); - test('constraints_and_polymers_3', async ({ page }) => { - await utils.open_app_with_model(page, local_views_slide_69_ka, true, 20000); + test('constraints_and_polymers_3', async ({ page, run_in_electron }) => { + await utils.open_app_with_model(page, local_views_slide_69_ka, run_in_electron, true, 20000); await page.locator('#navconstraints').click(); await expect.soft(constraint_locator(page, 0)).toHaveText( `E(x) => [ E(x[.]) v E(x[x.R]) ] @@ -212,8 +225,8 @@ R(CN[C.R],CR[CR.R]) => R(CN[2],CR[1]),R(C[2],CR[1]) ]); }); - test('constraints_and_polymers_4', async ({ page }) => { - await utils.open_app_with_model(page, counter_2_ka); + test('constraints_and_polymers_4', async ({ page, run_in_electron }) => { + await utils.open_app_with_model(page, counter_2_ka, run_in_electron); await page.locator('#navconstraints').click(); await expect.soft(constraint_locator(page, 4)).toHaveText( `A() => A(c{[0 .. 2]}) @@ -221,10 +234,17 @@ R(CN[C.R],CR[CR.R]) => R(CN[2],CR[1]),R(C[2],CR[1]) ); }); - test('contact_map_accuracy', async ({ page }) => { - // TODO: find a smaller example so that execution is faster - test.setTimeout(180000) - await utils.open_app_with_model(page, minikai_counters_ka, false, 120000); + test('contact_map_accuracy', async ({ page, run_in_electron }) => { + await utils.open_app_with_model_from_text(page, + `%agent: A(x,c,d) +%agent: B(x,y) +%agent: C(x1{u p},x2{u p}) +'a.b' A(x[.]),B(x[.]) -> A(x[1]),B(x[1]) @ 'on_rate' //A binds B +'a..b' A(x[1/.]),B(x[1/.]) @ 'off_rate' //AB dissociation +'never_occuring' A(d[1]),B(y[1]) -> A(d[.]), B(y[.]) @ 1 +%init: 12 A(),B() +%init: 13 C()` + , run_in_electron); const contact_map = page.locator('#map-container'); await expect.soft(contact_map).toHaveScreenshot(); await page.locator('#contact_map-accuracy').selectOption('high'); @@ -235,8 +255,8 @@ R(CN[C.R],CR[CR.R]) => R(CN[2],CR[1]),R(C[2],CR[1]) test.describe('Simulation tools', () => { - test('Simulation, plot', async ({ page, browserName }) => { - await utils.open_app_with_model(page, abc_ka); + test('Simulation, plot', async ({ page, run_in_electron, browserName }) => { + await utils.open_app_with_model(page, abc_ka, run_in_electron); await utils.setSeed(page, 1); // Run simulation to 30, then 100, then test plot options await utils.set_pause_if(page, '[T] > 30'); @@ -271,11 +291,13 @@ test.describe('Simulation tools', () => { await page.locator('.panel-footer').click(); // needed for update await expect.soft(page.getByRole('img')).toHaveScreenshot(); - await utils.testExports(page, '#export_plot-export', 'plot', ['csv', 'json', 'tsv'], undefined); - await utils.testExports(page, '#export_plot-export', 'plot', ['svg'], undefined, browserName); - if (browserName != "chromium") { - await utils.testExports(page, '#export_plot-export', 'plot', ['png'], undefined, browserName); - // TODO: pngs doesn't match on CI's chromium. check if we can test them in some way + if (!run_in_electron || RUN_DOWNLOADS_IN_ELECTRON) { + await utils.testExports(page, '#export_plot-export', 'plot', ['csv', 'json', 'tsv'], undefined); + await utils.testExports(page, '#export_plot-export', 'plot', ['svg'], undefined, browserName); + if (browserName != "chromium") { + await utils.testExports(page, '#export_plot-export', 'plot', ['png'], undefined, browserName); + // TODO: pngs doesn't match on CI's chromium. check if we can test them in some way + } } // Test larger plots, slider @@ -296,8 +318,8 @@ test.describe('Simulation tools', () => { await page.getByRole('button', { name: 'pause' }).click(); }); - test('DIN', async ({ page, browserName }) => { - await utils.open_app_with_model(page, abc_ka); + test('DIN', async ({ page, run_in_electron, browserName }) => { + await utils.open_app_with_model(page, abc_ka, run_in_electron); await utils.setSeed(page, 1); async function expectScreenShotDINTable(chromium_maxDiffPixels: number = 0) { @@ -326,7 +348,9 @@ test.describe('Simulation tools', () => { await page.locator('#navDIN').click(); await expectScreenShotDINTable(350); - await utils.testExports(page, '#export_din-export', 'flux', ['json', 'dot', 'html']); + if (!run_in_electron || RUN_DOWNLOADS_IN_ELECTRON) { + await utils.testExports(page, '#export_din-export', 'flux', ['json', 'dot', 'html']); + } await utils.set_pause_if(page, '[T] > 60'); await page.getByRole('button', { name: 'continue' }).click(); @@ -338,14 +362,16 @@ test.describe('Simulation tools', () => { await page.getByRole('combobox').first().selectOption('flux.json'); await expectScreenShotDINTable(3000); - await utils.testExports(page, '#export_din-export', 'flux_json', ['json', 'dot', 'html']); + if (!run_in_electron || RUN_DOWNLOADS_IN_ELECTRON) { + await utils.testExports(page, '#export_din-export', 'flux_json', ['json', 'dot', 'html']); + } await page.getByRole('combobox').first().selectOption('flux.html'); await expectScreenShotDINTable(350); }); - test('snapshots', async ({ page, browserName }) => { - await utils.open_app_with_model(page, abc_ka); + test('snapshots', async ({ page, run_in_electron, browserName }) => { + await utils.open_app_with_model(page, abc_ka, run_in_electron); await utils.setSeed(page, 1); // Generate two snapshots @@ -430,28 +456,30 @@ test.describe('Simulation tools', () => { // await page.locator('#force-container circle').first().click(); // Test exports - await page.locator('#format_select_id').selectOption('Kappa'); - await utils.testExports(page, "#export_snapshot_kappa", "snapshot_kappa", ["json", "kappa", "dot"], - ['', '', '"#\\w{5,6}"']); - await page.locator('#format_select_id').selectOption('Graph'); - await utils.testExports(page, "#export_snapshot_graph", "snapshot_graph", ["json", "kappa", "dot"], ['', '', '"#\\w{5,6}"']); - - await utils.testExports(page, "#export_snapshot_graph", "snapshot_graph", ["svg"], - [' { - await utils.open_app_with_model(page, abc_ka); + test('outputs', async ({ page, run_in_electron }) => { + await utils.open_app_with_model(page, abc_ka, run_in_electron); await utils.setSeed(page, 1); // Generate two snapshots @@ -486,19 +514,20 @@ test.describe('Simulation tools', () => { await page.locator('#output-select-id').selectOption('ab.txt'); await expect.soft(outputs_display).toHaveText("394393"); - const downloadPromise = page.waitForEvent('download'); - await page.getByRole('button', { name: 'All outputs' }).click(); - const download = await downloadPromise; - - utils.compare_zip_files_list_with_ref(download, []); + if (!run_in_electron || RUN_DOWNLOADS_IN_ELECTRON) { + const downloadPromise = page.waitForEvent('download'); + await page.getByRole('button', { name: 'All outputs' }).click(); + const download = await downloadPromise; + utils.compare_zip_files_list_with_ref(download, []); + } }); }); test.describe('stories', () => { - async function setup_stories(page: Page) { - await utils.open_app_with_model(page, causality_slide_10_ka, true); + async function setup_stories(page: Page, run_in_electron: boolean) { + await utils.open_app_with_model(page, causality_slide_10_ka, run_in_electron, true); await utils.setSeed(page, 1); // Enable trace @@ -540,8 +569,8 @@ test.describe('stories', () => { } - test('Empty', async ({ page }) => { - await setup_stories(page); + test('Empty', async ({ page, run_in_electron }) => { + await setup_stories(page, run_in_electron); // No screenshot test as no stories causes no image to locate await computeStoriesAndTest(page, "", `Starting Compression Compression completed @@ -549,8 +578,8 @@ Compression completed `, false); }); - test('Weakly', async ({ page }) => { - await setup_stories(page); + test('Weakly', async ({ page, run_in_electron }) => { + await setup_stories(page, run_in_electron); await page.getByRole('checkbox', { name: 'Weakly' }).check(); await computeStoriesAndTest(page, `ids: 11, 19, 24, 29, 33, 36, 37, 39, 49, 52, 55 @@ -567,8 +596,8 @@ Compression completed `); }); - test('Strongly', async ({ page }) => { - await setup_stories(page); + test('Strongly', async ({ page, run_in_electron }) => { + await setup_stories(page, run_in_electron); await page.getByRole('checkbox', { name: 'Strongly' }).check(); await computeStoriesAndTest(page, `ids: 11, 19, 24, 29, 33, 36, 37, 39, 49, 52, 55, 5, 8, 21, 27, 28, 30, 31, @@ -603,8 +632,8 @@ Compression completed }); - test('Causal + select stories', async ({ page }) => { - await setup_stories(page); + test('Causal + select stories', async ({ page, run_in_electron }) => { + await setup_stories(page, run_in_electron); await page.getByRole('checkbox', { name: 'Causal' }).check(); const computation_log = `Starting Compression Start one causal compression @@ -689,8 +718,8 @@ event=5200, 3184, 2246`, computation_log); }); - test('Weakly + Strongly', async ({ page }) => { - await setup_stories(page); + test('Weakly + Strongly', async ({ page, run_in_electron }) => { + await setup_stories(page, run_in_electron); await page.getByRole('checkbox', { name: 'Weakly' }).check(); await page.getByRole('checkbox', { name: 'Strongly' }).check(); await computeStoriesAndTest(page, @@ -712,19 +741,21 @@ Compression completed `); }); - test('Trace download', async ({ page }) => { - await setup_stories(page); - const downloadPromise = page.waitForEvent('download'); - await page.getByRole('button', { name: 'get trace' }).click(); - const download = await downloadPromise; - await utils.compare_download_to_ref(download, "stories_trace"); + test('Trace download', async ({ page, run_in_electron }) => { + await setup_stories(page, run_in_electron); + if (!run_in_electron || RUN_DOWNLOADS_IN_ELECTRON) { + const downloadPromise = page.waitForEvent('download'); + await page.getByRole('button', { name: 'get trace' }).click(); + const download = await downloadPromise; + await utils.compare_download_to_ref(download, "stories_trace"); + } }); }); test.describe('projects_and_files', () => { - test('project', async ({ page }) => { - await utils.open_app_with_model(page, causality_slide_10_ka, true); + test('project', async ({ page, run_in_electron }) => { + await utils.open_app_with_model(page, causality_slide_10_ka, run_in_electron, true); await utils.setSeed(page, 1); // project tab is `a` in `list`, `list` contains "active" class info, `a` is clickable @@ -770,36 +801,38 @@ test.describe('projects_and_files', () => { // TODO: Could also check simulation results }); - test('files', async ({ page }) => { - await utils.open_app_with_model(page, abc_ka, false); + test('files', async ({ page, run_in_electron }) => { + await utils.open_app_with_model(page, abc_ka, run_in_electron, false); await utils.setSeed(page, 1); - // download file - await page.getByRole('button', { name: 'File' }).click(); - const downloadPromise = page.waitForEvent('download'); - await page.locator('#menu-editor-file-export-li').click(); - const download = await downloadPromise; - await utils.compare_download_to_ref(download, "abc_download.ka"); - const downloaded_path = await download.path(); - - // close it, and reopen it - await page.getByRole('button', { name: 'File' }).click(); - await page.locator('#menu-editor-file-close-li').click(); - await page.getByRole('button', { name: 'File' }).click(); - const fileChooserPromise = page.waitForEvent('filechooser'); - await page.locator('#menu-editor-file-open-li').click(); - const fileChooser = await fileChooserPromise; - await fileChooser.setFiles(downloaded_path); - - // write other file and check contact map - await page.getByRole('button', { name: 'File' }).click(); - await page.locator('#menu-editor-file-new-li').click(); - await page.getByRole('textbox', { name: 'file name' }).click(); - await page.getByRole('textbox', { name: 'file name' }).fill('test.ka'); - await page.getByRole('textbox', { name: 'file name' }).press('Enter'); - await page.locator('.CodeMirror-scroll').click(); - await utils.input_in_editor_from_str(page, - `%agent: K(x) + // TODO: see if we can adapt part of this to electron? + if (!run_in_electron || RUN_DOWNLOADS_IN_ELECTRON) { + // download file + await page.getByRole('button', { name: 'File' }).click(); + const downloadPromise = page.waitForEvent('download'); + await page.locator('#menu-editor-file-export-li').click(); + const download = await downloadPromise; + await utils.compare_download_to_ref(download, "abc_download.ka"); + const downloaded_path = await download.path(); + + // close it, and reopen it + await page.getByRole('button', { name: 'File' }).click(); + await page.locator('#menu-editor-file-close-li').click(); + await page.getByRole('button', { name: 'File' }).click(); + const fileChooserPromise = page.waitForEvent('filechooser'); + await page.locator('#menu-editor-file-open-li').click(); + const fileChooser = await fileChooserPromise; + await fileChooser.setFiles(downloaded_path); + + // write other file and check contact map + await page.getByRole('button', { name: 'File' }).click(); + await page.locator('#menu-editor-file-new-li').click(); + await page.getByRole('textbox', { name: 'file name' }).click(); + await page.getByRole('textbox', { name: 'file name' }).fill('test.ka'); + await page.getByRole('textbox', { name: 'file name' }).press('Enter'); + await page.locator('.CodeMirror-scroll').click(); + await utils.input_in_editor_from_str(page, + `%agent: K(x) %agent: S(a b{u p} c{u p}) %init: 1000 K() %init: 1000 S() @@ -810,20 +843,22 @@ test.describe('projects_and_files', () => { %obs: 'S++' |S(b{p} c{p})| %mod: [true] do $TRACK 'S++' [true] ; ` - ); - await utils.wait_for_file_load(page, { timeout: 10000 }); - const contact_map = page.locator('#map-container'); - - const opts_screen = { maxDiffPixels: 150 } - await expect.soft(contact_map).toHaveScreenshot(opts_screen); - - // TODO: fix this flaky test: sometimes the graph doesn't show, bug? - // simulate and test screenshot - // await utils.set_pause_if(page, '[T] > 30'); - // await page.getByRole('button', { name: 'start' }).click(); - // await utils.wait_for_sim_stop(page, { timeout: 20000 }); - // await page.locator('#navplot').click(); - // await expect.soft(page.getByRole('img')).toHaveScreenshot(); + ); + await utils.wait_for_file_load(page, { timeout: 10000 }); + const contact_map = page.locator('#map-container'); + + const opts_screen = { maxDiffPixels: 150 } + await expect.soft(contact_map).toHaveScreenshot(opts_screen); + + // TODO: fix this flaky test: sometimes the graph doesn't show, bug? + // simulate and test screenshot + // await utils.set_pause_if(page, '[T] > 30'); + // await page.getByRole('button', { name: 'start' }).click(); + // await utils.wait_for_sim_stop(page, { timeout: 20000 }); + // await page.locator('#navplot').click(); + // await expect.soft(page.getByRole('img')).toHaveScreenshot(); + // + } }); }); diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-1-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-1-electron-linux.png new file mode 100644 index 000000000..fc181b995 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-1-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-2-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-2-electron-linux.png new file mode 100644 index 000000000..e2a87d83f Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-2-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-3-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-3-electron-linux.png new file mode 100644 index 000000000..6d4455a7d Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-3-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-4-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-4-electron-linux.png new file mode 100644 index 000000000..bcefde34e Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-4-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-5-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-5-electron-linux.png new file mode 100644 index 000000000..fc181b995 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-5-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-6-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-6-electron-linux.png new file mode 100644 index 000000000..03a55ac16 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-6-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-7-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-7-electron-linux.png new file mode 100644 index 000000000..fc181b995 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-7-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-1-chromium-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-1-chromium-linux.png index 9553b5cd1..b5c46e541 100644 Binary files a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-1-chromium-linux.png and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-1-chromium-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-1-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-1-electron-linux.png new file mode 100644 index 000000000..147a9776b Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-1-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-1-firefox-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-1-firefox-linux.png index 242008379..d22be5c5a 100644 Binary files a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-1-firefox-linux.png and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-1-firefox-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-2-chromium-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-2-chromium-linux.png index 359809ee4..99a0a30d2 100644 Binary files a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-2-chromium-linux.png and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-2-chromium-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-2-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-2-electron-linux.png new file mode 100644 index 000000000..0971b3f71 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-2-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-2-firefox-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-2-firefox-linux.png index 04875fa9f..26267ce7e 100644 Binary files a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-2-firefox-linux.png and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-contact-map-accuracy-2-firefox-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-1-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-1-electron-linux.png new file mode 100644 index 000000000..4038a0d62 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-1-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-10-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-10-electron-linux.png new file mode 100644 index 000000000..042f68cd8 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-10-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-2-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-2-electron-linux.png new file mode 100644 index 000000000..e63bbaa21 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-2-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-3-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-3-electron-linux.png new file mode 100644 index 000000000..cf180297f Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-3-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-4-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-4-electron-linux.png new file mode 100644 index 000000000..c7b3e3a8f Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-4-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-5-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-5-electron-linux.png new file mode 100644 index 000000000..09de1bf10 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-5-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-6-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-6-electron-linux.png new file mode 100644 index 000000000..3843f9c53 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-6-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-7-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-7-electron-linux.png new file mode 100644 index 000000000..efe24a90d Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-7-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-8-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-8-electron-linux.png new file mode 100644 index 000000000..042f68cd8 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-8-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-9-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-9-electron-linux.png new file mode 100644 index 000000000..83d7b4c1a Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Editor-tab-influences-9-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-DIN-1-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-DIN-1-electron-linux.png new file mode 100644 index 000000000..d65646e7f Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-DIN-1-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-DIN-2-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-DIN-2-electron-linux.png new file mode 100644 index 000000000..d65646e7f Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-DIN-2-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-DIN-3-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-DIN-3-electron-linux.png new file mode 100644 index 000000000..87c342561 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-DIN-3-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-DIN-4-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-DIN-4-electron-linux.png new file mode 100644 index 000000000..d65646e7f Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-DIN-4-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-1-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-1-electron-linux.png new file mode 100644 index 000000000..a6703d305 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-1-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-10-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-10-electron-linux.png new file mode 100644 index 000000000..839944d34 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-10-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-11-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-11-electron-linux.png new file mode 100644 index 000000000..b460425f6 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-11-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-12-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-12-electron-linux.png new file mode 100644 index 000000000..b85c5241e Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-12-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-13-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-13-electron-linux.png new file mode 100644 index 000000000..0aca5ed07 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-13-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-2-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-2-electron-linux.png new file mode 100644 index 000000000..839944d34 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-2-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-3-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-3-electron-linux.png new file mode 100644 index 000000000..8af7b47d5 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-3-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-4-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-4-electron-linux.png new file mode 100644 index 000000000..b91fb9b45 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-4-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-5-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-5-electron-linux.png new file mode 100644 index 000000000..4835f06a5 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-5-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-6-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-6-electron-linux.png new file mode 100644 index 000000000..839944d34 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-6-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-7-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-7-electron-linux.png new file mode 100644 index 000000000..5dcb32937 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-7-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-8-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-8-electron-linux.png new file mode 100644 index 000000000..839944d34 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-8-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-9-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-9-electron-linux.png new file mode 100644 index 000000000..56ee69e16 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-Simulation-plot-9-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-snapshots-1-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-snapshots-1-electron-linux.png new file mode 100644 index 000000000..42208e2ef Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-snapshots-1-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-snapshots-2-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-snapshots-2-electron-linux.png new file mode 100644 index 000000000..42208e2ef Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-snapshots-2-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-snapshots-3-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-snapshots-3-electron-linux.png new file mode 100644 index 000000000..940446a8a Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-snapshots-3-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-snapshots-4-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-snapshots-4-electron-linux.png new file mode 100644 index 000000000..1c8d4061b Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-snapshots-4-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-snapshots-5-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-snapshots-5-electron-linux.png new file mode 100644 index 000000000..3ae1c7945 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-snapshots-5-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-snapshots-6-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-snapshots-6-electron-linux.png new file mode 100644 index 000000000..5b101dcb2 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/Simulation-tools-snapshots-6-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/projects-and-files-project-1-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/projects-and-files-project-1-electron-linux.png new file mode 100644 index 000000000..fc181b995 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/projects-and-files-project-1-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/projects-and-files-project-2-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/projects-and-files-project-2-electron-linux.png new file mode 100644 index 000000000..eece45392 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/projects-and-files-project-2-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/projects-and-files-project-3-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/projects-and-files-project-3-electron-linux.png new file mode 100644 index 000000000..fc181b995 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/projects-and-files-project-3-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/stories-Causal-select-stories-1-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/stories-Causal-select-stories-1-electron-linux.png new file mode 100644 index 000000000..7d2089177 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/stories-Causal-select-stories-1-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/stories-Causal-select-stories-2-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/stories-Causal-select-stories-2-electron-linux.png new file mode 100644 index 000000000..861774d79 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/stories-Causal-select-stories-2-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/stories-Causal-select-stories-3-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/stories-Causal-select-stories-3-electron-linux.png new file mode 100644 index 000000000..65fa93a9c Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/stories-Causal-select-stories-3-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/stories-Strongly-1-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/stories-Strongly-1-electron-linux.png new file mode 100644 index 000000000..861774d79 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/stories-Strongly-1-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/stories-Weakly-1-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/stories-Weakly-1-electron-linux.png new file mode 100644 index 000000000..e8d644e70 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/stories-Weakly-1-electron-linux.png differ diff --git a/tests/playwright/procedure.spec.ts-snapshots/stories-Weakly-Strongly-1-electron-linux.png b/tests/playwright/procedure.spec.ts-snapshots/stories-Weakly-Strongly-1-electron-linux.png new file mode 100644 index 000000000..e8d644e70 Binary files /dev/null and b/tests/playwright/procedure.spec.ts-snapshots/stories-Weakly-Strongly-1-electron-linux.png differ diff --git a/tests/playwright/project_electron_param.ts b/tests/playwright/project_electron_param.ts new file mode 100644 index 000000000..a3111e056 --- /dev/null +++ b/tests/playwright/project_electron_param.ts @@ -0,0 +1,56 @@ +// Allows to define an electron project and use this param +// See https://playwright.dev/docs/test-parameterize#parameterized-projects +import { test as test_base } from '@playwright/test'; +import { _electron as electron } from 'playwright'; + +const electron_app_entry_point_path = 'build/Kappapp/resources/app/main.js'; +const electron_exe_path = 'build/Kappapp/kappapp'; + +type TestOptions = { + run_in_electron: boolean; +} + +export const RUN_DOWNLOADS_IN_ELECTRON = false; + +// Note: for adding features https://playwright.dev/docs/api/class-test#test-extend +export const test = test_base.extend({ + // Define an option and provide a default value. + // We can later override it in the config. + run_in_electron: [false, { option: true }], + + // setup electron page if necessary + page: async ({ page, run_in_electron }, use) => { + if (run_in_electron) { + // TODO: check this: probably need to setup this as a fixture ? + console.info("Setting up electron app"); + const electronApp = await electron.launch({ args: [electron_app_entry_point_path], executablePath: electron_exe_path }); + + // TODO: remove? + // Evaluation expression in the Electron context. + const appPath = await electronApp.evaluate(async ({ app }) => { + // This runs in the main Electron process, parameter here is always + // the result of the require('electron') in the main app script. + return app.getAppPath(); + }); + console.log("App path: ", appPath); + + const window = await electronApp.firstWindow(); + // Direct Electron console to Node terminal. + window.on('console', console.log); + + console.log(await window.title()); + + // TODO: add this to a fixture to close the app + // await electronApp.close(); + + await use(window); + window + } else { + // TODO: check if useful + await use(page); + page + } + }, +}); + +// TODO: fixture for launching electron if selected, and setting up page ? YES diff --git a/tests/playwright/webapp_utils.ts b/tests/playwright/webapp_utils.ts index 9e0e7d929..22dd89445 100644 --- a/tests/playwright/webapp_utils.ts +++ b/tests/playwright/webapp_utils.ts @@ -101,10 +101,28 @@ export async function input_in_editor_from_url(page: Page, url_protocol_relative await input_in_editor_from_str(page, model); } -export async function open_app_with_model(page: Page, url_protocol_relative: string, paste_in_editor: boolean = false, timeout: number = 10000) { - if (paste_in_editor) { - // download the file and paste it in the editor +export async function open_app_with_model_from_text(page: Page, model_text: string, run_in_electron: boolean, timeout: number = 10000) { + if (!run_in_electron) { + // load the app if not in electron + // if in electron, the page is already loaded, and we just need to enter the file in the editor await page.goto(url); + } + await wait_for_project_ready_status(page); + await input_in_editor_from_str(page, model_text); + + // Note: if fails in input_in_editor_from_str, it won't wait for second timeout as expect is not expect.soft + await wait_for_file_load(page, { timeout: timeout }); +} + +// TODO: paste_in_editor is now always true, as default is true +export async function open_app_with_model(page: Page, url_protocol_relative: string, run_in_electron: boolean, paste_in_editor: boolean = true, timeout: number = 10000) { + if (paste_in_editor || run_in_electron) { + // download the file and paste it in the editor + if (!run_in_electron) { + // load the app if not in electron + // if in electron, the page is already loaded, and we just need to enter the file in the editor + await page.goto(url); + } await wait_for_project_ready_status(page); await input_in_editor_from_url(page, url_protocol_relative); } else { @@ -116,6 +134,7 @@ export async function open_app_with_model(page: Page, url_protocol_relative: str } export function get_error_field(page: Page) { + // Note: alternative emplacement, showing different info, in case it's relevant // return page.locator('#configuration_error_div'); return page.locator('#configuration_alert_div'); }