diff --git a/cypress/integration/edit.js b/cypress/integration/edit.js index 069fd31607d..c16a2fac369 100644 --- a/cypress/integration/edit.js +++ b/cypress/integration/edit.js @@ -1,12 +1,16 @@ import createPageFactory from '../support/CreatePage'; import editPageFactory from '../support/EditPage'; import listPageFactory from '../support/ListPage'; +import loginPageFactory from '../support/LoginPage'; describe('Edit Page', () => { const EditPostPage = editPageFactory('/#/posts/5'); + const ListPagePosts = listPageFactory('/#/posts'); const CreatePostPage = createPageFactory('/#/posts/create'); const EditCommentPage = editPageFactory('/#/comments/5'); - const ListPagePosts = listPageFactory('/#/posts'); + const LoginPage = loginPageFactory('/#/login'); + const EditUserPage = editPageFactory('/#/users/3'); + const CreateUserPage = createPageFactory('/#/users/create'); describe('Title', () => { it('should show the correct title in the appBar', () => { @@ -165,6 +169,26 @@ describe('Edit Page', () => { }); }); + it('should not lose the cloned values when switching tabs', () => { + EditPostPage.navigate(); + EditPostPage.logout(); + LoginPage.navigate(); + LoginPage.login('admin', 'password'); + EditUserPage.navigate(); + cy.get(EditUserPage.elements.input('name')).should(el => + expect(el).to.have.value('Annamarie Mayer') + ); + EditUserPage.clone(); + cy.get(CreateUserPage.elements.input('name')).then(el => { + expect(el).to.have.value('Annamarie Mayer'); + }); + CreateUserPage.gotoTab(2); + CreateUserPage.gotoTab(1); + cy.get(CreateUserPage.elements.input('name')).then(el => { + expect(el).to.have.value('Annamarie Mayer'); + }); + }); + it('should persit emptied inputs', () => { EditPostPage.navigate(); EditPostPage.gotoTab(3); diff --git a/cypress/support/EditPage.js b/cypress/support/EditPage.js index 16324ed6514..61c896d106c 100644 --- a/cypress/support/EditPage.js +++ b/cypress/support/EditPage.js @@ -15,6 +15,8 @@ export default url => ({ cloneButton: '.button-clone', tab: index => `.form-tab:nth-of-type(${index})`, title: '#react-admin-title', + userMenu: 'button[title="Profile"]', + logout: '.logout', }, navigate() { @@ -57,4 +59,9 @@ export default url => ({ clone() { cy.get(this.elements.cloneButton).click(); }, + + logout() { + cy.get(this.elements.userMenu).click(); + cy.get(this.elements.logout).click(); + }, }); diff --git a/examples/simple/src/users/UserEdit.js b/examples/simple/src/users/UserEdit.js index 09e8a22048e..a5754a124cd 100644 --- a/examples/simple/src/users/UserEdit.js +++ b/examples/simple/src/users/UserEdit.js @@ -2,15 +2,18 @@ import React from 'react'; import PropTypes from 'prop-types'; import { + CloneButton, DeleteWithConfirmButton, Edit, FormTab, + required, SaveButton, SelectInput, + ShowButton, TabbedForm, TextInput, Toolbar, - required, + TopToolbar, } from 'react-admin'; import { makeStyles } from '@material-ui/core/styles'; @@ -39,8 +42,24 @@ const UserEditToolbar = props => { ); }; +const EditActions = ({ basePath, data, hasShow }) => ( + + + + +); + const UserEdit = ({ permissions, ...props }) => ( - } aside={