Skip to content
Snippets Groups Projects
Unverified Commit 75d24981 authored by Raphael Krut-Landau's avatar Raphael Krut-Landau Committed by GitHub
Browse files

Ensure that correct error messages show up in the Edit user modal (#48966)

parent 7ffdac92
No related branches found
No related tags found
No related merge requests found
......@@ -255,9 +255,17 @@ describe("scenarios > admin > people", () => {
showUserOptions(normalUserName);
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Edit user").click();
cy.findByDisplayValue(normal.first_name).click().clear().type(NEW_NAME);
clickButton("Update");
modal().within(() => {
cy.log("Should display error messages (metabase#46449)");
cy.findByLabelText("First name").click().clear().type(" ");
clickButton("Update");
cy.findByText(/non-blank string./).should("exist");
cy.findByLabelText("First name").click().clear().type(NEW_NAME);
clickButton("Update", { timeout: 4000 });
});
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText(NEW_FULL_NAME);
cy.location().should(loc => expect(loc.pathname).to.eq("/admin/people"));
......@@ -872,8 +880,8 @@ function showUserOptions(full_name) {
});
}
function clickButton(button_name) {
cy.button(button_name).should("not.be.disabled").click();
function clickButton(button_name, opts = {}) {
cy.button(button_name, opts).should("not.be.disabled").click();
}
function assertTableRowsCount(length) {
......
......@@ -43,7 +43,8 @@ export const currentUser = createReducer<User | null>(null, builder => {
return state;
})
.addCase(Users.actionTypes.UPDATE, (state, { payload }) => {
const isCurrentUserUpdated = state?.id === payload.user.id;
const isCurrentUserUpdated =
payload.user && state?.id === payload.user.id;
if (isCurrentUserUpdated) {
return {
...state,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment