0

I have a component listing-table which takes a number of properties, like this:

{{listing-table model=model.devices type='user' exclude='customerName'}}

This works as intended, and the integration tests also work just fine. However, my acceptance tests fail, because apparently my exclude property is not being taken into account while running an acceptance test.

I have tested this by printing to console the value of this.get('exclude') in the component's javascript file and getting undefined. However, printing e.g. this.get('type') yields the expected results.

I have then, for testing purposes, removed exclude and replaced type's value with it, i.e. type='endpointName,typeName', however, I would get the previous value in the console, e.g. user.

This is all way beyond puzzling, and I'd really like to know what's the matter with acceptance test. Any sort of hints are more than welcome, and thanks for your time!


EDIT:

I have now edited my acceptance test to exclude clicking through various elements to get to the route that contains my listing-table component:

From:

visit('/users/1')
click('a:contains("Devices")')

To:

visit('/users/1/devices')

And the test passes. I still don't understand why clicking through makes my component's properties disappear, whereas visiting the page directly works just fine.


EDIT 2:

So, here is some sample code. This is what my test looks like:

test('/customers/1/devices should display 5 devices', function (assert) {
  let type = server.create('endpoint-type')
  let user = server.create('user')
  let endpoint = server.create('endpoint', { type })
  server.createList('device', 5, { user })

  visit('/customers');
  click('a:contains("Customer 0")')
  click('a:contains("Devices")')
  andThen(function () {
    assert.equal(find('.device-listing').length, 5, 'should see 5 listings')
    assert.equal(find('th').text().trim(), 'IDModelManufacturerMACExtensionLocation', 'should only contain ID, Model, Manufacturer, MAC, Extension, and Location columns')
  })

Now, my Devices table should, in this case, omit the 'Customer' column, however, the column does appear in there, even though my component in devices.show.customers has been invoked with:

{{listing-table model=model.devices type='user' exclude='customerName'}}

My listing-table.js file basically uses this.get('exclude') inside the init () function to process the excludes, but as I said, if I add a console.log(this.get('exclude') in that file, I get undefined.


EDIT 3:

After more testing, I have made some progress, and the resulting question needs its own page, here.

finferflu
  • 1,368
  • 2
  • 11
  • 28

1 Answers1

1

Just a few thoughts:

  1. I assume this one has been done since you got green on your second attempt... are you using andThen to handle your assertions to make sure all of your async events are settled?
  2. Is the model hook being triggered? Depending on how you enter the route, the model hook will sometimes not get triggred: Why isn't my ember.js route model being called?

Might be helpful to have some code to look at.

IAMZERG
  • 100
  • 9
  • Thanks for the feedback! 1. Yes, I'm using `andThen()`; 2. Even if the model hook isn't being triggered, why does the same procedure work when running in the browser, but it fails when running in a test environment? I will update my original question with some code. Thanks again. – finferflu Aug 11 '17 at 19:54