diff --git a/packages/builder/cypress/integration/createBinding.spec.js b/packages/builder/cypress/integration/createBinding.spec.js index 8bf1ec8ea4..57cd0cc5fc 100644 --- a/packages/builder/cypress/integration/createBinding.spec.js +++ b/packages/builder/cypress/integration/createBinding.spec.js @@ -26,7 +26,7 @@ filterTests(['smoke', 'all'], () => { it("should add a URL param binding", () => { const paramName = "foo" - cy.createScreen("Test Param", `/test/:${paramName}`) + cy.createScreen(`/test/:${paramName}`) cy.addComponent("Elements", "Paragraph").then(componentId => { addSettingBinding("text", `URL.${paramName}`) // The builder preview pages don't have a real URL, so all we can do diff --git a/packages/builder/cypress/integration/createScreen.js b/packages/builder/cypress/integration/createScreen.js index 75132a22ba..f83de22df8 100644 --- a/packages/builder/cypress/integration/createScreen.js +++ b/packages/builder/cypress/integration/createScreen.js @@ -9,27 +9,27 @@ filterTests(["smoke", "all"], () => { }) it("Should successfully create a screen", () => { - cy.createScreen("Test Screen", "/test") + cy.createScreen("/test") cy.get(".nav-items-container").within(() => { cy.contains("/test").should("exist") }) }) it("Should update the url", () => { - cy.createScreen("Test Screen", "test with spaces") + cy.createScreen("test with spaces") cy.get(".nav-items-container").within(() => { cy.contains("/test-with-spaces").should("exist") }) }) it("Should create a blank screen with the selected access level", () => { - cy.createScreen("Test Screen Admin", "admin only", "Admin") + cy.createScreen("admin only", "Admin") cy.get(".nav-items-container").within(() => { cy.contains("/admin-only").should("exist") }) - cy.createScreen("Test Screen Public", "open to all", "Public") + cy.createScreen("open to all", "Public") cy.get(".nav-items-container").within(() => { cy.contains("/open-to-all").should("exist") @@ -37,5 +37,11 @@ filterTests(["smoke", "all"], () => { cy.get(".nav-item").contains("/test-screen").should("not.exist") }) }) + + it("Should create a set of datasource screens with the selected access level", () => { + + cy.createDatasourceScreen("Cypress Tests", "Public") + + }) }) }) diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index 7549270af4..1966957edb 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -142,7 +142,7 @@ Cypress.Commands.add("createTestApp", () => { const appName = "Cypress Tests" cy.deleteApp(appName) cy.createApp(appName, "This app is used for Cypress testing.") - cy.createScreen("home", "home") + cy.createScreen("home") }) Cypress.Commands.add("createTestTableWithData", () => { @@ -283,28 +283,59 @@ Cypress.Commands.add("navigateToDataSection", () => { }) //Blank -Cypress.Commands.add("createScreen", (screenName, route, accessLevelLabel) => { +Cypress.Commands.add("createScreen", (route, accessLevelLabel) => { cy.contains("Design").click() cy.get("[aria-label=AddCircle]").click() cy.get(".spectrum-Modal").within(() => { - cy.get(".item").contains("Blank").click() + cy.get(".item").contains("Blank screen").click() cy.get(".spectrum-Button").contains("Continue").click({ force: true }) cy.wait(500) }) cy.get(".spectrum-Dialog-grid").within(() => { cy.get(".spectrum-Form-itemField").eq(0).type(route) + cy.get(".spectrum-Button").contains("Continue").click({ force: true }) + cy.wait(1000) + }) + cy.get(".spectrum-Modal").within(() => { if (accessLevelLabel) { cy.get(".spectrum-Picker-label").click() cy.wait(500) cy.contains(accessLevelLabel).click() } - - cy.get(".spectrum-Button").contains("Continue").click({ force: true }) - cy.wait(1000) + cy.get(".spectrum-Button").contains("Done").click({ force: true }) }) }) +Cypress.Commands.add("createDatasourceScreen", (datasourceName, accessLevelLabel) => { + cy.contains("Design").click() + cy.get("[aria-label=AddCircle]").click() + cy.get(".spectrum-Modal").within(() => { + cy.get(".item").contains("Autogenerated screens").click() + cy.get(".spectrum-Button").contains("Continue").click({ force: true }) + cy.wait(500) + }) + cy.get(".spectrum-Modal [data-cy='data-source-modal']").within(() => { + cy.get(".data-source-entry").contains(datasourceName).should("exist") + cy.get(".data-source-entry").contains(datasourceName).click({ force: true }) + + cy.get(".data-source-entry").contains(datasourceName).get(".data-source-check").should("exist") + cy.get(".spectrum-Button").contains("Confirm").click({ force: true }) + }) + + cy.get(".spectrum-Modal").within(() => { + if (accessLevelLabel) { + cy.get(".spectrum-Picker-label").click() + cy.wait(500) + cy.contains(accessLevelLabel).click() + } + cy.get(".spectrum-Button").contains("Done").click({ force: true }) + }) + + cy.contains("Design").click() +}) + + Cypress.Commands.add("navigateToAutogeneratedModal", () => { // Screen name must already exist within data source cy.contains("Design").click() diff --git a/packages/builder/src/components/design/NavigationPanel/DatasourceModal.svelte b/packages/builder/src/components/design/NavigationPanel/DatasourceModal.svelte index 17a8556831..1cb3856165 100644 --- a/packages/builder/src/components/design/NavigationPanel/DatasourceModal.svelte +++ b/packages/builder/src/components/design/NavigationPanel/DatasourceModal.svelte @@ -60,90 +60,94 @@ }) - - - {#each filteredSources as datasource} -
-
-
- + + + + {#each filteredSources as datasource} +
+
+
+ +
+
{datasource.name}
-
{datasource.name}
-
- {#if Array.isArray(datasource.entities)} - {#each datasource.entities.filter(table => table._id !== "ta_users") as table} -
x.table === table.name)} - on:click={() => toggleScreenSelection(table, datasource)} - > - - - - {table.name} - - {#if selectedScreens.find(x => x.table === table.name)} - - - - {/if} -
- {/each} - {/if} - {#if datasource["entities"] && !Array.isArray(datasource.entities)} - {#each Object.keys(datasource.entities).filter(table => table._id !== "ta_users") as table_key} -
x.table === datasource.entities[table_key].name - )} - on:click={() => - toggleScreenSelection( - datasource.entities[table_key], - datasource + {#if Array.isArray(datasource.entities)} + {#each datasource.entities.filter(table => table._id !== "ta_users") as table} +
x.table === table.name )} - > - toggleScreenSelection(table, datasource)} > - - - {datasource.entities[table_key].name} + + + + {table.name} - {#if selectedScreens.find(x => x.table === datasource.entities[table_key].name)} - - - - {/if} -
- {/each} - {/if} -
- {/each} -
-
+ {#if selectedScreens.find(x => x.table === table.name)} + + + + {/if} +
+ {/each} + {/if} + {#if datasource["entities"] && !Array.isArray(datasource.entities)} + {#each Object.keys(datasource.entities).filter(table => table._id !== "ta_users") as table_key} +
x.table === datasource.entities[table_key].name + )} + on:click={() => + toggleScreenSelection( + datasource.entities[table_key], + datasource + )} + > + + + + {datasource.entities[table_key].name} + + {#if selectedScreens.find(x => x.table === datasource.entities[table_key].name)} + + + + {/if} +
+ {/each} + {/if} +
+ {/each} + + +