Ember.js 余烬验收测试未识别下拉列表的更改

Ember.js 余烬验收测试未识别下拉列表的更改,ember.js,ember-cli-mirage,Ember.js,Ember Cli Mirage,在我的余烬应用程序中,有一个下拉列表控制状态字段。状态字段控制表中显示的列数 如果下拉菜单=打开,则有14列。否则,就有12个。应用程序在这方面表现良好 我正试图写一个验收测试,我有一些问题 下拉列表标记为id=状态下拉列表。在订单模板/路线上 在我的验收测试中,我有: test('Col numbers by status', function(assert) { //go to the orders pages visit('/orders'); //wait for the o

在我的余烬应用程序中,有一个下拉列表控制状态字段。状态字段控制表中显示的列数

如果下拉菜单=打开,则有14列。否则,就有12个。应用程序在这方面表现良好

我正试图写一个验收测试,我有一些问题

下拉列表标记为id=状态下拉列表。在订单模板/路线上

在我的验收测试中,我有:

test('Col numbers by status', function(assert) {
  //go to the orders pages
  visit('/orders');
  //wait for the orders visit to resolve
  andThen(function() {
    //change the status to All Statuses
    Ember.$('#status-dropdown').val("All Statuses").change();
    //now check the number of columns in the orders table
    assert.equal(Ember.$('#orders-table thead tr th').length, 12);
    return pauseTest(); //for debugging
  });
});
但在测试中,列数返回为14

通过使用pauseTest()调用,我可以看到测试似乎正在处理的DOM。如果我打开控制台,执行$('#orders table thead tr th').length,它将返回12。不是14岁。然而,测试认为有14个

是否有一些技巧或怪癖我错过了有关灰烬验收测试和DOM上的下拉效果?我是否应该以某种方式更改下拉列表值,而不是像上面那样的jQuery调用

pauseTest()返回的DOM与实际测试认为存在的DOM不同,这有什么原因吗

我尝试过将下拉列表更改为“and then”之前的代码,但这不起作用。我已经尝试过在一秒钟内将更改嵌套到下拉列表中,然后在第一个下拉列表中嵌套(),但这也不起作用

我用海市蜃楼做测试,如果有必要的话

编辑以添加把手代码:

//status-dropdown.hbs

<select id="status-dropdown" class="col-xs-12" onchange={{action "filterByStatus" value="target.value"}}>
  <option value="all" selected={{eq status -1}}>All Statuses</option>
  <option value="Open" selected={{eq status "Open"}}>Open</option>
  <option value="Filled" selected={{eq status "Filled"}}>Filled</option>
  <option value="Rejected" selected={{eq status "Rejected"}}>Rejected</option>
  <option value="Cancelled" selected={{eq status "Cancelled"}}>Cancelled</option>
  <option value="Expired" selected={{eq status "Expired"}}>Expired</option>
</select>
//status-dropdown.hbs
所有状态
打开
填满
拒绝
取消
期满
上述代码作为一部分集成到orders.hbs模板中


hbs代码非常庞大和复杂,但就测试而言,重要的是主表中有14列。但最后两列仅在status=Open时出现,这是通过相关列的orders.hbs模板中的{{if statusIsOpen}}调用检查的。

共享下拉列表的把手代码并发布后续注释。这是一个异步操作:
Ember.$('#status dropdown').val(“所有状态”).change()?也许您需要等待操作完成,使用另一个
和第四个()
?Pavol,我尝试嵌套第四个(),但没关系@Iolmaus编辑了我的帖子,加入了车把代码。