Conversation
swarajpure
left a comment
There was a problem hiding this comment.
Can we use Ember Test Selectors instead of regular querySelector? More in comments
ankushdharkar
left a comment
There was a problem hiding this comment.
@SagarBajpai Missing a test where the button click was checked. Can we add that please?
# Conflicts: # package-lock.json # package.json
There was a problem hiding this comment.
Is this a feature? Having space before the text?
There was a problem hiding this comment.
Good eye @pallabez.
How does the component handle timezones though? 🤔
There was a problem hiding this comment.
In tests, we can get the time using the Date object with our provided epoch time and while implementing the component, we can do the conversion using the Date object in a similar way, It converts epoch time according to the user's current timezone
There was a problem hiding this comment.
let myDate = new Date(1656237389*1000);
| assert.verifySteps([CACHE_CLEAR_CLICKED]); | ||
| }); | ||
|
|
||
| skip('it disables button after a click', async function (assert) { |
There was a problem hiding this comment.
On what condition it gets enabled again?
There was a problem hiding this comment.
I had the same doubt, need to ask @ankushdharkar, but probably there will be a fixed time after which the button gets enabled again and it will be handled on the frontend, we need not to test that I guess
There was a problem hiding this comment.
How I think it should be -
Button clicked > Handle Click function calls which disables button & an API request to clear cache > Wait for server to respond > Server responds > Enable button again
There was a problem hiding this comment.
Good questions and suggestions.
We should be testing this on Frontend AND Backend. Backend should always validate and verify the behaviour (otherwise a bad user can just use curl/postman/etc to trigger the API anyway)
The button to be disabled here is to prevent multiple calls from firing (because clearing cache costs us as well as, it will cost crypto to clear your cache in future). We want to ideally make idempotent calls to clear the cache, and we should discuss this. We would have to implement some sort of UUID for this.
You can read more about the solution here: https://stripe.com/docs/api/idempotent_requests, but until then, we should just do a simpler implementation of maybe disabling the button for 5 seconds and move on.
- Start an RFC for the the idempotent requests setup
There was a problem hiding this comment.
Created an RFC here
RealDevSquad/website-backend#627
Written Unit test for the Cache clearing page.
Cases covered for now are :
More tests will add to this file.
Run this module by running the test suite:
npx ember test --server --filter="Integration | Component | self-clear-cache"Closes #67