mirror of https://github.com/Budibase/budibase.git
338 changed files with 26688 additions and 3370 deletions
@ -1,9 +1,11 @@ |
|||||
node_modules |
node_modules |
||||
public |
|
||||
dist |
dist |
||||
*.spec.js |
*.spec.js |
||||
packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte |
packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte |
||||
packages/server/builder |
packages/server/builder |
||||
packages/server/coverage |
packages/server/coverage |
||||
packages/server/client |
packages/server/client |
||||
packages/builder/.routify |
packages/server/src/definitions/openapi.ts |
||||
|
packages/builder/.routify |
||||
|
packages/builder/cypress/support/queryLevelTransformerFunction.js |
||||
|
packages/builder/cypress/support/queryLevelTransformerFunctionWithData.js |
||||
|
|||||
@ -0,0 +1,3 @@ |
|||||
|
{ |
||||
|
"extends": "next/core-web-vitals" |
||||
|
} |
||||
@ -0,0 +1,38 @@ |
|||||
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. |
||||
|
|
||||
|
# dependencies |
||||
|
/node_modules |
||||
|
/.pnp |
||||
|
.pnp.js |
||||
|
|
||||
|
# testing |
||||
|
/coverage |
||||
|
|
||||
|
# next.js |
||||
|
/.next/ |
||||
|
/out/ |
||||
|
|
||||
|
# production |
||||
|
/build |
||||
|
|
||||
|
# misc |
||||
|
.DS_Store |
||||
|
*.pem |
||||
|
|
||||
|
# debug |
||||
|
npm-debug.log* |
||||
|
yarn-debug.log* |
||||
|
yarn-error.log* |
||||
|
.pnpm-debug.log* |
||||
|
|
||||
|
# local env files |
||||
|
.env.local |
||||
|
.env.development.local |
||||
|
.env.test.local |
||||
|
.env.production.local |
||||
|
|
||||
|
# vercel |
||||
|
.vercel |
||||
|
|
||||
|
# typescript |
||||
|
*.tsbuildinfo |
||||
@ -0,0 +1,41 @@ |
|||||
|
# Budibase API + Next.js example |
||||
|
|
||||
|
This is an example of how Budibase can be used as a backend for a Postgres database for a Next.js sales app. You will |
||||
|
need to follow the walk-through that has been published in the Budibase docs to set up your Budibase app for this example. |
||||
|
|
||||
|
## Pre-requisites |
||||
|
|
||||
|
To use this example you will need: |
||||
|
1. [Docker](https://www.docker.com/) |
||||
|
2. [Docker Compose](https://docs.docker.com/compose/) |
||||
|
3. [Node.js](https://nodejs.org/en/) |
||||
|
4. A self-hosted Budibase installation |
||||
|
|
||||
|
## Getting Started |
||||
|
|
||||
|
The first step is to set up the database - you can do this by going to the `db/` directory and running the command: |
||||
|
|
||||
|
```bash |
||||
|
docker-compose up |
||||
|
``` |
||||
|
|
||||
|
The next step is to follow the example walk-through and set up a Budibase app as it describes. Once you've done |
||||
|
this you can configure the settings in `next.config.js`, specifically the `apiKey`, `host` and `appName`. |
||||
|
|
||||
|
Finally, you can start the dev server with the following command: |
||||
|
|
||||
|
```bash |
||||
|
npm run dev |
||||
|
# or |
||||
|
yarn dev |
||||
|
``` |
||||
|
|
||||
|
## Accessing the app |
||||
|
|
||||
|
Open [http://localhost:3001](http://localhost:3001) with your browser to see the sales app. |
||||
|
|
||||
|
Look in the API routes (`pages/api/sales.ts` and `pages/api/salespeople.ts`) to see how this is integrated with Budibase. |
||||
|
There is also a utility file where some core functions and types have been defined, in `utilities/index.ts`. |
||||
|
|
||||
|
## Attribution |
||||
|
This example was set up using [Next.js](https://nextjs.org/) and bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). |
||||
@ -0,0 +1,42 @@ |
|||||
|
import Link from "next/link" |
||||
|
import Image from "next/image" |
||||
|
import { ReactNotifications } from "react-notifications-component" |
||||
|
|
||||
|
function layout(props: any) { |
||||
|
return ( |
||||
|
<> |
||||
|
<nav className="navbar" role="navigation" aria-label="main navigation"> |
||||
|
<div id="navbar" className="navbar-menu"> |
||||
|
<div className="logo"> |
||||
|
<Image alt="logo" src="/bb-emblem.svg" width="50" height="50" /> |
||||
|
</div> |
||||
|
<div className="navbar-start"> |
||||
|
<Link href="/"> |
||||
|
<a className="navbar-item"> |
||||
|
List |
||||
|
</a> |
||||
|
</Link> |
||||
|
<Link href="/save"> |
||||
|
<a className="navbar-item"> |
||||
|
New sale |
||||
|
</a> |
||||
|
</Link> |
||||
|
</div> |
||||
|
<div className="navbar-end"> |
||||
|
<div className="navbar-item"> |
||||
|
<div className="buttons"> |
||||
|
<a className="button is-primary" href="https://budibase.readme.io/reference"> |
||||
|
<strong>API Documentation</strong> |
||||
|
</a> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</nav> |
||||
|
<ReactNotifications /> |
||||
|
{props.children} |
||||
|
</> |
||||
|
) |
||||
|
} |
||||
|
|
||||
|
export default layout |
||||
@ -0,0 +1,28 @@ |
|||||
|
import { Store } from "react-notifications-component" |
||||
|
|
||||
|
const notifications = { |
||||
|
error: (error: string, title: string) => { |
||||
|
Store.addNotification({ |
||||
|
container: "top-right", |
||||
|
type: "danger", |
||||
|
message: error, |
||||
|
title: title, |
||||
|
dismiss: { |
||||
|
duration: 10000, |
||||
|
}, |
||||
|
}) |
||||
|
}, |
||||
|
success: (message: string, title: string) => { |
||||
|
Store.addNotification({ |
||||
|
container: "top-right", |
||||
|
type: "success", |
||||
|
message: message, |
||||
|
title: title, |
||||
|
dismiss: { |
||||
|
duration: 3000, |
||||
|
}, |
||||
|
}) |
||||
|
}, |
||||
|
} |
||||
|
|
||||
|
export default notifications |
||||
@ -0,0 +1,17 @@ |
|||||
|
version: "3.8" |
||||
|
services: |
||||
|
db: |
||||
|
container_name: postgres |
||||
|
image: postgres |
||||
|
restart: always |
||||
|
environment: |
||||
|
POSTGRES_USER: root |
||||
|
POSTGRES_PASSWORD: root |
||||
|
POSTGRES_DB: postgres |
||||
|
ports: |
||||
|
- "5432:5432" |
||||
|
volumes: |
||||
|
- pg_data:/var/lib/postgresql/data/ |
||||
|
- ./init.sql:/docker-entrypoint-initdb.d/init.sql |
||||
|
volumes: |
||||
|
pg_data: |
||||
@ -0,0 +1,21 @@ |
|||||
|
CREATE TABLE IF NOT EXISTS sales_people ( |
||||
|
person_id SERIAL PRIMARY KEY, |
||||
|
name varchar(200) NOT NULL |
||||
|
); |
||||
|
|
||||
|
CREATE TABLE IF NOT EXISTS sales ( |
||||
|
sale_id SERIAL PRIMARY KEY, |
||||
|
sale_name varchar(200) NOT NULL, |
||||
|
sold_by INT, |
||||
|
CONSTRAINT sold_by_fk |
||||
|
FOREIGN KEY(sold_by) |
||||
|
REFERENCES sales_people(person_id) |
||||
|
); |
||||
|
|
||||
|
INSERT INTO sales_people (name) |
||||
|
select 'Salesperson ' || id |
||||
|
FROM GENERATE_SERIES(1, 50) as id; |
||||
|
|
||||
|
INSERT INTO sales (sale_name, sold_by) |
||||
|
select 'Sale ' || id, floor(random() * 50 + 1)::int |
||||
|
FROM GENERATE_SERIES(1, 200) as id; |
||||
@ -0,0 +1,7 @@ |
|||||
|
import { components } from "./openapi" |
||||
|
|
||||
|
export type App = components["schemas"]["applicationOutput"]["data"] |
||||
|
export type Table = components["schemas"]["tableOutput"]["data"] |
||||
|
export type TableSearch = components["schemas"]["tableSearch"] |
||||
|
export type AppSearch = components["schemas"]["applicationSearch"] |
||||
|
export type RowSearch = components["schemas"]["searchOutput"] |
||||
File diff suppressed because it is too large
@ -0,0 +1,5 @@ |
|||||
|
/// <reference types="next" />
|
||||
|
/// <reference types="next/image-types/global" />
|
||||
|
|
||||
|
// NOTE: This file should not be edited
|
||||
|
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
||||
@ -0,0 +1,16 @@ |
|||||
|
const { join } = require("path") |
||||
|
/** @type {import('next').NextConfig} */ |
||||
|
const nextConfig = { |
||||
|
reactStrictMode: true, |
||||
|
sassOptions: { |
||||
|
includePaths: [join(__dirname, "styles")], |
||||
|
}, |
||||
|
serverRuntimeConfig: { |
||||
|
apiKey: |
||||
|
"bf4d86af933b5ac0af0fdbe4bf7d89ff-f929752a1eeaafb00f4b5e3325097d51a44fe4b39f22ed857923409cc75414b379323a25ebfb4916", |
||||
|
appName: "sales", |
||||
|
host: "http://localhost:10000", |
||||
|
}, |
||||
|
} |
||||
|
|
||||
|
module.exports = nextConfig |
||||
@ -0,0 +1,27 @@ |
|||||
|
{ |
||||
|
"name": "nextjs-api-sales", |
||||
|
"version": "0.1.0", |
||||
|
"private": true, |
||||
|
"scripts": { |
||||
|
"dev": "next dev -p 3001", |
||||
|
"build": "next build", |
||||
|
"start": "next start", |
||||
|
"lint": "next lint" |
||||
|
}, |
||||
|
"dependencies": { |
||||
|
"bulma": "^0.9.3", |
||||
|
"next": "12.1.0", |
||||
|
"node-fetch": "^3.2.2", |
||||
|
"node-sass": "^7.0.1", |
||||
|
"react": "17.0.2", |
||||
|
"react-dom": "17.0.2", |
||||
|
"react-notifications-component": "^3.4.1" |
||||
|
}, |
||||
|
"devDependencies": { |
||||
|
"@types/node": "17.0.21", |
||||
|
"@types/react": "17.0.39", |
||||
|
"eslint": "8.10.0", |
||||
|
"eslint-config-next": "12.1.0", |
||||
|
"typescript": "4.6.2" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
import "../styles/global.sass" |
||||
|
import type { AppProps } from "next/app" |
||||
|
import Head from "next/head" |
||||
|
import Layout from "../components/layout" |
||||
|
|
||||
|
function MyApp({ Component, pageProps }: AppProps) { |
||||
|
return ( |
||||
|
<Layout> |
||||
|
<Head> |
||||
|
<title>BB NextJS Sales Example</title> |
||||
|
</Head> |
||||
|
<Component {...pageProps} /> |
||||
|
</Layout> |
||||
|
) |
||||
|
} |
||||
|
|
||||
|
export default MyApp |
||||
@ -0,0 +1,46 @@ |
|||||
|
import { getApp, findTable, makeCall } from "../../utilities" |
||||
|
|
||||
|
async function getSales(req: any) { |
||||
|
const { page } = req.query |
||||
|
const { _id: appId } = await getApp() |
||||
|
const table = await findTable(appId, "sales") |
||||
|
return await makeCall("post", `tables/${table._id}/rows/search`, { |
||||
|
appId, |
||||
|
body: { |
||||
|
limit: 10, |
||||
|
sort: { |
||||
|
type: "string", |
||||
|
order: "descending", |
||||
|
column: "sale_id", |
||||
|
}, |
||||
|
paginate: true, |
||||
|
bookmark: parseInt(page), |
||||
|
}, |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
async function saveSale(req: any) { |
||||
|
const { _id: appId } = await getApp() |
||||
|
const table = await findTable(appId, "sales") |
||||
|
return await makeCall("post", `tables/${table._id}/rows`, { |
||||
|
body: req.body, |
||||
|
appId, |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
export default async function handler(req: any, res: any) { |
||||
|
let response: any = {} |
||||
|
try { |
||||
|
if (req.method === "POST") { |
||||
|
response = await saveSale(req) |
||||
|
} else if (req.method === "GET") { |
||||
|
response = await getSales(req) |
||||
|
} else { |
||||
|
res.status(404) |
||||
|
return |
||||
|
} |
||||
|
res.status(200).json(response) |
||||
|
} catch (err: any) { |
||||
|
res.status(400).send(err) |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
import { getApp, findTable, makeCall } from "../../utilities" |
||||
|
|
||||
|
async function getSalespeople() { |
||||
|
const { _id: appId } = await getApp() |
||||
|
const table = await findTable(appId, "sales_people") |
||||
|
return await makeCall("post", `tables/${table._id}/rows/search`, { |
||||
|
appId, |
||||
|
body: { |
||||
|
sort: { |
||||
|
type: "string", |
||||
|
order: "ascending", |
||||
|
column: "person_id", |
||||
|
}, |
||||
|
}, |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
export default async function handler(req: any, res: any) { |
||||
|
let response: any = {} |
||||
|
try { |
||||
|
if (req.method === "GET") { |
||||
|
response = await getSalespeople() |
||||
|
} else { |
||||
|
res.status(404) |
||||
|
return |
||||
|
} |
||||
|
res.status(200).json(response) |
||||
|
} catch (err: any) { |
||||
|
res.status(400).send(err) |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,83 @@ |
|||||
|
import type { NextPage } from "next" |
||||
|
import styles from "../styles/home.module.css" |
||||
|
import { useState, useEffect, useCallback } from "react" |
||||
|
import Notifications from "../components/notifications" |
||||
|
|
||||
|
const Home: NextPage = () => { |
||||
|
const [sales, setSales] = useState([]) |
||||
|
const [currentPage, setCurrentPage] = useState(1) |
||||
|
const [loaded, setLoaded] = useState(false) |
||||
|
|
||||
|
const getSales = useCallback(async (page: Number = 1) => { |
||||
|
let url = "/api/sales" |
||||
|
if (page) { |
||||
|
url += `?page=${page}` |
||||
|
} |
||||
|
const response = await fetch(url) |
||||
|
if (!response.ok) { |
||||
|
const error = await response.text() |
||||
|
Notifications.error(error, "Failed to get sales") |
||||
|
return |
||||
|
} |
||||
|
const sales = await response.json() |
||||
|
// @ts-ignore
|
||||
|
setCurrentPage(page) |
||||
|
return setSales(sales.data) |
||||
|
}, []) |
||||
|
|
||||
|
const goToNextPage = useCallback(async () => { |
||||
|
await getSales(currentPage + 1) |
||||
|
}, [currentPage, getSales]) |
||||
|
|
||||
|
const goToPrevPage = useCallback(async () => { |
||||
|
if (currentPage > 1) { |
||||
|
await getSales(currentPage - 1) |
||||
|
} |
||||
|
}, [currentPage, getSales]) |
||||
|
|
||||
|
useEffect(() => { |
||||
|
getSales().then(() => { |
||||
|
setLoaded(true) |
||||
|
}).catch(() => { |
||||
|
setSales([]) |
||||
|
}) |
||||
|
}, []) |
||||
|
|
||||
|
if (!loaded) { |
||||
|
return null |
||||
|
} |
||||
|
|
||||
|
return ( |
||||
|
<div className={styles.container}> |
||||
|
<div className={styles.tableSection}> |
||||
|
<h1 className="subtitle">Sales</h1> |
||||
|
<div className={styles.table}> |
||||
|
<table className="table"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<th>Sale ID</th> |
||||
|
<th>name</th> |
||||
|
<th>Sold by</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
{sales.map((sale: any) => |
||||
|
<tr key={sale.sale_id}> |
||||
|
<th>{sale.sale_id}</th> |
||||
|
<th>{sale.sale_name}</th> |
||||
|
<th>{sale.sales_person?.map((person: any) => person.primaryDisplay)[0]}</th> |
||||
|
</tr> |
||||
|
)} |
||||
|
</tbody> |
||||
|
</table> |
||||
|
<div className={styles.buttons}> |
||||
|
<button className="button" onClick={goToPrevPage}>Prev Page</button> |
||||
|
<button className="button" onClick={goToNextPage}>Next Page</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
) |
||||
|
} |
||||
|
|
||||
|
export default Home |
||||
@ -0,0 +1,81 @@ |
|||||
|
import type { NextPage } from "next" |
||||
|
import { useCallback, useEffect, useState } from "react" |
||||
|
import styles from "../styles/save.module.css" |
||||
|
import Notifications from "../components/notifications" |
||||
|
|
||||
|
const Save: NextPage = () => { |
||||
|
const [salespeople, setSalespeople] = useState([]) |
||||
|
const [loaded, setLoaded] = useState(false) |
||||
|
|
||||
|
const saveSale = useCallback(async (event: any) => { |
||||
|
event.preventDefault() |
||||
|
const sale = { |
||||
|
sale_name: event.target.name.value, |
||||
|
sales_person: [event.target.soldBy.value], |
||||
|
} |
||||
|
const response = await fetch("/api/sales", { |
||||
|
method: "POST", |
||||
|
headers: { |
||||
|
"Content-Type": "application/json", |
||||
|
}, |
||||
|
body: JSON.stringify(sale), |
||||
|
}) |
||||
|
if (!response.ok) { |
||||
|
const error = await response.text() |
||||
|
Notifications.error(error, "Failed to save sale") |
||||
|
return |
||||
|
} |
||||
|
Notifications.success("Sale saved successfully!", "Sale saved") |
||||
|
}, []) |
||||
|
|
||||
|
const getSalespeople = useCallback(async () => { |
||||
|
const response: any = await fetch("/api/salespeople") |
||||
|
if (!response.ok) { |
||||
|
throw new Error(await response.text()) |
||||
|
} |
||||
|
const json = await response.json() |
||||
|
setSalespeople(json.data) |
||||
|
}, []) |
||||
|
|
||||
|
useEffect(() => { |
||||
|
getSalespeople().then(() => { |
||||
|
setLoaded(true) |
||||
|
}).catch(() => { |
||||
|
setSalespeople([]) |
||||
|
}) |
||||
|
}, []) |
||||
|
|
||||
|
if (!loaded) { |
||||
|
return null |
||||
|
} |
||||
|
return ( |
||||
|
<div className={styles.container}> |
||||
|
<div className={styles.formSection}> |
||||
|
<h1 className="subtitle">New sale</h1> |
||||
|
<form onSubmit={saveSale}> |
||||
|
<div className="field"> |
||||
|
<label className="label">Name</label> |
||||
|
<div className="control"> |
||||
|
<input id="name" className="input" type="text" placeholder="Text input" /> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div className="field"> |
||||
|
<label className="label">Sold by</label> |
||||
|
<div className="control"> |
||||
|
<div className="select"> |
||||
|
<select id="soldBy"> |
||||
|
{salespeople.map((person: any) => <option key={person._id} value={person._id}>{person.name}</option>)} |
||||
|
</select> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div className="control"> |
||||
|
<button className="button is-link">Submit</button> |
||||
|
</div> |
||||
|
</form> |
||||
|
</div> |
||||
|
</div> |
||||
|
) |
||||
|
} |
||||
|
|
||||
|
export default Save |
||||
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 25 KiB |
@ -0,0 +1,26 @@ |
|||||
|
@charset "utf-8" |
||||
|
|
||||
|
@import url('https://fonts.googleapis.com/css?family=Roboto:400,700') |
||||
|
$family-sans-serif: "Roboto", sans-serif |
||||
|
|
||||
|
#__next |
||||
|
display: flex |
||||
|
flex-direction: column |
||||
|
justify-content: flex-start |
||||
|
align-items: stretch |
||||
|
height: 100vh |
||||
|
--bg-color: #f5f5f5 |
||||
|
|
||||
|
.logo |
||||
|
padding: 0.75rem |
||||
|
|
||||
|
@import "../node_modules/bulma/bulma.sass" |
||||
|
@import "../node_modules/react-notifications-component/dist/theme.css" |
||||
|
|
||||
|
// applied after bulma styles are enabled |
||||
|
html |
||||
|
overflow-y: auto |
||||
|
|
||||
|
.navbar |
||||
|
background-color: var(--bg-color) |
||||
|
color: white |
||||
@ -0,0 +1,30 @@ |
|||||
|
.container { |
||||
|
width: 100vw; |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
padding: 5rem 2rem 0; |
||||
|
align-items: center; |
||||
|
flex: 1 1 auto; |
||||
|
} |
||||
|
|
||||
|
.buttons { |
||||
|
display: flex; |
||||
|
flex-direction: row; |
||||
|
justify-content: space-between; |
||||
|
} |
||||
|
|
||||
|
.tableSection { |
||||
|
padding: 2rem; |
||||
|
background: var(--bg-color); |
||||
|
width: 800px; |
||||
|
border-radius: 10px; |
||||
|
} |
||||
|
|
||||
|
.table table { |
||||
|
width: 100%; |
||||
|
} |
||||
|
|
||||
|
.tableSection h1 { |
||||
|
text-align: center; |
||||
|
color: black; |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
.container { |
||||
|
width: 100vw; |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
padding: 5rem 2rem 0; |
||||
|
align-items: center; |
||||
|
flex: 1 1 auto; |
||||
|
} |
||||
|
|
||||
|
.formSection { |
||||
|
padding: 2rem; |
||||
|
background: var(--bg-color); |
||||
|
width: 400px; |
||||
|
border-radius: 10px; |
||||
|
} |
||||
|
|
||||
|
.formSection h1 { |
||||
|
text-align: center; |
||||
|
color: black; |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
{ |
||||
|
"compilerOptions": { |
||||
|
"target": "es5", |
||||
|
"lib": ["dom", "dom.iterable", "esnext"], |
||||
|
"allowJs": true, |
||||
|
"skipLibCheck": true, |
||||
|
"strict": true, |
||||
|
"forceConsistentCasingInFileNames": true, |
||||
|
"noEmit": true, |
||||
|
"esModuleInterop": true, |
||||
|
"module": "esnext", |
||||
|
"moduleResolution": "node", |
||||
|
"resolveJsonModule": true, |
||||
|
"isolatedModules": true, |
||||
|
"jsx": "preserve", |
||||
|
"incremental": true |
||||
|
}, |
||||
|
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], |
||||
|
"exclude": ["node_modules"] |
||||
|
} |
||||
@ -0,0 +1,82 @@ |
|||||
|
import { App, AppSearch, Table, TableSearch } from "../definitions" |
||||
|
import getConfig from "next/config" |
||||
|
|
||||
|
const { serverRuntimeConfig } = getConfig() |
||||
|
const apiKey = serverRuntimeConfig["apiKey"] |
||||
|
const appName = serverRuntimeConfig["appName"] |
||||
|
const host = serverRuntimeConfig["host"] |
||||
|
|
||||
|
let APP: App | null = null |
||||
|
let TABLES: { [key: string]: Table } = {} |
||||
|
|
||||
|
export async function makeCall( |
||||
|
method: string, |
||||
|
url: string, |
||||
|
opts?: { body?: any; appId?: string } |
||||
|
): Promise<any> { |
||||
|
const fetchOpts: any = { |
||||
|
method, |
||||
|
headers: { |
||||
|
"x-budibase-api-key": apiKey, |
||||
|
}, |
||||
|
} |
||||
|
if (opts?.appId) { |
||||
|
fetchOpts.headers["x-budibase-app-id"] = opts.appId |
||||
|
} |
||||
|
if (opts?.body) { |
||||
|
fetchOpts.body = |
||||
|
typeof opts.body !== "string" ? JSON.stringify(opts.body) : opts.body |
||||
|
fetchOpts.headers["Content-Type"] = "application/json" |
||||
|
} |
||||
|
const finalUrl = `${host}/api/public/v1/${url}` |
||||
|
const response = await fetch(finalUrl, fetchOpts) |
||||
|
if (response.ok) { |
||||
|
return response.json() |
||||
|
} else { |
||||
|
const error = await response.text() |
||||
|
console.error("Budibase server error - ", error) |
||||
|
throw new Error(error) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export async function getApp(): Promise<App> { |
||||
|
if (APP) { |
||||
|
return APP |
||||
|
} |
||||
|
const apps: AppSearch = await makeCall("post", "applications/search", { |
||||
|
body: { |
||||
|
name: appName, |
||||
|
}, |
||||
|
}) |
||||
|
const app = apps.data.find((app: App) => app.name === appName) |
||||
|
if (!app) { |
||||
|
throw new Error( |
||||
|
"Could not find app, please make sure app name in config is correct." |
||||
|
) |
||||
|
} |
||||
|
APP = app |
||||
|
return app |
||||
|
} |
||||
|
|
||||
|
export async function findTable( |
||||
|
appId: string, |
||||
|
tableName: string |
||||
|
): Promise<Table> { |
||||
|
if (TABLES[tableName]) { |
||||
|
return TABLES[tableName] |
||||
|
} |
||||
|
const tables: TableSearch = await makeCall("post", "tables/search", { |
||||
|
body: { |
||||
|
name: tableName, |
||||
|
}, |
||||
|
appId, |
||||
|
}) |
||||
|
const table = tables.data.find((table: Table) => table.name === tableName) |
||||
|
if (!table) { |
||||
|
throw new Error( |
||||
|
"Could not find table, please make sure your app is configured with the Postgres datasource correctly." |
||||
|
) |
||||
|
} |
||||
|
TABLES[tableName] = table |
||||
|
return table |
||||
|
} |
||||
File diff suppressed because it is too large
@ -1,145 +0,0 @@ |
|||||
user nginx; |
|
||||
error_log /var/log/nginx/error.log debug; |
|
||||
pid /var/run/nginx.pid; |
|
||||
worker_processes auto; |
|
||||
worker_rlimit_nofile 33282; |
|
||||
|
|
||||
events { |
|
||||
worker_connections 1024; |
|
||||
} |
|
||||
|
|
||||
http { |
|
||||
limit_req_zone $binary_remote_addr zone=ratelimit:10m rate=20r/s; |
|
||||
include /etc/nginx/mime.types; |
|
||||
default_type application/octet-stream; |
|
||||
charset utf-8; |
|
||||
sendfile on; |
|
||||
tcp_nopush on; |
|
||||
tcp_nodelay on; |
|
||||
server_tokens off; |
|
||||
types_hash_max_size 2048; |
|
||||
|
|
||||
# buffering |
|
||||
client_body_buffer_size 1K; |
|
||||
client_header_buffer_size 1k; |
|
||||
client_max_body_size 1k; |
|
||||
ignore_invalid_headers off; |
|
||||
|
|
||||
|
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' |
|
||||
'$status $body_bytes_sent "$http_referer" ' |
|
||||
'"$http_user_agent" "$http_x_forwarded_for"'; |
|
||||
|
|
||||
map $http_upgrade $connection_upgrade { |
|
||||
default "upgrade"; |
|
||||
} |
|
||||
|
|
||||
server { |
|
||||
listen 10000 default_server; |
|
||||
listen [::]:10000 default_server; |
|
||||
server_name _; |
|
||||
client_max_body_size 1000m; |
|
||||
ignore_invalid_headers off; |
|
||||
proxy_buffering off; |
|
||||
port_in_redirect off; |
|
||||
|
|
||||
# Security Headers |
|
||||
add_header X-Frame-Options SAMEORIGIN always; |
|
||||
add_header X-Content-Type-Options nosniff always; |
|
||||
add_header X-XSS-Protection "1; mode=block" always; |
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.budi.live https://js.intercomcdn.com https://widget.intercom.io; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://fonts.googleapis.com https://rsms.me; object-src 'none'; base-uri 'self'; connect-src 'self' https://api-iam.intercom.io https://app.posthog.com wss://nexus-websocket-a.intercom.io; font-src 'self' data: https://cdn.jsdelivr.net https://fonts.gstatic.com https://rsms.me; frame-src 'self'; img-src http: https: data:; manifest-src 'self'; media-src 'self'; worker-src 'none';" always; |
|
||||
|
|
||||
location /app { |
|
||||
proxy_pass http://app-service:4002; |
|
||||
rewrite ^/app/(.*)$ /$1 break; |
|
||||
} |
|
||||
|
|
||||
location = / { |
|
||||
port_in_redirect off; |
|
||||
proxy_pass http://app-service:4002; |
|
||||
} |
|
||||
|
|
||||
location = /v1/update { |
|
||||
proxy_pass http://watchtower-service:8080; |
|
||||
} |
|
||||
|
|
||||
location /builder/ { |
|
||||
port_in_redirect off; |
|
||||
proxy_http_version 1.1; |
|
||||
proxy_set_header Connection $connection_upgrade; |
|
||||
proxy_set_header Upgrade $http_upgrade; |
|
||||
proxy_set_header Host $host; |
|
||||
proxy_set_header X-Real-IP $remote_addr; |
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
||||
proxy_pass http://app-service:4002; |
|
||||
} |
|
||||
|
|
||||
location ~ ^/(builder|app_) { |
|
||||
port_in_redirect off; |
|
||||
proxy_http_version 1.1; |
|
||||
proxy_set_header Connection $connection_upgrade; |
|
||||
proxy_set_header Upgrade $http_upgrade; |
|
||||
proxy_set_header Host $host; |
|
||||
proxy_set_header X-Real-IP $remote_addr; |
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
||||
proxy_pass http://app-service:4002; |
|
||||
} |
|
||||
|
|
||||
location ~ ^/api/(system|admin|global)/ { |
|
||||
proxy_pass http://worker-service:4003; |
|
||||
} |
|
||||
|
|
||||
location /worker/ { |
|
||||
proxy_pass http://worker-service:4003; |
|
||||
rewrite ^/worker/(.*)$ /$1 break; |
|
||||
} |
|
||||
|
|
||||
location /api/ { |
|
||||
# calls to the API are rate limited with bursting |
|
||||
limit_req zone=ratelimit burst=20 nodelay; |
|
||||
|
|
||||
# 120s timeout on API requests |
|
||||
proxy_read_timeout 120s; |
|
||||
proxy_connect_timeout 120s; |
|
||||
proxy_send_timeout 120s; |
|
||||
|
|
||||
proxy_http_version 1.1; |
|
||||
proxy_set_header Connection $connection_upgrade; |
|
||||
proxy_set_header Upgrade $http_upgrade; |
|
||||
proxy_set_header Host $host; |
|
||||
proxy_set_header X-Real-IP $remote_addr; |
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
||||
|
|
||||
proxy_pass http://app-service:4002; |
|
||||
} |
|
||||
|
|
||||
location /db/ { |
|
||||
proxy_pass http://couchdb-service:5984; |
|
||||
rewrite ^/db/(.*)$ /$1 break; |
|
||||
} |
|
||||
|
|
||||
location / { |
|
||||
proxy_set_header X-Real-IP $remote_addr; |
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
||||
proxy_set_header X-Forwarded-Proto $scheme; |
|
||||
proxy_set_header Host $http_host; |
|
||||
|
|
||||
proxy_connect_timeout 300; |
|
||||
proxy_http_version 1.1; |
|
||||
proxy_set_header Connection ""; |
|
||||
chunked_transfer_encoding off; |
|
||||
proxy_pass http://minio-service:9000; |
|
||||
} |
|
||||
|
|
||||
client_header_timeout 60; |
|
||||
client_body_timeout 60; |
|
||||
keepalive_timeout 60; |
|
||||
|
|
||||
# gzip |
|
||||
gzip on; |
|
||||
gzip_vary on; |
|
||||
gzip_proxied any; |
|
||||
gzip_comp_level 6; |
|
||||
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml; |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1 @@ |
|||||
|
module.exports = require("./src/security/encryption") |
||||
@ -0,0 +1 @@ |
|||||
|
exports.lookupApiKey = async () => {} |
||||
@ -0,0 +1,33 @@ |
|||||
|
const crypto = require("crypto") |
||||
|
const env = require("../environment") |
||||
|
|
||||
|
const ALGO = "aes-256-ctr" |
||||
|
const SECRET = env.JWT_SECRET |
||||
|
const SEPARATOR = "-" |
||||
|
const ITERATIONS = 10000 |
||||
|
const RANDOM_BYTES = 16 |
||||
|
const STRETCH_LENGTH = 32 |
||||
|
|
||||
|
function stretchString(string, salt) { |
||||
|
return crypto.pbkdf2Sync(string, salt, ITERATIONS, STRETCH_LENGTH, "sha512") |
||||
|
} |
||||
|
|
||||
|
exports.encrypt = input => { |
||||
|
const salt = crypto.randomBytes(RANDOM_BYTES) |
||||
|
const stretched = stretchString(SECRET, salt) |
||||
|
const cipher = crypto.createCipheriv(ALGO, stretched, salt) |
||||
|
const base = cipher.update(input) |
||||
|
const final = cipher.final() |
||||
|
const encrypted = Buffer.concat([base, final]).toString("hex") |
||||
|
return `${salt.toString("hex")}${SEPARATOR}${encrypted}` |
||||
|
} |
||||
|
|
||||
|
exports.decrypt = input => { |
||||
|
const [salt, encrypted] = input.split(SEPARATOR) |
||||
|
const saltBuffer = Buffer.from(salt, "hex") |
||||
|
const stretched = stretchString(SECRET, saltBuffer) |
||||
|
const decipher = crypto.createDecipheriv(ALGO, stretched, saltBuffer) |
||||
|
const base = decipher.update(Buffer.from(encrypted, "hex")) |
||||
|
const final = decipher.final() |
||||
|
return Buffer.concat([base, final]).toString() |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
<script> |
||||
|
import "@spectrum-css/toast/dist/index-vars.css" |
||||
|
import Portal from "svelte-portal" |
||||
|
import { banner } from "../Stores/banner" |
||||
|
import Banner from "./Banner.svelte" |
||||
|
import { fly } from "svelte/transition" |
||||
|
</script> |
||||
|
|
||||
|
<Portal target=".banner-container"> |
||||
|
<div class="banner"> |
||||
|
{#if $banner.message} |
||||
|
<div transition:fly={{ y: -30 }}> |
||||
|
<Banner |
||||
|
type={$banner.type} |
||||
|
extraButtonText={$banner.extraButtonText} |
||||
|
extraButtonAction={$banner.extraButtonAction} |
||||
|
on:change={$banner.onChange} |
||||
|
> |
||||
|
{$banner.message} |
||||
|
</Banner> |
||||
|
</div> |
||||
|
{/if} |
||||
|
</div> |
||||
|
</Portal> |
||||
|
|
||||
|
<style> |
||||
|
.banner { |
||||
|
pointer-events: none; |
||||
|
width: 100%; |
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,37 @@ |
|||||
|
import { writable } from "svelte/store" |
||||
|
|
||||
|
export function createBannerStore() { |
||||
|
const DEFAULT_CONFIG = {} |
||||
|
|
||||
|
const banner = writable(DEFAULT_CONFIG) |
||||
|
|
||||
|
const show = async ( |
||||
|
// eslint-disable-next-line
|
||||
|
config = { message, type, extraButtonText, extraButtonAction, onChange } |
||||
|
) => { |
||||
|
banner.update(store => { |
||||
|
return { |
||||
|
...store, |
||||
|
...config, |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
const showStatus = async () => { |
||||
|
const config = { |
||||
|
message: "Some systems are experiencing issues", |
||||
|
type: "negative", |
||||
|
extraButtonText: "View Status", |
||||
|
extraButtonAction: () => window.open("https://status.budibase.com/"), |
||||
|
} |
||||
|
|
||||
|
await show(config) |
||||
|
} |
||||
|
|
||||
|
return { |
||||
|
subscribe: banner.subscribe, |
||||
|
showStatus, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export const banner = createBannerStore() |
||||
File diff suppressed because it is too large
@ -1,9 +1,11 @@ |
|||||
{ |
{ |
||||
"baseUrl": "http://localhost:10001/builder/", |
"baseUrl": "http://localhost:4100", |
||||
"video": true, |
"video": false, |
||||
"projectId": "bmbemn", |
"projectId": "bmbemn", |
||||
"env": { |
"env": { |
||||
"PORT": "10001", |
"PORT": "4100", |
||||
"JWT_SECRET": "test" |
"WORKER_PORT": "4200", |
||||
|
"JWT_SECRET": "test", |
||||
|
"HOST_IP": "" |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,35 +1,39 @@ |
|||||
context("Add Radio Buttons", () => { |
import filterTests from "../support/filterTests" |
||||
before(() => { |
|
||||
cy.login() |
|
||||
cy.createTestApp() |
|
||||
}) |
|
||||
|
|
||||
it("should add Radio Buttons options picker on form, add data, and confirm", () => { |
filterTests(['all'], () => { |
||||
cy.navigateToFrontend() |
context("Add Radio Buttons", () => { |
||||
cy.addComponent("Form", "Form") |
before(() => { |
||||
cy.addComponent("Form", "Options Picker").then((componentId) => { |
cy.login() |
||||
// Provide field setting
|
cy.createTestApp() |
||||
cy.get(`[data-cy="field-prop-control"]`).type("1") |
|
||||
// Open dropdown and select Radio buttons
|
|
||||
cy.get(`[data-cy="optionsType-prop-control"]`).click().then(() => { |
|
||||
cy.get('.spectrum-Popover').contains('Radio buttons') |
|
||||
.wait(500) |
|
||||
.click() |
|
||||
}) |
|
||||
const radioButtonsTotal = 3 |
|
||||
// Add values and confirm total
|
|
||||
addRadioButtonData(radioButtonsTotal) |
|
||||
cy.getComponent(componentId).find('[type="radio"]') |
|
||||
.should('have.length', radioButtonsTotal) |
|
||||
}) |
}) |
||||
}) |
|
||||
|
it("should add Radio Buttons options picker on form, add data, and confirm", () => { |
||||
const addRadioButtonData = (totalRadioButtons) => { |
cy.navigateToFrontend() |
||||
cy.get(`[data-cy="optionsSource-prop-control"]`).click().then(() => { |
cy.addComponent("Form", "Form") |
||||
cy.get('.spectrum-Popover').contains('Custom') |
cy.addComponent("Form", "Options Picker").then((componentId) => { |
||||
|
// Provide field setting
|
||||
|
cy.get(`[data-cy="field-prop-control"]`).type("1") |
||||
|
// Open dropdown and select Radio buttons
|
||||
|
cy.get(`[data-cy="optionsType-prop-control"]`).click().then(() => { |
||||
|
cy.get('.spectrum-Popover').contains('Radio buttons') |
||||
.wait(500) |
.wait(500) |
||||
.click() |
.click() |
||||
|
}) |
||||
|
const radioButtonsTotal = 3 |
||||
|
// Add values and confirm total
|
||||
|
addRadioButtonData(radioButtonsTotal) |
||||
|
cy.getComponent(componentId).find('[type="radio"]') |
||||
|
.should('have.length', radioButtonsTotal) |
||||
|
}) |
||||
}) |
}) |
||||
cy.addCustomSourceOptions(totalRadioButtons) |
|
||||
} |
const addRadioButtonData = (totalRadioButtons) => { |
||||
|
cy.get(`[data-cy="optionsSource-prop-control"]`).click().then(() => { |
||||
|
cy.get('.spectrum-Popover').contains('Custom') |
||||
|
.wait(500) |
||||
|
.click() |
||||
|
}) |
||||
|
cy.addCustomSourceOptions(totalRadioButtons) |
||||
|
} |
||||
|
}) |
||||
}) |
}) |
||||
|
|||||
@ -0,0 +1,51 @@ |
|||||
|
import filterTests from "../support/filterTests" |
||||
|
|
||||
|
filterTests(['smoke', 'all'], () => { |
||||
|
context("Auto Screens UI", () => { |
||||
|
before(() => { |
||||
|
cy.login() |
||||
|
cy.createTestApp() |
||||
|
}) |
||||
|
|
||||
|
it("should generate internal table screens", () => { |
||||
|
// Create autogenerated screens from the internal table
|
||||
|
cy.createAutogeneratedScreens(["Cypress Tests"]) |
||||
|
// Confirm screens have been auto generated
|
||||
|
cy.get(".nav-items-container").contains("cypress-tests").click({ force: true }) |
||||
|
cy.get(".nav-items-container").should('contain', 'cypress-tests/:id') |
||||
|
.and('contain', 'cypress-tests/new/row') |
||||
|
}) |
||||
|
|
||||
|
it("should generate multiple internal table screens at once", () => { |
||||
|
// Create a second internal table
|
||||
|
const initialTable = "Cypress Tests" |
||||
|
const secondTable = "Table Two" |
||||
|
cy.createTable(secondTable) |
||||
|
// Create autogenerated screens from the internal tables
|
||||
|
cy.createAutogeneratedScreens([initialTable, secondTable]) |
||||
|
// Confirm screens have been auto generated
|
||||
|
cy.get(".nav-items-container").contains("cypress-tests").click({ force: true }) |
||||
|
// Previously generated tables are suffixed with numbers - as expected
|
||||
|
cy.get(".nav-items-container").should('contain', 'cypress-tests-2/:id') |
||||
|
.and('contain', 'cypress-tests-2/new/row') |
||||
|
cy.get(".nav-items-container").contains("table-two").click() |
||||
|
cy.get(".nav-items-container").should('contain', 'table-two/:id') |
||||
|
.and('contain', 'table-two/new/row') |
||||
|
}) |
||||
|
|
||||
|
if (Cypress.env("TEST_ENV")) { |
||||
|
it("should generate data source screens", () => { |
||||
|
// Using MySQL data source for testing this
|
||||
|
const datasource = "MySQL" |
||||
|
// Select & configure MySQL data source
|
||||
|
cy.selectExternalDatasource(datasource) |
||||
|
cy.addDatasourceConfig(datasource) |
||||
|
// Create autogenerated screens from a MySQL table - MySQL contains books table
|
||||
|
cy.createAutogeneratedScreens(["books"]) |
||||
|
cy.get(".nav-items-container").contains("books").click() |
||||
|
cy.get(".nav-items-container").should('contain', 'books/:id') |
||||
|
.and('contain', 'books/new/row') |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
@ -0,0 +1,43 @@ |
|||||
|
import filterTests from "../support/filterTests" |
||||
|
|
||||
|
filterTests(['all'], () => { |
||||
|
context("Change Application Icon and Colour", () => { |
||||
|
before(() => { |
||||
|
cy.login() |
||||
|
}) |
||||
|
|
||||
|
it("should change the icon and colour for an application", () => { |
||||
|
// Search for test application
|
||||
|
cy.searchForApplication("Cypress Tests") |
||||
|
cy.get(".appTable") |
||||
|
.within(() => { |
||||
|
cy.get(".spectrum-Icon").eq(1).click() |
||||
|
}) |
||||
|
cy.get(".spectrum-Menu").contains("Edit icon").click() |
||||
|
// Select random icon
|
||||
|
cy.get(".grid").within(() => { |
||||
|
cy.get(".icon-item").eq(Math.floor(Math.random() * 23) + 1).click() |
||||
|
}) |
||||
|
// Select random colour
|
||||
|
cy.get(".fill").click() |
||||
|
cy.get(".colors").within(() => { |
||||
|
cy.get(".color").eq(Math.floor(Math.random() * 33) + 1).click() |
||||
|
}) |
||||
|
cy.intercept('**/applications/**').as('iconChange') |
||||
|
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
||||
|
cy.wait("@iconChange") |
||||
|
cy.get("@iconChange").its('response.statusCode') |
||||
|
.should('eq', 200) |
||||
|
cy.wait(1000) |
||||
|
// Confirm icon has changed from default
|
||||
|
// Confirm colour has been applied - There is no default colour
|
||||
|
cy.get(".appTable") |
||||
|
.within(() => { |
||||
|
cy.get('[aria-label]').eq(0).children() |
||||
|
.should('have.attr', 'xlink:href').and('not.contain', '#spectrum-icon-18-Apps') |
||||
|
cy.get(".title").children().children() |
||||
|
.should('have.attr', 'style').and('contains', 'color') |
||||
|
}) |
||||
|
}) |
||||
|
}) |
||||
|
}) |
||||
@ -1,8 +1,12 @@ |
|||||
context("Create an Application", () => { |
import filterTests from '../support/filterTests' |
||||
it("should create a new application", () => { |
|
||||
cy.login() |
filterTests(['smoke', 'all'], () => { |
||||
cy.createTestApp() |
context("Create an Application", () => { |
||||
cy.visit(`localhost:${Cypress.env("PORT")}/builder`) |
it("should create a new application", () => { |
||||
cy.contains("Cypress Tests").should("exist") |
cy.login() |
||||
}) |
cy.createTestApp() |
||||
|
cy.visit(`${Cypress.config().baseUrl}/builder`) |
||||
|
cy.contains("Cypress Tests").should("exist") |
||||
|
}) |
||||
|
}) |
||||
}) |
}) |
||||
|
|||||
@ -1,66 +1,69 @@ |
|||||
context("Create a automation", () => { |
import filterTests from "../support/filterTests" |
||||
before(() => { |
|
||||
cy.login() |
|
||||
cy.createTestApp() |
|
||||
}) |
|
||||
|
|
||||
// https://on.cypress.io/interacting-with-elements
|
filterTests(['smoke', 'all'], () => { |
||||
it("should create a automation", () => { |
context("Create a automation", () => { |
||||
cy.createTestTableWithData() |
before(() => { |
||||
cy.wait(2000) |
cy.login() |
||||
cy.contains("Automate").click() |
cy.createTestApp() |
||||
cy.get("[data-cy='new-screen'] > .spectrum-Icon").click() |
|
||||
cy.get(".modal-inner-wrapper").within(() => { |
|
||||
cy.get("input").type("Add Row") |
|
||||
cy.contains("Row Created").click({ force: true }) |
|
||||
cy.wait(500) |
|
||||
cy.get(".spectrum-Button--cta").click() |
|
||||
}) |
}) |
||||
|
|
||||
// Setup trigger
|
it("should create a automation", () => { |
||||
cy.contains("Setup").click() |
cy.createTestTableWithData() |
||||
cy.get(".spectrum-Picker-label").click() |
cy.wait(2000) |
||||
cy.wait(500) |
cy.contains("Automate").click() |
||||
cy.contains("dog").click() |
cy.get("[data-cy='new-screen'] > .spectrum-Icon").click() |
||||
cy.wait(2000) |
cy.get(".modal-inner-wrapper").within(() => { |
||||
// Create action
|
cy.get("input").type("Add Row") |
||||
cy.get(".block > .spectrum-Icon").click() |
cy.contains("Row Created").click({ force: true }) |
||||
cy.get(".modal-inner-wrapper").within(() => { |
cy.wait(500) |
||||
cy.wait(1000) |
cy.get(".spectrum-Button--cta").click() |
||||
cy.contains("Create Row").trigger('mouseover').click().click() |
}) |
||||
cy.get(".spectrum-Button--cta").click() |
|
||||
}) |
|
||||
cy.contains("Setup").click() |
|
||||
cy.get(".spectrum-Picker-label").click() |
|
||||
cy.contains("dog").click() |
|
||||
cy.get(".spectrum-Textfield-input") |
|
||||
.first() |
|
||||
.type("{{ trigger.row.name }}", { parseSpecialCharSequences: false }) |
|
||||
cy.get(".spectrum-Textfield-input") |
|
||||
.eq(1) |
|
||||
.type("11") |
|
||||
cy.contains("Finish and test automation").click() |
|
||||
|
|
||||
cy.get(".modal-inner-wrapper").within(() => { |
// Setup trigger
|
||||
cy.wait(1000) |
cy.contains("Setup").click() |
||||
cy.get(".spectrum-Picker-label").click() |
cy.get(".spectrum-Picker-label").click() |
||||
|
cy.wait(500) |
||||
|
cy.contains("dog").click() |
||||
|
cy.wait(2000) |
||||
|
// Create action
|
||||
|
cy.get('[aria-label="AddCircle"]').eq(1).click() |
||||
|
cy.get(".modal-inner-wrapper").within(() => { |
||||
|
cy.wait(1000) |
||||
|
cy.contains("Create Row").trigger('mouseover').click().click() |
||||
|
cy.get(".spectrum-Button--cta").click() |
||||
|
}) |
||||
|
cy.contains("Setup").click() |
||||
|
cy.get(".spectrum-Picker-label").eq(1).click() |
||||
cy.contains("dog").click() |
cy.contains("dog").click() |
||||
cy.wait(1000) |
|
||||
cy.get(".spectrum-Textfield-input") |
cy.get(".spectrum-Textfield-input") |
||||
.first() |
.first() |
||||
.type("automationGoodboy") |
.type("{{ trigger.row.name }}", { parseSpecialCharSequences: false }) |
||||
cy.get(".spectrum-Textfield-input") |
cy.get(".spectrum-Textfield-input") |
||||
.eq(1) |
.eq(1) |
||||
.type("11") |
.type("11") |
||||
cy.get(".spectrum-Textfield-input") |
cy.contains("Finish and test automation").click() |
||||
.eq(2) |
|
||||
.type("123456") |
cy.get(".modal-inner-wrapper").within(() => { |
||||
cy.get(".spectrum-Textfield-input") |
cy.wait(1000) |
||||
.eq(3) |
cy.get(".spectrum-Picker-label").click() |
||||
.type("123456") |
cy.contains("dog").click() |
||||
cy.contains("Test").click() |
cy.wait(1000) |
||||
|
cy.get(".spectrum-Textfield-input") |
||||
|
.first() |
||||
|
.type("automationGoodboy") |
||||
|
cy.get(".spectrum-Textfield-input") |
||||
|
.eq(1) |
||||
|
.type("11") |
||||
|
cy.get(".spectrum-Textfield-input") |
||||
|
.eq(2) |
||||
|
.type("123456") |
||||
|
cy.get(".spectrum-Textfield-input") |
||||
|
.eq(3) |
||||
|
.type("123456") |
||||
|
cy.contains("Test").click() |
||||
|
}) |
||||
|
cy.contains("Data").click() |
||||
|
cy.contains("automationGoodboy") |
||||
}) |
}) |
||||
cy.contains("Data").click() |
|
||||
cy.contains("automationGoodboy") |
|
||||
}) |
}) |
||||
}) |
}) |
||||
|
|||||
@ -1,58 +1,62 @@ |
|||||
context("Create Bindings", () => { |
import filterTests from "../support/filterTests" |
||||
before(() => { |
|
||||
cy.login() |
|
||||
cy.createTestApp() |
|
||||
cy.navigateToFrontend() |
|
||||
}) |
|
||||
|
|
||||
it("should add a current user binding", () => { |
filterTests(['smoke', 'all'], () => { |
||||
cy.addComponent("Elements", "Paragraph").then(() => { |
context("Create Bindings", () => { |
||||
addSettingBinding("text", "Current User._id") |
before(() => { |
||||
|
cy.login() |
||||
|
cy.createTestApp() |
||||
|
cy.navigateToFrontend() |
||||
}) |
}) |
||||
}) |
|
||||
|
|
||||
it("should handle an invalid binding", () => { |
it("should add a current user binding", () => { |
||||
cy.addComponent("Elements", "Paragraph").then(componentId => { |
cy.addComponent("Elements", "Paragraph").then(() => { |
||||
// Cypress needs to escape curly brackets
|
addSettingBinding("text", "Current User._id") |
||||
cy.get("[data-cy=setting-text] input") |
}) |
||||
.type("{{}{{}{{} Current User._id {}}{}}") |
|
||||
.blur() |
|
||||
cy.getComponent(componentId).should("have.text", "{{{ [user].[_id] }}") |
|
||||
}) |
}) |
||||
}) |
|
||||
|
|
||||
it("should add a URL param binding", () => { |
it("should handle an invalid binding", () => { |
||||
const paramName = "foo" |
cy.addComponent("Elements", "Paragraph").then(componentId => { |
||||
cy.createScreen("Test Param", `/test/:${paramName}`) |
// Cypress needs to escape curly brackets
|
||||
cy.addComponent("Elements", "Paragraph").then(componentId => { |
cy.get("[data-cy=setting-text] input") |
||||
addSettingBinding("text", `URL.${paramName}`) |
.type("{{}{{}{{} Current User._id {}}{}}") |
||||
// The builder preview pages don't have a real URL, so all we can do
|
.blur() |
||||
// is check that we were able to bind to the property, and that the
|
cy.getComponent(componentId).should("have.text", "{{{ [user].[_id] }}") |
||||
// component exists on the page
|
}) |
||||
cy.getComponent(componentId).should("have.text", "New Paragraph") |
|
||||
}) |
}) |
||||
}) |
|
||||
|
|
||||
it("should add a binding with a handlebars helper", () => { |
it("should add a URL param binding", () => { |
||||
cy.addComponent("Elements", "Paragraph").then(componentId => { |
const paramName = "foo" |
||||
// Cypress needs to escape curly brackets
|
cy.createScreen("Test Param", `/test/:${paramName}`) |
||||
cy.get("[data-cy=setting-text] input") |
cy.addComponent("Elements", "Paragraph").then(componentId => { |
||||
.type("{{}{{} add 1 2 {}}{}}") |
addSettingBinding("text", `URL.${paramName}`) |
||||
.blur() |
// The builder preview pages don't have a real URL, so all we can do
|
||||
cy.getComponent(componentId).should("have.text", "3") |
// 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", "New Paragraph") |
||||
|
}) |
||||
}) |
}) |
||||
}) |
|
||||
}) |
|
||||
|
|
||||
const addSettingBinding = (setting, bindingText, clickOption = true) => { |
it("should add a binding with a handlebars helper", () => { |
||||
cy.get(`[data-cy="setting-${setting}"] [data-cy=text-binding-button]`).click() |
cy.addComponent("Elements", "Paragraph").then(componentId => { |
||||
cy.get(".drawer").within(() => { |
// Cypress needs to escape curly brackets
|
||||
if (clickOption) { |
cy.get("[data-cy=setting-text] input") |
||||
cy.contains(bindingText).click() |
.type("{{}{{} add 1 2 {}}{}}") |
||||
cy.get("textarea").should("have.value", `{{ ${bindingText} }}`) |
.blur() |
||||
} else { |
cy.getComponent(componentId).should("have.text", "3") |
||||
cy.get("textarea").type(bindingText) |
}) |
||||
} |
}) |
||||
cy.contains("Save").click() |
|
||||
}) |
}) |
||||
} |
|
||||
|
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.contains("Save").click() |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
|||||
@ -1,92 +1,97 @@ |
|||||
// TODO for now components are skipped, might not be good to keep doing this
|
// TODO for now components are skipped, might not be good to keep doing this
|
||||
xcontext("Create Components", () => { |
|
||||
let headlineId |
|
||||
|
|
||||
before(() => { |
import filterTests from "../support/filterTests" |
||||
cy.login() |
|
||||
cy.createTestApp() |
|
||||
cy.createTable("dog") |
|
||||
cy.addColumn("dog", "name", "Text") |
|
||||
cy.addColumn("dog", "age", "Number") |
|
||||
cy.addColumn("dog", "type", "Options") |
|
||||
cy.navigateToFrontend() |
|
||||
}) |
|
||||
|
|
||||
it("should add a container", () => { |
filterTests(['all'], () => { |
||||
cy.addComponent(null, "Container").then(componentId => { |
xcontext("Create Components", () => { |
||||
cy.getComponent(componentId).should("exist") |
let headlineId |
||||
}) |
|
||||
}) |
|
||||
|
|
||||
it("should add a headline", () => { |
before(() => { |
||||
cy.addComponent("Elements", "Headline").then(componentId => { |
cy.login() |
||||
headlineId = componentId |
cy.createTestApp() |
||||
cy.getComponent(headlineId).should("exist") |
cy.createTable("dog") |
||||
|
cy.addColumn("dog", "name", "Text") |
||||
|
cy.addColumn("dog", "age", "Number") |
||||
|
cy.addColumn("dog", "type", "Options") |
||||
|
cy.navigateToFrontend() |
||||
}) |
}) |
||||
}) |
|
||||
|
|
||||
it("should change the text of the headline", () => { |
it("should add a container", () => { |
||||
const text = "Lorem ipsum dolor sit amet." |
cy.addComponent(null, "Container").then(componentId => { |
||||
cy.get("[data-cy=Settings]").click() |
cy.getComponent(componentId).should("exist") |
||||
cy.get("[data-cy=setting-text] input") |
}) |
||||
.type(text) |
}) |
||||
.blur() |
|
||||
cy.getComponent(headlineId).should("have.text", text) |
|
||||
}) |
|
||||
|
|
||||
it("should change the size of the headline", () => { |
it("should add a headline", () => { |
||||
cy.get("[data-cy=Design]").click() |
cy.addComponent("Elements", "Headline").then(componentId => { |
||||
cy.contains("Typography").click() |
headlineId = componentId |
||||
cy.get("[data-cy=font-size-prop-control]").click() |
cy.getComponent(headlineId).should("exist") |
||||
cy.contains("60px").click() |
}) |
||||
cy.getComponent(headlineId).should("have.css", "font-size", "60px") |
}) |
||||
}) |
|
||||
|
|
||||
it("should create a form and reset to match schema", () => { |
it("should change the text of the headline", () => { |
||||
cy.addComponent("Form", "Form").then(() => { |
const text = "Lorem ipsum dolor sit amet." |
||||
cy.get("[data-cy=Settings]").click() |
cy.get("[data-cy=Settings]").click() |
||||
cy.get("[data-cy=setting-dataSource]") |
cy.get("[data-cy=setting-text] input") |
||||
.contains("Choose option") |
.type(text) |
||||
.click() |
.blur() |
||||
cy.get(".dropdown") |
cy.getComponent(headlineId).should("have.text", text) |
||||
.contains("dog") |
}) |
||||
.click() |
|
||||
cy.addComponent("Form", "Field Group").then(fieldGroupId => { |
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.getComponent(headlineId).should("have.css", "font-size", "60px") |
||||
|
}) |
||||
|
|
||||
|
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=Settings]").click() |
||||
cy.contains("Update Form Fields").click() |
cy.get("[data-cy=setting-dataSource]") |
||||
cy.get(".modal") |
.contains("Choose option") |
||||
.get("button.primary") |
.click() |
||||
|
cy.get(".dropdown") |
||||
|
.contains("dog") |
||||
.click() |
.click() |
||||
cy.getComponent(fieldGroupId).within(() => { |
cy.addComponent("Form", "Field Group").then(fieldGroupId => { |
||||
cy.contains("name").should("exist") |
cy.get("[data-cy=Settings]").click() |
||||
cy.contains("age").should("exist") |
cy.contains("Update Form Fields").click() |
||||
cy.contains("type").should("exist") |
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) |
||||
}) |
}) |
||||
cy.getComponent(fieldGroupId) |
|
||||
.find("input") |
|
||||
.should("have.length", 2) |
|
||||
cy.getComponent(fieldGroupId) |
|
||||
.find(".spectrum-Picker") |
|
||||
.should("have.length", 1) |
|
||||
}) |
}) |
||||
}) |
}) |
||||
}) |
|
||||
|
|
||||
it("deletes a component", () => { |
it("deletes a component", () => { |
||||
cy.addComponent("Elements", "Paragraph").then(componentId => { |
cy.addComponent("Elements", "Paragraph").then(componentId => { |
||||
cy.get("[data-cy=setting-_instanceName] input") |
cy.get("[data-cy=setting-_instanceName] input") |
||||
.type(componentId) |
.type(componentId) |
||||
.blur() |
.blur() |
||||
cy.get(".ui-nav ul .nav-item.selected .ri-more-line").click({ |
cy.get(".ui-nav ul .nav-item.selected .ri-more-line").click({ |
||||
force: true, |
force: true, |
||||
|
}) |
||||
|
cy.get(".dropdown-container") |
||||
|
.contains("Delete") |
||||
|
.click() |
||||
|
cy.get(".modal") |
||||
|
.contains("Delete Component") |
||||
|
.click() |
||||
|
cy.getComponent(componentId).should("not.exist") |
||||
}) |
}) |
||||
cy.get(".dropdown-container") |
|
||||
.contains("Delete") |
|
||||
.click() |
|
||||
cy.get(".modal") |
|
||||
.contains("Delete Component") |
|
||||
.click() |
|
||||
cy.getComponent(componentId).should("not.exist") |
|
||||
}) |
}) |
||||
}) |
}) |
||||
}) |
}) |
||||
|
|||||
@ -1,21 +1,25 @@ |
|||||
context("Screen Tests", () => { |
import filterTests from "../support/filterTests" |
||||
before(() => { |
|
||||
cy.login() |
|
||||
cy.createTestApp() |
|
||||
cy.navigateToFrontend() |
|
||||
}) |
|
||||
|
|
||||
it("Should successfully create a screen", () => { |
filterTests(["smoke", "all"], () => { |
||||
cy.createScreen("Test Screen", "/test") |
context("Screen Tests", () => { |
||||
cy.get(".nav-items-container").within(() => { |
before(() => { |
||||
cy.contains("/test").should("exist") |
cy.login() |
||||
|
cy.createTestApp() |
||||
|
cy.navigateToFrontend() |
||||
|
}) |
||||
|
|
||||
|
it("Should successfully create a screen", () => { |
||||
|
cy.createScreen("Test Screen", "/test") |
||||
|
cy.get(".nav-items-container").within(() => { |
||||
|
cy.contains("/test").should("exist") |
||||
|
}) |
||||
}) |
}) |
||||
}) |
|
||||
|
|
||||
it("Should update the url", () => { |
it("Should update the url", () => { |
||||
cy.createScreen("Test Screen", "test with spaces") |
cy.createScreen("Test Screen", "test with spaces") |
||||
cy.get(".nav-items-container").within(() => { |
cy.get(".nav-items-container").within(() => { |
||||
cy.contains("/test-with-spaces").should("exist") |
cy.contains("/test-with-spaces").should("exist") |
||||
|
}) |
||||
}) |
}) |
||||
}) |
}) |
||||
}) |
}) |
||||
|
|||||
@ -1,74 +1,113 @@ |
|||||
context("Create a Table", () => { |
import filterTests from "../support/filterTests" |
||||
before(() => { |
|
||||
cy.login() |
|
||||
cy.createTestApp() |
|
||||
}) |
|
||||
|
|
||||
it("should create a new Table", () => { |
filterTests(["smoke", "all"], () => { |
||||
cy.createTable("dog") |
context("Create a Table", () => { |
||||
cy.wait(1000) |
before(() => { |
||||
// Check if Table exists
|
cy.login() |
||||
cy.get(".table-title h1").should("have.text", "dog") |
cy.createTestApp() |
||||
}) |
}) |
||||
|
|
||||
it("adds a new column to the table", () => { |
it("should create a new Table", () => { |
||||
cy.addColumn("dog", "name", "Text") |
cy.createTable("dog") |
||||
cy.contains("name").should("be.visible") |
cy.wait(1000) |
||||
}) |
// Check if Table exists
|
||||
|
cy.get(".table-title h1").should("have.text", "dog") |
||||
|
}) |
||||
|
|
||||
it("creates a row in the table", () => { |
it("adds a new column to the table", () => { |
||||
cy.addRow(["Rover"]) |
cy.addColumn("dog", "name", "Text") |
||||
cy.contains("Rover").should("be.visible") |
cy.contains("name").should("be.visible") |
||||
}) |
}) |
||||
|
|
||||
it("updates a column on the table", () => { |
it("creates a row in the table", () => { |
||||
cy.get(".title").click() |
cy.addRow(["Rover"]) |
||||
cy.get(".spectrum-Table-editIcon > use").click() |
cy.contains("Rover").should("be.visible") |
||||
cy.get("input").eq(1).type("updated", { force: true }) |
}) |
||||
// Unset table display column
|
|
||||
cy.get(".spectrum-Switch-input").eq(1).click() |
|
||||
cy.contains("Save Column").click() |
|
||||
cy.contains("nameupdated ").should("contain", "nameupdated") |
|
||||
}) |
|
||||
|
|
||||
|
it("updates a column on the table", () => { |
||||
it("edits a row", () => { |
cy.get(".title").click() |
||||
cy.contains("button", "Edit").click({ force: true }) |
cy.get(".spectrum-Table-editIcon > use").click() |
||||
cy.wait(1000) |
cy.get(".modal-inner-wrapper").within(() => { |
||||
cy.get(".spectrum-Modal input").clear() |
|
||||
cy.get(".spectrum-Modal input").type("Updated") |
|
||||
cy.contains("Save").click() |
|
||||
cy.contains("Updated").should("have.text", "Updated") |
|
||||
}) |
|
||||
|
|
||||
it("deletes a row", () => { |
|
||||
cy.get(".spectrum-Checkbox-input").check({ force: true }) |
|
||||
cy.contains("Delete 1 row(s)").click() |
|
||||
cy.get(".spectrum-Modal").contains("Delete").click() |
|
||||
cy.contains("RoverUpdated").should("not.exist") |
|
||||
}) |
|
||||
|
|
||||
it("deletes a column", () => { |
cy.get("input").eq(0).type("updated", { force: true }) |
||||
cy.get(".title").click() |
// Unset table display column
|
||||
cy.get(".spectrum-Table-editIcon > use").click() |
cy.get(".spectrum-Switch-input").eq(1).click() |
||||
cy.contains("Delete").click() |
cy.contains("Save Column").click() |
||||
cy.wait(50) |
}) |
||||
cy.get(`[data-cy="delete-column-confirm"]`).type("nameupdated") |
cy.contains("nameupdated ").should("contain", "nameupdated") |
||||
cy.contains("Delete Column").click() |
}) |
||||
cy.contains("nameupdated").should("not.exist") |
|
||||
}) |
it("edits a row", () => { |
||||
|
cy.contains("button", "Edit").click({ force: true }) |
||||
|
cy.wait(1000) |
||||
|
cy.get(".spectrum-Modal input").clear() |
||||
|
cy.get(".spectrum-Modal input").type("Updated") |
||||
|
cy.contains("Save").click() |
||||
|
cy.contains("Updated").should("have.text", "Updated") |
||||
|
}) |
||||
|
|
||||
|
it("deletes a row", () => { |
||||
|
cy.get(".spectrum-Checkbox-input").check({ force: true }) |
||||
|
cy.contains("Delete 1 row(s)").click() |
||||
|
cy.get(".spectrum-Modal").contains("Delete").click() |
||||
|
cy.contains("RoverUpdated").should("not.exist") |
||||
|
}) |
||||
|
|
||||
|
if (Cypress.env("TEST_ENV")) { |
||||
|
// No Pagination in CI - Test env only for the next two tests
|
||||
|
it("Adds 15 rows and checks pagination", () => { |
||||
|
// 10 rows per page, 15 rows should create 2 pages within table
|
||||
|
const totalRows = 16 |
||||
|
for (let i = 1; i < totalRows; i++) { |
||||
|
cy.addRow([i]) |
||||
|
} |
||||
|
cy.wait(1000) |
||||
|
cy.get(".spectrum-Pagination").within(() => { |
||||
|
cy.get(".spectrum-ActionButton").eq(1).click() |
||||
|
}) |
||||
|
cy.get(".spectrum-Pagination").within(() => { |
||||
|
cy.get(".spectrum-Body--secondary").contains("Page 2") |
||||
|
}) |
||||
|
}) |
||||
|
|
||||
|
it("Deletes rows and checks pagination", () => { |
||||
|
// Delete rows, removing second page of rows from table
|
||||
|
const deleteRows = 5 |
||||
|
cy.get(".spectrum-Checkbox-input").check({ force: true }) |
||||
|
cy.get(".spectrum-Table") |
||||
|
cy.contains("Delete 5 row(s)").click() |
||||
|
cy.get(".spectrum-Modal").contains("Delete").click() |
||||
|
cy.wait(1000) |
||||
|
|
||||
it("deletes a table", () => { |
// Confirm table only has one page
|
||||
cy.get(".nav-item") |
cy.get(".spectrum-Pagination").within(() => { |
||||
.contains("dog") |
cy.get(".spectrum-ActionButton").eq(1).should("not.be.enabled") |
||||
.parents(".nav-item") |
}) |
||||
.first() |
|
||||
.within(() => { |
|
||||
cy.get(".actions .spectrum-Icon").click({ force: true }) |
|
||||
}) |
}) |
||||
cy.get(".spectrum-Menu > :nth-child(2)").click() |
} |
||||
cy.get(`[data-cy="delete-table-confirm"]`).type("dog") |
|
||||
cy.contains("Delete Table").click() |
it("deletes a column", () => { |
||||
cy.contains("dog").should("not.exist") |
const columnName = "nameupdated" |
||||
|
cy.get(".title").click() |
||||
|
cy.get(".spectrum-Table-editIcon > use").click() |
||||
|
cy.contains("Delete").click() |
||||
|
cy.get('[data-cy="delete-column-confirm"]').type(columnName) |
||||
|
cy.contains("Delete Column").click() |
||||
|
cy.contains("nameupdated").should("not.exist") |
||||
|
}) |
||||
|
|
||||
|
it("deletes a table", () => { |
||||
|
cy.get(".nav-item") |
||||
|
.contains("dog") |
||||
|
.parents(".nav-item") |
||||
|
.first() |
||||
|
.within(() => { |
||||
|
cy.get(".actions .spectrum-Icon").click({ force: true }) |
||||
|
}) |
||||
|
cy.get(".spectrum-Menu > :nth-child(2)").click() |
||||
|
cy.get('[data-cy="delete-table-confirm"]').type("dog") |
||||
|
cy.contains("Delete Table").click() |
||||
|
cy.contains("dog").should("not.exist") |
||||
|
}) |
||||
}) |
}) |
||||
}) |
}) |
||||
|
|||||
@ -1,10 +0,0 @@ |
|||||
context("Create a User", () => { |
|
||||
before(() => { |
|
||||
cy.login() |
|
||||
}) |
|
||||
|
|
||||
it("should create a user", () => { |
|
||||
cy.createUser("bbuser@test.com") |
|
||||
cy.contains("bbuser").should("be.visible") |
|
||||
}) |
|
||||
}) |
|
||||
@ -0,0 +1,180 @@ |
|||||
|
import filterTests from "../support/filterTests" |
||||
|
|
||||
|
filterTests(["smoke", "all"], () => { |
||||
|
context("Create a User and Assign Roles", () => { |
||||
|
before(() => { |
||||
|
cy.login() |
||||
|
}) |
||||
|
|
||||
|
it("should create a user", () => { |
||||
|
cy.createUser("bbuser@test.com") |
||||
|
cy.get(".spectrum-Table").should("contain", "bbuser") |
||||
|
}) |
||||
|
|
||||
|
it("should confirm there is No Access for a New User", () => { |
||||
|
// Click into the user
|
||||
|
cy.contains("bbuser").click() |
||||
|
cy.wait(500) |
||||
|
// Get No Access table - Confirm it has apps in it
|
||||
|
cy.get(".spectrum-Table").eq(1).should("not.contain", "No rows found") |
||||
|
// Get Configure Roles table - Confirm it has no apps
|
||||
|
cy.get(".spectrum-Table").eq(0).contains("No rows found") |
||||
|
}) |
||||
|
|
||||
|
it("should assign role types", () => { |
||||
|
// 3 apps minimum required - to assign an app to each role type
|
||||
|
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`) |
||||
|
.its("body") |
||||
|
.then(val => { |
||||
|
if (val.length < 3) { |
||||
|
for (let i = 1; i < 3; i++) { |
||||
|
const uuid = () => Cypress._.random(0, 1e6) |
||||
|
const name = uuid() |
||||
|
cy.createApp(name) |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
// Navigate back to the user
|
||||
|
cy.visit(`${Cypress.config().baseUrl}/builder`) |
||||
|
cy.wait(500) |
||||
|
cy.get(".spectrum-SideNav").contains("Users").click() |
||||
|
cy.wait(500) |
||||
|
cy.get(".spectrum-Table").contains("bbuser").click() |
||||
|
cy.wait(1000) |
||||
|
for (let i = 0; i < 3; i++) { |
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(1) |
||||
|
.find(".spectrum-Table-row") |
||||
|
.eq(0) |
||||
|
.find(".spectrum-Table-cell") |
||||
|
.eq(0) |
||||
|
.click() |
||||
|
cy.wait(500) |
||||
|
cy.get(".spectrum-Dialog-grid") |
||||
|
.contains("Choose an option") |
||||
|
.click() |
||||
|
.then(() => { |
||||
|
cy.wait(1000) |
||||
|
if (i == 0) { |
||||
|
cy.get(".spectrum-Popover").contains("Admin").click() |
||||
|
} |
||||
|
if (i == 1) { |
||||
|
cy.get(".spectrum-Popover").contains("Power").click() |
||||
|
} |
||||
|
if (i == 2) { |
||||
|
cy.get(".spectrum-Popover").contains("Basic").click() |
||||
|
} |
||||
|
cy.wait(1000) |
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Update role") |
||||
|
.click({ force: true }) |
||||
|
}) |
||||
|
} |
||||
|
// Confirm roles exist within Configure roles table
|
||||
|
cy.wait(2000) |
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(0) |
||||
|
.within(assginedRoles => { |
||||
|
expect(assginedRoles).to.contain("Admin") |
||||
|
expect(assginedRoles).to.contain("Power") |
||||
|
expect(assginedRoles).to.contain("Basic") |
||||
|
}) |
||||
|
}) |
||||
|
|
||||
|
it("should unassign role types", () => { |
||||
|
// Set each app within Configure roles table to 'No Access'
|
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(0) |
||||
|
.find(".spectrum-Table-row") |
||||
|
.its("length") |
||||
|
.then(len => { |
||||
|
for (let i = 0; i < len; i++) { |
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(0) |
||||
|
.find(".spectrum-Table-row") |
||||
|
.eq(0) |
||||
|
.find(".spectrum-Table-cell") |
||||
|
.eq(0) |
||||
|
.click() |
||||
|
.then(() => { |
||||
|
cy.get(".spectrum-Picker").eq(1).click({ force: true }) |
||||
|
cy.wait(500) |
||||
|
cy.get(".spectrum-Popover").contains("No Access").click() |
||||
|
}) |
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Update role") |
||||
|
.click({ force: true }) |
||||
|
cy.wait(1000) |
||||
|
} |
||||
|
}) |
||||
|
// Confirm Configure roles table no longer has any apps in it
|
||||
|
cy.get(".spectrum-Table").eq(0).contains("No rows found") |
||||
|
}) |
||||
|
|
||||
|
it("should enable Developer access", () => { |
||||
|
// Enable Developer access
|
||||
|
cy.get(".field") |
||||
|
.eq(4) |
||||
|
.within(() => { |
||||
|
cy.get(".spectrum-Switch-input").click({ force: true }) |
||||
|
}) |
||||
|
// No Access table should now be empty
|
||||
|
cy.get(".container") |
||||
|
.contains("No Access") |
||||
|
.parent() |
||||
|
.within(() => { |
||||
|
cy.get(".spectrum-Table").contains("No rows found") |
||||
|
}) |
||||
|
|
||||
|
// Each app within Configure roles should have Admin access
|
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(0) |
||||
|
.find(".spectrum-Table-row") |
||||
|
.its("length") |
||||
|
.then(len => { |
||||
|
for (let i = 0; i < len; i++) { |
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(0) |
||||
|
.find(".spectrum-Table-row") |
||||
|
.eq(i) |
||||
|
.contains("Admin") |
||||
|
cy.wait(500) |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
|
|
||||
|
it("should disable Developer access", () => { |
||||
|
// Disable Developer access
|
||||
|
cy.get(".field") |
||||
|
.eq(4) |
||||
|
.within(() => { |
||||
|
cy.get(".spectrum-Switch-input").click({ force: true }) |
||||
|
}) |
||||
|
// Configure roles table should now be empty
|
||||
|
cy.get(".container") |
||||
|
.contains("Configure roles") |
||||
|
.parent() |
||||
|
.within(() => { |
||||
|
cy.get(".spectrum-Table").contains("No rows found") |
||||
|
}) |
||||
|
}) |
||||
|
|
||||
|
it("should delete a user", () => { |
||||
|
// Click Delete user button
|
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Delete user") |
||||
|
.click({ force: true }) |
||||
|
.then(() => { |
||||
|
// Confirm deletion within modal
|
||||
|
cy.wait(500) |
||||
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Delete user") |
||||
|
.click({ force: true }) |
||||
|
cy.wait(4000) |
||||
|
}) |
||||
|
}) |
||||
|
cy.get(".spectrum-Table").should("not.have.text", "bbuser") |
||||
|
}) |
||||
|
}) |
||||
|
}) |
||||
@ -1,152 +1,156 @@ |
|||||
context("Create a View", () => { |
import filterTests from "../support/filterTests" |
||||
before(() => { |
|
||||
cy.login() |
filterTests(['smoke', 'all'], () => { |
||||
cy.createTestApp() |
context("Create a View", () => { |
||||
cy.createTable("data") |
before(() => { |
||||
cy.addColumn("data", "group", "Text") |
cy.login() |
||||
cy.addColumn("data", "age", "Number") |
cy.createTestApp() |
||||
cy.addColumn("data", "rating", "Number") |
cy.createTable("data") |
||||
|
cy.addColumn("data", "group", "Text") |
||||
// 6 Rows
|
cy.addColumn("data", "age", "Number") |
||||
cy.addRow(["Students", 25, 1]) |
cy.addColumn("data", "rating", "Number") |
||||
cy.addRow(["Students", 20, 3]) |
|
||||
cy.addRow(["Students", 18, 6]) |
// 6 Rows
|
||||
cy.addRow(["Students", 25, 2]) |
cy.addRow(["Students", 25, 1]) |
||||
cy.addRow(["Teachers", 49, 5]) |
cy.addRow(["Students", 20, 3]) |
||||
cy.addRow(["Teachers", 36, 3]) |
cy.addRow(["Students", 18, 6]) |
||||
}) |
cy.addRow(["Students", 25, 2]) |
||||
|
cy.addRow(["Teachers", 49, 5]) |
||||
it("creates a view", () => { |
cy.addRow(["Teachers", 36, 3]) |
||||
cy.contains("Create view").click() |
|
||||
cy.get(".modal-inner-wrapper").within(() => { |
|
||||
cy.get("input").type("Test View") |
|
||||
cy.get("button").contains("Create View").click({ force: true }) |
|
||||
}) |
}) |
||||
cy.get(".table-title h1").contains("Test View") |
|
||||
cy.get(".title").then($headers => { |
it("creates a view", () => { |
||||
expect($headers).to.have.length(3) |
cy.contains("Create view").click() |
||||
const headers = Array.from($headers).map(header => |
cy.get(".modal-inner-wrapper").within(() => { |
||||
header.textContent.trim() |
cy.get("input").type("Test View") |
||||
) |
cy.get("button").contains("Create View").click({ force: true }) |
||||
expect(removeSpacing(headers)).to.deep.eq(["group", "age", "rating"]) |
}) |
||||
|
cy.get(".table-title h1").contains("Test View") |
||||
|
cy.get(".title").then($headers => { |
||||
|
expect($headers).to.have.length(3) |
||||
|
const headers = Array.from($headers).map(header => |
||||
|
header.textContent.trim() |
||||
|
) |
||||
|
expect(removeSpacing(headers)).to.deep.eq(["group", "age", "rating"]) |
||||
|
}) |
||||
}) |
}) |
||||
}) |
|
||||
|
|
||||
it("filters the view by age over 10", () => { |
it("filters the view by age over 10", () => { |
||||
cy.contains("Filter").click() |
cy.contains("Filter").click() |
||||
cy.contains("Add Filter").click() |
cy.contains("Add Filter").click() |
||||
|
|
||||
cy.get(".modal-inner-wrapper").within(() => { |
cy.get(".modal-inner-wrapper").within(() => { |
||||
cy.get(".spectrum-Picker-label").eq(0).click() |
cy.get(".spectrum-Picker-label").eq(0).click() |
||||
cy.contains("age").click({ force: true }) |
cy.contains("age").click({ force: true }) |
||||
|
|
||||
cy.get(".spectrum-Picker-label").eq(1).click() |
cy.get(".spectrum-Picker-label").eq(1).click() |
||||
cy.contains("More Than").click({ force: true }) |
cy.contains("More Than").click({ force: true }) |
||||
|
|
||||
cy.get("input").type(18) |
cy.get("input").type(18) |
||||
cy.contains("Save").click() |
cy.contains("Save").click() |
||||
}) |
}) |
||||
|
|
||||
cy.get(".spectrum-Table-row").get($values => { |
cy.get(".spectrum-Table-row").get($values => { |
||||
expect($values).to.have.length(5) |
expect($values).to.have.length(5) |
||||
|
}) |
||||
}) |
}) |
||||
}) |
|
||||
|
|
||||
it("creates a stats calculation view based on age", () => { |
|
||||
cy.wait(1000) |
|
||||
cy.contains("Calculate").click() |
|
||||
cy.get(".modal-inner-wrapper").within(() => { |
|
||||
cy.get(".spectrum-Picker-label").eq(0).click() |
|
||||
cy.contains("Statistics").click() |
|
||||
|
|
||||
cy.get(".spectrum-Picker-label").eq(1).click() |
it("creates a stats calculation view based on age", () => { |
||||
cy.contains("age").click({ force: true }) |
cy.wait(1000) |
||||
|
cy.contains("Calculate").click() |
||||
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
cy.get(".modal-inner-wrapper").within(() => { |
||||
}) |
cy.get(".spectrum-Picker-label").eq(0).click() |
||||
cy.wait(1000) |
cy.contains("Statistics").click() |
||||
|
|
||||
cy.get(".title").then($headers => { |
cy.get(".spectrum-Picker-label").eq(1).click() |
||||
expect($headers).to.have.length(7) |
cy.contains("age").click({ force: true }) |
||||
const headers = Array.from($headers).map(header => |
|
||||
header.textContent.trim() |
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
||||
) |
}) |
||||
expect(removeSpacing(headers)).to.deep.eq([ |
cy.wait(1000) |
||||
"field", |
|
||||
"sum", |
cy.get(".title").then($headers => { |
||||
"min", |
expect($headers).to.have.length(7) |
||||
"max", |
const headers = Array.from($headers).map(header => |
||||
"count", |
header.textContent.trim() |
||||
"sumsqr", |
) |
||||
"avg", |
expect(removeSpacing(headers)).to.deep.eq([ |
||||
]) |
"field", |
||||
|
"sum", |
||||
|
"min", |
||||
|
"max", |
||||
|
"count", |
||||
|
"sumsqr", |
||||
|
"avg", |
||||
|
]) |
||||
|
}) |
||||
|
cy.get(".spectrum-Table-cell").then($values => { |
||||
|
let values = Array.from($values).map(header => header.textContent.trim()) |
||||
|
expect(values).to.deep.eq(["age", "155", "20", "49", "5", "5347", "31"]) |
||||
|
}) |
||||
}) |
}) |
||||
cy.get(".spectrum-Table-cell").then($values => { |
|
||||
let values = Array.from($values).map(header => header.textContent.trim()) |
|
||||
expect(values).to.deep.eq(["age", "155", "20", "49", "5", "5347", "31"]) |
|
||||
}) |
|
||||
}) |
|
||||
|
|
||||
it("groups the view by group", () => { |
it("groups the view by group", () => { |
||||
cy.contains("Group by").click() |
cy.contains("Group by").click() |
||||
cy.get(".modal-inner-wrapper").within(() => { |
cy.get(".modal-inner-wrapper").within(() => { |
||||
cy.get(".spectrum-Picker-label").eq(0).click() |
cy.get(".spectrum-Picker-label").eq(0).click() |
||||
cy.contains("group").click() |
cy.contains("group").click() |
||||
cy.contains("Save").click() |
cy.contains("Save").click() |
||||
|
}) |
||||
|
cy.wait(1000) |
||||
|
cy.contains("Students").should("be.visible") |
||||
|
cy.contains("Teachers").should("be.visible") |
||||
|
|
||||
|
cy.get(".spectrum-Table-cell").then($values => { |
||||
|
let values = Array.from($values).map(header => header.textContent.trim()) |
||||
|
expect(values).to.deep.eq([ |
||||
|
"Students", |
||||
|
"70", |
||||
|
"20", |
||||
|
"25", |
||||
|
"3", |
||||
|
"1650", |
||||
|
"23.333333333333332", |
||||
|
"Teachers", |
||||
|
"85", |
||||
|
"36", |
||||
|
"49", |
||||
|
"2", |
||||
|
"3697", |
||||
|
"42.5", |
||||
|
]) |
||||
|
}) |
||||
}) |
}) |
||||
cy.wait(1000) |
|
||||
cy.contains("Students").should("be.visible") |
|
||||
cy.contains("Teachers").should("be.visible") |
|
||||
|
|
||||
cy.get(".spectrum-Table-cell").then($values => { |
|
||||
let values = Array.from($values).map(header => header.textContent.trim()) |
|
||||
expect(values).to.deep.eq([ |
|
||||
"Students", |
|
||||
"70", |
|
||||
"20", |
|
||||
"25", |
|
||||
"3", |
|
||||
"1650", |
|
||||
"23.333333333333332", |
|
||||
"Teachers", |
|
||||
"85", |
|
||||
"36", |
|
||||
"49", |
|
||||
"2", |
|
||||
"3697", |
|
||||
"42.5", |
|
||||
]) |
|
||||
}) |
|
||||
}) |
|
||||
|
|
||||
it("renames a view", () => { |
it("renames a view", () => { |
||||
cy.contains(".nav-item", "Test View") |
cy.contains(".nav-item", "Test View") |
||||
.find(".actions .icon") |
.find(".actions .icon") |
||||
.click({ force: true }) |
.click({ force: true }) |
||||
cy.get(".spectrum-Menu-itemLabel").contains("Edit").click() |
cy.get(".spectrum-Menu-itemLabel").contains("Edit").click() |
||||
cy.get(".modal-inner-wrapper").within(() => { |
cy.get(".modal-inner-wrapper").within(() => { |
||||
cy.get("input").type(" Updated") |
cy.get("input").type(" Updated") |
||||
cy.contains("Save").click() |
cy.contains("Save").click() |
||||
|
}) |
||||
|
cy.wait(1000) |
||||
|
cy.contains("Test View Updated").should("be.visible") |
||||
}) |
}) |
||||
cy.wait(1000) |
|
||||
cy.contains("Test View Updated").should("be.visible") |
|
||||
}) |
|
||||
|
|
||||
it("deletes a view", () => { |
it("deletes a view", () => { |
||||
cy.contains(".nav-item", "Test View Updated") |
cy.contains(".nav-item", "Test View Updated") |
||||
.find(".actions .icon") |
.find(".actions .icon") |
||||
.click({ force: true }) |
.click({ force: true }) |
||||
cy.contains("Delete").click() |
cy.contains("Delete").click() |
||||
cy.contains("Delete View").click() |
cy.contains("Delete View").click() |
||||
cy.wait(500) |
cy.wait(500) |
||||
cy.contains("TestView Updated").should("not.exist") |
cy.contains("TestView Updated").should("not.exist") |
||||
|
}) |
||||
}) |
}) |
||||
}) |
|
||||
|
|
||||
function removeSpacing(headers) { |
function removeSpacing(headers) { |
||||
let newHeaders = [] |
let newHeaders = [] |
||||
for (let header of headers) { |
for (let header of headers) { |
||||
newHeaders.push(header.replace(/\s\s+/g, " ")) |
newHeaders.push(header.replace(/\s\s+/g, " ")) |
||||
|
} |
||||
|
return newHeaders |
||||
} |
} |
||||
return newHeaders |
}) |
||||
} |
|
||||
|
|||||
@ -1,84 +1,87 @@ |
|||||
xcontext("Custom Theming Properties", () => { |
import filterTests from "../support/filterTests" |
||||
before(() => { |
|
||||
cy.login() |
|
||||
cy.createTestApp() |
|
||||
cy.navigateToFrontend() |
|
||||
}) |
|
||||
|
|
||||
/* Default Values: |
filterTests(['all'], () => { |
||||
Button roundness = Large |
xcontext("Custom Theming Properties", () => { |
||||
Accent colour = Blue 600 |
before(() => { |
||||
Accent colour (hover) = Blue 500 |
cy.login() |
||||
Navigation bar background colour = Gray 100 |
cy.createTestApp() |
||||
Navigation bar text colour = Gray 800 */ |
cy.navigateToFrontend() |
||||
it("should reset the color property values", () => { |
}) |
||||
// Open Theme modal and change colours
|
|
||||
cy.get(".spectrum-ActionButton-label").contains("Theme").click() |
/* Default Values: |
||||
cy.get(".spectrum-Picker").contains("Large").click() |
Button roundness = Large |
||||
.parents() |
Accent colour = Blue 600 |
||||
.get(".spectrum-Menu-itemLabel").contains("None").click() |
Accent colour (hover) = Blue 500 |
||||
changeThemeColors() |
Navigation bar background colour = Gray 100 |
||||
// Reset colours
|
Navigation bar text colour = Gray 800 */ |
||||
cy.get(".spectrum-Button-label").contains("Reset").click({force: true}) |
it("should reset the color property values", () => { |
||||
// Check values have reset
|
// Open Theme modal and change colours
|
||||
checkThemeColorDefaults() |
cy.get(".spectrum-ActionButton-label").contains("Theme").click() |
||||
}) |
cy.get(".spectrum-Picker").contains("Large").click() |
||||
|
.parents() |
||||
/* Button Roundness Values: |
.get(".spectrum-Menu-itemLabel").contains("None").click() |
||||
None = 0 |
changeThemeColors() |
||||
Small = 4px |
// Reset colours
|
||||
Medium = 8px |
cy.get(".spectrum-Button-label").contains("Reset").click({force: true}) |
||||
Large = 16px */ |
// Check values have reset
|
||||
it("should test button roundness", () => { |
checkThemeColorDefaults() |
||||
const buttonRoundnessValues = ["0", "4px", "8px", "16px"] |
}) |
||||
cy.wait(1000) |
|
||||
// Add button, change roundness and confirm value
|
/* Button Roundness Values: |
||||
cy.addComponent("Button", null).then((componentId) => { |
None = 0 |
||||
buttonRoundnessValues.forEach(function (item, index){ |
Small = 4px |
||||
cy.get(".spectrum-ActionButton-label").contains("Theme").click() |
Medium = 8px |
||||
cy.get(".setting").contains("Button roundness").parent() |
Large = 16px */ |
||||
.get(".select-wrapper").click() |
it("should test button roundness", () => { |
||||
cy.get(".spectrum-Popover").find('li').eq(index).click() |
const buttonRoundnessValues = ["0", "4px", "8px", "16px"] |
||||
cy.get(".spectrum-Button").contains("View changes").click({force: true}) |
cy.wait(1000) |
||||
cy.reload() |
// Add button, change roundness and confirm value
|
||||
cy.getComponent(componentId) |
cy.addComponent("Button", null).then((componentId) => { |
||||
.parents(".svelte-xiqd1c").eq(0).should('have.attr', 'style').and('contains', `--buttonBorderRadius:${item}`) |
buttonRoundnessValues.forEach(function (item, index){ |
||||
|
cy.get(".spectrum-ActionButton-label").contains("Theme").click() |
||||
|
cy.get(".setting").contains("Button roundness").parent() |
||||
|
.get(".select-wrapper").click() |
||||
|
cy.get(".spectrum-Popover").find('li').eq(index).click() |
||||
|
cy.get(".spectrum-Button").contains("View changes").click({force: true}) |
||||
|
cy.reload() |
||||
|
cy.getComponent(componentId) |
||||
|
.parents(".svelte-xiqd1c").eq(0).should('have.attr', 'style').and('contains', `--buttonBorderRadius:${item}`) |
||||
|
}) |
||||
}) |
}) |
||||
}) |
}) |
||||
|
|
||||
|
const changeThemeColors = () => { |
||||
|
// Changes the theme colours
|
||||
|
cy.get(".spectrum-FieldLabel").contains("Accent color") |
||||
|
.parent().find(".container.svelte-z3cm5a").click() |
||||
|
.find('[title="Red 400"]').click() |
||||
|
cy.get(".spectrum-FieldLabel").contains("Accent color (hover)") |
||||
|
.parent().find(".container.svelte-z3cm5a").click() |
||||
|
.find('[title="Orange 400"]').click() |
||||
|
cy.get(".spectrum-FieldLabel").contains("Navigation bar background color") |
||||
|
.parent().find(".container.svelte-z3cm5a").click() |
||||
|
.find('[title="Yellow 400"]').click() |
||||
|
cy.get(".spectrum-FieldLabel").contains("Navigation bar text color") |
||||
|
.parent().find(".container.svelte-z3cm5a").click() |
||||
|
.find('[title="Green 400"]').click() |
||||
|
} |
||||
|
|
||||
|
const checkThemeColorDefaults = () => { |
||||
|
cy.get(".spectrum-FieldLabel").contains("Accent color") |
||||
|
.parent().find(".container.svelte-z3cm5a").click() |
||||
|
.get('[title="Blue 600"]').children().find('[aria-label="Checkmark"]') |
||||
|
cy.get(".spectrum-Dialog-grid").click() |
||||
|
cy.get(".spectrum-FieldLabel").contains("Accent color (hover)") |
||||
|
.parent().find(".container.svelte-z3cm5a").click() |
||||
|
.get('[title="Blue 500"]').children().find('[aria-label="Checkmark"]') |
||||
|
cy.get(".spectrum-Dialog-grid").click() |
||||
|
cy.get(".spectrum-FieldLabel").contains("Navigation bar background color") |
||||
|
.parent().find(".container.svelte-z3cm5a").click() |
||||
|
.get('[title="Gray 100"]').children().find('[aria-label="Checkmark"]') |
||||
|
cy.get(".spectrum-Dialog-grid").click() |
||||
|
cy.get(".spectrum-FieldLabel").contains("Navigation bar text color") |
||||
|
.parent().find(".container.svelte-z3cm5a").click() |
||||
|
.get('[title="Gray 800"]').children().find('[aria-label="Checkmark"]') |
||||
|
} |
||||
}) |
}) |
||||
|
|
||||
const changeThemeColors = () => { |
|
||||
// Changes the theme colours
|
|
||||
cy.get(".spectrum-FieldLabel").contains("Accent color") |
|
||||
.parent().find(".container.svelte-z3cm5a").click() |
|
||||
.find('[title="Red 400"]').click() |
|
||||
cy.get(".spectrum-FieldLabel").contains("Accent color (hover)") |
|
||||
.parent().find(".container.svelte-z3cm5a").click() |
|
||||
.find('[title="Orange 400"]').click() |
|
||||
cy.get(".spectrum-FieldLabel").contains("Navigation bar background color") |
|
||||
.parent().find(".container.svelte-z3cm5a").click() |
|
||||
.find('[title="Yellow 400"]').click() |
|
||||
cy.get(".spectrum-FieldLabel").contains("Navigation bar text color") |
|
||||
.parent().find(".container.svelte-z3cm5a").click() |
|
||||
.find('[title="Green 400"]').click() |
|
||||
} |
|
||||
|
|
||||
const checkThemeColorDefaults = () => { |
|
||||
cy.get(".spectrum-FieldLabel").contains("Accent color") |
|
||||
.parent().find(".container.svelte-z3cm5a").click() |
|
||||
.get('[title="Blue 600"]').children().find('[aria-label="Checkmark"]') |
|
||||
cy.get(".spectrum-Dialog-grid").click() |
|
||||
cy.get(".spectrum-FieldLabel").contains("Accent color (hover)") |
|
||||
.parent().find(".container.svelte-z3cm5a").click() |
|
||||
.get('[title="Blue 500"]').children().find('[aria-label="Checkmark"]') |
|
||||
cy.get(".spectrum-Dialog-grid").click() |
|
||||
cy.get(".spectrum-FieldLabel").contains("Navigation bar background color") |
|
||||
.parent().find(".container.svelte-z3cm5a").click() |
|
||||
.get('[title="Gray 100"]').children().find('[aria-label="Checkmark"]') |
|
||||
cy.get(".spectrum-Dialog-grid").click() |
|
||||
cy.get(".spectrum-FieldLabel").contains("Navigation bar text color") |
|
||||
.parent().find(".container.svelte-z3cm5a").click() |
|
||||
.get('[title="Gray 800"]').children().find('[aria-label="Checkmark"]') |
|
||||
} |
|
||||
|
|
||||
}) |
}) |
||||
|
|||||
@ -0,0 +1,43 @@ |
|||||
|
import filterTests from "../../support/filterTests" |
||||
|
|
||||
|
filterTests(['all'], () => { |
||||
|
context("Datasource Wizard", () => { |
||||
|
if (Cypress.env("TEST_ENV")) { |
||||
|
before(() => { |
||||
|
cy.login() |
||||
|
cy.createTestApp() |
||||
|
}) |
||||
|
|
||||
|
it("should navigate in and out of a datasource via wizard", () => { |
||||
|
// Select PostgreSQL and add config (without fetch)
|
||||
|
const datasource = "Oracle" |
||||
|
cy.selectExternalDatasource(datasource) |
||||
|
cy.addDatasourceConfig(datasource, true) |
||||
|
|
||||
|
// Navigate back within datasource wizard
|
||||
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
|
cy.get(".spectrum-Button").contains("Back").click({ force: true }) |
||||
|
cy.wait(1000) |
||||
|
}) |
||||
|
|
||||
|
// Select PostgreSQL datasource again
|
||||
|
cy.get(".item-list").contains(datasource).click() |
||||
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
|
cy.get(".spectrum-Button").contains("Continue").click({ force: true }) |
||||
|
}) |
||||
|
|
||||
|
// Fetch tables after selection
|
||||
|
// Previously entered config should not have been saved
|
||||
|
// Config is back to default values
|
||||
|
// Modal will close and provide 500 error
|
||||
|
cy.intercept('**/datasources').as('datasourceConnection') |
||||
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
|
cy.get(".spectrum-Button").contains("Save and fetch tables").click({ force: true }) |
||||
|
}) |
||||
|
cy.wait("@datasourceConnection") |
||||
|
cy.get("@datasourceConnection").its('response.body') |
||||
|
.should('have.property', 'status', 500) |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
@ -0,0 +1,222 @@ |
|||||
|
import filterTests from "../../support/filterTests" |
||||
|
|
||||
|
filterTests(["all"], () => { |
||||
|
context("MySQL Datasource Testing", () => { |
||||
|
if (Cypress.env("TEST_ENV")) { |
||||
|
before(() => { |
||||
|
cy.login() |
||||
|
cy.createTestApp() |
||||
|
}) |
||||
|
const datasource = "MySQL" |
||||
|
const queryName = "Cypress Test Query" |
||||
|
const queryRename = "CT Query Rename" |
||||
|
|
||||
|
it("Should add MySQL data source without configuration", () => { |
||||
|
// Select MySQL data source
|
||||
|
cy.selectExternalDatasource(datasource) |
||||
|
// Attempt to fetch tables without applying configuration
|
||||
|
cy.intercept("**/datasources").as("datasource") |
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Save and fetch tables") |
||||
|
.click({ force: true }) |
||||
|
// Intercept Request after button click & apply assertions
|
||||
|
cy.wait("@datasource") |
||||
|
cy.get("@datasource") |
||||
|
.its("response.body") |
||||
|
.should( |
||||
|
"have.property", |
||||
|
"message", |
||||
|
"connect ECONNREFUSED 127.0.0.1:3306" |
||||
|
) |
||||
|
cy.get("@datasource") |
||||
|
.its("response.body") |
||||
|
.should("have.property", "status", 500) |
||||
|
}) |
||||
|
|
||||
|
it("should add MySQL data source and fetch tables", () => { |
||||
|
// Add & configure MySQL data source
|
||||
|
cy.selectExternalDatasource(datasource) |
||||
|
cy.intercept("**/datasources").as("datasource") |
||||
|
cy.addDatasourceConfig(datasource) |
||||
|
// Check response from datasource after adding configuration
|
||||
|
cy.wait("@datasource") |
||||
|
cy.get("@datasource").its("response.statusCode").should("eq", 200) |
||||
|
// Confirm fetch tables was successful
|
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(0) |
||||
|
.find(".spectrum-Table-row") |
||||
|
.its("length") |
||||
|
.should("be.gt", 0) |
||||
|
}) |
||||
|
|
||||
|
it("should check table fetching error", () => { |
||||
|
// MySQL test data source contains tables without primary keys
|
||||
|
cy.get(".spectrum-InLineAlert") |
||||
|
.should("contain", "Error fetching tables") |
||||
|
.and("contain", "No primary key constraint found") |
||||
|
}) |
||||
|
|
||||
|
it("should define a One relationship type", () => { |
||||
|
// Select relationship type & configure
|
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Define relationship") |
||||
|
.click({ force: true }) |
||||
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
|
cy.get(".spectrum-Picker").eq(0).click() |
||||
|
cy.get(".spectrum-Popover").contains("One").click() |
||||
|
cy.get(".spectrum-Picker").eq(1).click() |
||||
|
cy.get(".spectrum-Popover").contains("REGIONS").click() |
||||
|
cy.get(".spectrum-Picker").eq(2).click() |
||||
|
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
||||
|
cy.get(".spectrum-Picker").eq(3).click() |
||||
|
cy.get(".spectrum-Popover").contains("COUNTRIES").click() |
||||
|
cy.get(".spectrum-Picker").eq(4).click() |
||||
|
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
||||
|
// Save relationship & reload page
|
||||
|
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
||||
|
cy.reload() |
||||
|
}) |
||||
|
// Confirm table length & column name
|
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(1) |
||||
|
.find(".spectrum-Table-row") |
||||
|
.its("length") |
||||
|
.should("eq", 1) |
||||
|
cy.get(".spectrum-Table-cell").should("contain", "COUNTRIES to REGIONS") |
||||
|
}) |
||||
|
|
||||
|
it("should define a Many relationship type", () => { |
||||
|
// Select relationship type & configure
|
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Define relationship") |
||||
|
.click({ force: true }) |
||||
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
|
cy.get(".spectrum-Picker").eq(0).click() |
||||
|
cy.get(".spectrum-Popover").contains("Many").click() |
||||
|
cy.get(".spectrum-Picker").eq(1).click() |
||||
|
cy.get(".spectrum-Popover").contains("LOCATIONS").click() |
||||
|
cy.get(".spectrum-Picker").eq(2).click() |
||||
|
cy.get(".spectrum-Popover").contains("REGIONS").click() |
||||
|
cy.get(".spectrum-Picker").eq(3).click() |
||||
|
cy.get(".spectrum-Popover").contains("COUNTRIES").click() |
||||
|
cy.get(".spectrum-Picker").eq(4).click() |
||||
|
cy.get(".spectrum-Popover").contains("COUNTRY_ID").click() |
||||
|
cy.get(".spectrum-Picker").eq(5).click() |
||||
|
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
||||
|
// Save relationship & reload page
|
||||
|
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
||||
|
cy.reload() |
||||
|
cy.wait(1000) |
||||
|
}) |
||||
|
// Confirm table length & relationship name
|
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(1) |
||||
|
.find(".spectrum-Table-row") |
||||
|
.its("length") |
||||
|
.should("eq", 2) |
||||
|
cy.get(".spectrum-Table-cell").should( |
||||
|
"contain", |
||||
|
"LOCATIONS through COUNTRIES → REGIONS" |
||||
|
) |
||||
|
}) |
||||
|
|
||||
|
it("should delete relationships", () => { |
||||
|
// Delete both relationships
|
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(1) |
||||
|
.find(".spectrum-Table-row") |
||||
|
.its("length") |
||||
|
.then(len => { |
||||
|
for (let i = 0; i < len; i++) { |
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(1) |
||||
|
.within(() => { |
||||
|
cy.get(".spectrum-Table-row").eq(0).click() |
||||
|
cy.wait(500) |
||||
|
}) |
||||
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Delete") |
||||
|
.click({ force: true }) |
||||
|
}) |
||||
|
cy.reload() |
||||
|
} |
||||
|
// Confirm relationships no longer exist
|
||||
|
cy.get(".spectrum-Body").should( |
||||
|
"contain", |
||||
|
"No relationships configured" |
||||
|
) |
||||
|
}) |
||||
|
}) |
||||
|
|
||||
|
it("should add a query", () => { |
||||
|
// Add query
|
||||
|
cy.get(".spectrum-Button").contains("Add query").click({ force: true }) |
||||
|
cy.get(".spectrum-Form-item") |
||||
|
.eq(0) |
||||
|
.within(() => { |
||||
|
cy.get("input").type(queryName) |
||||
|
}) |
||||
|
// Insert Query within Fields section
|
||||
|
cy.get(".CodeMirror textarea") |
||||
|
.eq(0) |
||||
|
.type("SELECT * FROM books", { force: true }) |
||||
|
// Intercept query execution
|
||||
|
cy.intercept("**/queries/preview").as("query") |
||||
|
cy.get(".spectrum-Button").contains("Run Query").click({ force: true }) |
||||
|
cy.wait(500) |
||||
|
cy.wait("@query") |
||||
|
// Assert against Status Code & Body
|
||||
|
cy.get("@query").its("response.statusCode").should("eq", 200) |
||||
|
cy.get("@query").its("response.body").should("not.be.empty") |
||||
|
// Save query
|
||||
|
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) |
||||
|
cy.get(".nav-item").should("contain", queryName) |
||||
|
}) |
||||
|
|
||||
|
it("should duplicate a query", () => { |
||||
|
// Get last nav item - The query
|
||||
|
cy.get(".nav-item") |
||||
|
.last() |
||||
|
.within(() => { |
||||
|
cy.get(".icon").eq(1).click({ force: true }) |
||||
|
}) |
||||
|
// Select and confirm duplication
|
||||
|
cy.get(".spectrum-Menu").contains("Duplicate").click() |
||||
|
cy.get(".nav-item").should("contain", queryName + " (1)") |
||||
|
}) |
||||
|
|
||||
|
it("should edit a query name", () => { |
||||
|
// Rename query
|
||||
|
cy.get(".spectrum-Form-item") |
||||
|
.eq(0) |
||||
|
.within(() => { |
||||
|
cy.get("input").clear().type(queryRename) |
||||
|
}) |
||||
|
// Save query
|
||||
|
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) |
||||
|
cy.get(".nav-item").should("contain", queryRename) |
||||
|
}) |
||||
|
|
||||
|
it("should delete a query", () => { |
||||
|
// Get last nav item - The query
|
||||
|
for (let i = 0; i < 2; i++) { |
||||
|
cy.get(".nav-item") |
||||
|
.last() |
||||
|
.within(() => { |
||||
|
cy.get(".icon").eq(1).click({ force: true }) |
||||
|
}) |
||||
|
// Select Delete
|
||||
|
cy.get(".spectrum-Menu").contains("Delete").click() |
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Delete Query") |
||||
|
.click({ force: true }) |
||||
|
cy.wait(1000) |
||||
|
} |
||||
|
// Confirm deletion
|
||||
|
cy.get(".nav-item").should("not.contain", queryName) |
||||
|
cy.get(".nav-item").should("not.contain", queryRename) |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
@ -0,0 +1,230 @@ |
|||||
|
import filterTests from "../../support/filterTests" |
||||
|
|
||||
|
filterTests(["all"], () => { |
||||
|
context("Oracle Datasource Testing", () => { |
||||
|
if (Cypress.env("TEST_ENV")) { |
||||
|
before(() => { |
||||
|
cy.login() |
||||
|
cy.createTestApp() |
||||
|
}) |
||||
|
const datasource = "Oracle" |
||||
|
const queryName = "Cypress Test Query" |
||||
|
const queryRename = "CT Query Rename" |
||||
|
|
||||
|
it("Should add Oracle data source and skip table fetch", () => { |
||||
|
// Select Oracle data source
|
||||
|
cy.selectExternalDatasource(datasource) |
||||
|
// Skip table fetch - no config added
|
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Skip table fetch") |
||||
|
.click({ force: true }) |
||||
|
cy.wait(500) |
||||
|
// Confirm config contains localhost
|
||||
|
cy.get(".spectrum-Textfield-input") |
||||
|
.eq(1) |
||||
|
.should("have.value", "localhost") |
||||
|
// Add another Oracle data source, configure & skip table fetch
|
||||
|
cy.selectExternalDatasource(datasource) |
||||
|
cy.addDatasourceConfig(datasource, true) |
||||
|
// Confirm config and no tables
|
||||
|
cy.get(".spectrum-Textfield-input") |
||||
|
.eq(1) |
||||
|
.should("have.value", Cypress.env("oracle").HOST) |
||||
|
cy.get(".spectrum-Body").eq(2).should("contain", "No tables found.") |
||||
|
}) |
||||
|
|
||||
|
it("Should add Oracle data source and fetch tables without configuration", () => { |
||||
|
// Select Oracle data source
|
||||
|
cy.selectExternalDatasource(datasource) |
||||
|
// Attempt to fetch tables without applying configuration
|
||||
|
cy.intercept("**/datasources").as("datasource") |
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Save and fetch tables") |
||||
|
.click({ force: true }) |
||||
|
// Intercept Request after button click & apply assertions
|
||||
|
cy.wait("@datasource") |
||||
|
cy.get("@datasource") |
||||
|
.its("response.body") |
||||
|
.should("have.property", "status", 500) |
||||
|
}) |
||||
|
|
||||
|
it("should add Oracle data source and fetch tables", () => { |
||||
|
// Add & configure Oracle data source
|
||||
|
cy.selectExternalDatasource(datasource) |
||||
|
cy.intercept("**/datasources").as("datasource") |
||||
|
cy.addDatasourceConfig(datasource) |
||||
|
// Check response from datasource after adding configuration
|
||||
|
cy.wait("@datasource") |
||||
|
cy.get("@datasource").its("response.statusCode").should("eq", 200) |
||||
|
// Confirm fetch tables was successful
|
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(0) |
||||
|
.find(".spectrum-Table-row") |
||||
|
.its("length") |
||||
|
.should("be.gt", 0) |
||||
|
}) |
||||
|
|
||||
|
it("should define a One relationship type", () => { |
||||
|
// Select relationship type & configure
|
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Define relationship") |
||||
|
.click({ force: true }) |
||||
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
|
cy.get(".spectrum-Picker").eq(0).click() |
||||
|
cy.get(".spectrum-Popover").contains("One").click() |
||||
|
cy.get(".spectrum-Picker").eq(1).click() |
||||
|
cy.get(".spectrum-Popover").contains("REGIONS").click() |
||||
|
cy.get(".spectrum-Picker").eq(2).click() |
||||
|
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
||||
|
cy.get(".spectrum-Picker").eq(3).click() |
||||
|
cy.get(".spectrum-Popover").contains("COUNTRIES").click() |
||||
|
cy.get(".spectrum-Picker").eq(4).click() |
||||
|
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
||||
|
// Save relationship & reload page
|
||||
|
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
||||
|
cy.reload() |
||||
|
}) |
||||
|
// Confirm table length & column name
|
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(1) |
||||
|
.find(".spectrum-Table-row") |
||||
|
.its("length") |
||||
|
.should("eq", 1) |
||||
|
cy.get(".spectrum-Table-cell").should("contain", "COUNTRIES to REGIONS") |
||||
|
}) |
||||
|
|
||||
|
it("should define a Many relationship type", () => { |
||||
|
// Select relationship type & configure
|
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Define relationship") |
||||
|
.click({ force: true }) |
||||
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
|
cy.get(".spectrum-Picker").eq(0).click() |
||||
|
cy.get(".spectrum-Popover").contains("Many").click() |
||||
|
cy.get(".spectrum-Picker").eq(1).click() |
||||
|
cy.get(".spectrum-Popover").contains("LOCATIONS").click() |
||||
|
cy.get(".spectrum-Picker").eq(2).click() |
||||
|
cy.get(".spectrum-Popover").contains("REGIONS").click() |
||||
|
cy.get(".spectrum-Picker").eq(3).click() |
||||
|
cy.get(".spectrum-Popover").contains("COUNTRIES").click() |
||||
|
cy.get(".spectrum-Picker").eq(4).click() |
||||
|
cy.get(".spectrum-Popover").contains("COUNTRY_ID").click() |
||||
|
cy.get(".spectrum-Picker").eq(5).click() |
||||
|
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
||||
|
// Save relationship & reload page
|
||||
|
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
||||
|
cy.reload() |
||||
|
}) |
||||
|
// Confirm table length & relationship name
|
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(1) |
||||
|
.find(".spectrum-Table-row") |
||||
|
.its("length") |
||||
|
.should("eq", 2) |
||||
|
cy.get(".spectrum-Table-cell").should( |
||||
|
"contain", |
||||
|
"LOCATIONS through COUNTRIES → REGIONS" |
||||
|
) |
||||
|
}) |
||||
|
|
||||
|
it("should delete relationships", () => { |
||||
|
// Delete both relationships
|
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(1) |
||||
|
.find(".spectrum-Table-row") |
||||
|
.its("length") |
||||
|
.then(len => { |
||||
|
for (let i = 0; i < len; i++) { |
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(1) |
||||
|
.within(() => { |
||||
|
cy.get(".spectrum-Table-row").eq(0).click() |
||||
|
cy.wait(500) |
||||
|
}) |
||||
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Delete") |
||||
|
.click({ force: true }) |
||||
|
}) |
||||
|
cy.reload() |
||||
|
} |
||||
|
// Confirm relationships no longer exist
|
||||
|
cy.get(".spectrum-Body").should( |
||||
|
"contain", |
||||
|
"No relationships configured" |
||||
|
) |
||||
|
}) |
||||
|
}) |
||||
|
|
||||
|
it("should add a query", () => { |
||||
|
// Add query
|
||||
|
cy.get(".spectrum-Button").contains("Add query").click({ force: true }) |
||||
|
cy.get(".spectrum-Form-item") |
||||
|
.eq(0) |
||||
|
.within(() => { |
||||
|
cy.get("input").type(queryName) |
||||
|
}) |
||||
|
// Insert Query within Fields section
|
||||
|
cy.get(".CodeMirror textarea") |
||||
|
.eq(0) |
||||
|
.type("SELECT * FROM JOBS", { force: true }) |
||||
|
// Intercept query execution
|
||||
|
cy.intercept("**/queries/preview").as("query") |
||||
|
cy.get(".spectrum-Button").contains("Run Query").click({ force: true }) |
||||
|
cy.wait(500) |
||||
|
cy.wait("@query") |
||||
|
// Assert against Status Code & Body
|
||||
|
cy.get("@query").its("response.statusCode").should("eq", 200) |
||||
|
cy.get("@query").its("response.body").should("not.be.empty") |
||||
|
// Save query
|
||||
|
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) |
||||
|
cy.get(".nav-item").should("contain", queryName) |
||||
|
}) |
||||
|
|
||||
|
it("should duplicate a query", () => { |
||||
|
// Get query nav item
|
||||
|
cy.get(".nav-item") |
||||
|
.contains(queryName) |
||||
|
.parent() |
||||
|
.within(() => { |
||||
|
cy.get(".spectrum-Icon").eq(1).click({ force: true }) |
||||
|
}) |
||||
|
// Select and confirm duplication
|
||||
|
cy.get(".spectrum-Menu").contains("Duplicate").click() |
||||
|
cy.get(".nav-item").should("contain", queryName + " (1)") |
||||
|
}) |
||||
|
|
||||
|
it("should edit a query name", () => { |
||||
|
// Rename query
|
||||
|
cy.get(".spectrum-Form-item") |
||||
|
.eq(0) |
||||
|
.within(() => { |
||||
|
cy.get("input").clear().type(queryRename) |
||||
|
}) |
||||
|
// Save query
|
||||
|
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) |
||||
|
cy.get(".nav-item").should("contain", queryRename) |
||||
|
}) |
||||
|
|
||||
|
it("should delete a query", () => { |
||||
|
// Get query nav item - QueryName
|
||||
|
cy.get(".nav-item") |
||||
|
.contains(queryName) |
||||
|
.parent() |
||||
|
.within(() => { |
||||
|
cy.get(".spectrum-Icon").eq(1).click({ force: true }) |
||||
|
}) |
||||
|
|
||||
|
// Select Delete
|
||||
|
cy.get(".spectrum-Menu").contains("Delete").click() |
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Delete Query") |
||||
|
.click({ force: true }) |
||||
|
cy.wait(1000) |
||||
|
|
||||
|
// Confirm deletion
|
||||
|
cy.get(".nav-item").should("not.contain", queryName) |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
@ -0,0 +1,285 @@ |
|||||
|
import filterTests from "../../support/filterTests" |
||||
|
|
||||
|
filterTests(["all"], () => { |
||||
|
context("PostgreSQL Datasource Testing", () => { |
||||
|
if (Cypress.env("TEST_ENV")) { |
||||
|
before(() => { |
||||
|
cy.login() |
||||
|
cy.createTestApp() |
||||
|
}) |
||||
|
const datasource = "PostgreSQL" |
||||
|
const queryName = "Cypress Test Query" |
||||
|
const queryRename = "CT Query Rename" |
||||
|
|
||||
|
it("Should add PostgreSQL data source without configuration", () => { |
||||
|
// Select PostgreSQL data source
|
||||
|
cy.selectExternalDatasource(datasource) |
||||
|
// Attempt to fetch tables without applying configuration
|
||||
|
cy.intercept("**/datasources").as("datasource") |
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Save and fetch tables") |
||||
|
.click({ force: true }) |
||||
|
// Intercept Request after button click & apply assertions
|
||||
|
cy.wait("@datasource") |
||||
|
cy.get("@datasource") |
||||
|
.its("response.body") |
||||
|
.should( |
||||
|
"have.property", |
||||
|
"message", |
||||
|
"connect ECONNREFUSED 127.0.0.1:5432" |
||||
|
) |
||||
|
cy.get("@datasource") |
||||
|
.its("response.body") |
||||
|
.should("have.property", "status", 500) |
||||
|
}) |
||||
|
|
||||
|
it("should add PostgreSQL data source and fetch tables", () => { |
||||
|
// Add & configure PostgreSQL data source
|
||||
|
cy.selectExternalDatasource(datasource) |
||||
|
cy.intercept("**/datasources").as("datasource") |
||||
|
cy.addDatasourceConfig(datasource) |
||||
|
// Check response from datasource after adding configuration
|
||||
|
cy.wait("@datasource") |
||||
|
cy.get("@datasource").its("response.statusCode").should("eq", 200) |
||||
|
// Confirm fetch tables was successful
|
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(0) |
||||
|
.find(".spectrum-Table-row") |
||||
|
.its("length") |
||||
|
.should("be.gt", 0) |
||||
|
}) |
||||
|
|
||||
|
it("should define a One relationship type", () => { |
||||
|
// Select relationship type & configure
|
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Define relationship") |
||||
|
.click({ force: true }) |
||||
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
|
cy.get(".spectrum-Picker").eq(0).click() |
||||
|
cy.get(".spectrum-Popover").contains("One").click() |
||||
|
cy.get(".spectrum-Picker").eq(1).click() |
||||
|
cy.get(".spectrum-Popover").contains("REGIONS").click() |
||||
|
cy.get(".spectrum-Picker").eq(2).click() |
||||
|
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
||||
|
cy.get(".spectrum-Picker").eq(3).click() |
||||
|
cy.get(".spectrum-Popover").contains("COUNTRIES").click() |
||||
|
cy.get(".spectrum-Picker").eq(4).click() |
||||
|
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
||||
|
// Save relationship & reload page
|
||||
|
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
||||
|
cy.reload() |
||||
|
}) |
||||
|
// Confirm table length & column name
|
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(1) |
||||
|
.find(".spectrum-Table-row") |
||||
|
.its("length") |
||||
|
.should("eq", 1) |
||||
|
cy.get(".spectrum-Table-cell").should("contain", "COUNTRIES to REGIONS") |
||||
|
}) |
||||
|
|
||||
|
it("should define a Many relationship type", () => { |
||||
|
// Select relationship type & configure
|
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Define relationship") |
||||
|
.click({ force: true }) |
||||
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
|
cy.get(".spectrum-Picker").eq(0).click() |
||||
|
cy.get(".spectrum-Popover").contains("Many").click() |
||||
|
cy.get(".spectrum-Picker").eq(1).click() |
||||
|
cy.get(".spectrum-Popover").contains("LOCATIONS").click() |
||||
|
cy.get(".spectrum-Picker").eq(2).click() |
||||
|
cy.get(".spectrum-Popover").contains("REGIONS").click() |
||||
|
cy.get(".spectrum-Picker").eq(3).click() |
||||
|
cy.get(".spectrum-Popover").contains("COUNTRIES").click() |
||||
|
cy.get(".spectrum-Picker").eq(4).click() |
||||
|
cy.get(".spectrum-Popover").contains("COUNTRY_ID").click() |
||||
|
cy.get(".spectrum-Picker").eq(5).click() |
||||
|
cy.get(".spectrum-Popover").contains("REGION_ID").click() |
||||
|
// Save relationship & reload page
|
||||
|
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
||||
|
cy.reload() |
||||
|
}) |
||||
|
// Confirm table length & relationship name
|
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(1) |
||||
|
.find(".spectrum-Table-row") |
||||
|
.its("length") |
||||
|
.should("eq", 2) |
||||
|
cy.get(".spectrum-Table-cell").should( |
||||
|
"contain", |
||||
|
"LOCATIONS through COUNTRIES → REGIONS" |
||||
|
) |
||||
|
}) |
||||
|
|
||||
|
it("should delete a relationship", () => { |
||||
|
cy.get(".hierarchy-items-container").contains(datasource).click() |
||||
|
cy.reload() |
||||
|
// Delete one relationship
|
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(1) |
||||
|
.within(() => { |
||||
|
cy.get(".spectrum-Table-row").eq(0).click() |
||||
|
cy.wait(500) |
||||
|
}) |
||||
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
|
cy.get(".spectrum-Button").contains("Delete").click({ force: true }) |
||||
|
}) |
||||
|
cy.reload() |
||||
|
// Confirm relationship was deleted
|
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(1) |
||||
|
.find(".spectrum-Table-row") |
||||
|
.its("length") |
||||
|
.should("eq", 1) |
||||
|
}) |
||||
|
|
||||
|
it("should add a query", () => { |
||||
|
// Add query
|
||||
|
cy.get(".spectrum-Button").contains("Add query").click({ force: true }) |
||||
|
cy.get(".spectrum-Form-item") |
||||
|
.eq(0) |
||||
|
.within(() => { |
||||
|
cy.get("input").type(queryName) |
||||
|
}) |
||||
|
// Insert Query within Fields section
|
||||
|
cy.get(".CodeMirror textarea") |
||||
|
.eq(0) |
||||
|
.type("SELECT * FROM books", { force: true }) |
||||
|
// Intercept query execution
|
||||
|
cy.intercept("**/queries/preview").as("query") |
||||
|
cy.get(".spectrum-Button").contains("Run Query").click({ force: true }) |
||||
|
cy.wait(500) |
||||
|
cy.wait("@query") |
||||
|
// Assert against Status Code & Body
|
||||
|
cy.get("@query").its("response.statusCode").should("eq", 200) |
||||
|
cy.get("@query").its("response.body").should("not.be.empty") |
||||
|
// Save query
|
||||
|
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) |
||||
|
cy.get(".hierarchy-items-container").should("contain", queryName) |
||||
|
}) |
||||
|
|
||||
|
it("should switch to schema with no tables", () => { |
||||
|
// Switch Schema - To one without any tables
|
||||
|
cy.get(".hierarchy-items-container").contains(datasource).click() |
||||
|
switchSchema("randomText") |
||||
|
|
||||
|
// No tables displayed
|
||||
|
cy.get(".spectrum-Body").eq(2).should("contain", "No tables found") |
||||
|
|
||||
|
// Previously created query should be visible
|
||||
|
cy.get(".spectrum-Table").should("contain", queryName) |
||||
|
}) |
||||
|
|
||||
|
it("should switch schemas", () => { |
||||
|
// Switch schema - To one with tables
|
||||
|
switchSchema("1") |
||||
|
|
||||
|
// Confirm tables exist - Check for specific one
|
||||
|
cy.get(".spectrum-Table").eq(0).should("contain", "test") |
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(0) |
||||
|
.find(".spectrum-Table-row") |
||||
|
.its("length") |
||||
|
.should("eq", 1) |
||||
|
|
||||
|
// Confirm specific table visible within left nav bar
|
||||
|
cy.get(".hierarchy-items-container").should("contain", "test") |
||||
|
|
||||
|
// Switch back to public schema
|
||||
|
switchSchema("public") |
||||
|
|
||||
|
// Confirm tables exist - again
|
||||
|
cy.get(".spectrum-Table").eq(0).should("contain", "REGIONS") |
||||
|
cy.get(".spectrum-Table") |
||||
|
.eq(0) |
||||
|
.find(".spectrum-Table-row") |
||||
|
.its("length") |
||||
|
.should("be.gt", 1) |
||||
|
|
||||
|
// Confirm specific table visible within left nav bar
|
||||
|
cy.get(".hierarchy-items-container").should("contain", "REGIONS") |
||||
|
|
||||
|
// No relationships and one query
|
||||
|
cy.get(".spectrum-Body") |
||||
|
.eq(3) |
||||
|
.should("contain", "No relationships configured.") |
||||
|
cy.get(".spectrum-Table").eq(1).should("contain", queryName) |
||||
|
}) |
||||
|
|
||||
|
it("should duplicate a query", () => { |
||||
|
// Get last nav item - The query
|
||||
|
cy.get(".nav-item") |
||||
|
.last() |
||||
|
.within(() => { |
||||
|
cy.get(".icon").eq(1).click({ force: true }) |
||||
|
}) |
||||
|
// Select and confirm duplication
|
||||
|
cy.get(".spectrum-Menu").contains("Duplicate").click() |
||||
|
cy.get(".nav-item").should("contain", queryName + " (1)") |
||||
|
}) |
||||
|
|
||||
|
it("should edit a query name", () => { |
||||
|
// Access query
|
||||
|
cy.get(".hierarchy-items-container") |
||||
|
.contains(queryName + " (1)") |
||||
|
.click() |
||||
|
|
||||
|
// Rename query
|
||||
|
cy.get(".spectrum-Form-item") |
||||
|
.eq(0) |
||||
|
.within(() => { |
||||
|
cy.get("input").clear().type(queryRename) |
||||
|
}) |
||||
|
|
||||
|
// Run and Save query
|
||||
|
cy.get(".spectrum-Button").contains("Run Query").click({ force: true }) |
||||
|
cy.wait(500) |
||||
|
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) |
||||
|
cy.get(".nav-item").should("contain", queryRename) |
||||
|
}) |
||||
|
|
||||
|
it("should delete a query", () => { |
||||
|
// Get last nav item - The query
|
||||
|
for (let i = 0; i < 2; i++) { |
||||
|
cy.get(".nav-item") |
||||
|
.last() |
||||
|
.within(() => { |
||||
|
cy.get(".icon").eq(1).click({ force: true }) |
||||
|
}) |
||||
|
// Select Delete
|
||||
|
cy.get(".spectrum-Menu").contains("Delete").click() |
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Delete Query") |
||||
|
.click({ force: true }) |
||||
|
cy.wait(1000) |
||||
|
} |
||||
|
// Confirm deletion
|
||||
|
cy.get(".nav-item").should("not.contain", queryName) |
||||
|
cy.get(".nav-item").should("not.contain", queryRename) |
||||
|
}) |
||||
|
|
||||
|
const switchSchema = schema => { |
||||
|
// Edit configuration - Change Schema
|
||||
|
cy.get(".spectrum-Textfield") |
||||
|
.eq(6) |
||||
|
.within(() => { |
||||
|
cy.get("input").clear().type(schema) |
||||
|
}) |
||||
|
// Save configuration & fetch
|
||||
|
cy.get(".spectrum-Button").contains("Save").click({ force: true }) |
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Fetch tables") |
||||
|
.click({ force: true }) |
||||
|
// Click fetch tables again within modal
|
||||
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
|
cy.get(".spectrum-Button") |
||||
|
.contains("Fetch tables") |
||||
|
.click({ force: true }) |
||||
|
}) |
||||
|
cy.reload() |
||||
|
cy.wait(5000) |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
@ -0,0 +1,47 @@ |
|||||
|
import filterTests from "../../support/filterTests" |
||||
|
|
||||
|
filterTests(["smoke", "all"], () => { |
||||
|
context("REST Datasource Testing", () => { |
||||
|
before(() => { |
||||
|
cy.login() |
||||
|
cy.createTestApp() |
||||
|
}) |
||||
|
|
||||
|
const datasource = "REST" |
||||
|
const restUrl = "https://api.openbrewerydb.org/breweries" |
||||
|
|
||||
|
it("Should add REST data source with incorrect API", () => { |
||||
|
// Select REST data source
|
||||
|
cy.selectExternalDatasource(datasource) |
||||
|
// Enter incorrect api & attempt to send query
|
||||
|
cy.wait(500) |
||||
|
cy.get(".spectrum-Button").contains("Add query").click({ force: true }) |
||||
|
cy.intercept("**/preview").as("queryError") |
||||
|
cy.get("input").clear().type("random text") |
||||
|
cy.get(".spectrum-Button").contains("Send").click({ force: true }) |
||||
|
// Intercept Request after button click & apply assertions
|
||||
|
cy.wait("@queryError") |
||||
|
cy.get("@queryError") |
||||
|
.its("response.body") |
||||
|
.should("have.property", "message", "Invalid URL: http://random text?") |
||||
|
cy.get("@queryError") |
||||
|
.its("response.body") |
||||
|
.should("have.property", "status", 400) |
||||
|
}) |
||||
|
|
||||
|
it("should add and configure a REST datasource", () => { |
||||
|
// Select REST datasource and create query
|
||||
|
cy.selectExternalDatasource(datasource) |
||||
|
cy.wait(500) |
||||
|
// createRestQuery confirms query creation
|
||||
|
cy.createRestQuery("GET", restUrl, "/breweries") |
||||
|
// Confirm status code response within REST datasource
|
||||
|
cy.wait(1000) |
||||
|
cy.get(".stats").within(() => { |
||||
|
cy.get(".spectrum-FieldLabel") |
||||
|
.eq(0) |
||||
|
.should("contain", 200) |
||||
|
}) |
||||
|
}) |
||||
|
}) |
||||
|
}) |
||||
@ -0,0 +1,140 @@ |
|||||
|
import filterTests from "../support/filterTests" |
||||
|
|
||||
|
filterTests(["smoke", "all"], () => { |
||||
|
context("Query Level Transformers", () => { |
||||
|
before(() => { |
||||
|
cy.login() |
||||
|
cy.deleteApp("Cypress Tests") |
||||
|
cy.createApp("Cypress Tests") |
||||
|
}) |
||||
|
|
||||
|
it("should write a transformer function", () => { |
||||
|
// Add REST datasource - contains API for breweries
|
||||
|
const datasource = "REST" |
||||
|
const restUrl = "https://api.openbrewerydb.org/breweries" |
||||
|
cy.selectExternalDatasource(datasource) |
||||
|
cy.createRestQuery("GET", restUrl, "/breweries") |
||||
|
cy.get(".spectrum-Tabs-itemLabel").contains("Transformer").click() |
||||
|
// Get Transformer Function from file
|
||||
|
cy.readFile("cypress/support/queryLevelTransformerFunction.js").then( |
||||
|
transformerFunction => { |
||||
|
cy.get(".CodeMirror textarea") |
||||
|
// Highlight current text and overwrite with file contents
|
||||
|
.type(Cypress.platform === "darwin" ? "{cmd}a" : "{ctrl}a", { |
||||
|
force: true, |
||||
|
}) |
||||
|
.type(transformerFunction, { parseSpecialCharSequences: false }) |
||||
|
} |
||||
|
) |
||||
|
// Send Query
|
||||
|
cy.intercept("**/queries/preview").as("query") |
||||
|
cy.get(".spectrum-Button").contains("Send").click({ force: true }) |
||||
|
cy.wait("@query") |
||||
|
// Assert against Status Code, body, & body rows
|
||||
|
cy.get("@query").its("response.statusCode").should("eq", 200) |
||||
|
cy.get("@query").its("response.body").should("not.be.empty") |
||||
|
cy.get("@query").its("response.body.rows").should("not.be.empty") |
||||
|
}) |
||||
|
|
||||
|
it("should add data to the previous query", () => { |
||||
|
// Add REST datasource - contains API for breweries
|
||||
|
const datasource = "REST" |
||||
|
const restUrl = "https://api.openbrewerydb.org/breweries" |
||||
|
cy.selectExternalDatasource(datasource) |
||||
|
cy.createRestQuery("GET", restUrl, "/breweries") |
||||
|
cy.get(".spectrum-Tabs-itemLabel").contains("Transformer").click() |
||||
|
// Get Transformer Function with Data from file
|
||||
|
cy.readFile( |
||||
|
"cypress/support/queryLevelTransformerFunctionWithData.js" |
||||
|
).then(transformerFunction => { |
||||
|
//console.log(transformerFunction[1])
|
||||
|
cy.get(".CodeMirror textarea") |
||||
|
// Highlight current text and overwrite with file contents
|
||||
|
.type(Cypress.platform === "darwin" ? "{cmd}a" : "{ctrl}a", { |
||||
|
force: true, |
||||
|
}) |
||||
|
.type(transformerFunction, { parseSpecialCharSequences: false }) |
||||
|
}) |
||||
|
// Send Query
|
||||
|
cy.intercept("**/queries/preview").as("query") |
||||
|
cy.get(".spectrum-Button").contains("Send").click({ force: true }) |
||||
|
cy.wait("@query") |
||||
|
// Assert against Status Code, body, & body rows
|
||||
|
cy.get("@query").its("response.statusCode").should("eq", 200) |
||||
|
cy.get("@query").its("response.body").should("not.be.empty") |
||||
|
cy.get("@query").its("response.body.rows").should("not.be.empty") |
||||
|
}) |
||||
|
|
||||
|
it("should run an invalid query within the transformer section", () => { |
||||
|
// Add REST datasource - contains API for breweries
|
||||
|
const datasource = "REST" |
||||
|
const restUrl = "https://api.openbrewerydb.org/breweries" |
||||
|
cy.selectExternalDatasource(datasource) |
||||
|
cy.createRestQuery("GET", restUrl, "/breweries") |
||||
|
cy.get(".spectrum-Tabs-itemLabel").contains("Transformer").click() |
||||
|
// Clear the code box and add "test"
|
||||
|
cy.get(".CodeMirror textarea") |
||||
|
.type(Cypress.platform === "darwin" ? "{cmd}a" : "{ctrl}a", { |
||||
|
force: true, |
||||
|
}) |
||||
|
.type("test") |
||||
|
// Run Query and intercept
|
||||
|
cy.intercept("**/preview").as("queryError") |
||||
|
cy.get(".spectrum-Button").contains("Send").click({ force: true }) |
||||
|
cy.wait("@queryError") |
||||
|
cy.wait(500) |
||||
|
// Assert against message and status for the query error
|
||||
|
cy.get("@queryError") |
||||
|
.its("response.body") |
||||
|
.should("have.property", "message", "test is not defined") |
||||
|
cy.get("@queryError") |
||||
|
.its("response.body") |
||||
|
.should("have.property", "status", 400) |
||||
|
}) |
||||
|
|
||||
|
xit("should run an invalid query via POST request", () => { |
||||
|
// POST request with transformer as null
|
||||
|
cy.request({ |
||||
|
method: "POST", |
||||
|
url: `${Cypress.config().baseUrl}/api/queries/`, |
||||
|
body: { |
||||
|
fields: { headers: {}, queryString: null, path: null }, |
||||
|
parameters: [], |
||||
|
schema: {}, |
||||
|
name: "test", |
||||
|
queryVerb: "read", |
||||
|
transformer: null, |
||||
|
datasourceId: "test", |
||||
|
}, |
||||
|
// Expected 400 error - Transformer must be a string
|
||||
|
failOnStatusCode: false, |
||||
|
}).then(response => { |
||||
|
expect(response.status).to.equal(400) |
||||
|
expect(response.body.message).to.include( |
||||
|
'Invalid body - "transformer" must be a string' |
||||
|
) |
||||
|
}) |
||||
|
}) |
||||
|
|
||||
|
xit("should run an empty query", () => { |
||||
|
// POST request with Transformer as an empty string
|
||||
|
cy.request({ |
||||
|
method: "POST", |
||||
|
url: `${Cypress.config().baseUrl}/api/queries/preview`, |
||||
|
body: { |
||||
|
fields: { headers: {}, queryString: null, path: null }, |
||||
|
queryVerb: "read", |
||||
|
transformer: "", |
||||
|
datasourceId: "test", |
||||
|
}, |
||||
|
// Expected 400 error - Transformer is not allowed to be empty
|
||||
|
failOnStatusCode: false, |
||||
|
}).then(response => { |
||||
|
expect(response.status).to.equal(400) |
||||
|
expect(response.body.message).to.include( |
||||
|
'Invalid body - "transformer" is not allowed to be empty' |
||||
|
) |
||||
|
}) |
||||
|
}) |
||||
|
}) |
||||
|
}) |
||||
@ -1,103 +1,133 @@ |
|||||
context("Rename an App", () => { |
import filterTests from "../support/filterTests" |
||||
beforeEach(() => { |
|
||||
cy.login() |
|
||||
cy.createTestApp() |
|
||||
}) |
|
||||
|
|
||||
it("should rename an unpublished application", () => { |
filterTests(['all'], () => { |
||||
const appRename = "Cypress Renamed" |
context("Rename an App", () => { |
||||
// Rename app, Search for app, Confirm name was changed
|
beforeEach(() => { |
||||
cy.get(".home-logo").click() |
cy.login() |
||||
renameApp(appRename) |
cy.createTestApp() |
||||
cy.searchForApplication(appRename) |
|
||||
cy.get(".appTable").find(".title").should("have.length", 1) |
|
||||
cy.deleteApp(appRename) |
|
||||
}) |
|
||||
|
|
||||
xit("Should rename a published application", () => { |
|
||||
// It is not possible to rename a published application
|
|
||||
const appRename = "Cypress Renamed" |
|
||||
// Publish the app
|
|
||||
cy.get(".toprightnav") |
|
||||
cy.get(".spectrum-Button").contains("Publish").click({force: true}) |
|
||||
cy.get(".spectrum-Dialog-grid") |
|
||||
.within(() => { |
|
||||
// Click publish again within the modal
|
|
||||
cy.get(".spectrum-Button").contains("Publish").click({force: true}) |
|
||||
}) |
}) |
||||
// Rename app, Search for app, Confirm name was changed
|
|
||||
cy.get(".home-logo").click() |
|
||||
renameApp(appRename, true) |
|
||||
cy.searchForApplication(appRename) |
|
||||
cy.get(".appTable").find(".title").should("have.length", 1) |
|
||||
}) |
|
||||
|
|
||||
it("Should try to rename an application to have no name", () => { |
it("should rename an unpublished application", () => { |
||||
cy.get(".home-logo").click() |
const appName = "Cypress Tests" |
||||
renameApp(" ", false, true) |
const appRename = "Cypress Renamed" |
||||
// Close modal and confirm name has not been changed
|
// Rename app, Search for app, Confirm name was changed
|
||||
cy.get(".spectrum-Dialog-grid").contains("Cancel").click() |
cy.get(".home-logo").click() |
||||
cy.searchForApplication("Cypress Tests") |
renameApp(appName, appRename) |
||||
cy.get(".appTable").find(".title").should("have.length", 1) |
cy.reload() |
||||
}) |
cy.wait(1000) |
||||
|
cy.searchForApplication(appRename) |
||||
|
cy.get(".appTable").find(".title").should("have.length", 1) |
||||
|
// Set app name back to Cypress Tests
|
||||
|
cy.reload() |
||||
|
cy.wait(1000) |
||||
|
renameApp(appRename, appName) |
||||
|
}) |
||||
|
|
||||
|
xit("Should rename a published application", () => { |
||||
|
// It is not possible to rename a published application
|
||||
|
const appName = "Cypress Tests" |
||||
|
const appRename = "Cypress Renamed" |
||||
|
// Publish the app
|
||||
|
cy.get(".toprightnav") |
||||
|
cy.get(".spectrum-Button").contains("Publish").click({force: true}) |
||||
|
cy.get(".spectrum-Dialog-grid") |
||||
|
.within(() => { |
||||
|
// Click publish again within the modal
|
||||
|
cy.get(".spectrum-Button").contains("Publish").click({force: true}) |
||||
|
}) |
||||
|
// Rename app, Search for app, Confirm name was changed
|
||||
|
cy.get(".home-logo").click() |
||||
|
renameApp(appName, appRename, true) |
||||
|
cy.searchForApplication(appRename) |
||||
|
cy.get(".appTable").find(".wrapper").should("have.length", 1) |
||||
|
}) |
||||
|
|
||||
|
it("Should try to rename an application to have no name", () => { |
||||
|
const appName = "Cypress Tests" |
||||
|
cy.get(".home-logo").click() |
||||
|
renameApp(appName, " ", false, true) |
||||
|
cy.wait(500) |
||||
|
// Close modal and confirm name has not been changed
|
||||
|
cy.get(".spectrum-Dialog-grid").contains("Cancel").click() |
||||
|
cy.reload() |
||||
|
cy.wait(1000) |
||||
|
cy.searchForApplication(appName) |
||||
|
cy.get(".appTable").find(".title").should("have.length", 1) |
||||
|
|
||||
xit("Should create two applications with the same name", () => { |
|
||||
// It is not possible to have applications with the same name
|
|
||||
const appName = "Cypress Tests" |
|
||||
cy.visit(`localhost:${Cypress.env("PORT")}/builder`) |
|
||||
cy.wait(500) |
|
||||
cy.get(".spectrum-Button").contains("Create app").click({force: true}) |
|
||||
cy.contains(/Start from scratch/).click() |
|
||||
cy.get(".spectrum-Modal") |
|
||||
.within(() => { |
|
||||
cy.get("input").eq(0).type(appName) |
|
||||
cy.get(".spectrum-ButtonGroup").contains("Create app").click({force: true}) |
|
||||
cy.get(".error").should("have.text", "Another app with the same name already exists") |
|
||||
}) |
}) |
||||
}) |
|
||||
|
|
||||
it("should validate application names", () => { |
xit("Should create two applications with the same name", () => { |
||||
// App name must be letters, numbers and spaces only
|
// It is not possible to have applications with the same name
|
||||
// This test checks numbers and special characters specifically
|
const appName = "Cypress Tests" |
||||
const numberName = 12345 |
cy.visit(`${Cypress.config().baseUrl}/builder`) |
||||
const specialCharName = "£$%^" |
cy.wait(500) |
||||
cy.get(".home-logo").click() |
cy.get(".spectrum-Button").contains("Create app").click({force: true}) |
||||
renameApp(numberName) |
cy.contains(/Start from scratch/).click() |
||||
cy.searchForApplication(numberName) |
cy.get(".spectrum-Modal") |
||||
cy.get(".appTable").find(".title").should("have.length", 1) |
.within(() => { |
||||
renameApp(specialCharName) |
cy.get("input").eq(0).type(appName) |
||||
cy.get(".error").should("have.text", "App name must be letters, numbers and spaces only") |
cy.get(".spectrum-ButtonGroup").contains("Create app").click({force: true}) |
||||
}) |
cy.get(".error").should("have.text", "Another app with the same name already exists") |
||||
|
}) |
||||
const renameApp = (appName, published, noName) => { |
}) |
||||
cy.request(`localhost:${Cypress.env("PORT")}/api/applications?status=all`) |
|
||||
.its("body") |
it("should validate application names", () => { |
||||
.then(val => { |
// App name must be letters, numbers and spaces only
|
||||
if (val.length > 0) { |
// This test checks numbers and special characters specifically
|
||||
cy.get(".appTable > :nth-child(5) > :nth-child(2) > .spectrum-Icon").click() |
const appName = "Cypress Tests" |
||||
// Check for when an app is published
|
const numberName = 12345 |
||||
if (published == true){ |
const specialCharName = "£$%^" |
||||
// Should not have Edit as option, will unpublish app
|
cy.get(".home-logo").click() |
||||
cy.should("not.have.value", "Edit") |
renameApp(appName, numberName) |
||||
cy.get(".spectrum-Menu").contains("Unpublish").click() |
cy.reload() |
||||
cy.get(".spectrum-Dialog-grid").contains("Unpublish app").click() |
cy.wait(1000) |
||||
cy.get(".appTable > :nth-child(5) > :nth-child(2) > .spectrum-Icon").click() |
cy.searchForApplication(numberName) |
||||
} |
cy.get(".appTable").find(".title").should("have.length", 1) |
||||
cy.contains("Edit").click() |
cy.reload() |
||||
cy.get(".spectrum-Modal") |
cy.wait(1000) |
||||
.within(() => { |
renameApp(numberName, specialCharName) |
||||
if (noName == true){ |
cy.get(".error").should("have.text", "App name must be letters, numbers and spaces only") |
||||
cy.get("input").clear() |
// Set app name back to Cypress Tests
|
||||
cy.get(".spectrum-Dialog-grid").click() |
cy.reload() |
||||
.contains("App name must be letters, numbers and spaces only") |
cy.wait(1000) |
||||
return cy |
renameApp(numberName, appName) |
||||
|
}) |
||||
|
|
||||
|
const renameApp = (originalName, changedName, published, noName) => { |
||||
|
cy.searchForApplication(originalName) |
||||
|
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`) |
||||
|
.its("body") |
||||
|
.then(val => { |
||||
|
if (val.length > 0) { |
||||
|
cy.get(".appTable") |
||||
|
.within(() => { |
||||
|
cy.get(".spectrum-Icon").eq(1).click() |
||||
|
}) |
||||
|
// Check for when an app is published
|
||||
|
if (published == true){ |
||||
|
// Should not have Edit as option, will unpublish app
|
||||
|
cy.should("not.have.value", "Edit") |
||||
|
cy.get(".spectrum-Menu").contains("Unpublish").click() |
||||
|
cy.get(".spectrum-Dialog-grid").contains("Unpublish app").click() |
||||
|
cy.get(".appTable > :nth-child(5) > :nth-child(2) > .spectrum-Icon").click() |
||||
} |
} |
||||
cy.get("input").clear() |
cy.contains("Edit").click() |
||||
cy.get("input").eq(0).type(appName).should("have.value", appName).blur() |
cy.get(".spectrum-Modal") |
||||
cy.get(".spectrum-ButtonGroup").contains("Save").click({force: true}) |
.within(() => { |
||||
cy.wait(500) |
if (noName == true){ |
||||
}) |
cy.get("input").clear() |
||||
|
cy.get(".spectrum-Dialog-grid").click() |
||||
|
.contains("App name must be letters, numbers and spaces only") |
||||
|
return cy |
||||
|
} |
||||
|
cy.get("input").clear() |
||||
|
cy.get("input").eq(0).type(changedName).should("have.value", changedName).blur() |
||||
|
cy.get(".spectrum-ButtonGroup").contains("Save").click({force: true}) |
||||
|
cy.wait(500) |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
|
||||
} |
} |
||||
}) |
}) |
||||
} |
|
||||
}) |
}) |
||||
|
|||||
@ -0,0 +1,67 @@ |
|||||
|
import filterTests from "../support/filterTests" |
||||
|
|
||||
|
filterTests(['smoke', 'all'], () => { |
||||
|
context("Revert apps", () => { |
||||
|
before(() => { |
||||
|
cy.login() |
||||
|
cy.createTestApp() |
||||
|
}) |
||||
|
|
||||
|
it("should try to revert an unpublished app", () => { |
||||
|
// Click revert icon
|
||||
|
cy.get(".toprightnav").within(() => { |
||||
|
cy.get(".spectrum-Icon").eq(1).click() |
||||
|
}) |
||||
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
|
// Enter app name before revert
|
||||
|
cy.get("input").type("Cypress Tests") |
||||
|
cy.intercept('**/revert').as('revertApp') |
||||
|
// Click Revert
|
||||
|
cy.get(".spectrum-Button").contains("Revert").click({ force: true }) |
||||
|
// Intercept Request after button click & apply assertions
|
||||
|
cy.wait("@revertApp") |
||||
|
cy.get("@revertApp").its('response.body').should('have.property', 'message', "App has not yet been deployed") |
||||
|
cy.get("@revertApp").its('response.body').should('have.property', 'status', 400) |
||||
|
}) |
||||
|
}) |
||||
|
|
||||
|
it("should revert a published app", () => { |
||||
|
// Add initial component - Paragraph
|
||||
|
cy.addComponent("Elements", "Paragraph") |
||||
|
// Publish app
|
||||
|
cy.get(".spectrum-Button").contains("Publish").click({ force: true }) |
||||
|
cy.get(".spectrum-ButtonGroup").within(() => { |
||||
|
cy.get(".spectrum-Button").contains("Publish").click({ force: true }) |
||||
|
}) |
||||
|
// Add second component - Button
|
||||
|
cy.addComponent("Elements", "Button") |
||||
|
// Click Revert
|
||||
|
cy.get(".toprightnav").within(() => { |
||||
|
cy.get(".spectrum-Icon").eq(1).click() |
||||
|
}) |
||||
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
|
// Click Revert
|
||||
|
cy.get(".spectrum-Button").contains("Revert").click({ force: true }) |
||||
|
cy.wait(1000) |
||||
|
}) |
||||
|
// Confirm Paragraph component is still visible
|
||||
|
cy.get(".root").contains("New Paragraph") |
||||
|
// Confirm Button component is not visible
|
||||
|
cy.get(".root").should("not.have.text", "New Button") |
||||
|
cy.wait(500) |
||||
|
}) |
||||
|
|
||||
|
it("should enter incorrect app name when reverting", () => { |
||||
|
// Click Revert
|
||||
|
cy.get(".toprightnav").within(() => { |
||||
|
cy.get(".spectrum-Icon").eq(1).click({ force: true }) |
||||
|
}) |
||||
|
// Enter incorrect app name
|
||||
|
cy.get(".spectrum-Dialog-grid").within(() => { |
||||
|
cy.get("input").type("Cypress Tests") |
||||
|
// Revert button within modal should be disabled
|
||||
|
cy.get(".spectrum-Button").eq(1).should('be.disabled') |
||||
|
}) |
||||
|
}) |
||||
|
}) |
||||
|
}) |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue