From e3d5d5957101915a5f4b5d1bc8fa5c9eaafac279 Mon Sep 17 00:00:00 2001 From: Greg Hoin Date: Mon, 9 Aug 2021 18:37:11 +0200 Subject: [PATCH] Add proper cancel method --- .../project-config-variables/list-item.ts | 2 +- .../project-config-variables/list.hbs | 8 +++-- .../project-config-variables/list.ts | 7 ++++ .../project-config-variables-list-test.ts | 32 ++++++++++++++++++- 4 files changed, 45 insertions(+), 4 deletions(-) diff --git a/ui/app/components/project-config-variables/list-item.ts b/ui/app/components/project-config-variables/list-item.ts index b8f1504e76f..44746a55c74 100644 --- a/ui/app/components/project-config-variables/list-item.ts +++ b/ui/app/components/project-config-variables/list-item.ts @@ -70,7 +70,7 @@ export default class ProjectConfigVariablesListItemComponent extends Component {{#each this.variablesList as |variable|}} - {{/each}} diff --git a/ui/app/components/project-config-variables/list.ts b/ui/app/components/project-config-variables/list.ts index ad242b0c7e5..def7d125072 100644 --- a/ui/app/components/project-config-variables/list.ts +++ b/ui/app/components/project-config-variables/list.ts @@ -29,6 +29,13 @@ export default class ProjectConfigVariablesListComponent extends Component { return v.toProtobuf().toObject(); }); this.set('variablesList', varList); - await render(hbs``); + this.set('project', proj); + await render( + hbs`` + ); assert.dom('.variables-list').exists('The list renders'); assert.equal(page.variablesList.length, 10, 'it renders: the list has the proper length'); }); + test('adding and deleting variables works', async function (assert) { + let dbproj = await this.server.create('project', { name: 'Proj1' }); + let proj = dbproj.toProtobuf().toObject(); + let dbVariablesList = this.server.createList('config-variable', 3, 'random'); + let varList = dbVariablesList.map(v => { + return v.toProtobuf().toObject(); + }); + this.set('variablesList', varList); + this.set('project', proj); + await render( + hbs`` + ); + + assert.dom('.variables-list').exists('The list renders'); + assert.equal(page.variablesList.length, 3, 'the list contains all variables'); + await page.createButton(); + assert.ok(page.hasForm, 'Attempt to create: the form appears when the Add Variable button is clicked'); + await page.cancelButton(); + assert.notOk(page.hasForm, 'Attempt to create: the form is hidden after canceling'); + assert.equal( + page.variablesList.length, + 3, + 'Attempt to create: the list still has the normal count of variables after cancelling' + ); + }); + // test('only static variables are editable', async function (assert) {}); // test('internal variables', async function (assert) {}); // test('nameIsPath works', async function (assert) {});