Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d812f7e

Browse files
committedJul 31, 2020
test: add example app
1 parent 4140e88 commit d812f7e

File tree

13 files changed

+4497
-2
lines changed

13 files changed

+4497
-2
lines changed
 

‎.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,7 @@ dist
157157
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
158158

159159
types
160-
build
160+
build
161+
.adminbro
162+
163+
example-app/cypress/videos

‎.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
.github
33
coommitlint.config.js
4+
example-app

‎example-app/cypress.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"baseUrl": "http://localhost:3000/admin"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "hello@cypress.io",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
context('Dashboard Page', () => {
2+
beforeEach(() => {
3+
cy.visit('/')
4+
})
5+
6+
it('shows overridden sidebar footer', () => {
7+
cy.contains('Welcome on Board')
8+
})
9+
})

‎example-app/cypress/plugins/index.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/// <reference types="cypress" />
2+
// ***********************************************************
3+
// This example plugins/index.js can be used to load plugins
4+
//
5+
// You can change the location of this file or turn off loading
6+
// the plugins file with the 'pluginsFile' configuration option.
7+
//
8+
// You can read more here:
9+
// https://on.cypress.io/plugins-guide
10+
// ***********************************************************
11+
12+
// This function is called when a project is opened or re-opened (e.g. due to
13+
// the project's config changing)
14+
15+
/**
16+
* @type {Cypress.PluginConfig}
17+
*/
18+
module.exports = (on, config) => {
19+
// `on` is used to hook into various events Cypress emits
20+
// `config` is the resolved Cypress config
21+
}
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// ***********************************************
2+
// This example commands.js shows you how to
3+
// create various custom commands and overwrite
4+
// existing commands.
5+
//
6+
// For more comprehensive examples of custom
7+
// commands please read more here:
8+
// https://on.cypress.io/custom-commands
9+
// ***********************************************
10+
//
11+
//
12+
// -- This is a parent command --
13+
// Cypress.Commands.add("login", (email, password) => { ... })
14+
//
15+
//
16+
// -- This is a child command --
17+
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
18+
//
19+
//
20+
// -- This is a dual command --
21+
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
22+
//
23+
//
24+
// -- This will overwrite an existing command --
25+
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

‎example-app/cypress/support/index.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ***********************************************************
2+
// This example support/index.js is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands'
18+
19+
// Alternatively you can use CommonJS syntax:
20+
// require('./commands')

‎example-app/package.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "example-app",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"license": "MIT",
6+
"scripts": {
7+
"start": "ts-node src/index.ts",
8+
"cypress:open": "cypress open",
9+
"cypress:run": "cypress run"
10+
},
11+
"devDependencies": {
12+
"@types/express": "^4.17.7",
13+
"ts-node": "^8.10.2",
14+
"cypress": "^4.11.0",
15+
"typescript": "^3.9.7"
16+
},
17+
"dependencies": {
18+
"@admin-bro/core": "^3.0.0-beta.2",
19+
"@admin-bro/express": "^3.0.0-beta.1",
20+
"express": "^4.17.1",
21+
"express-formidable": "^1.2.0",
22+
"express-session": "^1.17.1"
23+
}
24+
}

‎example-app/src/index.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import express from 'express'
2+
import AdminBro from '@admin-bro/core'
3+
import { buildRouter } from '@admin-bro/express'
4+
5+
const PORT = 3000
6+
7+
const run = async () => {
8+
const app = express()
9+
const admin = new AdminBro()
10+
const router = buildRouter(admin)
11+
12+
app.use(admin.options.rootPath, router)
13+
14+
app.listen(PORT, () => {
15+
// eslint-disable-next-line no-console
16+
console.log(`Example app listening at http://localhost:${PORT}`)
17+
})
18+
}
19+
20+
run()

‎example-app/tsconfig.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"outDir": "./build",
4+
"target": "es2017",
5+
"esModuleInterop": true,
6+
"jsx": "react",
7+
"strictNullChecks": true,
8+
"strictPropertyInitialization": true,
9+
"strictFunctionTypes": true,
10+
"strictBindCallApply": true,
11+
"noImplicitThis": true,
12+
"moduleResolution": "node",
13+
"module": "commonjs",
14+
"types": ["cypress"]
15+
},
16+
"include": [
17+
"./src/**/*",
18+
"./cypress/**/*"
19+
],
20+
}

0 commit comments

Comments
 (0)
Please sign in to comment.