-
Notifications
You must be signed in to change notification settings - Fork 97
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
Cache test case #79
base: develop
Are you sure you want to change the base?
Cache test case #79
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.
Can we use Ember Test Selectors
instead of regular querySelector
? More in comments
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.
@SagarBajpai Missing a test where the button click was checked. Can we add that please?
# Conflicts: # package-lock.json # package.json
import { hbs } from 'ember-cli-htmlbars'; | ||
|
||
const EPOCH_TIMESTAMP = 1626242030; | ||
const HUMAN_TIME = ' July 13, 2021 10:53:50 PM IST'; |
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.
Is this a feature? Having space before the text?
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.
Fixed that
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.
Good eye @pallabez.
How does the component handle timezones though? 🤔
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On what condition it gets enabled 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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created an RFC here
Real-Dev-Squad/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