-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dbbfec2
commit 3c3ae3c
Showing
5 changed files
with
95 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,22 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<script> | ||
document.addEventListener('DOMContentLoaded', () => { | ||
document.getElementById('nw-app-argv').innerText = nw.App.argv; | ||
}); | ||
</script> | ||
<title>nw.App fixture</title> | ||
</head> | ||
|
||
<body> | ||
<div> | ||
<span>nw.App.argv: </span> | ||
<span id="nw-app-argv"></span> | ||
</div> | ||
</body> | ||
|
||
</html> |
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,4 @@ | ||
{ | ||
"name": "basic", | ||
"main": "index.html" | ||
} |
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,59 @@ | ||
import path from 'node:path'; | ||
|
||
import selenium from 'selenium-webdriver'; | ||
import chrome from 'selenium-webdriver/chrome.js'; | ||
import { afterAll, beforeAll, describe, expect, it } from 'vitest'; | ||
|
||
import * as nw from 'nw'; | ||
|
||
describe('nw.App', { timeout: Infinity }, async function () { | ||
/** | ||
* @type {chrome.Driver} | ||
*/ | ||
let driver = undefined; | ||
|
||
/** | ||
* @type {string} | ||
*/ | ||
let chromedriverPath = undefined; | ||
|
||
beforeAll(async () => { | ||
const options = new chrome.Options(); | ||
const args = [ | ||
`--nwapp=${path.resolve('tests', 'fixtures', 'app')}`, | ||
'--headless=new', | ||
]; | ||
options.addArguments(args); | ||
chromedriverPath = await nw.findpath('chromedriver', { flavor: 'sdk' }); | ||
const service = new chrome.ServiceBuilder(chromedriverPath).build(); | ||
driver = chrome.Driver.createSession(options, service); | ||
}); | ||
|
||
it('renders nw.App.argv', async () => { | ||
/** | ||
* `nw.App.argv` looks similar to the following: | ||
* | ||
* `"--allow-pre-commit-input,--disable-popup-blocking,--enable-automation,--enable-logging,--headless=new,--user-data-dir=/tmp/.io.nwjs.reD0Us"` | ||
* | ||
* @type {string} | ||
*/ | ||
const argv = await driver.findElement(selenium.By.id('nw-app-argv')).getText(); | ||
|
||
/* There should be 6 command line arguments. */ | ||
const argvLength = argv.split(',').length; | ||
expect(argvLength).toBe(6); | ||
|
||
/* Since order does not matter, the `.toContain` matcher is used.*/ | ||
expect(argv).toContain('--allow-pre-commit-input'); | ||
expect(argv).toContain('--disable-popup-blocking'); | ||
expect(argv).toContain('--enable-automation'); | ||
expect(argv).toContain('--enable-logging'); | ||
expect(argv).toContain('--headless=new'); | ||
expect(argv).toContain('--user-data-dir='); | ||
}); | ||
|
||
afterAll(async function () { | ||
await driver.quit(); | ||
}); | ||
|
||
}); |