2014-02-13 100 views
1

我正在使用AngularJS 1.2.10 ng表和我正在写我的第一个结束使用茉莉&业力结束测试。AngularJS e2e测试ng表过滤器​​

问题是当我输入一个过滤器输入框(由ng-table提供)时,我的测试中的列表不会自动更新,即:它没有在测试中运行过滤器。当我通过浏览器手动测试时,我确实工作。

这里是我的测试

it "should allow filtering on name", -> 
    browser().navigateTo('#/debtors') 
    expect(browser().location().path()).toBe("/debtors") 
    element(".ng-table-filters > th:nth-child(2) input").val('John') 
    sleep(10) 
    expect(repeater('.table > tbody tr').count()).toBeGreaterThan(0) 
    expect(repeater('.table > tbody tr').row(0)).toContain("John Smith") 

这里是我的过滤器代码:

<table ng-table="tableParams" show-filter="true" class="table"> 
    <button ng-click="tableParams.sorting({code: 'asc'})" class="btn btn-default pull-right">Clear sorting</button> 
    <button ng-click="tableParams.filter({})" class="btn btn-default pull-right">Clear filter</button> 
    <tr class='listing' ng-repeat="debtor in $data"> 
    <td data-title="'Code'" sortable="'code'" filter="{ 'code': 'text'}"> 
     {{debtor.code}} 
    </td> 
    <td data-title="'Name'" sortable="'name'" filter="{ 'name': 'text'}"> 
     {{debtor.name}} 
    </td> 
    <td> 
     <a href="/api#/clients/{{debtor.id}}">Show</a> 
     <a href="/api#/clients/{{debtor.id}}/edit">Edit</a> 
     <a href="" ng-confirm-click="destroy(debtor.id)">Delete</a> 
    </td> 
    </tr> 
</table> 

当测试其手动有显示结果前稍有停顿,我没有打任何提交按钮。当我在测试中这样做时,尽管它看起来像ngTable事件没有触发。

回答

0

我开始用量角器,而不是哪个更好套房AngularJS项目

describe('filter debtor', -> 

    beforeEach -> 
    helper.login() 

    afterEach -> 
    helper.logout() 

    describe "when person", -> 
    it 'shows the client after creation', -> 
     browser.get('/api#/clients/new_debtor') 
     element(By.id("name")).sendKeys("John") 
     element(By.id("surname")).sendKeys("Smith") 
     element(By.id("create_btn")).click() 

     browser.get('/api#/debtors') 
     element.all(By.model("params.filter()[name]")).last().sendKeys("John") 
     first=element.all(By.id("listing")).first() 
     expect(first.getText()).toContain("John Smith")