diff --git a/app/app-e2e-tests/e2e/example.spec.ts b/app/app-e2e-tests/e2e/example.spec.ts index d2e41c5219..7f52d41506 100644 --- a/app/app-e2e-tests/e2e/example.spec.ts +++ b/app/app-e2e-tests/e2e/example.spec.ts @@ -1,4 +1,4 @@ -import { expect, Page, test } from '@playwright/test'; +import { expect, test } from '@playwright/test'; import { _electron } from '@playwright/test'; import { spawn } from 'child_process'; @@ -88,34 +88,6 @@ test('launch app', async () => { // await window.click('text=Click me'); }); -class HeadlampPage { - constructor(private page: Page) {} - - async homepage() { - await this.page.goto('http://localhost:3000/'); - await this.page.waitForLoadState('domcontentloaded'); - await this.page.waitForSelector('button'); - await this.page.click('button'); - } -} - -test('launch app w/page', async () => { - // Launch Electron app. - const electronApp = await electron.launch({ - cwd: '/home/vtaylor/headlamp/app/electron', - timeout: 0, - args: ['main.js'], - }); - - // const context = await electronApp.context(); - const page = await electronApp.firstWindow(); - const headlampPage = new HeadlampPage(page); - - electronApp.on('window', async () => { - await headlampPage.homepage(); - }); -}); - test('launch app with integrated shell commands', async () => { // Start the frontend server await runCommand('npm', ['start'], { cwd: '/home/vtaylor/headlamp/frontend' }); diff --git a/app/app-e2e-tests/e2e/tests/demo-test.spec.ts b/app/app-e2e-tests/e2e/tests/demo-test.spec.ts new file mode 100644 index 0000000000..9f43e66ca5 --- /dev/null +++ b/app/app-e2e-tests/e2e/tests/demo-test.spec.ts @@ -0,0 +1,52 @@ +import { test } from '@playwright/test'; +import { _electron } from '@playwright/test'; +import { headlampAppPage } from './demo-test'; + +const electron = _electron; +let electronApp; + +test.beforeAll(async () => { + // Launch Electron app. + electronApp = await electron.launch({ + cwd: '/home/vtaylor/headlamp/app/electron', + timeout: 0, + args: ['main.js'], + }); +}); + +test('launch app / check homepage', async () => { + // Launch Electron app. + + // note: may use .context() instead of .firstWindow()? + // const context = await electronApp.context(); + + // note: firstWindow returns a page object so we can replace the window object + const page = await electronApp.firstWindow(); + const headlampPage = new headlampAppPage(page); + + await headlampPage.navHomepage(); + + electronApp.close(); + // electronApp.on('window', async () => { + // await headlampPage.homepage(); + // }); +}); + +test('launch app / check notifications', async () => { + // Launch Electron app. + // const electronApp = await electron.launch({ + // cwd: '/home/vtaylor/headlamp/app/electron', + // timeout: 0, + // args: ['main.js'], + // }); + + const page = await electronApp.firstWindow(); + const headlampPage = new headlampAppPage(page); + + await headlampPage.navNotifactions(); + + electronApp.close(); + // electronApp.on('window', async () => { + // await headlampPage.notifications(); + // }); +}); diff --git a/app/app-e2e-tests/e2e/tests/demo-test.ts b/app/app-e2e-tests/e2e/tests/demo-test.ts new file mode 100644 index 0000000000..a5f10bc43e --- /dev/null +++ b/app/app-e2e-tests/e2e/tests/demo-test.ts @@ -0,0 +1,23 @@ +import { expect, Page } from '@playwright/test'; + +export class headlampAppPage { + constructor(private page: Page) {} + + async navHomepage() { + await this.page.waitForLoadState('domcontentloaded'); + await this.page.goto('http://localhost:3000/'); + + await expect(this.page.getByRole('button', { name: 'Home' })).toBeVisible(); + await this.page.getByRole('button', { name: 'Home' }).click(); + } + + async navNotifactions() { + await this.page.waitForLoadState('domcontentloaded'); + await this.page.goto('http://localhost:3000/'); + + await expect(this.page.getByRole('button', { name: 'Notifications' })).toBeVisible(); + await this.page.getByRole('button', { name: 'Notifications' }).click(); + + await expect(this.page.getByRole('heading', { name: 'Notifications' })).toBeVisible(); + } +} diff --git a/app/app-e2e-tests/tests/demo-test.spec.ts b/app/app-e2e-tests/tests/demo-test.spec.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/app/app-e2e-tests/tests/demo-test.ts b/app/app-e2e-tests/tests/demo-test.ts deleted file mode 100644 index e69de29bb2..0000000000