vault/ui/tests/integration/components/form/v2/wizard-test.js
Vault Automation f0cf2a4b68
UI/v2 forms infrastructure (#14134) (#14694)
* copies v2 form components from POC branch

* fixes issue in form-config-generator when path parameters are not defined

* adds api code-generator for snippet creation

* expands cli and terraform code generators

* updates form-config-generator to return api path from spec

* fixes issue setting field value in v2-form class

* updates form-config types

* updates v2 form and renderer components to conditional render fields

* adds v2 form apply component

* updates v2 form wizard component to support apply step

* add support for field types (text input variants, text area, checkbox, radio, masked input) and add test coverage

* Dynamic field visibility and Select field support

* [POC] Public PKI (mocked) Wizard - revert this before merging

* Revert "[POC] Public PKI (mocked) Wizard - revert this before merging"

This reverts commit 66646f1d7a71d0e67028ebcabcfe33925197ffc9.

* cleanup & address copilot pr comments

* address PR comments

---------

Co-authored-by: Shannon Roberts (Beagin) <beagins@users.noreply.github.com>
Co-authored-by: Jordan Reimer <jordan.reimer@hashicorp.com>
2026-05-13 08:46:34 -07:00

90 lines
2.3 KiB
JavaScript

/**
* Copyright IBM Corp. 2016, 2026
* SPDX-License-Identifier: BUSL-1.1
*/
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { module, test } from 'qunit';
import sinon from 'sinon';
import { setupRenderingTest } from 'vault/tests/helpers';
module('Integration | Component | form/v2/wizard', function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
this.onCancel = sinon.spy();
this.onSuccess = sinon.spy();
this.wizardConfig = {
title: 'Test Wizard',
description: 'A test wizard',
steps: [
{
name: 'step1',
title: 'Step 1',
description: 'First step',
formConfig: {
name: 'step1-form',
path: '/v1/test/step1',
payload: {
name: '',
},
submit: sinon.stub().resolves({ id: 'step1-result' }),
sections: [
{
name: 'basic',
fields: [
{
name: 'name',
label: 'Name',
type: 'TextInput',
validations: [{ type: 'required' }],
},
],
},
],
},
},
{
name: 'step2',
title: 'Step 2',
description: 'Second step',
formConfig: {
name: 'step2-form',
path: '/v1/test/step2',
payload: {
description: '',
},
submit: sinon.stub().resolves({ id: 'step2-result' }),
sections: [
{
name: 'details',
fields: [
{
name: 'description',
label: 'Description',
type: 'TextArea',
},
],
},
],
},
},
],
};
});
test('it renders the first step content', async function (assert) {
await render(hbs`
<Form::V2::Wizard
@config={{this.wizardConfig}}
@onCancel={{this.onCancel}}
@onSuccess={{this.onSuccess}}
/>
`);
assert.dom('label').includesText('Name', 'renders first step field');
assert.dom(this.element).includesText('Step 1', 'renders first step title');
});
});