-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* new dev env * fix NUA test
- Loading branch information
Showing
6 changed files
with
123 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
# env variables | ||
cypress.env.json | ||
cypress.env.*.json | ||
/cypress-prod.env.json | ||
|
||
# output | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
|
@@ -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.'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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')}`; | ||
|
@@ -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', | ||
|
@@ -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', | ||
|
@@ -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', | ||
|
@@ -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')}`, | ||
|