Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #26163: Edit Contentlet implement Feature Flag #26242

Merged
merged 62 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
411dc85
dev (general): add new library and route
zJaaal Sep 22, 2023
51b3780
dev (configuration resource Java): Add Feature Flags to WhiteList
zJaaal Sep 22, 2023
c65112c
copywritting (edit-content routing): change name to match standard
zJaaal Sep 22, 2023
a2ccaa9
dev (edit content guard): add guard to prevent navigation without fea…
zJaaal Sep 22, 2023
caa5ca1
dev (app routing): add guard to edit content and move pages route to …
zJaaal Sep 22, 2023
04b3347
fix (general): add guard to providers and fix bad use of inject
zJaaal Sep 22, 2023
4c61008
dev (custom event handler): add feature flag to redirect to new form …
zJaaal Sep 22, 2023
346d367
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 22, 2023
326776e
fix (general test): test were broken by bad import in providers
zJaaal Sep 22, 2023
d0a956e
fix (form component test): missing import
zJaaal Sep 22, 2023
f4eaab9
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 25, 2023
6709147
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 25, 2023
347a0a7
dev (general): add routing for creating contentlet
zJaaal Sep 25, 2023
ac864dd
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 25, 2023
cdc7e35
dev (dot custom event handler): add re routing for edit task
zJaaal Sep 25, 2023
3d272cd
Merge branch '26163-edit-contentlet-implement-feature-flag' of https:…
zJaaal Sep 25, 2023
15bb437
dev (dot pages store): add redirect to new portlet when feature flag …
zJaaal Sep 25, 2023
13ea07f
fix (pages portlet): some tests were broken
zJaaal Sep 25, 2023
380f1b9
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 25, 2023
fa10913
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 25, 2023
407b1e9
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 25, 2023
2e3566a
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 26, 2023
d9a3f9f
dev (dot edit page nav): Add redirect to new edit contentlet
zJaaal Sep 26, 2023
7c55257
fix (pages create dialog): route were wrong
zJaaal Sep 26, 2023
46d04d6
Revert "dev (dot edit page nav): Add redirect to new edit contentlet"
zJaaal Sep 26, 2023
6eb68ce
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 26, 2023
7f36595
dev (jsp): add contentType to event
zJaaal Sep 26, 2023
114c0d5
dev (dot custom event handler service): add event for create contentl…
zJaaal Sep 26, 2023
a85ba15
dev (general): final replace of the route to content
zJaaal Sep 26, 2023
2208999
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 27, 2023
f913f4b
dev (general): solve feedback
zJaaal Sep 27, 2023
bdfb404
Merge branch '26163-edit-contentlet-implement-feature-flag' of https:…
zJaaal Sep 27, 2023
dd293a8
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 27, 2023
714dd66
feedback (edit content guard): change the approach to be functional g…
zJaaal Sep 27, 2023
05fb545
feedback (general): add tests and small refactor
zJaaal Sep 27, 2023
837d620
feedback (general): small refactor
zJaaal Sep 27, 2023
a2b19d3
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 27, 2023
40e8008
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 28, 2023
02c532e
feedback (feature flags): fix content editor 2 value
zJaaal Sep 28, 2023
38563e1
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 28, 2023
672f949
dev (dot properties service): add methods to get feature flags values…
zJaaal Sep 28, 2023
9ae9832
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 28, 2023
b3b6e90
dev (jsp): edit redirects now sends the content type in the event
zJaaal Sep 28, 2023
810ce09
dev (host jsp): now host emits a different event to go to legacy portlet
zJaaal Sep 28, 2023
2aed8c0
dev (custom event handler): refactor to handle new feature flag metho…
zJaaal Sep 28, 2023
4e7f7c2
fix (custom event handler): tests were broken
zJaaal Sep 28, 2023
49b3d8d
fix (dot properties service): Add missing done callback
zJaaal Sep 29, 2023
2684893
dev (general): apply refactor for new feature flag method
zJaaal Sep 29, 2023
8475381
fix (dot feature flag resolver): test were broken
zJaaal Sep 29, 2023
ea892d4
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 29, 2023
8d47a22
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 29, 2023
9b11af9
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 29, 2023
67533e2
dev (dot pages): add redirect to new edit contentlet checking the con…
zJaaal Sep 29, 2023
c6d7a78
fix (pages store): fix tests
zJaaal Sep 29, 2023
48466a1
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 29, 2023
dae4107
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 29, 2023
e16492a
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 29, 2023
c1f8e27
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 29, 2023
bcec178
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Sep 29, 2023
13175a7
feedback (general): change name of methods
zJaaal Oct 2, 2023
f66aaab
Merge branch 'master' into 26163-edit-contentlet-implement-feature-flag
zJaaal Oct 2, 2023
bb7c22a
feedback (general): fix feature flag name
zJaaal Oct 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import { of } from 'rxjs';

