From 7695f32fe2e7c15ed7e638d2ed913d0e5d899704 Mon Sep 17 00:00:00 2001 From: OlgaLarina Date: Wed, 8 Nov 2023 16:07:50 +0300 Subject: [PATCH] add lint --- .eslintignore | 4 + .eslintrc.json | 159 +++++ eslint-surveyjs/index.js | 29 + eslint-surveyjs/package.json | 5 + examples/add_properties.testcafe.js | 613 +++++++++--------- examples/ck_editor.testcafe.js | 38 +- examples/custom_adorner.testcafe.js | 52 +- examples/custom_matrix_cell_types.testcafe.js | 26 +- examples/custom_property_editor.testcafe.js | 20 +- examples/custom_theme.testcafe.js | 14 +- examples/custom_widgets.testcafe.js | 50 +- .../custom_widgets_single_page.testcafe.js | 276 ++++---- examples/depends_on_properties.testcafe.js | 26 +- examples/depends_on_single_page.testcafe.js | 122 ++-- examples/editor_options.testcafe.js | 16 +- .../editor_options_singlepage.testcafe.js | 84 +-- .../element_menu_customization.testcafe.js | 20 +- ...menu_customization_single_page.testcafe.js | 44 +- examples/load_survey_from_service.testcafe.js | 14 +- examples/localization.testcafe.js | 56 +- examples/localization_single_page.testcafe.js | 92 +-- examples/modify_new_question.testcafe.js | 29 +- ...odify_new_question_single_page.testcafe.js | 44 +- examples/multiple_languages.testcafe.js | 44 +- examples/open_close_edit_question.testcafe.js | 12 +- examples/question_editor.testcafe.js | 24 +- examples/remove_properties.testcafe.js | 86 +-- examples/set_and_save_survey.testcafe.js | 52 +- examples/survey_title.testcafe.js | 34 +- examples/toolbox_categories.testcafe.js | 112 ++-- examples/toolbox_customization.testcafe.js | 34 +- ...lbox_customization_single_page.testcafe.js | 116 ++-- package.json | 18 +- payment/Common/cart.testcafe.js | 2 +- surveyjsio mobile version/docs.testcafe.js | 2 +- .../examples.testcafe.js | 2 +- surveyjsio mobile version/helpers.js | 2 +- .../index_page.testcafe.js | 2 +- .../mobile_menu.testcafe.js | 2 +- .../Examples/codesandboxcheck.testcafe.js | 2 +- .../Examples/question_types.testcafe.js | 2 +- .../Library/Examples/survey.testcafe.js | 2 +- .../Library/Examples/tabs.testcafe.js | 2 +- surveyjstest/helpers.js | 2 +- warmup/_warmup.testcafe.js | 2 +- 45 files changed, 1284 insertions(+), 1105 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc.json create mode 100644 eslint-surveyjs/index.js create mode 100644 eslint-surveyjs/package.json diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..58f42c2 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,4 @@ +node_modules +dist +playwright +eslint-surveyjs diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..1753f11 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,159 @@ +{ + "root": true, + "parser": "@typescript-eslint/parser", + "plugins": [ + "@typescript-eslint", + "surveyjs" + ], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "globals": { + "document": true, + "foo": true, + "window": true, + "console": true + }, + "rules": { + "surveyjs/no-test-only": 2, + "surveyjs/no-test-debug": 2, + "indent": [ + "error", 2, + { + "SwitchCase": 1, + "MemberExpression": 1, + "CallExpression": { + "arguments": 1 + } + } + ], + "no-trailing-spaces": [ + "error", + { + "ignoreComments": true + } + ], + "no-trailing-spaces": "error", + "no-multi-spaces": "error", + "block-spacing": "error", + "comma-spacing": "error", + "key-spacing": "error", + "semi-spacing": "error", + "object-curly-spacing": [ + "error", + "always" + ], + "space-before-blocks": [ + "error", + "always" + ], + "space-in-parens": [ + "error", + "never" + ], + "array-bracket-spacing": [ + "error", + "never" + ], + "computed-property-spacing": "error", + // "keyword-spacing": ["error", { + // "overrides": { + // "if": { "after": false }, + // "for": { "after": false }, + // "while": { "after": false }, + // "switch": { "after": false }, + // //"this": { "after": false, "before": false }, + // "new": { "before": false }, + // "function": { "after": false, "before": false }, + // "catch": { "after": false } + // } + // }], + "no-multiple-empty-lines": [ + "error", + { + "max": 1 + } + ], + "no-whitespace-before-property": "error", + // sub group: semicolons + "semi": [ + "error", + "always" + ], + "semi": "error", + "no-extra-semi": [ + "error" + ], + "@typescript-eslint/member-delimiter-style": [ + "error", + { + "multiline": { + "delimiter": "comma", + "requireLast": true + }, + "singleline": { + "delimiter": "comma", + "requireLast": false + }, + "overrides": { + "interface": { + "multiline": { + "delimiter": "semi", + "requireLast": true + } + } + } + } + ], + "no-case-declarations": "off", + "quotes": [ + "error", + "single", + { + "avoidEscape": true + } + ], + "no-useless-escape": "off", + // group: add in future + "@typescript-eslint/no-var-requires": "off", // TODO add ignores + "no-unexpected-multiline": "off", + "no-constant-condition": "off", + "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/no-this-alias": "off", + "@typescript-eslint/class-name-casing": "off", + "@typescript-eslint/camelcase": "off", + "no-extra-boolean-cast": "off", + //sub group: js native functions + "no-prototype-builtins": "off", + "prefer-spread": "off", + //sub group: var definition: + "no-var": "off", + "prefer-const": "off", + "@typescript-eslint/no-use-before-define": "off", + "no-unsafe-finally": "off", + //"curly": [ "error", "multi-line", "consistent" ], + //"eqeqeq": ["error", "allow-null"], + "@typescript-eslint/no-unused-vars": "off", + // group: add in very far future + //"no-eval": "error", + //"no-extend-native": "error", + "@typescript-eslint/interface-name-prefix": "off", + "prefer-rest-params": "off", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/consistent-type-assertions": "off", + "@typescript-eslint/no-inferrable-types": "off", + // group: usless rules + "no-empty": "off", + "@typescript-eslint/no-empty-interface": "off", + "@typescript-eslint/no-empty-function": "off", + "@typescript-eslint/ban-types": "off", + // group: ok + //"@typescript-eslint/consistent-type-assertions": [ "error", { "assertionStyle": "angle-bracket" }], + "linebreak-style": [ + "off", + "windows" + ] + } +} \ No newline at end of file diff --git a/eslint-surveyjs/index.js b/eslint-surveyjs/index.js new file mode 100644 index 0000000..4d7ba09 --- /dev/null +++ b/eslint-surveyjs/index.js @@ -0,0 +1,29 @@ +const testOnlyMessage = " :( please don't forget to remove 'test.only' testcafe statement it will disable all other tests :( "; +const debugMessage = " :( please don't forget to remove 'debug()' :( "; + +module.exports = { + rules: { + "no-test-only": context => + ({ + MemberExpression: function (node) { + if (node.object.name === "test" && node.property.name === "only") { + context.report(node, testOnlyMessage); + } else if (node.object.type === "CallExpression" && node.property.name === "only" ){ + context.report(node, testOnlyMessage); + } else if (node.object.name === "QUnit" && node.property.name === "only" ){ + context.report(node, testOnlyMessage); + } + } + }), + "no-test-debug": context => + ({ + MemberExpression: function (node) { + if (node.object.name === "t" && node.property.name === "debug") { + context.report(node, debugMessage); + } else if (node.object.type === "CallExpression" && node.property.name === "debug" ){ + context.report(node, debugMessage); + } + } + }), + } +}; \ No newline at end of file diff --git a/eslint-surveyjs/package.json b/eslint-surveyjs/package.json new file mode 100644 index 0000000..e317a45 --- /dev/null +++ b/eslint-surveyjs/package.json @@ -0,0 +1,5 @@ +{ + "name": "eslint-plugin-surveyjs", + "version": "1.0.0", + "main": "index.js" +} \ No newline at end of file diff --git a/examples/add_properties.testcafe.js b/examples/add_properties.testcafe.js index 2cf5557..505e92d 100644 --- a/examples/add_properties.testcafe.js +++ b/examples/add_properties.testcafe.js @@ -1,370 +1,339 @@ -import { Selector, ClientFunction } from 'testcafe'; +import { Selector, ClientFunction, fixture, test } from 'testcafe'; fixture `add_properties` - .page `https://surveyjstest.azurewebsites.net//Examples/CreatorSinglePage?id=addproperties&platform=Knockoutjs&theme=default`; + .page `https://surveyjstest.azurewebsites.net//Examples/CreatorSinglePage?id=addproperties&platform=Knockoutjs&theme=default`; test.skip('Survey property with default string type', async t => { - await t - .maximizeWindow(); - - const dummy = ClientFunction(() => { - Survey - .Serializer - .addProperty('survey', { name: 'foo' } ); - var creatorOptions = {}; - new SurveyCreator.SurveyCreator('creatorElement', creatorOptions); - return 'dummy'; - }); - - await t - .expect(dummy()).eql('dummy') - .click(Selector('span').withText('Others')) - .expect(Selector('label').withText('Foo').exists).eql(true) - .expect(Selector('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]').nth(2).exists).eql(true); + await t + .maximizeWindow(); + + const dummy = ClientFunction(() => { + window.Survey.Serializer.addProperty('survey', { name: 'foo' }); + var creatorOptions = {}; + new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions); + return 'dummy'; + }); + + await t + .expect(dummy()).eql('dummy') + .click(Selector('span').withText('Others')) + .expect(Selector('label').withText('Foo').exists).eql(true) + .expect(Selector('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]').nth(2).exists).eql(true); }); test('Required property', async t => { - await t - .maximizeWindow(); - - const dummy = ClientFunction(() => { - Survey - .Serializer - .addProperty('checkbox', { name: '!foo' } ); - creator.JSON = ""; - return 'dummy'; - }); - - await t - .expect(dummy()).eql('dummy') - .click(Selector('.svd_toolbox').find('div').withText('Checkbox')) - .click(Selector('span.nav-link').withText('JSON Editor')) - //.expect(Selector('.svd-json-editor-area').exists).eql(true); // if ACE not loaded - .expect(Selector('div').withAttribute('class', /ace_gutter\-cell\s+ace_error/).exists).eql(true); // if ACE loaded + await t + .maximizeWindow(); + + const dummy = ClientFunction(() => { + window.Survey.Serializer.addProperty('checkbox', { name: '!foo' }); + window.creator.JSON = ''; + return 'dummy'; + }); + + await t + .expect(dummy()).eql('dummy') + .click(Selector('.svd_toolbox').find('div').withText('Checkbox')) + .click(Selector('span.nav-link').withText('JSON Editor')) + //.expect(Selector('.svd-json-editor-area').exists).eql(true); // if ACE not loaded + .expect(Selector('div').withAttribute('class', /ace_gutter\-cell\s+ace_error/).exists).eql(true); // if ACE loaded }); test.skip('Set property via JSON', async t => { - await t - .maximizeWindow(); - - const dummy = ClientFunction(() => { - Survey - .Serializer - .addProperty('checkbox', { name: '!foo' } ); - var creatorOptions = {}; - new SurveyCreator.SurveyCreator('creatorElement', creatorOptions); - return 'dummy'; - }); - - await t - .expect(dummy()).eql('dummy') - .click(Selector('.svd_toolbox').find('div').withText('Checkbox')) - .click(Selector('span.nav-link').withText('JSON Editor')) - .typeText('.ace_text-input', '{ "pages": [ { "name": "page1", "elements": [ { "type": "checkbox", "name": "question1", "choices": [ "item1", "item2", "item3" ], "foo":"bar" } ] } ] }') - .click(Selector('span.nav-link').withText('Survey Designer')) - .click('.sv_row') - .click(Selector('span').withText('Others')) - .expect(Selector('label').withText('Foo').exists).eql(true) - .expect(Selector('#editor_tab_id_others').find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]').value).eql("bar"); + await t + .maximizeWindow(); + + const dummy = ClientFunction(() => { + window.Survey.Serializer.addProperty('checkbox', { name: '!foo' }); + var creatorOptions = {}; + new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions); + return 'dummy'; + }); + + await t + .expect(dummy()).eql('dummy') + .click(Selector('.svd_toolbox').find('div').withText('Checkbox')) + .click(Selector('span.nav-link').withText('JSON Editor')) + .typeText('.ace_text-input', '{ "pages": [ { "name": "page1", "elements": [ { "type": "checkbox", "name": "question1", "choices": [ "item1", "item2", "item3" ], "foo":"bar" } ] } ] }') + .click(Selector('span.nav-link').withText('Survey Designer')) + .click('.sv_row') + .click(Selector('span').withText('Others')) + .expect(Selector('label').withText('Foo').exists).eql(true) + .expect(Selector('#editor_tab_id_others').find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]').value).eql('bar'); }); test('Property with default value', async t => { - await t - .maximizeWindow(); - - const dummy = ClientFunction(() => { - Survey - .Serializer - .addProperty('survey', { name: 'foo', default: 'bar' } ); - creator.JSON = {}; - return 'dummy'; - }); - - await t - .expect(dummy()).eql('dummy') - .click(Selector('span').withText('Others')) - .expect(Selector('input[placeholder=\"bar\"]').value).eql('bar'); + await t + .maximizeWindow(); + + const dummy = ClientFunction(() => { + window.Survey.Serializer.addProperty('survey', { name: 'foo', default: 'bar' }); + window.creator.JSON = {}; + return 'dummy'; + }); + + await t + .expect(dummy()).eql('dummy') + .click(Selector('span').withText('Others')) + .expect(Selector('input[placeholder=\"bar\"]').value).eql('bar'); }); test('Check boolean property', async t => { - await t - .maximizeWindow(); - - const dummy = ClientFunction(() => { - Survey - .Serializer - .addProperty('survey', { name: 'foo:boolean' } ); - creator.JSON = {}; - return 'dummy'; - }); - - await t - .expect(dummy()).eql('dummy') - .click(Selector('span').withText('Others')) - .expect(Selector('.sjs-cb-label').withText('Foo').exists).eql(true) - .expect(Selector('.sjs-cb-container').withText('Foo').find('input').exists).eql(true); + await t + .maximizeWindow(); + + const dummy = ClientFunction(() => { + window.Survey.Serializer.addProperty('survey', { name: 'foo:boolean' }); + window.creator.JSON = {}; + return 'dummy'; + }); + + await t + .expect(dummy()).eql('dummy') + .click(Selector('span').withText('Others')) + .expect(Selector('.sjs-cb-label').withText('Foo').exists).eql(true) + .expect(Selector('.sjs-cb-container').withText('Foo').find('input').exists).eql(true); }); test.skip('Check number property', async t => { - await t - .maximizeWindow(); - - const dummy = ClientFunction(() => { - Survey - .Serializer - .addProperty('survey', { name: 'foo:number' } ); - var creatorOptions = {}; - new SurveyCreator.SurveyCreator('creatorElement', creatorOptions); - return 'dummy'; - }); - - await t - .expect(dummy()).eql('dummy') - .click(Selector('span').withText('Others')) - .expect(Selector('label').withText('Foo').exists).eql(true) - .expect(Selector('div').withText('Foo').find('input').exists).eql(true) - .typeText(Selector('div').withText('Foo').find('input'), '7') - .expect(Selector('div').withText('Foo').find('input').value).eql('7'); + await t + .maximizeWindow(); + + const dummy = ClientFunction(() => { + window.Survey.Serializer.addProperty('survey', { name: 'foo:number' }); + var creatorOptions = {}; + new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions); + return 'dummy'; + }); + + await t + .expect(dummy()).eql('dummy') + .click(Selector('span').withText('Others')) + .expect(Selector('label').withText('Foo').exists).eql(true) + .expect(Selector('div').withText('Foo').find('input').exists).eql(true) + .typeText(Selector('div').withText('Foo').find('input'), '7') + .expect(Selector('div').withText('Foo').find('input').value).eql('7'); }); test('Check text property', async t => { - await t - .maximizeWindow(); - - const dummy = ClientFunction(() => { - Survey - .Serializer - .addProperty('survey', { name: 'foo:text' } ); - creator.JSON = {}; - return 'dummy'; - }); - - await t - .expect(dummy()).eql('dummy') - .click(Selector('span').withText('Others')) - .click(Selector('div').withText('Foo').find('textarea')) - .typeText(Selector('div').withText('Foo').find('textarea'), 'Bar') - .expect(Selector('div').withText('Foo').find('textarea').value).eql('Bar'); + await t + .maximizeWindow(); + + const dummy = ClientFunction(() => { + window.Survey.Serializer.addProperty('survey', { name: 'foo:text' }); + window.creator.JSON = {}; + return 'dummy'; + }); + + await t + .expect(dummy()).eql('dummy') + .click(Selector('span').withText('Others')) + .click(Selector('div').withText('Foo').find('textarea')) + .typeText(Selector('div').withText('Foo').find('textarea'), 'Bar') + .expect(Selector('div').withText('Foo').find('textarea').value).eql('Bar'); }); test('Check html property', async t => { - await t - .maximizeWindow(); - - const dummy = ClientFunction(() => { - Survey - .Serializer - .addProperty('survey', { name: 'foo:html' } ); - creator.JSON = {}; - return 'dummy'; - }); - - await t - .expect(dummy()).eql('dummy') - .click(Selector('span').withText('Others')) - .click(Selector('div').withText('Foo')) - .typeText(Selector('div').withText('Foo').find('textarea'), 'Bar') - .expect(Selector('div').withText('Foo').find('textarea').value).eql('Bar'); + await t + .maximizeWindow(); + + const dummy = ClientFunction(() => { + window.Survey.Serializer.addProperty('survey', { name: 'foo:html' }); + window.creator.JSON = {}; + return 'dummy'; + }); + + await t + .expect(dummy()).eql('dummy') + .click(Selector('span').withText('Others')) + .click(Selector('div').withText('Foo')) + .typeText(Selector('div').withText('Foo').find('textarea'), 'Bar') + .expect(Selector('div').withText('Foo').find('textarea').value).eql('Bar'); }); test.skip('Check choices property', async t => { - await t - .maximizeWindow(); - - const dummy = ClientFunction(() => { - Survey - .Serializer - .addProperty('survey', { name: 'foo', choices: ['bar', 'egg'], default: 'bar' } ); - var creatorOptions = {}; - new SurveyCreator.SurveyCreator('creatorElement', creatorOptions); - return 'dummy'; - }); - - await t - .expect(dummy()).eql('dummy') - .click(Selector('span').withText('Others')) - .expect(Selector('div').withText('Foo').find('select').value).eql('bar') - .click(Selector('div').withText('Foo').find('select')) - .click(Selector('option').withText('egg')) - .expect(Selector('div').withText('Foo').find('select').value).eql('egg') - .click('.svd-survey-placeholder'); + await t + .maximizeWindow(); + + const dummy = ClientFunction(() => { + window.Survey.Serializer.addProperty('survey', { name: 'foo', choices: ['bar', 'egg'], default: 'bar' }); + var creatorOptions = {}; + new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions); + return 'dummy'; + }); + + await t + .expect(dummy()).eql('dummy') + .click(Selector('span').withText('Others')) + .expect(Selector('div').withText('Foo').find('select').value).eql('bar') + .click(Selector('div').withText('Foo').find('select')) + .click(Selector('option').withText('egg')) + .expect(Selector('div').withText('Foo').find('select').value).eql('egg') + .click('.svd-survey-placeholder'); }); test('Check itemvalues property', async t => { - await t - .maximizeWindow(); - - const dummy = ClientFunction(() => { - Survey - .Serializer - .addProperty('survey', { name: 'foo:itemvalues' }); - creator.JSON = {}; - return 'dummy'; - }); - - await t - .expect(dummy()).eql('dummy') - .click(Selector('span').withText('Others')) - .click(Selector('button').withText('Form Entry')) - .click("input[value='Add New']") - .click("input[value='Add New']") - .expect(Selector('div').withText('Foo').find('table tbody').find('tr').count).eql(2); + await t + .maximizeWindow(); + + const dummy = ClientFunction(() => { + window.Survey.Serializer.addProperty('survey', { name: 'foo:itemvalues' }); + window.creator.JSON = {}; + return 'dummy'; + }); + + await t + .expect(dummy()).eql('dummy') + .click(Selector('span').withText('Others')) + .click(Selector('button').withText('Form Entry')) + .click("input[value='Add New']") + .click("input[value='Add New']") + .expect(Selector('div').withText('Foo').find('table tbody').find('tr').count).eql(2); }); test.skip('Check matrixdropdowncolumns property', async t => { - await t - .maximizeWindow(); - - const dummy = ClientFunction(() => { - Survey - .Serializer - .addProperty('matrixdynamic', { name: 'foo:matrixdropdowncolumns' }); - var creatorOptions = {}; - new SurveyCreator.SurveyCreator('creatorElement', creatorOptions); - return 'dummy'; - }); - - await t - .expect(dummy()).eql('dummy') - .click(Selector('div').withText('Matrix').nth(9).find('.svd_toolbox_item_text.hidden-sm.hidden-xs[data-bind="text:title"]')) - .click(Selector('a').withText('Items').nth(2).find('[data-bind="text: koText"]')) - .click(Selector('div').withText('Required').nth(19).find('.btn.btn-primary[data-bind^="click: onAddClick, value: $root.getLocString(\\\'pe.a"]')) - .click(Selector('.modal-body.svd_notopbottompaddings').nth(8).find('div').withText('Required')) - .click(Selector('div').withText('Required').nth(19).find('.btn.btn-primary[data-bind^="click: onAddClick, value: $root.getLocString(\\\'pe.a"]')) - .click(Selector('div').withText('×').nth(44).find('.btn.btn-default.btn-secondary[data-bind^="click: $data.onOkClick, disable: readOnly, value: "]')) - .expect(Selector('a').withText('Items').nth(2).find('[data-bind="text: koText"]').innerText).eql('[ Items: 2 ]'); + await t + .maximizeWindow(); + + const dummy = ClientFunction(() => { + window.Survey.Serializer.addProperty('matrixdynamic', { name: 'foo:matrixdropdowncolumns' }); + var creatorOptions = {}; + new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions); + return 'dummy'; + }); + + await t + .expect(dummy()).eql('dummy') + .click(Selector('div').withText('Matrix').nth(9).find('.svd_toolbox_item_text.hidden-sm.hidden-xs[data-bind="text:title"]')) + .click(Selector('a').withText('Items').nth(2).find('[data-bind="text: koText"]')) + .click(Selector('div').withText('Required').nth(19).find('.btn.btn-primary[data-bind^="click: onAddClick, value: $root.getLocString(\\\'pe.a"]')) + .click(Selector('.modal-body.svd_notopbottompaddings').nth(8).find('div').withText('Required')) + .click(Selector('div').withText('Required').nth(19).find('.btn.btn-primary[data-bind^="click: onAddClick, value: $root.getLocString(\\\'pe.a"]')) + .click(Selector('div').withText('×').nth(44).find('.btn.btn-default.btn-secondary[data-bind^="click: $data.onOkClick, disable: readOnly, value: "]')) + .expect(Selector('a').withText('Items').nth(2).find('[data-bind="text: koText"]').innerText).eql('[ Items: 2 ]'); }); test.skip('Check textitems property', async t => { - await t - .maximizeWindow(); - - const dummy = ClientFunction(() => { - Survey - .Serializer - .addProperty('multipletext', { name: 'foo:textitems' }); - var creatorOptions = {}; - new SurveyCreator.SurveyCreator('creatorElement', creatorOptions); - return 'dummy'; - }); - - await t - .expect(dummy()).eql('dummy') - .click(Selector('div').withText('Multiple Text').nth(7).find('.svd_toolbox_item_text.hidden-sm.hidden-xs[data-bind="text:title"]')) - .click(Selector('a').withText('Items').find('[data-bind="text: koText"]')) - .click(Selector('.svd-items-control-footer[data-bind="visible: koAllowAddRemoveItems"]').find('.btn.btn-primary[data-bind^="click: onAddClick, value: $root.getLocString(\\\'pe.a"]')) - .click(Selector('.svd-items-control-footer[data-bind="visible: koAllowAddRemoveItems"]').find('.btn.btn-primary[data-bind^="click: onAddClick, value: $root.getLocString(\\\'pe.a"]')) - .click(Selector('div').withText('×').nth(28).find('.btn.btn-default.btn-secondary[data-bind^="click: $data.onOkClick, disable: readOnly, value: "]')) - .expect(Selector('a').withText('Items').nth(1).find('[data-bind="text: koText"]').textContent).eql('[ Items: 2 ]'); + await t + .maximizeWindow(); + + const dummy = ClientFunction(() => { + window.Survey.Serializer.addProperty('multipletext', { name: 'foo:textitems' }); + var creatorOptions = {}; + new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions); + return 'dummy'; + }); + + await t + .expect(dummy()).eql('dummy') + .click(Selector('div').withText('Multiple Text').nth(7).find('.svd_toolbox_item_text.hidden-sm.hidden-xs[data-bind="text:title"]')) + .click(Selector('a').withText('Items').find('[data-bind="text: koText"]')) + .click(Selector('.svd-items-control-footer[data-bind="visible: koAllowAddRemoveItems"]').find('.btn.btn-primary[data-bind^="click: onAddClick, value: $root.getLocString(\\\'pe.a"]')) + .click(Selector('.svd-items-control-footer[data-bind="visible: koAllowAddRemoveItems"]').find('.btn.btn-primary[data-bind^="click: onAddClick, value: $root.getLocString(\\\'pe.a"]')) + .click(Selector('div').withText('×').nth(28).find('.btn.btn-default.btn-secondary[data-bind^="click: $data.onOkClick, disable: readOnly, value: "]')) + .expect(Selector('a').withText('Items').nth(1).find('[data-bind="text: koText"]').textContent).eql('[ Items: 2 ]'); }); test.skip('Check choices with function property', async t => { - await t - .maximizeWindow(); - - const dummy = ClientFunction(() => { - Survey - .Serializer - .addProperty('survey', { name: 'locale', - choices: function() { return Survey.surveyLocalization.getLocales(); } }); - var creatorOptions = {}; - new SurveyCreator.SurveyCreator('creatorElement', creatorOptions); - return 'dummy'; - }); - - await t - .expect(dummy()).eql('dummy') - .click(Selector('div').withText('Default').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) - .click(Selector('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').nth(2).find('option').withText('русский')) - .expect(Selector('div').withText('Default').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').value).eql('ru'); + await t + .maximizeWindow(); + + const dummy = ClientFunction(() => { + window.Survey.Serializer.addProperty('survey', { name: 'locale', choices: function() { return window.Survey.surveyLocalization.getLocales(); } }); + var creatorOptions = {}; + new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions); + return 'dummy'; + }); + + await t + .expect(dummy()).eql('dummy') + .click(Selector('div').withText('Default').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) + .click(Selector('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').nth(2).find('option').withText('русский')) + .expect(Selector('div').withText('Default').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').value).eql('ru'); }); test.skip('Check triggers property', async t => { - await t - .maximizeWindow(); - - const dummy = ClientFunction(() => { - Survey - .Serializer - .addProperty('survey', { name: 'foo:triggers' }); - var creatorOptions = {}; - new SurveyCreator.SurveyCreator('creatorElement', creatorOptions); - return 'dummy'; - }); - - await t - .expect(dummy()).eql('dummy') - .click(Selector('span').withText('Single-Line Input')) - .click('#objectSelector') - .click(Selector('option').withText('Survey')) - .click(Selector('[data-bind="text: koText"]').nth(5)); - - const workaroundShow = ClientFunction(() => { - const el = document.querySelector('#modelEditortriggers49').querySelector('div.ddmenu').querySelector('ul'); - el.style.visibility = 'visible'; - return true; - }); - - await t - .expect(workaroundShow()).ok() - .click(Selector('a').withText('complete survey').nth(0)); - - const workaroundHide = ClientFunction(() => { - const el = document.querySelector('#modelEditortriggers49').querySelector('div.ddmenu').querySelector('ul'); - el.style.visibility = 'hidden'; - return true; - }); - - await t - .expect(workaroundHide()).ok() - .click('[data-bind="if: true, value: koAddConditionQuestion"]') - .click('[data-bind^="value: name, text: (text || \'\').substring(0, 80), "][title="question1"]') - .click('.form-control[data-bind^="textInput:koAddConditionValue, enable: koAddContio"]') - .typeText('.form-control[data-bind^="textInput:koAddConditionValue, enable: koAddContio"]', 'Arr') - .click(Selector('.btn.btn-default.btn-secondary[data-bind^="click: $data.onOkClick, disable: readOnly, value: "]').nth(5)) - .expect(Selector('[data-bind="text: koText"]').nth(5).textContent).eql('[ Items: 1 ]'); + await t + .maximizeWindow(); + + const dummy = ClientFunction(() => { + window.Survey.Serializer.addProperty('survey', { name: 'foo:triggers' }); + var creatorOptions = {}; + new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions); + return 'dummy'; + }); + + await t + .expect(dummy()).eql('dummy') + .click(Selector('span').withText('Single-Line Input')) + .click('#objectSelector') + .click(Selector('option').withText('Survey')) + .click(Selector('[data-bind="text: koText"]').nth(5)); + + const workaroundShow = ClientFunction(() => { + const el = document.querySelector('#modelEditortriggers49').querySelector('div.ddmenu').querySelector('ul'); + el.style.visibility = 'visible'; + return true; + }); + + await t + .expect(workaroundShow()).ok() + .click(Selector('a').withText('complete survey').nth(0)); + + const workaroundHide = ClientFunction(() => { + const el = document.querySelector('#modelEditortriggers49').querySelector('div.ddmenu').querySelector('ul'); + el.style.visibility = 'hidden'; + return true; + }); + + await t + .expect(workaroundHide()).ok() + .click('[data-bind="if: true, value: koAddConditionQuestion"]') + .click('[data-bind^="value: name, text: (text || \'\').substring(0, 80), "][title="question1"]') + .click('.form-control[data-bind^="textInput:koAddConditionValue, enable: koAddContio"]') + .typeText('.form-control[data-bind^="textInput:koAddConditionValue, enable: koAddContio"]', 'Arr') + .click(Selector('.btn.btn-default.btn-secondary[data-bind^="click: $data.onOkClick, disable: readOnly, value: "]').nth(5)) + .expect(Selector('[data-bind="text: koText"]').nth(5).textContent).eql('[ Items: 1 ]'); }); test.skip('Check validators property', async t => { - await t - .maximizeWindow(); - - const dummy = ClientFunction(() => { - Survey - .Serializer - .addProperty('survey', { name: 'foo:validators' }); - var creatorOptions = {}; - new SurveyCreator.SurveyCreator('creatorElement', creatorOptions); - return 'dummy'; - }); - - await t - .expect(dummy()).eql('dummy') - .click(Selector('[data-bind="text: koText"]').nth(5)); - - const workaroundShow = ClientFunction(() => { - const el = document.querySelectorAll('.propertyeditor-validators')[2].querySelector('div.ddmenu').querySelector('ul'); - el.style.visibility = 'visible'; - return true; - }); - - await t - .expect(workaroundShow()).ok() - .click(Selector('a').withText('numeric')); - - const workaroundHide = ClientFunction(() => { - const el = document.querySelectorAll('.propertyeditor-validators')[2].querySelector('div.ddmenu').querySelector('ul'); - el.style.visibility = 'hidden'; - return true; - }); - - await t - .expect(workaroundHide()).ok() - .typeText(Selector('#editor_tab_id_general').find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]'), '3') - .typeText(Selector('[data-bind^="visible: objectProperty.koVisible, event: { keydow"][data-property="minValue"]').find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {max: koM"]'), '1') - .click(Selector('[data-bind^="visible: objectProperty.koVisible, event: { keydow"][data-property="maxValue"]').find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {max: koM"]')) - .typeText(Selector('[data-bind^="visible: objectProperty.koVisible, event: { keydow"][data-property="maxValue"]').find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {max: koM"]'), '4') - .click(Selector('.modal-footer').nth(5).nth(5).find('input').nth(1)) - .expect(Selector('[data-bind="text: koText"]').nth(5).textContent).eql('[ Items: 1 ]'); + await t + .maximizeWindow(); + + const dummy = ClientFunction(() => { + window.Survey.Serializer.addProperty('survey', { name: 'foo:validators' }); + var creatorOptions = {}; + new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions); + return 'dummy'; + }); + + await t + .expect(dummy()).eql('dummy') + .click(Selector('[data-bind="text: koText"]').nth(5)); + + const workaroundShow = ClientFunction(() => { + const el = document.querySelectorAll('.propertyeditor-validators')[2].querySelector('div.ddmenu').querySelector('ul'); + el.style.visibility = 'visible'; + return true; + }); + + await t + .expect(workaroundShow()).ok() + .click(Selector('a').withText('numeric')); + + const workaroundHide = ClientFunction(() => { + const el = document.querySelectorAll('.propertyeditor-validators')[2].querySelector('div.ddmenu').querySelector('ul'); + el.style.visibility = 'hidden'; + return true; + }); + + await t + .expect(workaroundHide()).ok() + .typeText(Selector('#editor_tab_id_general').find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]'), '3') + .typeText(Selector('[data-bind^="visible: objectProperty.koVisible, event: { keydow"][data-property="minValue"]').find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {max: koM"]'), '1') + .click(Selector('[data-bind^="visible: objectProperty.koVisible, event: { keydow"][data-property="maxValue"]').find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {max: koM"]')) + .typeText(Selector('[data-bind^="visible: objectProperty.koVisible, event: { keydow"][data-property="maxValue"]').find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {max: koM"]'), '4') + .click(Selector('.modal-footer').nth(5).nth(5).find('input').nth(1)) + .expect(Selector('[data-bind="text: koText"]').nth(5).textContent).eql('[ Items: 1 ]'); }); \ No newline at end of file diff --git a/examples/ck_editor.testcafe.js b/examples/ck_editor.testcafe.js index 9c3f304..9485173 100644 --- a/examples/ck_editor.testcafe.js +++ b/examples/ck_editor.testcafe.js @@ -1,25 +1,25 @@ -import { Selector } from 'testcafe'; +import { Selector, fixture, test } from 'testcafe'; import { getIUnderstandButton } from '../surveyjstest/helpers'; fixture `ck_editor` - .page `https://surveyjstest.azurewebsites.net/Examples/Builder?id=ckeditorpropertyeditor&theme=default`; + .page `https://surveyjstest.azurewebsites.net/Examples/Builder?id=ckeditorpropertyeditor&theme=default`; test.skip('CK editor', async t => { - await t - .maximizeWindow() - .click(Selector('.svd_toolbox').find('div').withText('Single-Line Input')) - .click(Selector('.svda_question_action.svd-main-color[data-bind^="key2click, clickNoFocus: function() { onClick($par"][title="Edit"]').find('span').withText('Edit')) - .click(Selector('.modal-body.svd_notopbottompaddings').nth(9).find('div').withText('Title').nth(1)) - .expect(Selector('#cke_modalEditorCustomWidget12').id).contains('cke') - .click(Selector('#cke_669').find('.cke_button_icon.cke_button__bold_icon')) - .switchToIframe('.cke_wysiwyg_frame.cke_reset[title="Rich Text Editor, modalEditorCustomWidget12"]') - .click(Selector('body').find('p')) - .typeText(Selector('body').find('p'), 'hello') - .switchToMainWindow() - .click(getIUnderstandButton()) - .switchToIframe('.cke_wysiwyg_frame.cke_reset[title="Rich Text Editor, modalEditorCustomWidget12"]') - .expect(Selector('strong').withText('hello').textContent).eql("​hello") - .switchToMainWindow() - .switchToIframe('.cke_wysiwyg_frame.cke_reset[title="Rich Text Editor, modalEditorCustomWidget12"]') - .expect(Selector('strong').withText('hello').tagName).eql('strong'); + await t + .maximizeWindow() + .click(Selector('.svd_toolbox').find('div').withText('Single-Line Input')) + .click(Selector('.svda_question_action.svd-main-color[data-bind^="key2click, clickNoFocus: function() { onClick($par"][title="Edit"]').find('span').withText('Edit')) + .click(Selector('.modal-body.svd_notopbottompaddings').nth(9).find('div').withText('Title').nth(1)) + .expect(Selector('#cke_modalEditorCustomWidget12').id).contains('cke') + .click(Selector('#cke_669').find('.cke_button_icon.cke_button__bold_icon')) + .switchToIframe('.cke_wysiwyg_frame.cke_reset[title="Rich Text Editor, modalEditorCustomWidget12"]') + .click(Selector('body').find('p')) + .typeText(Selector('body').find('p'), 'hello') + .switchToMainWindow() + .click(getIUnderstandButton()) + .switchToIframe('.cke_wysiwyg_frame.cke_reset[title="Rich Text Editor, modalEditorCustomWidget12"]') + .expect(Selector('strong').withText('hello').textContent).eql('​hello') + .switchToMainWindow() + .switchToIframe('.cke_wysiwyg_frame.cke_reset[title="Rich Text Editor, modalEditorCustomWidget12"]') + .expect(Selector('strong').withText('hello').tagName).eql('strong'); }); \ No newline at end of file diff --git a/examples/custom_adorner.testcafe.js b/examples/custom_adorner.testcafe.js index bccc477..cd1e803 100644 --- a/examples/custom_adorner.testcafe.js +++ b/examples/custom_adorner.testcafe.js @@ -1,36 +1,36 @@ -import { Selector } from 'testcafe'; +import { Selector, fixture, test } from 'testcafe'; fixture `Custom Adorner` - .page `https://surveyjstest.azurewebsites.net/survey-creator/examples/s/create-custom-adorners/reactjs`; + .page `https://surveyjstest.azurewebsites.net/survey-creator/examples/s/create-custom-adorners/reactjs`; test('Adorner exists', async t => { - const selector = Selector('.svc-question__content span').withText('Read-Only'); - await t - .maximizeWindow() - .expect(selector.visible).notOk() - .click(Selector('span').withText('JSON Editor')) - .pressKey('ctrl+a') - .pressKey('delete') - .click(Selector('span').withText('Designer')) - .wait(1000) - .expect(selector.visible).notOk() - .click(Selector('span').withText('Single-Line Input')) - .wait(1000) - .expect(selector.exists).ok() - .expect(selector.visible).ok(); + const selector = Selector('.svc-question__content span').withText('Read-Only'); + await t + .maximizeWindow() + .expect(selector.visible).notOk() + .click(Selector('span').withText('JSON Editor')) + .pressKey('ctrl+a') + .pressKey('delete') + .click(Selector('span').withText('Designer')) + .wait(1000) + .expect(selector.visible).notOk() + .click(Selector('span').withText('Single-Line Input')) + .wait(1000) + .expect(selector.exists).ok() + .expect(selector.visible).ok(); }); test.skip('Adorner works', async t => { - await t - .maximizeWindow() - .click(Selector('span').withText('Single-Line Input')) - .click(Selector('.svda_question_action.svd-main-color[data-bind^="key2click, clickNoFocus: function() { onClick($par"][title="Edit"]').find('span').withText('Edit')) - .expect(Selector('div').withText('Is start with new line').nth(25).find('.checkmark.svd-main-background-color[data-bind^="css: { \\\'svd-main-background-color\\\': koValue, \\\'svd-"]').getStyleProperty('background-color')).eql("rgb(26, 179, 148)") - .click('.btn.btn-primary[data-bind^="click: onResetClick, value: $root.getLocString(\'pe"]') - .click('[data-bind="value: selection"]') - .click(Selector('option').withText('Place On The Same Line')) - .click(Selector('.svda_question_action.svd-main-color[data-bind^="key2click, clickNoFocus: function() { onClick($par"][title="Edit"]').find('span').withText('Edit')) - .expect(Selector('div').withText('Is start with new line').nth(25).find('.checkmark.svd-light-background-color[data-bind^="css: { \\\'svd-main-background-color\\\': koValue, \\\'svd-"]').getStyleProperty('background-color')).eql("rgb(231, 234, 236)"); + await t + .maximizeWindow() + .click(Selector('span').withText('Single-Line Input')) + .click(Selector('.svda_question_action.svd-main-color[data-bind^="key2click, clickNoFocus: function() { onClick($par"][title="Edit"]').find('span').withText('Edit')) + .expect(Selector('div').withText('Is start with new line').nth(25).find('.checkmark.svd-main-background-color[data-bind^="css: { \\\'svd-main-background-color\\\': koValue, \\\'svd-"]').getStyleProperty('background-color')).eql('rgb(26, 179, 148)') + .click('.btn.btn-primary[data-bind^="click: onResetClick, value: $root.getLocString(\'pe"]') + .click('[data-bind="value: selection"]') + .click(Selector('option').withText('Place On The Same Line')) + .click(Selector('.svda_question_action.svd-main-color[data-bind^="key2click, clickNoFocus: function() { onClick($par"][title="Edit"]').find('span').withText('Edit')) + .expect(Selector('div').withText('Is start with new line').nth(25).find('.checkmark.svd-light-background-color[data-bind^="css: { \\\'svd-main-background-color\\\': koValue, \\\'svd-"]').getStyleProperty('background-color')).eql('rgb(231, 234, 236)'); }); /* Test for all version diff --git a/examples/custom_matrix_cell_types.testcafe.js b/examples/custom_matrix_cell_types.testcafe.js index 3a40fcb..c56c8ea 100644 --- a/examples/custom_matrix_cell_types.testcafe.js +++ b/examples/custom_matrix_cell_types.testcafe.js @@ -1,19 +1,19 @@ -import { Selector } from 'testcafe'; +import { Selector, fixture, test } from 'testcafe'; import { getIUnderstandButton } from '../surveyjstest/helpers'; fixture `custom_matrix_cell_types` - .page `https://surveyjstest.azurewebsites.net/Examples/Builder?id=matrixcustomcelltypes&theme=default`; + .page `https://surveyjstest.azurewebsites.net/Examples/Builder?id=matrixcustomcelltypes&theme=default`; test.skip('File and tagbox cell types in matrix', async t => { - await t - .maximizeWindow() - .click(Selector('span.nav-link').withText('Test Survey')) - .expect(Selector('#sq_148').find('td').withText('English').textContent).contains('LiteratureMath') - .expect(Selector('div').withText('Select a subject').nth(40).find('[data-bind^="css: question.cssClasses.fileInput, attr: {id: que"].sv_q_file_input[title="Choose file(s)..."]').tagName).eql('input') - .click(Selector('div').withText('English').nth(42).find('.select2-selection__rendered')) - .click('[class^="select2-results__option select2-results__option--h"]') - .click(getIUnderstandButton()) - .click(Selector('.surveyjs-customer-survey-close[title="Hide this panel"]').find('img')) - .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') - .expect(Selector('div').withText('[{\"subjects\":[\"English: American Literature\"]}').textContent).match(/Literature/); + await t + .maximizeWindow() + .click(Selector('span.nav-link').withText('Test Survey')) + .expect(Selector('#sq_148').find('td').withText('English').textContent).contains('LiteratureMath') + .expect(Selector('div').withText('Select a subject').nth(40).find('[data-bind^="css: question.cssClasses.fileInput, attr: {id: que"].sv_q_file_input[title="Choose file(s)..."]').tagName).eql('input') + .click(Selector('div').withText('English').nth(42).find('.select2-selection__rendered')) + .click('[class^="select2-results__option select2-results__option--h"]') + .click(getIUnderstandButton()) + .click(Selector('.surveyjs-customer-survey-close[title="Hide this panel"]').find('img')) + .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') + .expect(Selector('div').withText('[{\"subjects\":[\"English: American Literature\"]}').textContent).match(/Literature/); }); \ No newline at end of file diff --git a/examples/custom_property_editor.testcafe.js b/examples/custom_property_editor.testcafe.js index de55bb0..bdd3605 100644 --- a/examples/custom_property_editor.testcafe.js +++ b/examples/custom_property_editor.testcafe.js @@ -1,15 +1,15 @@ -import { Selector } from 'testcafe'; +import { Selector, fixture, test } from 'testcafe'; fixture `custom_property_editor` - .page `https://surveyjstest.azurewebsites.net//Examples/CreatorSinglePage?id=custompropertyeditor&theme=default`; + .page `https://surveyjstest.azurewebsites.net//Examples/CreatorSinglePage?id=custompropertyeditor&theme=default`; test.skip('Check shortname property', async t => { - await t - .maximizeWindow() - .click(Selector('span').withText('Single-Line Input')) - .click(Selector('.svda_question_action.svd-main-color[data-bind^="key2click, clickNoFocus: function() { onClick($par"][title="Edit"]').find('span').withText('Edit')) - .expect(Selector('#editor_tab_id_general').find('label').withText('Shortname').innerText).eql('Shortname') - .click(Selector('div').withText('Shortname').nth(19).find('.form-control.svd_editor_control')) - .typeText(Selector('div').withText('Shortname').nth(19).find('.form-control.svd_editor_control'), '123456789') - .expect(Selector('div').withText('Shortname').nth(19).find('.form-control.svd_editor_control').value).eql('12345'); + await t + .maximizeWindow() + .click(Selector('span').withText('Single-Line Input')) + .click(Selector('.svda_question_action.svd-main-color[data-bind^="key2click, clickNoFocus: function() { onClick($par"][title="Edit"]').find('span').withText('Edit')) + .expect(Selector('#editor_tab_id_general').find('label').withText('Shortname').innerText).eql('Shortname') + .click(Selector('div').withText('Shortname').nth(19).find('.form-control.svd_editor_control')) + .typeText(Selector('div').withText('Shortname').nth(19).find('.form-control.svd_editor_control'), '123456789') + .expect(Selector('div').withText('Shortname').nth(19).find('.form-control.svd_editor_control').value).eql('12345'); }); \ No newline at end of file diff --git a/examples/custom_theme.testcafe.js b/examples/custom_theme.testcafe.js index 8be24ff..2f7217b 100644 --- a/examples/custom_theme.testcafe.js +++ b/examples/custom_theme.testcafe.js @@ -1,12 +1,12 @@ -import { Selector } from 'testcafe'; +import { Selector, fixture, test } from 'testcafe'; fixture `custom_theme` - .page `https://surveyjstest.azurewebsites.net/Examples/Survey-Creator?id=editor-custom-theme&theme=default`; + .page `https://surveyjstest.azurewebsites.net/Examples/Survey-Creator?id=editor-custom-theme&theme=default`; test.skip('Survey Creator default theme customization', async t => { - await t - .maximizeWindow() - .expect(Selector('button').withText('Survey Settings').getStyleProperty('background-color')).eql("rgb(127, 240, 127)") - .expect(Selector('span.nav-link').withText('Survey Designer').getStyleProperty('color')).eql("rgb(127, 240, 127)") - .expect(Selector('button').withText('Redo').getStyleProperty('background-color')).eql("rgb(127, 240, 127)"); + await t + .maximizeWindow() + .expect(Selector('button').withText('Survey Settings').getStyleProperty('background-color')).eql('rgb(127, 240, 127)') + .expect(Selector('span.nav-link').withText('Survey Designer').getStyleProperty('color')).eql('rgb(127, 240, 127)') + .expect(Selector('button').withText('Redo').getStyleProperty('background-color')).eql('rgb(127, 240, 127)'); }); \ No newline at end of file diff --git a/examples/custom_widgets.testcafe.js b/examples/custom_widgets.testcafe.js index ef634d4..ad2de97 100644 --- a/examples/custom_widgets.testcafe.js +++ b/examples/custom_widgets.testcafe.js @@ -1,31 +1,31 @@ -import { Selector } from 'testcafe'; +import { Selector, fixture, test } from 'testcafe'; import { acceptCookie, getExampleTabSelector } from '../surveyjstest/helpers'; fixture`custom_widgets` - .page`https://surveyjstest.azurewebsites.net/Examples/Builder?id=customwidgets&platform=reactjs`.beforeEach(async t => { - await acceptCookie(t); - }); + .page`https://surveyjstest.azurewebsites.net/Examples/Builder?id=customwidgets&platform=reactjs`.beforeEach(async t => { + await acceptCookie(t); +}); test('Check custom widgets default tabs', async t => { - await t - .maximizeWindow() - .click(getExampleTabSelector('Code')) - .expect(Selector('code').textContent).contains('const options') - .click(Selector('span').withText('index.html')) - .expect(Selector('code').textContent).contains('ckeditor.js') - .click(Selector('span').withText('package.json')) - .expect(Selector('code').textContent).contains('nouislider') - .expect(Selector('code').textContent).contains('inputmask') - .expect(Selector('code').textContent).contains('jquery') - .expect(Selector('code').textContent).contains('jquery-bar-rating') - .expect(Selector('code').textContent).contains('surveyjs-widgets') - .click(getExampleTabSelector('Documentation')) - .expect(getExampleTabSelector('Documentation').classNames).contains('v2-class---footer-toolbar-item--active') - .expect(Selector('a').withText('this repo to find out more').getAttribute('href')).eql('https://github.com/surveyjs/widgets') - .expect(Selector('a').withText('create a new issue').getAttribute('href')).eql('https://github.com/surveyjs/widgets/issues') - .click(getExampleTabSelector('Result')); - await t - .expect(Selector('span.svc-tabbed-menu-item__text').withText('Designer').visible).ok() - .expect(Selector('span.svc-tabbed-menu-item__text').withText('Preview').visible).ok() - .expect(Selector('span.svc-tabbed-menu-item__text').withText('JSON Editor').visible).ok(); + await t + .maximizeWindow() + .click(getExampleTabSelector('Code')) + .expect(Selector('code').textContent).contains('const options') + .click(Selector('span').withText('index.html')) + .expect(Selector('code').textContent).contains('ckeditor.js') + .click(Selector('span').withText('package.json')) + .expect(Selector('code').textContent).contains('nouislider') + .expect(Selector('code').textContent).contains('inputmask') + .expect(Selector('code').textContent).contains('jquery') + .expect(Selector('code').textContent).contains('jquery-bar-rating') + .expect(Selector('code').textContent).contains('surveyjs-widgets') + .click(getExampleTabSelector('Documentation')) + .expect(getExampleTabSelector('Documentation').classNames).contains('v2-class---footer-toolbar-item--active') + .expect(Selector('a').withText('this repo to find out more').getAttribute('href')).eql('https://github.com/surveyjs/widgets') + .expect(Selector('a').withText('create a new issue').getAttribute('href')).eql('https://github.com/surveyjs/widgets/issues') + .click(getExampleTabSelector('Result')); + await t + .expect(Selector('span.svc-tabbed-menu-item__text').withText('Designer').visible).ok() + .expect(Selector('span.svc-tabbed-menu-item__text').withText('Preview').visible).ok() + .expect(Selector('span.svc-tabbed-menu-item__text').withText('JSON Editor').visible).ok(); }); \ No newline at end of file diff --git a/examples/custom_widgets_single_page.testcafe.js b/examples/custom_widgets_single_page.testcafe.js index ba4e664..2a14ba1 100644 --- a/examples/custom_widgets_single_page.testcafe.js +++ b/examples/custom_widgets_single_page.testcafe.js @@ -1,163 +1,163 @@ -import { Selector } from 'testcafe'; +import { Selector, fixture, test } from 'testcafe'; fixture `custom_widgets_single_page` - .page `https://surveyjstest.azurewebsites.net//Examples/BuilderSinglePage?id=customwidgets&platform=Knockoutjs&theme=default`; + .page `https://surveyjstest.azurewebsites.net//Examples/BuilderSinglePage?id=customwidgets&platform=Knockoutjs&theme=default`; test.skip('Check bar rating in creator', async t => { - await t - .maximizeWindow() - .click(Selector('.svd_toolbox').find('div').withText('Bar rating')) - .click(Selector('.svda_question_action.svd-main-color[data-bind^="key2click, clickNoFocus: function() { onClick($par"][title="Edit"]').find('span')) - .click(Selector('.modal-body.svd_notopbottompaddings').nth(13).find('div').withText('Choices').nth(1)) - .pressKey('backspace') - .typeText(Selector('.form-group').nth(79).find('.form-control.svd_editor_control[data-bind^=\"value: koValue, disable: readOnly, attr: {placehol\"]'), 'first') - .selectText(Selector('.form-group').nth(88).find('.form-control.svd_editor_control[data-bind^=\"value: koValue, disable: readOnly, attr: {placehol\"]'), 1, 0) - .typeText(Selector('.form-group').nth(88).find('.form-control.svd_editor_control[data-bind^=\"value: koValue, disable: readOnly, attr: {placehol\"]'), 'last', { - caretPos: 0 - }) - .click('.btn.btn-default.btn-secondary[data-bind^="click: onOkClick, disable: readOnly, value: $root."]') - .expect(Selector('.item_editable.item_draggable').find('[data-bind="text: text"]').textContent).eql("first") - .click(Selector('span.nav-link').withText('Test Survey')) - .click(Selector('[data-rating-value="last"][data-rating-text="last"]').nth(1)) - .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') - .expect(Selector('td').withText('last').textContent).eql('last') - .expect(Selector('.svd-dark-border-color[data-bind="text: getString(displayValue)"]').textContent).eql('last') - .click(Selector('span.nav-link').withText('Survey Designer')) - .click(Selector('div').withText('fontawesome').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) - .click(Selector('option').withText('fontawesome').nth(0)) - .click(Selector('span.nav-link').withText('Test Survey')) - .click(Selector('.br-widget').nth(1).find('[data-rating-value="last"][data-rating-text="last"]')) - .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') - .expect(Selector('td').withText('last').textContent).eql("last") - .click(Selector('span.nav-link').withText('Survey Designer')) - .click(Selector('div').withText('fontawesome').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) - .click(Selector('option').withText('bars').nth(0)) - .click(Selector('span.nav-link').withText('Test Survey')) - .click(Selector('.br-widget').nth(1).find('[data-rating-value="3"][data-rating-text="3"]')) - .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') - .expect(Selector('.survey-result-value[data-bind="text: getString(value)"]').textContent).eql("3") - .click('.panel.card.svd_content.svd-dark-bg-color') - .click(Selector('span.nav-link').withText('Survey Designer')) - .click(Selector('div').withText('fontawesome').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) - .click(Selector('option').withText('bars').nth(1)) - .click(Selector('span.nav-link').withText('Test Survey')) - .click(Selector('#sq_115').find('[data-rating-value="4"][data-rating-text="4"]')) - .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') - .click(Selector('span.nav-link').withText('JSON Editor')) - .click(Selector('span.nav-link').withText('JSON Editor')) - .doubleClick(Selector('span.nav-link').withText('JSON Editor')) - .click(Selector('span.nav-link').withText('Test Survey')) - .click(Selector('span.nav-link').withText('Survey Designer')) - .click('#sq_118') - .click(Selector('div').withText('fontawesome').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) - .click(Selector('option').withText('bars').nth(2)) - .click(Selector('span.nav-link').withText('Test Survey')) - .click(Selector('#sq_123').find('[data-rating-value="3"][data-rating-text="3"]')) - .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') - .expect(Selector('.survey-result-value[data-bind="text: getString(value)"]').textContent).eql("3") - .click(Selector('span.nav-link').withText('Survey Designer')) - .click(Selector('div').withText('fontawesome').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) - .click(Selector('span.nav-link').withText('Test Survey')) - .click(Selector('#sq_125').find('[data-rating-value="3"][data-rating-text="3"]')) - .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') - .expect(Selector('.survey-result-value[data-bind="text: getString(value)"]').textContent).eql("3") - .click(Selector('span.nav-link').withText('Survey Designer')) - .click(Selector('div').withText('fontawesome').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) - .click(Selector('option').withText('bars').nth(3)) - .click(Selector('span.nav-link').withText('Test Survey')) - .click(Selector('.br-widget').nth(1).find('[data-rating-value="first"][data-rating-text="first"]')) - .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') - .expect(Selector('.survey-result-value[data-bind="text: getString(value)"]').textContent).eql("first") - .click(Selector('span.nav-link').withText('Survey Designer')) - .click(Selector('div').withText('fontawesome').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) - .click(Selector('option').withText('fontawesome').nth(1)) - .click(Selector('span.nav-link').withText('Test Survey')) - .click(Selector('[data-rating-value="last"][data-rating-text="last"]').nth(1)) - .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') - .expect(Selector('td').withText('last').textContent).eql("last") - .click(Selector('span.nav-link').withText('JSON Editor')) - .expect(Selector('#surveyjsJSONEditor').find('.ace_content').textContent).contains('fontawesome-stars-o'); + await t + .maximizeWindow() + .click(Selector('.svd_toolbox').find('div').withText('Bar rating')) + .click(Selector('.svda_question_action.svd-main-color[data-bind^="key2click, clickNoFocus: function() { onClick($par"][title="Edit"]').find('span')) + .click(Selector('.modal-body.svd_notopbottompaddings').nth(13).find('div').withText('Choices').nth(1)) + .pressKey('backspace') + .typeText(Selector('.form-group').nth(79).find('.form-control.svd_editor_control[data-bind^=\"value: koValue, disable: readOnly, attr: {placehol\"]'), 'first') + .selectText(Selector('.form-group').nth(88).find('.form-control.svd_editor_control[data-bind^=\"value: koValue, disable: readOnly, attr: {placehol\"]'), 1, 0) + .typeText(Selector('.form-group').nth(88).find('.form-control.svd_editor_control[data-bind^=\"value: koValue, disable: readOnly, attr: {placehol\"]'), 'last', { + caretPos: 0 + }) + .click('.btn.btn-default.btn-secondary[data-bind^="click: onOkClick, disable: readOnly, value: $root."]') + .expect(Selector('.item_editable.item_draggable').find('[data-bind="text: text"]').textContent).eql('first') + .click(Selector('span.nav-link').withText('Test Survey')) + .click(Selector('[data-rating-value="last"][data-rating-text="last"]').nth(1)) + .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') + .expect(Selector('td').withText('last').textContent).eql('last') + .expect(Selector('.svd-dark-border-color[data-bind="text: getString(displayValue)"]').textContent).eql('last') + .click(Selector('span.nav-link').withText('Survey Designer')) + .click(Selector('div').withText('fontawesome').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) + .click(Selector('option').withText('fontawesome').nth(0)) + .click(Selector('span.nav-link').withText('Test Survey')) + .click(Selector('.br-widget').nth(1).find('[data-rating-value="last"][data-rating-text="last"]')) + .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') + .expect(Selector('td').withText('last').textContent).eql('last') + .click(Selector('span.nav-link').withText('Survey Designer')) + .click(Selector('div').withText('fontawesome').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) + .click(Selector('option').withText('bars').nth(0)) + .click(Selector('span.nav-link').withText('Test Survey')) + .click(Selector('.br-widget').nth(1).find('[data-rating-value="3"][data-rating-text="3"]')) + .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') + .expect(Selector('.survey-result-value[data-bind="text: getString(value)"]').textContent).eql('3') + .click('.panel.card.svd_content.svd-dark-bg-color') + .click(Selector('span.nav-link').withText('Survey Designer')) + .click(Selector('div').withText('fontawesome').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) + .click(Selector('option').withText('bars').nth(1)) + .click(Selector('span.nav-link').withText('Test Survey')) + .click(Selector('#sq_115').find('[data-rating-value="4"][data-rating-text="4"]')) + .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') + .click(Selector('span.nav-link').withText('JSON Editor')) + .click(Selector('span.nav-link').withText('JSON Editor')) + .doubleClick(Selector('span.nav-link').withText('JSON Editor')) + .click(Selector('span.nav-link').withText('Test Survey')) + .click(Selector('span.nav-link').withText('Survey Designer')) + .click('#sq_118') + .click(Selector('div').withText('fontawesome').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) + .click(Selector('option').withText('bars').nth(2)) + .click(Selector('span.nav-link').withText('Test Survey')) + .click(Selector('#sq_123').find('[data-rating-value="3"][data-rating-text="3"]')) + .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') + .expect(Selector('.survey-result-value[data-bind="text: getString(value)"]').textContent).eql('3') + .click(Selector('span.nav-link').withText('Survey Designer')) + .click(Selector('div').withText('fontawesome').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) + .click(Selector('span.nav-link').withText('Test Survey')) + .click(Selector('#sq_125').find('[data-rating-value="3"][data-rating-text="3"]')) + .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') + .expect(Selector('.survey-result-value[data-bind="text: getString(value)"]').textContent).eql('3') + .click(Selector('span.nav-link').withText('Survey Designer')) + .click(Selector('div').withText('fontawesome').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) + .click(Selector('option').withText('bars').nth(3)) + .click(Selector('span.nav-link').withText('Test Survey')) + .click(Selector('.br-widget').nth(1).find('[data-rating-value="first"][data-rating-text="first"]')) + .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') + .expect(Selector('.survey-result-value[data-bind="text: getString(value)"]').textContent).eql('first') + .click(Selector('span.nav-link').withText('Survey Designer')) + .click(Selector('div').withText('fontawesome').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) + .click(Selector('option').withText('fontawesome').nth(1)) + .click(Selector('span.nav-link').withText('Test Survey')) + .click(Selector('[data-rating-value="last"][data-rating-text="last"]').nth(1)) + .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') + .expect(Selector('td').withText('last').textContent).eql('last') + .click(Selector('span.nav-link').withText('JSON Editor')) + .expect(Selector('#surveyjsJSONEditor').find('.ace_content').textContent).contains('fontawesome-stars-o'); }); test('Check date picker in creator', async t => { - await t - .maximizeWindow(); + await t + .maximizeWindow(); }); test.skip('Check nouislider in creator', async t => { - await t - .maximizeWindow() - .click(Selector('.svd_toolbox').find('div').withText('noUiSlider')) - .click(Selector('span.nav-link').withText('Test Survey')) - .wait(1000) - .click(Selector('#sq_106').find('.noUi-connect')) - .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') - .expect(Selector('.survey-result-value[data-bind="text: getString(value)"]').textContent).eql("25.00"); + await t + .maximizeWindow() + .click(Selector('.svd_toolbox').find('div').withText('noUiSlider')) + .click(Selector('span.nav-link').withText('Test Survey')) + .wait(1000) + .click(Selector('#sq_106').find('.noUi-connect')) + .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') + .expect(Selector('.survey-result-value[data-bind="text: getString(value)"]').textContent).eql('25.00'); }); test.skip('Check tagbox in creator', async t => { - await t - .maximizeWindow() - .click(Selector('.svd_toolbox').find('div').withText('Tag box')) - .click(Selector('a').withText('Items').find('[data-bind="text: koText"]')) - .selectText(Selector('.form-group').nth(4).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]'), 6, 0) - .typeText(Selector('.form-group').nth(4).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]'), '1', { - caretPos: 0 - }) - .click(Selector('.form-group').nth(5).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]')) - .typeText(Selector('.form-group').nth(5).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]'), 'First') - .click(Selector('.modal-footer').find('.btn.btn-primary[data-bind^="visible: $data.koShowApplyButton, disable: readOnl"]')) - .click(Selector('.modal-footer').find('.btn.btn-default.btn-secondary[data-bind^="click: $data.onOkClick, disable: readOnly, value: "]')) - .click(Selector('span.nav-link').withText('Test Survey')) - .click(Selector('#sq_107').find('.select2-selection__rendered')) - .click(Selector('li').withText('First')) - .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') - .expect(Selector('td').withText('First').textContent).eql("First") - .expect(Selector('.survey-result-value[data-bind="text: getString(value)"]').textContent).eql("[\"1\"]"); + await t + .maximizeWindow() + .click(Selector('.svd_toolbox').find('div').withText('Tag box')) + .click(Selector('a').withText('Items').find('[data-bind="text: koText"]')) + .selectText(Selector('.form-group').nth(4).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]'), 6, 0) + .typeText(Selector('.form-group').nth(4).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]'), '1', { + caretPos: 0 + }) + .click(Selector('.form-group').nth(5).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]')) + .typeText(Selector('.form-group').nth(5).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]'), 'First') + .click(Selector('.modal-footer').find('.btn.btn-primary[data-bind^="visible: $data.koShowApplyButton, disable: readOnl"]')) + .click(Selector('.modal-footer').find('.btn.btn-default.btn-secondary[data-bind^="click: $data.onOkClick, disable: readOnly, value: "]')) + .click(Selector('span.nav-link').withText('Test Survey')) + .click(Selector('#sq_107').find('.select2-selection__rendered')) + .click(Selector('li').withText('First')) + .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') + .expect(Selector('td').withText('First').textContent).eql('First') + .expect(Selector('.survey-result-value[data-bind="text: getString(value)"]').textContent).eql('["1"]'); }); test.skip('Check sortable list in creator', async t => { - await t - .maximizeWindow() - .click(Selector('.svd_toolbox').find('div').withText('Sortable list')) - .click(Selector('a').withText('Items').find('[data-bind="text: koText"]')) - .pressKey('left') - .pressKey('backspace backspace backspace backspace backspace backspace backspace backspace backspace backspace backspace backspace backspace') - .click(Selector('.form-group').nth(5).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]')) - .typeText(Selector('.form-group').nth(5).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]'), 'first') - .click(Selector('.modal-footer').find('.btn.btn-primary[data-bind^="visible: $data.koShowApplyButton, disable: readOnl"]')) - .click(Selector('.modal-footer').find('.btn.btn-default.btn-secondary[data-bind^="click: $data.onOkClick, disable: readOnly, value: "]')) - .click(Selector('span.nav-link').withText('Test Survey')) - .drag(Selector('[data-value="1"]').nth(1).find('div').withText('first'), 3, -56, { - offsetX: 102, - offsetY: 19 - }) - .wait(1000) - .click('[data-bind="css: css.body"].sv_body') - .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') - .expect(Selector('.survey-result-value[data-bind="text: getString(value)"]').textContent).eql("[\"1\"]") - .expect(Selector('td').withText('first').textContent).eql("first"); + await t + .maximizeWindow() + .click(Selector('.svd_toolbox').find('div').withText('Sortable list')) + .click(Selector('a').withText('Items').find('[data-bind="text: koText"]')) + .pressKey('left') + .pressKey('backspace backspace backspace backspace backspace backspace backspace backspace backspace backspace backspace backspace backspace') + .click(Selector('.form-group').nth(5).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]')) + .typeText(Selector('.form-group').nth(5).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]'), 'first') + .click(Selector('.modal-footer').find('.btn.btn-primary[data-bind^="visible: $data.koShowApplyButton, disable: readOnl"]')) + .click(Selector('.modal-footer').find('.btn.btn-default.btn-secondary[data-bind^="click: $data.onOkClick, disable: readOnly, value: "]')) + .click(Selector('span.nav-link').withText('Test Survey')) + .drag(Selector('[data-value="1"]').nth(1).find('div').withText('first'), 3, -56, { + offsetX: 102, + offsetY: 19 + }) + .wait(1000) + .click('[data-bind="css: css.body"].sv_body') + .click('[data-bind^="value: completeText, click: completeLastPage, visi"].sv_complete_btn') + .expect(Selector('.survey-result-value[data-bind="text: getString(value)"]').textContent).eql('["1"]') + .expect(Selector('td').withText('first').textContent).eql('first'); }); test.skip('Check custrom editor as widget in creator ', async t => { - await t - .maximizeWindow() - .click(Selector('span').withText('Editor')) - .click(Selector('span.nav-link').withText('Test Survey')) - .switchToIframe(Selector('.cke_wysiwyg_frame.cke_reset').nth(1)) - .typeText(Selector('body').find('p'), 'hello') - .switchToMainWindow() - .click('.sv_complete_btn') - .expect(Selector('div').withText('


hello

').nth(8).exists).eql(true); + await t + .maximizeWindow() + .click(Selector('span').withText('Editor')) + .click(Selector('span.nav-link').withText('Test Survey')) + .switchToIframe(Selector('.cke_wysiwyg_frame.cke_reset').nth(1)) + .typeText(Selector('body').find('p'), 'hello') + .switchToMainWindow() + .click('.sv_complete_btn') + .expect(Selector('div').withText('


hello

').nth(8).exists).eql(true); }); test('Check microphone in creator', async t => { - await t - .maximizeWindow() - .click(Selector('span').withText('Microphone')) - .click(Selector('span.nav-link').withText('Test Survey')) - .expect(Selector('button[title=\"Record\"]').exists).eql(true) - .expect(Selector('audio').exists).eql(true); + await t + .maximizeWindow() + .click(Selector('span').withText('Microphone')) + .click(Selector('span.nav-link').withText('Test Survey')) + .expect(Selector('button[title=\"Record\"]').exists).eql(true) + .expect(Selector('audio').exists).eql(true); }); test('Check bootstrap datepicker', async t => {}); \ No newline at end of file diff --git a/examples/depends_on_properties.testcafe.js b/examples/depends_on_properties.testcafe.js index 4c4f173..42cb7a0 100644 --- a/examples/depends_on_properties.testcafe.js +++ b/examples/depends_on_properties.testcafe.js @@ -1,19 +1,19 @@ -import { Selector } from 'testcafe'; +import { Selector, fixture, test } from 'testcafe'; import { getExampleTabSelector, acceptCookie } from '../surveyjstest/helpers'; fixture `depends_on_properties` - .page `https://surveyjstest.azurewebsites.net/Examples/Builder?id=dependsonproperties&platform=Knockoutjs&theme=default`.beforeEach(async t => { - await acceptCookie(t); - }); + .page `https://surveyjstest.azurewebsites.net/Examples/Builder?id=dependsonproperties&platform=Knockoutjs&theme=default`.beforeEach(async t => { + await acceptCookie(t); +}); test('Check default tabs', async t => { - await t - .maximizeWindow() - .expect(Selector('span.nav-link').withText('Survey Designer').visible).ok() - .expect(Selector('span.nav-link').withText('Test Survey').visible).ok() - .expect(Selector('span.nav-link').withText('JSON Editor').visible).ok() - .click(getExampleTabSelector('Code')) - .expect(Selector('code').textContent).contains('Populate countries depending on the selected region') - .click(Selector('span').withText('index.html')) - .expect(Selector('code').textContent).contains('id="surveyCreatorContainer"'); + await t + .maximizeWindow() + .expect(Selector('span.nav-link').withText('Survey Designer').visible).ok() + .expect(Selector('span.nav-link').withText('Test Survey').visible).ok() + .expect(Selector('span.nav-link').withText('JSON Editor').visible).ok() + .click(getExampleTabSelector('Code')) + .expect(Selector('code').textContent).contains('Populate countries depending on the selected region') + .click(Selector('span').withText('index.html')) + .expect(Selector('code').textContent).contains('id="surveyCreatorContainer"'); }); \ No newline at end of file diff --git a/examples/depends_on_single_page.testcafe.js b/examples/depends_on_single_page.testcafe.js index 5c7e1b2..df8f1d3 100644 --- a/examples/depends_on_single_page.testcafe.js +++ b/examples/depends_on_single_page.testcafe.js @@ -1,72 +1,72 @@ -import { Selector } from 'testcafe'; +import { Selector, fixture, test } from 'testcafe'; fixture `depends_on_single_page` - .page `https://surveyjstest.azurewebsites.net//Examples/CreatorSinglePage?id=dependsonproperties&theme=default`; + .page `https://surveyjstest.azurewebsites.net//Examples/CreatorSinglePage?id=dependsonproperties&theme=default`; test.skip('Check survey properties', async t => { - await t - .maximizeWindow() - .click(Selector('#svd-survey-settings').find('span').withText('Survey Settings')) - .wait(1000) - .click(Selector('#editor_tab_id_general').find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').nth(3)) - .click(Selector('#editor_tab_id_general').find('option').withText('Asia')) - .expect(Selector('div').withText('Afghanistan').nth(22).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').textContent).eql("AfghanistanArmeniaAzerbaijanBahrainBangladeshBhutanBrunei DarussalamCambodiaChinaGeorgiaHong KongIndiaIndonesiaIran (Islamic Republic of)IraqIsraelJapanJordanKazakhstanKuwaitKyrgyzstanLao People's Democratic RepublicLebanonMacaoMalaysiaMaldivesMongoliaMyanmarNepalKorea (Democratic People's Republic of)OmanPakistanPalestine, State ofPhilippinesQatarSaudi ArabiaSingaporeKorea (Republic of)Sri LankaSyrian Arab RepublicTaiwanTajikistanThailandTimor-LesteTurkeyTurkmenistanUnited Arab EmiratesUzbekistanViet NamYemen") - .click(Selector('div').withText('Afghanistan').nth(22).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) - .click(Selector('#editor_tab_id_general').find('option').withText('Armenia')) - .click('.btn.btn-primary[data-bind^="visible: koShowApplyButton, disable: readOnly, cli"]') - .click('.btn.btn-default.btn-secondary[data-bind^="click: onOkClick, disable: readOnly, value: $root."]') - .expect(Selector('div').withText('Africa').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').value).eql("Asia") - .click(Selector('button').withText('Survey Settings')) - .click(Selector('div').withText('Africa').nth(22).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) - .click(Selector('#editor_tab_id_general').find('option').withText('Europe')) - .click(Selector('div').withText('Åland Islands').nth(14).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) - .click(Selector('option').withText('Russian Federation')) - .expect(Selector('div').withText('Åland Islands').nth(14).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').textContent).eql("Åland IslandsAlbaniaAndorraAustriaBelarusBelgiumBosnia and HerzegovinaBulgariaCroatiaCyprusCzech RepublicDenmarkEstoniaFaroe IslandsFinlandFranceGermanyGibraltarGreeceGuernseyHoly SeeHungaryIcelandIrelandIsle of ManItalyJerseyLatviaLiechtensteinLithuaniaLuxembourgMacedonia (the former Yugoslav Republic of)MaltaMoldova (Republic of)MonacoMontenegroNetherlandsNorwayPolandPortugalRepublic of KosovoRomaniaRussian FederationSan MarinoSerbiaSlovakiaSloveniaSpainSvalbard and Jan MayenSwedenSwitzerlandUkraineUnited Kingdom of Great Britain and Northern Ireland") - .click('.btn.btn-primary[data-bind^="visible: koShowApplyButton, disable: readOnly, cli"]') - .click('.btn.btn-default.btn-secondary[data-bind^="click: onOkClick, disable: readOnly, value: $root."]'); + await t + .maximizeWindow() + .click(Selector('#svd-survey-settings').find('span').withText('Survey Settings')) + .wait(1000) + .click(Selector('#editor_tab_id_general').find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').nth(3)) + .click(Selector('#editor_tab_id_general').find('option').withText('Asia')) + .expect(Selector('div').withText('Afghanistan').nth(22).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').textContent).eql("AfghanistanArmeniaAzerbaijanBahrainBangladeshBhutanBrunei DarussalamCambodiaChinaGeorgiaHong KongIndiaIndonesiaIran (Islamic Republic of)IraqIsraelJapanJordanKazakhstanKuwaitKyrgyzstanLao People's Democratic RepublicLebanonMacaoMalaysiaMaldivesMongoliaMyanmarNepalKorea (Democratic People's Republic of)OmanPakistanPalestine, State ofPhilippinesQatarSaudi ArabiaSingaporeKorea (Republic of)Sri LankaSyrian Arab RepublicTaiwanTajikistanThailandTimor-LesteTurkeyTurkmenistanUnited Arab EmiratesUzbekistanViet NamYemen") + .click(Selector('div').withText('Afghanistan').nth(22).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) + .click(Selector('#editor_tab_id_general').find('option').withText('Armenia')) + .click('.btn.btn-primary[data-bind^="visible: koShowApplyButton, disable: readOnly, cli"]') + .click('.btn.btn-default.btn-secondary[data-bind^="click: onOkClick, disable: readOnly, value: $root."]') + .expect(Selector('div').withText('Africa').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').value).eql('Asia') + .click(Selector('button').withText('Survey Settings')) + .click(Selector('div').withText('Africa').nth(22).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) + .click(Selector('#editor_tab_id_general').find('option').withText('Europe')) + .click(Selector('div').withText('Åland Islands').nth(14).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) + .click(Selector('option').withText('Russian Federation')) + .expect(Selector('div').withText('Åland Islands').nth(14).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').textContent).eql('Åland IslandsAlbaniaAndorraAustriaBelarusBelgiumBosnia and HerzegovinaBulgariaCroatiaCyprusCzech RepublicDenmarkEstoniaFaroe IslandsFinlandFranceGermanyGibraltarGreeceGuernseyHoly SeeHungaryIcelandIrelandIsle of ManItalyJerseyLatviaLiechtensteinLithuaniaLuxembourgMacedonia (the former Yugoslav Republic of)MaltaMoldova (Republic of)MonacoMontenegroNetherlandsNorwayPolandPortugalRepublic of KosovoRomaniaRussian FederationSan MarinoSerbiaSlovakiaSloveniaSpainSvalbard and Jan MayenSwedenSwitzerlandUkraineUnited Kingdom of Great Britain and Northern Ireland') + .click('.btn.btn-primary[data-bind^="visible: koShowApplyButton, disable: readOnly, cli"]') + .click('.btn.btn-default.btn-secondary[data-bind^="click: onOkClick, disable: readOnly, value: $root."]'); }); test.skip('Check question properties', async t => { - await t - .maximizeWindow() - .click(Selector('span').withText('Checkbox')) - .click(Selector('.svda_question_action.svd-main-color[data-bind^="key2click, clickNoFocus: function() { onClick($par"][title="Edit"]').find('span').withText('Edit')) - .click(Selector('#surveyquestioneditorwindow').find('div').withText('Depends On').nth(4)) - .click(Selector('#editor_tab_id_dependsOn').find('div').find('div').find('div').find('div').nth(1).find('select')) - .click(Selector('#editor_tab_id_dependsOn').find('option').withText('Developement').nth(0)) - .expect(Selector('div').withText('Developement 1').nth(14).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').textContent).eql("Developement 1Developement 2Developement 3") - .click(Selector('div').withText('Developement 1').nth(14).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) - .click(Selector('option').withText('Developement 2')) - .click('.btn.btn-primary[data-bind^="visible: koShowApplyButton, disable: readOnly, cli"]') - .click('.btn.btn-default.btn-secondary[data-bind^="click: onOkClick, disable: readOnly, value: $root."]') - .expect(Selector('div').withText('Account').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').value).eql("Developement") - .expect(Selector('div').withText('Developement 1').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').value).eql("Developement 2") - .click(Selector('div').withText('Account').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) - .click(Selector('#creatorElement').find('option').withText('Account').nth(0)) - .expect(Selector('div').withText('Account 1').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').textContent).eql("Account 1Account 2Account 3") - .click(Selector('div').withText('Account 1').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) - .click(Selector('option').withText('Account 2')) - .click(Selector('.svda_question_action.svd-main-color[data-bind^="key2click, clickNoFocus: function() { onClick($par"][title="Edit"]').find('span').withText('Edit')) - .click(Selector('.modal-body.svd_notopbottompaddings').nth(13).find('div').withText('Depends On').nth(1)) - .expect(Selector('div').withText('Account 1').nth(22).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').value).eql("Account 2") - .click('.btn.btn-default.btn-secondary[data-bind^="click: onOkClick, disable: readOnly, value: $root."]'); + await t + .maximizeWindow() + .click(Selector('span').withText('Checkbox')) + .click(Selector('.svda_question_action.svd-main-color[data-bind^="key2click, clickNoFocus: function() { onClick($par"][title="Edit"]').find('span').withText('Edit')) + .click(Selector('#surveyquestioneditorwindow').find('div').withText('Depends On').nth(4)) + .click(Selector('#editor_tab_id_dependsOn').find('div').find('div').find('div').find('div').nth(1).find('select')) + .click(Selector('#editor_tab_id_dependsOn').find('option').withText('Developement').nth(0)) + .expect(Selector('div').withText('Developement 1').nth(14).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').textContent).eql('Developement 1Developement 2Developement 3') + .click(Selector('div').withText('Developement 1').nth(14).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) + .click(Selector('option').withText('Developement 2')) + .click('.btn.btn-primary[data-bind^="visible: koShowApplyButton, disable: readOnly, cli"]') + .click('.btn.btn-default.btn-secondary[data-bind^="click: onOkClick, disable: readOnly, value: $root."]') + .expect(Selector('div').withText('Account').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').value).eql('Developement') + .expect(Selector('div').withText('Developement 1').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').value).eql('Developement 2') + .click(Selector('div').withText('Account').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) + .click(Selector('#creatorElement').find('option').withText('Account').nth(0)) + .expect(Selector('div').withText('Account 1').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').textContent).eql('Account 1Account 2Account 3') + .click(Selector('div').withText('Account 1').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) + .click(Selector('option').withText('Account 2')) + .click(Selector('.svda_question_action.svd-main-color[data-bind^="key2click, clickNoFocus: function() { onClick($par"][title="Edit"]').find('span').withText('Edit')) + .click(Selector('.modal-body.svd_notopbottompaddings').nth(13).find('div').withText('Depends On').nth(1)) + .expect(Selector('div').withText('Account 1').nth(22).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').value).eql('Account 2') + .click('.btn.btn-default.btn-secondary[data-bind^="click: onOkClick, disable: readOnly, value: $root."]'); }); test.skip('Check single input properties', async t => { - await t - .maximizeWindow() - .click(Selector('.svd_toolbox').find('div').withText('Single-Line Input')) - .click(Selector('.svd-svg-icon').nth(34).find('use')) - .click(Selector('#editor_tab_id_general').find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) - .click(Selector('#editor_tab_id_general').find('option').withText('datetime').nth(0)) - .typeText(Selector('div').withText('Date Format').nth(13).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]'), 'mm/dd/yy') - .click(Selector('div').withText('Date Format').nth(13).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]')) - .expect(Selector('div').withText('Date Format').nth(13).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]').value).eql('mm/dd/yy') - .click(Selector('#editor_tab_id_general').find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) - .click(Selector('#editor_tab_id_general').find('option').withText('color')) - .expect(Selector('div').withText('dateFormat').nth(13).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]').exists).eql(false) - .click('.btn.btn-default.btn-secondary[data-bind^="click: onOkClick, disable: readOnly, value: $root."]') - .click(Selector('div').withText('color').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) - .click(Selector('option').withText('date').nth(0)) - .expect(Selector('[data-bind="event: { keydown: $data.editor.keyDownHandler }"]').nth(1).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]').exists).eql(true); + await t + .maximizeWindow() + .click(Selector('.svd_toolbox').find('div').withText('Single-Line Input')) + .click(Selector('.svd-svg-icon').nth(34).find('use')) + .click(Selector('#editor_tab_id_general').find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) + .click(Selector('#editor_tab_id_general').find('option').withText('datetime').nth(0)) + .typeText(Selector('div').withText('Date Format').nth(13).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]'), 'mm/dd/yy') + .click(Selector('div').withText('Date Format').nth(13).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]')) + .expect(Selector('div').withText('Date Format').nth(13).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]').value).eql('mm/dd/yy') + .click(Selector('#editor_tab_id_general').find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) + .click(Selector('#editor_tab_id_general').find('option').withText('color')) + .expect(Selector('div').withText('dateFormat').nth(13).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]').exists).eql(false) + .click('.btn.btn-default.btn-secondary[data-bind^="click: onOkClick, disable: readOnly, value: $root."]') + .click(Selector('div').withText('color').nth(10).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]')) + .click(Selector('option').withText('date').nth(0)) + .expect(Selector('[data-bind="event: { keydown: $data.editor.keyDownHandler }"]').nth(1).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]').exists).eql(true); }); \ No newline at end of file diff --git a/examples/editor_options.testcafe.js b/examples/editor_options.testcafe.js index 3659676..1ee172b 100644 --- a/examples/editor_options.testcafe.js +++ b/examples/editor_options.testcafe.js @@ -1,13 +1,13 @@ -import { Selector } from 'testcafe'; +import { Selector, fixture, test } from 'testcafe'; fixture `Editor Options` - .page `https://surveyjstest.azurewebsites.net/Examples/Builder?id=options&platform=Knockoutjs&theme=default`; + .page `https://surveyjstest.azurewebsites.net/Examples/Builder?id=options&platform=Knockoutjs&theme=default`; test('Show default tabs', async t => { - await t - .maximizeWindow() - .expect(Selector('.panel.card.svd_content.svd-dark-bg-color').exists).eql(true) - .expect(Selector('span.nav-link').withText('Survey Designer').innerText).eql('Survey Designer') - .expect(Selector('span.nav-link').withText('Test Survey').exists).eql(true) - .expect(Selector('span.nav-link').withText('Survey Logic').exists).eql(true); + await t + .maximizeWindow() + .expect(Selector('.panel.card.svd_content.svd-dark-bg-color').exists).eql(true) + .expect(Selector('span.nav-link').withText('Survey Designer').innerText).eql('Survey Designer') + .expect(Selector('span.nav-link').withText('Test Survey').exists).eql(true) + .expect(Selector('span.nav-link').withText('Survey Logic').exists).eql(true); }); \ No newline at end of file diff --git a/examples/editor_options_singlepage.testcafe.js b/examples/editor_options_singlepage.testcafe.js index 7954a3e..da7975d 100644 --- a/examples/editor_options_singlepage.testcafe.js +++ b/examples/editor_options_singlepage.testcafe.js @@ -1,67 +1,67 @@ -import { Selector, ClientFunction } from 'testcafe'; +import { Selector, ClientFunction, fixture, test } from 'testcafe'; fixture `editor_options_singlepage` - .page `https://surveyjstest.azurewebsites.net//Examples/CreatorSinglePage?id=options&platform=Knockoutjs&theme=default`; + .page `https://surveyjstest.azurewebsites.net//Examples/CreatorSinglePage?id=options&platform=Knockoutjs&theme=default`; test('Check editor works after JSON Editor tab hidden', async t => { - const toolboxSingleInput = Selector('span.svd_toolbox_item_text').withText('Single Input'); + const toolboxSingleInput = Selector('span.svd_toolbox_item_text').withText('Single Input'); - await t - .maximizeWindow() - .expect(Selector('span.sv-string-viewer').withText("question1").exists).eql(false) - .click(Selector('input[value="showTestSurveyTab"]')) - .expect(Selector('span.nav-link').withText('JSON Editor').exists).eql(false) - .expect(Selector('span.nav-link').withText('Test Survey').exists).eql(false) - .expect(toolboxSingleInput.exists).eql(true) - .click(toolboxSingleInput) - .expect(Selector('span.sv-string-viewer').withText("question1").exists).eql(true); + await t + .maximizeWindow() + .expect(Selector('span.sv-string-viewer').withText('question1').exists).eql(false) + .click(Selector('input[value="showTestSurveyTab"]')) + .expect(Selector('span.nav-link').withText('JSON Editor').exists).eql(false) + .expect(Selector('span.nav-link').withText('Test Survey').exists).eql(false) + .expect(toolboxSingleInput.exists).eql(true) + .click(toolboxSingleInput) + .expect(Selector('span.sv-string-viewer').withText('question1').exists).eql(true); }); test('Show Embed Survey tab', async t => { - await t - .click(Selector('input[value="showEmbeddedSurveyTab"]')) - .expect(Selector('span.nav-link').withText('Embed Survey').exists).eql(true); + await t + .click(Selector('input[value="showEmbeddedSurveyTab"]')) + .expect(Selector('span.nav-link').withText('Embed Survey').exists).eql(true); }); test('Show Translation tab', async t => { - await t - .click(Selector('input[value="showTranslationTab"]')) - .expect(Selector('span.nav-link').withText('Translation').exists).eql(true); + await t + .click(Selector('input[value="showTranslationTab"]')) + .expect(Selector('span.nav-link').withText('Translation').exists).eql(true); }); test('Hide/Show JSON Editor tab', async t => { - await t - .expect(Selector('span.nav-link').withText('JSON Editor').exists).eql(false) - .click(Selector('input[value="showJSONEditorTab"]')) - .expect(Selector('span.nav-link').withText('JSON Editor').exists).eql(true) - .click(Selector('input[value="showJSONEditorTab"]')) - .expect(Selector('span.nav-link').withText('JSON Editor').exists).eql(false); + await t + .expect(Selector('span.nav-link').withText('JSON Editor').exists).eql(false) + .click(Selector('input[value="showJSONEditorTab"]')) + .expect(Selector('span.nav-link').withText('JSON Editor').exists).eql(true) + .click(Selector('input[value="showJSONEditorTab"]')) + .expect(Selector('span.nav-link').withText('JSON Editor').exists).eql(false); }); test('Set generate JSON valid option false', async t => { - await t - .click(Selector('input[value="showJSONEditorTab"]')) - .click(Selector('span.nav-link').withText('JSON Editor')) - .expect(Selector('textarea').innerText).notContains('\"pages\"'); + await t + .click(Selector('input[value="showJSONEditorTab"]')) + .click(Selector('span.nav-link').withText('JSON Editor')) + .expect(Selector('textarea').innerText).notContains('\"pages\"'); }); test('Hide Test Survey tab', async t => { - await t - .expect(Selector('span.nav-link').withText('Test Survey').exists).eql(true) - .click(Selector('input[value="showTestSurveyTab"]')) - .expect(Selector('span.nav-link').withText('Test Survey').exists).eql(false); + await t + .expect(Selector('span.nav-link').withText('Test Survey').exists).eql(true) + .click(Selector('input[value="showTestSurveyTab"]')) + .expect(Selector('span.nav-link').withText('Test Survey').exists).eql(false); }); test('Change designer height', async t => { - const dummy = ClientFunction(() => { - var creatorOptions = { - designerHeight: '300px' - }; - new SurveyCreator.SurveyCreator('creatorElement', creatorOptions); - return 'dummy'; - }); + const dummy = ClientFunction(() => { + var creatorOptions = { + designerHeight: '300px' + }; + new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions); + return 'dummy'; + }); - await t - .expect(dummy()).eql('dummy') - .expect(Selector('.svd-survey-placeholder').clientHeight).eql(500); + await t + .expect(dummy()).eql('dummy') + .expect(Selector('.svd-survey-placeholder').clientHeight).eql(500); }); \ No newline at end of file diff --git a/examples/element_menu_customization.testcafe.js b/examples/element_menu_customization.testcafe.js index 0f40345..f9c10b9 100644 --- a/examples/element_menu_customization.testcafe.js +++ b/examples/element_menu_customization.testcafe.js @@ -1,21 +1,21 @@ -import { Selector } from "testcafe"; +import { Selector, fixture, test } from 'testcafe'; import { acceptCookie, getExampleTabSelector } from '../surveyjstest/helpers'; fixture`element_menu_customization` .page`https://surveyjstest.azurewebsites.net/Examples/Builder?id=elementmenu&platform=Knockoutjs&theme=default`.beforeEach(async t => { - await acceptCookie(t); + await acceptCookie(t); }); -test("Check default tabs", async (t) => { +test('Check default tabs', async (t) => { await t .maximizeWindow() - .expect(Selector("span.nav-link").withText("Survey Designer").visible).ok() - .expect(Selector("span.nav-link").withText("Test Survey").visible).ok() - .expect(Selector("span.nav-link").withText("JSON Editor").visible).ok() - .click(getExampleTabSelector("Code")) - .expect(Selector("span").withText("SurveyCreator").visible).ok() + .expect(Selector('span.nav-link').withText('Survey Designer').visible).ok() + .expect(Selector('span.nav-link').withText('Test Survey').visible).ok() + .expect(Selector('span.nav-link').withText('JSON Editor').visible).ok() + .click(getExampleTabSelector('Code')) + .expect(Selector('span').withText('SurveyCreator').visible).ok() .click(Selector('span').withText('index.html')) - .expect(Selector("span").withText("
{ - await t - .maximizeWindow() - .click(Selector('#toolboxCustomization').nth(1).find('span').withText('Toolbox Customization')) - .click('#comment') - .click('.modal__button.modal__button--default[data-dismiss="modal"]') - .expect(Selector('[class^="col-lg-2 col-md-2 col-sm-1 col-xs-1 svd_toolbox sv"]').find('div').withText('Comment').exists).eql(false) - .click(Selector('span').withText('Boolean')) - .click(Selector('.svd-primary-icon.icon-actionaddtosharedrepo[data-bind="css: $parent.getStyle($data)"]').find('.svd-svg-icon')) - .click(Selector('#toolboxCustomization').nth(1).find('span').withText('Toolbox Customization')) - .expect(Selector('div').withText('Custom Elements').nth(16).find('.panel__body').exists).eql(true) - .expect(Selector('#toobaritem_question1').find('label').withText('question1').textContent).eql("question1") - .click('#question1') - .click('.modal__button.modal__button--default[data-dismiss="modal"]') - .expect(Selector('.svd_toolbox').find('div').withText('question1').innerText).eql(" question1") - .click(Selector('div').withText('question1').nth(27).find('.svd_toolbox_item_text.hidden-sm.hidden-xs[data-bind="text:title"]')) - .expect(Selector('[class^="col-lg-2 col-md-2 col-sm-1 col-xs-1 svd_toolbox sv"]').find('div').withText('question1').textContent).contains('question1') - .click(Selector('#toolboxCustomization').nth(1).find('span').withText('Toolbox Customization')) - .click(Selector('button').withText('Remove')) - .click('.modal__button.modal__button--default[data-dismiss="modal"]') - .expect(Selector('[class^="col-lg-2 col-md-2 col-sm-1 col-xs-1 svd_toolbox sv"]').find('div').withText('question1').exists).eql(false); + await t + .maximizeWindow() + .click(Selector('#toolboxCustomization').nth(1).find('span').withText('Toolbox Customization')) + .click('#comment') + .click('.modal__button.modal__button--default[data-dismiss="modal"]') + .expect(Selector('[class^="col-lg-2 col-md-2 col-sm-1 col-xs-1 svd_toolbox sv"]').find('div').withText('Comment').exists).eql(false) + .click(Selector('span').withText('Boolean')) + .click(Selector('.svd-primary-icon.icon-actionaddtosharedrepo[data-bind="css: $parent.getStyle($data)"]').find('.svd-svg-icon')) + .click(Selector('#toolboxCustomization').nth(1).find('span').withText('Toolbox Customization')) + .expect(Selector('div').withText('Custom Elements').nth(16).find('.panel__body').exists).eql(true) + .expect(Selector('#toobaritem_question1').find('label').withText('question1').textContent).eql('question1') + .click('#question1') + .click('.modal__button.modal__button--default[data-dismiss="modal"]') + .expect(Selector('.svd_toolbox').find('div').withText('question1').innerText).eql(' question1') + .click(Selector('div').withText('question1').nth(27).find('.svd_toolbox_item_text.hidden-sm.hidden-xs[data-bind="text:title"]')) + .expect(Selector('[class^="col-lg-2 col-md-2 col-sm-1 col-xs-1 svd_toolbox sv"]').find('div').withText('question1').textContent).contains('question1') + .click(Selector('#toolboxCustomization').nth(1).find('span').withText('Toolbox Customization')) + .click(Selector('button').withText('Remove')) + .click('.modal__button.modal__button--default[data-dismiss="modal"]') + .expect(Selector('[class^="col-lg-2 col-md-2 col-sm-1 col-xs-1 svd_toolbox sv"]').find('div').withText('question1').exists).eql(false); }); \ No newline at end of file diff --git a/examples/load_survey_from_service.testcafe.js b/examples/load_survey_from_service.testcafe.js index ac1332f..ac102c1 100644 --- a/examples/load_survey_from_service.testcafe.js +++ b/examples/load_survey_from_service.testcafe.js @@ -1,12 +1,12 @@ -import { Selector } from 'testcafe'; +import { Selector, fixture, test } from 'testcafe'; fixture `load_survey_from_service` - .page `https://surveyjstest.azurewebsites.net/Examples/Builder?id=loadfromservice&platform=Knockoutjs&theme=default`; + .page `https://surveyjstest.azurewebsites.net/Examples/Builder?id=loadfromservice&platform=Knockoutjs&theme=default`; test('Load survey from service', async t => { - await t - .maximizeWindow() - .click(Selector('span.nav-link').withText('JSON Editor')) - //.expect(Selector('.svd-json-editor-area').value).contains('frameworkUsing'); // if ACE not loaded - .expect(Selector('.svd-json-editor').find('.ace_content').textContent).match(/frameworkUsing.*\s*.*mvvmUsing/); // if ACE loaded + await t + .maximizeWindow() + .click(Selector('span.nav-link').withText('JSON Editor')) + //.expect(Selector('.svd-json-editor-area').value).contains('frameworkUsing'); // if ACE not loaded + .expect(Selector('.svd-json-editor').find('.ace_content').textContent).match(/frameworkUsing.*\s*.*mvvmUsing/); // if ACE loaded }); \ No newline at end of file diff --git a/examples/localization.testcafe.js b/examples/localization.testcafe.js index ff96079..ea6fbf6 100644 --- a/examples/localization.testcafe.js +++ b/examples/localization.testcafe.js @@ -1,34 +1,34 @@ -import { Selector } from 'testcafe'; +import { Selector, fixture, test } from 'testcafe'; import { acceptCookie, explicitErrorHandler, getExampleTabSelector } from '../surveyjstest/helpers'; fixture `localization` - .page `https://surveyjstest.azurewebsites.net/survey-creator/examples/survey-creator-interface-localization/knockoutjs` - .clientScripts({ - content: `(${explicitErrorHandler.toString()})()` - }) - .beforeEach(async t => { - await acceptCookie(t); - }); + .page `https://surveyjstest.azurewebsites.net/survey-creator/examples/survey-creator-interface-localization/knockoutjs` + .clientScripts({ + content: `(${explicitErrorHandler.toString()})()` + }) + .beforeEach(async t => { + await acceptCookie(t); + }); test('Check tabs', async t => { - await t - .maximizeWindow() - // .expect(Selector('.svc-tabbed-menu-item__text').withText('Wahrheitswert').visible).ok() - .expect(Selector('.svc-tabbed-menu-item__text').withText('Test').visible).ok() - .expect(Selector('.svc-tabbed-menu-item__text').withText('Logik').visible).ok() - .expect(Selector('.svc-tabbed-menu-item__text').withText('JSON').visible).ok() - .switchToMainWindow() - .expect(getExampleTabSelector('Code').visible).ok() - .click(getExampleTabSelector('Code')) - .expect(Selector('span').withText(' Override individual translations in an existing locale').visible).ok() - - .click(Selector('span').withText('index.html')) - .expect(Selector('pre').withText('id="surveyCreatorContainer"').textContent).contains(" { - await t - .maximizeWindow() - .expect(Selector(".nav-tabs.svd-tabs ").innerText).eql("Umfrage entwerfen Umfrage testen Umfragelogik JSON") - .expect(Selector('.svd-tab-text').withText('Umfrage entwerfen').visible).ok() - .expect(Selector('.svd-tab-text').withText('Umfrage testen').visible).ok() - .expect(Selector('.svd-tab-text').withText('Umfragelogik').visible).ok() - .expect(Selector('.svd-tab-text').withText('JSON').visible).ok() - .expect(Selector('.svd-empty-message').textContent).eql("Frage bitte hier platzieren.") - .expect(Selector(".svd-toolbar-dropdown__select").filterVisible().nth(0).textContent).contains("Seite1Neue Seite hinzufügen"); + await t + .maximizeWindow() + .expect(Selector('.nav-tabs.svd-tabs ').innerText).eql('Umfrage entwerfen Umfrage testen Umfragelogik JSON') + .expect(Selector('.svd-tab-text').withText('Umfrage entwerfen').visible).ok() + .expect(Selector('.svd-tab-text').withText('Umfrage testen').visible).ok() + .expect(Selector('.svd-tab-text').withText('Umfragelogik').visible).ok() + .expect(Selector('.svd-tab-text').withText('JSON').visible).ok() + .expect(Selector('.svd-empty-message').textContent).eql('Frage bitte hier platzieren.') + .expect(Selector('.svd-toolbar-dropdown__select').filterVisible().nth(0).textContent).contains('Seite1Neue Seite hinzufügen'); }); test('Check toolbox names with deutsch', async t => { - await t - .maximizeWindow() - .expect(Selector('.svd_toolbox span').withText('Auswahl').visible).ok() - .expect(Selector('.svd_toolbox span').withText('Kommentar').visible).ok() - .expect(Selector('.svd_toolbox span').withText('Panel (dynamisch)').visible).ok() + await t + .maximizeWindow() + .expect(Selector('.svd_toolbox span').withText('Auswahl').visible).ok() + .expect(Selector('.svd_toolbox span').withText('Kommentar').visible).ok() + .expect(Selector('.svd_toolbox span').withText('Panel (dynamisch)').visible).ok(); }); test('Check property names with deutsch', async t => { - await t - .maximizeWindow() + await t + .maximizeWindow() - .click(Selector(".svd-accordion-tab-header").withText("Allgemein")) - .click(Selector(".svd-accordion-tab-header").withText("Timer")) - .expect(Selector(".svd-control-label").withText("Modus des Timers").visible).ok() + .click(Selector('.svd-accordion-tab-header').withText('Allgemein')) + .click(Selector('.svd-accordion-tab-header').withText('Timer')) + .expect(Selector('.svd-control-label').withText('Modus des Timers').visible).ok() - .click(Selector(".svd-accordion-tab-header").withText("Fragen")) - .expect(Selector(".svd-control-label").withText("Fragennummern anzeigen").visible).ok() + .click(Selector('.svd-accordion-tab-header').withText('Fragen')) + .expect(Selector('.svd-control-label').withText('Fragennummern anzeigen').visible).ok(); - const options = await Selector(".svd-control-label").withText("Fragennummern anzeigen").parent(".form-group").find(".svd-toolbar-dropdown__select").innerText; - await t.expect(options.replace(/\n/g, '_')).eql("an_an (unabhängig für jede Seite)_aus"); + const options = await Selector('.svd-control-label').withText('Fragennummern anzeigen').parent('.form-group').find('.svd-toolbar-dropdown__select').innerText; + await t.expect(options.replace(/\n/g, '_')).eql('an_an (unabhängig für jede Seite)_aus'); }); //You can't recreate the creator, you should do it for the new creator change the locale //creator.locale = "fr"; test.skip('Check custom translation', async t => { - await t - .maximizeWindow(); + await t + .maximizeWindow(); - const changeCurrentLocale = ClientFunction(() => { - //Create your translation - var frenchStrings = { - qt: { comment: "Commentaire" }, - pe: { isRequired: "Est obligatoire ?" }, - ed: { designer: "Éditeur de questionnaire" } - }; + const changeCurrentLocale = ClientFunction(() => { + //Create your translation + var frenchStrings = { + qt: { comment: 'Commentaire' }, + pe: { isRequired: 'Est obligatoire ?' }, + ed: { designer: 'Éditeur de questionnaire' } + }; - //Set the your translation to the locale - SurveyCreator.localization.locales["fr"] = frenchStrings; - SurveyCreator.localization.currentLocale = "fr"; - new SurveyCreator.SurveyCreator("creatorElement"); - return "dummy"; - }); + //Set the your translation to the locale + window.SurveyCreator.localization.locales['fr'] = frenchStrings; + window.SurveyCreator.localization.currentLocale = 'fr'; + new window.SurveyCreator.SurveyCreator('creatorElement'); + return 'dummy'; + }); - await t - .expect(changeCurrentLocale()).eql('dummy') - .expect(Selector('.svd-tab-text').withText('Éditeur de questionnaire').visible).ok() - .expect(Selector('span').withText('Commentaire').visible).ok() - .click(Selector('.svd_toolbox_item').filterVisible().nth(0)) - .expect(Selector('.svda_question_action[title="Est obligatoire ?"]').visible).ok(); + await t + .expect(changeCurrentLocale()).eql('dummy') + .expect(Selector('.svd-tab-text').withText('Éditeur de questionnaire').visible).ok() + .expect(Selector('span').withText('Commentaire').visible).ok() + .click(Selector('.svd_toolbox_item').filterVisible().nth(0)) + .expect(Selector('.svda_question_action[title="Est obligatoire ?"]').visible).ok(); }); \ No newline at end of file diff --git a/examples/modify_new_question.testcafe.js b/examples/modify_new_question.testcafe.js index 357a515..bed424d 100644 --- a/examples/modify_new_question.testcafe.js +++ b/examples/modify_new_question.testcafe.js @@ -1,21 +1,20 @@ -import { Selector } from 'testcafe'; +import { Selector, fixture, test } from 'testcafe'; import { acceptCookie, getExampleTabSelector } from '../surveyjstest/helpers'; fixture`modify_new_question` - .page`https://surveyjstest.azurewebsites.net/Examples/Builder?id=oncreatequestion&platform=Knockoutjs&theme=default`.beforeEach(async t => { - await acceptCookie(t); - });; -; + .page`https://surveyjstest.azurewebsites.net/Examples/Builder?id=oncreatequestion&platform=Knockoutjs&theme=default`.beforeEach(async t => { + await acceptCookie(t); +}); test('Check default tabs', async t => { - await t - .maximizeWindow() - .expect(Selector('span.nav-link').withText('Test Survey').visible).ok() - .click(getExampleTabSelector('Code')) - .expect(Selector('code').textContent).contains('Add a tag property') - .click(Selector('span').withText('index.html')) - .wait(2000) - .expect(Selector('code').textContent).contains('surveyCreatorContainer') - .click(getExampleTabSelector('Documentation')); - //.expect(getExampleTabSelector('Documentation').filterVisible().classNames).contains('tabs__tab--active'); + await t + .maximizeWindow() + .expect(Selector('span.nav-link').withText('Test Survey').visible).ok() + .click(getExampleTabSelector('Code')) + .expect(Selector('code').textContent).contains('Add a tag property') + .click(Selector('span').withText('index.html')) + .wait(2000) + .expect(Selector('code').textContent).contains('surveyCreatorContainer') + .click(getExampleTabSelector('Documentation')); + //.expect(getExampleTabSelector('Documentation').filterVisible().classNames).contains('tabs__tab--active'); }); \ No newline at end of file diff --git a/examples/modify_new_question_single_page.testcafe.js b/examples/modify_new_question_single_page.testcafe.js index 07a0fff..245a754 100644 --- a/examples/modify_new_question_single_page.testcafe.js +++ b/examples/modify_new_question_single_page.testcafe.js @@ -1,29 +1,29 @@ -import { Selector, ClientFunction } from 'testcafe'; +import { Selector, ClientFunction, fixture, test } from 'testcafe'; fixture `modify_new_question_single_page` - .page `https://surveyjstest.azurewebsites.net//Examples/CreatorSinglePage?id=oncreatequestion&theme=default`; + .page `https://surveyjstest.azurewebsites.net//Examples/CreatorSinglePage?id=oncreatequestion&theme=default`; test.skip('Check question properties', async t => { - await t - .maximizeWindow(); + await t + .maximizeWindow(); - const guid = ClientFunction(() => { - window.guid = function (){ - return window.questionCounter; - } - return 'dummy' - }); + const guid = ClientFunction(() => { + window.guid = function () { + return window.questionCounter; + }; + return 'dummy'; + }); - await t - .expect(guid()).eql('dummy') - .click(Selector('#creatorElement').find('div').withText('Single-Line Input').nth(5)) - .expect(Selector('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]').nth(0).value).eql("QuestionText1") - .expect(Selector('[data-bind=\"event: { keydown: $data.editor.keyDownHandler }\"]').nth(17).find('.form-control.svd_editor_control[data-bind^=\"value: koValue, disable: readOnly, attr: {placehol\"]').value).eql("1") - .click(Selector('span').withText('Checkbox')) - .expect(Selector('[data-bind=\"event: { keydown: $data.editor.keyDownHandler }\"]').nth(19).find('.form-control.svd_editor_control[data-bind^=\"value: koValue, disable: readOnly, attr: {placehol\"]').value).eql("QuestionCheckbox2") - .expect(Selector('[data-bind=\"event: { keydown: $data.editor.keyDownHandler }\"]').nth(30).find('.form-control.svd_editor_control[data-bind^=\"value: koValue, disable: readOnly, attr: {placehol\"]').value).eql("2") - .click(Selector('[class^="col-lg-2 col-md-2 col-sm-1 col-xs-1 svd_toolbox sv"]').find('div').withText('Matrix').nth(0)) - .expect(Selector('[data-bind=\"event: { keydown: $data.editor.keyDownHandler }\"]').nth(11).find('.form-control.svd_editor_control[data-bind^=\"value: koValue, disable: readOnly, attr: {placehol\"]').value).eql("QuestionMatrix3") - .expect(Selector('[data-bind=\"event: { keydown: $data.editor.keyDownHandler }\"]').nth(11).find('.form-control.svd_editor_control[data-bind^=\"value: koValue, disable: readOnly, attr: {placehol\"]').getAttribute('disabled')).eql("") - .expect(Selector('[data-bind=\"event: { keydown: $data.editor.keyDownHandler }\"]').nth(21).find('.form-control.svd_editor_control[data-bind^=\"value: koValue, disable: readOnly, attr: {placehol\"]').getAttribute('disabled')).eql(""); + await t + .expect(guid()).eql('dummy') + .click(Selector('#creatorElement').find('div').withText('Single-Line Input').nth(5)) + .expect(Selector('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]').nth(0).value).eql('QuestionText1') + .expect(Selector('[data-bind=\"event: { keydown: $data.editor.keyDownHandler }\"]').nth(17).find('.form-control.svd_editor_control[data-bind^=\"value: koValue, disable: readOnly, attr: {placehol\"]').value).eql('1') + .click(Selector('span').withText('Checkbox')) + .expect(Selector('[data-bind=\"event: { keydown: $data.editor.keyDownHandler }\"]').nth(19).find('.form-control.svd_editor_control[data-bind^=\"value: koValue, disable: readOnly, attr: {placehol\"]').value).eql('QuestionCheckbox2') + .expect(Selector('[data-bind=\"event: { keydown: $data.editor.keyDownHandler }\"]').nth(30).find('.form-control.svd_editor_control[data-bind^=\"value: koValue, disable: readOnly, attr: {placehol\"]').value).eql('2') + .click(Selector('[class^="col-lg-2 col-md-2 col-sm-1 col-xs-1 svd_toolbox sv"]').find('div').withText('Matrix').nth(0)) + .expect(Selector('[data-bind=\"event: { keydown: $data.editor.keyDownHandler }\"]').nth(11).find('.form-control.svd_editor_control[data-bind^=\"value: koValue, disable: readOnly, attr: {placehol\"]').value).eql('QuestionMatrix3') + .expect(Selector('[data-bind=\"event: { keydown: $data.editor.keyDownHandler }\"]').nth(11).find('.form-control.svd_editor_control[data-bind^=\"value: koValue, disable: readOnly, attr: {placehol\"]').getAttribute('disabled')).eql('') + .expect(Selector('[data-bind=\"event: { keydown: $data.editor.keyDownHandler }\"]').nth(21).find('.form-control.svd_editor_control[data-bind^=\"value: koValue, disable: readOnly, attr: {placehol\"]').getAttribute('disabled')).eql(''); }); \ No newline at end of file diff --git a/examples/multiple_languages.testcafe.js b/examples/multiple_languages.testcafe.js index 28b1e55..81cec07 100644 --- a/examples/multiple_languages.testcafe.js +++ b/examples/multiple_languages.testcafe.js @@ -1,27 +1,27 @@ -import { Selector } from 'testcafe'; +import { Selector, fixture, test } from 'testcafe'; fixture `multiple_languages` - .page `https://surveyjstest.azurewebsites.net/Examples/Builder?id=multiplelanguages&theme=default`; + .page `https://surveyjstest.azurewebsites.net/Examples/Builder?id=multiplelanguages&theme=default`; test.skip('Translate matrix', async t => { - await t - .maximizeWindow() - .click(Selector('a').withText('Test Survey')) - .expect(Selector('#sq_135').find('span').withText('Moonlight').innerText).eql('Moonlight') - .expect(Selector('#sq_135').find('span').withText('Zootopia').innerText).eql('Zootopia') - .click('.form-control[data-bind^="options: koLanguages, value: koActiveLanguage, opt"]') - .click(Selector('#testSurveyLocale').find('option').withText('deutsch')) - .expect(Selector('#sq_135').find('span').withText('Moonlight').innerText).eql('Moonlight') - .expect(Selector('span').withText('Zoomania').innerText).eql('Zoomania') - .click(Selector('a').withText('Translation')) - .click(Selector('.icon-toolbox-arrow').find('.svd-svg-icon')) - .click(Selector('#creatorElement').find('span').withText('favoriteMovie')) - .click(Selector('.svd-toolbox-category-header[data-bind^="click: function(){ group.koExpanded(!group.koExpan"]').nth(4).find('span').withText('rows')) - .click(Selector('[data-bind^="visible: $data.koVisible, style: {width: $data.koV"]').nth(9).find('.form-control[data-bind^="visible: $data.koVisible, value:item.koValue($data"]')) - .typeText(Selector('[data-bind^="visible: $data.koVisible, style: {width: $data.koV"]').nth(9).find('.form-control[data-bind^="visible: $data.koVisible, value:item.koValue($data"]'), 'Mondlicht') - .click(Selector('.svd-toolbox-category-header[data-bind^="click: function(){ group.koExpanded(!group.koExpan"]').nth(4).find('span').withText('rows')) - .click(Selector('a').withText('Test Survey')) - .click('.form-control[data-bind^="options: koLanguages, value: koActiveLanguage, opt"]') - .click(Selector('option').withText('deutsch')) - .expect(Selector('span').withText('Mondlicht').innerText).eql('Mondlicht'); + await t + .maximizeWindow() + .click(Selector('a').withText('Test Survey')) + .expect(Selector('#sq_135').find('span').withText('Moonlight').innerText).eql('Moonlight') + .expect(Selector('#sq_135').find('span').withText('Zootopia').innerText).eql('Zootopia') + .click('.form-control[data-bind^="options: koLanguages, value: koActiveLanguage, opt"]') + .click(Selector('#testSurveyLocale').find('option').withText('deutsch')) + .expect(Selector('#sq_135').find('span').withText('Moonlight').innerText).eql('Moonlight') + .expect(Selector('span').withText('Zoomania').innerText).eql('Zoomania') + .click(Selector('a').withText('Translation')) + .click(Selector('.icon-toolbox-arrow').find('.svd-svg-icon')) + .click(Selector('#creatorElement').find('span').withText('favoriteMovie')) + .click(Selector('.svd-toolbox-category-header[data-bind^="click: function(){ group.koExpanded(!group.koExpan"]').nth(4).find('span').withText('rows')) + .click(Selector('[data-bind^="visible: $data.koVisible, style: {width: $data.koV"]').nth(9).find('.form-control[data-bind^="visible: $data.koVisible, value:item.koValue($data"]')) + .typeText(Selector('[data-bind^="visible: $data.koVisible, style: {width: $data.koV"]').nth(9).find('.form-control[data-bind^="visible: $data.koVisible, value:item.koValue($data"]'), 'Mondlicht') + .click(Selector('.svd-toolbox-category-header[data-bind^="click: function(){ group.koExpanded(!group.koExpan"]').nth(4).find('span').withText('rows')) + .click(Selector('a').withText('Test Survey')) + .click('.form-control[data-bind^="options: koLanguages, value: koActiveLanguage, opt"]') + .click(Selector('option').withText('deutsch')) + .expect(Selector('span').withText('Mondlicht').innerText).eql('Mondlicht'); }); \ No newline at end of file diff --git a/examples/open_close_edit_question.testcafe.js b/examples/open_close_edit_question.testcafe.js index 718a1d2..abdc5bd 100644 --- a/examples/open_close_edit_question.testcafe.js +++ b/examples/open_close_edit_question.testcafe.js @@ -1,13 +1,13 @@ -import { Selector } from "testcafe"; +import { Selector, fixture, test } from 'testcafe'; fixture`open_close_edit_question` .page`https://surveyjstest.azurewebsites.net/Examples/CreatorSinglePage?id=options&platform=Knockoutjs&theme=default`; -test("Open close check question title", async (t) => { +test('Open close check question title', async (t) => { await t .maximizeWindow() - .click(Selector(".svd_toolbox").find("div").withText("Single Input")) - .click(Selector("span").withText("question1")) - .pressKey("enter") - .hover(Selector("span").withText("question1")); + .click(Selector('.svd_toolbox').find('div').withText('Single Input')) + .click(Selector('span').withText('question1')) + .pressKey('enter') + .hover(Selector('span').withText('question1')); }); diff --git a/examples/question_editor.testcafe.js b/examples/question_editor.testcafe.js index 032155a..8c7d780 100644 --- a/examples/question_editor.testcafe.js +++ b/examples/question_editor.testcafe.js @@ -1,17 +1,17 @@ -import { Selector } from 'testcafe'; +import { Selector, fixture, test } from 'testcafe'; fixture `question_editor` - .page `https://surveyjstest.azurewebsites.net//Examples/CreatorSinglePage?id=questioneditor&theme=default`; + .page `https://surveyjstest.azurewebsites.net//Examples/CreatorSinglePage?id=questioneditor&theme=default`; test.skip('Add, hide propery to editor modal, change tabs order', async t => { - await t - .maximizeWindow() - .click(Selector('.svd_toolbox').find('div').withText('Single-Line Input')) - .click(Selector('.svda_question_action.svd-main-color[data-bind^="key2click, clickNoFocus: function() { onClick($par"][title="Edit"]').find('span').withText('Edit')) - .expect(Selector('div').withText('Is start with new line').nth(14).find('.sjs-cb-wrapper').exists).eql(false) - .expect(Selector('.form-group').nth(50).find('div').withText('Tag').exists).eql(true) - .click('.btn.btn-default.btn-secondary[data-bind^="click: onOkClick, disable: readOnly, value: $root."]') - .click(Selector('div').withText('Matrix (single choice)').nth(7).find('.svd_toolbox_item_text.hidden-sm.hidden-xs[data-bind=\"text:title\"]')) - .click(Selector('.svda_question_action.svd-main-color[data-bind^="key2click, clickNoFocus: function() { onClick($par"][title="Edit"]').nth(1).find('span').withText('Edit')) - .expect(Selector('#surveyquestioneditorwindow').find('.modal-body.svd_notopbottompaddings').innerText).match(/Visible.If.*\s+.*Columns/); + await t + .maximizeWindow() + .click(Selector('.svd_toolbox').find('div').withText('Single-Line Input')) + .click(Selector('.svda_question_action.svd-main-color[data-bind^="key2click, clickNoFocus: function() { onClick($par"][title="Edit"]').find('span').withText('Edit')) + .expect(Selector('div').withText('Is start with new line').nth(14).find('.sjs-cb-wrapper').exists).eql(false) + .expect(Selector('.form-group').nth(50).find('div').withText('Tag').exists).eql(true) + .click('.btn.btn-default.btn-secondary[data-bind^="click: onOkClick, disable: readOnly, value: $root."]') + .click(Selector('div').withText('Matrix (single choice)').nth(7).find('.svd_toolbox_item_text.hidden-sm.hidden-xs[data-bind=\"text:title\"]')) + .click(Selector('.svda_question_action.svd-main-color[data-bind^="key2click, clickNoFocus: function() { onClick($par"][title="Edit"]').nth(1).find('span').withText('Edit')) + .expect(Selector('#surveyquestioneditorwindow').find('.modal-body.svd_notopbottompaddings').innerText).match(/Visible.If.*\s+.*Columns/); }); \ No newline at end of file diff --git a/examples/remove_properties.testcafe.js b/examples/remove_properties.testcafe.js index 1b722b9..46bed82 100644 --- a/examples/remove_properties.testcafe.js +++ b/examples/remove_properties.testcafe.js @@ -1,56 +1,56 @@ -import { Selector, ClientFunction } from 'testcafe'; +import { Selector, ClientFunction, fixture, test } from 'testcafe'; fixture `remove_properties` - .page `https://surveyjstest.azurewebsites.net//Examples/CreatorSinglePage?id=options&theme=default`; + .page `https://surveyjstest.azurewebsites.net//Examples/CreatorSinglePage?id=options&theme=default`; test.skip('Remove property', async t => { - await t - .maximizeWindow(); + await t + .maximizeWindow(); - const dummy = ClientFunction(() => { - Survey.Serializer.removeProperty('question', 'description'); - var creatorOptions = {}; - new SurveyCreator.SurveyCreator('creatorElement', creatorOptions); - return 'dummy'; - }); + const dummy = ClientFunction(() => { + window.Survey.Serializer.removeProperty('question', 'description'); + var creatorOptions = {}; + new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions); + return 'dummy'; + }); - await t - .expect(dummy()).eql('dummy') - .click(Selector('.svd_toolbox').find('div').withText('Single-Line Input')) - .expect(Selector('#creatorElement').find('[data-bind^="text: displayName, attr: {title: title || displayN"][title="Description"]').exists).eql(false) - .click(Selector('a').withText('JSON Editor')) - .click(Selector('#surveyjsJSONEditor').find('.ace_content'), { - offsetX: 173, - offsetY: 98 - }) - .typeText(Selector('#surveyjsJSONEditor').find('.ace_text-input'), `, + await t + .expect(dummy()).eql('dummy') + .click(Selector('.svd_toolbox').find('div').withText('Single-Line Input')) + .expect(Selector('#creatorElement').find('[data-bind^="text: displayName, attr: {title: title || displayN"][title="Description"]').exists).eql(false) + .click(Selector('a').withText('JSON Editor')) + .click(Selector('#surveyjsJSONEditor').find('.ace_content'), { + offsetX: 173, + offsetY: 98 + }) + .typeText(Selector('#surveyjsJSONEditor').find('.ace_text-input'), `, description: \'desc\'`, { - caretPos: 1 - }) - .expect(Selector('div').withAttribute('class', /ace_gutter\-cell\s+ace_error/).classNames).contains('ace_error'); + caretPos: 1 + }) + .expect(Selector('div').withAttribute('class', /ace_gutter\-cell\s+ace_error/).classNames).contains('ace_error'); }); test.skip('Hide property in designer', async t => { - await t - .maximizeWindow(); + await t + .maximizeWindow(); - const dummy = ClientFunction(() => { - Survey.Serializer.findProperty('question', 'description').visible = false; - var creatorOptions = {}; - new SurveyCreator.SurveyCreator('creatorElement', creatorOptions); - return 'dummy'; - }); + const dummy = ClientFunction(() => { + window.Survey.Serializer.findProperty('question', 'description').visible = false; + var creatorOptions = {}; + new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions); + return 'dummy'; + }); - await t - .expect(dummy()).eql('dummy') - .click(Selector('.svd_toolbox').find('div').withText('Single-Line Input')) - .expect(Selector('[data-bind^="text: displayName, attr: {title: title || displayN"][title="Description"]').exists).eql(false) - .click(Selector('a').withText('JSON Editor')) - .pressKey('backspace') - .typeText(Selector('#surveyjsJSONEditor').find('.ace_text-input'), '{ "pages": [ { "name": "page1", "elements": [ { "type": "text", "name": "question1", "description": "desc" } ] } ] }', { - caretPos: 1 - }) - .expect(Selector('div').withAttribute('class', /ace_gutter\-cell\s+ace_error/).exists).eql(false) - .click(Selector('a').withText('Test Survey')) - .expect(Selector('span').withText('desc').nth(1).textContent).eql('desc'); + await t + .expect(dummy()).eql('dummy') + .click(Selector('.svd_toolbox').find('div').withText('Single-Line Input')) + .expect(Selector('[data-bind^="text: displayName, attr: {title: title || displayN"][title="Description"]').exists).eql(false) + .click(Selector('a').withText('JSON Editor')) + .pressKey('backspace') + .typeText(Selector('#surveyjsJSONEditor').find('.ace_text-input'), '{ "pages": [ { "name": "page1", "elements": [ { "type": "text", "name": "question1", "description": "desc" } ] } ] }', { + caretPos: 1 + }) + .expect(Selector('div').withAttribute('class', /ace_gutter\-cell\s+ace_error/).exists).eql(false) + .click(Selector('a').withText('Test Survey')) + .expect(Selector('span').withText('desc').nth(1).textContent).eql('desc'); }); \ No newline at end of file diff --git a/examples/set_and_save_survey.testcafe.js b/examples/set_and_save_survey.testcafe.js index 555e1b1..f51657a 100644 --- a/examples/set_and_save_survey.testcafe.js +++ b/examples/set_and_save_survey.testcafe.js @@ -1,35 +1,35 @@ -import { Selector, ClientFunction } from 'testcafe'; +import { Selector, ClientFunction, fixture, test } from 'testcafe'; fixture `set_and_save_survey` - .page `https://surveyjstest.azurewebsites.net/Examples/Builder?id=setsurvey&theme=default`; + .page `https://surveyjstest.azurewebsites.net/Examples/Builder?id=setsurvey&theme=default`; test.skip('Load survey text and log modified designer', async t => { - await t - .maximizeWindow(); + await t + .maximizeWindow(); - const console_log_hook = ClientFunction(() => { - console.stdlog = console.log.bind(console); - console.logs = []; - console.log = function(){ - console.logs.push(Array.from(arguments)); - console.stdlog.apply(console, arguments); - } - return 'dummy'; - }); + const console_log_hook = ClientFunction(() => { + console.stdlog = console.log.bind(console); + console.logs = []; + console.log = function() { + console.logs.push(Array.from(arguments)); + console.stdlog.apply(console, arguments); + }; + return 'dummy'; + }); - await t - .expect(console_log_hook()).eql('dummy') - .click(Selector('a').withText('Test Survey')) - .expect(Selector('span').withText('q1').nth(4).textContent).eql('q1') - .expect(Selector('div').withText('1 .  q1').nth(24).find('[data-bind^="disable: question.isReadOnly, attr: {type: questio"].sv_q_text_root').tagName).eql('input') - .click(Selector('a').withText('Survey Designer')) - .click(Selector('span').withText('Checkbox')) - .click(Selector('#svd-save').find('span').withText('Save Survey')); + await t + .expect(console_log_hook()).eql('dummy') + .click(Selector('a').withText('Test Survey')) + .expect(Selector('span').withText('q1').nth(4).textContent).eql('q1') + .expect(Selector('div').withText('1 .  q1').nth(24).find('[data-bind^="disable: question.isReadOnly, attr: {type: questio"].sv_q_text_root').tagName).eql('input') + .click(Selector('a').withText('Survey Designer')) + .click(Selector('span').withText('Checkbox')) + .click(Selector('#svd-save').find('span').withText('Save Survey')); - const console_log_content = ClientFunction(() => { - return console.logs[console.logs.length - 1][0]; - }); + const console_log_content = ClientFunction(() => { + return console.logs[console.logs.length - 1][0]; + }); - await t - .expect(console_log_content()).match(/text.*\s?.*q1.*\s?.*\s?.*\s?.*checkbox.*\s?.*\s?.*\s?.*item1/); + await t + .expect(console_log_content()).match(/text.*\s?.*q1.*\s?.*\s?.*\s?.*checkbox.*\s?.*\s?.*\s?.*item1/); }); \ No newline at end of file diff --git a/examples/survey_title.testcafe.js b/examples/survey_title.testcafe.js index edc88a0..cab37c2 100644 --- a/examples/survey_title.testcafe.js +++ b/examples/survey_title.testcafe.js @@ -1,22 +1,22 @@ -import { Selector } from 'testcafe'; +import { Selector, fixture, test } from 'testcafe'; fixture`survey_title` - .page`https://surveyjstest.azurewebsites.net/Examples/Survey-Creator?id=titleadorner&platform=Knockoutjs`; + .page`https://surveyjstest.azurewebsites.net/Examples/Survey-Creator?id=titleadorner&platform=Knockoutjs`; test('title_adorners', async t => { - await t - .maximizeWindow() - .expect(Selector('span').withText('Input page title here').nth(2).visible).eql(true, 'Page title is visible') - .expect(Selector('span').withText('Enter a page description').nth(2).visible).eql(true) - .expect(Selector('#scrollableDiv').find('span').withText('Input survey title here').nth(2).visible).eql(false) - .expect(Selector('span').withText('Enter a survey description').nth(2).visible).eql(false) - .click(Selector('.svd-primary-icon.svda-title-action__show-hide[data-bind="css: $parent.getStyle($data)"]').find('svg')) - .expect(Selector('span').withText('Input survey title here').nth(2).visible).eql(true) - .expect(Selector('span').withText('Enter a survey description').nth(2).visible).eql(true) - .expect(Selector('span').withText('Add logo...').nth(2).visible).eql(true) - .click(Selector('span').withText('Allow show page empty title')) - .expect(Selector('span').withText('Input page title here').exists).eql(false) - .expect(Selector('span').withText('Enter a page description').exists).eql(false) - .click(Selector('span').withText('Allow user to change survey title visibility')) - .expect(Selector('.svd-primary-icon.svda-title-action__show-hide[data-bind=\"css: $parent.getStyle($data)\"]').find('svg').exists).eql(false); + await t + .maximizeWindow() + .expect(Selector('span').withText('Input page title here').nth(2).visible).eql(true, 'Page title is visible') + .expect(Selector('span').withText('Enter a page description').nth(2).visible).eql(true) + .expect(Selector('#scrollableDiv').find('span').withText('Input survey title here').nth(2).visible).eql(false) + .expect(Selector('span').withText('Enter a survey description').nth(2).visible).eql(false) + .click(Selector('.svd-primary-icon.svda-title-action__show-hide[data-bind="css: $parent.getStyle($data)"]').find('svg')) + .expect(Selector('span').withText('Input survey title here').nth(2).visible).eql(true) + .expect(Selector('span').withText('Enter a survey description').nth(2).visible).eql(true) + .expect(Selector('span').withText('Add logo...').nth(2).visible).eql(true) + .click(Selector('span').withText('Allow show page empty title')) + .expect(Selector('span').withText('Input page title here').exists).eql(false) + .expect(Selector('span').withText('Enter a page description').exists).eql(false) + .click(Selector('span').withText('Allow user to change survey title visibility')) + .expect(Selector('.svd-primary-icon.svda-title-action__show-hide[data-bind=\"css: $parent.getStyle($data)\"]').find('svg').exists).eql(false); }); \ No newline at end of file diff --git a/examples/toolbox_categories.testcafe.js b/examples/toolbox_categories.testcafe.js index d103bbc..b2a083f 100644 --- a/examples/toolbox_categories.testcafe.js +++ b/examples/toolbox_categories.testcafe.js @@ -1,68 +1,68 @@ -import { Selector, ClientFunction } from 'testcafe'; +import { Selector, ClientFunction, fixture, test } from 'testcafe'; fixture `toolbox_categories` - .page `https://surveyjstest.azurewebsites.net//Examples/CreatorSinglePage?id=toolboxcategories&theme=default`; + .page `https://surveyjstest.azurewebsites.net//Examples/CreatorSinglePage?id=toolboxcategories&theme=default`; test.skip('Change category', async t => { - await t - .maximizeWindow(); + await t + .maximizeWindow(); - const dummy = ClientFunction(() => { - var creatorOptions = { }; - creator = new SurveyCreator.SurveyCreator('creatorElement', creatorOptions); - creator - .toolbox - .changeCategories([ - { - name: 'rating', - category: 'Rating' - } - ]); - return 'dummy'; - }); + const dummy = ClientFunction(() => { + var creatorOptions = { }; + var creator = new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions); + creator + .toolbox + .changeCategories([ + { + name: 'rating', + category: 'Rating' + } + ]); + return 'dummy'; + }); - await t - .expect(dummy()).eql('dummy') - .expect(Selector('span').withText('GENERAL').exists).eql(true) - .expect(Selector('span').withText('RATING').exists).eql(true) - .click(Selector('span').withText('RATING')) - .expect(Selector('[data-bind="css: { \\\'panel-collapse collapse\\\': koCollapsed}"]').nth(1).find('div').withText('Rating').exists).eql(true) - .click(Selector('span').withText('Rating')) - .expect(Selector('#sq_148').exists).eql(true); + await t + .expect(dummy()).eql('dummy') + .expect(Selector('span').withText('GENERAL').exists).eql(true) + .expect(Selector('span').withText('RATING').exists).eql(true) + .click(Selector('span').withText('RATING')) + .expect(Selector('[data-bind="css: { \\\'panel-collapse collapse\\\': koCollapsed}"]').nth(1).find('div').withText('Rating').exists).eql(true) + .click(Selector('span').withText('Rating')) + .expect(Selector('#sq_148').exists).eql(true); }); test.skip('Add toolbox item to new category', async t => { - await t - .maximizeWindow(); + await t + .maximizeWindow(); - const dummy = ClientFunction(() => { - var creatorOptions = { }; - creator = new SurveyCreator.SurveyCreator('creatorElement', creatorOptions); - creator - .toolbox - .addItem({ - name: 'countries', - isCopied: true, - iconName: 'icon-default', - title: 'All countries', - category: 'Custom', - json: { - type: 'dropdown', - optionsCaption: 'Select a country...', - choicesByUrl: { - url: 'https://restcountries.eu/rest/v2/all' - } - } - }); - return 'dummy'; - }); + const dummy = ClientFunction(() => { + var creatorOptions = { }; + var creator = new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions); + creator + .toolbox + .addItem({ + name: 'countries', + isCopied: true, + iconName: 'icon-default', + title: 'All countries', + category: 'Custom', + json: { + type: 'dropdown', + optionsCaption: 'Select a country...', + choicesByUrl: { + url: 'https://restcountries.eu/rest/v2/all' + } + } + }); + return 'dummy'; + }); - await t - .expect(dummy()).eql('dummy') - .expect(Selector('span').withText('GENERAL').exists).eql(true) - .expect(Selector('span').withText('CUSTOM').exists).eql(true) - .click(Selector('.panel.panel-info').nth(1).find('div').withText('CUSTOM')) - .expect(Selector('[data-bind="css: { \\\'panel-collapse collapse\\\': koCollapsed}"]').nth(1).find('div').withText('All countries').exists).eql(true) - .click(Selector('span').withText('All countries')) - .expect(Selector('#sq_148').exists).eql(true); + await t + .expect(dummy()).eql('dummy') + .expect(Selector('span').withText('GENERAL').exists).eql(true) + .expect(Selector('span').withText('CUSTOM').exists).eql(true) + .click(Selector('.panel.panel-info').nth(1).find('div').withText('CUSTOM')) + .expect(Selector('[data-bind="css: { \\\'panel-collapse collapse\\\': koCollapsed}"]').nth(1).find('div').withText('All countries').exists).eql(true) + .click(Selector('span').withText('All countries')) + .expect(Selector('#sq_148').exists).eql(true); }); \ No newline at end of file diff --git a/examples/toolbox_customization.testcafe.js b/examples/toolbox_customization.testcafe.js index d9c54bf..52265f7 100644 --- a/examples/toolbox_customization.testcafe.js +++ b/examples/toolbox_customization.testcafe.js @@ -1,23 +1,23 @@ -import { Selector } from 'testcafe'; +import { Selector, fixture, test } from 'testcafe'; import { acceptCookie, getExampleTabSelector } from '../surveyjstest/helpers'; fixture`toolbox_customization` - .page`https://surveyjstest.azurewebsites.net/Examples/Builder?id=toolboxcustomization&platform=Knockoutjs&theme=default`.beforeEach(async t => { - await acceptCookie(t); - }); + .page`https://surveyjstest.azurewebsites.net/Examples/Builder?id=toolboxcustomization&platform=Knockoutjs&theme=default`.beforeEach(async t => { + await acceptCookie(t); +}); test('Check tabs', async t => { - await t - .maximizeWindow() - .switchToMainWindow() - .click(getExampleTabSelector('Code')) - .expect(Selector('code').textContent).contains('const creator = new SurveyCreator.SurveyCreator("surveyCreatorContainer", options);') - .click(Selector('span').withText('index.html')) - .expect(Selector('code').textContent).contains('id="surveyCreatorContainer"') - .click(getExampleTabSelector('Documentation')) - .expect(getExampleTabSelector('Documentation').classNames).contains('v2-class---footer-toolbar-item--active') - .click(getExampleTabSelector('Result')) - .expect(Selector('span.nav-link').withText('Survey Designer').visible).ok() - .expect(Selector('span.nav-link').withText('Test Survey').visible).ok() - .expect(Selector('span.nav-link').withText('JSON Editor').visible).ok(); + await t + .maximizeWindow() + .switchToMainWindow() + .click(getExampleTabSelector('Code')) + .expect(Selector('code').textContent).contains('const creator = new SurveyCreator.SurveyCreator("surveyCreatorContainer", options);') + .click(Selector('span').withText('index.html')) + .expect(Selector('code').textContent).contains('id="surveyCreatorContainer"') + .click(getExampleTabSelector('Documentation')) + .expect(getExampleTabSelector('Documentation').classNames).contains('v2-class---footer-toolbar-item--active') + .click(getExampleTabSelector('Result')) + .expect(Selector('span.nav-link').withText('Survey Designer').visible).ok() + .expect(Selector('span.nav-link').withText('Test Survey').visible).ok() + .expect(Selector('span.nav-link').withText('JSON Editor').visible).ok(); }); \ No newline at end of file diff --git a/examples/toolbox_customization_single_page.testcafe.js b/examples/toolbox_customization_single_page.testcafe.js index cd176ff..b5fdd6b 100644 --- a/examples/toolbox_customization_single_page.testcafe.js +++ b/examples/toolbox_customization_single_page.testcafe.js @@ -1,69 +1,69 @@ -import { Selector, ClientFunction } from 'testcafe'; +import { Selector, ClientFunction, fixture, test } from 'testcafe'; fixture `toolbox_customization_single_page` - .page `https://surveyjstest.azurewebsites.net//Examples/CreatorSinglePage?id=toolboxcustomization&theme=default`; + .page `https://surveyjstest.azurewebsites.net//Examples/CreatorSinglePage?id=toolboxcustomization&theme=default`; test.skip('Check dropdown', async t => { - await t - .maximizeWindow() - .drag(Selector('span').withText('All countries'), 388, 448, { - offsetX: 18, - offsetY: 5 - }) - .expect(Selector('label').withText('Options caption').exists).eql(true) - .expect(Selector('label').withText('Options caption').parent().find('input').value).eql("Select a country..."); + await t + .maximizeWindow() + .drag(Selector('span').withText('All countries'), 388, 448, { + offsetX: 18, + offsetY: 5 + }) + .expect(Selector('label').withText('Options caption').exists).eql(true) + .expect(Selector('label').withText('Options caption').parent().find('input').value).eql('Select a country...'); }); test.skip('Check matrix dynamic', async t => { - await t - .maximizeWindow(); + await t + .maximizeWindow(); - const addMatrixDynamic = ClientFunction(() => { - creator - .toolbox - .addItem({ - name: 'Teacher rate', - isCopied: true, - iconName: 'icon-default', - title: 'Teacher rate', - json: { - type: 'matrixdynamic', - name: 'teachersRate', - cellType: 'radiogroup', - choices: [ - { - value: 1, - text: 'Yes' - } - ], - columns: [ - { - name: 'subject', - cellType: 'dropdown', - title: 'Select a subject', - choices: [ - 'Math: Practical Math' - ] - }, { - name: 'explains' - } - ] + const addMatrixDynamic = ClientFunction(() => { + window.creator + .toolbox + .addItem({ + name: 'Teacher rate', + isCopied: true, + iconName: 'icon-default', + title: 'Teacher rate', + json: { + type: 'matrixdynamic', + name: 'teachersRate', + cellType: 'radiogroup', + choices: [ + { + value: 1, + text: 'Yes' } - }); - return 'dummy' - }); + ], + columns: [ + { + name: 'subject', + cellType: 'dropdown', + title: 'Select a subject', + choices: [ + 'Math: Practical Math' + ] + }, { + name: 'explains' + } + ] + } + }); + return 'dummy'; + }); - await t - .expect(addMatrixDynamic()).eql('dummy') - .click(Selector('span').withText('Teacher rate')) - .click(Selector('a').withText('Items').find('[data-bind="text: koText"]')) - .expect(Selector('.form-group').nth(6).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]').value).eql("1") - .expect(Selector('.form-group').nth(7).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]').value).eql('Yes') - .click(Selector('.modal-header').find('button').withText('×')) - .click(Selector('a').withText('Items').nth(1).find('[data-bind="text: koText"]')) - .expect(Selector('div').withText('Default').nth(15).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').value).eql("dropdown") - .expect('').eql('') - .expect(Selector('.form-group').nth(20).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]').value).eql("explains") - .click(Selector('.form-group').nth(16).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]')) - .click(Selector('.modal-header').nth(1).find('button').withText('×')); + await t + .expect(addMatrixDynamic()).eql('dummy') + .click(Selector('span').withText('Teacher rate')) + .click(Selector('a').withText('Items').find('[data-bind="text: koText"]')) + .expect(Selector('.form-group').nth(6).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]').value).eql('1') + .expect(Selector('.form-group').nth(7).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]').value).eql('Yes') + .click(Selector('.modal-header').find('button').withText('×')) + .click(Selector('a').withText('Items').nth(1).find('[data-bind="text: koText"]')) + .expect(Selector('div').withText('Default').nth(15).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, options: koChoi"]').value).eql('dropdown') + .expect('').eql('') + .expect(Selector('.form-group').nth(20).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]').value).eql('explains') + .click(Selector('.form-group').nth(16).find('.form-control.svd_editor_control[data-bind^="value: koValue, disable: readOnly, attr: {placehol"]')) + .click(Selector('.modal-header').nth(1).find('button').withText('×')); }); \ No newline at end of file diff --git a/package.json b/package.json index c84fff5..deef47a 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,10 @@ "pw:ui": "npx playwright test --ui", "pw:debug": "npx playwright test --ui --debug", "pw:codegen": "npx playwright codegen", - "pw:file": "npx playwright test example" + "pw:file": "npx playwright test example", + "pre-push-check": "npm run lint", + "lint": "eslint ./examples --quiet && eslint './surveyjsio mobile version' --quiet && eslint ./surveyjstest --quiet && eslint ./V2 --quiet", + "prepare": "husky install" }, "dependencies": { "devextreme-screenshot-comparer": "^2.0.16", @@ -30,6 +33,17 @@ "testcafe-reporter-xunit": "^2.2.1" }, "devDependencies": { - "@playwright/test": "^1.32.3" + "@playwright/test": "^1.32.3", + "@typescript-eslint/eslint-plugin": "^4.29.0", + "@typescript-eslint/parser": "^4.29.0", + "eslint": "^7.32.0", + "eslint-cli": "^1.1.1", + "eslint-plugin-surveyjs": "file:eslint-surveyjs", + "husky": "^8" + }, + "husky": { + "hooks": { + "pre-push": "npm run pre-push-check" + } } } diff --git a/payment/Common/cart.testcafe.js b/payment/Common/cart.testcafe.js index dd161b9..d2cea22 100644 --- a/payment/Common/cart.testcafe.js +++ b/payment/Common/cart.testcafe.js @@ -1,4 +1,4 @@ -import { Selector } from 'testcafe'; +import { Selector , fixture, test } from 'testcafe'; //const domain = 'http://localhost:62946'; const domain = "https://surveyjstest.azurewebsites.net"; diff --git a/surveyjsio mobile version/docs.testcafe.js b/surveyjsio mobile version/docs.testcafe.js index cbcca39..3fbe1fc 100644 --- a/surveyjsio mobile version/docs.testcafe.js +++ b/surveyjsio mobile version/docs.testcafe.js @@ -1,4 +1,4 @@ -import { Selector } from 'testcafe'; +import { Selector , fixture, test } from 'testcafe'; import { getIUnderstandButton } from './helpers'; fixture `docs` diff --git a/surveyjsio mobile version/examples.testcafe.js b/surveyjsio mobile version/examples.testcafe.js index 3a90ba5..9395ce2 100644 --- a/surveyjsio mobile version/examples.testcafe.js +++ b/surveyjsio mobile version/examples.testcafe.js @@ -1,4 +1,4 @@ -import { Selector } from 'testcafe'; +import { Selector , fixture, test } from 'testcafe'; import { getIUnderstandButton } from './helpers'; fixture `examples` diff --git a/surveyjsio mobile version/helpers.js b/surveyjsio mobile version/helpers.js index 6819e48..9e355c6 100644 --- a/surveyjsio mobile version/helpers.js +++ b/surveyjsio mobile version/helpers.js @@ -1,4 +1,4 @@ -import { Selector } from 'testcafe'; +import { Selector, fixture, test } from 'testcafe'; export function getSideBarGroupItem(text) { return Selector(".sidebar__item").withText(text); diff --git a/surveyjsio mobile version/index_page.testcafe.js b/surveyjsio mobile version/index_page.testcafe.js index 85c141e..bef4ac3 100644 --- a/surveyjsio mobile version/index_page.testcafe.js +++ b/surveyjsio mobile version/index_page.testcafe.js @@ -1,4 +1,4 @@ -import { Selector } from 'testcafe'; +import { Selector , fixture, test } from 'testcafe'; import { getIUnderstandButton } from './helpers'; fixture `Index Page` diff --git a/surveyjsio mobile version/mobile_menu.testcafe.js b/surveyjsio mobile version/mobile_menu.testcafe.js index dfca962..cea69b4 100644 --- a/surveyjsio mobile version/mobile_menu.testcafe.js +++ b/surveyjsio mobile version/mobile_menu.testcafe.js @@ -1,4 +1,4 @@ -import { Selector } from 'testcafe'; +import { Selector , fixture, test } from 'testcafe'; import { getIUnderstandButton } from './helpers'; fixture `Mobile Menu` diff --git a/surveyjstest/Library/Examples/codesandboxcheck.testcafe.js b/surveyjstest/Library/Examples/codesandboxcheck.testcafe.js index edd4973..d8c50ca 100644 --- a/surveyjstest/Library/Examples/codesandboxcheck.testcafe.js +++ b/surveyjstest/Library/Examples/codesandboxcheck.testcafe.js @@ -1,4 +1,4 @@ -import { Selector } from 'testcafe'; +import { Selector , fixture, test } from 'testcafe'; import { explicitErrorHandler } from '../../helpers'; fixture`question_types` diff --git a/surveyjstest/Library/Examples/question_types.testcafe.js b/surveyjstest/Library/Examples/question_types.testcafe.js index 72af3e4..18b6a27 100644 --- a/surveyjstest/Library/Examples/question_types.testcafe.js +++ b/surveyjstest/Library/Examples/question_types.testcafe.js @@ -1,4 +1,4 @@ -import { Selector } from 'testcafe'; +import { Selector , fixture, test } from 'testcafe'; import { explicitErrorHandler, getSideBarGroupItem, getSideBarItem } from '../../helpers'; fixture `question_types`.page `https://surveyjstest.azurewebsites.net/Examples/Library`.clientScripts({ diff --git a/surveyjstest/Library/Examples/survey.testcafe.js b/surveyjstest/Library/Examples/survey.testcafe.js index 32dc469..b6708fb 100644 --- a/surveyjstest/Library/Examples/survey.testcafe.js +++ b/surveyjstest/Library/Examples/survey.testcafe.js @@ -1,4 +1,4 @@ -import { Selector } from 'testcafe'; +import { Selector , fixture, test } from 'testcafe'; import { getSideBarGroupItem, getSideBarItem, explicitErrorHandler, acceptCookie } from '../../helpers'; fixture`survey` diff --git a/surveyjstest/Library/Examples/tabs.testcafe.js b/surveyjstest/Library/Examples/tabs.testcafe.js index 56c37a2..b94326d 100644 --- a/surveyjstest/Library/Examples/tabs.testcafe.js +++ b/surveyjstest/Library/Examples/tabs.testcafe.js @@ -1,4 +1,4 @@ -import { Selector } from 'testcafe'; +import { Selector , fixture, test } from 'testcafe'; import { getIUnderstandButton, getExampleTabSelector, acceptCookie } from '../../helpers'; fixture `tabs` diff --git a/surveyjstest/helpers.js b/surveyjstest/helpers.js index 41bd163..11ba93e 100644 --- a/surveyjstest/helpers.js +++ b/surveyjstest/helpers.js @@ -1,4 +1,4 @@ -import { Selector } from 'testcafe'; +import { Selector , fixture, test } from 'testcafe'; export function getSideBarGroupItem(text) { return Selector(".v2-class---drop-down-menu-item__link--level-1").withText(text); diff --git a/warmup/_warmup.testcafe.js b/warmup/_warmup.testcafe.js index e83e1ea..d0e0a51 100644 --- a/warmup/_warmup.testcafe.js +++ b/warmup/_warmup.testcafe.js @@ -1,4 +1,4 @@ -import { Selector } from 'testcafe'; +import { Selector, fixture, test } from 'testcafe'; fixture `warmup` .page `https://surveyjstest.azurewebsites.net/Account/Login`;