Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Platform
Development
swh-web
Commits
393deaa5
Commit
393deaa5
authored
5 years ago
by
Kalpit Kothari
Browse files
Options
Downloads
Patches
Plain Diff
cypress: Add Language Select Tests
parent
59db5cd6
No related branches found
No related tags found
1 merge request
!918
cypress: Test Language-select
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cypress/integration/language-select.spec.js
+90
-0
90 additions, 0 deletions
cypress/integration/language-select.spec.js
cypress/utils/index.js
+5
-0
5 additions, 0 deletions
cypress/utils/index.js
with
95 additions
and
0 deletions
cypress/integration/language-select.spec.js
0 → 100644
+
90
−
0
View file @
393deaa5
/**
* 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
origin
=
{
url
:
'
https://github.com/memononen/libtess2
'
,
content
:
{
path
:
'
premake4.lua
'
}
};
let
contentWithLanguageInfo
,
contentWithoutLanguageInfo
;
let
languages
=
[];
const
$
=
Cypress
.
$
;
describe
(
'
Test Content Language Select
'
,
function
()
{
before
(
function
()
{
contentWithLanguageInfo
=
this
.
Urls
.
browse_origin_content
(
origin
.
url
,
origin
.
content
.
path
);
cy
.
visit
(
contentWithLanguageInfo
);
cy
.
window
().
then
(
win
=>
{
const
metadata
=
win
.
swh
.
webapp
.
getBrowsedSwhObjectMetadata
();
origin
.
content
.
name
=
metadata
.
filename
;
origin
.
content
.
sha1git
=
metadata
.
sha1_git
;
contentWithoutLanguageInfo
=
this
.
Urls
.
browse_content
(
`sha1_git:
${
origin
.
content
.
sha1git
}
`
);
$
(
'
.language-select option
'
).
each
(
function
()
{
languages
.
push
(
this
.
value
);
});
});
});
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
);
let
languageSelect
=
languages
[
random
(
0
,
languages
.
length
)];
cy
.
get
(
'
.chosen-container
'
)
.
click
()
.
get
(
'
.chosen-results > li
'
)
.
contains
(
languageSelect
)
.
click
()
.
then
(()
=>
{
assert
.
strictEqual
(
$
(
'
.language-select
'
).
val
(),
languageSelect
);
});
});
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
()
{
const
languageSelect
=
languages
[
random
(
0
,
languages
.
length
)];
cy
.
visit
(
`
${
contentWithLanguageInfo
}
?language=
${
languageSelect
}
`
);
checkLanguageHighlighting
(
languageSelect
);
});
});
This diff is collapsed.
Click to expand it.
cypress/utils/index.js
+
5
−
0
View file @
393deaa5
...
@@ -45,3 +45,8 @@ export function checkLanguageHighlighting(language) {
...
@@ -45,3 +45,8 @@ export function checkLanguageHighlighting(language) {
.
should
(
'
be.visible
'
)
.
should
(
'
be.visible
'
)
.
and
(
'
not.be.empty
'
);
.
and
(
'
not.be.empty
'
);
}
}
export
function
random
(
start
,
end
)
{
const
range
=
end
-
start
;
return
Math
.
floor
(
Math
.
random
()
*
range
)
+
start
;
}
This diff is collapsed.
Click to expand it.
Phabricator Migration user
@phabricator-migration
mentioned in issue
#1909 (closed)
·
2 years ago
mentioned in issue
#1909 (closed)
mentioned in issue #1909
Toggle commit list
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