[英]Ember.js: disappearing component properties while performing acceptance tests
I have a component listing-table
which takes a number of properties, like this: 我有一个包含许多属性的组件
listing-table
,如下所示:
{{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. 但是,我的验收测试失败,因为显然在运行验收测试时未考虑我的
exclude
属性。
I have tested this by printing to console the value of this.get('exclude')
in the component's javascript file and getting undefined
. 我已经通过打印以在组件的javascript文件中控制台
this.get('exclude')
的值并获得undefined
。 However, printing eg this.get('type')
yields the expected results. 但是,例如打印
this.get('type')
产生预期的结果。
I have then, for testing purposes, removed exclude
and replaced type
's value with it, ie type='endpointName,typeName'
, however, I would get the previous value in the console, eg user
. 然后,出于测试目的,我删除了
exclude
并将其替换为type
的值,即type='endpointName,typeName'
,但是,我会在控制台中获取先前的值,例如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: 现在,我已经编辑了验收测试,以排除单击各种元素以到达包含
listing-table
组件的路线listing-table
:
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: 编辑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: 现在,在这种情况下,我的设备表应该省略“客户”列,但是,即使我的
devices.show.customers
组件已被调用,该列也确实出现在其中:
{{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
. 我的
listing-table.js
文件基本上在init ()
函数中使用listing-table.js
this.get('exclude')
来处理排除项,但是正如我所说,如果我在console.log(this.get('exclude')
添加console.log(this.get('exclude')
该文件,我undefined
。
EDIT 3: 编辑3:
After more testing, I have made some progress, and the resulting question needs its own page, here . 经过更多测试之后,我已经取得了一些进步,所产生的问题需要在此处单独显示 。
Just a few thoughts: 只是一些想法:
Might be helpful to have some code to look at. 看看一些代码可能会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.