Skip to content

Commit

Permalink
Rich text editor | Add tests for different list elements in same leve…
Browse files Browse the repository at this point in the history
…l behavior (#1481)

# Pull Request

## 🤨 Rationale

- Resolves #1473, where different
type of list element is possible to be added in same level.
It can be reproduced using the steps from
#1462 (comment)

## 👩‍💻 Implementation

- Added unit and ui test for the possibility of having different type of
list element in same level

## 🧪 Testing

- Added unit and ui testing

## ✅ Checklist

<!--- Review the list and put an x in the boxes that apply or ~~strike
through~~ around items that don't (along with an explanation). -->

- [x] I have updated the project documentation to reflect my changes or
determined no changes are needed.

---------

Signed-off-by: Sai krishnan Perumal <[email protected]>
Signed-off-by: Sai krishnan Perumal <[email protected]>
Co-authored-by: m-akinc <[email protected]>
  • Loading branch information
saikrishnan-ni and m-akinc authored Sep 7, 2023
1 parent 8e9908e commit aa91800
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "Added test for different list types at same level in rich text editor",
"packageName": "@ni/nimble-components",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,20 @@ multipleSubPointsContentInMobileWidth.play = (): void => {
.setMarkdown(multipleSubPointsContent);
};

const differentListElementContentInSameLevel = `
1. Point 1
* Sub point 1
1. Sub point 2
* Sub point 3
1. Sub point 4`;

export const differentListElementInSameLevel: StoryFn = createStory(mobileWidthComponent);
differentListElementInSameLevel.play = (): void => {
document
.querySelector('nimble-rich-text-editor')!
.setMarkdown(differentListElementContentInSameLevel);
};

export const longWordContentInMobileWidth: StoryFn = createStory(mobileWidthComponent);
longWordContentInMobileWidth.play = (): void => {
document
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,23 @@ describe('RichTextEditor', () => {
'bold, italics and bullet list'
]);
});

it('should have different type of list at same level possible', () => {
element.setMarkdown(`- Bulleted List
\n 1. Numbered List
\n - Bulleted List`);
expect(pageObject.getEditorTagNames()).toEqual([
'UL',
'LI',
'P',
'OL',
'LI',
'P',
'UL',
'LI',
'P'
]);
});
});

describe('various wacky string values input into the editor', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,31 @@ describe('RichTextViewer', () => {
'https://nimble.ni.dev/'
]);
});

it('should have different type of list at same level possible', async () => {
element.markdown = `- Bulleted List
\n 1. Numbered List
\n - Bulleted List`;

await connect();

expect(pageObject.getRenderedMarkdownTagNames()).toEqual([
'UL',
'LI',
'P',
'OL',
'LI',
'P',
'UL',
'LI',
'P'
]);
expect(pageObject.getRenderedMarkdownLeafContents()).toEqual([
'Bulleted List',
'Numbered List',
'Bulleted List'
]);
});
});

describe('various not supported markdown string values render as unchanged strings', () => {
Expand Down

0 comments on commit aa91800

Please sign in to comment.