Commit a02b930f authored by Lukas Eipert's avatar Lukas Eipert

Fix failing / flakey test

parent edb1dc8e
...@@ -5,6 +5,7 @@ exports[`dashboard should match the snapshot 1`] = ` ...@@ -5,6 +5,7 @@ exports[`dashboard should match the snapshot 1`] = `
class="operations-dashboard" class="operations-dashboard"
> >
<glmodal-stub <glmodal-stub
modalclass=""
modalid="add-projects-modal" modalid="add-projects-modal"
ok-disabled="true" ok-disabled="true"
ok-title="Add projects" ok-title="Add projects"
......
...@@ -4,6 +4,7 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -4,6 +4,7 @@ import axios from '~/lib/utils/axios_utils';
import ResetKey from 'ee/prometheus_alerts/components/reset_key.vue'; import ResetKey from 'ee/prometheus_alerts/components/reset_key.vue';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import { GlModal } from '@gitlab/ui'; import { GlModal } from '@gitlab/ui';
import waitForPromises from 'helpers/wait_for_promises';
describe('ResetKey', () => { describe('ResetKey', () => {
let Component; let Component;
...@@ -47,23 +48,23 @@ describe('ResetKey', () => { ...@@ -47,23 +48,23 @@ describe('ResetKey', () => {
expect(vm.find('.js-reset-auth-key').text()).toEqual('Reset key'); expect(vm.find('.js-reset-auth-key').text()).toEqual('Reset key');
}); });
it('reset updates key', done => { it('reset updates key', () => {
mock.onPost(propsData.changeKeyUrl).replyOnce(200, { token: 'newToken' }); mock.onPost(propsData.changeKeyUrl).replyOnce(200, { token: 'newToken' });
vm.find(GlModal).vm.$emit('ok'); vm.find(GlModal).vm.$emit('ok');
setTimeout(() => { return waitForPromises().then(() => {
expect(vm.vm.authorizationKey).toEqual('newToken');
expect(vm.find('#authorization-key').attributes('value')).toEqual('newToken'); expect(vm.find('#authorization-key').attributes('value')).toEqual('newToken');
done();
}); });
}); });
it('reset key failure shows error', done => { it('reset key failure shows error', () => {
mock.onPost(propsData.changeKeyUrl).replyOnce(500); mock.onPost(propsData.changeKeyUrl).replyOnce(500);
vm.find(GlModal).vm.$emit('ok'); vm.find(GlModal).vm.$emit('ok');
setTimeout(() => { return waitForPromises().then(() => {
expect(vm.find('#authorization-key').attributes('value')).toEqual( expect(vm.find('#authorization-key').attributes('value')).toEqual(
propsData.initialAuthorizationKey, propsData.initialAuthorizationKey,
); );
...@@ -71,7 +72,6 @@ describe('ResetKey', () => { ...@@ -71,7 +72,6 @@ describe('ResetKey', () => {
expect(document.querySelector('.flash-container').innerText.trim()).toEqual( expect(document.querySelector('.flash-container').innerText.trim()).toEqual(
'Failed to reset key. Please try again.', 'Failed to reset key. Please try again.',
); );
done();
}); });
}); });
}); });
...@@ -89,14 +89,13 @@ describe('ResetKey', () => { ...@@ -89,14 +89,13 @@ describe('ResetKey', () => {
expect(vm.find('#authorization-key').attributes('value')).toEqual(''); expect(vm.find('#authorization-key').attributes('value')).toEqual('');
}); });
it('Generate key button triggers key change', done => { it('Generate key button triggers key change', () => {
mock.onPost(propsData.changeKeyUrl).replyOnce(200, { token: 'newToken' }); mock.onPost(propsData.changeKeyUrl).replyOnce(200, { token: 'newToken' });
vm.find('.js-reset-auth-key').vm.$emit('click'); vm.find('.js-reset-auth-key').vm.$emit('click');
setTimeout(() => { return waitForPromises().then(() => {
expect(vm.find('#authorization-key').attributes('value')).toEqual('newToken'); expect(vm.find('#authorization-key').attributes('value')).toEqual('newToken');
done();
}); });
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment