Get help with testing, discuss unit testing strategies etc.


Post by klodoma »

Not sure if it's even possible, but maybe you can point out to the right direction.

In Chrome/FF, we can emulate a mobile device with different screensizes and which also sets the browser userAgent to the specific "tablet" or "phone" mode.
Ref to a generic user agent detection https://www.abeautifulsite.net/detecting-mobile-devices-with-javascript
Screenshot_387.png
Screenshot_387.png (63.96 KiB) Viewed 3696 times

Is this possible to set the userAgent with siesta?
The screen size probably one could simulate by limiting the size of the view, but can we enforce the user agent?

I searched through the examples and found nothing in this direction.

The problem:
- same views behave/look differently on desktop/tablet and mobile
- currently we can see only the "desktop" mode

The use-case would be the following:
- the same view behaves differently on desktop, tablet and phone
- test this view on different modes(desktop, tablet and phone) and check if components are visible or not etc...

Can you provide some directions?

Post by mats »

We don't support mocking the userAgent but you can set viewportWidth / height. Docs: https://www.bryntum.com/docs/siesta/#!/api/Siesta.Project.Browser-cfg-viewportHeight

Post by klodoma »

mats wrote: Thu Jun 13, 2019 1:27 pm We don't support mocking the userAgent but you can set viewportWidth / height. Docs: https://www.bryntum.com/docs/siesta/#!/api/Siesta.Project.Browser-cfg-viewportHeight
It works if I set the viewportWidth during configuration.

I found a way to set the userAgent to mobile, is it possible to change the viewportWidth/Height for each test or before each test? Or the test should set the values.

I tried to manipulate the iframe width/height after a test kicks off, but it leads to some layout side-effects.
        window.parent.$('iframe').width(300);
        window.parent.$('iframe').height(700);

Post by klodoma »

Is this the way?
StartTest(function (t) {
    t.setWindowSize(300, 700);

Post by nickolay »

Yes, this should do it.

Post Reply