mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-11-28 20:48:52 +03:00
fix(tests): update cli.js app fixture (#1469)
This commit is contained in:
parent
5b6c7bb6ee
commit
64d7625b28
@ -20,6 +20,7 @@ function runBuildTest(args) {
|
||||
setTimeout(resolve, 2000)
|
||||
})
|
||||
process.chdir(appDir)
|
||||
console.log(server)
|
||||
await build(args).promise
|
||||
|
||||
const artifactFolder = args.debug ? 'debug' : 'release'
|
||||
|
@ -5,16 +5,13 @@
|
||||
function callBackEnd(route, args) {
|
||||
console.log(route)
|
||||
console.log(args)
|
||||
var xhr = new XMLHttpRequest()
|
||||
xhr.onload = function () {
|
||||
console.log(route, args, 'done', xhr.status)
|
||||
}
|
||||
xhr.onerror = function () {
|
||||
console.log(route, args, 'error with ' + xhr.status)
|
||||
}
|
||||
xhr.open('POST', 'http://localhost:7000/' + route)
|
||||
xhr.setRequestHeader('Content-type', 'application/json')
|
||||
xhr.send(JSON.stringify(args))
|
||||
window.__TAURI__.http
|
||||
.fetch('http://localhost:7000/' + route, {
|
||||
method: 'POST',
|
||||
body: window.__TAURI__.http.Body.json(args),
|
||||
responseType: window.__TAURI__.http.ResponseType.Binary
|
||||
})
|
||||
.catch(console.error)
|
||||
}
|
||||
|
||||
function reply(args) {
|
||||
@ -136,7 +133,7 @@
|
||||
})
|
||||
|
||||
setTimeout(function () {
|
||||
window.rpc.notify('exit')
|
||||
window.__TAURI__.invoke('exit')
|
||||
}, 15000)
|
||||
</script>
|
||||
</body>
|
||||
|
@ -4,10 +4,9 @@ workspace = { }
|
||||
name = "app"
|
||||
version = "0.1.0"
|
||||
description = "A Tauri App"
|
||||
author = [ "Daniel Thompson-Yvetot" ]
|
||||
authors = [ "Daniel Thompson-Yvetot" ]
|
||||
license = ""
|
||||
repository = ""
|
||||
default-run = "app"
|
||||
edition = "2018"
|
||||
|
||||
[package.metadata.bundle]
|
||||
@ -20,6 +19,9 @@ icon = [
|
||||
"icons/icon.ico"
|
||||
]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { path = "../../../../../../../core/tauri-build" }
|
||||
|
||||
[dependencies]
|
||||
serde_json = "1.0.64"
|
||||
serde = "1.0"
|
||||
@ -27,8 +29,5 @@ serde_derive = "1.0"
|
||||
tauri = { path = "../../../../../../../core/tauri", features =["api-all"]}
|
||||
|
||||
[features]
|
||||
default = [ "custom-protocol" ]
|
||||
custom-protocol = [ "tauri/custom-protocol" ]
|
||||
|
||||
[[bin]]
|
||||
name = "app"
|
||||
path = "src/main.rs"
|
||||
|
7
tooling/cli.js/test/jest/fixtures/app/src-tauri/build.rs
Normal file
7
tooling/cli.js/test/jest/fixtures/app/src-tauri/build.rs
Normal file
@ -0,0 +1,7 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
}
|
@ -1,26 +1,20 @@
|
||||
use tauri::ApplicationDispatcherExt;
|
||||
#[tauri::command(with_window)]
|
||||
fn exit<M: tauri::Params>(window: tauri::Window<M>) {
|
||||
window.close().unwrap();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
tauri::Builder::default()
|
||||
.setup(|webview_manager| async move {
|
||||
let mut webview_manager_ = webview_manager.clone();
|
||||
tauri::event::listen(String::from("hello"), move |_| {
|
||||
tauri::event::emit(
|
||||
&webview_manager_,
|
||||
String::from("reply"),
|
||||
Some("{ msg: 'TEST' }".to_string()),
|
||||
)
|
||||
.unwrap();
|
||||
.on_page_load(|window, _| {
|
||||
let window_ = window.clone();
|
||||
window.listen("hello".into(), move |_| {
|
||||
window_
|
||||
.emit(&"reply".to_string(), Some("{ msg: 'TEST' }".to_string()))
|
||||
.unwrap();
|
||||
});
|
||||
webview_manager
|
||||
.current_webview()
|
||||
.eval("window.onTauriInit && window.onTauriInit()");
|
||||
})
|
||||
.invoke_handler(|webview_manager, command, _arg| async move {
|
||||
if &command == "exit" {
|
||||
webview_manager.close().unwrap();
|
||||
}
|
||||
window.eval("window.onTauriInit()").unwrap();
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![exit])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error encountered while running tauri application");
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
{
|
||||
"build": {
|
||||
"devPath": "http://localhost:4000",
|
||||
"distDir": "../dist"
|
||||
"devPath": "../dist",
|
||||
"distDir": "../dist",
|
||||
"withGlobalTauri": true
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
@ -19,7 +20,8 @@
|
||||
},
|
||||
"windows": [
|
||||
{
|
||||
"title": "Fixture"
|
||||
"title": "Fixture",
|
||||
"visible": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ pub struct PackageConfig {
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct BundleConfig {
|
||||
/// Whether we should build your app with tauri-bundler or plain `cargo build`
|
||||
#[serde(default)]
|
||||
pub active: bool,
|
||||
/// The bundle targets, currently supports ["deb", "app", "msi", "appimage", "dmg"] or "all"
|
||||
pub targets: Option<BundleTarget>,
|
||||
@ -535,6 +536,7 @@ impl TauriConfig {
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct UpdaterConfig {
|
||||
/// Whether the updater is active or not.
|
||||
#[serde(default)]
|
||||
pub active: bool,
|
||||
/// Display built-in dialog or use event system if disabled.
|
||||
#[serde(default = "default_dialog")]
|
||||
|
@ -242,12 +242,10 @@
|
||||
},
|
||||
"BundleConfig": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"active"
|
||||
],
|
||||
"properties": {
|
||||
"active": {
|
||||
"description": "Whether we should build your app with tauri-bundler or plain `cargo build`",
|
||||
"default": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
"category": {
|
||||
@ -966,12 +964,10 @@
|
||||
},
|
||||
"UpdaterConfig": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"active"
|
||||
],
|
||||
"properties": {
|
||||
"active": {
|
||||
"description": "Whether the updater is active or not.",
|
||||
"default": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
"dialog": {
|
||||
|
Loading…
Reference in New Issue
Block a user