Skip to content

Commit

Permalink
Merge branch 'main' into staff-restricted
Browse files Browse the repository at this point in the history
  • Loading branch information
rcantin-w authored Nov 11, 2024
2 parents b47eaa6 + 146af4b commit 13e908b
Show file tree
Hide file tree
Showing 21 changed files with 2,575 additions and 3,872 deletions.
2 changes: 1 addition & 1 deletion .buildkite/urls/expected_200_urls.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/search/stories?query=human
/search/images?query=human
/search/works?query=human
/concepts/n4fvtc49
/concepts/cza334ke
# A works search page where some results contain thumbnails
# https://wellcome.slack.com/archives/C8X9YKM5X/p1657191146272169
/search/works?subjects.label=Liliaceae
Expand Down
6 changes: 0 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ updates:
update-types: ['version-update:semver-patch'] # Ignore all patch updates for version updates only
# We are looking at updating Chromatic, so don't tell us about it. Remove this once we've upgraded.
- dependency-name: 'chromatic*'
# Bigger piece, has a ticket to upgrade. Remove this once it's done.
- dependency-name: 'next'
- dependency-name: '@next*'
# Needs to be done carefully, has its own ticket. Remove this once it's done.
- dependency-name: 'slice-machine-ui'
- dependency-name: '@slicemachine'
# Needs more work, has its own ticket. Remove this once it's done.
- dependency-name: 'eslint*'
# Needs untangling, has its own ticket. Remove this once it's done.
Expand Down
2 changes: 1 addition & 1 deletion cardigan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@storybook/theming": "^8.3.5",
"chromatic": "^6.21.1",
"husky": "^4.3.0",
"next": "13.5.7",
"next": "14.2.10",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"typescript": "^5.6.2",
Expand Down
4 changes: 2 additions & 2 deletions common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"jest-environment-jsdom": "^29.5.0",
"koa-compose": "^4.1.0",
"lodash.debounce": "^4.0.8",
"next": "13.2.3",
"next": "14.2.10",
"nprogress": "^0.2.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand All @@ -44,6 +44,6 @@
},
"devDependencies": {
"@slicemachine/adapter-next": "^0.3.36",
"slice-machine-ui": "^1.25.0"
"slice-machine-ui": "^2.10.0"
}
}
25 changes: 15 additions & 10 deletions common/services/prismic/link-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ type Props = {
type: string;
siteSection?: SiteSection;
};

