Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Commits on Source (2)
Added in featureflag cookie setting
· 8bb61289
Ben
authored
Sep 23, 2019
8bb61289
Updated to override feat flag by cookie
· 19ac9cb1
Ben
authored
Sep 23, 2019
19ac9cb1
Hide whitespace changes
Inline
Side-by-side
cypress/integration/comments/comment-permissions.spec.js
View file @
19ac9cb1
context
.
skip
(
'
Comment Permissions
'
,
()
=>
{
context
(
'
Comment Permissions
'
,
()
=>
{
const
postMenu
=
'
minds-activity:first > div > m-post-menu
'
;
const
deletePostOption
=
"
m-post-menu > ul > li:visible:contains('Delete')
"
;
...
...
@@ -8,6 +8,19 @@ context.skip('Comment Permissions', () => {
before
(()
=>
{
//make a post new.
cy
.
overrideFeatureFlag
({
'
blockchain_creditcard
'
:
true
,
'
suggested-users
'
:
true
,
'
helpdesk
'
:
true
,
'
top-feeds
'
:
true
,
'
es-feeds
'
:
true
,
'
allow-comments-toggle
'
:
true
,
'
permissions
'
:
true
,
'
wire-multi-currency
'
:
true
,
'
dark-mode
'
:
true
,
'
pro
'
:
true
});
cy
.
getCookie
(
'
minds_sess
'
)
.
then
((
sessionCookie
)
=>
{
if
(
sessionCookie
===
null
)
{
...
...
cypress/support/commands.js
View file @
19ac9cb1
...
...
@@ -215,6 +215,17 @@ Cypress.Commands.add('post', (message) => {
});
});
/**
* Sets the feature flag cookie.
* @param { Object } flags - JSON object containing flags to turn on
* e.g. { dark mode:false, es-feeds: true }
* @returns void
*/
Cypress
.
Commands
.
add
(
'
overrideFeatureFlag
'
,
(
flags
)
=>
{
const
base64
=
Buffer
.
from
(
JSON
.
stringify
(
flags
)).
toString
(
"
base64
"
);
cy
.
setCookie
(
'
staging-features
'
,
base64
);
});
/**
* Converts base64 to blob format
* @param { string } b64Data - The base64 data.
...
...
src/app/services/features.service.ts
View file @
19ac9cb1
import
{
Injectable
,
isDevMode
}
from
'
@angular/core
'
;
import
{
Session
}
from
'
./session
'
;
import
{
Router
}
from
'
@angular/router
'
;
import
{
Cookie
}
from
'
../services/cookie
'
;
import
{
includes
}
from
'
lodash
'
;
@
Injectable
()
export
class
FeaturesService
{
protected
_features
:
any
;
protected
_warnedCache
:
{
[
key
:
string
]:
number
}
=
{};
private
cookie
:
Cookie
=
new
Cookie
();
constructor
(
private
session
:
Session
,
private
router
:
Router
)
{
this
.
_features
=
window
.
Minds
.
features
||
{};
...
...
@@ -20,6 +23,11 @@ export class FeaturesService {
return
!
this
.
has
(
feature
.
substring
(
1
));
}
const
overrides
=
JSON
.
parse
(
atob
(
this
.
cookie
.
get
(
'
staging-features
'
)));
if
(
feature
in
overrides
)
{
return
true
;
}
if
(
typeof
this
.
_features
[
feature
]
===
'
undefined
'
)
{
if
(
isDevMode
()
&&
!
this
.
_hasWarned
(
feature
))
{
console
.
warn
(
...
...
@@ -68,7 +76,7 @@ export class FeaturesService {
return
this
.
_warnedCache
[
feature
]
+
5000
<
Date
.
now
();
}
static
_
(
session
:
Session
,
router
:
Router
)
{
static
_
(
session
:
Session
,
router
:
Router
,
cookie
:
Cookie
)
{
return
new
FeaturesService
(
session
,
router
);
}
}