Skip to content

Commit d24b516

Browse files
committed
Add autocomplete cypress tests in CI
1 parent 8b6d13a commit d24b516

File tree

12 files changed

+186
-46
lines changed

12 files changed

+186
-46
lines changed

.github/workflows/meilisearch-prototype-tests.yml

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
echo $MEILISEARCH_VERSION
3030
fi
3131
echo "meilisearch_version=$MEILISEARCH_VERSION" >> $GITHUB_OUTPUT
32-
cypress-run:
32+
cypress-autocomplete-client-run:
3333
runs-on: ubuntu-latest
3434
needs: ['meilisearch-version']
3535
services:
@@ -40,7 +40,47 @@ jobs:
4040
MEILI_NO_ANALYTICS: 'true'
4141
ports:
4242
- '7700:7700'
43-
name: end-to-end-tests
43+
name: autocomplete-client end-to-end-tests
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v3
47+
- name: Setup node
48+
uses: actions/setup-node@v3
49+
with:
50+
node-version: 16
51+
cache: yarn
52+
- name: Install dependencies
53+
run: yarn
54+
- name: Run local browser tests
55+
uses: cypress-io/github-action@v5
56+
with:
57+
project: ./playgrounds/autocomplete
58+
wait-on: 'http://localhost:7700'
59+
# Tests are only done on one playground to avoid long testing time
60+
start: yarn playground:autocomplete
61+
env: playground=local
62+
- uses: actions/upload-artifact@v3
63+
if: failure()
64+
with:
65+
name: cypress-screenshots
66+
path: cypress/screenshots
67+
- uses: actions/upload-artifact@v3
68+
if: failure()
69+
with:
70+
name: cypress-videos
71+
path: cypress/videos
72+
cypress-instant-meilisearch-run:
73+
runs-on: ubuntu-latest
74+
needs: ['meilisearch-version']
75+
services:
76+
meilisearch:
77+
image: getmeili/meilisearch:${{ needs.meilisearch-version.outputs.version }}
78+
env:
79+
MEILI_MASTER_KEY: 'masterKey'
80+
MEILI_NO_ANALYTICS: 'true'
81+
ports:
82+
- '7700:7700'
83+
name: instant-meilisearch end-to-end-tests
4484
steps:
4585
- name: Checkout
4686
uses: actions/checkout@v3
@@ -69,7 +109,6 @@ jobs:
69109
with:
70110
name: cypress-videos
71111
path: cypress/videos
72-
73112
integration_tests:
74113
runs-on: ubuntu-latest
75114
needs: ['meilisearch-version']