import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';

import { ConfirmationService } from 'primeng/api';
Expand All @@ -18,6 +21,7 @@ import {
DotEventsService,
DotGenerateSecurePasswordService,
DotLicenseService,
DotPropertiesService,
DotWorkflowActionsFireService
} from '@dotcms/data-access';
import {
Expand All @@ -33,6 +37,7 @@ import {
StringUtils,
UserModel
} from '@dotcms/dotcms-js';
import { FeaturedFlags } from '@dotcms/dotcms-models';
import { DotLoadingIndicatorService } from '@dotcms/utils';
import {
CoreWebServiceMock,
Expand Down Expand Up @@ -62,9 +67,18 @@ describe('DotCustomEventHandlerService', () => {
let dotWorkflowEventHandlerService: DotWorkflowEventHandlerService;
let dotEventsService: DotEventsService;
let dotLicenseService: DotLicenseService;
let router: Router;

beforeEach(() => {
TestBed.configureTestingModule({
const createFeatureFlagResponse = (
enabled: string = 'NOT_FOUND',
contentType: string = '*'
) => ({
[FeaturedFlags.FEATURE_FLAG_CONTENT_EDITOR2_ENABLED]: enabled,
[FeaturedFlags.FEATURE_FLAG_CONTENT_EDITOR2_CONTENT_TYPE]: contentType
});

const setup = (dotPropertiesMock: unknown) => {
TestBed.resetTestingModule().configureTestingModule({
providers: [
DotCustomEventHandlerService,
DotLoadingIndicatorService,
Expand Down Expand Up @@ -100,7 +114,9 @@ describe('DotCustomEventHandlerService', () => {
DotDownloadBundleDialogService,
DotGenerateSecurePasswordService,
LoginService,
DotLicenseService
DotLicenseService,
{ provide: DotPropertiesService, useValue: dotPropertiesMock },
Router
],
imports: [RouterTestingModule, HttpClientTestingModule]
});
Expand All @@ -116,6 +132,13 @@ describe('DotCustomEventHandlerService', () => {
dotWorkflowEventHandlerService = TestBed.inject(DotWorkflowEventHandlerService);
dotEventsService = TestBed.inject(DotEventsService);
dotLicenseService = TestBed.inject(DotLicenseService);
router = TestBed.inject(Router);
};

beforeEach(() => {
setup({
getKeys: () => of(createFeatureFlagResponse())
});
});

it('should show loading indicator and go to edit page when event is emited by iframe', () => {
Expand Down Expand Up @@ -144,6 +167,7 @@ describe('DotCustomEventHandlerService', () => {

it('should create a contentlet', () => {
spyOn(dotContentletEditorService, 'create');

service.handle(
new CustomEvent('ng-event', {
detail: {
Expand All @@ -160,6 +184,43 @@ describe('DotCustomEventHandlerService', () => {
});
});

it('should create a host', () => {
spyOn(dotContentletEditorService, 'create');

service.handle(
new CustomEvent('ng-event', {
detail: {
name: 'create-host',
data: { url: 'hello.world.com' }
}
})
);

expect(dotContentletEditorService.create).toHaveBeenCalledWith({
data: {
url: 'hello.world.com'
}
});
});

it('should create a contentlet from edit page', () => {
zJaaal marked this conversation as resolved.
Show resolved Hide resolved
spyOn(dotContentletEditorService, 'create');
service.handle(
new CustomEvent('ng-event', {
detail: {
name: 'create-contentlet-from-edit-page',
data: { url: 'hello.world.com' }
}
})
);

expect(dotContentletEditorService.create).toHaveBeenCalledWith({
data: {
url: 'hello.world.com'
}
});
});

it('should edit a contentlet', () => {
service.handle(
new CustomEvent('ng-event', {
Expand All @@ -174,6 +235,20 @@ describe('DotCustomEventHandlerService', () => {
expect(dotRouterService.goToEditContentlet).toHaveBeenCalledWith('123');
});

it('should edit a host', () => {
service.handle(
new CustomEvent('ng-event', {
detail: {
name: 'edit-host',
data: {
inode: '123'
}
}
})
);
expect(dotRouterService.goToEditContentlet).toHaveBeenCalledWith('123');
});

it('should edit a a workflow task', () => {
service.handle(
new CustomEvent('ng-event', {
Expand Down Expand Up @@ -304,4 +379,162 @@ describe('DotCustomEventHandlerService', () => {
);
expect(dotLicenseService.updateLicense).toHaveBeenCalled();
});

describe('edit content 2 is enabled and contentTypes are catchall', () => {
beforeEach(() => {
setup({
getKeys: () => of(createFeatureFlagResponse('true'))
});

spyOn(router, 'navigate');
});

it('should create a contentlet', () => {
spyOn(dotContentletEditorService, 'create');

service.handle(
new CustomEvent('ng-event', {
detail: {
name: 'create-contentlet',
data: { contentType: 'test' }
}
})
);

expect(router.navigate).toHaveBeenCalledWith(['content/new/test']);
});

it('should edit a a workflow task', () => {
service.handle(
new CustomEvent('ng-event', {
detail: {
name: 'edit-task',
data: {
inode: '123',
contentType: 'test'
}
}
})
);

expect(router.navigate).toHaveBeenCalledWith(['content/123']);
});

it('should edit a contentlet', () => {
service.handle(
new CustomEvent('ng-event', {
detail: {
name: 'edit-contentlet',
data: {
inode: '123',
contentType: 'test'
}
}
})
);
expect(router.navigate).toHaveBeenCalledWith(['content/123']);
});
});

describe('edit content 2 is enabled and contentTypes are limited', () => {
beforeEach(() => {
setup({
getKeys: () => of(createFeatureFlagResponse('true', 'test,test2'))
});

spyOn(router, 'navigate');
});

it('should create a contentlet', () => {
spyOn(dotContentletEditorService, 'create');

service.handle(
new CustomEvent('ng-event', {
detail: {
name: 'create-contentlet',
data: { contentType: 'test' }
}
})
);

expect(router.navigate).toHaveBeenCalledWith(['content/new/test']);
});

it('should edit a a workflow task', () => {
service.handle(
new CustomEvent('ng-event', {
detail: {
name: 'edit-task',
data: {
inode: '123',
contentType: 'test2'
}
}
})
);

expect(router.navigate).toHaveBeenCalledWith(['content/123']);
});

it('should edit a contentlet', () => {
service.handle(
new CustomEvent('ng-event', {
detail: {
name: 'edit-contentlet',
data: {
inode: '123',
contentType: 'test2'
}
}
})
);
expect(router.navigate).toHaveBeenCalledWith(['content/123']);
});

it('should not create a contentlet', () => {
spyOn(dotContentletEditorService, 'create');

service.handle(
new CustomEvent('ng-event', {
detail: {
name: 'create-contentlet',
data: { contentType: 'not in the list' }
}
})
);

expect(router.navigate).not.toHaveBeenCalledWith(['content/new/test']);
});

it('should not edit a a workflow task', () => {
service.handle(
new CustomEvent('ng-event', {
detail: {
name: 'edit-task',
data: {
inode: '123',
contentType: 'not in the list'
}
}
})
);

expect(router.navigate).not.toHaveBeenCalledWith(['content/123']);
});

it('should not edit a contentlet', () => {
service.handle(
new CustomEvent('ng-event', {
detail: {
name: 'edit-contentlet',
data: {
inode: '123',
contentType: 'not in the list'
}
}
})
);
expect(router.navigate).not.toHaveBeenCalledWith(['content/123']);
});
});
});
Loading