// Untransformed data
type DataProps = {
uid?: string;
type: string;
Expand All @@ -20,7 +22,8 @@ type DataProps = {
};

function linkResolver(doc: Props | DataProps): string {
// this is mostly useful for scenarios like rendering in Page Builder
// This is mostly useful for scenarios like rendering in Page Builder
// which doesn't necessarily have access to all data
if (!doc) return '/';

const { uid, type } = doc;
Expand Down Expand Up @@ -52,18 +55,20 @@ function linkResolver(doc: Props | DataProps): string {
}

if (type === 'pages') {
if ('siteSection' in doc) {
return `${doc.siteSection}/${uid}`;
} else if ('tags' in doc) {
// Needed for Prismic previews
const docSiteSection = doc.tags.find(t => isSiteSection(t));
let siteSection: SiteSection | undefined;

const isLandingPage = docSiteSection === uid;
if (isLandingPage) return `/${uid}`;
if ('siteSection' in doc) {
siteSection = doc.siteSection;
}

return `${docSiteSection ? '/' + docSiteSection : ''}/${uid}`;
// Prismic previews come through here.
if ('tags' in doc) {
siteSection = doc.tags.find(t => isSiteSection(t));
}
return `/${uid}`;

const isLandingPage = siteSection === uid;

return isLandingPage || !siteSection ? `/${uid}` : `/${siteSection}/${uid}`;
}

if (isContentType(type)) {
Expand Down
2 changes: 1 addition & 1 deletion content/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"koa-router": "^7.4.0",
"lodash.flattendeep": "^4.4.0",
"lodash.throttle": "^4.1.1",
"next": "13.2.3",
"next": "14.2.10",
"next-router-mock": "^0.9.3",
"openseadragon": "^4.0.0",
"react": "^18.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ import Space from '@weco/common/views/components/styled/Space';
import SpacingComponent from '@weco/common/views/components/styled/SpacingComponent';
import { components } from '@weco/common/views/slices';
import Table from '@weco/content/components/Table';
import * as page from '@weco/content/pages/pages/[pageId]';
import { setCacheControl } from '@weco/content/utils/setCacheControl';

import * as page from './pages/[pageId]';

const CookieTable = ({ rows }: { rows: string[][] }) => {
return (
<SpacingComponent>
Expand Down Expand Up @@ -54,7 +53,7 @@ const CookiePolicy: FunctionComponent<page.Props> = (props: page.Props) => {
title={props.page.title}
description={props.page.metadataDescription || ''}
hideNewsletterPromo={true}
url={{ pathname: '/cookie-policy' }}
url={{ pathname: '/about-us/cookie-policy' }}
jsonLd={{ '@type': 'WebPage' }}
openGraphType="website"
siteSection={props.page.siteSection}
Expand Down Expand Up @@ -101,6 +100,7 @@ export const getServerSideProps: GetServerSideProps<
return page.getServerSideProps({
...context,
query: { pageId: prismicPageIds.cookiePolicy },
params: { siteSection: 'about-us' },
});
};

Expand Down
13 changes: 5 additions & 8 deletions content/webapp/pages/events/[eventId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,11 @@ const EventPage: NextPage<EventProps> = ({
url: '/events',
text: 'Events',
},
...event.series.map(series => {
console.log(series);
return {
url: linkResolver(series),
text: series.title || '',
prefix: 'Part of',
};
}),
...event.series.map(series => ({
url: linkResolver(series),
text: series.title || '',
prefix: 'Part of',
})),
scheduledIn
? {
url: linkResolver(scheduledIn),
Expand Down
16 changes: 14 additions & 2 deletions content/webapp/pages/pages/[pageId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,13 @@ export const getServerSideProps: GetServerSideProps<
const { pageId } = context.query;
const siteSection = toMaybeString(context.params?.siteSection);

if (!looksLikePrismicId(pageId)) {
// We don't allow e.g. /visit-us/visit-us as it's a landing page
// Should only display on /visit-us
const isLandingPageRenderingAsSubPage =
pageId === siteSection &&
context.resolvedUrl.indexOf(`/${siteSection}/${pageId}`) === 0;

if (!looksLikePrismicId(pageId) || isLandingPageRenderingAsSubPage) {
return { notFound: true };
}

Expand All @@ -123,10 +129,16 @@ export const getServerSideProps: GetServerSideProps<
const basicDocSiteSection = basicDocument.tags.find(t =>
isSiteSection(t)
);
const isLandingPage = basicDocSiteSection === pageId;

const redirectUrl =
isLandingPage || !basicDocSiteSection
? `/${pageId}`
: `/${basicDocSiteSection}/${pageId}`;

return {
redirect: {
destination: `${basicDocSiteSection ? '/' + basicDocSiteSection : ''}/${basicDocument.uid}`,
destination: redirectUrl,
permanent: false,
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ describe('transformExhibitionGuide', () => {
it('returns a set of components', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const exhibition = transformExhibitionGuide(exhibitionGuidesDoc as any);
console.log(exhibition.components.length, 'the exhibition');
expect(exhibition.components.length).toBe(2);
});
});
Expand Down
2 changes: 1 addition & 1 deletion dash/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@babel/runtime": "^7.24.7",
"@types/react": "^18.3.3",
"cookies-next": "^4.2.1",
"next": "^14.2.10",
"next": "14.2.10",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"styled-components": "^6.1.11",
Expand Down
2 changes: 1 addition & 1 deletion identity/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"koa": "^2.13.0",
"koa-json": "^2.0.2",
"koa-logger": "^3.2.1",
"next": "13.2.3",
"next": "14.2.10",
"next-router-mock": "^0.9.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
8 changes: 8 additions & 0 deletions identity/webapp/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ export async function createApp(): Promise<Koa> {
ctx.respond = false;
});

// Upgrading next passed 13.5.1 led to an issue with the incorrect status code being returned
// So we do it explicitly here
// See https://github.com/vercel/next.js/issues/65691 for similar
app.use(async (ctx, next) => {
ctx.res.statusCode = 200;
await next();
});

app.use(router.routes()).use(router.allowedMethods());

process.on('SIGINT', async () => {
Expand Down
4 changes: 2 additions & 2 deletions identity/webapp/src/frontend/components/PageWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ export const PageWrapper: FunctionComponent<PropsWithChildren<Props>> = ({
const { isEnhanced } = useContext(AppContext);
const { collectionVenues } = usePrismicData();
const venues = transformCollectionVenues(collectionVenues);

const fullTitle = `${title} | Wellcome Collection`;
return (
<>
<Head>
<title>{title} | Wellcome Collection</title>
<title>{fullTitle}</title>
<Favicons />
</Head>
<GlobalStyle isFontsLoaded={useIsFontsLoaded()} />
Expand Down
26 changes: 11 additions & 15 deletions playwright/test/article.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,16 @@ test('(4) | No related story is shown for an article in a serial with only one s
).toHaveCount(0);
});

// 2024-08-02 - commenting out this test until Prismic permanently fixes the issue
// See https://github.com/wellcomecollection/wellcomecollection.org/issues/7641
// test('(5) | Articles use the 32:15 crop for their social media preview', async ({
// page,
// context,
// }) => {
// await article('Yd8L-hAAAIAWFxqa', context, page);
test('(5) | Articles use the 32:15 crop for their social media preview', async ({
page,
context,
}) => {
await article('Yd8L-hAAAIAWFxqa', context, page);

// const metaTag = await page.locator('meta[name="twitter:image"]');
const metaTag = await page.locator('meta[name="twitter:image"]');

// await expect(metaTag).toHaveAttribute(
// 'content',
// TODO amend expected result once image issue is fixed
// https://github.com/wellcomecollection/wellcomecollection.org/issues/10853
// 'https://images.prismic.io/wellcomecollection/2a42de1c-7954-4ece-be5f-775079c4bc54_Lauren+seated+outside.jpg?auto=format%2Ccompress&rect=&w=800&h='
// );
// });
await expect(metaTag).toHaveAttribute(
'content',
'https://images.prismic.io/wellcomecollection/2a42de1c-7954-4ece-be5f-775079c4bc54_Lauren+seated+outside.jpg?auto=compress%2Cformat&rect=0%2C275%2C4000%2C1875&w=800&h=375'
);
});
2 changes: 1 addition & 1 deletion playwright/test/concept.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const test = base.extend<{
// Chosen because there are works both about and by this person,
// and his label is punctuated in such a way that would break the page if
// it is not escaped properly in the API calls.
await concept('d46ea7yk', context, page);
await concept('qe5c6x6f', context, page);
const thackrahPage = new ConceptPage(page, 'person');
await use(thackrahPage);
},
Expand Down
4 changes: 1 addition & 3 deletions playwright/test/helpers/contexts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ const stageApiToggleCookie = createCookie({
value: 'true',
});

// TODO: context.addCookies should run for the first test of a suite (even on beforeAll/beforeEach)

const requiredCookies = useStageApis
export const requiredCookies = useStageApis
? [acceptCookieCookie, stageApiToggleCookie]
: [acceptCookieCookie];

Expand Down
41 changes: 41 additions & 0 deletions playwright/test/pages.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { expect, test } from '@playwright/test';

import { gotoWithoutCache, requiredCookies } from './helpers/contexts';
import { baseUrl } from './helpers/utils';

test.describe('Server-side redirection logic works as expected', () => {
test('/pages/ route redirects to relevant URL', async ({ context, page }) => {
await context.addCookies(requiredCookies);

// Visit Us site section
await gotoWithoutCache(`${baseUrl}/pages/accessibility`, page);
await expect(page.url()).toEqual(`${baseUrl}/visit-us/accessibility`);

// Orphan page
await gotoWithoutCache(`${baseUrl}/pages/contact-us`, page);
await expect(page.url()).toEqual(`${baseUrl}/contact-us`);
});

test("Landing pages don't have a parent route", async ({ context, page }) => {
await context.addCookies(requiredCookies);

await gotoWithoutCache(`${baseUrl}/visit-us/visit-us`, page);
await expect(
page
.getByRole('heading')
.getByText('Not the Wellcome you were expecting?')
).toBeVisible();

await gotoWithoutCache(`${baseUrl}/pages/visit-us`, page);
await expect(page.url()).toEqual(`${baseUrl}/visit-us`);
});
});

// As they are displayed through a hack, we want to make sure they're working
// https://github.com/wellcomecollection/wellcomecollection.org/pull/10890
test('Cookie policy tables are showing', async ({ context, page }) => {
await context.addCookies(requiredCookies);
await gotoWithoutCache(`${baseUrl}/about-us/cookie-policy`, page);

await expect(page.getByRole('table')).toHaveCount(3);
});
4 changes: 2 additions & 2 deletions prismic-model/lintPrismicData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function detectIncorrectAudioVideoDuration(doc: any): string[] {
)
.map(
e =>
`The audio_duration for should be in the format xx:xx but it is ${e.primary.audio_duration}`
`The audio_duration for "${e.primary.title[0].text}" should be in the format xx:xx but it is ${e.primary.audio_duration}`
);
const videoErrors = guideStopSlices
.filter(
Expand All @@ -180,7 +180,7 @@ function detectIncorrectAudioVideoDuration(doc: any): string[] {
)
.map(
e =>
`The video_duration for should be in the format xx:xx but it is ${e.primary.video_duration}`
`The video_duration for "${e.primary.title[0].text}" should be in the format xx:xx but it is ${e.primary.video_duration}`
);

return [...audioErrors, ...videoErrors];
Expand Down
2 changes: 1 addition & 1 deletion updown/updown-checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default [
slackAlerts: ['alerts-channel'],
},
{
url: 'https://content.wellcomecollection.org/concepts/v3m7uhy9',
url: 'https://content.wellcomecollection.org/concepts/fppbxh8b',
name: 'Concept',
slackAlerts: ['alerts-channel'],
apdexThreshold: 1.0, // We expect this to be a slower page
Expand Down
Loading

0 comments on commit 13e908b

Please sign in to comment.