2014-02-13 59 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")