Get help with testing, discuss unit testing strategies etc.


Post by nuridesengin »

Hi, there will be two question and before that I would like to highlight test structure;
//FooTestCase.js > Here is my Test Case: Calls methods located base Siesta.Test.Class
describe('UI Test Case', function (t) {
    ...
    t.chain({grid: 'foogrid'});
}); 

//Here is Siesta.Test.Class
Class('Siesta.Test.ListClass', {
    isa     : Siesta.Test.ExtJS,

    methods: {
        grid: function (fooGrid, callback) {
            let t = this;

            t.it(testTranslations.testingGrid , function (t) {
                t.chain(
                    function (next) {next();},
                    {waitForCQ: cssSelector1 +'[xtype='+ fooGrid +']', timeout: 120000, isReadyTimeout: 120000},
                    {click: cssSelector2, timeout: 120000, isReadyTimeout: 120000, desc: 'Clicks...'},
                    {click: cssSelector3, timeout: 120000, isReadyTimeout: 120000, desc: 'Clicks...'},
                    {click: cssSelector4, timeout: 120000, isReadyTimeout: 120000, desc: 'Clicks...'},
                    {moveCursorTo: cssSelector4, , timeout: 120000, isReadyTimeout: 120000, desc: 'Scrolling...'},

                    callback
                )
            });
        }, 

//and the harness file
let project = new Siesta.Project.Browser(); 

project.configure({
    title: 'Foo Test Runner',
    viewDOM: true,
    enableCodeCoverage: true,
    coverageUnit: 'file',
    waitForTimeout: 120000,
    isReadyTimeout: 120000,
    runCore: 'sequential',
    separateContext: true
});

project.start(
    {
        group: 'UI Tests',
        testClass: Siesta.Test.ListClass,
        items: [
            {
                  title: 'FooTestCase',
                  hostPageUrl: localApp,
                  url: testPath + 'FooTestCase.js'
            } 
        ]
    }
);
So depends on test structure above;

1. I've tried to set waitForTimeout, isReadyTimeout configs on configure() method and timeout, isReadyTimeout on TestClass to 120000 (which 2 mins) but I can not adjust the Test Case to adapt this value. I get error below during loading data from web-service to grid because it loads litt bit slowly for sometimes.
How can I set-up a `timeout` feature better?
The step in `t.chain()` call did not complete within required timeframe, chain can not proceed
2. How can I override TestClass on Test Case itself? I mean; as you'll notice there are couple of click actions on grid method of Test Class and sometimes I need to de-active/ignore some of them; e.g. Is it possible to ignoring this click action below on some specific Test Cases;
{click: cssSelector3, timeout: 120000, isReadyTimeout: 120000, desc: 'Clicks...'}


Thanks a lot..

Post by nickolay »

Hi,

1) The timeout of the chain step can be configured with https://www.bryntum.com/docs/siesta/#!/ ... ultTimeout option. It can be specified in the "project.configure()" call (for the whole project) or in test descriptor (for individual test).

I noticed you are testing a Sencha ExtJS application - you should use "Siesta.Project.Browser.ExtJS" project class then.

The "click" action does not recognize the "timeout" and "isReadyTimeout" configs.

2) To make a chain step optional based on some condition, you have 2 options:
t.chain(
    function (next) {
        if (someCondition) {
            doThis()
            
            next()
        } else {
            doThat()
            
            next()
        }
    }
)

// or

t.chain(
    someCondition ? { click : 'something' } : null,
)
Difference is, in the 1st case the "someCondition" will be evaluated at the time of that step execution. In the 2nd case, "someCondition" will be evaluated at the time of `t.chain()` call (before any steps).

Post by nuridesengin »

Hello dear nickolay; that's been a good explaination. Let me to practise your advice.
Thanks.

Post by nuridesengin »

1. I've refactored click actions of grid method and used Siesta.Project.Browser.ExtJS() as you advice; as well stated defaultTimeout but it doesn't work to me as expected. Is it possible to set up a delay/timeout feature for actions of chain, instead of setting timeout for whole descriptor?

BTW: I've tried subTestTimeout, wrapping related chain or actions with setTimeout func and setting up a promise but non of them worked... I keep get error for the first action (clicks on cssSelector2) during waiting for grid loading and says:
The step in `t.chain()` call did not complete within required timeframe, chain can not proceed
Class('Siesta.Test.ListClass', {
    isa     : Siesta.Test.ExtJS,

    methods: {
        grid: function (fooGrid, callback) {
            let t = this;

            t.it(testTranslations.testingGrid , function (t) {
                t.chain(
                    // I need seting up a delay or timeout on those action: to wait response of API to load grid.
                    function (next) {next();},,
                    {click: cssSelector2, desc: 'Clicks... cssSelector2'},
                    {click: cssSelector3, desc: 'Clicks... cssSelector3'},
                    {click: cssSelector4, desc: 'Clicks... cssSelector4'},
                    {moveCursorTo: cssSelector5, desc: 'Scrolling to... cssSelector5'},
                    callback
                )
            });
        },

Post by nickolay »

No, its not possible to configure the timeout for individual chain step. What if you set "defaultTimeout" to some big value? Perhaps "cssSelector2" does not appear in the DOM?

Post Reply