Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
minerva
core
Commits
8e3c8aef
Commit
8e3c8aef
authored
6 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
when user load map that was removed and loaded again there will be no error due to caching
parent
390c28b6
No related branches found
No related tags found
1 merge request
!335
Resolve "minerva popup `Cannot read property 'getModel' of null`"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend-js/src/main/js/map/overlay/AbstractDbOverlay.js
+6
-0
6 additions, 0 deletions
frontend-js/src/main/js/map/overlay/AbstractDbOverlay.js
frontend-js/src/test/js/map/overlay/SearchDbOverlay-test.js
+81
-65
81 additions, 65 deletions
frontend-js/src/test/js/map/overlay/SearchDbOverlay-test.js
with
87 additions
and
65 deletions
frontend-js/src/main/js/map/overlay/AbstractDbOverlay.js
+
6
−
0
View file @
8e3c8aef
...
...
@@ -180,6 +180,12 @@ AbstractDbOverlay.prototype.searchByEncodedQuery = function (originalQuery, fitB
return
this
.
searchNamesByTarget
(
query
.
target
);
}
else
if
(
query
.
type
===
AbstractDbOverlay
.
QueryType
.
SEARCH_BY_COORDINATES
)
{
query
.
coordinates
=
new
google
.
maps
.
Point
(
query
.
coordinates
.
x
,
query
.
coordinates
.
y
);
if
(
this
.
getMap
().
getSubmapById
(
query
.
modelId
)
===
null
)
{
//this can happen when cached data comes from project that was removed and something else
//was uploaded with the same name
logger
.
warn
(
"
Invalid search query. Model doesn't exist:
"
+
query
.
modelId
);
return
Promise
.
resolve
();
}
return
this
.
searchByCoordinates
(
query
);
}
else
{
throw
new
Error
(
"
Unknown type of query:
"
+
query
.
type
);
...
...
This diff is collapsed.
Click to expand it.
frontend-js/src/test/js/map/overlay/SearchDbOverlay-test.js
+
81
−
65
View file @
8e3c8aef
"
use strict
"
;
require
(
'
../../mocha-config.js
'
);
var
logger
=
require
(
'
../../logger
'
);
...
...
@@ -9,12 +10,12 @@ var AbstractDbOverlay = require('../../../../main/js/map/overlay/AbstractDbOverl
var
assert
=
require
(
'
assert
'
);
var
Promise
=
require
(
'
bluebird
'
);
describe
(
'
SearchDbOverlay
'
,
function
()
{
it
(
"
constructor 1
"
,
function
()
{
describe
(
'
SearchDbOverlay
'
,
function
()
{
it
(
"
constructor 1
"
,
function
()
{
var
map
=
helper
.
createCustomMap
();
var
oc
=
new
SearchDbOverlay
({
map
:
map
,
name
:
'
search
'
map
:
map
,
name
:
'
search
'
});
assert
.
ok
(
oc
);
assert
.
equal
(
oc
.
getName
(),
'
search
'
);
...
...
@@ -22,44 +23,44 @@ describe('SearchDbOverlay', function() {
assert
.
equal
(
logger
.
getWarnings
.
length
,
0
);
});
it
(
"
searchByCoordinates with too far alias as result
"
,
function
()
{
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
it
(
"
searchByCoordinates with too far alias as result
"
,
function
()
{
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
var
map
=
helper
.
createCustomMap
(
project
);
var
searchDb
=
helper
.
createSearchDbOverlay
(
map
);
var
searchParams
=
{
modelId
:
map
.
getModel
().
getId
(),
coordinates
:
new
google
.
maps
.
Point
(
207.73
,
479.18
),
zoom
:
4
,
modelId
:
map
.
getModel
().
getId
(),
coordinates
:
new
google
.
maps
.
Point
(
207.73
,
479.18
),
zoom
:
4
,
};
return
searchDb
.
searchByCoordinates
(
searchParams
);
}).
then
(
function
(
result
)
{
}).
then
(
function
(
result
)
{
assert
.
equal
(
result
.
length
,
0
);
});
});
describe
(
"
searchByQuery
"
,
function
()
{
it
(
"
with perfectMatch
"
,
function
()
{
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
describe
(
"
searchByQuery
"
,
function
()
{
it
(
"
with perfectMatch
"
,
function
()
{
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
var
map
=
helper
.
createCustomMap
(
project
);
map
.
getModel
().
setId
(
15781
);
var
searchDb
=
helper
.
createSearchDbOverlay
(
map
);
return
searchDb
.
searchByQuery
(
"
s1
"
,
true
);
}).
then
(
function
(
result
)
{
}).
then
(
function
(
result
)
{
assert
.
equal
(
result
.
length
,
1
);
assert
.
equal
(
result
[
0
].
length
,
1
);
});
});
it
(
"
check state when network problems
"
,
function
()
{
it
(
"
check state when network problems
"
,
function
()
{
var
problematicQuery
=
"
sxx1
"
;
var
searchDb
;
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
var
map
=
helper
.
createCustomMap
(
project
);
searchDb
=
helper
.
createSearchDbOverlay
(
map
);
return
searchDb
.
searchByQuery
(
problematicQuery
);
}).
then
(
null
,
function
()
{
}).
then
(
null
,
function
()
{
var
queries
=
searchDb
.
getQueries
();
var
promises
=
[];
for
(
var
i
=
0
;
i
<
queries
.
length
;
i
++
)
{
...
...
@@ -70,119 +71,134 @@ describe('SearchDbOverlay', function() {
});
});
it
(
"
searchByEncodedQuery
"
,
function
()
{
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
var
map
=
helper
.
createCustomMap
(
project
);
var
searchDb
=
helper
.
createSearchDbOverlay
(
map
);
var
point
=
new
google
.
maps
.
Point
(
316.05
,
253.61
);
var
queryType
=
AbstractDbOverlay
.
QueryType
.
SEARCH_BY_COORDINATES
;
var
query
=
searchDb
.
encodeQuery
(
queryType
,
map
.
getModel
().
getId
(),
point
,
2
);
return
searchDb
.
searchByEncodedQuery
(
query
);
}).
then
(
function
(
result
)
{
assert
.
ok
(
result
.
length
>
0
);
describe
(
"
searchByEncodedQuery
"
,
function
()
{
it
(
"
search by coordinates
"
,
function
()
{
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
var
map
=
helper
.
createCustomMap
(
project
);
var
searchDb
=
helper
.
createSearchDbOverlay
(
map
);
var
point
=
new
google
.
maps
.
Point
(
316.05
,
253.61
);
var
queryType
=
AbstractDbOverlay
.
QueryType
.
SEARCH_BY_COORDINATES
;
var
query
=
searchDb
.
encodeQuery
(
queryType
,
map
.
getModel
().
getId
(),
point
,
2
);
return
searchDb
.
searchByEncodedQuery
(
query
);
}).
then
(
function
(
result
)
{
assert
.
ok
(
result
.
length
>
0
);
});
});
it
(
"
search by coordinates on map that doesn't exist
"
,
function
()
{
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
var
map
=
helper
.
createCustomMap
(
project
);
var
searchDb
=
helper
.
createSearchDbOverlay
(
map
);
var
point
=
new
google
.
maps
.
Point
(
316.05
,
253.61
);
var
queryType
=
AbstractDbOverlay
.
QueryType
.
SEARCH_BY_COORDINATES
;
var
query
=
searchDb
.
encodeQuery
(
queryType
,
-
1
,
point
,
2
);
return
searchDb
.
searchByEncodedQuery
(
query
);
}).
then
(
function
(
result
)
{
assert
.
equal
(
logger
.
getWarnings
().
length
,
1
);
assert
.
equal
(
result
.
length
,
0
);
});
});
});
describe
(
"
searchByCoordinates
"
,
function
()
{
it
(
"
with too far reaction as result
"
,
function
()
{
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
describe
(
"
searchByCoordinates
"
,
function
()
{
it
(
"
with too far reaction as result
"
,
function
()
{
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
var
map
=
helper
.
createCustomMap
(
project
);
var
searchDb
=
helper
.
createSearchDbOverlay
(
map
);
var
searchParams
=
{
modelId
:
map
.
getModel
().
getId
(),
coordinates
:
new
google
.
maps
.
Point
(
553.10
,
479.18
),
zoom
:
4
,
modelId
:
map
.
getModel
().
getId
(),
coordinates
:
new
google
.
maps
.
Point
(
553.10
,
479.18
),
zoom
:
4
,
};
return
searchDb
.
searchByCoordinates
(
searchParams
);
}).
then
(
function
(
result
)
{
}).
then
(
function
(
result
)
{
assert
.
equal
(
result
.
length
,
0
);
});
});
it
(
"
on empty map
"
,
function
()
{
it
(
"
on empty map
"
,
function
()
{
helper
.
setUrl
(
"
http://test/?id=empty
"
);
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
var
map
=
helper
.
createCustomMap
(
project
);
var
searchDb
=
helper
.
createSearchDbOverlay
(
map
);
var
searchParams
=
{
modelId
:
map
.
getModel
().
getId
(),
coordinates
:
new
google
.
maps
.
Point
(
553.10
,
479.18
),
zoom
:
4
,
modelId
:
map
.
getModel
().
getId
(),
coordinates
:
new
google
.
maps
.
Point
(
553.10
,
479.18
),
zoom
:
4
,
};
return
searchDb
.
searchByCoordinates
(
searchParams
);
}).
then
(
function
(
result
)
{
}).
then
(
function
(
result
)
{
assert
.
equal
(
result
.
length
,
0
);
});
});
it
(
"
on hidden nested object
"
,
function
()
{
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
it
(
"
on hidden nested object
"
,
function
()
{
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
var
map
=
helper
.
createCustomMap
(
project
);
var
searchDb
=
helper
.
createSearchDbOverlay
(
map
);
var
searchParams
=
{
modelId
:
map
.
getModel
().
getId
(),
coordinates
:
new
google
.
maps
.
Point
(
316.05
,
253.61
),
zoom
:
2
,
modelId
:
map
.
getModel
().
getId
(),
coordinates
:
new
google
.
maps
.
Point
(
316.05
,
253.61
),
zoom
:
2
,
};
return
searchDb
.
searchByCoordinates
(
searchParams
);
}).
then
(
function
(
result
)
{
}).
then
(
function
(
result
)
{
// id of the parent
assert
.
equal
(
result
[
0
].
getId
(),
329159
);
});
});
it
(
"
on nested object
"
,
function
()
{
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
it
(
"
on nested object
"
,
function
()
{
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
var
map
=
helper
.
createCustomMap
(
project
);
var
searchDb
=
helper
.
createSearchDbOverlay
(
map
);
var
searchParams
=
{
modelId
:
map
.
getModel
().
getId
(),
coordinates
:
new
google
.
maps
.
Point
(
316.05
,
253.61
),
zoom
:
4
,
modelId
:
map
.
getModel
().
getId
(),
coordinates
:
new
google
.
maps
.
Point
(
316.05
,
253.61
),
zoom
:
4
,
};
return
searchDb
.
searchByCoordinates
(
searchParams
);
}).
then
(
function
(
result
)
{
}).
then
(
function
(
result
)
{
assert
.
equal
(
result
[
0
].
getId
(),
329159
);
});
});
});
describe
(
"
getDetailDataByIdentifiedElement
"
,
function
()
{
it
(
"
get by alias
"
,
function
()
{
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
describe
(
"
getDetailDataByIdentifiedElement
"
,
function
()
{
it
(
"
get by alias
"
,
function
()
{
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
var
map
=
helper
.
createCustomMap
(
project
);
var
searchDb
=
helper
.
createSearchDbOverlay
(
map
);
var
searchParams
=
new
IdentifiedElement
({
type
:
"
ALIAS
"
,
id
:
329177
,
modelId
:
project
.
getModel
().
getId
(),
type
:
"
ALIAS
"
,
id
:
329177
,
modelId
:
project
.
getModel
().
getId
(),
});
return
searchDb
.
getDetailDataByIdentifiedElement
(
searchParams
);
}).
then
(
function
(
result
)
{
}).
then
(
function
(
result
)
{
assert
.
equal
(
result
.
getId
(),
329177
);
});
});
it
(
"
get by point
"
,
function
()
{
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
it
(
"
get by point
"
,
function
()
{
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
var
map
=
helper
.
createCustomMap
(
project
);
var
searchDb
=
helper
.
createSearchDbOverlay
(
map
);
var
searchParams
=
new
IdentifiedElement
({
type
:
"
POINT
"
,
id
:
"
2,3
"
,
modelId
:
project
.
getModel
().
getId
(),
type
:
"
POINT
"
,
id
:
"
2,3
"
,
modelId
:
project
.
getModel
().
getId
(),
});
return
searchDb
.
getDetailDataByIdentifiedElement
(
searchParams
);
}).
then
(
function
(
result
)
{
}).
then
(
function
(
result
)
{
assert
.
equal
(
result
,
null
);
});
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment