Skip to content

Commit

Permalink
try fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaLarina committed Nov 8, 2023
1 parent affeb9e commit c91ee29
Showing 1 changed file with 39 additions and 57 deletions.
96 changes: 39 additions & 57 deletions examples/Creator/add_properties.testcafe.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test.skip('Survey property with default string type', async t => {
.maximizeWindow();

const dummy = ClientFunction(() => {
window.Survey.Serializer.addProperty('survey', { name: 'foo' });
Survey.Serializer.addProperty('survey', { name: 'foo' });
var creatorOptions = {};
new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions);
return 'dummy';
Expand All @@ -22,17 +22,14 @@ test.skip('Survey property with default string type', async t => {
});

test('Required property', async t => {
await t
.maximizeWindow();
await t.maximizeWindow();

const dummy = ClientFunction(() => {
window.Survey.Serializer.addProperty('checkbox', { name: '!foo' });
window.creator.JSON = '';
return 'dummy';
});
await ClientFunction(() => {
Survey.Serializer.addProperty('checkbox', { name: '!foo' });
creator.JSON = '';
})();

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
Expand All @@ -45,7 +42,7 @@ test.skip('Set property via JSON', async t => {
.maximizeWindow();

const dummy = ClientFunction(() => {
window.Survey.Serializer.addProperty('checkbox', { name: '!foo' });
Survey.Serializer.addProperty('checkbox', { name: '!foo' });
var creatorOptions = {};
new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions);
return 'dummy';
Expand All @@ -64,33 +61,27 @@ test.skip('Set property via JSON', async t => {
});

test('Property with default value', async t => {
await t
.maximizeWindow();
await t.maximizeWindow();

const dummy = ClientFunction(() => {
window.Survey.Serializer.addProperty('survey', { name: 'foo', default: 'bar' });
window.creator.JSON = {};
return 'dummy';
});
await ClientFunction(() => {
Survey.Serializer.addProperty('survey', { name: 'foo', default: 'bar' });
creator.JSON = {};
})();

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();
await t.maximizeWindow();

const dummy = ClientFunction(() => {
window.Survey.Serializer.addProperty('survey', { name: 'foo:boolean' });
window.creator.JSON = {};
return 'dummy';
});
ClientFunction(() => {
Survey.Serializer.addProperty('survey', { name: 'foo:boolean' });
creator.JSON = {};
})();

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);
Expand All @@ -101,7 +92,7 @@ test.skip('Check number property', async t => {
.maximizeWindow();

const dummy = ClientFunction(() => {
window.Survey.Serializer.addProperty('survey', { name: 'foo:number' });
Survey.Serializer.addProperty('survey', { name: 'foo:number' });
var creatorOptions = {};
new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions);
return 'dummy';
Expand All @@ -117,35 +108,29 @@ test.skip('Check number property', async t => {
});

test('Check text property', async t => {
await t
.maximizeWindow();
await t.maximizeWindow();

const dummy = ClientFunction(() => {
window.Survey.Serializer.addProperty('survey', { name: 'foo:text' });
window.creator.JSON = {};
return 'dummy';
});
ClientFunction(() => {
Survey.Serializer.addProperty('survey', { name: 'foo:text' });
creator.JSON = {};
})();

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();
await t.maximizeWindow();

const dummy = ClientFunction(() => {
window.Survey.Serializer.addProperty('survey', { name: 'foo:html' });
window.creator.JSON = {};
return 'dummy';
});
ClientFunction(() => {
Survey.Serializer.addProperty('survey', { name: 'foo:html' });
creator.JSON = {};
})();

await t
.expect(dummy()).eql('dummy')
.click(Selector('span').withText('Others'))
.click(Selector('div').withText('Foo'))
.typeText(Selector('div').withText('Foo').find('textarea'), 'Bar')
Expand All @@ -157,7 +142,7 @@ test.skip('Check choices property', async t => {
.maximizeWindow();

const dummy = ClientFunction(() => {
window.Survey.Serializer.addProperty('survey', { name: 'foo', choices: ['bar', 'egg'], default: 'bar' });
Survey.Serializer.addProperty('survey', { name: 'foo', choices: ['bar', 'egg'], default: 'bar' });
var creatorOptions = {};
new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions);
return 'dummy';
Expand All @@ -174,17 +159,14 @@ test.skip('Check choices property', async t => {
});

test('Check itemvalues property', async t => {
await t
.maximizeWindow();
await t.maximizeWindow();

const dummy = ClientFunction(() => {
window.Survey.Serializer.addProperty('survey', { name: 'foo:itemvalues' });
window.creator.JSON = {};
return 'dummy';
});
ClientFunction(() => {
Survey.Serializer.addProperty('survey', { name: 'foo:itemvalues' });
creator.JSON = {};
})();

await t
.expect(dummy()).eql('dummy')
.click(Selector('span').withText('Others'))
.click(Selector('button').withText('Form Entry'))
.click("input[value='Add New']")
Expand All @@ -197,7 +179,7 @@ test.skip('Check matrixdropdowncolumns property', async t => {
.maximizeWindow();

const dummy = ClientFunction(() => {
window.Survey.Serializer.addProperty('matrixdynamic', { name: 'foo:matrixdropdowncolumns' });
Survey.Serializer.addProperty('matrixdynamic', { name: 'foo:matrixdropdowncolumns' });
var creatorOptions = {};
new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions);
return 'dummy';
Expand All @@ -219,7 +201,7 @@ test.skip('Check textitems property', async t => {
.maximizeWindow();

const dummy = ClientFunction(() => {
window.Survey.Serializer.addProperty('multipletext', { name: 'foo:textitems' });
Survey.Serializer.addProperty('multipletext', { name: 'foo:textitems' });
var creatorOptions = {};
new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions);
return 'dummy';
Expand All @@ -240,7 +222,7 @@ test.skip('Check choices with function property', async t => {
.maximizeWindow();

const dummy = ClientFunction(() => {
window.Survey.Serializer.addProperty('survey', { name: 'locale', choices: function() { return window.Survey.surveyLocalization.getLocales(); } });
Survey.Serializer.addProperty('survey', { name: 'locale', choices: function() { return window.Survey.surveyLocalization.getLocales(); } });
var creatorOptions = {};
new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions);
return 'dummy';
Expand All @@ -258,7 +240,7 @@ test.skip('Check triggers property', async t => {
.maximizeWindow();

const dummy = ClientFunction(() => {
window.Survey.Serializer.addProperty('survey', { name: 'foo:triggers' });
Survey.Serializer.addProperty('survey', { name: 'foo:triggers' });
var creatorOptions = {};
new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions);
return 'dummy';
Expand Down Expand Up @@ -302,7 +284,7 @@ test.skip('Check validators property', async t => {
.maximizeWindow();

const dummy = ClientFunction(() => {
window.Survey.Serializer.addProperty('survey', { name: 'foo:validators' });
Survey.Serializer.addProperty('survey', { name: 'foo:validators' });
var creatorOptions = {};
new window.SurveyCreator.SurveyCreator('creatorElement', creatorOptions);
return 'dummy';
Expand Down

0 comments on commit c91ee29

Please sign in to comment.