Skip to content

Commit

Permalink
Merge branch 'release/2020-08'
Browse files Browse the repository at this point in the history
  • Loading branch information
taki9 committed Aug 6, 2020
2 parents 96d5dd9 + 14d3210 commit 6888e44
Show file tree
Hide file tree
Showing 183 changed files with 5,631 additions and 4,329 deletions.
8 changes: 7 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,20 @@ module.exports = {
'no-unused-vars': 'off',
'no-console': 'off',
'react/prop-types': 0,
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-unused-vars': 'off', // Use Typescript own check for this
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-extra-non-null-assertion': 'off',
'@typescript-eslint/no-extra-semi': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'@typescript-eslint/array-type': ['error', { default: 'array-simple', readonly: 'array-simple' }],
'@typescript-eslint/no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }],
'@typescript-eslint/prefer-as-const': 'off',
'no-unused-expressions': 'off',
'prettier/prettier': 'error',
'require-jsdoc': 1,
Expand Down
53 changes: 53 additions & 0 deletions .github/ISSUE_TEMPLATE/e2e_testcases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
name: 🧪E2E test cases
about: Add E2E test cases
title: '[E2E test]'
labels: test, e2e-test
assignees: ''
---

# 🧪E2E test cases

<!--- Provide a scope for the test cases -->

# Test case 1

## 😎 Role

<!-- Add the role of the user on whose behalf the following tests should be running -->
<!-- [e.g.: admin (default), superadmin, developer, editor ] -->

## 🧫 Purpose of the test

<!--- Summarize the test case -->

## 🐾 Steps

<!--- Add steps of the test case -->
<!-- [e.g.:
1. Login with devdog
2. Open the usermenu
3. ...
] -->

# Test case 2

## 😎 Role

<!-- Add the role of the user on whose behalf the following tests should be running -->
<!-- [e.g.: admin (default), superadmin, developer, editor ] -->

## 🧫 Purpose of the test

<!--- Summarize the test case -->

## 🐾 Steps

<!--- Add steps of the test case -->
<!-- [e.g.:
1. Login with devdog
2. Open the usermenu
3. ...
] -->

...
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ jobs:
RELATIVE_CI_KEY: ${{ secrets.RELATIVE_CI_KEY }}

- name: test
run: yarn test --coverage
run: NODE_OPTIONS='--max-old-space-size=4096' yarn test --coverage --logHeapUsage

- uses: codecov/codecov-action@v1
13 changes: 13 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: AdminUI end-to-end tests
on: [workflow_dispatch]
jobs:
cypress-run:
runs-on: ubuntu-16.04
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Cypress run
uses: cypress-io/github-action@v2
with:
command: yarn snapp cypress:all --env secret_superadmin=${{ secrets.AUTH_SECRET_SUPERADMIN }},secret_admin=${{ secrets.AUTH_SECRET_ADMIN }},secret_developer=${{ secrets.AUTH_SECRET_DEVELOPER }},secret_editor=${{ secrets.AUTH_SECRET_EDITOR }}
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,3 @@ jspm_packages/

# Misc
.DS_Store

# Cypress realted videos
cypress/videos
4 changes: 4 additions & 0 deletions apps/sensenet/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ dist
temp
build
stats.json

# Cypress related videos and screenshots
cypress/videos
cypress/screenshots
31 changes: 31 additions & 0 deletions apps/sensenet/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"baseUrl": "https://admin.test.sensenet.com",
"chromeWebSecurity": false,
"defaultCommandTimeout": 10000,
"env": {
"repoUrl": "https://e2e-service.test.sensenet.com",
"identityServer": "https://is.test.sensenet.com",
"users": {
"superadmin": {
"clientId": "client",
"clientSecret": "",
"id": "/Root/IMS/BuiltIn/Portal('Admin')"
},
"admin": {
"clientId": "kitty",
"clientSecret": "",
"id": "/Root/IMS/Public('businesscat')"
},
"developer": {
"clientId": "devdog",
"clientSecret": "",
"id": "/Root/IMS/Public('devdog')"
},
"editor": {
"clientId": "eddie",
"clientSecret": "",
"id": "/Root/IMS/Public('editormanatee')"
}
}
}
}
Empty file.
70 changes: 70 additions & 0 deletions apps/sensenet/cypress/integration/search/search.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { PATHS } from '../../../src/application-paths'
import { pathWithQueryParams } from '../../../src/services/query-string-builder'

