2021-12-13 23:08:30 -08:00
|
|
|
import pytest
|
|
|
|
import subprocess
|
2022-05-09 19:49:57 -07:00
|
|
|
import os
|
2021-12-13 23:08:30 -08:00
|
|
|
|
|
|
|
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")
|
2022-06-22 08:31:18 -07:00
|
|
|
ingest_file_via_rest("tests/cypress/cypress_dbt_data.json")
|
2022-05-02 17:28:47 -07:00
|
|
|
ingest_file_via_rest("tests/cypress/schema-blame-data.json")
|
2021-12-13 23:08:30 -08:00
|
|
|
yield
|
|
|
|
print("removing test data")
|
|
|
|
delete_urns_from_file("tests/cypress/data.json")
|
2022-06-22 08:31:18 -07:00
|
|
|
delete_urns_from_file("tests/cypress/cypress_dbt_data.json")
|
2022-05-02 17:28:47 -07:00
|
|
|
delete_urns_from_file("tests/cypress/schema-blame-data.json")
|
2021-12-13 23:08:30 -08:00
|
|
|
|
|
|
|
|
|
|
|
def test_run_cypress(frontend_session, wait_for_healthchecks):
|
2022-05-09 19:49:57 -07:00
|
|
|
# Run with --record option only if CYPRESS_RECORD_KEY is non-empty
|
|
|
|
record_key = os.getenv("CYPRESS_RECORD_KEY")
|
|
|
|
if record_key:
|
|
|
|
print('Running Cypress tests with recording')
|
2022-07-14 22:04:06 +05:30
|
|
|
command = f"NO_COLOR=1 npx cypress run --record"
|
2022-05-09 19:49:57 -07:00
|
|
|
else:
|
|
|
|
print('Running Cypress tests without recording')
|
2022-07-14 22:04:06 +05:30
|
|
|
command = f"NO_COLOR=1 npx cypress run"
|
2021-12-13 23:08:30 -08:00
|
|
|
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)
|