-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add e2e scenario related to the window management
- Loading branch information
Showing
5 changed files
with
92 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
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,18 @@ | ||
import { multiremotebrowser, expect } from '@wdio/globals'; | ||
describe('application with changing window', () => { | ||
it('should launch the application first screen', async () => { | ||
const browserA = multiremotebrowser.getInstance('browserA'); | ||
const browserB = multiremotebrowser.getInstance('browserB'); | ||
await expect(browserA).toHaveTitle('Splash window'); | ||
await expect(browserB).toHaveTitle('Splash window'); | ||
}); | ||
|
||
it('should launch the application second screen', async () => { | ||
const browserA = multiremotebrowser.getInstance('browserA'); | ||
const browserB = multiremotebrowser.getInstance('browserB'); | ||
browserA.$('.switch-main-window').click(); | ||
browserB.$('.switch-main-window').click(); | ||
await expect(browserA).toHaveTitle('Test'); | ||
await expect(browserB).toHaveTitle('Test'); | ||
}); | ||
}); |
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,19 @@ | ||
import { expect } from '@wdio/globals'; | ||
import { browser } from 'wdio-electron-service'; | ||
|
||
describe('application with changing window', () => { | ||
it('should launch the application first screen', async () => { | ||
const appName = await browser.electron.execute((electron) => electron.app.getName()); | ||
console.log(`appName: ${appName}`); | ||
await expect(browser).toHaveTitle('Splash window'); | ||
}); | ||
|
||
it('should launch the application second screen', async () => { | ||
const elem = browser.$('.switch-main-window'); | ||
await elem.click(); | ||
|
||
const appName = await browser.electron.execute((electron) => electron.app.getName()); | ||
console.log(`appName: ${appName}`); | ||
await expect(browser).toHaveTitle('Test'); | ||
}); | ||
}); |
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 url from 'node:url'; | ||
import path from 'node:path'; | ||
import fs from 'node:fs'; | ||
|
||
import type { NormalizedPackageJson } from 'read-package-up'; | ||
|
||
import { getElectronVersion } from '@wdio/electron-utils'; | ||
import type { WdioElectronConfig } from '@wdio/electron-types'; | ||
|
||
const exampleDir = process.env.EXAMPLE_DIR || 'forge-esm'; | ||
const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); | ||
const packageJsonPath = path.join(__dirname, '..', 'apps', exampleDir, 'package.json'); | ||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf-8' })) as NormalizedPackageJson; | ||
const appEntryPoint = path.join(__dirname, '..', 'apps', exampleDir, 'dist', 'main.bundle.js'); | ||
|
||
globalThis.packageJson = { | ||
name: 'Electron', | ||
version: getElectronVersion({ packageJson, path: packageJsonPath }) as string, | ||
}; | ||
process.env.TEST = 'true'; | ||
process.env.ENABLE_SPLASH_WINDOW = 'true'; | ||
|
||
export const config: WdioElectronConfig = { | ||
services: [['electron', { restoreMocks: true }]], | ||
capabilities: [ | ||
{ | ||
'browserName': 'electron', | ||
'wdio:electronServiceOptions': { | ||
appEntryPoint, | ||
appArgs: ['foo', 'bar=baz'], | ||
}, | ||
}, | ||
], | ||
waitforTimeout: 5000, | ||
connectionRetryCount: 10, | ||
connectionRetryTimeout: 30000, | ||
logLevel: 'debug', | ||
runner: 'local', | ||
outputDir: `wdio-logs-${exampleDir}`, | ||
specs: ['./test/window/*.spec.ts'], | ||
tsConfigPath: path.join(__dirname, 'tsconfig.json'), | ||
framework: 'mocha', | ||
mochaOpts: { | ||
ui: 'bdd', | ||
timeout: 30000, | ||
}, | ||
}; |