mirror of https://github.com/Budibase/budibase.git
committed by
GitHub
17 changed files with 274 additions and 171 deletions
@ -1,8 +1,8 @@ |
|||
{ |
|||
"baseUrl": "http://localhost:4005/_builder/", |
|||
"baseUrl": "http://localhost:4001/_builder/", |
|||
"video": true, |
|||
"projectId": "bmbemn", |
|||
"env": { |
|||
"PORT": "4005" |
|||
"PORT": "4001" |
|||
} |
|||
} |
|||
|
|||
@ -1,18 +1,7 @@ |
|||
context('Create an Application', () => { |
|||
|
|||
beforeEach(() => { |
|||
cy.server() |
|||
cy.visit(`localhost:${Cypress.env("PORT")}/_builder`) |
|||
}) |
|||
|
|||
// https://on.cypress.io/interacting-with-elements
|
|||
|
|||
it('should create a new application', () => { |
|||
// https://on.cypress.io/type
|
|||
cy.createApp('My Cool App', 'This is a description') |
|||
|
|||
cy.visit(`localhost:${Cypress.env("PORT")}/_builder`) |
|||
|
|||
cy.contains('My Cool App').should('exist') |
|||
}) |
|||
context("Create an Application", () => { |
|||
it("should create a new application", () => { |
|||
cy.createTestApp() |
|||
cy.visit(`localhost:${Cypress.env("PORT")}/_builder`) |
|||
cy.contains("Cypress Tests").should("exist") |
|||
}) |
|||
}) |
|||
|
|||
@ -1,18 +1,59 @@ |
|||
xcontext('Create a Binding', () => { |
|||
before(() => { |
|||
cy.visit(`localhost:${Cypress.env("PORT")}/_builder`) |
|||
cy.createApp('Binding App', 'Binding App Description') |
|||
cy.navigateToFrontend() |
|||
context("Create Bindings", () => { |
|||
before(() => { |
|||
cy.createTestApp() |
|||
cy.navigateToFrontend() |
|||
}) |
|||
|
|||
it("should add a current user binding", () => { |
|||
cy.addComponent("Elements", "Paragraph").then(componentId => { |
|||
addSettingBinding("text", "Current User._id") |
|||
cy.getComponent(componentId).should( |
|||
"have.text", |
|||
`ro_ta_users_us_test@test.com` |
|||
) |
|||
}) |
|||
}) |
|||
|
|||
it("should handle an invalid binding", () => { |
|||
cy.addComponent("Elements", "Paragraph").then(componentId => { |
|||
// Cypress needs to escape curly brackets
|
|||
cy.get("[data-cy=setting-text] input") |
|||
.type("{{}{{}{{} Current User._id {}}{}}") |
|||
.blur() |
|||
cy.getComponent(componentId).should("have.text", "{{{ user._id }}") |
|||
}) |
|||
}) |
|||
|
|||
it('add an input binding', () => { |
|||
cy.get(".nav-items-container").contains('Home').click() |
|||
cy.contains("Add").click() |
|||
cy.get("[data-cy=Input]").click() |
|||
cy.get("[data-cy=Textfield]").click() |
|||
cy.contains("Heading").click() |
|||
cy.get("[data-cy=text-binding-button]").click() |
|||
cy.get("[data-cy=binding-dropdown-modal]").contains('Input 1').click() |
|||
cy.get("[data-cy=binding-dropdown-modal] textarea").should('have.value', 'Home{{ Input 1 }}') |
|||
it("should add a URL param binding", () => { |
|||
const paramName = "foo" |
|||
cy.createScreen("Test Param", `/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
|
|||
// is check that we were able to bind to the property, and that the
|
|||
// component exists on the page
|
|||
cy.getComponent(componentId).should("have.text", "") |
|||
}) |
|||
}) |
|||
|
|||
it("should add a binding with a handlebars helper", () => { |
|||
cy.addComponent("Elements", "Paragraph").then(componentId => { |
|||
// Cypress needs to escape curly brackets
|
|||
addSettingBinding("text", "{{}{{} add 1 2 {}}{}}", false) |
|||
cy.getComponent(componentId).should("have.text", "3") |
|||
}) |
|||
}) |
|||
}) |
|||
|
|||
const addSettingBinding = (setting, bindingText, clickOption = true) => { |
|||
cy.get(`[data-cy="setting-${setting}"] [data-cy=text-binding-button]`).click() |
|||
cy.get(".drawer").within(() => { |
|||
if (clickOption) { |
|||
cy.contains(bindingText).click() |
|||
cy.get("textarea").should("have.value", `{{ ${bindingText} }}`) |
|||
} else { |
|||
cy.get("textarea").type(bindingText) |
|||
} |
|||
cy.get("button").click() |
|||
}) |
|||
} |
|||
|
|||
@ -1,60 +1,90 @@ |
|||
xcontext("Create Components", () => { |
|||
context("Create Components", () => { |
|||
let headlineId |
|||
|
|||
before(() => { |
|||
cy.server() |
|||
cy.visit(`localhost:${Cypress.env("PORT")}/_builder`) |
|||
// https://on.cypress.io/type
|
|||
cy.createApp("Table App", "Table App Description") |
|||
cy.createTable("dog", "name", "age") |
|||
cy.addRow("bob", "15") |
|||
cy.createTestApp() |
|||
cy.createTable("dog") |
|||
cy.addColumn("dog", "name", "string") |
|||
cy.addColumn("dog", "age", "number") |
|||
cy.addColumn("dog", "type", "options") |
|||
cy.navigateToFrontend() |
|||
}) |
|||
|
|||
// https://on.cypress.io/interacting-with-elements
|
|||
it("should add a container", () => { |
|||
cy.navigateToFrontend() |
|||
cy.get(".switcher > :nth-child(2)").click() |
|||
cy.contains("Container").click() |
|||
cy.addComponent(null, "Container").then(componentId => { |
|||
cy.getComponent(componentId).should("exist") |
|||
}) |
|||
}) |
|||
|
|||
it("should add a headline", () => { |
|||
cy.addHeadlineComponent("An Amazing headline!") |
|||
cy.addComponent("Elements", "Headline").then(componentId => { |
|||
headlineId = componentId |
|||
cy.getComponent(headlineId).should("exist") |
|||
}) |
|||
}) |
|||
|
|||
getIframeBody().contains("An Amazing headline!") |
|||
it("should change the text of the headline", () => { |
|||
const text = "Lorem ipsum dolor sit amet." |
|||
cy.get("[data-cy=Settings]").click() |
|||
cy.get("[data-cy=setting-text] input") |
|||
.type(text) |
|||
.blur() |
|||
cy.getComponent(headlineId).should("have.text", text) |
|||
}) |
|||
it("change the font size of the headline", () => { |
|||
|
|||
it("should change the size of the headline", () => { |
|||
cy.get("[data-cy=Design]").click() |
|||
cy.contains("Typography").click() |
|||
cy.get("[data-cy=font-size-prop-control]").click() |
|||
cy.contains("60px").click() |
|||
cy.contains("Design").click() |
|||
|
|||
getIframeBody() |
|||
.contains("An Amazing headline!") |
|||
.should("have.css", "font-size", "60px") |
|||
cy.getComponent(headlineId).should("have.css", "font-size", "60px") |
|||
}) |
|||
}) |
|||
|
|||
const getIframeDocument = () => { |
|||
return ( |
|||
cy |
|||
.get("iframe") |
|||
// Cypress yields jQuery element, which has the real
|
|||
// DOM element under property "0".
|
|||
// From the real DOM iframe element we can get
|
|||
// the "document" element, it is stored in "contentDocument" property
|
|||
// Cypress "its" command can access deep properties using dot notation
|
|||
// https://on.cypress.io/its
|
|||
.its("0.contentDocument") |
|||
.should("exist") |
|||
) |
|||
} |
|||
it("should create a form and reset to match schema", () => { |
|||
cy.addComponent("Form", "Form").then(() => { |
|||
cy.get("[data-cy=Settings]").click() |
|||
cy.get("[data-cy=setting-datasource]") |
|||
.contains("Choose option") |
|||
.click() |
|||
cy.get(".dropdown") |
|||
.contains("dog") |
|||
.click() |
|||
cy.addComponent("Form", "Field Group").then(fieldGroupId => { |
|||
cy.get("[data-cy=Settings]").click() |
|||
cy.contains("Update Form Fields").click() |
|||
cy.get(".modal") |
|||
.get("button.primary") |
|||
.click() |
|||
cy.getComponent(fieldGroupId).within(() => { |
|||
cy.contains("name").should("exist") |
|||
cy.contains("age").should("exist") |
|||
cy.contains("type").should("exist") |
|||
}) |
|||
cy.getComponent(fieldGroupId) |
|||
.find("input") |
|||
.should("have.length", 2) |
|||
cy.getComponent(fieldGroupId) |
|||
.find(".spectrum-Picker") |
|||
.should("have.length", 1) |
|||
}) |
|||
}) |
|||
}) |
|||
|
|||
const getIframeBody = () => { |
|||
// get the document
|
|||
return ( |
|||
getIframeDocument() |
|||
// automatically retries until body is loaded
|
|||
.its("body") |
|||
.should("not.be.undefined") |
|||
// wraps "body" DOM element to allow
|
|||
// chaining more Cypress commands, like ".find(...)"
|
|||
.then(cy.wrap) |
|||
) |
|||
} |
|||
it("deletes a component", () => { |
|||
cy.addComponent("Elements", "Paragraph").then(componentId => { |
|||
cy.get("[data-cy=setting-_instanceName] input") |
|||
.type(componentId) |
|||
.blur() |
|||
cy.get(".ui-nav ul .nav-item.selected .ri-more-line").click({ |
|||
force: true, |
|||
}) |
|||
cy.get(".dropdown-container") |
|||
.contains("Delete") |
|||
.click() |
|||
cy.get(".modal") |
|||
.contains("Delete Component") |
|||
.click() |
|||
cy.getComponent(componentId).should("not.exist") |
|||
}) |
|||
}) |
|||
}) |
|||
|
|||
@ -0,0 +1,10 @@ |
|||
context("Screen Tests", () => { |
|||
before(() => { |
|||
cy.createTestApp() |
|||
cy.navigateToFrontend() |
|||
}) |
|||
|
|||
it("Should successfully create a screen", () => { |
|||
cy.createScreen("Test Screen", "/test") |
|||
}) |
|||
}) |
|||
@ -1,17 +1,10 @@ |
|||
context('Create a User', () => { |
|||
context("Create a User", () => { |
|||
before(() => { |
|||
cy.createTestApp() |
|||
}) |
|||
|
|||
before(() => { |
|||
cy.server() |
|||
cy.visit(`localhost:${Cypress.env("PORT")}/_builder`) |
|||
// https://on.cypress.io/type
|
|||
cy.createApp('User App', 'This app is used to test user creation') |
|||
}) |
|||
|
|||
// https://on.cypress.io/interacting-with-elements
|
|||
it('should create a user', () => { |
|||
cy.createUser("bbuser@test.com", "test", "ADMIN") |
|||
|
|||
// // Check to make sure user was created!
|
|||
cy.contains("bbuser").should('be.visible') |
|||
}) |
|||
it("should create a user", () => { |
|||
cy.createUser("bbuser@test.com", "test", "ADMIN") |
|||
cy.contains("bbuser").should("be.visible") |
|||
}) |
|||
}) |
|||
|
|||
@ -1,13 +0,0 @@ |
|||
|
|||
context('Screen Tests', () => { |
|||
before(() => { |
|||
cy.server() |
|||
cy.visit(`localhost:${Cypress.env("PORT")}/_builder`) |
|||
cy.createApp('Conor Cy App', 'Table App Description') |
|||
cy.navigateToFrontend() |
|||
}) |
|||
|
|||
it('Should successfully create a screen', () => { |
|||
cy.createScreen("test Screen", "/test") |
|||
}) |
|||
}) |
|||
Loading…
Reference in new issue