ember-link icon indicating copy to clipboard operation
ember-link copied to clipboard

[Bug] 3.24.2 - up to - 3.25.3: `href` empty from links in rendering tests

Open esbanarango opened this issue 3 years ago β€’ 7 comments

🐞 Describe the Bug

In a rendering test the link helper always return an emptyhref.

πŸ”¬ Minimal Reproduction

  test('href test', async function (assert) {
    assert.expect(1);
    await render(hbs`
      {{#let (link route="login") as |l|}}
        <a href={{l.url}}>Login</a>
      {{/let}}
    `);
    assert.dom('a').hasAttribute('href', `/login`);
  });
Screen Shot 2021-03-08 at 9 29 56 AM

πŸ˜• Actual Behavior

Element a has an empty attribute "href".

πŸ€” Expected Behavior

Element a has attribute "href" with value "/login"

🌍 Environment

  • Ember: 3.25.3

βž• Additional Context

https://github.com/emberjs/ember.js/issues/19408

esbanarango avatar Mar 08 '21 14:03 esbanarango

Depending on how this addon does URL generation, I suspect it has to do roughly the same thing as the Ember PR's:

  • https://github.com/emberjs/ember.js/pull/19080
  • https://github.com/emberjs/ember.js/pull/19326
  • https://github.com/emberjs/ember.js/pull/19387
  • https://github.com/emberjs/ember.js/pull/19395

rwjblue avatar Mar 08 '21 15:03 rwjblue

@esbanarango that is roughly how Ember up until now also behaved and the addon tries to follow what Ember itself does. we even explicitly test for this behavior in the test suite here.

Turbo87 avatar Mar 08 '21 15:03 Turbo87

@Turbo87 mmmm that's weird. Looks like this is actually testing it to be "empty" ☹️.

https://github.com/buschtoens/ember-link/blob/master/tests/integration/components/link-test.ts#L40 or to be an ember selector (?) if you're using the setupLink hook:

(Using setupLink hook). Garaje_Tests_and_tmp-test_js_β€”_workspace__Workspace_

I don't think this is up with how Ember is behaving now.

This same test:

module('Integration | Component | TMP', function (hooks) {
  setupRenderingTest(hooks);

  test('href test', async function (assert) {
    assert.expect(1);
    await render(hbs`<LinkTo @route="login">test</LinkTo>`);
    assert.dom('a').hasAttribute('href', `/login`);
  });
});

works fine with ember-source: 3.25.3.

But this one breaks with ember-link: 1.3.1:

module('Integration | Component | TMP', function (hooks) {
  setupRenderingTest(hooks);

  test('href test', async function (assert) {
    assert.expect(1);
    await render(hbs`
      {{#let (link route="login") as |l|}}
        <a href={{l.url}}>Login</a>
      {{/let}}
    `);
    assert.dom('a').hasAttribute('href', `/login`);
  });
});
GitHub
Link primitive to pass around self-contained route references. It's {{link-to}}, but better! - buschtoens/ember-link

esbanarango avatar Mar 08 '21 15:03 esbanarango

I don't think this is up with how Ember is behaving now.

yes, because Ember changed its behavior multiple times lately πŸ€·β€β™‚οΈ

Turbo87 avatar Mar 08 '21 15:03 Turbo87

Yeah :/ sorry about this. We are trying to make the default behavior appropriate out of the box. From my perspective, the current implemetnation (in 3.24.3 and 3.25.3) is much better...

rwjblue avatar Mar 08 '21 15:03 rwjblue

I asked if this behavior were a bug in the related issue. Good to know that we will have a fix for it! πŸ‘πŸΌπŸ§‘

rogeraraujo90 avatar Mar 12 '21 19:03 rogeraraujo90

@Turbo87 I tried tackling this issue but I think I'm missing some context on how you guys are matching the way Ember behaves. Is this on your radar πŸ™ ?

esbanarango avatar Mar 29 '21 15:03 esbanarango