Live view reloads when in IEx.pry() in phx-click callback - phoenix-live-view

I am using IEx.pry() to break at the top of a phx-click callback. Chrome reloads the page after 30 seconds.
devs.exs:
config :app, AppWeb.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 4000, protocol_options: [idle_timeout: :infinity]],
Chrome log:
utils.js:28 phx-Fvw3t47Zh2jpRAij destroyed: the child has been removed from the parent - undefined
utils.js:28 phx-Fvw3t47Zh2jpRAij timeout: received timeout while communicating with server. Falling back to hard refresh for recovery - undefined
The socket shows the phx_click message, then phx_leave before the reload. I tried different idle_timeout values, same behavior. Is there another setting?

Related

Salesforce lwc lightning/modal dispatchEvent

Documentation - https://developer.salesforce.com/docs/component-library/bundle/lightning-modal/documentation - modal - API 56
When I try to fire an event from the modal window to the parent window - completely according to the example from the documentation - I get an error -
Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.
Completely according to the example from the documentation
this.dispatchEvent(new CustomEvent('select', {
detail: {
id: 42
}
}));
The error occurs even at the moment the event is sent - not to mention the moment it is received
I'm waiting for an event but it doesn't happen
You have to enable Lightning Web Security Enabled in the org to get this working.
You can check this https://salesforce.stackexchange.com/questions/387924/lightning-modal-custom-event-not-working-in-winter-23-release
I've checked it myself and it's working well.

ngx-toastr GlobalConfig timeout settings

Not able to achieve using the IndividualConfig and GlobalConfig classes.
imports: [ToastrModule.forRoot({timeOut: 10000, positionClass: 'toast-bottom-right', preventDuplicates: true})]
Setting the GlobalConfig like the above code snippet will set the timeout for all the types of messages/toastrs, I would like to take control of timeout for each type of message. For example say I want to timeout success message after 2000 milliseconds, error message after 6 seconds, warn and info after 3 seconds. I see this kind of configurations available in Growl messages but not sure about ngx-toastr messages.
I have tried using growl messages in angular 1.x version application
growlProvider.globalTimeToLive({ success: 2000, error: 5000, warning: 3000, info: 2000 });growlProvider.globalDisableCountDown(true);
In Angular 6 App
imports: [ToastrModule.forRoot({timeOut: 10000})]
I am able to set global timeout which is getting applied for all message notifications but i want to take control of each message type
Hi you can try with below configuration
import the ToastrModule and ToastContainerModule in your module
imports: [
ToastrModule.forRoot({ positionClass: 'inline' }),
ToastContainerModule,
]
or
imports: [
ToastrModule.forRoot(),
ToastContainerModule,
]
than call below code to open the toastr with timeout
this.toastrService.show(
'message',
'title',
{positionClass:'inline',
timeOut:500000},
);
check StackBlitz Code in detail

AngularJS testing with Protractor- call to click() never seems to be performed

