Skip to content
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

Closed
wants to merge 5 commits into from
Closed

test(storybook): test added for headings #311

wants to merge 5 commits into from

Conversation

sanketshevkar
Copy link
Member

@sanketshevkar sanketshevkar commented Mar 20, 2021

Signed-off-by: User shevkar.sanket@gmail.com

Changes

  • Added cypress test for: Placing cursor in paragraph and changing to header 1, 2, 3. Just wanted the maintainers to review the format and code quality. Once approved I'll add other tests for Headings.

Related Issues

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary
  • Merging to master from fork:branchname
  • Manual accessibility test performed
    • Keyboard-only access, including forms
    • Contrast at least WCAG Level A
    • Appropriate labels, alt text, and instructions

Signed-off-by: User <shevkar.sanket@gmail.com>
@jolanglinais
Copy link
Member

This looks like a great start, I'll try to review it as soon as I can.

@Cronus1007
Copy link
Contributor

Cronus1007 commented Mar 23, 2021

@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 selection command. @irmerk @mttrbrts I have written a little bit of code to select the text will need a little bit help in it i guess.

@sanketshevkar
Copy link
Member Author

@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 selection command. @irmerk @mttrbrts I have written a little bit of code to select the text will need a little bit help in it i guess.

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.

@Cronus1007
Copy link
Contributor

Cronus1007 commented Mar 23, 2021

@sanketshevkar Plzzz have a look upon it. I am getting that all the tests are failing.

cd packages/storybook
npm run test:e2e

Comment on lines 11 to 24
//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');
});
Copy link
Member

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 a p and no longer has the heading properties?

Copy link
Member Author

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 .

@sanketshevkar
Copy link
Member Author

@sanketshevkar Plzzz have a look upon it. I am getting that all the tests are failing.


cd packages/storybook

npm run test:e2e

I'll look into it

@jolanglinais
Copy link
Member

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?

@sanketshevkar
Copy link
Member Author

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.

Copy link
Contributor

@Cronus1007 Cronus1007 left a 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.

@sanketshevkar
Copy link
Member Author

@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>
@sanketshevkar
Copy link
Member Author

@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?

@jolanglinais
Copy link
Member

I think we should be testing what is in ui-markdown-editor/src/utilities/constants, which looks like is what the ci/cd server is expecting?

Maybe even import those values into the test so we know we're testing what is the source of truth for the CSS.

@sanketshevkar
Copy link
Member Author

sanketshevkar commented Apr 14, 2021

@irmerk I'm really sorry for the late response.
I tried importing css values from ui-markdown-editor/src/utilities/constants and it's working. Thank you for the suggestion.
The problem was that with merging PR #302, the sizes of H1 and H2 are now same, the difference being their alignment. And this commit wasn't present in my local repository, so the tests were failing.

Also, I think styling for paragraph should be added in ui-markdown-editor/src/utilities/constants, because in ui-markdown-editor/src/utilities/constants style for paragraph is null.

@jolanglinais
Copy link
Member

@sanketshevkar I believe @Michael-Grover will need to provide context on styling in relation to testing/consistency.

@Michael-Grover
Copy link

@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.

image

Signed-off-by: User <shevkar.sanket@gmail.com>
@sanketshevkar
Copy link
Member Author

@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.
Thank You.

@Michael-Grover
Copy link

@sanketshevkar

I took a look at the Netlify preview and it looks like there are only 3 header styles in the dropdown now
image

And it looks like the style for H6 changed
image

@sanketshevkar
Copy link
Member Author

Continued on PR #350. Had some merge conflicts on my fork and local repo. Sorry for the inconvenience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants