Skip to content

Commit

Permalink
feat: add report
Browse files Browse the repository at this point in the history
  • Loading branch information
jincheng.zhang committed May 24, 2024
1 parent 5ca7e17 commit 77cf0da
Show file tree
Hide file tree
Showing 4 changed files with 7,461 additions and 1 deletion.
23 changes: 23 additions & 0 deletions crates/netpurr/src/panels/test_editor_panel.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
use std::cell::RefCell;
use std::ops::Deref;
use std::path::PathBuf;
use std::rc::Rc;
use std::sync::{Arc, RwLock};

use eframe::epaint::{Color32, FontFamily, FontId};
use egui::{Align, FontSelection, RichText, Style, Ui};
use egui::text::LayoutJob;
use log::info;
use poll_promise::Promise;
use strum::IntoEnumIterator;
use strum_macros::{Display, EnumIter};
use egui_toast::Toast;

use netpurr_core::data::collections::{CollectionFolder, Testcase};
use netpurr_core::data::record::Record;
Expand Down Expand Up @@ -66,6 +69,8 @@ impl TestEditorPanel {
) {
if let Some(p) = &self.run_promise {
if p.ready().is_some() {
//这里应该是测试完毕了
operation.add_success_toast("Test all right");
self.run_promise = None
}
}
Expand Down Expand Up @@ -193,6 +198,11 @@ impl TestEditorPanel {
}

}
fn export_report(&self,path:PathBuf){
self.test_group_run_result.clone().map(|result|{
result.read().unwrap().export(path);
});
}
fn render_test_item_folder(
&mut self,
operation: &Operation,
Expand Down Expand Up @@ -323,6 +333,19 @@ impl TestEditorPanel {
folder.clone(),
);
}
ui.add_enabled_ui(self.test_group_run_result.is_some(),|ui|{
if ui.button("Export Report").clicked(){
if let Some(path) = rfd::FileDialog::new()
.add_filter("html",&["html"])
.set_title("Export Report")
.set_file_name("report")
.save_file() {
info!("export report path: {:?}",path);
self.export_report(path);
}
}
});

}else{
if ui.button("Stop Test").clicked() {
match &self.test_group_run_result {
Expand Down
Loading

0 comments on commit 77cf0da

Please sign in to comment.