Skip to content

Commit 4caa95f

Browse files
bors[bot]meili-botbidoubiwa
authored
Merge #57
57: e2e tests in CI r=bidoubiwa a=bidoubiwa closes: #12 closes #15 Integrations tests are not added for now as the e2e tests cover all routes : #64 Co-authored-by: meili-bot <[email protected]> Co-authored-by: Charlotte Vermandel <[email protected]> Co-authored-by: cvermand <[email protected]>
2 parents c822f95 + f851c47 commit 4caa95f

File tree

17 files changed

+1503
-235
lines changed

17 files changed

+1503
-235
lines changed

.eslintrc.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ module.exports = {
1010
},
1111
extends: [
1212
'plugin:react/recommended',
13-
'standard'
13+
'standard',
14+
'plugin:cypress/recommended'
1415
],
1516
parserOptions: {
1617
ecmaFeatures: {
@@ -29,6 +30,8 @@ module.exports = {
2930
},
3031
rules: {
3132
'react/jsx-indent': 'error',
32-
'react/jsx-indent-props': [2, 2]
33+
'react/jsx-indent-props': [2, 2],
34+
'cypress/no-unnecessary-waiting': 'off',
35+
'react/prop-types': 'off'
3336
}
3437
}

.github/workflows/tests.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,41 @@ on:
1010
- main
1111

1212
jobs:
13+
cypress-run:
14+
runs-on: ubuntu-latest
15+
container: cypress/browsers:node12.18.3-chrome87-ff82
16+
services:
17+
meilisearch:
18+
image: getmeili/meilisearch:latest
19+
env:
20+
MEILI_MASTER_KEY: 'masterKey'
21+
MEILI_NO_ANALYTICS: 'true'
22+
ports:
23+
- '7700:7700'
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v2
27+
- name: Setup node
28+
uses: actions/setup-node@v1
29+
- name: Install dependencies
30+
run: yarn --dev && yarn --cwd ./playground
31+
- name: Cypress run
32+
uses: cypress-io/github-action@v2
33+
with:
34+
build: yarn playground:build
35+
start: yarn playground:start
36+
env: env=ci
37+
- uses: actions/upload-artifact@v1
38+
if: failure()
39+
with:
40+
name: cypress-screenshots
41+
path: cypress/screenshots
42+
- uses: actions/upload-artifact@v1
43+
if: failure()
44+
with:
45+
name: cypress-videos
46+
path: cypress/videos
47+
1348
playground_build_tests:
1449
runs-on: ubuntu-latest
1550
strategy:
@@ -22,6 +57,8 @@ jobs:
2257
uses: actions/setup-node@v1
2358
with:
2459
node-version: ${{ matrix.node }}
60+
- name: Install dependencies
61+
run: yarn --dev && yarn --cwd ./playground
2562
- name: Build Strapi playground
2663
run: yarn playground:build
2764

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,13 @@ exports
123123
*.cache
124124
build
125125
.strapi-updater.json
126+
127+
############################
128+
# CYPRESS
129+
############################
130+
cypress/screenshots
131+
cypress/videos
132+
cypress/support
133+
cypress/plugins
134+
cypress/fixtures
135+

CONTRIBUTING.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,19 @@ docker pull getmeili/meilisearch:latest # Fetch the latest version of MeiliSearc
4545
docker run -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey --no-analytics=true
4646

4747
# Tests the project
48-
yarn develop
48+
yarn test
49+
# Tests the project in watch/open mode
50+
yarn test:watch
4951
# Linter
50-
yarn lint
52+
yarn style
5153
# Linter with fixing
52-
yarn lint:fix
54+
yarn style:fix
55+
```
56+
57+
If you already have a running Strapi app in local, testing is possible with the following command:
58+
59+
```bash
60+
yarn cy:open
5361
```
5462

5563
### Playgrounds

admin/src/components/Collections.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ const headers = [
2121
}
2222
]
2323

24-
const Collections = () => {
24+
const Collections = ({ updateCredentials }) => {
2525
const [collectionsList, setCollectionsList] = useState([])
26-
const [infoUpdated, setInfoUpdated] = useState(false)
26+
const [updatedCollections, setUpdatedCollections] = useState(false)
2727

2828
const updateStatus = async ({ indexUid, updateId }) => {
2929
const response = await request(`/${pluginId}/indexes/${indexUid}/update/${updateId}`, {
@@ -32,7 +32,7 @@ const Collections = () => {
3232
const { error } = response
3333
if (error) errorNotifications(error)
3434
else successNotification({ message: `${indexUid} has all its documents indexed` })
35-
setInfoUpdated(false)
35+
setUpdatedCollections(false)
3636
}
3737

3838
const addCollectionToMeiliSearch = async ({ name: indexUid }) => {
@@ -65,7 +65,7 @@ const Collections = () => {
6565
const addOrRemoveCollection = async (row) => {
6666
if (row._isChecked) await deleteIndex(row)
6767
else await addCollectionToMeiliSearch(row)
68-
setInfoUpdated(false)
68+
setUpdatedCollections(false)
6969
}
7070

7171
const fetchCollections = async () => {
@@ -81,20 +81,23 @@ const Collections = () => {
8181
}
8282
))
8383
setCollectionsList(colStatus)
84-
setInfoUpdated(true)
84+
setUpdatedCollections(true)
8585
}
8686
}
8787

8888
useEffect(() => {
89-
if (!infoUpdated) {
90-
fetchCollections()
91-
}
92-
}, [infoUpdated])
89+
setUpdatedCollections(false)
90+
}, [updateCredentials])
91+
92+
useEffect(() => {
93+
if (!updatedCollections) fetchCollections()
94+
}, [updatedCollections, updateCredentials])
9395

9496
return (
9597
<div className="col-md-12">
9698
<Wrapper>
9799
<Table
100+
className='collections'
98101
headers={headers}
99102
rows={collectionsList}
100103
withBulkAction

admin/src/components/Credentials.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import pluginId from '../pluginId'
99
import { Button, InputText, Label } from '@buffetjs/core'
1010
import { Wrapper } from '../components/Wrapper'
1111

12-
const Credentials = () => {
12+
const Credentials = ({ setUpdatedCredentials }) => {
1313
const [msApiKey, setApiKey] = useState('')
1414
const [msHost, setHost] = useState('')
1515

@@ -41,6 +41,7 @@ const Credentials = () => {
4141
})
4242
setApiKey(apiKey)
4343
setHost(host)
44+
setUpdatedCredentials(prev => !prev)
4445
}
4546

4647
return (
@@ -66,7 +67,7 @@ const Credentials = () => {
6667
type="text"
6768
value={msApiKey}
6869
/>
69-
<Button onClick={addMeilisearchCredentials} style={{ marginTop: '20px' }}>
70+
<Button className="credentials_button" onClick={addMeilisearchCredentials} style={{ marginTop: '20px' }}>
7071
Add
7172
</Button>
7273
</Wrapper>

admin/src/containers/HomePage/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
*
55
*/
66

7-
import React, { memo } from 'react'
7+
import React, { memo, useState } from 'react'
88
import { useGlobalContext } from 'strapi-helper-plugin'
99
import { Header } from '@buffetjs/custom'
1010
import getTrad from '../../utils/getTrad'
1111
import Credentials from '../../components/Credentials'
1212
import Collections from '../../components/Collections'
1313

1414
const HomePage = () => {
15+
const [updateCredentials, setUpdatedCredentials] = useState()
1516
const { formatMessage } = useGlobalContext()
17+
1618
return (
1719
<div className="container-fluid" style={{ padding: '18px 30px 66px 30px' }}>
1820
<Header
@@ -21,8 +23,8 @@ const HomePage = () => {
2123
}}
2224
content={formatMessage({ id: getTrad('header.description') })}
2325
/>
24-
<Credentials />
25-
<Collections />
26+
<Credentials setUpdatedCredentials={setUpdatedCredentials} />
27+
<Collections updateCredentials={updateCredentials} />
2628
</div>
2729
)
2830
}

admin/src/translations/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"plugin.name": "MeiliSearch Client",
2+
"plugin.name": "MeiliSearch",
33
"header.description": "Add your data to MeiliSearch and start searching"
44
}

bors.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ status = [
33
'playground-build (Node.js 12)',
44
'playground-build (Node.js 14)',
55
'style-check',
6+
'cypress-run'
67
]
78
# 1 hour timeout
89
timeout-sec = 3600

cypress.env.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"user": {
3+
"email": "[email protected]",
4+
"password": "Qwertyuiop1"
5+
},
6+
"apiKey": "masterKey",
7+
"test": {
8+
"adminUrl": "http://localhost:1337/admin/auth/login",
9+
"host": "http://localhost:7700"
10+
},
11+
"watch": {
12+
"adminUrl": "http://localhost:8000/admin/auth/login",
13+
"host": "http://localhost:7700"
14+
},
15+
"ci": {
16+
"adminUrl": "http://localhost:1337/admin/auth/login",
17+
"host": "http://meilisearch:7700"
18+
}
19+
}

0 commit comments

Comments
 (0)