...
 
Commits (2)
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) {
......
......@@ -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.
......
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);
}
}