fix: cypress and add check for __islocal

changed check for __islocal as well in savedocs

As new route ends with random hash instead of numbers,
updated cypress test to just check start of data-route instead of entire path
This commit is contained in:
Maharshi Patel 2023-10-17 16:05:00 +05:30
parent 0c9efd3b5a
commit fd1fe44850
2 changed files with 5 additions and 4 deletions

View file

@ -254,7 +254,10 @@ Cypress.Commands.add("awesomebar", (text) => {
Cypress.Commands.add("new_form", (doctype) => {
let dt_in_route = doctype.toLowerCase().replace(/ /g, "-");
cy.visit(`/app/${dt_in_route}/new`);
cy.get("body").should("have.attr", "data-route", `Form/${doctype}/new-${dt_in_route}-1`);
cy.get("body").should(($body) => {
const dataRoute = $body.attr("data-route");
expect(dataRoute).to.match(new RegExp(`^Form/${doctype}/new-${dt_in_route}-`));
});
cy.get("body").should("have.attr", "data-ajax-state", "complete");
});

View file

@ -17,9 +17,7 @@ def savedocs(doc, action):
"""save / submit / update doclist"""
doc = frappe.get_doc(json.loads(doc))
capture_doc(doc, action)
if doc.doctype not in ["DocType", "File"] and doc.name.startswith(
"new-" + doc.doctype.lower().replace(" ", "-")
):
if doc.get("__islocal") and doc.name.startswith("new-" + doc.doctype.lower().replace(" ", "-")):
# required to relink missing attachments if they exist.
doc.__temporary_name = doc.name
set_local_name(doc)