Search code examples
extjsextjs6.2sencha-testsencha-test-2.1

Sencha Test validate content of MessageBox


Does someone know how can you validate the text within a Messagebox using Sencha Test 2.1 ?

I'm successful in retrieving the actual messagebox like this:

ST.panel('messagebox').visible();

So I want to do something like:

ST.panel('messagebox').visible().expect('value').toEqual('Awesome, all went well!');

I've tried value, text, etc can't seem to find a property to use.


Solution

  • Glad you figured out a solution. If you wanted to more of a direct assertion on the "html", you could do something like so:

    it('should have the right html', function () {
        Ext.Msg.alert('Title', 'Awesome, all went well');
    
        ST.panel('messagebox')
          .gotoComponent('[cls=x-window-text]')
          .get('html')
          .and(function () {
              expect(this.future.data.html).toBe('Awesome, all went well');
          }); 
    });
    

    Or even more compact:

    it('should have the right html', function () {
        Ext.Msg.alert('Title', 'Awesome, all went well');
    
        ST.panel('messagebox')
          .gotoComponent('[cls=x-window-text]')
          .expect('html')
          .toBe('Awesome, all went well'); 
    });
    

    http://docs.sencha.com/sencha_test/2.1.0/api/ST.future.Component.html#method-get