Skip to content
This repository has been archived by the owner on Nov 23, 2022. It is now read-only.

started work on E2E Tests #298

Merged
merged 32 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d156603
added first e2e tests
DerMolly Jun 27, 2020
365aa44
finished Intro Links e2e tests
DerMolly Jun 27, 2020
af0cf2b
added e2e tests for intro and history functionality
DerMolly Jun 28, 2020
2c40dd5
added github actions run
DerMolly Jun 28, 2020
2cd856c
moved e2e test in own workflow
DerMolly Jun 28, 2020
cc280d5
workd on e2e workflow
DerMolly Jun 28, 2020
5e43685
server gets run and then tested
DerMolly Jun 28, 2020
67b6b77
everything is now in typescript
DerMolly Jun 29, 2020
68f22fe
changed e2e workflow
DerMolly Jun 29, 2020
206c94c
changed cache name
DerMolly Jun 29, 2020
6d56b46
added sudo to apt-get
DerMolly Jun 29, 2020
6321eca
fixed name of e2e:chromium
DerMolly Jun 29, 2020
b38ff4a
changed package.json scripts
DerMolly Jun 29, 2020
110aec0
removed delay from config call
DerMolly Jun 30, 2020
393d0c8
updated README
DerMolly Jun 30, 2020
7fec204
updated README
DerMolly Jun 30, 2020
1b45f83
try using webpack for CI runs
DerMolly Jun 30, 2020
e326c0c
removed explicit webpack dependency
DerMolly Jun 30, 2020
4a85605
changed browser chrome
DerMolly Jun 30, 2020
610efa8
removed cypress folder from tsconfig.json
DerMolly Jun 30, 2020
febeef6
parallelize chrome and firefox e2e test
DerMolly Jun 30, 2020
6aa805e
changed names of paralleled chrome and firefox e2e runs
DerMolly Jun 30, 2020
edba048
try to fix firefox
DerMolly Jun 30, 2020
3f12ce1
removed unit testing section from readme
DerMolly Jul 1, 2020
c82a2de
reworded some test descriptions
DerMolly Jul 4, 2020
8f34d88
used more newlines in the tests
DerMolly Jul 4, 2020
bcdd3ef
removed unnecessary id's
DerMolly Jul 4, 2020
ecd8609
e2e workflow now uses matrix strategy
DerMolly Jul 4, 2020
3b5c27a
added branding to config mock call
DerMolly Jul 4, 2020
5aafe0e
added cypress badge to README
DerMolly Jul 4, 2020
8c4c0f2
added suggestion from review
DerMolly Jul 7, 2020
16faf49
fixed language e2e test, not everyone's system is in english...
DerMolly Jul 8, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Expand Up @@ -2,9 +2,9 @@ name: lint and build

on:
push:
branches: [master, dev]
branches: [master]
pull_request:
branches: [master, dev]
branches: [master]

jobs:
build:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/e2e.yml
@@ -0,0 +1,34 @@
name: e2e

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like both jobs are the same, but the browser. How about the matrix strategy, like we used in the build job?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I use the matrix parameters just in with statements?

Or should this also work?

end2end:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        browser: ['e2e:chrome', 'e2e:firefox']
    name: e2e Test Chrome
    steps:
      ...
      - name: Run cypress tests
        run: yarn ${{ matrix.browser }}

Copy link
Member

@mrdrogdrog mrdrogdrog Jul 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use it everywhere, where you want to insert a value. (please remember changing the job names, too)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

