Commit 7dcdbbff authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera

Merge branch '220020-flaky-test' into 'master'

Fix flaky spec in repo_editor_spec.js

Closes #220020

See merge request gitlab-org/gitlab!33744
parents a45b8ff8 3c0eef90
......@@ -525,6 +525,14 @@ describe('RepoEditor', () => {
);
};
const watchState = watched =>
new Promise(resolve => {
const unwatch = vm.$store.watch(watched, () => {
unwatch();
resolve();
});
});
beforeEach(() => {
setFileName('bar.md');
......@@ -562,7 +570,10 @@ describe('RepoEditor', () => {
it("adds a markdown image tag to the file's contents", () => {
pasteImage();
return waitForPromises().then(() => {
// Pasting an image does a lot of things like using the FileReader API,
// so, waitForPromises isn't very reliable (and causes a flaky spec)
// Read more about state.watch: https://vuex.vuejs.org/api/#watch
return watchState(s => s.entries['foo/bar.md'].content).then(() => {
expect(vm.file.content).toBe('hello world\n![foo.png](./foo.png)');
});
});
......
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