refactor: clean up tags tests (#45411)
I also added a note about why it's flaky, since I haven't been able to fix the flakiness
This commit is contained in:
committed by
GitHub
parent
bd8f9097c6
commit
1e63f38c53
@ -1,87 +1,98 @@
|
|||||||
|
const challenges = {
|
||||||
|
responsiveWebDesign:
|
||||||
|
'/learn/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements',
|
||||||
|
rosettaCode: '/learn/coding-interview-prep/rosetta-code/100-doors',
|
||||||
|
projectEuler:
|
||||||
|
'/learn/coding-interview-prep/project-euler/problem-1-multiples-of-3-and-5'
|
||||||
|
};
|
||||||
|
|
||||||
|
const social = {
|
||||||
|
description: 'Learn to Code — For Free'
|
||||||
|
};
|
||||||
|
|
||||||
|
const scripts = {
|
||||||
|
mathjax: {
|
||||||
|
selector: 'body script[id="mathjax"]',
|
||||||
|
src: 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS_HTML'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
describe('The Document Metadata', () => {
|
describe('The Document Metadata', () => {
|
||||||
before(() => {
|
describe('landing page', () => {
|
||||||
cy.visit('/');
|
before(() => {
|
||||||
cy.document();
|
cy.visit('/');
|
||||||
});
|
});
|
||||||
|
|
||||||
const social = {
|
it('has correct <meta> for description', () => {
|
||||||
description: 'Learn to Code — For Free'
|
cy.get('head meta[name="description"]').should(
|
||||||
};
|
'have.attr',
|
||||||
|
'content',
|
||||||
const challengs = {
|
'Learn to Code — For Free'
|
||||||
responsiveWebDesign:
|
);
|
||||||
'/learn/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements',
|
});
|
||||||
rosetaCode: '/learn/coding-interview-prep/rosetta-code/100-doors',
|
it('has correct <meta> for og title', () => {
|
||||||
projectEuler:
|
cy.get('head meta[name="og:title"]').should(
|
||||||
'/learn/coding-interview-prep/project-euler/problem-1-multiples-of-3-and-5'
|
'have.attr',
|
||||||
};
|
'content',
|
||||||
|
'freeCodeCamp.org'
|
||||||
const scripts = {
|
);
|
||||||
mathjax: {
|
});
|
||||||
selector: 'body script[id="mathjax"]',
|
it('has correct <meta> for og description', () => {
|
||||||
src: 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS_HTML'
|
cy.get('head meta[name="og:description"]').should(
|
||||||
}
|
'have.attr',
|
||||||
};
|
'content',
|
||||||
it('landing page has correct <meta> for description', () => {
|
social.description
|
||||||
cy.get('head meta[name="description"]').should(
|
);
|
||||||
'have.attr',
|
});
|
||||||
'content',
|
it('has correct <meta> for twitter title', () => {
|
||||||
'Learn to Code — For Free'
|
cy.get('head meta[name="twitter:title"]').should(
|
||||||
);
|
'have.attr',
|
||||||
|
'content',
|
||||||
|
'freeCodeCamp.org'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('has correct <meta>for twitter description', () => {
|
||||||
|
cy.get('head meta[name="twitter:description"]').should(
|
||||||
|
'have.attr',
|
||||||
|
'content',
|
||||||
|
social.description
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('should not have mathjax body script', () => {
|
||||||
|
cy.get(scripts.mathjax.selector).should('not.exist');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('landing page has correct <meta> for og title', () => {
|
describe('responsive webdesign challenges', () => {
|
||||||
cy.get('head meta[name="og:title"]').should(
|
it('should not have mathjax body script', () => {
|
||||||
'have.attr',
|
cy.visit(challenges.responsiveWebDesign);
|
||||||
'content',
|
cy.contains('Basic HTML and HTML5');
|
||||||
'freeCodeCamp.org'
|
cy.get(scripts.mathjax.selector).should('not.exist');
|
||||||
);
|
});
|
||||||
});
|
});
|
||||||
it('landing page has correct <meta> for og description', () => {
|
describe('project euler challenges', () => {
|
||||||
cy.get('head meta[name="og:description"]').should(
|
it('should have mathjax body script', () => {
|
||||||
'have.attr',
|
// TODO: this is flaky, because (somehow) a chunk error is thrown when
|
||||||
'content',
|
// visiting this page and browser (somehow) ends up on
|
||||||
social.description
|
// challenges/responsiveWebDesign
|
||||||
);
|
// The second visit to this page works fine.
|
||||||
|
cy.visit(challenges.projectEuler);
|
||||||
|
cy.contains('Project Euler');
|
||||||
|
cy.get(scripts.mathjax.selector).should(
|
||||||
|
'have.attr',
|
||||||
|
'src',
|
||||||
|
scripts.mathjax.src
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('landing page has correct <meta> for twitter title', () => {
|
describe('rosetta code challenges', () => {
|
||||||
cy.get('head meta[name="twitter:title"]').should(
|
it('should have mathjax body script', () => {
|
||||||
'have.attr',
|
cy.visit(challenges.rosettaCode);
|
||||||
'content',
|
cy.contains('Rosetta Code');
|
||||||
'freeCodeCamp.org'
|
cy.get(scripts.mathjax.selector).should(
|
||||||
);
|
'have.attr',
|
||||||
});
|
'src',
|
||||||
it('landing page has correct <meta>for twitter description', () => {
|
scripts.mathjax.src
|
||||||
cy.get('head meta[name="twitter:description"]').should(
|
);
|
||||||
'have.attr',
|
});
|
||||||
'content',
|
|
||||||
social.description
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it('landing page should not have mathjax body script', () => {
|
|
||||||
cy.reload();
|
|
||||||
cy.get(scripts.mathjax.selector).should('not.exist');
|
|
||||||
});
|
|
||||||
it('responsive webdesign challenges should not have mathjax body script', () => {
|
|
||||||
cy.visit(challengs.responsiveWebDesign);
|
|
||||||
cy.reload();
|
|
||||||
cy.get(scripts.mathjax.selector).should('not.exist');
|
|
||||||
});
|
|
||||||
it('project euler challenges should have mathjax body script', () => {
|
|
||||||
cy.visit(challengs.projectEuler);
|
|
||||||
cy.reload();
|
|
||||||
cy.get(scripts.mathjax.selector).should(
|
|
||||||
'have.attr',
|
|
||||||
'src',
|
|
||||||
scripts.mathjax.src
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it('rosetta code challenges should have mathjax body script', () => {
|
|
||||||
cy.visit(challengs.projectEuler);
|
|
||||||
cy.reload();
|
|
||||||
cy.get(scripts.mathjax.selector).should(
|
|
||||||
'have.attr',
|
|
||||||
'src',
|
|
||||||
scripts.mathjax.src
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user