I am developing a suite of tests for an AngularJS application, and have recently added the following test script to my spec.js file:
it('should navigate to the Charts page', function() {
console.log("Start Charts page test ");
browser.waitForAngularEnabled(false);
browser.wait(EC.presenceOf(chartsMenuBtn), 5000).then(
browser.actions().mouseMove(chartsMenuBtn).perform().then(
chartsMenuBtn.click().then(
browser.wait(EC.elementToBeClickable(closeDlgBtn)).then(
function(){
closeDlg();
expect(browser.getCurrentUrl()).toBe(VM + '/#/charts');
}
)
//)
)
)
)
})
Currently, when I run my tests, all of the tests written before this one run & execute correctly, then when this test is run, I get the following output in the command line where I'm running protractor conf.js:
...Alarms page test completed
.Start Charts page test
FA Jasmine spec timed out. Resetting the WebDriver Control Flow.
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
Start final Browser page test
Browser menu button clicked
End Browser page test (then call)
.
Failures:
1) App should navigate to the Charts page
Message:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
Stack:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
at ontimeout (timers.js:386:11)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)
Message:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
Stack:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
at ontimeout (timers.js:386:11)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)
6 specs, 1 failure
Finished in 64.989 seconds
In the browser window that is opened by the script (the window where the tests are being run), I can see that the chartsMenuBtn element is highlighted (i.e. when the test moves the cursor to it), but at that point, the script appears to freeze, and the call to chartsMenuBtn.click() never appears to be run...
If I add a call to browser.pause() into my script, so that I manually have to tell the script to continue at every executable line, then the script behaves exactly as I expect, and everything passes.
But when I remove the call to browser.pause(), and watch the script run through on its own, it always gets stuck at the same point.
It's clear that the line:
browser.actions().mouseMove(chartsMenuBtn).perform().then(
is executed, because I can see that the chartsMenuBtn element is highlighted in the browser. But for some reason, the script never then seems to execute the line:
chartsMenuBtn.click().then(
If it did, I would expect the browser to navigate to the Charts page (as it does if I manually click on the chartsMenuBtn element.
The DEFAULT_TIMEOUT_INTERVAL is set to 35 seconds in jasmine.js with:
j$.DEFAULT_TIMEOUT_INTERVAL = 35000;
I tried increasing its value, but that didn't make a difference- the test still timed out in the same place, for the same reason, which would indicate to me that there is another reason that this test is failing/ timing out.
Does anyone have any suggestions how I can fix this?
Edit
So I changed my script to add some debug to the test (print statements before and after the call to chartsMenuBtn.click().then(, to see whether or not this line was actually being run, and when I run my test now, I can see both of those print statements displayed in the command line:
Started
...Alarms page test completed
.Start Charts page test
Cursor hovering over chartsMenuBtn
Call to chartsMenuBtn.click() performed
FA Jasmine spec timed out. Resetting the WebDriver Control Flow.
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
Start final Tag Browser page test
Tag Browser menu button clicked
End Tag Browser page test (then call)
.
The two debug lines I added were:
Cursor hovering over chartsMenuBtn
Call to chartsMenuBtn.click() performed
I added these debug lines either side of the call to:
chartsMenuBtn.click().then(
so it's clear that this line is being run, yet for some reason, the click either doesn't seem to be registering, or the result of a click on this element is not actually performing the required & expected action.
Any suggestions for why this is?
Edit
So I've managed to make a bit of progress with this, although it's still not working as I intended/ hoped... I've altered the test script slightly by putting the call to chartsMenuBtn.click() inside a browser.actions() call, chaining multiple promises together:
it('should navigate to the Charts page', function() {
console.log("Start Charts page test ");
browser.waitForAngularEnabled(false);
browser.wait(EC.presenceOf(chartsMenuBtn), 5000).then(
browser.actions().mouseMove(chartsMenuBtn).perform().then(
browser.actions(console.log("Cursor hovering over chartsMenuBtn ")).perform().then(
browser.actions(chartsMenuBtn.click()).perform().then(
browser.actions(console.log("Call to chartsMenuBtn.click() performed ")).perform().then(
function(){
expect(EC.visibilityOf(closeDlgBtn).call()).toBeTruthy();
}
)
)
)
)
)
})
When I now run my script again, I just get a single failure- which seems to be caused by the timing associated with animation that has been set on one of the dialogs opened during the course of one of the tests to run prior to this test.
The error states:
Failed: unknown error: Element ... is not clickable at point (40, 229). Other element would receive the click:
<div tabindex="-1" role="dialog" class="modal fade ng-isolate-scope ult-loading modal-message ng-animate in-remove in-remove-active" ng-class="{in: animate}" ng-style="{'z-index': 1050 + index*10, display: 'block'}" ng-click="close($event)" modal-window="" window-class="ult-loading modal-message" size="sm" index="0" animate="animate" style="z-index: 1050; display: block;; transition-property: opacity;transition-duration: 0.15s;">...</div>
(Session info: chrome=62.0.3202.89)
(Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.16299 x86_64)
I tried putting the expect clause of my test inside a browser.wait() that would wait for the closeDlgBtn element to be present before running (but given that my expectation is that the button element is visible, this seems a bit redundant...):
function(){
browser.wait(EC.presenceOf(closeDlgBtn), 5000).then(
expect(EC.visibilityOf(closeDlgBtn).call()).toBeTruthy();
)
}
but this gives me a syntax error stating that there's a missing ) on the line:
expect(EC.visibilityOf(closeDlgBtn).call()).toBeTruthy();
I can't see a missing ) anywhere on that line. Can anyone spot what I'm doing wrong here?
Edit
I also tried surrounding the call to browser.actions(chartsMenuBtn.click()).perform().then( with a call to browser.wait(EC.elementToBeClickable()), so that it would wait for the element to be clickable before clicking on it (instead of just waiting for it to be present):
browser.wait(EC.elementToBeClickable(chartsMenuBtn), 5000).then(
browser.actions(chartsMenuBtn.click()).perform().then(
browser.actions(console.log("Call to chartsMenuBtn.click() performed ")).perform().then(
function(){
expect(EC.visibilityOf(closeDlgBtn).call()).toBeTruthy();
}
)
)
)
But for some reason, I still get the same error:
Failed: unknown error: Element ... is not clickable at point (40, 229). Other element would receive the click:
which doesn't make sense- since it should be waiting for the element to be clickable before clicking on it...?
Edit
So, I had a look at actions on the Protract API, and it appears I have been chaining the promises incorrectly. I changed the test script to:
it('should navigate to the Charts page', function() {
console.log("Start Charts page test ");
browser.waitForAngularEnabled(false);
browser.wait(EC.elementToBeClickable(chartsMenuBtn), 5000).then(
browser.actions().
mouseMove(chartsMenuBtn).
//console.log("Cursor hovering over chartsMenuBtn").
chartsMenuBtn.click().
//console.log("Call to chartsMenuBtn.click() performed").
browser.wait(EC.urlIs(VM + '/#/charts'), 5000).
//console.log("browser.wait called- URL should now be VM + /#/charts/ ").
perform()
);
})
and this seems to have resolved the 'element not clickable' issue. However, I now get another error that says:
Failed: Cannot read property 'click' of undefined
but chartsMenuBtn has been defined with:
var chartsMenuBtn = element(by.linkText("Charts"));
Anyone have any suggestions?

Leaflet ionic position errors

From some time on I am getting
[Log] PositionError (mapController.js, line 141)
code: 2
message: ""
__proto__: PositionErrorPrototype
in Safari on OSX and iOS when I run my Leaflet.js based app and the example that it's based on.
When I started the project, this was not the case. It happens when I try to get the current location by calling
$cordovaGeolocation.getCurrentPosition().then(function (position) {
...
}
Any ideas? Is it reproducible?
Edit:
I figured it's returning PositionError.POSITION_UNAVAILABLE as defined in the specs.
I added options to the request { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true } hoping it would extend the timeout span to 5sec., but I keep getting the error immediately after request...
Safari 8.0.6 OSX 10.10.3 XCode 6.3.2
It works fine with Chrome, but I plan to deploy this on iOS & Android

when running protractor with phantomjs browser, only able to run tests once

test code:
describe('mysite', function(){
var init_url = 'http://localhost/mySite/#/home';
beforeEach(function(){
// driver = new webdriver.Builder().
// withCapabilities(webdriver.Capabilities.phantomjs()).build();
})
it('should click on toolbox and do stuff', function(){
browser.get(init_url);
browser.waitForAngular();
browser.getCurrentUrl().then(function(url){
console.log('current_url', url);
expect(init_url).toEqual(init_url);
})
expect(true).toBe(true);
browser.sleep(2000);
})
result 1st time run,
Using the selenium server at http://localhost:9515
data Zoom Pad
class active
mysite
should click on toolbox and do stuff
Finished in 3.94 seconds
1 test, 4 assertions, 0 failures
2nd time run, without any interruption, just up arrow and enter:
Stacktrace:
Error: Error while running testForAngular: Error Message => 'Detected a pag
e unload event; asynchronous script execution does not work across page loads.'
caused by Request => {"headers":{"Accept":"application/json; charset=utf-8","Co
nnection":"keep-alive","Content-Length":"689","Content-Type":"application/json;c
harset=UTF-8","Host":"localhost:9515"},"httpVersion":"1.1","method":"POST","post
":"{\"script\":\"return (function () {\\n var attempts = arguments[0];\\n var
callback = arguments[arguments.length - 1];\\n var check = function(n) {\\n
try {\\n if (window.angular && window.angular.resumeBootstrap) {\\n
callback([true, null]);\\n } else if (n < 1) {\\n if (window.angular
) {\\n callback([false, 'angular never provided resumeBootstrap']);\\n
} else {\\n callback([false, 'retries looking for angular exceed
third time
1) mysite should click on toolbox and do stuff
Message:
Error: ECONNREFUSED connect ECONNREFUSED
Stacktrace:
Error: ECONNREFUSED connect ECONNREFUSED
at ClientRequest.<anonymous> (K:\Users\Congwen\AppData\Roaming\npm\node_modu
les\protractor\node_modules\selenium-webdriver\http\index.js:127:16)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1547:9)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:441:14
and on third time the phantomjs webserver is down, and needs to be reconnected, and afterwards it goes back to result 1:
any clues?
config file used:
exports.config = {
seleniumAddress: 'http://localhost:9515',
specs: [
'./ptor-tests/mysite-test.js'
],
capabilities: {
browserName: 'phantomjs',
version: '',
platform: 'ANY'
},
//baseUrl: 'http://testapp.example.com/index.html',
rootElement: 'body',
allScriptsTimeout: 11000,
onPrepare: function () {},
jasmineNodeOpts: {
onComplete: function () {},
isVerbose: true,
showColors: true,
includeStackTrace: true,
defaultTimeoutInterval: 30000
}
};
also I noticed that sometimes there's no step 2 needed and it will go directly to ECONNECT error, and sometimes it gets stuck in step 2 for a number of tests and eventually will terminate phantomjs server.
This is an issue with Protractor that was resolved in version 0.17 and made better in 0.18.
It's a bug with a long tail, but the TL;DR is that Protractor's .get(url) function actually uses client-side JavaScript to make the location change; this is to ensure it properly bootstraps. An unfortunate side effect of that design is that for some reason, PhantomJS takes a few seconds to navigate over properly.
The bug was resolved by adding a longer timeout to the .get function.
Github Issue: https://github.com/angular/protractor/issues/85
Relevant changelog entries:
v0.18
(10aec0f) fix(pageload): increase wait timeout
The 300 ms wait caused problems when testing IE on Sauce Labs. It seems way too short. "browser.get()" invariably timed out. Increasing it solved our problem.
v0.17
(a0bd84b) fix(pageload): add a wait during protractor.get() to solve unload issues
Some systems would not wait for the browser unload event to finish before beginning the asynchronous script execution.
Closes #406. Closes #85.
I've run your test locally (with a different page, but otherwise the same code):
Happy testing!

Resources