fix: source certificates into Gatsby (#39648)
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
f132f5157c
commit
4b14f9297b
@ -1,9 +1,11 @@
|
|||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
|
|
||||||
function createChallengeNode(challenge, reporter) {
|
function createChallengeNode(challenge, reporter) {
|
||||||
|
// challengeType 11 is for video challenges (they only have instructions)
|
||||||
|
// challengeType 7 is for certificates (they only have tests)
|
||||||
if (
|
if (
|
||||||
typeof challenge.description[0] !== 'string' &&
|
typeof challenge.description[0] !== 'string' &&
|
||||||
challenge.challengeType !== 11
|
(challenge.challengeType !== 11 && challenge.challengeType !== 7)
|
||||||
) {
|
) {
|
||||||
reporter.warn(`
|
reporter.warn(`
|
||||||
|
|
||||||
@ -17,7 +19,7 @@ function createChallengeNode(challenge, reporter) {
|
|||||||
.digest('hex');
|
.digest('hex');
|
||||||
const internal = {
|
const internal = {
|
||||||
contentDigest,
|
contentDigest,
|
||||||
type: 'ChallengeNode'
|
type: challenge.challengeType === 7 ? 'CertificateNode' : 'ChallengeNode'
|
||||||
};
|
};
|
||||||
|
|
||||||
/* eslint-disable prefer-object-spread/prefer-object-spread */
|
/* eslint-disable prefer-object-spread/prefer-object-spread */
|
||||||
@ -26,13 +28,13 @@ function createChallengeNode(challenge, reporter) {
|
|||||||
Object.assign(
|
Object.assign(
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
id: challenge.id + ' >>>> ChallengeNode',
|
|
||||||
children: [],
|
children: [],
|
||||||
parent: null,
|
parent: null,
|
||||||
internal,
|
internal,
|
||||||
sourceInstanceName: 'challenge'
|
sourceInstanceName: 'challenge'
|
||||||
},
|
},
|
||||||
challenge
|
challenge,
|
||||||
|
{ id: challenge.id + internal.type }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -69,7 +69,6 @@ File changed at ${filePath}, replacing challengeNode id ${challenge.id}
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createVisibleChallenge(challenge) {
|
function createVisibleChallenge(challenge) {
|
||||||
if (challenge.superBlock.toLowerCase() === 'certificates') return;
|
|
||||||
createNode(createChallengeNode(challenge, reporter));
|
createNode(createChallengeNode(challenge, reporter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,9 +76,6 @@ exports.createChallengePages = createPage => ({ node }, index, thisArray) => {
|
|||||||
} = node;
|
} = node;
|
||||||
// TODO: challengeType === 7 and isPrivate are the same, right? If so, we
|
// TODO: challengeType === 7 and isPrivate are the same, right? If so, we
|
||||||
// should remove one of them.
|
// should remove one of them.
|
||||||
if (challengeType === 7) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return createPage({
|
return createPage({
|
||||||
path: slug,
|
path: slug,
|
||||||
|
@ -7,6 +7,19 @@ const selectors = {
|
|||||||
landingPageImage: '.landing-page-image'
|
landingPageImage: '.landing-page-image'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const certifications = [
|
||||||
|
'Responsive Web Design',
|
||||||
|
'JavaScript Algorithms and Data Structures',
|
||||||
|
'Front End Libraries',
|
||||||
|
'Data Visualization',
|
||||||
|
'APIs and Microservices',
|
||||||
|
'Quality Assurance',
|
||||||
|
'Scientific Computing with Python',
|
||||||
|
'Data Analysis with Python',
|
||||||
|
'Information Security',
|
||||||
|
'Machine Learning with Python'
|
||||||
|
];
|
||||||
|
|
||||||
describe('Landing page', () => {
|
describe('Landing page', () => {
|
||||||
it('Should render', () => {
|
it('Should render', () => {
|
||||||
cy.visit('/');
|
cy.visit('/');
|
||||||
@ -50,11 +63,14 @@ describe('Landing page', () => {
|
|||||||
.should('not.be.visible');
|
.should('not.be.visible');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Has 10 certifications', function() {
|
it('Has links to all the certifications', function() {
|
||||||
cy.get(selectors.certifications)
|
cy.get(selectors.certifications)
|
||||||
.children()
|
.children()
|
||||||
.its('length')
|
.its('length')
|
||||||
.should('eq', 10);
|
.should('eq', 10);
|
||||||
|
cy.wrap(certifications).each(cert => {
|
||||||
|
cy.get(selectors.certifications).contains(cert);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Has 3 testimonial cards', function() {
|
it('Has 3 testimonial cards', function() {
|
||||||
|
Reference in New Issue
Block a user