aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--next.config.js6
-rw-r--r--tests/cypress/e2e/pages/404.cy.ts5
-rw-r--r--tests/cypress/e2e/pages/blog.cy.ts72
-rw-r--r--tests/cypress/e2e/search.cy.ts24
-rw-r--r--tests/fixtures/wp-posts.fixture.ts273
-rw-r--r--tests/fixtures/wp-thematics.fixture.ts10
-rw-r--r--tests/fixtures/wp-topics.fixture.ts10
7 files changed, 324 insertions, 76 deletions
diff --git a/next.config.js b/next.config.js
index 5bd458d..02aa847 100644
--- a/next.config.js
+++ b/next.config.js
@@ -107,6 +107,10 @@ const nextConfig = {
protocol: 'https',
hostname: 'cloudflare-ipfs.com',
},
+ {
+ protocol: 'https',
+ hostname: 'picsum.photos',
+ },
],
},
output: 'standalone',
@@ -190,4 +194,4 @@ const withMDX = nextMDX({
export default withBundleAnalyzer(withMDX(nextConfig));
-// cSpell:ignore ipfs
+// cSpell:ignore ipfs picsum
diff --git a/tests/cypress/e2e/pages/404.cy.ts b/tests/cypress/e2e/pages/404.cy.ts
index 7899275..77f3085 100644
--- a/tests/cypress/e2e/pages/404.cy.ts
+++ b/tests/cypress/e2e/pages/404.cy.ts
@@ -25,7 +25,10 @@ describe('404 Page', () => {
const keywords = 'coldark';
cy.findByRole('searchbox').type(keywords);
- cy.findByRole('button', { name: /Rechercher/ }).click();
+ cy.findByRole('button', { name: /Rechercher/ })
+ .click()
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
+ .wait(500);
cy.findByRole('heading', { level: 1 }).should('contain.text', keywords);
});
});
diff --git a/tests/cypress/e2e/pages/blog.cy.ts b/tests/cypress/e2e/pages/blog.cy.ts
index 0350e39..a83caa0 100644
--- a/tests/cypress/e2e/pages/blog.cy.ts
+++ b/tests/cypress/e2e/pages/blog.cy.ts
@@ -1,10 +1,6 @@
import { CONFIG } from '../../../../src/utils/config';
import { ROUTES } from '../../../../src/utils/constants';
-
-type ArticlesGroup = {
- first: string;
- total: string;
-};
+import { wpPostsFixture } from '../../../fixtures';
describe('Blog Page', () => {
beforeEach(() => {
@@ -19,43 +15,39 @@ describe('Blog Page', () => {
cy.findByRole('navigation', { name: 'Fil d’Ariane' }).should('exist');
});
- it('loads the correct number of pages', () => {
+ it('loads the correct number of posts', () => {
cy.findByText(
/(?<first>\d+) articles chargés sur un total de (?<total>\d+)/i
- )
- .then(($div) => {
- const firstLastNumbers = /(?<first>\d+).*[\D](?<total>\d+)/;
- const result = RegExp(firstLastNumbers).exec($div.text());
-
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
- expect(result).to.not.be.null;
-
- const { first, total } = result
- ? (result.groups as ArticlesGroup)
- : { first: '0', total: '0' };
- const totalArticles = parseInt(total, 10);
-
- expect(parseInt(first, 10)).to.be.within(1, CONFIG.postsPerPage);
- expect(totalArticles).to.be.at.least(1);
-
- const totalPages = Math.ceil(totalArticles / CONFIG.postsPerPage);
- const remainingPages = totalPages - 1;
-
- return Array.from({ length: remainingPages }, (_, i) => i + 1);
- })
- .then((remainingPages) => {
- if (remainingPages.length >= 1) {
- cy.wrap(remainingPages).each(() => {
- cy.findByRole('button', {
- name: /Charger plus d’articles/i,
- }).click();
- });
- }
-
- cy.findByRole('button', { name: /Charger plus d’articles/i }).should(
- 'not.exist'
- );
- });
+ ).should('exist');
+ cy.findAllByRole('link', { name: /En lire plus/ }).should(
+ 'have.length.at.most',
+ CONFIG.postsPerPage
+ );
+
+ const loadMorePosts = () => {
+ cy.findByRole('button', { name: /Charger plus/ })
+ .should((_) => {
+ /* do nothing */
+ })
+ .then(($loadMoreBtn) => {
+ if (!$loadMoreBtn.length) {
+ cy.log('No more posts');
+ return;
+ }
+
+ cy.log('Loading more posts');
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
+ cy.wrap($loadMoreBtn).click().wait(500);
+ loadMorePosts();
+ });
+ };
+
+ loadMorePosts();
+
+ cy.findAllByRole('link', { name: /En lire plus/ }).should(
+ 'have.length',
+ wpPostsFixture.length
+ );
});
it('contains a thematics list widget and a topics list widget', () => {
diff --git a/tests/cypress/e2e/search.cy.ts b/tests/cypress/e2e/search.cy.ts
index be9aa9f..f4f80f2 100644
--- a/tests/cypress/e2e/search.cy.ts
+++ b/tests/cypress/e2e/search.cy.ts
@@ -1,31 +1,32 @@
import { ROUTES } from '../../../src/utils/constants';
-const queryWithArticles = 'Coldark';
const queryWithoutArticles = 'etEtRerum';
describe('Search', () => {
it('should open and close search form by clicking on search button', () => {
cy.visit('/');
// findByLabelText does not return the input but the label...
- cy.findByLabelText(/Ouvrir la recherche/i)
+ cy.findByLabelText(/Ouvrir le formulaire de recherche/i)
.prev()
.should('not.be.checked');
cy.findByRole('searchbox', { name: /Rechercher/i }).should('not.exist');
- cy.findByLabelText(/Ouvrir la recherche/i).click();
- cy.findByLabelText(/Ouvrir la recherche/i)
+ cy.findByLabelText(/Ouvrir le formulaire de recherche/i).click();
+ cy.findByLabelText(/Ouvrir le formulaire de recherche/i)
.prev()
.should('be.checked');
cy.findByRole('searchbox', { name: /Rechercher/i }).should('exist');
- cy.findByLabelText(/Ouvrir la recherche/i).click();
- cy.findByLabelText(/Ouvrir la recherche/i).should('not.be.checked');
+ cy.findByLabelText(/Ouvrir le formulaire de recherche/i).click();
+ cy.findByLabelText(/Ouvrir le formulaire de recherche/i).should(
+ 'not.be.checked'
+ );
cy.findByRole('searchbox', { name: /Rechercher/i }).should('not.exist');
});
it('should navigate the search page', () => {
cy.visit('/');
- cy.findByLabelText(/Ouvrir la recherche/i).click();
+ cy.findByLabelText(/Ouvrir le formulaire de recherche/i).click();
cy.findByRole('searchbox', { name: /Rechercher/i }).type(
- `${queryWithArticles}{enter}`
+ `${'coldark'}{enter}`
);
cy.url().should('include', ROUTES.SEARCH);
cy.findByRole('heading', { level: 1 }).contains(
@@ -33,13 +34,6 @@ describe('Search', () => {
);
});
- it('should display the total of articles if successful', () => {
- cy.visit(`${ROUTES.SEARCH}?s=${encodeURIComponent(queryWithArticles)}`);
- const metaList = cy.findByRole('heading', { level: 1 }).next();
- metaList.findByRole('term').contains(/Total/i);
- metaList.findByRole('definition').contains(/article/i);
- });
-
it('should display a search form if unsuccessful', () => {
cy.visit(`${ROUTES.SEARCH}?s=${encodeURIComponent(queryWithoutArticles)}`);
cy.findByRole('searchbox', { name: /Rechercher/i }).should('exist');
diff --git a/tests/fixtures/wp-posts.fixture.ts b/tests/fixtures/wp-posts.fixture.ts
index a512c51..537219e 100644
--- a/tests/fixtures/wp-posts.fixture.ts
+++ b/tests/fixtures/wp-posts.fixture.ts
@@ -26,7 +26,7 @@ export const wpPostsFixture = [
metaDesc: 'Repudiandae autem numquam.',
title: 'similique atque corporis',
},
- slug: '/post-1',
+ slug: 'post-1',
title: 'Post 1',
},
{
@@ -64,7 +64,7 @@ export const wpPostsFixture = [
metaDesc: 'Veritatis deleniti et cum modi id necessitatibus dolores.',
title: 'numquam nihil voluptas',
},
- slug: '/post-2',
+ slug: 'post-2',
title: 'Post 2',
},
{
@@ -72,7 +72,7 @@ export const wpPostsFixture = [
postsInThematic: [
{
databaseId: 2,
- slug: '/thematic-1',
+ slug: 'thematic-1',
title: 'Thematic 1',
},
],
@@ -112,7 +112,7 @@ export const wpPostsFixture = [
'Ut deserunt qui reprehenderit ut veritatis consequatur quia corporis.',
title: 'laboriosam incidunt enim',
},
- slug: '/post-3',
+ slug: 'post-3',
title: 'Post 3',
},
{
@@ -120,12 +120,12 @@ export const wpPostsFixture = [
postsInThematic: [
{
databaseId: 3,
- slug: '/thematic-2',
+ slug: 'thematic-2',
title: 'Thematic 2',
},
{
databaseId: 4,
- slug: '/thematic-3',
+ slug: 'thematic-3',
title: 'Thematic 3',
},
],
@@ -133,7 +133,7 @@ export const wpPostsFixture = [
{
databaseId: 2,
featuredImage: null,
- slug: '/topic-1',
+ slug: 'topic-1',
title: 'Topic 1',
},
],
@@ -171,10 +171,265 @@ export const wpPostsFixture = [
metaDesc: 'In ipsam pariatur laboriosam aut alias molestiae.',
title: 'fugit et sunt',
},
- slug: '/post-4',
+ slug: 'post-4',
title: 'Post 4',
},
{
+ acfPosts: {
+ postsInThematic: [
+ {
+ databaseId: 3,
+ slug: 'thematic-2',
+ title: 'Thematic 2',
+ },
+ {
+ databaseId: 4,
+ slug: 'thematic-3',
+ title: 'Thematic 3',
+ },
+ ],
+ postsInTopic: [
+ {
+ databaseId: 2,
+ featuredImage: null,
+ slug: 'topic-1',
+ title: 'Topic 1',
+ },
+ ],
+ },
+ author: {
+ node: {
+ name: 'Roberto8',
+ },
+ },
+ commentCount: 2,
+ contentParts: {
+ afterMore:
+ 'Sint incidunt accusantium nemo nam nihil optio et et. Perferendis modi nemo quasi iusto rerum. Velit et praesentium quaerat deserunt labore. Et et rem. In vel voluptatem eius laborum amet. Alias et ducimus aut.',
+ beforeMore: 'Quis voluptatem nulla porro eius a. Iste odit dicta.',
+ },
+ databaseId: 5,
+ date: '2022-11-09',
+ featuredImage: {
+ node: {
+ altText: 'dolor velit et',
+ mediaDetails: {
+ height: 480,
+ width: 640,
+ },
+ sourceUrl: 'https://picsum.photos/640/480',
+ title: 'quia nihil doloremque',
+ },
+ },
+ info: {
+ wordsCount: 632,
+ },
+ modified: '2022-11-09',
+ seo: {
+ metaDesc: 'Velit ex quidem praesentium.',
+ title: 'alias vitae voluptatibus',
+ },
+ slug: 'post-5',
+ title: 'Post 5',
+ },
+ {
+ acfPosts: null,
+ author: {
+ node: {
+ name: 'Maude15',
+ },
+ },
+ commentCount: 1,
+ contentParts: {
+ afterMore:
+ 'Aut molestiae quidem blanditiis error vero. Nemo enim temporibus impedit ut. Ratione dolor voluptas molestiae.',
+ beforeMore:
+ 'Impedit nulla quaerat in eum. Id exercitationem eveniet nulla quod officiis ducimus modi atque quae.',
+ },
+ databaseId: 6,
+ date: '2022-11-12',
+ featuredImage: null,
+ info: {
+ wordsCount: 400,
+ },
+ modified: '2022-11-12',
+ seo: {
+ metaDesc: 'Natus ut consequuntur mollitia quis.',
+ title: 'iste quaerat veritatis',
+ },
+ slug: 'post-6',
+ title: 'Post 6',
+ },
+ {
+ acfPosts: null,
+ author: {
+ node: {
+ name: 'Alisha.Dare45',
+ },
+ },
+ commentCount: 0,
+ contentParts: {
+ afterMore:
+ 'Recusandae fuga aut. Eos nemo tempora omnis sapiente. Nobis nemo et modi officia odit fuga. Voluptas minima voluptas.',
+ beforeMore:
+ 'Laudantium quia fugit hic. Nesciunt voluptas debitis asperiores non. Distinctio nam omnis labore asperiores earum consectetur sequi.',
+ },
+ databaseId: 7,
+ date: '2022-11-22',
+ featuredImage: null,
+ info: {
+ wordsCount: 250,
+ },
+ modified: '2022-11-23',
+ seo: {
+ metaDesc: 'Nulla pariatur recusandae.',
+ title: 'quidem cumque dolores',
+ },
+ slug: 'post-7',
+ title: 'Post 7',
+ },
+ {
+ acfPosts: {
+ postsInThematic: [
+ {
+ databaseId: 2,
+ slug: 'thematic-1',
+ title: 'Thematic 1',
+ },
+ ],
+ postsInTopic: null,
+ },
+ author: {
+ node: {
+ name: 'Jess.Anderson76',
+ },
+ },
+ commentCount: 1,
+ contentParts: {
+ afterMore:
+ 'Commodi iusto labore cumque. Molestias quam hic. Doloremque qui sint odit ad quia est. Aut qui sed perferendis nisi commodi illum. Ipsum facilis officiis voluptas est non ut.',
+ beforeMore:
+ 'Tenetur corrupti natus est enim ab. Harum incidunt recusandae earum neque. Impedit cum qui.',
+ },
+ databaseId: 8,
+ date: '2022-11-27',
+ featuredImage: {
+ node: {
+ altText: 'voluptatibus iure ea',
+ mediaDetails: {
+ height: 480,
+ width: 640,
+ },
+ sourceUrl: 'https://picsum.photos/640/480',
+ title: null,
+ },
+ },
+ info: {
+ wordsCount: 310,
+ },
+ modified: '2022-11-28',
+ seo: {
+ metaDesc: 'Voluptates enim quaerat perferendis facilis ducimus.',
+ title: 'sed qui harum',
+ },
+ slug: 'post-8',
+ title: 'Post 8',
+ },
+ {
+ acfPosts: {
+ postsInThematic: [
+ {
+ databaseId: 3,
+ slug: 'thematic-2',
+ title: 'Thematic 2',
+ },
+ ],
+ postsInTopic: null,
+ },
+ author: {
+ node: {
+ name: 'Alisha.Dare45',
+ },
+ },
+ commentCount: 1,
+ contentParts: {
+ afterMore:
+ 'Qui voluptas ut fugit adipisci nihil eaque quasi. Tenetur laboriosam sapiente et nihil eaque unde officia molestiae. Dolor ut minima hic assumenda et inventore harum sint.',
+ beforeMore:
+ 'Tempora quis iste possimus sit aspernatur et at alias ipsum. Commodi eius quis quod sint quis nihil fugit rem deleniti. Itaque ea necessitatibus tempore. Et sint modi velit quam sint.',
+ },
+ databaseId: 9,
+ date: '2022-12-02',
+ featuredImage: {
+ node: {
+ altText: 'ut totam dolores',
+ mediaDetails: {
+ height: 480,
+ width: 640,
+ },
+ sourceUrl: 'https://picsum.photos/640/480',
+ title: null,
+ },
+ },
+ info: {
+ wordsCount: 412,
+ },
+ modified: '2022-12-02',
+ seo: {
+ metaDesc: 'Nemo temporibus et eos magnam blanditiis voluptas.',
+ title: 'at sunt et',
+ },
+ slug: 'post-9',
+ title: 'Post 9',
+ },
+ {
+ acfPosts: {
+ postsInThematic: [
+ {
+ databaseId: 4,
+ slug: 'thematic-3',
+ title: 'Thematic 3',
+ },
+ ],
+ postsInTopic: null,
+ },
+ author: {
+ node: {
+ name: 'Dominic.Cronin57',
+ },
+ },
+ commentCount: 5,
+ contentParts: {
+ afterMore:
+ 'Cum nihil omnis molestias atque. Suscipit voluptas culpa. Accusantium ducimus qui dignissimos corrupti esse quo accusamus. Eum eaque sint incidunt odio. Aut nesciunt repellat nobis dolorem eos temporibus ducimus nesciunt similique. Dignissimos veniam repellat.',
+ beforeMore:
+ 'Qui dolores qui soluta aliquam a suscipit quas. Laborum quos qui esse ut sequi. Omnis voluptas ut. Iure et ducimus unde. Officiis id laborum sunt perferendis libero et. Ut dolores necessitatibus perferendis distinctio.',
+ },
+ databaseId: 10,
+ date: '2022-12-06',
+ featuredImage: {
+ node: {
+ altText: 'ratione necessitatibus hic',
+ mediaDetails: {
+ height: 480,
+ width: 640,
+ },
+ sourceUrl: 'https://picsum.photos/640/480',
+ title: null,
+ },
+ },
+ info: {
+ wordsCount: 220,
+ },
+ modified: '2022-12-07',
+ seo: {
+ metaDesc: 'Perspiciatis ut et.',
+ title: 'voluptatem aut omnis',
+ },
+ slug: 'post-10',
+ title: 'Post 10',
+ },
+ {
acfPosts: null,
author: {
node: {
@@ -202,7 +457,7 @@ export const wpPostsFixture = [
/* I don't want to mock all the requests so I need an existing slug. The
* solution is only temporary since if I write another article, I would
* need to update the slug... */
- slug: '/version-2022-bonjour-next-js',
+ slug: 'version-2022-bonjour-next-js',
title: 'porro adipisci adipisci',
},
] satisfies WPPost[];
diff --git a/tests/fixtures/wp-thematics.fixture.ts b/tests/fixtures/wp-thematics.fixture.ts
index ac9064a..23b772d 100644
--- a/tests/fixtures/wp-thematics.fixture.ts
+++ b/tests/fixtures/wp-thematics.fixture.ts
@@ -17,7 +17,7 @@ export const wpThematicsFixture: WPThematic[] = [
metaDesc: 'In temporibus quis nihil veniam cum excepturi aliquam.',
title: 'aut veritatis molestias',
},
- slug: '/veritatis-autem-voluptas',
+ slug: 'veritatis-autem-voluptas',
title: 'veritatis autem voluptas',
},
{
@@ -46,7 +46,7 @@ export const wpThematicsFixture: WPThematic[] = [
metaDesc: 'Sed nulla nihil at dolores omnis repellendus qui sed.',
title: 'assumenda omnis placeat',
},
- slug: '/aliquid-quia-eius',
+ slug: 'aliquid-quia-eius',
title: 'aliquid quia eius',
},
{
@@ -68,7 +68,7 @@ export const wpThematicsFixture: WPThematic[] = [
'Consequatur nisi dolorum fugiat mollitia aperiam ratione quibusdam.',
title: 'vel et velit',
},
- slug: '/quasi-sint-nulla',
+ slug: 'quasi-sint-nulla',
title: 'quasi sint nulla',
},
{
@@ -88,7 +88,7 @@ export const wpThematicsFixture: WPThematic[] = [
wordsCount: 523,
},
modified: '2021-10-15',
- slug: '/incidunt-cupiditate-in',
+ slug: 'incidunt-cupiditate-in',
title: 'incidunt cupiditate in',
},
],
@@ -108,7 +108,7 @@ export const wpThematicsFixture: WPThematic[] = [
'Recusandae et laboriosam repudiandae sit dignissimos accusantium.',
title: 'consectetur magni eum',
},
- slug: '/numquam-commodi-velit',
+ slug: 'numquam-commodi-velit',
title: 'numquam commodi velit',
},
];
diff --git a/tests/fixtures/wp-topics.fixture.ts b/tests/fixtures/wp-topics.fixture.ts
index d790dea..50117cb 100644
--- a/tests/fixtures/wp-topics.fixture.ts
+++ b/tests/fixtures/wp-topics.fixture.ts
@@ -17,7 +17,7 @@ export const wpTopicsFixture: WPTopic[] = [
metaDesc: 'Et magnam id dicta iste molestiae illum officia provident.',
title: 'est dolores tempore',
},
- slug: '/eveniet-ut-quis',
+ slug: 'eveniet-ut-quis',
title: 'eveniet ut quis',
},
{
@@ -50,7 +50,7 @@ export const wpTopicsFixture: WPTopic[] = [
'Consequuntur aut excepturi dicta et qui quasi enim voluptas cum.',
title: 'aliquid consectetur corporis',
},
- slug: '/nisi-ut-facere',
+ slug: 'nisi-ut-facere',
title: 'nisi ut facere',
},
{
@@ -72,7 +72,7 @@ export const wpTopicsFixture: WPTopic[] = [
metaDesc: 'Sed impedit quisquam voluptate voluptatem consequuntur.',
title: 'porro autem sunt',
},
- slug: '/iusto-non-consectetur',
+ slug: 'iusto-non-consectetur',
title: 'iusto non consectetur',
},
{
@@ -93,7 +93,7 @@ export const wpTopicsFixture: WPTopic[] = [
wordsCount: 468,
},
modified: '2021-09-15',
- slug: '/possimus-temporibus-magni',
+ slug: 'possimus-temporibus-magni',
title: 'possimus temporibus magni',
},
],
@@ -112,7 +112,7 @@ export const wpTopicsFixture: WPTopic[] = [
metaDesc: 'Quaerat non ex inventore officiis amet.',
title: 'in alias ipsa',
},
- slug: '/non-repellendus-ipsam',
+ slug: 'non-repellendus-ipsam',
title: 'non repellendus ipsam',
},
];