-
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
Closed
sanketshevkar
wants to merge
5
commits into
accordproject:master
from
sanketshevkar:sanketshevkar/14/headingsTest
Closed
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7af2a03
test(storybook): test added for headings
sanketshevkar 20c5b9d
test(storybook): test added for headings
sanketshevkar 997295b
test(storybook): test added for headings
sanketshevkar 77269c4
feat(storybook): CSS constansts used for testing
sanketshevkar ec5ff06
Merge branch 'accordproject:master' into sanketshevkar/14/headingsTest
sanketshevkar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
packages/storybook/cypress/storybook/markdownEditorHeader.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// https://www.cypress.io/blog/2020/02/12/working-with-iframes-in-cypress/ | ||
const getIframeDocument = () => | ||
cy.get("#storybook-preview-iframe").its("0.contentDocument").should("exist"); | ||
|
||
const getIframeBody = () => | ||
getIframeDocument().its("body").should("not.be.undefined").then(cy.wrap); | ||
|
||
describe(" Placing cursor in paragraph and changing to header 1, 2, 3", () => { | ||
it("Change to Header 3", () => { | ||
cy.visit("/"); | ||
//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'); | ||
}); | ||
|
||
it("Change to Header 2", () => { | ||
cy.visit("/"); | ||
//Finds the paragraph and place cursor | ||
getIframeBody().find("#ap-rich-text-editor > p:nth-child(2)").click(); | ||
//Find heading dropdown and select heading-2 | ||
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(3)").click(); | ||
//checks if para changed to heading-2 | ||
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', '20px', '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', '20px', 'font-weight', 'bold'); | ||
}); | ||
|
||
it("Change to Header 1", () => { | ||
cy.visit("/"); | ||
//Finds the paragraph and place cursor | ||
getIframeBody().find("#ap-rich-text-editor > p:nth-child(2)").click(); | ||
getIframeBody().find("#ap-rich-text-editor-toolbar > div.ui.simple.dropdown").click(); | ||
//Find heading dropdown and select heading-1 | ||
getIframeBody().find("#ap-rich-text-editor-toolbar > div.ui.active.visible.simple.dropdown > div.menu.transition.visible > div:nth-child(2)").click(); | ||
//checks if para changed to heading-1 | ||
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', '25px', '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', '25px', 'font-weight', 'bold'); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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)
Could potential make this more readable.
// 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 .