Skip to content

Commit a92f211

Browse files
marker-daomarker dao ®Ruslan Farkhutdinov
authored
HtmlEditor: Add screenshot, a11y tests for AI toolbar item and AIDialog (DevExpress#29871)
Co-authored-by: marker dao ® <[email protected]> Co-authored-by: Ruslan Farkhutdinov <[email protected]>
1 parent bee83fe commit a92f211

File tree

59 files changed

+449
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+449
-15
lines changed
1 Byte
Loading

e2e/testcafe-devextreme/tests/accessibility/common/htmlEditor.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { Properties } from 'devextreme/ui/html_editor.d';
2+
import HtmlEditor from 'devextreme-testcafe-models/htmlEditor';
23
import { Selector } from 'testcafe';
34
import url from '../../../helpers/getPageUrl';
45
import { defaultSelector, testAccessibility, Configuration } from '../../../helpers/accessibility/test';
56
import { Options } from '../../../helpers/generateOptionMatrix';
67

8+
const MENU_ITEM_CLASS = 'dx-menu-item';
9+
const SUBMENU_CLASS = 'dx-submenu';
10+
711
fixture.disablePageReloads`Accessibility`
812
.page(url(__dirname, '../../container.html'));
913

@@ -42,3 +46,38 @@ const configuration: Configuration = {
4246
};
4347

4448
testAccessibility(configuration);
49+
50+
const aiOptions: Options<Properties> = {
51+
value: [markup],
52+
focusStateEnabled: [true],
53+
toolbar: [{ items: ['ai'] }],
54+
aiIntegration: [
55+
({} as any),
56+
{ changeStyle() {} },
57+
{ changeStyle(_, { onComplete }) { onComplete?.('Result'); } },
58+
{ changeStyle(_, { onError }) { onError?.('Error' as any); } },
59+
],
60+
};
61+
62+
const aiCreated = async (t: TestController): Promise<void> => {
63+
const htmlEditor = new HtmlEditor('#container');
64+
65+
await t.click(Selector(defaultSelector));
66+
67+
await t
68+
.click(htmlEditor.toolbar.getItemByName('ai'))
69+
.click(Selector(`.${SUBMENU_CLASS} .${MENU_ITEM_CLASS}`).nth(4));
70+
71+
await t
72+
.click(Selector(`.${SUBMENU_CLASS} .${MENU_ITEM_CLASS}`).nth(4)
73+
.find(`.${SUBMENU_CLASS} .${MENU_ITEM_CLASS}`).nth(0));
74+
};
75+
76+
const aiConfiguration: Configuration = {
77+
component: 'dxHtmlEditor',
78+
a11yCheckConfig,
79+
options: aiOptions,
80+
created: aiCreated,
81+
};
82+
83+
testAccessibility(aiConfiguration);

e2e/testcafe-devextreme/tests/htmlEditor/common.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
2+
import HtmlEditor from 'devextreme-testcafe-models/htmlEditor';
23
import { Selector } from 'testcafe';
34
import { createWidget } from '../../helpers/createWidget';
45
import url from '../../helpers/getPageUrl';
56
import { testScreenshot } from '../../helpers/themeUtils';
67
import { appendElementTo, setStyleAttribute } from '../../helpers/domUtils';
78

9+
const MENU_ITEM_CLASS = 'dx-menu-item';
10+
const SUBMENU_CLASS = 'dx-submenu';
11+
812
fixture.disablePageReloads`HtmlEditor`
913
.page(url(__dirname, '../container.html'));
1014

@@ -50,3 +54,29 @@ fixture.disablePageReloads`HtmlEditor`
5054
}, '#editorWithToolbar');
5155
});
5256
});
57+
58+
test('AI toolbar item', async (t) => {
59+
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
60+
const htmlEditor = new HtmlEditor('#container');
61+
62+
await testScreenshot(t, takeScreenshot, 'htmleditor-ai-toolbar-item.png', { element: '#container' });
63+
64+
await t
65+
.click(htmlEditor.toolbar.getItemByName('ai'))
66+
.click(Selector(`.${SUBMENU_CLASS}`).find(`.${MENU_ITEM_CLASS}`).nth(5));
67+
68+
await testScreenshot(t, takeScreenshot, 'htmleditor-ai-toolbar-item-expanded.png', { element: '#container' });
69+
70+
await t
71+
.expect(compareResults.isValid())
72+
.ok(compareResults.errorMessages());
73+
}).before(async () => {
74+
await createWidget('dxHtmlEditor', {
75+
height: 500,
76+
width: 350,
77+
aiIntegration: {},
78+
toolbar: {
79+
items: ['ai'],
80+
},
81+
});
82+
});

0 commit comments

Comments
 (0)