Skip to content

Commit

Permalink
new dev env (#105)
Browse files Browse the repository at this point in the history
* new dev env

* fix NUA test
  • Loading branch information
ebrehault authored Aug 30, 2024
1 parent 648ea2d commit 61e827f
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 63 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/run-e2e-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: run-e2e-dev
run-name: Running Cypress e2e tests on Dev
on:
workflow_dispatch:
branches:
- main
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
cypress-run:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
# Launch NucliaDB in docker
- run: |
docker pull nuclia/nucliadb:latest
docker build -t nucliadb-server .
docker run -p 8080:8080 \
-v nucliadb-standalone:/data \
-e NUCLIA_PUBLIC_URL="https://{zone}.gcp-global-dev-1.nuclia.io" \
-e NUA_API_KEY=${{ secrets.NUA_KEY_DEV }} \
nucliadb-server &
# Install npm dependencies, cache them correctly and run all Cypress tests
- name: Cypress run
id: cypress
uses: cypress-io/github-action@v6
with:
install-command: yarn install
env:
CYPRESS_BASE_URL: https://gcp-global-dev-1.nuclia.io
CYPRESS_BEARER_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN_DEV }}
CYPRESS_NUA_KEY: ${{ secrets.NUA_KEY_DEV }}
CYPRESS_USER_NAME: ${{ secrets.USER_NAME_DEV }}
CYPRESS_USER_PWD: ${{ secrets.USER_PWD_DEV }}
CYPRESS_RUNNING_ENV: dev
# after the test run completes store reports and any screenshots
- name: Cypress reports
id: report
uses: actions/upload-artifact@v4
if: ${{ failure() && steps.cypress.conclusion == 'failure' }}
with:
name: cypress-reports
path: cypress/reports
if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn`
- name: Slack notification
id: slack
uses: slackapi/[email protected]
if: ${{ failure() && steps.cypress.conclusion == 'failure' && github.ref_name == 'main' }}
with:
payload: |
{
"text": "⚠️ Cypress E2E failed on Dev\nTriggered by ${{ github.triggering_actor }} \nRun #${{ github.run_number }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\nCypress report: ${{ steps.report.outputs.artifact-url }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_HOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# env variables
cypress.env.json
cypress.env.*.json
/cypress-prod.env.json

# output
Expand Down
35 changes: 19 additions & 16 deletions cypress/e2e/0-user/auth.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,27 @@
import { ACCOUNT, user } from '../../support/common';

describe('User Login', () => {
it('should redirect unauthenticated user to login page', function() {
it('should redirect unauthenticated user to login page', function () {
cy.visit('/at/testing');
cy.location('pathname').should('equal', '/user/login');
});


it('should redirect to kb selection page after login', () => {
cy.visit('/');
cy.get(`[formcontrolname="email"] input`).type(user.email,{ log: false });
cy.get(`[data-cy="password"] input[type="password"]`).type(user.password,{ log: false });
cy.get(`[formcontrolname="email"] input`).type(user.email, { log: false });
cy.get(`[data-cy="password"] input[type="password"]`).type(user.password, { log: false });
cy.get(`button[type='submit']`).click();
cy.location('pathname').should('equal', `/select/${ACCOUNT.slug}`);
});

it('should allow a visitor to login and logout', () => {
const permanentKb = ACCOUNT.availableZones[0].permanentKb;
cy.visit('/');
cy.get(`[formcontrolname="email"] input`).type(user.email,{ log: false });
cy.get(`[data-cy="password"] input[type="password"]`).type(`${user.password}{enter}`,{ log: false });
cy.get('a').contains(permanentKb.name).click();
cy.get(`[formcontrolname="email"] input`).type(user.email, { log: false });
cy.get(`[data-cy="password"] input[type="password"]`).type(`${user.password}{enter}`, { log: false });
cy.get('.select-kb-list a').contains(permanentKb.name).click();
cy.location('pathname').should('equal', `/at/${ACCOUNT.slug}/${permanentKb.zone}/${permanentKb.slug}`);
cy.get(`.kb-details .title-xxs`).should('contain', 'NucliaDB API endpoint')
cy.get(`.kb-details .title-xxs`).should('contain', 'NucliaDB API endpoint');

// logout
cy.get('[data-cy="user-menu"]').click();
Expand All @@ -42,18 +41,22 @@ describe('User Login', () => {

cy.get(`button[type='submit']`).should('be.disabled');
});

it('should error for an invalid user', () => {
cy.visit('/');
cy.get(`[formcontrolname="email"] input`).type('[email protected]',{ log: false });
cy.get(`[data-cy="password"] input[type="password"]`).type('invalid{enter}',{ log: false });
cy.get(`[data-cy="login-error"]`).should('contain', 'Authentication error.').and('contain', 'Please try again or reset your password below.')
cy.get(`[formcontrolname="email"] input`).type('[email protected]', { log: false });
cy.get(`[data-cy="password"] input[type="password"]`).type('invalid{enter}', { log: false });
cy.get(`[data-cy="login-error"]`)
.should('contain', 'Authentication error.')
.and('contain', 'Please try again or reset your password below.');
});

it('should error for an invalid password for existing user', () => {
cy.visit('/');
cy.get(`[formcontrolname="email"] input`).type(user.email,{ log: false });
cy.get(`[data-cy="password"] input[type="password"]`).type('invalid{enter}',{ log: false });
cy.get(`[data-cy="login-error"]`).should('contain', 'Authentication error.').and('contain', 'Please try again or reset your password below.')
cy.get(`[formcontrolname="email"] input`).type(user.email, { log: false });
cy.get(`[data-cy="password"] input[type="password"]`).type('invalid{enter}', { log: false });
cy.get(`[data-cy="login-error"]`)
.should('contain', 'Authentication error.')
.and('contain', 'Please try again or reset your password below.');
});
});
});
8 changes: 5 additions & 3 deletions cypress/e2e/2-nua/create-key-with-dashboard.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ describe('Create NUA key with the dashboard', () => {
cy.get('[data-cy="open-create-nua-key-dialog"]').click();
cy.get('pa-modal-advanced').should('be.visible');
cy.get('pa-modal-advanced input[name="title"]').should('be.visible').type('A new key');
cy.get('[formcontrolname="zone"] .pa-field-container').should('not.have.class', 'pa-readonly');
cy.get('[formcontrolname="zone"]').click();
cy.get('[formcontrolname="zone"] pa-option').contains(zone.title).click();
if (ACCOUNT.hasMultipleZones) {
cy.get('[formcontrolname="zone"] .pa-field-container').should('not.have.class', 'pa-readonly');
cy.get('[formcontrolname="zone"]').click();
cy.get('[formcontrolname="zone"] pa-option').contains(zone.title).click();
}
cy.get('pa-modal-advanced').get('[data-cy="save-nua-client"]').click();
cy.get('pa-modal-dialog').get('[data-cy="copy-token"]').click();
cy.get('pa-modal-dialog').get('[data-cy="close-token-dialog"]').click();
Expand Down
40 changes: 0 additions & 40 deletions cypress/e2e/2-nua/push-to-api.cy.js

This file was deleted.

44 changes: 40 additions & 4 deletions cypress/support/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { closeButton, nucliaSearchResultsSelector, viewerSelector } from '../e2e
const ZONES = {
europe: 'europe-1',
usa: 'aws-us-east-2-1',
dev: 'gcp-dev-1',
};

export const STANDALONE_KB_NAME = `${Cypress.env('STANDALONE_KB_NAME')}`;
Expand All @@ -14,11 +15,11 @@ export const ACCOUNT_STAGE = {
id: '23d9209a-34be-4648-8ef0-5b522f9976be',
slug: 'testing',
domain: 'stashify.cloud',
hasMultipleZones: true,
availableZones: [
{
slug: ZONES['europe'],
title: 'Europe',
nuaKey: `${Cypress.env('NUA_KEY')}`,
permanentKb: {
name: 'permanent',
slug: 'permanent',
Expand All @@ -44,11 +45,11 @@ export const ACCOUNT_PROD = {
id: '5cec111b-ea23-4b0c-a82a-d1a666dd1fd2',
slug: 'nuclia-testing',
domain: 'nuclia.cloud',
hasMultipleZones: true,
availableZones: [
{
slug: ZONES['europe'],
title: 'Europe',
nuaKey: `${Cypress.env('NUA_KEY_EUROPE')}`,
permanentKb: {
name: 'permanent',
slug: 'permanent',
Expand All @@ -69,7 +70,6 @@ export const ACCOUNT_PROD = {
{
slug: ZONES['usa'],
title: 'USA',
nuaKey: `${Cypress.env('NUA_KEY_USA')}`,
permanentKb: {
name: 'permanent USA',
slug: 'permanent-usa',
Expand All @@ -91,7 +91,43 @@ export const ACCOUNT_PROD = {
permanentKbCount: 4,
};

export const ACCOUNT = `${Cypress.env('RUNNING_ENV')}` === 'prod' ? ACCOUNT_PROD : ACCOUNT_STAGE;
export const ACCOUNT_DEV = {
//[email protected]
id: '22e77dea-3552-45ad-b387-1c8755f9c3cc',
slug: 'testing',
domain: 'gcp-global-dev-1.nuclia.io',
hasMultipleZones: false,
availableZones: [
{
slug: ZONES['dev'],
title: 'Regional gcp-dev-1',
permanentKb: {
name: 'permanent',
slug: 'permanent',
id: '0d773aed-bfb8-4228-a9d7-ed9f0ff171eb',
zone: ZONES['dev'],
},
emptyKb: {
name: 'permanent-empty',
slug: 'permanent-empty',
id: '065ce433-e294-494c-9dc7-56c7230dbf16',
zone: ZONES['dev'],
},
askUrl: 'https://nuclia.github.io/frontend/e2e/dev/ask.html',
citationsUrl: 'https://nuclia.github.io/frontend/e2e/dev/citations.html',
findUrl: 'https://nuclia.github.io/frontend/e2e/dev/find.html',
searchUrl: 'https://nuclia.github.io/frontend/e2e/dev/search.html',
},
],
permanentKbCount: 2,
};

export const ACCOUNT =
`${Cypress.env('RUNNING_ENV')}` === 'prod'
? ACCOUNT_PROD
: `${Cypress.env('RUNNING_ENV')}` === 'dev'
? ACCOUNT_DEV
: ACCOUNT_STAGE;

export const user = {
email: `${Cypress.env('USER_NAME')}`,
Expand Down

0 comments on commit 61e827f

Please sign in to comment.