diff --git a/Makefile b/Makefile index c4cf3e8ab..5e62fd2f2 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,7 @@ e2e: export FLASK_APP=$(CURDIR)/cre.py export FLASK_CONFIG=development flask run& + sleep 5 yarn test:e2e killall yarn @@ -36,7 +37,7 @@ e2e: test: [ -d "./venv" ] && . ./venv/bin/activate export FLASK_APP=$(CURDIR)/cre.py - flask routes && flask test + flask test cover: . ./venv/bin/activate && FLASK_APP=cre.py FLASK_CONFIG=testing flask test --cover diff --git a/application/frontend/src/components/LoadingAndErrorIndicator/LoadingAndErrorIndicator.tsx b/application/frontend/src/components/LoadingAndErrorIndicator/LoadingAndErrorIndicator.tsx index c59c1ac1a..b68f64417 100644 --- a/application/frontend/src/components/LoadingAndErrorIndicator/LoadingAndErrorIndicator.tsx +++ b/application/frontend/src/components/LoadingAndErrorIndicator/LoadingAndErrorIndicator.tsx @@ -18,7 +18,7 @@ export const LoadingAndErrorIndicator: FunctionComponent - + {typeof error === 'string' ? error : 'Document could not be loaded'} diff --git a/application/frontend/src/pages/Search/SearchName.tsx b/application/frontend/src/pages/Search/SearchName.tsx index 5699888b6..2e67b2cb8 100644 --- a/application/frontend/src/pages/Search/SearchName.tsx +++ b/application/frontend/src/pages/Search/SearchName.tsx @@ -56,7 +56,7 @@ export const SearchName = () => { } return ( -
+

Results matching : {searchTerm}

diff --git a/application/frontend/src/test/basic-e2etest.ts b/application/frontend/src/test/basic-e2etest.ts index 5e96cd67f..7f8fa2af3 100644 --- a/application/frontend/src/test/basic-e2etest.ts +++ b/application/frontend/src/test/basic-e2etest.ts @@ -29,8 +29,8 @@ describe('App.js', () => { await page.waitForSelector('#SearchButton', { timeout: 1000 }); await page.type('#SearchBar > div > input', 'asdf'); await page.click('#SearchButton'); - await page.waitForSelector('.content', { timeout: 1000 }); - const text = await page.$eval('.content', (e) => e.textContent); + await page.waitForSelector('.error-content', { timeout: 100000 }); + const text = await page.$eval('.error-content', (e) => e.textContent); expect(text).toContain('No results match your search term'); }); @@ -58,7 +58,7 @@ describe('App.js', () => { it('the standard page works as expected', async () => { await page.goto('http://127.0.0.1:5000/node/standard/ASVS'); await page.waitForSelector('.standard-page', { timeout: 1000 }); - await page.waitForSelector('.standard-page__links-container', { timeout: 1000 }); + await page.waitForSelector('.standard-page__links-container', { timeout: 10000 }); const text = await page.$$('.standard-page', (e) => e.textContent); expect(text).not.toContain('Standard does not exist, please check your search parameters'); @@ -77,17 +77,19 @@ describe('App.js', () => { expect(await page.content()).not.toEqual(original_content); // link to section + await page.waitForSelector('.standard-page__links-container>.title>a', { timeout: 1000 }); await page.click('.standard-page__links-container>.title>a'); await page.waitForSelector('.standard-page', { timeout: 1000 }); const url = await page.url(); expect(url).toContain('section'); - const section = await page.$eval('.section-page > h5.standard-page__sub-heading', (e) => e.textContent); - expect(section).toContain('Section:'); // show reference + await page.waitForSelector('.standard-page > a', { timeout: 1000 }); const hrefs = await page.evaluate(() => - Array.from(document.querySelectorAll('.section-page > a[href]'), (a) => a.getAttribute('href')) + Array.from(document.querySelectorAll('.standard-page > a'), (a) => a.getAttribute('href')) ); + + console.log(hrefs); expect(hrefs[0]).toContain('https://'); // link to at least one cre diff --git a/application/frontend/src/types.ts b/application/frontend/src/types.ts index 18bbb4b92..a54901df7 100644 --- a/application/frontend/src/types.ts +++ b/application/frontend/src/types.ts @@ -48,14 +48,14 @@ interface GapAnalysisPathSegment { start: Document; end: Document; relationship: string; -}; +} interface GapAnalysisPath { end: Document; - path: GapAnalysisPathSegment[] -}; + path: GapAnalysisPathSegment[]; +} export interface GapAnalysisPathStart { start: Document; paths: Record; -}; +} diff --git a/application/tests/web_main_test.py b/application/tests/web_main_test.py index e934a6273..bd4244b6f 100644 --- a/application/tests/web_main_test.py +++ b/application/tests/web_main_test.py @@ -651,7 +651,6 @@ def test_gap_analysis_create_job_id( @patch.object(redis, "from_url") def test_standards_from_cache(self, redis_conn_mock) -> None: expected = ["A", "B"] - redis_conn_mock.return_value.exists.return_value = True redis_conn_mock.return_value.get.return_value = json.dumps(expected) with self.app.test_client() as client: response = client.get( diff --git a/application/web/web_main.py b/application/web/web_main.py index 7fb5df5c2..87d389382 100644 --- a/application/web/web_main.py +++ b/application/web/web_main.py @@ -236,7 +236,7 @@ def gap_analysis() -> Any: # TODO (spyros): add export result to spreadsheet if gap_analysis_dict.get("job_id"): try: res = job.Job.fetch(id=gap_analysis_dict.get("job_id"), connection=conn) - except exceptions.NoSuchJobError as nje: + except exceptions.NoSuchJobError: abort(404, "No such job") if ( res.get_status() != job.JobStatus.FAILED @@ -256,7 +256,6 @@ def gap_analysis() -> Any: # TODO (spyros): add export result to spreadsheet }, timeout="30m", ) - conn.set(standards_hash, json.dumps({"job_id": gap_analysis_job.id, "result": ""})) return jsonify({"job_id": gap_analysis_job.id})