Skip to content

Commit

Permalink
Bug hunt (#561)
Browse files Browse the repository at this point in the history
* Sentry event f354c893656e4f1a8c6266ea63b2ab1a

Remove complicated behavior when current frame's scan is removed from list by review mode toggle

* Sentry event f8996437cdbf485d9b36e9dd9d720834

Fix change method for inputs on either side of range slider

* Sentry event 1375ba8ecb1a4b9381fb9cf6227ce8b3

Remove unnecessary wrapping around errors from apiClient;
Only do specialized response (trigger logout) for unauthorized errors

* Sentry event ad245c987af5457181c8fa10cd457438

Close window lock options if protectedDiv is undefined or null

* Sentry event 6d010b988a7c4186a947b2a3248ba233

Guard against null or undefined values when setting task overview

* Fix test-pyppeteer determinism

The serializer for a scan did not consider scans last marked "usable" as
complete. Fixed the serializer and the expected outcome of the pyppeteer
test

* Update Sentry version

* Redirect to login when a logout is complete

* Remove some console logs

* Fix constant ticking (+1 to both values) of window range slider
  • Loading branch information
annehaley authored Aug 12, 2022
1 parent b8c289c commit 58fae93
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 136 deletions.
17 changes: 8 additions & 9 deletions miqa/core/rest/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,19 @@ def get_my_project_role(self, obj):
return obj.get_user_role(self.context['user'])

def get_scan_states(self, obj):
def convert_state_string(last_reviewer_role):
if last_reviewer_role == 'tier_2_reviewer':
def convert_state_string(last_decision):
last_reviewer_role = obj.get_user_role(last_decision.creator)
if last_reviewer_role == 'tier_2_reviewer' or last_decision.decision == 'U':
# scan is complete if it is marked usable by anyone
# or if marked at all by a tier 2 reviewer
return 'complete'
elif last_reviewer_role == 'tier_1_reviewer':
return 'needs tier 2 review'
else:
return last_reviewer_role

return {
str(scan.id): convert_state_string(
obj.get_user_role(scan.decisions.latest('created').creator)
if scan.decisions.count() > 0 and scan.decisions.latest('created').creator
else 'unreviewed'
)
str(scan.id): convert_state_string(scan.decisions.latest('created'))
if scan.decisions.count() > 0 and scan.decisions.latest('created').creator
else 'unreviewed'
for exp in obj.experiments.all()
for scan in exp.scans.all()
}
Expand Down
5 changes: 3 additions & 2 deletions miqa/core/tests/pyppeteer/test_save_decisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,11 @@ async def test_save_decisions_tier_1(
).click()
await page.waitFor(3_000)

# confirm that the number of scans awaiting tier 2 review is 3
# confirm that the number of scans awaiting tier 2 review is 1;
# only the second scan does not have "Usable" as the latest decision
complete_span = await (page.waitForXPath('//span[contains(., "tier 2 review (")]'))
complete_text = (await page.evaluate('(element) => element.textContent', complete_span)).strip()
assert complete_text == 'needs tier 2 review (3)'
assert complete_text == 'needs tier 2 review (1)'


@pytest.mark.pyppeteer
Expand Down
172 changes: 72 additions & 100 deletions web_client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web_client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dependencies": {
"@girder/oauth-client": "^0.7.7",
"@mdi/font": "^6.5.95",
"@sentry/vue": "^6.17.6",
"@sentry/vue": "^7.9.0",
"@types/idle-js": "^1.2.1",
"@types/jest": "^27.0.1",
"@typescript-eslint/eslint-plugin": "^4.33.0",
Expand Down
7 changes: 4 additions & 3 deletions web_client/src/components/WindowWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default defineComponent({
}
function updateFromRange([v0, v1]) {
if (windowLocked.value) return;
if (v0 === currentRange.value[0] && v1 === currentRange.value[1]) return;
const ww = v1 - v0;
const wl = v0 + Math.ceil(ww / 2);
updateRender(ww, wl);
Expand Down Expand Up @@ -88,7 +89,7 @@ export default defineComponent({
window.addEventListener('click', (event: Event) => {
const protectedDiv = document.getElementById('windowLockWidget');
const target = event.target as HTMLElement;
if (!protectedDiv.contains(target)) {
if (!protectedDiv || !protectedDiv.contains(target)) {
showLockOptions.value = false;
}
});
Expand Down Expand Up @@ -177,7 +178,7 @@ export default defineComponent({
single-line
type="number"
style="width: 60px"
@change="$set(currentRange, 0, $event)"
@input="(value) => currentRange = [value, currentRange[1]]"
/>
</template>
<template #append>
Expand All @@ -188,7 +189,7 @@ export default defineComponent({
single-line
type="number"
style="width: 60px"
@change="$set(currentRange, 1, $event)"
@input="(value) => currentRange = [currentRange[0], value]"
/>
</template>
</custom-range-slider>
Expand Down
11 changes: 5 additions & 6 deletions web_client/src/django.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ const djangoClient = {
try {
await apiClient.post('/logout/', undefined, { withCredentials: true });
} finally {
await oauthClient.logout();
await oauthClient.logout().then(
async () => {
await oauthClient.redirectToLogin();
},
);
}
},
async MIQAConfig() {
Expand Down Expand Up @@ -202,11 +206,6 @@ apiClient.interceptors.response.use(null, (error) => {
if (error?.response?.status === 401) {
djangoClient.logout();
}
let msg = error?.response?.data?.detail || 'No response from server';
if (error?.response?.status === 403) {
msg = 'You are not allowed to perform this action.';
}
throw new Error(msg);
});

export { apiClient, oauthClient };
Expand Down
Loading

0 comments on commit 58fae93

Please sign in to comment.