Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
d510b75c
Commit
d510b75c
authored
Nov 13, 2020
by
Denys Mishunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converted ide_spec to vtu
parent
f09bc126
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
126 additions
and
100 deletions
+126
-100
spec/frontend/ide/components/ide_spec.js
spec/frontend/ide/components/ide_spec.js
+126
-100
No files found.
spec/frontend/ide/components/ide_spec.js
View file @
d510b75c
import
Vue
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
{
createComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
createLocalVue
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
{
createStore
}
from
'
~/ide/stores
'
;
import
{
createStore
}
from
'
~/ide/stores
'
;
import
ErrorMessage
from
'
~/ide/components/error_message.vue
'
;
import
ide
from
'
~/ide/components/ide.vue
'
;
import
ide
from
'
~/ide/components/ide.vue
'
;
import
{
file
}
from
'
../helpers
'
;
import
{
file
}
from
'
../helpers
'
;
import
{
projectData
}
from
'
../mock_data
'
;
import
{
projectData
}
from
'
../mock_data
'
;
import
extendStore
from
'
~/ide/stores/extend
'
;
let
store
;
const
localVue
=
createLocalVue
();
localVue
.
use
(
Vuex
);
function
bootstrap
(
projData
)
{
describe
(
'
WebIDE
'
,
()
=>
{
store
=
createStore
()
;
const
emptyProjData
=
{
...
projectData
,
empty_repo
:
true
,
branches
:
{}
}
;
extendStore
(
store
,
document
.
createElement
(
'
div
'
))
;
let
wrapper
;
const
Component
=
Vue
.
extend
(
ide
);
function
createComponent
({
projData
=
emptyProjData
,
state
=
{},
mockStubs
=
{}
}
=
{})
{
const
store
=
createStore
();
store
.
state
.
currentProjectId
=
'
abcproject
'
;
store
.
state
.
currentProjectId
=
'
abcproject
'
;
store
.
state
.
currentBranchId
=
'
master
'
;
store
.
state
.
currentBranchId
=
'
master
'
;
store
.
state
.
projects
.
abcproject
=
{
...
projData
};
store
.
state
.
projects
.
abcproject
=
{
...
projData
};
Vue
.
set
(
store
.
state
.
trees
,
'
abcproject/master
'
,
{
store
.
state
.
trees
[
'
abcproject/master
'
]
=
{
tree
:
[],
tree
:
[],
loading
:
false
,
loading
:
false
,
});
return
createComponentWithStore
(
Component
,
store
,
{
emptyStateSvgPath
:
'
svg
'
,
noChangesStateSvgPath
:
'
svg
'
,
committedStateSvgPath
:
'
svg
'
,
});
}
describe
(
'
ide component, empty repo
'
,
()
=>
{
let
vm
;
beforeEach
(()
=>
{
const
emptyProjData
=
{
...
projectData
,
empty_repo
:
true
,
branches
:
{}
};
vm
=
bootstrap
(
emptyProjData
);
vm
.
$mount
();
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
it
(
'
renders "New file" button in empty repo
'
,
async
()
=>
{
await
waitForPromises
();
await
vm
.
$nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.ide-empty-state button[title="New file"]
'
)).
not
.
toBeNull
();
});
});
describe
(
'
ide component, non-empty repo
'
,
()
=>
{
let
vm
;
beforeEach
(()
=>
{
vm
=
bootstrap
(
projectData
);
vm
.
$mount
();
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
it
(
'
shows error message when set
'
,
async
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.gl-alert
'
)).
toBe
(
null
);
vm
.
$store
.
state
.
errorMessage
=
{
text
:
'
error
'
,
};
};
Object
.
keys
(
state
).
forEach
(
key
=>
{
await
waitForPromises
();
store
.
state
[
key
]
=
state
[
key
];
await
vm
.
$nextTick
();
expect
(
vm
.
$el
.
querySelector
(
'
.gl-alert
'
)).
not
.
toBe
(
null
);
});
describe
(
'
onBeforeUnload
'
,
()
=>
{
it
(
'
returns undefined when no staged files or changed files
'
,
()
=>
{
expect
(
vm
.
onBeforeUnload
()).
toBe
(
undefined
);
});
});
it
(
'
returns warning text when their are changed files
'
,
()
=>
{
return
shallowMount
(
ide
,
{
vm
.
$store
.
state
.
changedFiles
.
push
(
file
());
store
,
localVue
,
expect
(
vm
.
onBeforeUnload
()).
toBe
(
'
Are you sure you want to lose unsaved changes?
'
);
stubs
:
mockStubs
,
});
});
}
it
(
'
returns warning text when their are staged files
'
,
()
=>
{
afterEach
(()
=>
{
vm
.
$store
.
state
.
stagedFiles
.
push
(
file
());
wrapper
.
destroy
();
wrapper
=
null
;
});
expect
(
vm
.
onBeforeUnload
()).
toBe
(
'
Are you sure you want to lose unsaved changes?
'
);
describe
(
'
ide component, empty repo
'
,
()
=>
{
beforeEach
(()
=>
{
wrapper
=
createComponent
({
projData
:
{
empty_repo
:
true
,
},
});
});
});
it
(
'
updates event object
'
,
()
=>
{
it
(
'
renders "New file" button in empty repo
'
,
async
()
=>
{
const
event
=
{};
expect
(
wrapper
.
find
(
'
[title="New file"]
'
).
exists
()).
toBe
(
true
);
vm
.
$store
.
state
.
stagedFiles
.
push
(
file
());
vm
.
onBeforeUnload
(
event
);
expect
(
event
.
returnValue
).
toBe
(
'
Are you sure you want to lose unsaved changes?
'
);
});
});
});
});
describe
(
'
non-existent branch
'
,
()
=>
{
describe
(
'
ide component, non-empty repo
'
,
()
=>
{
it
(
'
does not render "New file" button for non-existent branch when repo is not empty
'
,
async
()
=>
{
describe
(
'
error message
'
,
()
=>
{
await
waitForPromises
();
it
(
'
does not show error message when it is not set
'
,
()
=>
{
await
vm
.
$nextTick
();
wrapper
=
createComponent
({
state
:
{
expect
(
vm
.
$el
.
querySelector
(
'
.ide-empty-state button[title="New file"]
'
)).
toBeNull
();
errorMessage
:
null
,
},
mockStubs
:
{
ErrorMessage
,
},
});
expect
(
wrapper
.
find
(
ErrorMessage
).
exists
()).
toBe
(
false
);
});
it
(
'
shows error message when set
'
,
()
=>
{
wrapper
=
createComponent
({
state
:
{
errorMessage
:
{
text
:
'
error
'
,
},
},
mockStubs
:
{
ErrorMessage
,
},
});
expect
(
wrapper
.
find
(
ErrorMessage
).
exists
()).
toBe
(
true
);
});
});
});
});
describe
(
'
branch with files
'
,
()
=>
{
describe
(
'
onBeforeUnload
'
,
()
=>
{
beforeEach
(()
=>
{
it
(
'
returns undefined when no staged files or changed files
'
,
()
=>
{
store
.
state
.
trees
[
'
abcproject/master
'
].
tree
=
[
file
()];
wrapper
=
createComponent
();
expect
(
wrapper
.
vm
.
onBeforeUnload
()).
toBe
(
undefined
);
});
it
(
'
returns warning text when their are changed files
'
,
()
=>
{
wrapper
=
createComponent
({
state
:
{
changedFiles
:
[
file
()],
},
});
expect
(
wrapper
.
vm
.
onBeforeUnload
()).
toBe
(
'
Are you sure you want to lose unsaved changes?
'
);
});
it
(
'
returns warning text when their are staged files
'
,
()
=>
{
wrapper
=
createComponent
({
state
:
{
stagedFiles
:
[
file
()],
},
});
expect
(
wrapper
.
vm
.
onBeforeUnload
()).
toBe
(
'
Are you sure you want to lose unsaved changes?
'
);
});
it
(
'
updates event object
'
,
()
=>
{
const
event
=
{};
wrapper
=
createComponent
({
state
:
{
stagedFiles
:
[
file
()],
},
});
wrapper
.
vm
.
onBeforeUnload
(
event
);
expect
(
event
.
returnValue
).
toBe
(
'
Are you sure you want to lose unsaved changes?
'
);
});
});
});
it
(
'
does not render "New file" button
'
,
async
()
=>
{
describe
(
'
non-existent branch
'
,
()
=>
{
await
waitForPromises
();
it
(
'
does not render "New file" button for non-existent branch when repo is not empty
'
,
()
=>
{
await
vm
.
$nextTick
();
wrapper
=
createComponent
({
state
:
{
projects
:
{},
},
});
expect
(
wrapper
.
find
(
'
[title="New file"]
'
).
exists
()).
toBe
(
false
);
});
});
expect
(
vm
.
$el
.
querySelector
(
'
.ide-empty-state button[title="New file"]
'
)).
toBeNull
();
describe
(
'
branch with files
'
,
()
=>
{
beforeEach
(()
=>
{
wrapper
=
createComponent
({
projData
:
{
empty_repo
:
false
,
},
});
});
it
(
'
does not render "New file" button
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
[title="New file"]
'
).
exists
()).
toBe
(
false
);
});
});
});
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment