-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes for fallback key test #17
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to check my understanding here:
We're using a promise and making the code async not to become particularly async ourselves but to manage that the function createRoom needs information that comes from a callback (line 37) rather than something it can do directly?
Did this work well / was it easy? I'm wondering if i should refactor away the use of jquery in favor of this sort of style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error handling i think needs to be addressed; though would also be happy with a note on how it's actually safe, if i've misunderstood something.
@@ -47,11 +47,11 @@ export function verifyLastMessageIsTrusted(): string { | |||
return "verified"; | |||
} | |||
|
|||
export function getTimeline(): JSONValue { | |||
const rsp = []; | |||
export function getTimeline(): Record<string, any> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we mean to change JSON value -> Record here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSONValue
is a type we define in trafficlight.spec.ts
and it's not exported. Record
here is basically saying that this function returns some object. Ideally we'd define the type explicitly, for eg:
type TimelineContent = {
user: string[];
e2e_issues: string[];
}
cy.resolveFromPromise(runAction(action, data)).then(result => { | ||
if (result) { | ||
sendResponse(result); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens to the flow if we don't send a result? We need to handle that as an error case (ActionRecord can be of type undefined) otherwise I think we'll end up in a loop doing a poll then trying to perform the action again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should move the whole set of methods to a promise interface and stop returning undefined; instead making the promise error. IDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only certain actions like idle and exit return undefined. All other actions will return something (most likely a string).
If these other actions don't return something that means an error was thrown while they were being executed. We have hooked to the cypress events so that these are caught and reported to the server. See
trafficlight-adapter-element-web/cypress/e2e/trafficlight/trafficlight.spec.ts
Lines 56 to 87 in 51d7e79
Cypress.on('uncaught:exception', (e, runnable) => { | |
console.log("uncaught exception", e.message); | |
const errorUrl = `${Cypress.env('TRAFFICLIGHT_URL') }/client/${ Cypress.env('TRAFFICLIGHT_UUID') }/error`; | |
const errorPath = e.stack?.split("\n")[0]; | |
const body = JSON.stringify({ | |
error: { | |
type: e.name, | |
details: e.message, | |
path: errorPath, | |
}, | |
}); | |
fetch(errorUrl, { method: "POST", body }); | |
return false; | |
}); | |
Cypress.on('fail', (e) => { | |
const errorUrl = `${Cypress.env('TRAFFICLIGHT_URL') }/client/${ Cypress.env('TRAFFICLIGHT_UUID') }/error`; | |
const errorPath = e.stack?.split("\n").slice(1).join("\n"); | |
const body = JSON.stringify({ | |
error: { | |
type: e.name, | |
details: e.message, | |
path: errorPath, | |
}, | |
}); | |
fetch(errorUrl, { | |
method: "post", | |
body, | |
headers: { 'Content-Type': 'application/json' }, | |
}); | |
throw e; | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this can probably be written in a better way but I suggest that we just create an issue for now (since this code was not introduced by the changes in this PR).
Cypress doesn't use JS promises, they use their own promise like objects. See https://docs.cypress.io/guides/core-concepts/introduction-to-cypress#Commands-Are-Asynchronous. |
Contains code to return the room-id from create-room action.