Skip to content

Commit

Permalink
feat(support more backends): add ocis compatibility
Browse files Browse the repository at this point in the history
smoke tests now can also use ocis as backend, to do so add OCIS=true env
before running the tests. More info in readme
  • Loading branch information
fschade committed Aug 16, 2021
1 parent 2d779cd commit ad2d279
Show file tree
Hide file tree
Showing 20 changed files with 251 additions and 241 deletions.
7 changes: 0 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ module.exports = {
'@typescript-eslint/no-extra-semi': 'off',
'@typescript-eslint/no-explicit-any': 'off'
}
},
{
// prettier does not support `export * as foo from 'bar'` syntax.
files: ['tests/**/*.ts'],
rules: {
'prettier/prettier': 'off'
}
}
]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"test:acceptance:drone": "cucumber-js --retry 1 --require-module @babel/register --require-module @babel/polyfill --require tests/acceptance/setup.js --require tests/acceptance/stepDefinitions --format @cucumber/pretty-formatter",
"test:acceptance:oc10": "cucumber-js --require-module @babel/register --require-module @babel/polyfill --require tests/acceptance/setup.js --require tests/acceptance/stepDefinitions --format @cucumber/pretty-formatter -t \"${TEST_TAGS:-not @skip and not @skipOnOC10}\"",
"test:acceptance:ocis": "NODE_TLS_REJECT_UNAUTHORIZED=0 RUN_ON_OCIS=true cucumber-js --require-module @babel/register --require-module @babel/polyfill --require tests/acceptance/setup.js --require tests/acceptance/stepDefinitions --format @cucumber/pretty-formatter -t \"${TEST_TAGS:-not @skip and not @skipOnOCIS and not @notToImplementOnOCIS}\"",
"test:smoke:experimental": "cucumber-js --profile=smoke",
"test:smoke:experimental": "NODE_TLS_REJECT_UNAUTHORIZED=0 cucumber-js --profile=smoke",
"test:unit": "jest --coverage --config ./tests/unit/config/jest.config.js",
"test:integration": "jest --config ./tests/integration/config/jest.config.js"
},
Expand Down
30 changes: 19 additions & 11 deletions tests/smoke/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Use with care, the smoke-test package introduces many new concepts and is still
Before we release a new web version, we always take care that nothing breaks and the core features are working as
expected. Till now this was a manual process which consumed a lot of time and effort.

Manual steps are error-prone by nature, on the one hand they can bring up unknown issues, but on the other it's easy
to forget some test steps. The main problem we faced, was that it's never a good thing to manually test your own code.
Manual steps are error-prone by nature, on the one hand they can bring up unknown issues, but on the other it's easy to
forget some test steps. The main problem we faced, was that it's never a good thing to manually test your own code.

To get closer to the point where we are able to release faster and more often, we started to develop the WEB-Smoke-Tests
package.
Expand All @@ -22,7 +22,7 @@ development.
The WEB-Smoke-Tests are much smaller and are still in an early phase. Many things are still not there compared to the
mature tests/acceptance package.

** The main reasons why we decided to split out the smoke tests are: **
**The main reasons why we decided to split out the smoke tests are:**

