-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retrieve the API Key from the url parameters #416
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,7 +83,7 @@ jobs: | |
with: | ||
start: yarn start:ci | ||
wait-on: 'http://0.0.0.0:3000' | ||
command: yarn cy:run | ||
command: yarn cy:run:test-no-api-key | ||
config-file: cypress.config.js | ||
- uses: actions/upload-artifact@v3 | ||
if: failure() | ||
|
@@ -137,3 +137,45 @@ jobs: | |
with: | ||
name: cypress-videos | ||
path: cypress/videos | ||
cypress_meilisearch-api-key-query-param: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why didn't you put all of this inside the |
||
runs-on: ubuntu-latest | ||
container: | ||
image: cypress/browsers:node16.14.2-slim-chrome100-ff99-edge | ||
options: --user 1001 | ||
services: | ||
meilisearch: | ||
image: getmeili/meilisearch:v0.30.5 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you want to update this to v1? |
||
env: | ||
MEILI_MASTER_KEY: 'masterKey' | ||
MEILI_NO_ANALYTICS: 'true' | ||
ports: | ||
- '7700:7700' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup node and cache | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
cache: "yarn" | ||
cache-dependency-path: yarn.lock | ||
- name: Install dependencies | ||
run: yarn | ||
- name: Test | ||
uses: cypress-io/github-action@v4 | ||
env: | ||
CYPRESS_host: http://meilisearch:7700 | ||
with: | ||
start: yarn start:ci | ||
wait-on: 'http://0.0.0.0:3000' | ||
command: yarn cy:run:test-api-key-required | ||
config-file: cypress.config.js | ||
- uses: actions/upload-artifact@v3 | ||
if: failure() | ||
with: | ||
name: cypress-screenshots | ||
path: cypress/screenshots | ||
- uses: actions/upload-artifact@v3 | ||
if: failure() | ||
with: | ||
name: cypress-videos | ||
path: cypress/videos |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* eslint-disable cypress/no-unnecessary-waiting */ | ||
const API_KEY = Cypress.env('apiKey') | ||
const WAITING_TIME = Cypress.env('waitingTime') | ||
|
||
describe(`Test API key required with query params`, () => { | ||
before(() => { | ||
cy.deleteAllIndexes() | ||
|
||
cy.wait(WAITING_TIME) | ||
cy.createIndex('movies') | ||
cy.wait(WAITING_TIME) | ||
cy.fixture('movies.json').then((movies) => { | ||
cy.addDocuments('movies', movies) | ||
cy.wait(WAITING_TIME) | ||
}) | ||
}) | ||
|
||
beforeEach(() => { | ||
cy.visit(`/?api_key=${API_KEY}`) | ||
}) | ||
|
||
it('Should display the movies', () => { | ||
cy.get('ul') | ||
.children() | ||
.should(($p) => { | ||
expect($p).to.have.length(20) | ||
}) | ||
}) | ||
|
||
it('Should have the api key written in the modal', () => { | ||
// Test if the query parameter is written in the modal | ||
// meaning it is added in the local storage | ||
cy.get('span').contains('Api Key').parent().click() | ||
cy.get('div[aria-label=settings-api-key]').within(() => { | ||
cy.get('input[name="apiKey"]').should('have.value', API_KEY) | ||
cy.get('button').contains('Go').click() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't really need this last line :) |
||
}) | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,8 @@ | |
"cy:open": "cypress open", | ||
"cy:run:test-no-meilisearch": "cypress run --spec '**/*/test-no-meilisearch.cy.js'", | ||
"cy:run:test-api-key-required": "cypress run --spec '**/*/test-api-key-required.cy.js'", | ||
"cy:run:test-api-key-query-param": "cypress run --spec '**/*/test-api-key-query-param.cy.js'", | ||
"cy:run:test-no-api-key": "cypress run --spec '**/*/test-no-api-key-required.cy.js'", | ||
"cy:run": "cypress run --config excludeSpecPattern=['**/*/test-no-meilisearch.cy.js','**/*/test-api-key-required.cy.js']", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Initially I had those commands for those specific tests:
I had those 3 because I needed to run 3 different instances in the CI. |
||
"icons": "npx @svgr/cli --title-prop --no-dimensions --replace-attr-values \"#39486E=currentColor,#959DB3=currentColor\" -d src/components/icons src/components/icons/svg" | ||
}, | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you double check that all the tests are being run? I recommend you check the
cy:run
command inside thepackage.json
, which runs all the tests except some specific ones.