Skip to content

Commit

Permalink
Merge branch 'main' into front-code-stack
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgorrie authored Oct 11, 2023
2 parents 0751562 + 1cc416e commit d9490ef
Show file tree
Hide file tree
Showing 53 changed files with 1,392 additions and 694 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ describe('Why do wombats do square poos?', function () {
// Wait for hydration
cy.get('gu-island[name=KnowledgeQuizAtomWrapper]')
.first()
.scrollIntoView()
.should('have.attr', 'data-island-status', 'hydrated');
// Establish that the elements showing the results are not present
cy.get('[data-atom-type=knowledgequiz] fieldset')
Expand Down Expand Up @@ -132,6 +133,7 @@ describe('Why do wombats do square poos?', function () {
// Wait for hydration
cy.get('gu-island[name=KnowledgeQuizAtomWrapper]')
.first()
.scrollIntoView()
.should('have.attr', 'data-island-status', 'hydrated');
// Establish that the elements showing the results are not present
cy.get('[data-atom-type=knowledgequiz] fieldset')
Expand Down
4 changes: 4 additions & 0 deletions dotcom-rendering/cypress/e2e/parallel-5/atom.video.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ describe('YouTube Atom', function () {
// Wait for hydration
cy.get('[data-component=youtube-atom]')
.parent()
.scrollIntoView()
.should('have.attr', 'data-island-status', 'hydrated');

// Make sure overlay is displayed
Expand Down Expand Up @@ -228,6 +229,7 @@ describe('YouTube Atom', function () {
.each((item) => {
cy.wrap(item)
.parent()
.scrollIntoView()
.should('have.attr', 'data-island-status', 'hydrated');
});

Expand Down Expand Up @@ -344,6 +346,7 @@ describe('YouTube Atom', function () {
// Wait for hydration
cy.get('[data-component=youtube-atom]')
.parent()
.scrollIntoView()
.should('have.attr', 'data-island-status', 'hydrated');

// Make sure overlay is displayed
Expand Down Expand Up @@ -394,6 +397,7 @@ describe('YouTube Atom', function () {
.each((item) => {
cy.wrap(item)
.parent()
.scrollIntoView()
.should('have.attr', 'data-island-status', 'hydrated');
});

Expand Down
2 changes: 2 additions & 0 deletions dotcom-rendering/fixtures/manual/chartAtoms.tsx

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions dotcom-rendering/fixtures/manual/trails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},
{
url: 'https://www.theguardian.com/environment/2019/dec/02/migration-v-climate-europes-new-political-divide',
Expand Down Expand Up @@ -111,6 +112,7 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},
{
url: 'https://www.theguardian.com/world/2019/nov/28/eu-parliament-declares-climate-emergency',
Expand All @@ -131,6 +133,7 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},
{
url: 'https://www.theguardian.com/environment/2019/nov/27/climate-emergency-world-may-have-crossed-tipping-points',
Expand All @@ -150,6 +153,7 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},
{
url: 'https://www.theguardian.com/world/2019/nov/26/european-parliament-split-on-declaring-climate-emergency',
Expand All @@ -169,6 +173,7 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},
{
url: 'https://www.theguardian.com/world/2019/nov/23/north-pole-explorers-on-thin-ice-as-climate-change-hits-expedition',
Expand All @@ -189,6 +194,7 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},
{
url: 'https://www.theguardian.com/environment/2019/oct/25/scientists-glacial-rivers-absorb-carbon-faster-rainforests',
Expand All @@ -210,6 +216,7 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},
{
url: 'https://www.theguardian.com/business/2019/oct/20/uk-urges-world-bank-to-channel-more-money-into-tackling-climate-crisis',
Expand All @@ -230,6 +237,7 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},

{
Expand All @@ -252,6 +260,7 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},
{
url: 'https://www.theguardian.com/world/2021/feb/17/uk-to-begin-worlds-first-covid-human-challenge-study-within-weeks',
Expand All @@ -273,6 +282,7 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},
{
url: 'https://www.theguardian.com/world/2021/feb/17/scottish-government-inadequately-prepared-for-covid-audit-scotland-report',
Expand All @@ -294,6 +304,7 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},
{
url: 'https://www.theguardian.com/society/2021/feb/16/encouraging-signs-covid-vaccine-over-80s-deaths-fall-england',
Expand All @@ -315,6 +326,7 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},
{
url: 'https://www.theguardian.com/world/2021/feb/16/contact-tracing-alone-has-little-impact-on-curbing-covid-spread-report-finds',
Expand All @@ -336,6 +348,7 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},
{
url: 'https://www.theguardian.com/world/2021/feb/16/covid-almost-2m-more-people-asked-shield-england',
Expand All @@ -357,6 +370,7 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},
{
url: 'https://www.theguardian.com/politics/live/2021/feb/16/uk-covid-live-coronavirus-sturgeon-return-scottish-schools-latest-updates',
Expand All @@ -378,6 +392,7 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},
{
url: 'https://www.theguardian.com/uk-news/2021/feb/16/qcovid-how-improved-algorithm-can-identify-more-higher-risk-adults',
Expand All @@ -399,6 +414,7 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},
{
url: 'https://www.theguardian.com/world/2019/nov/28/eu-parliament-declares-climate-emergency',
Expand All @@ -418,6 +434,7 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},
{
url: 'https://www.theguardian.com/society/2023/may/30/trans-activists-disrupt-kathleen-stock-speech-at-oxford-union',
Expand All @@ -438,6 +455,7 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},
{
url: 'https://www.theguardian.com/commentisfree/2023/may/31/price-controls-rishi-sunak-thatcher-prime-minister',
Expand All @@ -458,6 +476,7 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},
{
url: 'https://www.theguardian.com/tv-and-radio/2023/may/30/a-revelation-succession-matthew-macfadyen-has-been-a-consummate-shapeshifter',
Expand Down Expand Up @@ -526,5 +545,6 @@ export const trails: [
isExternalLink: false,
showLivePlayable: false,
discussionApiUrl,
showMainVideo: true,
},
];
12 changes: 12 additions & 0 deletions dotcom-rendering/scripts/gen-stories/get-stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@ const testLayoutFormats = [
theme: 'OpinionPillar',
renderingTarget: 'Web',
},
{
display: 'Standard',
design: 'Comment',
theme: 'NewsPillar',
renderingTarget: 'Apps',
},
{
display: 'Standard',
design: 'Interactive',
theme: 'NewsPillar',
renderingTarget: 'Apps',
},
];

const generateLayoutStories = () => {
Expand Down
2 changes: 1 addition & 1 deletion dotcom-rendering/scripts/webpack/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* @type {boolean} prevent TS from narrowing this to its current value
*/
const BUILD_VARIANT = true;
const BUILD_VARIANT = false;

/**
* Server-side test names for running variant test.
Expand Down
38 changes: 30 additions & 8 deletions dotcom-rendering/src/client/adaptiveSite.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
import { log } from '@guardian/libs';
import { isServer } from '../lib/isServer';
import { setSchedulerPriorityLastStartTime } from '../lib/scheduler';

/**
* Whether we should adapt the current page to address poor performance issues.
* Initially this will only happen as part of a @guardian/open-journalism test.
*
* It will resolve immediately if `false`, but needs to wait for perf check to
* complete if you're in the adaptive site test variant.
*/
export const shouldAdapt = new Promise<boolean>((resolve) => {
if (isServer) return resolve(false);
if (window.location.hash === '#adapt') return resolve(true);
export const shouldAdapt = async (): Promise<boolean> => {
if (isServer) return false;
if (window.location.hash === '#adapt') return true;
if (window.guardian.config.tests.adaptiveSiteVariant !== 'variant') {
return resolve(false);
return false;
}

// only evaluate this code if we want to adapt in response to page performance
return void import(
const { isPerformingPoorly } = await import(
/* webpackMode: "eager" */ './poorPerformanceMonitoring'
).then(({ isPerformingPoorly }) => isPerformingPoorly.then(resolve));
});
);

return isPerformingPoorly();
};

/** Hide all placeholders of non-critical islands */
const hideAdaptedIslands = () => {
const style = document.createElement('style');
style.innerHTML = `gu-island:not([priority=critical]) [data-name=placeholder] { display: none; }`;
document.head.appendChild(style);
};

export const adaptSite = (): void => {
log('openJournalism', '🎛️ Adapting');

// disable all tasks except critical ones
setSchedulerPriorityLastStartTime('feature', 0);
setSchedulerPriorityLastStartTime('enhancement', 0);
hideAdaptedIslands();
};
Loading

0 comments on commit d9490ef

Please sign in to comment.