Some angular unit tests use a wrong way of checking if an element exists

Bug #1493354 reported by Timur Sufiev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Low
Timur Sufiev

Bug Description

I've noticed a few occurrences of the following pattern in the Horizon unit tests for Angular directives: `expect(element.find(someSelector)).toBeDefined()`. That is going to always true, since element.find(someSelector) returns an Array-like object which _is_ defined. The correct pattern to use with such selectors is `expect(element.find(someSelector).length).toBe(1)`.

Tags: unittest
Timur Sufiev (tsufiev-x)
tags: added: unittest
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

Fix proposed to branch: master
Review: https://review.openstack.org/221283

Changed in horizon:
assignee: nobody → Timur Sufiev (tsufiev-x)
status: New → In Progress
Timur Sufiev (tsufiev-x)
Changed in horizon:
milestone: none → liberty-rc1
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/221283
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=1d8142b6f03304d2280f10c9650d28febd05165a
Submitter: Jenkins
Branch: master

commit 1d8142b6f03304d2280f10c9650d28febd05165a
Author: Timur Sufiev <email address hidden>
Date: Tue Sep 8 15:38:33 2015 +0300

    Check element's existence in angular unit tests in a proper way

    An assertion `expect(element.find(someSelector)).toBeDefined()` is
    always true due to implementation of jQuery selectors. The assertion
    that could actually catch something has the form
    `expect(element.find(someSelector).length).toBe(1)`.

    Change-Id: I52c48e26d87072731f689c136a00a4140a7afb3b
    Closes-Bug: #1493354

Changed in horizon:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in horizon:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in horizon:
milestone: liberty-rc1 → 8.0.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.