Commit 577301cc authored by Paul Slaughter's avatar Paul Slaughter

Merge branch '221039-flaky-spec' into 'master'

Fix flaky spec in repo_editor_spec

Closes #221039

See merge request gitlab-org/gitlab!34804
parents 29ba61a3 84c531d7
...@@ -618,6 +618,11 @@ describe('RepoEditor', () => { ...@@ -618,6 +618,11 @@ describe('RepoEditor', () => {
}); });
}); });
// 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
const waitForFileContentChange = () => watchState(s => s.entries['foo/bar.md'].content);
beforeEach(() => { beforeEach(() => {
setFileName('bar.md'); setFileName('bar.md');
...@@ -637,13 +642,10 @@ describe('RepoEditor', () => { ...@@ -637,13 +642,10 @@ describe('RepoEditor', () => {
}); });
}); });
// The following test is flaky it('adds an image entry to the same folder for a pasted image in a markdown file', () => {
// see https://gitlab.com/gitlab-org/gitlab/-/issues/221039
// eslint-disable-next-line jest/no-disabled-tests
it.skip('adds an image entry to the same folder for a pasted image in a markdown file', () => {
pasteImage(); pasteImage();
return waitForPromises().then(() => { return waitForFileContentChange().then(() => {
expect(vm.$store.state.entries['foo/foo.png']).toMatchObject({ expect(vm.$store.state.entries['foo/foo.png']).toMatchObject({
path: 'foo/foo.png', path: 'foo/foo.png',
type: 'blob', type: 'blob',
...@@ -657,10 +659,7 @@ describe('RepoEditor', () => { ...@@ -657,10 +659,7 @@ describe('RepoEditor', () => {
it("adds a markdown image tag to the file's contents", () => { it("adds a markdown image tag to the file's contents", () => {
pasteImage(); pasteImage();
// Pasting an image does a lot of things like using the FileReader API, return waitForFileContentChange().then(() => {
// 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)'); 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