mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-27 01:48:24 +00:00
ci(cypress): adding the foundation for cypress integration tests & some starter coverage for login, search & updates (#3672)
This commit is contained in:
parent
a4ac79db48
commit
e9c87bc0df
5
.gitignore
vendored
5
.gitignore
vendored
@ -46,5 +46,10 @@ MANIFEST
|
||||
**/spark-lineage/**/out.csv/
|
||||
.vscode
|
||||
|
||||
# cypress integration test generated files
|
||||
**/cypress/videos
|
||||
**/cypress/screenshots
|
||||
**/cypress/node_modules
|
||||
|
||||
# Metadata Ingestion Generated
|
||||
metadata-ingestion/generated/**
|
||||
|
||||
@ -23,4 +23,6 @@ datahub docker quickstart \
|
||||
--quickstart-compose-file ../docker/docker-compose.dev.yml \
|
||||
--dump-logs-on-failure
|
||||
|
||||
(cd tests/cypress ; yarn install)
|
||||
|
||||
pytest -vv --continue-on-collection-errors --junit-xml=junit.smoke.xml
|
||||
|
||||
0
smoke-test/tests/cypress/__init__.py
Normal file
0
smoke-test/tests/cypress/__init__.py
Normal file
3
smoke-test/tests/cypress/cypress.json
Normal file
3
smoke-test/tests/cypress/cypress.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"baseUrl": "http://localhost:9002"
|
||||
}
|
||||
5
smoke-test/tests/cypress/cypress/fixtures/example.json
Normal file
5
smoke-test/tests/cypress/cypress/fixtures/example.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "Using fixtures to represent data",
|
||||
"email": "hello@cypress.io",
|
||||
"body": "Fixtures are a great way to mock data for responses to routes"
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
describe('login', () => {
|
||||
it('logs in', () => {
|
||||
cy.visit('/');
|
||||
cy.get('input[placeholder=Username]').type('datahub');
|
||||
cy.get('input[placeholder=Password]').type('datahub');
|
||||
cy.contains('Log in').click();
|
||||
cy.contains('Welcome back, datahub');
|
||||
});
|
||||
})
|
||||
@ -0,0 +1,40 @@
|
||||
describe('mutations', () => {
|
||||
it('can create and add a tag to dataset and visit new tag page', () => {
|
||||
cy.deleteUrn('urn:li:tag:CypressTestAddTag')
|
||||
cy.login();
|
||||
cy.visit('/dataset/urn:li:dataset:(urn:li:dataPlatform:hive,cypress_logging_events,PROD)');
|
||||
cy.contains('cypress_logging_events');
|
||||
|
||||
cy.contains('Add Tag').click();
|
||||
|
||||
cy.focused().type('CypressTestAddTag');
|
||||
|
||||
cy.contains('Create CypressTestAddTag').click();
|
||||
|
||||
cy.get('textarea').type('CypressTestAddTag Test Description');
|
||||
|
||||
cy.contains(/Create$/).click();
|
||||
|
||||
// go to tag page
|
||||
cy.get('a[href="/tag/urn:li:tag:CypressTestAddTag"]').click();
|
||||
|
||||
// title of tag page
|
||||
cy.contains('CypressTestAddTag');
|
||||
|
||||
// description of tag page
|
||||
cy.contains('CypressTestAddTag Test Description');
|
||||
|
||||
// used by panel - click to search
|
||||
cy.contains('1 Datasets').click();
|
||||
|
||||
// verify dataset shows up in search now
|
||||
cy.contains('of 1 result').click();
|
||||
cy.contains('cypress_logging_events').click();
|
||||
cy.get('a[href="/tag/urn:li:tag:CypressTestAddTag"]').within(() => cy.get('span[aria-label=close]').click());
|
||||
cy.contains('Yes').click();
|
||||
|
||||
cy.get('a[href="/tag/urn:li:tag:CypressTestAddTag"]').should('not.exist');
|
||||
|
||||
cy.deleteUrn('urn:li:tag:CypressTestAddTag')
|
||||
});
|
||||
})
|
||||
@ -0,0 +1,44 @@
|
||||
describe('search', () => {
|
||||
it('can hit all entities search, see some results (testing this any more is tricky because it is cached for now)', () => {
|
||||
cy.login();
|
||||
cy.visit('/');
|
||||
cy.get('input[data-testid=search-input]').type('*{enter}');
|
||||
cy.contains('of 0 results').should('not.exist');
|
||||
cy.contains(/of [0-9]+ results/);
|
||||
});
|
||||
|
||||
it('can hit all entities search with an impossible query and find 0 results', () => {
|
||||
cy.login();
|
||||
cy.visit('/');
|
||||
// random string that is unlikely to accidentally have a match
|
||||
cy.get('input[data-testid=search-input]').type('zzzzzzzzzzzzzqqqqqqqqqqqqqzzzzzzqzqzqzqzq{enter}');
|
||||
cy.contains('of 0 results');
|
||||
});
|
||||
|
||||
it('can search, find a result, and visit the dataset page', () => {
|
||||
cy.login();
|
||||
cy.visit('http://localhost:9002/search?filter_entity=DATASET&filter_tags=urn%3Ali%3Atag%3ACypress&page=1&query=users_created')
|
||||
cy.contains('of 1 result');
|
||||
|
||||
cy.contains('Cypress')
|
||||
|
||||
cy.contains('fct_cypress_users_created').click();
|
||||
|
||||
// platform
|
||||
cy.contains('Hive');
|
||||
|
||||
// entity type
|
||||
cy.contains('Dataset');
|
||||
|
||||
// entity name
|
||||
cy.contains('fct_cypress_users_created');
|
||||
|
||||
// column name
|
||||
cy.contains('user_id');
|
||||
// column description
|
||||
cy.contains('Id of the user');
|
||||
|
||||
// table description
|
||||
cy.contains('table containing all the users created on a single day');
|
||||
});
|
||||
})
|
||||
22
smoke-test/tests/cypress/cypress/plugins/index.js
Normal file
22
smoke-test/tests/cypress/cypress/plugins/index.js
Normal file
@ -0,0 +1,22 @@
|
||||
/// <reference types="cypress" />
|
||||
// ***********************************************************
|
||||
// This example plugins/index.js can be used to load plugins
|
||||
//
|
||||
// You can change the location of this file or turn off loading
|
||||
// the plugins file with the 'pluginsFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/plugins-guide
|
||||
// ***********************************************************
|
||||
|
||||
// This function is called when a project is opened or re-opened (e.g. due to
|
||||
// the project's config changing)
|
||||
|
||||
/**
|
||||
* @type {Cypress.PluginConfig}
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
module.exports = (on, config) => {
|
||||
// `on` is used to hook into various events Cypress emits
|
||||
// `config` is the resolved Cypress config
|
||||
}
|
||||
39
smoke-test/tests/cypress/cypress/support/commands.js
Normal file
39
smoke-test/tests/cypress/cypress/support/commands.js
Normal file
@ -0,0 +1,39 @@
|
||||
// ***********************************************
|
||||
// This example commands.js shows you how to
|
||||
// create various custom commands and overwrite
|
||||
// existing commands.
|
||||
//
|
||||
// For more comprehensive examples of custom
|
||||
// commands please read more here:
|
||||
// https://on.cypress.io/custom-commands
|
||||
// ***********************************************
|
||||
//
|
||||
//
|
||||
// -- This is a parent command --
|
||||
Cypress.Commands.add('login', () => {
|
||||
cy.request('POST', '/logIn', {
|
||||
username: 'datahub',
|
||||
password: 'datahub',
|
||||
})
|
||||
})
|
||||
|
||||
Cypress.Commands.add('deleteUrn', (urn) => {
|
||||
cy.request({ method: 'POST', url: 'http://localhost:8080/entities?action=delete', body: {
|
||||
urn
|
||||
}, headers: {
|
||||
"X-RestLi-Protocol-Version": "2.0.0",
|
||||
"Content-Type": "application/json",
|
||||
}})
|
||||
})
|
||||
//
|
||||
//
|
||||
// -- This is a child command --
|
||||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a dual command --
|
||||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
||||
20
smoke-test/tests/cypress/cypress/support/index.js
Normal file
20
smoke-test/tests/cypress/cypress/support/index.js
Normal file
@ -0,0 +1,20 @@
|
||||
// ***********************************************************
|
||||
// This example support/index.js is processed and
|
||||
// loaded automatically before your test files.
|
||||
//
|
||||
// This is a great place to put global configuration and
|
||||
// behavior that modifies Cypress.
|
||||
//
|
||||
// You can change the location of this file or turn off
|
||||
// automatically serving support files with the
|
||||
// 'supportFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/configuration
|
||||
// ***********************************************************
|
||||
|
||||
// Import commands.js using ES2015 syntax:
|
||||
import './commands'
|
||||
|
||||
// Alternatively you can use CommonJS syntax:
|
||||
// require('./commands')
|
||||
1560
smoke-test/tests/cypress/data.json
Normal file
1560
smoke-test/tests/cypress/data.json
Normal file
File diff suppressed because it is too large
Load Diff
28
smoke-test/tests/cypress/integration_test.py
Normal file
28
smoke-test/tests/cypress/integration_test.py
Normal file
@ -0,0 +1,28 @@
|
||||
import pytest
|
||||
import subprocess
|
||||
|
||||
from tests.utils import ingest_file_via_rest
|
||||
from tests.utils import delete_urns_from_file
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def ingest_cleanup_data():
|
||||
print("ingesting test data")
|
||||
ingest_file_via_rest("tests/cypress/data.json")
|
||||
yield
|
||||
print("removing test data")
|
||||
delete_urns_from_file("tests/cypress/data.json")
|
||||
|
||||
|
||||
def test_run_cypress(frontend_session, wait_for_healthchecks):
|
||||
command = f"npx cypress run"
|
||||
print('starting?')
|
||||
proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd="tests/cypress")
|
||||
stdout = proc.stdout.read()
|
||||
stderr = proc.stderr.read()
|
||||
return_code = proc.wait()
|
||||
print(stdout.decode("utf-8"))
|
||||
print('stderr output:')
|
||||
print(stderr.decode("utf-8"))
|
||||
print('return code', return_code)
|
||||
assert(return_code == 0)
|
||||
9
smoke-test/tests/cypress/package.json
Normal file
9
smoke-test/tests/cypress/package.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "smoke-test",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"cypress": "^9.1.0"
|
||||
}
|
||||
}
|
||||
1112
smoke-test/tests/cypress/yarn.lock
Normal file
1112
smoke-test/tests/cypress/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user