Skip to content

Commit

Permalink
Merge branch 'master' into chore(uve)-fix-shouldShowUnlock-check-#28947
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinogiardino authored Jul 30, 2024
2 parents 2f5e7ab + 6343d2b commit 33162f8
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Component, DebugElement, Injectable, Input } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { ActivatedRoute } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';

Expand All @@ -19,6 +20,7 @@ import { TooltipModule } from 'primeng/tooltip';

import { DotWizardModule } from '@components/_common/dot-wizard/dot-wizard.module';
import { DotContentletEditorService } from '@components/dot-contentlet-editor/services/dot-contentlet-editor.service';
import { DotLanguageSelectorComponent } from '@components/dot-language-selector/dot-language-selector.component';
import { DotSecondaryToolbarModule } from '@components/dot-secondary-toolbar';
import { dotEventSocketURLFactory } from '@dotcms/app/test/dot-test-bed';
import {
Expand Down Expand Up @@ -64,11 +66,16 @@ import {
dotcmsContentletMock,
DotFormatDateServiceMock,
LoginServiceMock,
mockDotContainers,
mockDotLanguage,
mockDotLayout,
MockDotMessageService,
mockDotPage,
mockDotPersona,
mockDotRenderedPage,
mockDotRenderedPageState,
MockDotRouterService,
mockDotTemplate,
mockUser,
SiteServiceMock
} from '@dotcms/utils-testing';
Expand Down Expand Up @@ -164,12 +171,14 @@ describe('DotEditPageToolbarSeoComponent', () => {
TooltipModule,
TagModule,
DotExperimentClassDirective,
DotLanguageSelectorComponent,
RouterTestingModule.withRoutes([
{
path: 'edit-page/experiments/pageId/id/reports',
component: TestHostComponent
}
])
]),
NoopAnimationsModule
],
providers: [
DotSessionStorageService,
Expand Down Expand Up @@ -481,4 +490,38 @@ describe('DotEditPageToolbarSeoComponent', () => {
});
});
});

it('should have a new api link', async () => {
const initialLink = component.apiLink;

const host = `api/v1/page/render${componentHost.pageState.page.pageURI}`;
const newLanguageId = 2;
const expectedLink = `${host}?language_id=${newLanguageId}`;

fixtureHost.componentRef.setInput(
'pageState',
new DotPageRenderState(
mockUser(),
new DotPageRender({
containers: mockDotContainers(),
layout: mockDotLayout(),
page: { ...mockDotPage(), languageId: 2 },
template: mockDotTemplate(),
canCreateTemplate: true,
numberContents: 1,
viewAs: {
language: mockDotLanguage,
mode: DotPageMode.PREVIEW
}
}),
dotcmsContentletMock
)
);

fixtureHost.detectChanges();
await fixtureHost.whenStable();

expect(component.apiLink).toBe(expectedLink);
expect(component.apiLink).not.toBe(initialLink);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ export class DotEditPageToolbarSeoComponent implements OnInit, OnChanges, OnDest
});

this.isEnterpriseLicense$ = this.dotLicenseService.isEnterprise();
this.apiLink = `api/v1/page/render${this.pageState.page.pageURI}?language_id=${this.pageState.page.languageId}`;
this.apiLink = this.getApiLink();
}

ngOnChanges(): void {
this.pageRenderedHtml = this.updateRenderedHtml();

this.apiLink = this.getApiLink();
this.showWhatsChanged =
this.pageState.state.mode === DotPageMode.PREVIEW &&
!('persona' in this.pageState.viewAs) &&
Expand Down Expand Up @@ -140,4 +140,8 @@ export class DotEditPageToolbarSeoComponent implements OnInit, OnChanges, OnDest
? this.pageState.params.page.rendered
: this.pageRenderedHtml;
}

private getApiLink(): string {
return `api/v1/page/render${this.pageState.page.pageURI}?language_id=${this.pageState.page.languageId}`;
}
}

0 comments on commit 33162f8

Please sign in to comment.