-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add e2e test * add whisper & ffmpeg command validate test * remove tests-examples
- Loading branch information
Showing
7 changed files
with
224 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Playwright Tests | ||
on: workflow_dispatch | ||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [macos-11, macos-12, macos-13, macos-latest, windows-latest, ubuntu-latest] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
- name: Install dependencies | ||
run: npm install -g yarn && yarn | ||
# - name: Install Playwright Browsers | ||
# run: yarn playwright install --with-deps | ||
- name: Package | ||
run: yarn package:enjoy | ||
- name: Run Playwright tests | ||
run: yarn test:enjoy | ||
- uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { expect, test } from "@playwright/test"; | ||
import { | ||
clickMenuItemById, | ||
findLatestBuild, | ||
ipcMainCallFirstListener, | ||
ipcRendererCallFirstListener, | ||
parseElectronApp, | ||
ipcMainInvokeHandler, | ||
ipcRendererInvoke, | ||
} from "electron-playwright-helpers"; | ||
import { ElectronApplication, Page, _electron as electron } from "playwright"; | ||
|
||
declare global { | ||
interface Window { | ||
__ENJOY_APP__: any; | ||
} | ||
} | ||
|
||
let electronApp: ElectronApplication; | ||
|
||
test.beforeAll(async () => { | ||
// find the latest build in the out directory | ||
const latestBuild = findLatestBuild(); | ||
// parse the directory and find paths and other info | ||
const appInfo = parseElectronApp(latestBuild); | ||
// set the CI environment variable to true | ||
process.env.CI = "e2e"; | ||
electronApp = await electron.launch({ | ||
args: [appInfo.main], | ||
executablePath: appInfo.executable, | ||
}); | ||
electronApp.on("window", async (page) => { | ||
const filename = page.url()?.split("/").pop(); | ||
console.log(`Window opened: ${filename}`); | ||
|
||
// capture errors | ||
page.on("pageerror", (error) => { | ||
console.error(error); | ||
}); | ||
// capture console messages | ||
page.on("console", (msg) => { | ||
console.log(msg.text()); | ||
}); | ||
}); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await electronApp.close(); | ||
}); | ||
|
||
let page: Page; | ||
|
||
test("renders the first page", async () => { | ||
page = await electronApp.firstWindow(); | ||
const title = await page.title(); | ||
expect(title).toBe("Enjoy"); | ||
}); | ||
|
||
test("validate whisper command", async () => { | ||
page = await electronApp.firstWindow(); | ||
const res = await page.evaluate(() => { | ||
return window.__ENJOY_APP__.whisper.check(); | ||
}); | ||
expect(res.success).toBeTruthy(); | ||
}); | ||
|
||
test("valid ffmpeg command", async () => { | ||
page = await electronApp.firstWindow(); | ||
const res = await page.evaluate(() => { | ||
return window.__ENJOY_APP__.ffmpeg.check(); | ||
}); | ||
expect(res).toBeTruthy(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { defineConfig, devices } from "@playwright/test"; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// require('dotenv').config(); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: "./e2e", | ||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: "html", | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
// baseURL: 'http://127.0.0.1:3000', | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: "on-first-retry", | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
// projects: [ | ||
// { | ||
// name: "chromium", | ||
// use: { ...devices["Desktop Chrome"] }, | ||
// }, | ||
// ], | ||
|
||
/* Run your local dev server before starting the tests */ | ||
// webServer: { | ||
// command: 'npm run start', | ||
// url: 'http://127.0.0.1:3000', | ||
// reuseExistingServer: !process.env.CI, | ||
// }, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters