mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-19 00:21:32 +03:00
test(tauri.js) update fixture app and fix build/dev e2e tests (#1058)
This commit is contained in:
parent
92908c7e91
commit
a3b724738e
@ -41,6 +41,7 @@ module.exports = {
|
|||||||
transform: {
|
transform: {
|
||||||
'templates[\\\\/](tauri|mutation-observer).js':
|
'templates[\\\\/](tauri|mutation-observer).js':
|
||||||
'./test/jest/raw-loader-transformer.js',
|
'./test/jest/raw-loader-transformer.js',
|
||||||
|
'api[\\\\/]tauri.bundle.umd.js': './test/jest/raw-loader-transformer.js',
|
||||||
'\\.(js|ts)$': 'babel-jest'
|
'\\.(js|ts)$': 'babel-jest'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,8 @@ function runBuildTest(tauriConfig) {
|
|||||||
describe('Tauri Build', () => {
|
describe('Tauri Build', () => {
|
||||||
const build = {
|
const build = {
|
||||||
devPath: distDir,
|
devPath: distDir,
|
||||||
distDir: distDir
|
distDir: distDir,
|
||||||
|
withGlobalTauri: true
|
||||||
}
|
}
|
||||||
|
|
||||||
it.each`
|
it.each`
|
||||||
@ -77,6 +78,9 @@ describe('Tauri Build', () => {
|
|||||||
debug: flag === 'debug'
|
debug: flag === 'debug'
|
||||||
},
|
},
|
||||||
tauri: {
|
tauri: {
|
||||||
|
allowlist: {
|
||||||
|
all: true
|
||||||
|
},
|
||||||
embeddedServer: {
|
embeddedServer: {
|
||||||
active: mode === 'embedded-server'
|
active: mode === 'embedded-server'
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,8 @@ function runDevTest(tauriConfig) {
|
|||||||
|
|
||||||
describe('Tauri Dev', () => {
|
describe('Tauri Dev', () => {
|
||||||
const build = {
|
const build = {
|
||||||
distDir: distDir
|
distDir: distDir,
|
||||||
|
withGlobalTauri: true
|
||||||
}
|
}
|
||||||
|
|
||||||
const devServer = startDevServer()
|
const devServer = startDevServer()
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
return window.__TAURI__.fs
|
return window.__TAURI__.fs
|
||||||
.writeFile(
|
.writeFile(
|
||||||
{
|
{
|
||||||
file: 'tauri-test.txt',
|
path: 'tauri-test.txt',
|
||||||
contents: contents
|
contents: contents
|
||||||
},
|
},
|
||||||
options
|
options
|
||||||
@ -136,7 +136,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
window.__TAURI__.invoke({
|
window.__TAURI_INVOKE_HANDLER__({
|
||||||
cmd: 'exit'
|
cmd: 'exit'
|
||||||
})
|
})
|
||||||
}, 15000)
|
}, 15000)
|
||||||
|
@ -27,7 +27,7 @@ serde_derive = "1.0"
|
|||||||
tiny_http = "0.7"
|
tiny_http = "0.7"
|
||||||
phf = "0.8.0"
|
phf = "0.8.0"
|
||||||
includedir = "0.6.0"
|
includedir = "0.6.0"
|
||||||
tauri = { path = "../../../../../../../tauri", features = [ "all-api", "edge" ] }
|
tauri = { path = "../../../../../../../tauri", features = [ "all-api" ] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
embedded-server = [ "tauri/embedded-server" ]
|
embedded-server = [ "tauri/embedded-server" ]
|
||||||
|
@ -7,23 +7,26 @@ extern crate serde_json;
|
|||||||
fn main() {
|
fn main() {
|
||||||
tauri::AppBuilder::new()
|
tauri::AppBuilder::new()
|
||||||
.setup(|webview, _| {
|
.setup(|webview, _| {
|
||||||
let handle = webview.handle();
|
let mut webview_ = webview.as_mut();
|
||||||
tauri::event::listen(String::from("hello"), move |_| {
|
tauri::event::listen(String::from("hello"), move |_| {
|
||||||
tauri::event::emit(&handle, String::from("reply"), Some("{ msg: 'TEST' }".to_string()));
|
tauri::event::emit(
|
||||||
|
&mut webview_,
|
||||||
|
String::from("reply"),
|
||||||
|
Some("{ msg: 'TEST' }".to_string()),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
});
|
});
|
||||||
webview.eval("window.onTauriInit && window.onTauriInit()").unwrap();
|
webview.eval("window.onTauriInit && window.onTauriInit()");
|
||||||
})
|
})
|
||||||
.invoke_handler(|webview, arg| {
|
.invoke_handler(|webview, arg| {
|
||||||
use cmd::Cmd::*;
|
use cmd::Cmd::*;
|
||||||
match serde_json::from_str(arg) {
|
match serde_json::from_str(arg) {
|
||||||
Err(e) => {
|
Err(e) => Err(e.to_string()),
|
||||||
Err(e.to_string())
|
|
||||||
}
|
|
||||||
Ok(command) => {
|
Ok(command) => {
|
||||||
match command {
|
match command {
|
||||||
// definitions for your custom commands from Cmd here
|
// definitions for your custom commands from Cmd here
|
||||||
Exit { } => {
|
Exit {} => {
|
||||||
webview.exit();
|
webview.terminate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user