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
1a1a35c5
Commit
1a1a35c5
authored
Apr 19, 2021
by
Illya Klymov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address reviewer comments
- use parseBoolean - use finders in tests
parent
8d1fa430
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
31 deletions
+47
-31
app/assets/javascripts/pages/projects/new/index.js
app/assets/javascripts/pages/projects/new/index.js
+22
-13
app/views/projects/new.html.haml
app/views/projects/new.html.haml
+1
-1
spec/frontend/pages/projects/new/components/app_spec.js
spec/frontend/pages/projects/new/components/app_spec.js
+9
-5
spec/frontend/vue_shared/new_namespace/new_namespace_page_spec.js
...ntend/vue_shared/new_namespace/new_namespace_page_spec.js
+15
-12
No files found.
app/assets/javascripts/pages/projects/new/index.js
View file @
1a1a35c5
import
Vue
from
'
vue
'
;
import
{
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
import
initProjectVisibilitySelector
from
'
../../../project_visibility
'
;
import
initProjectNew
from
'
../../../projects/project_new
'
;
import
NewProjectCreationApp
from
'
./components/app.vue
'
;
...
...
@@ -6,18 +7,32 @@ import NewProjectCreationApp from './components/app.vue';
initProjectVisibilitySelector
();
initProjectNew
.
bindEvents
();
function
initNewProjectCreation
(
el
,
props
)
{
const
{
pushToCreateProjectCommand
,
workingWithProjectsHelpPath
}
=
el
.
dataset
;
function
initNewProjectCreation
(
el
)
{
const
{
pushToCreateProjectCommand
,
workingWithProjectsHelpPath
,
newProjectGuidelines
,
hasErrors
,
isCiCdAvailable
,
}
=
el
.
dataset
;
const
props
=
{
hasErrors
:
parseBoolean
(
hasErrors
),
isCiCdAvailable
:
parseBoolean
(
isCiCdAvailable
),
newProjectGuidelines
,
};
const
provide
=
{
workingWithProjectsHelpPath
,
pushToCreateProjectCommand
,
};
return
new
Vue
({
el
,
components
:
{
NewProjectCreationApp
,
},
provide
:
{
workingWithProjectsHelpPath
,
pushToCreateProjectCommand
,
},
provide
,
render
(
h
)
{
return
h
(
NewProjectCreationApp
,
{
props
});
},
...
...
@@ -26,10 +41,4 @@ function initNewProjectCreation(el, props) {
const
el
=
document
.
querySelector
(
'
.js-new-project-creation
'
);
const
config
=
{
hasErrors
:
'
hasErrors
'
in
el
.
dataset
,
isCiCdAvailable
:
'
isCiCdAvailable
'
in
el
.
dataset
,
newProjectGuidelines
:
el
.
dataset
.
newProjectGuidelines
,
};
initNewProjectCreation
(
el
,
config
);
initNewProjectCreation
(
el
);
app/views/projects/new.html.haml
View file @
1a1a35c5
...
...
@@ -8,7 +8,7 @@
.project-edit-errors
=
render
'projects/errors'
.js-new-project-creation
{
data:
{
is_ci_cd_available:
(
ci_cd_projects_available?
if
Gitlab
.
ee?
)
,
has_errors:
@project
.
errors
.
any?
,
new_project_guidelines:
brand_new_project_guidelines
,
push_to_create_project_command:
push_to_create_project_command
,
working_with_projects_help_path:
help_page_path
(
"user/project/working_with_projects"
)
}
}
.js-new-project-creation
{
data:
{
is_ci_cd_available:
(
ci_cd_projects_available?
if
Gitlab
.
ee?
)
.
to_s
,
has_errors:
@project
.
errors
.
any?
.
to_s
,
new_project_guidelines:
brand_new_project_guidelines
,
push_to_create_project_command:
push_to_create_project_command
,
working_with_projects_help_path:
help_page_path
(
"user/project/working_with_projects"
)
}
}
.row
{
'v-cloak'
:
true
}
#blank-project-pane
.tab-pane.active
...
...
spec/frontend/pages/projects/new/components/app_spec.js
View file @
1a1a35c5
...
...
@@ -6,15 +6,21 @@ import NewNamespacePage from '~/vue_shared/new_namespace/new_namespace_page.vue'
describe
(
'
Experimental new project creation app
'
,
()
=>
{
let
wrapper
;
const
findNewNamespacePage
=
()
=>
wrapper
.
findComponent
(
NewNamespacePage
);
const
createComponent
=
(
propsData
)
=>
{
wrapper
=
shallowMount
(
App
,
{
propsData
});
};
afterEach
(()
=>
{
wrapper
.
destroy
();
});
describe
(
'
new_repo experiment
'
,
()
=>
{
it
(
'
passes new_repo experiment
'
,
()
=>
{
createComponent
();
expect
(
wrapper
.
findComponent
(
NewNamespacePage
).
props
().
experiment
).
toBe
(
'
new_repo
'
);
expect
(
findNewNamespacePage
(
).
props
().
experiment
).
toBe
(
'
new_repo
'
);
});
describe
(
'
when in the candidate variant
'
,
()
=>
{
...
...
@@ -23,7 +29,7 @@ describe('Experimental new project creation app', () => {
it
(
'
has "repository" in the panel title
'
,
()
=>
{
createComponent
();
expect
(
wrapper
.
findComponent
(
NewNamespacePage
).
props
().
panels
[
0
].
title
).
toBe
(
expect
(
findNewNamespacePage
(
).
props
().
panels
[
0
].
title
).
toBe
(
'
Create blank project/repository
'
,
);
});
...
...
@@ -35,9 +41,7 @@ describe('Experimental new project creation app', () => {
it
(
'
has "project" in the panel title
'
,
()
=>
{
createComponent
();
expect
(
wrapper
.
findComponent
(
NewNamespacePage
).
props
().
panels
[
0
].
title
).
toBe
(
'
Create blank project
'
,
);
expect
(
findNewNamespacePage
().
props
().
panels
[
0
].
title
).
toBe
(
'
Create blank project
'
);
});
});
});
...
...
spec/frontend/vue_shared/new_namespace/new_namespace_page_spec.js
View file @
1a1a35c5
...
...
@@ -8,6 +8,10 @@ import NewNamespacePage from '~/vue_shared/new_namespace/new_namespace_page.vue'
describe
(
'
Experimental new project creation app
'
,
()
=>
{
let
wrapper
;
const
findWelcomePage
=
()
=>
wrapper
.
findComponent
(
WelcomePage
);
const
findLegacyContainer
=
()
=>
wrapper
.
findComponent
(
LegacyContainer
);
const
findBreadcrumb
=
()
=>
wrapper
.
findComponent
(
GlBreadcrumb
);
const
DEFAULT_PROPS
=
{
title
:
'
Create something
'
,
initialBreadcrumb
:
'
Something
'
,
...
...
@@ -31,14 +35,13 @@ describe('Experimental new project creation app', () => {
afterEach
(()
=>
{
wrapper
.
destroy
();
window
.
location
.
hash
=
''
;
wrapper
=
null
;
});
it
(
'
passes experiment to welcome component if provided
'
,
()
=>
{
const
EXPERIMENT
=
'
foo
'
;
createComponent
({
propsData
:
{
experiment
:
EXPERIMENT
}
});
expect
(
wrapper
.
findComponent
(
WelcomePage
).
props
().
experiment
).
toBe
(
EXPERIMENT
);
expect
(
findWelcomePage
(
).
props
().
experiment
).
toBe
(
EXPERIMENT
);
});
describe
(
'
with empty hash
'
,
()
=>
{
...
...
@@ -47,18 +50,18 @@ describe('Experimental new project creation app', () => {
});
it
(
'
renders welcome page
'
,
()
=>
{
expect
(
wrapper
.
findComponent
(
WelcomePage
).
exists
()).
toBe
(
true
);
expect
(
findWelcomePage
(
).
exists
()).
toBe
(
true
);
});
it
(
'
does not render breadcrumbs
'
,
()
=>
{
expect
(
wrapper
.
findComponent
(
GlBreadcrumb
).
exists
()).
toBe
(
false
);
expect
(
findBreadcrumb
(
).
exists
()).
toBe
(
false
);
});
});
it
(
'
renders first container if jumpToLastPersistedPanel passed
'
,
()
=>
{
createComponent
({
propsData
:
{
jumpToLastPersistedPanel
:
true
}
});
expect
(
wrapper
.
findComponent
(
WelcomePage
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
findComponent
(
LegacyContainer
).
exists
()).
toBe
(
true
);
expect
(
findWelcomePage
(
).
exists
()).
toBe
(
false
);
expect
(
findLegacyContainer
(
).
exists
()).
toBe
(
true
);
});
describe
(
'
when hash is not empty on load
'
,
()
=>
{
...
...
@@ -68,16 +71,16 @@ describe('Experimental new project creation app', () => {
});
it
(
'
renders relevant container
'
,
()
=>
{
expect
(
wrapper
.
findComponent
(
WelcomePage
).
exists
()).
toBe
(
false
);
expect
(
findWelcomePage
(
).
exists
()).
toBe
(
false
);
const
container
=
wrapper
.
findComponent
(
LegacyContainer
);
const
container
=
findLegacyContainer
(
);
expect
(
container
.
exists
()).
toBe
(
true
);
expect
(
container
.
props
().
selector
).
toBe
(
DEFAULT_PROPS
.
panels
[
1
].
selector
);
});
it
(
'
renders breadcrumbs
'
,
()
=>
{
const
breadcrumb
=
wrapper
.
findComponent
(
GlBreadcrumb
);
const
breadcrumb
=
findBreadcrumb
(
);
expect
(
breadcrumb
.
exists
()).
toBe
(
true
);
expect
(
breadcrumb
.
props
().
items
[
0
].
text
).
toBe
(
DEFAULT_PROPS
.
initialBreadcrumb
);
});
...
...
@@ -97,7 +100,7 @@ describe('Experimental new project creation app', () => {
it
(
'
renders relevant container when hash changes
'
,
async
()
=>
{
createComponent
();
expect
(
wrapper
.
findComponent
(
WelcomePage
).
exists
()).
toBe
(
true
);
expect
(
findWelcomePage
(
).
exists
()).
toBe
(
true
);
window
.
location
.
hash
=
`#
${
DEFAULT_PROPS
.
panels
[
0
].
name
}
`
;
const
ev
=
document
.
createEvent
(
'
HTMLEvents
'
);
...
...
@@ -105,7 +108,7 @@ describe('Experimental new project creation app', () => {
window
.
dispatchEvent
(
ev
);
await
nextTick
();
expect
(
wrapper
.
findComponent
(
WelcomePage
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
findComponent
(
LegacyContainer
).
exists
()).
toBe
(
true
);
expect
(
findWelcomePage
(
).
exists
()).
toBe
(
false
);
expect
(
findLegacyContainer
(
).
exists
()).
toBe
(
true
);
});
});
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