end2end:
runs-on: ubuntu-latest
strategy:
matrix:
browser: ['e2e:chrome', 'e2e:firefox']
name: ${{ matrix.browser }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Cache node_modules
uses: actions/cache@v1.1.0
with:
path: node_modules
key: node_modules
- name: Cache ~/.cache
uses: actions/cache@v1.1.0
with:
path: ~/.cache
key: cache
- name: install cypress dependencies
run: sudo apt-get install libgtk2.0-0 libgtk-3-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
- name: Install dependencies
run: yarn install
- name: Run e2e in chrome
run: yarn ${{ matrix.browser }}
13 changes: 13 additions & 0 deletions README.md
@@ -1,5 +1,7 @@
# CodiMD - React Client

![e2e](https://github.com/codimd/react-client/workflows/e2e/badge.svg)

This is the new, improved and better looking frontend for CodiMD 2.0.
Our goal is to recreate the current frontend in react and to improve it.

Expand All @@ -18,6 +20,17 @@ This should run the app in the development mode and open [http://localhost:3000]
The page will reload if you make edits.
You will also see any lint errors in the console.

### Tests

#### End2End

We use [cypress](https://cypress.io) for e2e tests.

1. Run the frontend with `yarn start`
2. RUn `yarn cy:open` to open the cypress test loader
3. Choose your browser and test
4. Let the tests run

## Production mode

1. Clone this repo (e.g. `git clone https://github.com/codimd/react-client.git codimd-react-client`)
Expand Down
8 changes: 8 additions & 0 deletions cypress.json
@@ -0,0 +1,8 @@
{
"baseUrl": "http://localhost:3000/",
"experimentalFetchPolyfill": true,
"firefoxGcInterval": {
"runMode": null,
"openMode": null
DerMolly marked this conversation as resolved.
Show resolved Hide resolved
}
}
23 changes: 23 additions & 0 deletions cypress/.eslintrc.json
@@ -0,0 +1,23 @@
{
"parserOptions": {
"tsconfigRootDir": "",
"project": [
"./cypress/tsconfig.json"
]
},
"plugins": [
"cypress",
"chai-friendly"
],
"extends": [
"plugin:cypress/recommended"
],
"rules": {
"@typescript-eslint/no-unused-expressions": 0,
"no-unused-expressions": 0,
"chai-friendly/no-unused-expressions": 2
},
"env": {
"cypress/globals": true
}
}
30 changes: 30 additions & 0 deletions cypress/fixtures/languages.ts
@@ -0,0 +1,30 @@
export const languages: string[] = [
'English',
'简体中文',
'繁體中文',
'Français',
'Deutsch',
'日本語',
'Español',
'Català',
'Ελληνικά',
'Português',
'Italiano',
'Türkçe',
'Русский',
'Nederlands',
'Hrvatski',
'Polski',
'Українська',
'हिन्दी',
'Svenska',
'Esperanto',
'Dansk',
'한국어',
'Bahasa Indonesia',
'Cрпски',
'Tiếng Việt',
'العربية',
'Česky',
'Slovensky'
]
26 changes: 26 additions & 0 deletions cypress/integration/banner.spec.ts
@@ -0,0 +1,26 @@
import { banner } from '../support/config'

describe('Banner', () => {
beforeEach(() => {
cy.visit('/')
expect(localStorage.getItem('bannerTimeStamp')).to.be.null
})

it('shows the correct alert banner text', () => {
cy.get('.alert-primary.show')
.contains(banner.text)
})

it('can be dismissed', () => {
cy.get('.alert-primary.show')
.contains(banner.text)
cy.get('.alert-primary.show')
.find('.fa-times')
.click()
.then(() => {
expect(localStorage.getItem('bannerTimeStamp')).to.equal(banner.timestamp)
})
cy.get('.alert-primary.show')
.should('not.exist')
})
})
35 changes: 35 additions & 0 deletions cypress/integration/history.spec.ts
@@ -0,0 +1,35 @@
describe('History', () => {
beforeEach(() => {
cy.visit('/history')
})

describe('History Mode', () => {
it('Cards', () => {
cy.get('div.card')
})

it('Table', () => {
cy.get('i.fa-table')
.click()
cy.get('table.history-table')
})
})

describe('Pinning', () => {
it('Cards', () => {
cy.get('.fa-thumb-tack')
.first()
.click()
cy.get('.modal-dialog')
.should('be.visible')
})

it('Table', () => {
cy.get('.fa-thumb-tack')
.first()
.click()
cy.get('.modal-dialog')
.should('be.visible')
})
})
})
58 changes: 58 additions & 0 deletions cypress/integration/intro.spec.ts
@@ -0,0 +1,58 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
describe('Intro', () => {
beforeEach(() => {
cy.visit('/')
})

describe('Cover Button are hidden when logged in', () => {
it('Sign in Cover Button', () => {
cy.get('.cover-button.btn-success')
.should('not.exist')
})

it('Features Cover Button', () => {
cy.get('.cover-button.btn-primary')
.should('not.exist')
})
})

describe('Cover Button are shown when logged out', () => {
beforeEach(() => {
cy.logout()
})

it('Sign in Cover Button', () => {
cy.get('.cover-button.btn-success')
.should('exist')
})

it('Features Cover Button', () => {
cy.get('.cover-button.btn-primary')
.should('exist')
})
})

describe('Version', () => {
it('can be opened', () => {
cy.get('#versionModal')
.should('not.be.visible')
cy.get('#version')
.click()
cy.get('#versionModal')
.should('be.visible')
})

it('can be closed', () => {
cy.get('#versionModal')
.should('not.be.visible')
cy.get('#version')
.click()
cy.get('#versionModal')
.should('be.visible')
cy.get('body')
.click()
cy.get('#versionModal')
.should('not.be.visible')
})
})
})
30 changes: 30 additions & 0 deletions cypress/integration/language.spec.ts
@@ -0,0 +1,30 @@
import { languages } from '../fixtures/languages'

describe('Languages', () => {
beforeEach(() => {
cy.visit('/')
})

it('all languages are available', () => {
cy.get('option')
.as('languages')
cy.get('@languages')
.should('have.length', 28)
languages.forEach(language => {
cy.get('@languages').contains(language)
})
})

it('language changes affect the UI', () => {
cy.get('select')
.select('English')
cy.get('.d-inline-flex.btn-primary')
.find('span')
.contains('New note')
cy.get('select')
.select('Deutsch')
cy.get('.d-inline-flex.btn-primary')
.find('span')
.contains('Neue Notiz')
})
})