Skip to content

Commit

Permalink
Add e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rachelcg committed Apr 27, 2023
1 parent 4955bc0 commit a99df8a
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 0 deletions.
38 changes: 38 additions & 0 deletions cypress/e2e/norobots.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
describe('SEO Meta Norobots', () => {
it('App loads', () => {
cy.visit('http://localhost:3000');
cy.get('h1').should('contain', 'Default SEO');
});

it('SEO norobots', () => {
cy.visit('http://localhost:3000/norobots');
cy.get('head meta[name="robots"]').should('not.exist');
});

it('SEO overrides norobots with nofollow correctly', () => {
cy.visit('http://localhost:3000/norobots/nofollow');
cy.get('head meta[name="robots"]').should(
'have.attr',
'content',
'index,nofollow',
);
});

it('SEO overrides norobots with nofollow correctly', () => {
cy.visit('http://localhost:3000/norobots/noindex');
cy.get('head meta[name="robots"]').should(
'have.attr',
'content',
'noindex,follow',
);
});

it('SEO overrides norobots with robots props correctly', () => {
cy.visit('http://localhost:3000/norobots/robots');
cy.get('head meta[name="robots"]').should(
'have.attr',
'content',
'index,follow,nosnippet,max-snippet:-1,max-image-preview:none,noarchive,noimageindex,max-video-preview:-1,notranslate',
);
});
});
1 change: 1 addition & 0 deletions e2e/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function MyApp({ Component, pageProps, router }: AppProps) {
router.pathname === '/dangerously/noindex' ||
router.pathname === '/dangerously/nofollow-and-noindex'
}
norobots={router.pathname.startsWith('/norobots')}
/>
<Component {...pageProps} />
</>
Expand Down
12 changes: 12 additions & 0 deletions e2e/pages/norobots/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import { NextSeo } from '../../..';
import Links from '../../components/links';

const NoRobots = () => (
<>
<NextSeo title="NoRobots" />
<h1>norobots</h1>
<Links />
</>
);
export default NoRobots;
12 changes: 12 additions & 0 deletions e2e/pages/norobots/nofollow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import { NextSeo } from '../../..';
import Links from '../../components/links';

const NoRobotsNoFollow = () => (
<>
<NextSeo title="NoRobots NoFollow" nofollow />
<h1>norobots and nofollow</h1>
<Links />
</>
);
export default NoRobotsNoFollow;
12 changes: 12 additions & 0 deletions e2e/pages/norobots/noindex.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import { NextSeo } from '../../..';
import Links from '../../components/links';

const NoRobotsNoIndex = () => (
<>
<NextSeo title="NoRobots NoIndex" noindex />
<h1>norobots and noindex</h1>
<Links />
</>
);
export default NoRobotsNoIndex;
24 changes: 24 additions & 0 deletions e2e/pages/norobots/robots.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import { NextSeo } from '../../..';
import Links from '../../components/links';

const Robots = () => (
<>
<NextSeo
title="Robots meta title"
robotsProps={{
nosnippet: true,
notranslate: true,
noimageindex: true,
noarchive: true,
maxSnippet: -1,
maxImagePreview: 'none',
maxVideoPreview: -1,
}}
/>
<h1>Norobots with Robots meta properties</h1>
<Links />
</>
);

export default Robots;

0 comments on commit a99df8a

Please sign in to comment.