* we wanted to test on a persona // use-case level
* testing should be easy, fast and reliable
Expand All @@ -48,6 +48,9 @@ To run the tests with below options, you have to set them as environment variabl
$ OPTION_1=foo OPTION_2=bar yarn test:smoke:experimental ...
```

* **OCIS=boolean**
* defines if the tests should use ocis as backend
* **default**: false
* **SLOW_MO=time-in-ms**
* run the tests with a timeout between every interaction
* **default**: 0
Expand All @@ -63,28 +66,33 @@ $ OPTION_1=foo OPTION_2=bar yarn test:smoke:experimental ...

This package is still in an early stage, design could change over time.

### Features `./tests/smoke/features`
### Features

Gherkin features a placed in there, nothing special, it follows
`./tests/smoke/features`
Gherkin features are placed in there, it follows
the [gherkin features spec](https://cucumber.io/docs/gherkin/reference/)

### Steps `./tests/smoke/steps`
### Steps

`./tests/smoke/steps`
Cucumber [step definitions](https://cucumber.io/docs/cucumber/step-definitions/) grouped by module // app.

### Setup `./tests/smoke/setup`
### Setup

All setup related stuff like config, cucumber or playwright preparation steps.
`./tests/smoke/setup`
Setup related stuff like config, cucumber or playwright preparation steps.

### Pages `./tests/smoke/pages`
### Pages

`./tests/smoke/pages`
With the option in mind that the smoke-test package could grow, we decided to already group interactions inside page
objects. To get more background what page objects are, you can read
the [introduction here](https://playwright.dev/docs/pom/)

### Helper `./tests/smoke/helpers`
### Helper

All else that is needed to interact with the browser, api or other things. If you not sure where to place a certain
`./tests/smoke/helpers`
All else that is needed to interact with the browser, api or other parties. If you not sure where to place a certain
functionality the helpers folder is a good fallback.

## Packages we use
Expand Down
2 changes: 1 addition & 1 deletion tests/smoke/helpers/api/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const request = async ({
body,
user
}: {
method: 'POST' | 'DELETE' | 'PUT'
method: 'POST' | 'DELETE' | 'PUT' | 'GET'
path: string
body?: BodyInit
user?: User
Expand Down
1 change: 1 addition & 0 deletions tests/smoke/helpers/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/* eslint-disable */
export * as http from './http'
export * as user from './user'
19 changes: 18 additions & 1 deletion tests/smoke/helpers/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ export const createUser = async ({ user }: { user: User }): Promise<void> => {
const promChain = []
{
const body = new URLSearchParams()
body.append('username', user.id)
body.append('email', user.email)
body.append('userid', user.id)
body.append('password', user.password)
body.append('displayname', user.displayName)

const response = await request({
method: 'POST',
Expand Down Expand Up @@ -40,7 +43,11 @@ export const createUser = async ({ user }: { user: User }): Promise<void> => {
)
})

await Promise.all(promChain)
// initUser is there because ocis needs to have at least 1 request to the created user to perform deleteRequests later
// twice because it works, known issue and needs to be cleaned up once the ocis users service is moved to reva
for (const prom of [initUser({ user }), ...promChain, initUser({ user })]) {
await prom
}
}

export const deleteUser = async ({ user }: { user: User }): Promise<User> => {
Expand All @@ -52,3 +59,13 @@ export const deleteUser = async ({ user }: { user: User }): Promise<User> => {

return user
}

export const initUser = async ({ user }: { user: User }): Promise<User> => {
await request({
method: 'GET',
path: join('cloud', 'users', user.id),
user: Users.get({ id: user.id })
})

return user
}
3 changes: 2 additions & 1 deletion tests/smoke/helpers/cta/files/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './misc'
/* eslint-disable */
export * as sidebar from './sidebar'
export * from './misc'
1 change: 1 addition & 0 deletions tests/smoke/helpers/cta/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/* eslint-disable */
export * as files from './files'
2 changes: 1 addition & 1 deletion tests/smoke/helpers/fixtures/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'path'
import { config } from '../../setup'
import { File } from '../../types'

export abstract class Files {
export class Files {
static get({ name }: { name: string }): File {
const relPath = path.join(config.assets, name)

Expand Down
52 changes: 6 additions & 46 deletions tests/smoke/helpers/fixtures/users.ts
Original file line number Diff line number Diff line change
@@ -1,75 +1,35 @@
import { User } from '../../types'
const passwords = {
admin: process.env.ADMIN_PASSWORD || 'admin',
regular: process.env.REGULAR_USER_PASSWORD || '123456',
alt1: process.env.ALT1_USER_PASSWORD || '1234',
alt2: process.env.ALT2_USER_PASSWORD || 'AaBb2Cc3Dd4',
alt3: process.env.ALT3_USER_PASSWORD || 'aVeryLongPassword42TheMeaningOfLife',
alt4: process.env.ALT4_USER_PASSWORD || 'ThisIsThe4thAlternatePwd',
alt11: process.env.ALT11_USER_PASSWORD || 'E-leven'
}

const users: User[] = [
{
id: 'admin',
displayName: process.env.ADMIN_USERNAME || 'admin',
password: passwords.admin
},
{
id: 'regularuser',
displayName: 'Regular User',
password: passwords.regular,
email: '[email protected]'
},
{
id: 'user0',
displayName: 'Regular User',
password: passwords.regular,
email: '[email protected]'
password: 'admin'
},
{
id: 'Alice',
displayName: 'Alice Hansen',
password: passwords.alt1,
password: '1234',
email: '[email protected]'
},
{
id: 'Brian',
displayName: 'Brian Murphy',
password: passwords.alt2,
password: '1234',
email: '[email protected]'
},
{
id: 'Carol',
displayName: 'Carol King',
password: passwords.alt3,
password: '1234',
email: '[email protected]'
},
{
id: 'David',
displayName: 'David Lopez',
password: passwords.alt4,
password: '1234',
email: '[email protected]'
},
{
id: 'user11',
displayName: 'User Eleven',
password: passwords.alt11,
email: '[email protected]'
},
{
id: 'usergrp',
displayName: 'User Grp',
password: passwords.regular,
email: '[email protected]'
},
{
id: 'sharee1',
displayName: 'Sharee One',
password: passwords.regular,
email: '[email protected]'
},
// These users are available by default only in ocis backend when not using ldap
{
id: 'Einstein',
displayName: 'Albert Einstein',
Expand All @@ -96,7 +56,7 @@ const users: User[] = [
}
]

export abstract class Users {
export class Users {
static get({ id }: { id: string }): User {
const user = users.find(user => user.id === id)

Expand Down
1 change: 1 addition & 0 deletions tests/smoke/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
export * as apiHelper from './api'
export * as ctaHelper from './cta'
export * as fixtures from './fixtures'
15 changes: 0 additions & 15 deletions tests/smoke/pages/autorize.ts

This file was deleted.

Loading

0 comments on commit ad2d279

Please sign in to comment.