fix(tests): update cli.js app fixture (#1469)

This commit is contained in:
Lucas Fernandes Nogueira 2021-04-13 01:47:34 -03:00 committed by GitHub
parent 5b6c7bb6ee
commit 64d7625b28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 42 additions and 44 deletions

View File

@ -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'

View File

@ -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>

View File

@ -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"

View 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()
}

View File

@ -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");
}

View File

@ -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
}
]
}

View File

@ -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")]

View File

@ -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": {