diff --git a/app/javascript/spec/cloud-volume-form/__snapshots__/attach-detach-cloud-volume-form.spec.js.snap b/app/javascript/spec/cloud-volume-form/__snapshots__/attach-detach-cloud-volume-form.spec.js.snap
index 120df804862..eb86f377754 100644
--- a/app/javascript/spec/cloud-volume-form/__snapshots__/attach-detach-cloud-volume-form.spec.js.snap
+++ b/app/javascript/spec/cloud-volume-form/__snapshots__/attach-detach-cloud-volume-form.spec.js.snap
@@ -4652,7 +4652,1218 @@ exports[`Attach / Detach form component should submit Attach API call 1`] = `
dropdownLabel="Instance"
isAttach={true}
recordId="1"
- />
+ >
+
+
+
+
+
+ ,
+ Array [
+ ,
+ ],
+ ,
+ ]
+ }
+ schema={
+ Object {
+ "fields": Array [
+ Object {
+ "component": "select",
+ "id": "dropdown_id",
+ "includeEmpty": true,
+ "isRequired": true,
+ "label": "Instance",
+ "name": "dropdown_id",
+ "options": Array [
+ Object {
+ "label": "server1",
+ "value": "1",
+ },
+ Object {
+ "label": "server2",
+ "value": "2",
+ },
+ Object {
+ "label": "server3",
+ "value": "3",
+ },
+ Object {
+ "label": "server4",
+ "value": "4",
+ },
+ Object {
+ "label": "server5",
+ "value": "5",
+ },
+ ],
+ },
+ Array [
+ Object {
+ "component": "text-field",
+ "id": "device_mountpoint",
+ "isRequired": true,
+ "label": "Device Mountpoint",
+ "name": "device_mountpoint",
+ "validate": Array [
+ Object {
+ "type": "required",
+ },
+ ],
+ },
+ ],
+ Object {
+ "component": "spy-field",
+ "initialize": undefined,
+ "name": "spy-field",
+ },
+ ],
+ }
+ }
+ >
+ ,
+ Array [
+ ,
+ ],
+ ,
+ ]
+ }
+ isAttach={true}
+ schema={
+ Object {
+ "fields": Array [
+ Object {
+ "component": "select",
+ "id": "dropdown_id",
+ "includeEmpty": true,
+ "isRequired": true,
+ "label": "Instance",
+ "name": "dropdown_id",
+ "options": Array [
+ Object {
+ "label": "server1",
+ "value": "1",
+ },
+ Object {
+ "label": "server2",
+ "value": "2",
+ },
+ Object {
+ "label": "server3",
+ "value": "3",
+ },
+ Object {
+ "label": "server4",
+ "value": "4",
+ },
+ Object {
+ "label": "server5",
+ "value": "5",
+ },
+ ],
+ },
+ Array [
+ Object {
+ "component": "text-field",
+ "id": "device_mountpoint",
+ "isRequired": true,
+ "label": "Device Mountpoint",
+ "name": "device_mountpoint",
+ "validate": Array [
+ Object {
+ "type": "required",
+ },
+ ],
+ },
+ ],
+ Object {
+ "component": "spy-field",
+ "initialize": undefined,
+ "name": "spy-field",
+ },
+ ],
+ }
+ }
+ >
+
+
+
+
+
+
+
+
+
`;
diff --git a/app/javascript/spec/cloud-volume-form/attach-detach-cloud-volume-form.spec.js b/app/javascript/spec/cloud-volume-form/attach-detach-cloud-volume-form.spec.js
index 6c6a5a374a1..b6cbd4ef3da 100644
--- a/app/javascript/spec/cloud-volume-form/attach-detach-cloud-volume-form.spec.js
+++ b/app/javascript/spec/cloud-volume-form/attach-detach-cloud-volume-form.spec.js
@@ -33,8 +33,7 @@ describe('Attach / Detach form component', () => {
};
beforeEach(() => {
- fetchMock
- .once('/api/cloud_volumes/1?option_action=attach', response);
+ fetchMock.once('/api/cloud_volumes/1?option_action=attach', response);
});
afterEach(() => {
@@ -42,23 +41,22 @@ describe('Attach / Detach form component', () => {
fetchMock.restore();
});
- it('should render form', (done) => {
- const wrapper = shallow();
- setImmediate(() => {
- wrapper.update();
- expect(toJson(wrapper)).toMatchSnapshot();
- done();
+ it('should render form', async () => {
+ let wrapper;
+ await act(async() => {
+ wrapper = shallow();
});
+ expect(toJson(wrapper)).toMatchSnapshot();
});
-/* Steps to reach page tested:
- 1. Storage > Volume
- 2. Configuration > Attach / Detach to an Instance
-*/
+ /** Steps to reach page tested:
+ 1. Storage > Volume
+ 2. Configuration > Attach / Detach to an Instance
+ */
it('should render Attach Selected Cloud Volume to an Instance form', async(done) => {
let wrapper;
await act(async() => {
- wrapper = mount();
+ wrapper = mount();
});
setImmediate(() => {
@@ -71,7 +69,7 @@ describe('Attach / Detach form component', () => {
it('should render Detach Selected Cloud Volume from an Instance form', async(done) => {
let wrapper;
await act(async() => {
- wrapper = mount();
+ wrapper = mount();
});
setImmediate(() => {
@@ -81,15 +79,15 @@ describe('Attach / Detach form component', () => {
});
});
-/* Steps to reach page tested:
+ /** Steps to reach page tested:
1. Compute > Cloud > Instances
2. Select an Instance that allows for attach/detach (Openstack, IBM Cloud, Amazon)
3. Configuration > Attach / Detach a Cloud Volume from this Instance
-*/
+ */
it('should render Attach Cloud Volume to the Selected Instance form', async(done) => {
let wrapper;
await act(async() => {
- wrapper = mount();
+ wrapper = mount();
});
setImmediate(() => {
@@ -102,7 +100,7 @@ describe('Attach / Detach form component', () => {
it('should render Detach Cloud Volume from the Selected Instance form', async(done) => {
let wrapper;
await act(async() => {
- wrapper = mount();
+ wrapper = mount();
});
setImmediate(() => {
@@ -112,35 +110,38 @@ describe('Attach / Detach form component', () => {
});
});
-/*
- * Submit Logic
- */
-
+ /** Submit Logic */
it('should submit Attach API call', async(done) => {
+ let wrapper;
const submitData = {
- "action": "attach",
- "resource": {
- "vm_id": "1",
- "device": "",
- }
- }
+ action: 'attach',
+ resource: {
+ vm_id: '1',
+ device: '',
+ },
+ };
fetchMock.postOnce('/api/cloud_volumes/1', submitData);
- const wrapper = mount();
- expect(toJson(wrapper)).toMatchSnapshot();
- done();
- });
+ await act(async() => {
+ wrapper = mount();
+ });
+ setImmediate(() => {
+ wrapper.update();
+ expect(toJson(wrapper)).toMatchSnapshot();
+ done();
+ });
+ });
it('should submit Detach API call', async(done) => {
const submitData = {
- "action": "attach",
- "resource": {
- "vm_id": "1",
- "device": "",
- }
- }
+ action: 'attach',
+ resource: {
+ vm_id: '1',
+ device: '',
+ },
+ };
fetchMock.postOnce('/api/cloud_volumes/1', submitData);
- const wrapper = mount();
+ const wrapper = mount();
expect(toJson(wrapper)).toMatchSnapshot();
done();
});