Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9123837
language-select.spec.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
language-select.spec.js
View Options
/**
* Copyright (C) 2019 The Software Heritage developers
* See the AUTHORS file at the top-level directory of this distribution
* License: GNU Affero General Public License version 3, or any later version
* See top-level LICENSE file for more information
*/
import
{
random
,
checkLanguageHighlighting
}
from
'../utils'
;
const
$
=
Cypress
.
$
;
let
origin
;
let
contentWithLanguageInfo
,
contentWithoutLanguageInfo
;
const
languageSelect
=
'python'
;
describe
(
'Test Content Language Select'
,
function
()
{
before
(
function
()
{
origin
=
this
.
origin
[
0
];
contentWithLanguageInfo
=
this
.
Urls
.
browse_origin_content
(
origin
.
url
,
origin
.
content
[
1
].
path
);
contentWithoutLanguageInfo
=
this
.
Urls
.
browse_content
(
`sha1_git:
${
origin
.
content
[
1
].
sha1git
}
`
);
});
context
(
'When Language is detected'
,
function
()
{
it
(
'should display correct language in dropdown'
,
function
()
{
cy
.
visit
(
contentWithLanguageInfo
)
.
then
(()
=>
{
cy
.
get
(
`code.
${
$
(
'.language-select'
).
val
()
}
`
)
.
should
(
'exist'
);
});
});
});
context
(
'When Language is not detected'
,
function
()
{
it
(
'should have no selected language in dropdown'
,
function
()
{
cy
.
visit
(
contentWithoutLanguageInfo
).
then
(()
=>
{
assert
.
strictEqual
(
$
(
'.language-select'
).
val
(),
null
);
});
});
});
context
(
'When language is switched from dropdown'
,
function
()
{
before
(
function
()
{
cy
.
visit
(
contentWithLanguageInfo
);
cy
.
get
(
'.chosen-container'
)
.
click
()
.
get
(
'.chosen-results > li'
)
.
its
(
'length'
)
.
then
(
numOptions
=>
{
const
languageIndex
=
random
(
0
,
numOptions
);
cy
.
get
(
'.chosen-results > li'
)
.
eq
(
languageIndex
)
.
click
();
});
});
it
(
'should contain argument with language in url'
,
function
()
{
cy
.
location
(
'search'
)
.
should
(
'contain'
,
`language=
${
$
(
'.language-select'
).
val
()
}
`
);
});
it
(
'should highlight according to new language'
,
function
()
{
checkLanguageHighlighting
(
$
(
'.language-select'
).
val
());
});
});
it
(
'should highlight according to the language passed as argument in url'
,
function
()
{
cy
.
visit
(
`
${
contentWithLanguageInfo
}
?language=
${
languageSelect
}
`
);
checkLanguageHighlighting
(
languageSelect
);
});
});
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Sat, Jun 21, 6:13 PM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3322605
Attached To
rDWAPPS Web applications
Event Timeline
Log In to Comment