diff --git a/packages/builder/cypress/integration/screens.spec.js b/packages/builder/cypress/integration/screens.spec.js new file mode 100644 index 0000000000..43f7d44917 --- /dev/null +++ b/packages/builder/cypress/integration/screens.spec.js @@ -0,0 +1,22 @@ + +context('Screen Tests', () => { + before(() => { + cy.visit('localhost:4001/_builder') + cy.createApp('Conor Cy App', 'Model App Description') + cy.navigateToFrontend() + }) + + it('Should successful create a screen', () => { + cy.createScreen("test Screen") + }) + + it('Should rename a screen', () => { + cy.get(".components-pane").within(() => { + cy.contains("Settings").click() + cy.get("input[name=_instanceName]").clear().type("About Us").blur() + }) + cy.get('.nav-items-container').within(() => { + cy.contains("About Us").should('exist') + }) + }) +}) \ No newline at end of file diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index ed19ba8233..f777adc333 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -103,3 +103,25 @@ Cypress.Commands.add("addButtonComponent", () => { cy.get("[data-cy=Button]").click() }) + +Cypress.Commands.add('navigateToFrontend', () => { + cy.wait(4000) + cy.get(".close").click() + cy.contains('frontend').click() + cy.wait(2000) + cy.get(".close").click() +}) + +Cypress.Commands.add("createScreen", (screenName, route) => { + cy.get(".newscreen").click() + cy.get(".uk-input:first").type(screenName) + if(route) { + cy.get(".uk-input:last").type(route) + } + cy.get('.uk-modal-footer').within(() => { + cy.contains('Create Screen').click() + }) + cy.get('.nav-items-container').within(() => { + cy.contains(screenName).should('exist') + }) +}) \ No newline at end of file diff --git a/packages/builder/src/builderStore/store/index.js b/packages/builder/src/builderStore/store/index.js index 7f6e2a7979..11f2ed365e 100644 --- a/packages/builder/src/builderStore/store/index.js +++ b/packages/builder/src/builderStore/store/index.js @@ -353,12 +353,11 @@ const selectComponent = store => component => { const setComponentProp = store => (name, value) => { store.update(state => { - const current_component = state.currentComponentInfo - state.currentComponentInfo[name] = value - - _saveCurrentPreviewItem(state) + let current_component = state.currentComponentInfo + current_component[name] = value state.currentComponentInfo = current_component + _saveCurrentPreviewItem(state) return state }) } diff --git a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte index ad07f8458f..0850125de1 100644 --- a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte +++ b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte @@ -54,7 +54,10 @@ store.setComponentProp(key, value) } - $: displayName = ( $store.currentView === "component" || $store.currentFrontEndType === "screen") && componentInstance._instanceName && componentInstance._component !== "##builtin/screenslot" + $: isComponentOrScreen = $store.currentView === "component" || $store.currentFrontEndType === "screen" + $: isNotScreenslot = componentInstance._component !== "##builtin/screenslot" + + $: displayName = isComponentOrScreen && componentInstance._instanceName && isNotScreenslot function walkProps(component, action) { action(component) diff --git a/packages/builder/src/components/userInterface/pagesParsing/renameScreen.js b/packages/builder/src/components/userInterface/pagesParsing/renameScreen.js index 72736446a1..6c351664d8 100644 --- a/packages/builder/src/components/userInterface/pagesParsing/renameScreen.js +++ b/packages/builder/src/components/userInterface/pagesParsing/renameScreen.js @@ -38,11 +38,6 @@ export const rename = (pages, screens, oldname, newname) => { for (let screen of screens) { let hasEdited = false - // if (screen.name === oldname) { - // screen.name = newname - // hasEdited = true - // } - if (screen.props.instanceName === oldname) { screen.props.instanceName = newname hasEdited = true diff --git a/packages/builder/src/components/userInterface/pagesParsing/searchComponents.js b/packages/builder/src/components/userInterface/pagesParsing/searchComponents.js index cb44030e1d..58ab70a5df 100644 --- a/packages/builder/src/components/userInterface/pagesParsing/searchComponents.js +++ b/packages/builder/src/components/userInterface/pagesParsing/searchComponents.js @@ -29,14 +29,7 @@ export const searchAllComponents = (components, phrase) => { } export const getExactComponent = (components, name, isScreen = false) => { - const stringEquals = (s1, s2) => normalString(s1) === normalString(s2) - return pipe(components, [ - find(c => - isScreen - ? stringEquals(c.props._instanceName, name) - : stringEquals(c._instanceName, name) - ), - ]) + return components.find(c => isScreen ? c.props._instanceName === name : c._instanceName === name) } export const getAncestorProps = (components, name, found = []) => {