Skip to content

Commit

Permalink
Merge branch 'version-14' of https://github.com/frappe/frappe into ve…
Browse files Browse the repository at this point in the history
…rsion-14
  • Loading branch information
aliriocastro committed Nov 5, 2023
2 parents 548e007 + 64c5705 commit 150b82f
Show file tree
Hide file tree
Showing 111 changed files with 1,638 additions and 319 deletions.
118 changes: 115 additions & 3 deletions cypress/integration/control_attach.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,25 @@ context("Attach Control", () => {
//Clicking on the attach button which is displayed as part of creating a doctype with "Attach" fieldtype
cy.findByRole("button", { name: "Attach" }).click();

//Clicking on "Link" button to attach a file using the "Link" button
cy.findByRole("button", { name: "Link" }).click();
cy.findByPlaceholderText("Attach a web link").type(
"https://wallpaperplay.com/walls/full/8/2/b/72402.jpg",
{ force: true }
);

//Clicking on the Upload button to upload the file
cy.intercept("POST", "/api/method/upload_file").as("upload_image");
cy.get(".modal-footer").findByRole("button", { name: "Upload" }).click({ delay: 500 });
cy.wait("@upload_image");
cy.findByRole("button", { name: "Save" }).click();

//Navigating to the new form for the newly created doctype to check Library button
cy.new_form("Test Attach Control");

//Clicking on the attach button which is displayed as part of creating a doctype with "Attach" fieldtype
cy.findByRole("button", { name: "Attach" }).click();

//Clicking on "Library" button to attach a file using the "Library" button
cy.findByRole("button", { name: "Library" }).click();
cy.contains("72402.jpg").click();
Expand All @@ -85,9 +104,10 @@ context("Attach Control", () => {
//Checking if clicking on the clear button clears the field of the doctype form and again displays the attach button
cy.get(".control-input > .btn-sm").should("contain", "Attach");

//Deleting the doc
//Deleting both docs
cy.go_to_list("Test Attach Control");
cy.get(".list-row-checkbox").eq(0).click();
cy.get(".list-row-checkbox").eq(1).click();
cy.get(".actions-btn-group > .btn").contains("Actions").click();
cy.get('.actions-btn-group > .dropdown-menu [data-label="Delete"]').click();
cy.click_modal_primary_button("Yes");
Expand All @@ -106,7 +126,10 @@ context("Attach Control", () => {
};
},
});
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");

//Clicking on the attach button which is displayed as part of creating a doctype with "Attach" fieldtype
Expand All @@ -126,7 +149,10 @@ context("Attach Control", () => {
delete win.navigator.mediaDevices;
},
});
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");

//Clicking on the attach button which is displayed as part of creating a doctype with "Attach" fieldtype
Expand All @@ -136,3 +162,89 @@ context("Attach Control", () => {
cy.findByRole("button", { name: "Camera" }).should("not.exist");
});
});
context("Attach Control with Failed Document Save", () => {
before(() => {
cy.login();
cy.visit("/app/doctype");
return cy
.window()
.its("frappe")
.then((frappe) => {
return frappe.xcall("frappe.tests.ui_test_helpers.create_doctype", {
name: "Test Mandatory Attach Control",
fields: [
{
label: "Attach File or Image",
fieldname: "attach",
fieldtype: "Attach",
in_list_view: 1,
},
{
label: "Mandatory Text Field",
fieldname: "text_field",
fieldtype: "Text Editor",
in_list_view: 1,
reqd: 1,
},
],
});
});
});
let temp_name = "";
let docname = "";
it("Attaching a file on an unsaved document", () => {
//Navigating to the new form for the newly created doctype
cy.new_form("Test Mandatory Attach Control");
cy.get("body").should(($body) => {
temp_name = $body.attr("data-route").split("/")[2];
});

//Clicking on the attach button which is displayed as part of creating a doctype with "Attach" fieldtype
cy.findByRole("button", { name: "Attach" }).click();

//Clicking on "Link" button to attach a file using the "Link" button
cy.findByRole("button", { name: "Link" }).click();
cy.findByPlaceholderText("Attach a web link").type(
"https://wallpaperplay.com/walls/full/8/2/b/72402.jpg",
{ force: true }
);

//Clicking on the Upload button to upload the file
cy.intercept("POST", "/api/method/upload_file").as("upload_image");
cy.get(".modal-footer").findByRole("button", { name: "Upload" }).click({ delay: 500 });
cy.wait("@upload_image");
cy.get(".msgprint-dialog .modal-title").contains("Missing Fields").should("be.visible");
cy.hide_dialog();
cy.fill_field("text_field", "Random value", "Text Editor").wait(500);
cy.findByRole("button", { name: "Save" }).click().wait(500);

//Checking if the URL of the attached image is getting displayed in the field of the newly created doctype
cy.get(".attached-file > .ellipsis > .attached-file-link")
.should("have.attr", "href")
.and("equal", "https://wallpaperplay.com/walls/full/8/2/b/72402.jpg");

cy.get(".title-text").then(($value) => {
docname = $value.text();
});
});

it("Check if file was uploaded correctly", () => {
cy.go_to_list("File");
cy.open_list_filter();
cy.get(".fieldname-select-area .form-control")
.click()
.type("Attached To Name{enter}")
.blur()
.wait(500);
cy.get('input[data-fieldname="attached_to_name"]').click().type(docname).blur();
cy.get(".filter-popover .apply-filters").click({ force: true });
cy.get("header .level-right .list-count").should("contain.text", "1 of 1");
});

it("Check if file exists with temporary name", () => {
cy.open_list_filter();
cy.get('input[data-fieldname="attached_to_name"]').click().clear().type(temp_name).blur();
cy.get(".filter-popover .apply-filters").click({ force: true });
cy.get(".frappe-list > .no-result").should("be.visible");
});
});
7 changes: 5 additions & 2 deletions cypress/integration/control_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ context("Data Control", () => {
cy.new_form("Test Data Control");

//Checking the URL for the new form of the doctype
cy.location("pathname").should("eq", "/app/test-data-control/new-test-data-control-1");
cy.location("pathname").should("contains", "/app/test-data-control/new-test-data-control");
cy.get(".title-text").should("have.text", "New Test Data Control");
cy.get('.frappe-control[data-fieldname="name1"]')
.find("label")
Expand Down Expand Up @@ -128,7 +128,10 @@ context("Data Control", () => {
cy.fill_field("phone", "9432380001", "Data");
cy.findByRole("button", { name: "Save" }).click({ force: true });
//Checking if the fields contains the data which has been filled in
cy.location("pathname").should("not.be", "/app/test-data-control/new-test-data-control-1");
cy.location("pathname").should(
"not.contains",
"/app/test-data-control/new-test-data-control"
);
cy.get_field("name1").should("have.value", "Komal");
cy.get_field("email").should("have.value", "[email protected]");
cy.get_field("phone").should("have.value", "9432380001");
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/dashboard_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ context("Dashboard Chart", () => {
});

it("Check filter populate for child table doctype", () => {
cy.visit("/app/dashboard-chart/new-dashboard-chart-1");
cy.new_form("Dashboard Chart");
cy.get('[data-fieldname="parent_document_type"]').should("have.css", "display", "none");

cy.get_field("document_type", "Link");
Expand Down
17 changes: 12 additions & 5 deletions cypress/integration/grid_keyboard_shortcut.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
context("Grid Keyboard Shortcut", () => {
let total_count = 0;
let contact_email_name = null;
before(() => {
cy.login();
});
beforeEach(() => {
cy.reload();
cy.visit("/app/contact/new-contact-1");
cy.new_form("Contact");
cy.get('.frappe-control[data-fieldname="email_ids"]').find(".grid-add-row").click();
// as new names uses hash instead of numbers get row's data-name dynamically.
cy.get('.frappe-control[data-fieldname="email_ids"]')
.find(".grid-body .grid-row")
.should(($row) => {
contact_email_name = $row.attr("data-name");
});
});
it("Insert new row at the end", () => {
cy.add_new_row_in_grid(
"{ctrl}{shift}{downarrow}",
(cy, total_count) => {
cy.get('[data-name="new-contact-email-1"]').should(
cy.get(`[data-name="${contact_email_name}"]`).should(
"have.attr",
"data-idx",
`${total_count + 1}`
Expand All @@ -23,17 +30,17 @@ context("Grid Keyboard Shortcut", () => {
});
it("Insert new row at the top", () => {
cy.add_new_row_in_grid("{ctrl}{shift}{uparrow}", (cy) => {
cy.get('[data-name="new-contact-email-1"]').should("have.attr", "data-idx", "2");
cy.get(`[data-name="${contact_email_name}"]`).should("have.attr", "data-idx", "2");
});
});
it("Insert new row below", () => {
cy.add_new_row_in_grid("{ctrl}{downarrow}", (cy) => {
cy.get('[data-name="new-contact-email-1"]').should("have.attr", "data-idx", "1");
cy.get(`[data-name^="${contact_email_name}"]`).should("have.attr", "data-idx", "1");
});
});
it("Insert new row above", () => {
cy.add_new_row_in_grid("{ctrl}{uparrow}", (cy) => {
cy.get('[data-name="new-contact-email-1"]').should("have.attr", "data-idx", "2");
cy.get(`[data-name^="${contact_email_name}"]`).should("have.attr", "data-idx", "2");
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/number_card.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ context("Number Card", () => {
});

it("Check filter populate for child table doctype", () => {
cy.visit("/app/number-card/new-number-card-1");
cy.new_form("Number Card");
cy.get('[data-fieldname="parent_document_type"]').should("have.css", "display", "none");

cy.get_field("document_type", "Link");
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ context("Timeline", () => {

it("Adding new ToDo, adding new comment, verifying comment addition & deletion and deleting ToDo", () => {
//Adding new ToDo
cy.visit("/app/todo/new-todo-1");
cy.new_form("ToDo");
cy.get('[data-fieldname="description"] .ql-editor.ql-blank')
.type("Test ToDo", { force: true })
.wait(200);
Expand Down
5 changes: 4 additions & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});

Expand Down
3 changes: 2 additions & 1 deletion frappe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
)
from .utils.lazy_loader import lazy_import

__version__ = "14.51.0"
__version__ = "14.54.0"
__title__ = "Frappe Framework"

controllers = {}
Expand Down Expand Up @@ -1653,6 +1653,7 @@ def get_newargs(fn: Callable, kwargs: dict[str, Any]) -> dict[str, Any]:
if (a in fnargs) or varkw_exist:
newargs[a] = kwargs.get(a)

# WARNING: This behaviour is now part of business logic in places, never remove.
newargs.pop("ignore_permissions", None)
newargs.pop("flags", None)

Expand Down
2 changes: 1 addition & 1 deletion frappe/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def serve(
application = StaticDataMiddleware(application, {"/files": str(os.path.abspath(sites_path))})

application.debug = True
application.config = {"SERVER_NAME": "127.0.0.1:8000"}
application.config = {"SERVER_NAME": "localhost:8000"}

log = logging.getLogger("werkzeug")
log.propagate = False
Expand Down
Loading

0 comments on commit 150b82f

Please sign in to comment.