Skip to content

Commit

Permalink
fix e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
northdpole committed Oct 28, 2023
1 parent 2dad277 commit 9c6ce1f
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ e2e:
export FLASK_APP=$(CURDIR)/cre.py
export FLASK_CONFIG=development
flask run&
sleep 5

yarn test:e2e
killall yarn
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const LoadingAndErrorIndicator: FunctionComponent<LoadingAndErrorIndicato
{!loading && error && (
<Message icon negative floating>
<Icon name="warning" />
<Message.Content>
<Message.Content className="error-content">
{typeof error === 'string' ? error : 'Document could not be loaded'}
</Message.Content>
</Message>
Expand Down
2 changes: 1 addition & 1 deletion application/frontend/src/pages/Search/SearchName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const SearchName = () => {
}

return (
<div className="cre-page">
<div className="cre-page content">
<h1 className="standard-page__heading">
Results matching : <i>{searchTerm}</i>
</h1>
Expand Down
14 changes: 8 additions & 6 deletions application/frontend/src/test/basic-e2etest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

Expand Down Expand Up @@ -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');

Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions application/frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, GapAnalysisPath>;
};
}
1 change: 0 additions & 1 deletion application/tests/web_main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions application/web/web_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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})

Expand Down

0 comments on commit 9c6ce1f

Please sign in to comment.