Skip to content

Commit

Permalink
Merge pull request #6374 from NMDSdevopsServiceAdm/fix/1523-load-pare…
Browse files Browse the repository at this point in the history
…nt-home-page-when-cms-fails

Add check for article before rendering ASC-WDS news card on parent home page
  • Loading branch information
duncanc19 authored Oct 3, 2024
2 parents f4732ca + 0b0f651 commit b89255c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
</p></app-card
>
</div>
<div class="govuk-grid-column-one-third asc-card-padding">
<div *ngIf="article" class="govuk-grid-column-one-third asc-card-padding">
<app-card [image]="'/assets/images/news.svg'">
<a
class="govuk-link--no-visited-state govuk-!-font-size-19 govuk-!-font-weight-bold"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('ParentHomeTabComponent', () => {
comparisonDataAvailable = true,
noOfWorkplaces = 9,
permissions = [],
canAccessCms = true,
) => {
const { fixture, queryAllByText, getByText, queryByText, getByTestId, queryByTestId } = await render(
ParentHomeTabComponent,
Expand All @@ -76,8 +77,8 @@ describe('ParentHomeTabComponent', () => {
useValue: {
snapshot: {
data: {
articleList,
articles,
articleList: canAccessCms ? articleList : null,
articles: canAccessCms ? articles : null,
workers: {
workersCreatedDate: [],
workerCount: 0,
Expand Down Expand Up @@ -304,6 +305,14 @@ describe('ParentHomeTabComponent', () => {
expect(ascWdsNewsLink).toBeTruthy();
expect(ascWdsNewsLink.getAttribute('href')).toContain(articleList.data[0].slug);
});

it('should not show an ASC-WDS news card when user cannot access CMS', async () => {
const { queryByText } = await setup(false, Establishment, true, 9, [], false);

const ascWdsNewsLink = queryByText('ASC-WDS news');

expect(ascWdsNewsLink).toBeFalsy();
});
});

describe('summary', () => {
Expand Down

0 comments on commit b89255c

Please sign in to comment.