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
25d9884f
Commit
25d9884f
authored
Feb 11, 2021
by
Paul Slaughter
Committed by
Jose Ivan Vargas
Feb 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add FE integration spec for IDE open in MR
- Also fixes 404 route to actually return 404
parent
1e3ed715
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
120 additions
and
8 deletions
+120
-8
spec/frontend/fixtures/api_merge_requests.rb
spec/frontend/fixtures/api_merge_requests.rb
+16
-3
spec/frontend_integration/ide/helpers/ide_helper.js
spec/frontend_integration/ide/helpers/ide_helper.js
+7
-1
spec/frontend_integration/ide/helpers/start.js
spec/frontend_integration/ide/helpers/start.js
+5
-4
spec/frontend_integration/ide/user_opens_mr_spec.js
spec/frontend_integration/ide/user_opens_mr_spec.js
+60
-0
spec/frontend_integration/test_helpers/fixtures.js
spec/frontend_integration/test_helpers/fixtures.js
+6
-0
spec/frontend_integration/test_helpers/mock_server/index.js
spec/frontend_integration/test_helpers/mock_server/index.js
+6
-0
spec/frontend_integration/test_helpers/mock_server/routes/404.js
...ontend_integration/test_helpers/mock_server/routes/404.js
+2
-0
spec/frontend_integration/test_helpers/mock_server/routes/projects.js
...d_integration/test_helpers/mock_server/routes/projects.js
+18
-0
No files found.
spec/frontend/fixtures/api_merge_requests.rb
View file @
25d9884f
...
...
@@ -6,9 +6,10 @@ RSpec.describe API::MergeRequests, '(JavaScript fixtures)', type: :request do
include
ApiHelpers
include
JavaScriptFixturesHelpers
let
(
:admin
)
{
create
(
:admin
,
name:
'root'
)
}
let
(
:namespace
)
{
create
(
:namespace
,
name:
'gitlab-test'
)}
let
(
:project
)
{
create
(
:project
,
:repository
,
namespace:
namespace
,
path:
'lorem-ipsum'
)
}
let_it_be
(
:admin
)
{
create
(
:admin
,
name:
'root'
)
}
let_it_be
(
:namespace
)
{
create
(
:namespace
,
name:
'gitlab-test'
)}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
namespace:
namespace
,
path:
'lorem-ipsum'
)
}
let_it_be
(
:mr
)
{
create
(
:merge_request
,
source_project:
project
)
}
before
(
:all
)
do
clean_frontend_fixtures
(
'api/merge_requests'
)
...
...
@@ -21,4 +22,16 @@ RSpec.describe API::MergeRequests, '(JavaScript fixtures)', type: :request do
expect
(
response
).
to
be_successful
end
it
'api/merge_requests/versions.json'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
mr
.
iid
}
/versions"
,
admin
)
expect
(
response
).
to
be_successful
end
it
'api/merge_requests/changes.json'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
mr
.
iid
}
/changes"
,
admin
)
expect
(
response
).
to
be_successful
end
end
spec/frontend_integration/ide/helpers/ide_helper.js
View file @
25d9884f
...
...
@@ -69,7 +69,7 @@ const openFileRow = (row) => {
row
.
click
();
};
const
findAndTraverseToPath
=
async
(
path
,
index
=
0
,
row
=
null
)
=>
{
export
const
findAndTraverseToPath
=
async
(
path
,
index
=
0
,
row
=
null
)
=>
{
if
(
!
path
)
{
return
row
;
}
...
...
@@ -110,6 +110,12 @@ const findAndClickRootAction = async (name) => {
button
.
click
();
};
/**
* Drop leading "/-/ide" and file path from the current URL
*/
export
const
getBaseRoute
=
(
url
=
window
.
location
.
pathname
)
=>
url
.
replace
(
/^
\/
-
\/
ide/
,
''
).
replace
(
/
\/
-
\/
.*$/
,
''
);
export
const
clickPreviewMarkdown
=
()
=>
{
screen
.
getByText
(
'
Preview Markdown
'
).
click
();
};
...
...
spec/frontend_integration/ide/helpers/start.js
View file @
25d9884f
...
...
@@ -4,11 +4,12 @@ import Editor from '~/ide/lib/editor';
import
extendStore
from
'
~/ide/stores/extend
'
;
import
{
IDE_DATASET
}
from
'
./mock_data
'
;
export
default
(
container
,
{
isRepoEmpty
=
false
,
path
=
''
}
=
{})
=>
{
export
default
(
container
,
{
isRepoEmpty
=
false
,
path
=
''
,
mrId
=
''
}
=
{})
=>
{
const
projectName
=
isRepoEmpty
?
'
lorem-ipsum-empty
'
:
'
lorem-ipsum
'
;
const
pathSuffix
=
mrId
?
`merge_requests/
${
mrId
}
`
:
`tree/master/-/
${
path
}
`
;
global
.
jsdom
.
reconfigure
({
url
:
`
${
TEST_HOST
}
/-/ide/project/gitlab-test/lorem-ipsum
${
isRepoEmpty
?
'
-empty
'
:
''
}
/tree/master/-/
${
path
}
`
,
url
:
`
${
TEST_HOST
}
/-/ide/project/gitlab-test/
${
projectName
}
/
${
pathSuffix
}
`
,
});
const
el
=
document
.
createElement
(
'
div
'
);
...
...
spec/frontend_integration/ide/user_opens_mr_spec.js
0 → 100644
View file @
25d9884f
import
{
basename
}
from
'
path
'
;
import
{
useOverclockTimers
}
from
'
test_helpers/utils/overclock_timers
'
;
import
{
getMergeRequests
,
getMergeRequestWithChanges
}
from
'
test_helpers/fixtures
'
;
import
*
as
ideHelper
from
'
./helpers/ide_helper
'
;
import
startWebIDE
from
'
./helpers/start
'
;
const
getRelevantChanges
=
()
=>
getMergeRequestWithChanges
().
changes
.
filter
((
x
)
=>
!
x
.
deleted_file
);
describe
(
'
IDE: User opens Merge Request
'
,
()
=>
{
useOverclockTimers
();
let
vm
;
let
container
;
let
changes
;
beforeEach
(
async
()
=>
{
const
[{
iid
:
mrId
}]
=
getMergeRequests
();
changes
=
getRelevantChanges
();
setFixtures
(
'
<div class="webide-container"></div>
'
);
container
=
document
.
querySelector
(
'
.webide-container
'
);
vm
=
startWebIDE
(
container
,
{
mrId
});
await
ideHelper
.
waitForTabToOpen
(
basename
(
changes
[
0
].
new_path
));
await
ideHelper
.
waitForMonacoEditor
();
});
afterEach
(
async
()
=>
{
vm
.
$destroy
();
vm
=
null
;
});
const
findAllTabs
=
()
=>
Array
.
from
(
document
.
querySelectorAll
(
'
.multi-file-tab
'
));
const
findAllTabsData
=
()
=>
findAllTabs
().
map
((
el
)
=>
({
title
:
el
.
getAttribute
(
'
title
'
),
text
:
el
.
textContent
.
trim
(),
}));
it
(
'
shows first change as active in file tree
'
,
async
()
=>
{
const
firstPath
=
changes
[
0
].
new_path
;
const
row
=
await
ideHelper
.
findAndTraverseToPath
(
firstPath
);
expect
(
row
).
toHaveClass
(
'
is-open
'
);
expect
(
row
).
toHaveClass
(
'
is-active
'
);
});
it
(
'
opens other changes
'
,
()
=>
{
// We only show first 10 changes
const
expectedTabs
=
changes
.
slice
(
0
,
10
).
map
((
x
)
=>
({
title
:
`
${
ideHelper
.
getBaseRoute
()}
/-/
${
x
.
new_path
}
/`
,
text
:
basename
(
x
.
new_path
),
}));
expect
(
findAllTabsData
()).
toEqual
(
expectedTabs
);
});
});
spec/frontend_integration/test_helpers/fixtures.js
View file @
25d9884f
...
...
@@ -31,6 +31,12 @@ export const getBranch = factory.json(() =>
export
const
getMergeRequests
=
factory
.
json
(()
=>
require
(
'
test_fixtures/api/merge_requests/get.json
'
),
);
export
const
getMergeRequestWithChanges
=
factory
.
json
(()
=>
require
(
'
test_fixtures/api/merge_requests/changes.json
'
),
);
export
const
getMergeRequestVersions
=
factory
.
json
(()
=>
require
(
'
test_fixtures/api/merge_requests/versions.json
'
),
);
export
const
getRepositoryFiles
=
factory
.
json
(()
=>
require
(
'
test_fixtures/projects_json/files.json
'
),
);
...
...
spec/frontend_integration/test_helpers/mock_server/index.js
View file @
25d9884f
...
...
@@ -4,6 +4,8 @@ import {
getEmptyProject
,
getBranch
,
getMergeRequests
,
getMergeRequestWithChanges
,
getMergeRequestVersions
,
getRepositoryFiles
,
getBlobReadme
,
getBlobImage
,
...
...
@@ -16,6 +18,8 @@ export const createMockServerOptions = () => ({
project
:
Model
,
branch
:
Model
,
mergeRequest
:
Model
,
mergeRequestChange
:
Model
,
mergeRequestVersion
:
Model
,
file
:
Model
,
userPermission
:
Model
,
},
...
...
@@ -30,6 +34,8 @@ export const createMockServerOptions = () => ({
projects
:
[
getProject
(),
getEmptyProject
()],
branches
:
[
getBranch
()],
mergeRequests
:
getMergeRequests
(),
mergeRequestChanges
:
[
getMergeRequestWithChanges
()],
mergeRequestVersions
:
getMergeRequestVersions
(),
filesRaw
:
[
{
raw
:
getBlobReadme
(),
...
...
spec/frontend_integration/test_helpers/mock_server/routes/404.js
View file @
25d9884f
import
{
Response
}
from
'
miragejs
'
;
export
default
(
server
)
=>
{
[
'
get
'
,
'
post
'
,
'
put
'
,
'
delete
'
,
'
patch
'
].
forEach
((
method
)
=>
{
server
[
method
](
'
*
'
,
()
=>
{
...
...
spec/frontend_integration/test_helpers/mock_server/routes/projects.js
View file @
25d9884f
...
...
@@ -20,4 +20,22 @@ export default (server) => {
return
result
.
models
;
});
server
.
get
(
'
/api/v4/projects/:id/merge_requests/:mid
'
,
(
schema
,
request
)
=>
{
const
mr
=
schema
.
mergeRequests
.
findBy
({
iid
:
request
.
params
.
mid
});
return
mr
.
attrs
;
});
server
.
get
(
'
/api/v4/projects/:id/merge_requests/:mid/versions
'
,
(
schema
,
request
)
=>
{
const
versions
=
schema
.
mergeRequestVersions
.
where
({
merge_request_id
:
request
.
params
.
mid
});
return
versions
.
models
;
});
server
.
get
(
'
/api/v4/projects/:id/merge_requests/:mid/changes
'
,
(
schema
,
request
)
=>
{
const
mrWithChanges
=
schema
.
mergeRequestChanges
.
findBy
({
iid
:
request
.
params
.
mid
});
return
mrWithChanges
.
attrs
;
});
};
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