Skip to content

Commit

Permalink
fix test and clean
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodDayForSurf committed Dec 30, 2024
1 parent 644b3a8 commit 433f440
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion apps/demos/Demos/Charts/ExportCustomMarkup/jQuery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ $(() => {
format: 'png',
svgToCanvas(svg, canvas) {
const deferred = $.Deferred();
console.log('---------->', canvas.getContext('2d'));

canvas.getContext('2d')
.drawSvg(new XMLSerializer().serializeToString(svg), 0, 0, null, null, {
renderCallback: deferred.resolve,
Expand Down
37 changes: 24 additions & 13 deletions apps/demos/testing/widgets/charts/Export.test.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
import { Selector as $ } from 'testcafe';
import { ClientFunction } from 'testcafe';
import { runManualTest } from '../../../utils/visual-tests/matrix-test-helper';
import { testScreenshot } from '../../../utils/visual-tests/helpers/theme-utils';

fixture('Charts.Export')
.page('http://localhost:8080/')
.before(async (ctx) => {
ctx.initialWindowSize = [900, 600];
});
.page('http://localhost:8080/')
.before(async (ctx) => {
ctx.initialWindowSize = [900, 600];
});

runManualTest('Charts', 'ExportCustomMarkup', ['jQuery', 'React', 'Vue', 'Angular'], (test) => {
test('Export', async (t) => {
let dialogAppeared = false;
let isFileCreateForDownload = false;

const checkFn = ClientFunction((checkData) => {
window.originalCreateObjectURL = URL.createObjectURL;
window._testedValue = '';

await t.setNativeDialogHandler(() => {
dialogAppeared = true;
return false;
URL.createObjectURL = (blob) => {
window._testedValue = blob.type;

return Promise.reject();
};
});

await t.click('dx-button[icon=export]');
await checkFn();

await t.click('#export,.dx-button[icon=export]');

isFileCreateForDownload = await ClientFunction(() => {
URL.createObjectURL = window.originalCreateObjectURL;
return window._testedValue === 'image/png';
})();

await t.expect(dialogAppeared).ok('Save dialog should appear');
await t.expect(isFileCreateForDownload).ok('File was created for download');
});
});

0 comments on commit 433f440

Please sign in to comment.