-
Notifications
You must be signed in to change notification settings - Fork 106
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
test(storybook): test added for headings #311
test(storybook): test added for headings #311
Conversation
Signed-off-by: User <shevkar.sanket@gmail.com>
This looks like a great start, I'll try to review it as soon as I can. |
@sanketshevkar How you have selected the text since cypress doesn't have any sort of api to select the text.The first need is to write the complete |
Nope. I had seen some scripts online, which could do that. I'm focusing on other tests rn as they seem to be easy and can be completed asap. If you're able get any solution do tell. |
@sanketshevkar Plzzz have a look upon it. I am getting that all the tests are failing.
|
//Finds the paragraph and place cursor | ||
getIframeBody().find("#ap-rich-text-editor > p:nth-child(2)").click(); | ||
//Find heading dropdown and select heading-3 | ||
getIframeBody().find("#ap-rich-text-editor-toolbar > div.ui.simple.dropdown").click(); | ||
getIframeBody().find("#ap-rich-text-editor-toolbar > div.ui.active.visible.simple.dropdown > div.menu.transition.visible > div:nth-child(4)").click(); | ||
//checks if para changed to heading-3 | ||
getIframeBody().find("#This-is-text-This-is-italic-text-This-is-bold-text-This-is-a-undefined-This-is-inline-code").should('have.css', 'font-size', '16px', 'font-weight', 'bold'); | ||
//undo and check | ||
getIframeBody().find("#ap-rich-text-editor-toolbar > svg:nth-child(11)").click(); | ||
getIframeBody().find("#ap-rich-text-editor > p:nth-child(2)").should('exist'); | ||
//redo and check | ||
getIframeBody().find("#ap-rich-text-editor-toolbar > svg:nth-child(12)").click(); | ||
getIframeBody().find("#This-is-text-This-is-italic-text-This-is-bold-text-This-is-a-undefined-This-is-inline-code").should('have.css', 'font-size', '16px', 'font-weight', 'bold'); | ||
}); |
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.
Some initial thoughts... (I'll still do more looking into this whole PR)
- Maybe we make some constants at the top of the file to describe what a lot of these are? For example:
const BUTTON_UNDO = 'svg:nth-child(11)';
const ID_TOOLBAR = '#ap-rich-text-editor-toolbar';
// ... etc
Could potential make this more readable.
- Similarly, could make a new line for each action:
getIframeBody()
.find("#ap-rich-text-editor > p:nth-child(2)")
.should('exist');
- Not sure I understand the
// undo and check
part. When undoing, we check to see if the paragraph exists? Is this checking to see if it is ap
and no longer has the heading properties?
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.
Yup I wanted to check whether it is a paragraph or not. Should I stick to css checking as I did for headers?
I'll make the code format changes and commit the code.
Thanks for the review @irmerk .
I'll look into it |
I think this looks amazing! Looks like some of these tests may be currently failing? Can you resolve and then I'll add more reviewers on this? |
I guess it would have timed out. Because these tests were passing on local repository. |
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.
@sanketshevkarm Assertion Error has occured since the it has not found out the element.Check the Details
of the failed tests.
It occurs when the storybook fails to load on the browser and thus element is not found. It works well locally. |
Signed-off-by: User <shevkar.sanket@gmail.com>
Signed-off-by: User <shevkar.sanket@gmail.com>
@irmerk this issue here is that the size of headings is being different in different browsers. My local browser for the test is expecting 25px, 20px, 16px for heading 1, 2, 3 respectively. Whereas the ci/cd server expects 25px, 25px, 20px for headings 1, 2, 3 respectively. So if the test are passing on ci-cd server, it is failing on my local machine and vice-versa. I guess we'll have to normalise font-size css for headings. Would this be the right thing to do? |
I think we should be testing what is in Maybe even import those values into the test so we know we're testing what is the source of truth for the CSS. |
@irmerk I'm really sorry for the late response. Also, I think styling for paragraph should be added in |
@sanketshevkar I believe @Michael-Grover will need to provide context on styling in relation to testing/consistency. |
@irmerk @sanketshevkar what is the specific design question here? I checked the heading CSS here and on storybook and it looks consistent with what I specified when I chose the styling for these headings. I think the file linked above is the closest thing to a source of truth I can find. All of the font sizes, colors, alignment, capitalization, etc. is what I expected. |
Signed-off-by: User <shevkar.sanket@gmail.com>
@irmerk @Michael-Grover I've imported the CSS constants and used them in the test as the source of truth. Requesting a review for the latest commit. |
Continued on PR #350. Had some merge conflicts on my fork and local repo. Sorry for the inconvenience. |
Signed-off-by: User shevkar.sanket@gmail.com
Changes
Headings
.Related Issues
Author Checklist
--signoff
option of git commit.master
fromfork:branchname