From 306c73309405cf26e7449c7aa43aea321f2740ce Mon Sep 17 00:00:00 2001 From: Conor_Mack Date: Wed, 24 Jun 2020 16:16:06 +0100 Subject: [PATCH] Cypress Tests and Discussion Resolves --- .../cypress/integration/screens.spec.js | 22 +++++++++++++++++++ packages/builder/cypress/support/commands.js | 22 +++++++++++++++++++ .../builder/src/builderStore/store/index.js | 7 +++--- .../ComponentPropertiesPanel.svelte | 5 ++++- .../pagesParsing/renameScreen.js | 5 ----- .../pagesParsing/searchComponents.js | 9 +------- 6 files changed, 52 insertions(+), 18 deletions(-) create mode 100644 packages/builder/cypress/integration/screens.spec.js 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 = []) => {