describe('Search', () => {
it('should search available', () => {
cy.login()
cy.visit(pathWithQueryParams({ path: '/', newParams: { repoUrl: Cypress.env('repoUrl') } }))
.get('[data-test="search-button"]')
.click()
.get('[data-test="command-box"] input')
.should('be.visible')
})

context('suggestion list', () => {
const term = 'busi'
beforeEach(() => {
cy.login()
cy.visit(pathWithQueryParams({ path: '/', newParams: { repoUrl: Cypress.env('repoUrl') } }))
.get('[data-test="search-button"]')
.click()
.get('[data-test="command-box"] input')
.type(term, { delay: 200 })
.get('[data-test="search-suggestion-list"] ul')
.children()
.as('search')
})

it('should have 6 suggestion items', () => {
cy.get('@search').should('have.length', 6)
})

it('first item should be a link to the result page', () => {
cy.get('@search')
.first()
.click()
.location()
.should((loc) => {
expect(loc.pathname).to.eq(PATHS.search.appPath)
expect(loc.search).to.eq(`?term=${term}`)
})
})

it('first item should contain the search term', () => {
cy.get('@search').first().contains(term)
})

it('second item is the Business Cat user', () => {
cy.get('@search').eq(1).contains('Business Cat')
})

it('second item should navigate to edit', () => {
cy.get('@search')
.eq(1)
.click()
.location()
.should((loc) => {
expect(loc.pathname).to.contain('edit')
})
})

it('second item should edit Business Cat', () => {
cy.get('@search')
.eq(1)
.click()
.get('#FullName')
.invoke('val')
.then((fullname) => expect(fullname).to.eq('Business Cat'))
})
})
})
24 changes: 24 additions & 0 deletions apps/sensenet/cypress/integration/shared/user.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { pathWithQueryParams } from '../../../src/services/query-string-builder'

describe('User handling', () => {
before(() => cy.clearCookies({ domain: null } as any))

it('should login with test user', () => {
cy.visit('/')
cy.get('input[name="repository"]').type(`${Cypress.env('repoUrl')}{enter}`)

cy.get('[data-test="demo-button"]').click()
})

it('should logout', () => {
cy.login()
cy.visit(pathWithQueryParams({ path: '/', newParams: { repoUrl: Cypress.env('repoUrl') } }))
.get('.MuiToolbar-root .MuiAvatar-root+.MuiButtonBase-root.MuiIconButton-root')
.click()
.get('.MuiList-root li[role="menuitem"]')
.contains('Log out')
.click()

cy.get('.MuiDialog-container .MuiDialogActions-root .MuiButton-containedPrimary').click()
})
})
File renamed without changes.
55 changes: 55 additions & 0 deletions apps/sensenet/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

Cypress.Commands.add('login', (userType = 'admin') => {
const user = Cypress.env('users')[userType]

const configuration = {
client_id: user.clientId,
client_secret: Cypress.env(`secret_${userType}`) || user.clientSecret,
grant_type: 'client_credentials',
scope: encodeURIComponent('sensenet'),
}

const requestBody = Object.keys(configuration).reduce((acc, current, idx) => {
return `${acc}${current}=${configuration[current]}${idx === Object.keys(configuration).length - 1 ? '' : '&'}`
}, '')

cy.request({
url: `${Cypress.env('identityServer')}/connect/token`,
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: requestBody,
}).then((resp) => {
const oidcUser = resp.body

oidcUser.profile = {
sub: user.id,
}

window.sessionStorage.setItem(`oidc.user:${Cypress.env('identityServer')}:spa`, JSON.stringify(oidcUser))
})
})
11 changes: 11 additions & 0 deletions apps/sensenet/cypress/support/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// <reference types="cypress" />
/// <reference types="cypress-xpath/src" />

declare namespace Cypress {
interface Chainable {
/**
* Custom command to log in programmatically.
*/
login(): void
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'
import 'cypress-xpath'

// Alternatively you can use CommonJS syntax:
// require('./commands')
import './commands'
10 changes: 10 additions & 0 deletions apps/sensenet/cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"strict": true,
"baseUrl": "../node_modules",
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress"]
},
"include": ["**/*.ts"]
}
Loading

0 comments on commit 6888e44

Please sign in to comment.