-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
FE - Temporarily mock metrics CRUD endpoints #38357
Conversation
const result = await get(payload); | ||
|
||
if (result.name.toLowerCase().startsWith("metric")) { | ||
return { ...result, type: "metric", dataset: false }; |
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.
dataset: false
is still only a temporary measure during the migration period, right?
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.
Hopefully. We will have both dataset
and type
, but we should not be using dataset
anymore.
const tweakedPayload = { ...payload, type: "question", dataset: false }; | ||
const result = await create(tweakedPayload); | ||
return { ...result, type: "metric" }; |
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.
Why do we have to first create a tweakedPayload with a type "question", only to override it with a type "metric" in the last (return) step?
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.
Let's say we want to create a metric.
We will try to call this create
endpoint with some payload which will include type: "metric"
.
Backend won't accept this, as it's not implemented yet.
So this override will actually make FE send type: "question"
to BE, but when the result comes back, we still want FE to believe it's a "metric", so we have to update the type
.
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.
Left some questions inline, but the change looks straightforward.
There are still some E2E tests failing, though - probably not related
return { ...result, type: "metric" }; | ||
} | ||
|
||
return await update(payload); |
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.
idk we do we use return await
without try catch, but seems there shouldn't be any difference comparing with just returning a promise
Good point. I disabled the overrides in tests so that we can have green CI: 97f2577 |
|
You might also need to use |
Closes #38262
Description
This PR mocks FE endpoint handlers to pretend that any question which has a name starting with "Metric" (case-insensitive) is a metric.
In other words: you can prefix your question names with "Metric" or "metric" to pretend they're metrics and not questions.
Be sure to pass correct
type: "metric"
to update/create endpoints though.