Skip to content

Instantly share code, notes, and snippets.

@hatched
Created June 19, 2014 21:41
Show Gist options
  • Save hatched/d12e15eb80c894d7b2cb to your computer and use it in GitHub Desktop.
Save hatched/d12e15eb80c894d7b2cb to your computer and use it in GitHub Desktop.
fix failing test-prod kadams54-unit-constraints
diff --git a/app/widgets/create-machine-view.js b/app/widgets/create-machine-view.js
index ff6d965..9a9961b 100644
--- a/app/widgets/create-machine-view.js
+++ b/app/widgets/create-machine-view.js
@@ -93,8 +93,13 @@ YUI.add('create-machine-view', function(Y) {
*/
_handleContainerTypeChange: function(e) {
e.preventDefault();
- var constraints = this.get('container').one('.constraints'),
- newVal = e.target.one('option:checked').get('value');
+ var constraints = this.get('container').one('.constraints');
+ var newVal;
+ e.currentTarget.all('option').each(function(o) {
+ if (o.getAttribute('selected')) {
+ newVal = o.get('value');
+ }
+ });
this.set('containerType', newVal);
if (newVal === 'kvm') {
constraints.removeClass('hidden');
diff --git a/test/index.html b/test/index.html
index e604d50..a08ab74 100644
--- a/test/index.html
+++ b/test/index.html
@@ -85,7 +85,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
<script src="test_browser_search_widget.js"></script>
<script src="test_cache.js"></script>
<script src="test_charmbrowser_view.js"></script>
- <script src="test_state.js"></script>
<script src="test_ui_state.js"></script>
<script src="test_bundle_details_view.js"></script>
<script src="test_bundle_module.js"></script>
diff --git a/test/test_machine_view_panel.js b/test/test_machine_view_panel.js
index 6a5f1e5..9a707d1 100644
--- a/test/test_machine_view_panel.js
+++ b/test/test_machine_view_panel.js
@@ -372,7 +372,7 @@ describe('machine view panel view', function() {
assert.equal(placeArgs[1], 'new0');
});
- it('creates new container when dropped on container header', function() {
+ it.only('creates new container when dropped on container header', function(done) {
view.render();
var toggleStub = utils.makeStubMethod(view, '_toggleAllPlacedMessage');
this._cleanups.push(toggleStub.reset);
@@ -392,31 +392,38 @@ describe('machine view panel view', function() {
createView.all('option').each(function(option) {
var value = option.get('value');
if (value === 'lxc') {
- option.setAttribute('selected', 'true');
+ option.setAttribute('selected');
} else {
option.removeAttribute('selected');
}
});
// Confirm the container creation
createView.one('select').simulate('change');
- createView.one('.create').simulate('click');
- assert.deepEqual(env.addMachines.lastArguments()[0], [{
- containerType: 'lxc',
- parentId: '5',
- constraints: {
- 'cpu-power': '',
- mem: '',
- 'root-disk': ''
- }
- }], 'Args passed to addMachines are incorrect');
- // A new ghost machine has been added to the database.
- assert.notEqual(machines.getById('5/lxc/new0'), null,
- 'new container is not in the database');
- var placeArgs = env.placeUnit.lastArguments();
- assert.strictEqual(placeArgs[0].id, 'test/1',
- 'the unit ID passed to placeUnit is incorrect');
- assert.equal(placeArgs[1], '5/lxc/new0',
- 'the container ID passed to placeUnit is incorrect');
+
+ setTimeout(function() {
+ createView.one('.create').simulate('click');
+ }, 1000)
+
+ setTimeout(function() {
+ assert.deepEqual(env.addMachines.lastArguments()[0], [{
+ containerType: 'lxc',
+ parentId: '5',
+ constraints: {
+ 'cpu-power': '',
+ mem: '',
+ 'root-disk': ''
+ }
+ }], 'Args passed to addMachines are incorrect');
+ // A new ghost machine has been added to the database.
+ assert.notEqual(machines.getById('5/lxc/new0'), null,
+ 'new container is not in the database');
+ var placeArgs = env.placeUnit.lastArguments();
+ assert.strictEqual(placeArgs[0].id, 'test/1',
+ 'the unit ID passed to placeUnit is incorrect');
+ assert.equal(placeArgs[1], '5/lxc/new0',
+ 'the container ID passed to placeUnit is incorrect');
+ done()
+ }, 5000);
});
it('displays new container form when dropped on a machine', function() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment