fix: ui tests

This commit is contained in:
sokumon 2025-11-14 08:19:55 +05:30
parent fbf4e29e25
commit c8f499ab2f
3 changed files with 18 additions and 10 deletions

View file

@ -120,7 +120,7 @@ context("Control Link", () => {
cy.get("@input").trigger("mouseover"); cy.get("@input").trigger("mouseover");
cy.get(".frappe-control[data-fieldname=link] .btn-open") cy.get(".frappe-control[data-fieldname=link] .btn-open")
.should("be.visible") .should("be.visible")
.should("have.attr", "href", `/app/todo/${todos[0]}`); .should("have.attr", "href", `/desk/todo/${todos[0]}`);
}); });
}); });
@ -176,7 +176,7 @@ context("Control Link", () => {
it("should update dependant fields (via fetch_from)", () => { it("should update dependant fields (via fetch_from)", () => {
cy.get("@todos").then((todos) => { cy.get("@todos").then((todos) => {
cy.visit(`/app/todo/${todos[0]}`); cy.visit(`/desk/todo/${todos[0]}`);
cy.intercept("POST", "/api/method/frappe.desk.search.search_link").as("search_link"); cy.intercept("POST", "/api/method/frappe.desk.search.search_link").as("search_link");
cy.intercept("/api/method/frappe.client.validate_link*").as("validate_link"); cy.intercept("/api/method/frappe.client.validate_link*").as("validate_link");

View file

@ -27,13 +27,18 @@ frappe.ui.Sidebar = class Sidebar {
} }
prepare() { prepare() {
this.sidebar_data = frappe.boot.workspace_sidebar_item[this.workspace_title.toLowerCase()]; try {
this.workspace_sidebar_items = this.sidebar_data.items; this.sidebar_data =
if (this.edit_mode) { frappe.boot.workspace_sidebar_item[this.workspace_title.toLowerCase()];
this.workspace_sidebar_items = this.new_sidebar_items; this.workspace_sidebar_items = this.sidebar_data.items;
if (this.edit_mode) {
this.workspace_sidebar_items = this.new_sidebar_items;
}
this.choose_app_name();
this.find_nested_items();
} catch (e) {
console.log(e);
} }
this.choose_app_name();
this.find_nested_items();
} }
choose_app_name() { choose_app_name() {
@ -350,7 +355,9 @@ frappe.ui.Sidebar = class Sidebar {
workspace_title = this.get_correct_workspace_sidebars(route); workspace_title = this.get_correct_workspace_sidebars(route);
} }
let module_name = workspace_title[0]; let module_name = workspace_title[0];
frappe.app.sidebar.setup(module_name || this.workspace_title); if (module_name) {
frappe.app.sidebar.setup(module_name || this.workspace_title);
}
} }
get_correct_workspace_sidebars(link_to) { get_correct_workspace_sidebars(link_to) {
@ -718,6 +725,7 @@ frappe.ui.Sidebar = class Sidebar {
message: __("Saving Sidebar"), message: __("Saving Sidebar"),
indicator: "success", indicator: "success",
}); });
await frappe.call({ await frappe.call({
type: "POST", type: "POST",
method: "frappe.desk.doctype.workspace_sidebar.workspace_sidebar.add_sidebar_items", method: "frappe.desk.doctype.workspace_sidebar.workspace_sidebar.add_sidebar_items",

View file

@ -62,7 +62,7 @@ frappe.ui.SidebarHeader = class SidebarHeader {
this.$drop_icon = this.wrapper.find(".drop-icon"); this.$drop_icon = this.wrapper.find(".drop-icon");
} }
set_header_icon() { set_header_icon() {
this.header_icon = this.sidebar.sidebar_data.header_icon; if (this.sidebar.sidebar_data) this.header_icon = this.sidebar.sidebar_data.header_icon;
} }
setup_app_switcher() { setup_app_switcher() {
this.dropdown_menu = $(".sidebar-header-menu"); this.dropdown_menu = $(".sidebar-header-menu");