Problems with wallaby and delete links on travis

I have a weird problem that I don’t understand with wallaby right now. Locally everything runs
fine, but on Travis it fails.

When I try to click a sign out link like so:

<%= link "Sign out", to: session_path(@conn, :delete, @current_user), method: "delete" %>

with

session
|> click(Query.link("Sign out"))

the link is not clicked on travis.

I made sure that travis and my local machine uses phantomjs 2.1.1 and I am using phoenix, “1.2.1”,

After searching for the problem I found an old issue that had a similar problem, but is closed and marked as fixed.

Since the thing I am working on is open source, you can have a look at the problematic file here.

Hope someone here can help me.

2 Likes

A method: "delete" link creates a form instead of a link, so probably the ‘click’ thing of yours is looking for a link instead of a form, you should adjust it to work with the form instead I’d guess. Though I’ve not heard of Wallaby so I could not say. ^.^

1 Like

Thats not totally correct (at least in phoenix 1.2.1). If a link has a method: "delete" then phoenix_html wraps the link in a form. There is a javascript handler that listens for a click event on the link. When it gets the event it submits the form. So looking for a link is correct here :slight_smile:

1 Like

Ah I changed it to a submit button in my templates I see, I needed it to work without javascript and the original way is very broken without javascript. ^.^

But still, submitting the form itself would work regardless. :slight_smile:

1 Like

I was really surprised to see that it doesn’t work without JS. Is there a easy way to change this behavior? I would love to have it work without JS.

1 Like

Right now it has no fallback if there is no javascript or if javascript is disabled, just implementing a fallback works. In my case (apparently so long ago I do not remember) I changed the link to a button and listen to the event on the form to catch submit and pop up the message and cancel the event if it is canceled or let it pass if it is not. Something without javascript will just delete without the question. Simple to do. :slight_smile:

1 Like