From 00791309671db63ae5677942cf741c45ca00391c Mon Sep 17 00:00:00 2001 From: Jordan Reimer Date: Thu, 18 Nov 2021 14:57:04 -0700 Subject: [PATCH] Raft Snapshot Restore Bug (#13107) (#13210) * fixes issue restoring raft snapshot * adds changelog entry --- changelog/13107.txt | 3 ++ ui/app/adapters/application.js | 1 + .../components/raft-storage-restore-test.js | 31 +++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 changelog/13107.txt create mode 100644 ui/tests/integration/components/raft-storage-restore-test.js diff --git a/changelog/13107.txt b/changelog/13107.txt new file mode 100644 index 000000000000..50f01ef4b062 --- /dev/null +++ b/changelog/13107.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Fixes issue restoring raft storage snapshot +``` \ No newline at end of file diff --git a/ui/app/adapters/application.js b/ui/app/adapters/application.js index 59a3e660bfb9..6cb3662f7fca 100644 --- a/ui/app/adapters/application.js +++ b/ui/app/adapters/application.js @@ -5,6 +5,7 @@ import { assign } from '@ember/polyfills'; import { set } from '@ember/object'; import RSVP from 'rsvp'; import config from '../config/environment'; +import fetch from 'fetch'; const { APP } = config; const { POLLING_URLS, NAMESPACE_ROOT_URLS } = APP; diff --git a/ui/tests/integration/components/raft-storage-restore-test.js b/ui/tests/integration/components/raft-storage-restore-test.js new file mode 100644 index 000000000000..acab360305cd --- /dev/null +++ b/ui/tests/integration/components/raft-storage-restore-test.js @@ -0,0 +1,31 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { setupMirage } from 'ember-cli-mirage/test-support'; +import { render, triggerEvent, click } from '@ember/test-helpers'; +import hbs from 'htmlbars-inline-precompile'; + +module('Integration | Component | raft-storage-restore', function(hooks) { + setupRenderingTest(hooks); + setupMirage(hooks); + + test('it should restore snapshot', async function(assert) { + assert.expect(2); + + this.server.post('/sys/storage/raft/snapshot', () => { + assert.ok(true, 'Request made to restore snapshot'); + return; + }); + this.server.post('/sys/storage/raft/snapshot-force', () => { + assert.ok(true, 'Request made to force restore snapshot'); + return; + }); + + await render(hbs``); + await triggerEvent('[data-test-file-input]', 'change', { + files: [new Blob(['Raft Snapshot'])], + }); + await click('[data-test-edit-form-submit]'); + await click('#force-restore'); + await click('[data-test-edit-form-submit]'); + }); +});