Skip to content

Commit

Permalink
Focus before click
Browse files Browse the repository at this point in the history
  • Loading branch information
vivinkrishna-ni committed Oct 3, 2024
1 parent bdb2188 commit c691f00
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,11 @@ export class RichTextEditorPageObject {
}

public async clickMentionListboxOption(index: number): Promise<void> {
if (this.isMentionListboxOpened()) {
this.richTextEditorElement.tiptapEditor.commands.focus();
await waitForUpdatesAsync();
}

const listOption = this.getAllListItemsInMentionBox()[index];
listOption?.click();
await waitForUpdatesAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1542,29 +1542,34 @@ describe('RichTextEditorMentionListbox', () => {
expect(pageObject.isMentionListboxOpened()).toBeTrue();
});

// Firefox skipped, see https://github.com/ni/nimble/issues/2404
it('should show mention popup for multiple mention configuration elements #SkipFirefox', async () => {
it('should show mention popup for multiple mention configuration elements', async () => {
await appendUserMentionConfiguration(element, [
{ key: 'user:1', displayName: 'username1' },
{ key: 'user:2', displayName: 'username2' }
]);

await pageObject.setEditorTextContent('@');
expect(pageObject.isMentionListboxOpened()).toBeTrue();

expect(pageObject.getMentionListboxItemsName()).toEqual([
'username1',
'username2'
]);
await pageObject.clickMentionListboxOption(0);
expect(pageObject.isMentionListboxOpened()).toBeTrue();

await pageObject.sliceEditorContent(0, 2);

await appendTestMentionConfiguration(element, [
{ key: 'test:1', displayName: 'testname1' },
{ key: 'test:2', displayName: 'testname2' }
]);

await pageObject.setEditorTextContent('!');
expect(pageObject.isMentionListboxOpened()).toBeTrue();

expect(pageObject.getMentionListboxItemsName()).toEqual([
'testname1',
'testname2'
]);
expect(pageObject.isMentionListboxOpened()).toBeTrue();
});

it('mention listbox should be closed when cursor position is moved to start and configuration dynamically changes', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,13 @@ Plain text 3`);
<user:1> `);
});

// Firefox skipped, see https://github.com/ni/nimble/issues/2404
it('Mention node #SkipFirefox', async () => {
it('Mention node', async () => {
await appendUserMentionConfiguration(element, [
{ key: 'user:1', displayName: 'username1' }
]);

await commitFirstMentionBoxOptionIntoEditor('@');

expect(element.getMarkdown()).toEqual('<user:1> ');
});

Expand Down

0 comments on commit c691f00

Please sign in to comment.