.github/workflows/pre-release-tests.yml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
run: |
2727
MEILISEARCH_VERSION=$(curl https://raw.githubusercontent.com/meilisearch/integration-guides/main/scripts/get-latest-meilisearch-rc.sh | sh)
2828
echo "meilisearch_version=$MEILISEARCH_VERSION" >> $GITHUB_OUTPUT
29-
cypress-run:
29+
cypress-autocomplete-client-run:
3030
runs-on: ubuntu-latest
3131
if: github.event_name != 'pull_request' || startsWith(github.base_ref, 'bump-meilisearch-v') || startsWith(github.base_ref, 'pre-release-beta')
3232
needs: ['meilisearch-version']
@@ -38,7 +38,48 @@ jobs:
3838
MEILI_NO_ANALYTICS: 'true'
3939
ports:
4040
- '7700:7700'
41-
name: end-to-end-tests
41+
name: autocomplete-client end-to-end-tests
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@v3
45+
- name: Setup node
46+
uses: actions/setup-node@v3
47+
with:
48+
node-version: 16
49+
cache: yarn
50+
- name: Install dependencies
51+
run: yarn
52+
- name: Run local browser tests
53+
uses: cypress-io/github-action@v5
54+
with:
55+
project: ./playgrounds/autocomplete
56+
wait-on: 'http://localhost:7700'
57+
# Tests are only done on one playground to avoid long testing time
58+
start: yarn playground:autocomplete
59+
env: playground=local
60+
- uses: actions/upload-artifact@v3
61+
if: failure()
62+
with:
63+
name: cypress-screenshots
64+
path: cypress/screenshots
65+
- uses: actions/upload-artifact@v3
66+
if: failure()
67+
with:
68+
name: cypress-videos
69+
path: cypress/videos
70+
cypress-instant-meilisearch-run:
71+
runs-on: ubuntu-latest
72+
if: github.event_name != 'pull_request' || startsWith(github.base_ref, 'bump-meilisearch-v') || startsWith(github.base_ref, 'pre-release-beta')
73+
needs: ['meilisearch-version']
74+
services:
75+
meilisearch:
76+
image: getmeili/meilisearch:${{ needs.meilisearch-version.outputs.version }}
77+
env:
78+
MEILI_MASTER_KEY: 'masterKey'
79+
MEILI_NO_ANALYTICS: 'true'
80+
ports:
81+
- '7700:7700'
82+
name: instant-meilisearch end-to-end-tests
4283
steps:
4384
- name: Checkout
4485
uses: actions/checkout@v3

.github/workflows/tests.yml

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
- main
1111

1212
jobs:
13-
cypress-run:
13+
cypress-autocomplete-client-run:
1414
runs-on: ubuntu-latest
1515
# Will not run if the event is a PR to bump-meilisearch-v* (so a pre-release PR)
1616
# Will not run if the event is a PR to pre-release-beta/*
@@ -31,7 +31,57 @@ jobs:
3131
MEILI_NO_ANALYTICS: 'true'
3232
ports:
3333
- '7700:7700'
34-
name: end-to-end-tests
34+
name: autocomplete-client end-to-end-tests
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v3
38+
- name: Setup node
39+
uses: actions/setup-node@v3
40+
with:
41+
node-version: 18
42+
cache: yarn
43+
- name: Install dependencies
44+
run: yarn
45+
- name: Run local browser tests
46+
uses: cypress-io/github-action@v5
47+
with:
48+
project: ./playgrounds/autocomplete
49+
wait-on: 'http://localhost:7700'
50+
# Tests are only done on one playground to avoid long testing time
51+
start: yarn playground:autocomplete
52+
env: playground=local
53+
- uses: actions/upload-artifact@v3
54+
if: failure()
55+
with:
56+
name: cypress-screenshots
57+
path: cypress/screenshots
58+
- uses: actions/upload-artifact@v3
59+
if: failure()
60+
with:
61+
name: cypress-videos
62+
path: cypress/videos
63+
cypress-instant-meilisearch-run:
64+
runs-on: ubuntu-latest
65+
# Will not run if the event is a PR to bump-meilisearch-v* (so a pre-release PR)
66+
# Will not run if the event is a PR to pre-release-beta/*
67+
# Will not run if the event is a PR to prototype-beta/*
68+
# Will not run if the event is a push on pre-release-beta/*
69+
# Will still run for each push to bump-meilisearch-v* and prototype-beta/*
70+
if: |
71+
github.event_name != 'pull_request' ||
72+
!startsWith(github.base_ref, 'bump-meilisearch-v') &&
73+
!startsWith(github.base_ref, 'pre-release-beta/') &&
74+
!startsWith(github.base_ref, 'prototype-beta/') &&
75+
!startsWith(github.head_ref, 'pre-release-beta/')
76+
services:
77+
meilisearch:
78+
image: getmeili/meilisearch:latest
79+
env:
80+
MEILI_MASTER_KEY: 'masterKey'
81+
MEILI_NO_ANALYTICS: 'true'
82+
ports:
83+
- '7700:7700'
84+
name: instant-meilisearch end-to-end-tests
3585
steps:
3686
- name: Checkout
3787
uses: actions/checkout@v3

CONTRIBUTING.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ turbo run test --filter=@meilisearch/instant-meilisearch
6363

6464
#### @meilisearch/instant-meilisearch playgrounds
6565

66-
To test directly your changes in `instant-meilisearch`, you can run the following playgrounds:
66+
To test directly your changes in `@meilisearch/instant-meilisearch`, you can run the following playgrounds:
6767

6868
`Vue 3`
6969
```bash
@@ -94,6 +94,14 @@ yarn playground:geo-javascript
9494

9595
Note: If the Google Maps stopped working, please create a new [Google Api Key](https://developers.google.com/maps/documentation/javascript/get-api-key) and add it in the `.env` file at the root of the playground: `/playgrounds/geo-javascript`
9696

97+
#### @meilisearch/instant-meilisearch playgrounds
98+
99+
To test directly your changes made in `@meilisearch/autocomplete-client`, you can run the following playground:
100+
101+
```
102+
yarn playground:autocomplete
103+
```
104+
97105
## Git Guidelines
98106

99107
### Git Branches <!-- omit in TOC -->
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Contributing <!-- omit in TOC -->
2+
3+
First of all, thank you for contributing to Meilisearch!
4+
5+
For the full explaination on how to contribute, please refer to the [contributing guide](../../CONTRIBUTING.md) at the root of this repository.
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { createSearchClient } from './createAutocompleteClient'
1+
import { PACKAGE_VERSION } from '../package-version'
2+
import { createSearchClient } from './createSearchClient'
23

34
/**
4-
* Create meilisearch autocomplete client
5+
* Create searchClient instance for autocomplete
56
*/
6-
7-
export const meilisearchAutocompleteClient = createSearchClient()
7+
const userAgent = `Meilisearch autocomplete-client (v${PACKAGE_VERSION})`
8+
export const meilisearchAutocompleteClient = createSearchClient({ userAgent })

packages/autocomplete-client/src/client/createAutocompleteClient.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { instantMeiliSearch } from '@meilisearch/instant-meilisearch'
2+
import { SearchClient } from '../types/SearchClient'
3+
import { ClientConfig } from '../types/ClientConfig'
4+
5+
export const concatUserAgents = (clientAgents: string[]): string[] => {
6+
return clientAgents.concat(clientAgents.filter((agent) => agent))
7+
}
8+
9+
/**
10+
* Create a searchClient instance
11+
*/
12+
export function createSearchClient({ userAgent }: { userAgent: string }) {
13+
return ({
14+
url,
15+
apiKey,
16+
options = { clientAgents: [] },
17+
}: ClientConfig): SearchClient => {
18+
const clientAgents = options.clientAgents || []
19+
const searchClient = instantMeiliSearch(url, apiKey, {
20+
...options,
21+
clientAgents: concatUserAgents([userAgent, ...clientAgents]),
22+
})
23+
24+
return {
25+
...searchClient,
26+
}
27+
}
28+
}

packages/autocomplete-client/src/client/createUserAgent.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
export * from './autocompleteSearchClient'
2-
export * from './createAutocompleteClient'
3-
export * from './createUserAgent'
2+
export * from './createSearchClient'

0 commit comments

Comments
 (0)