Skip to content
This repository was archived by the owner on Oct 4, 2022. It is now read-only.

Commit 3fbf823

Browse files
committed
Merge branch 'release-yoast-seo/9.8' of https://github.com/Yoast/javascript into release-yoast-seo/9.8
2 parents c8f1bb2 + f373906 commit 3fbf823

File tree

94 files changed

+1598
-2915
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1598
-2915
lines changed

packages/yoastseo/grunt/config/eslint.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = function( grunt ) {
1414
src: [ "<%= files.jsTests %>" ],
1515
options: {
1616
configFile: ".eslintrc-tests",
17-
maxWarnings: 49,
17+
maxWarnings: 19,
1818
fix: fix,
1919
},
2020
},

packages/yoastseo/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"url": "https://github.com/Yoast/YoastSEO.js"
1616
},
1717
"scripts": {
18+
"start": "npm start --prefix examples/webpack",
1819
"build": "grunt publish",
1920
"lint": "grunt check",
2021
"test": "jest --runInBand",
@@ -52,6 +53,7 @@
5253
"grunt-shell": "^2.0.0",
5354
"istanbul": "^0.4.0",
5455
"jest": "^23.5.0",
56+
"js-yaml": "^3.12.1",
5557
"load-grunt-config": "^1.0.0",
5658
"lodash-cli": "^4.14.1",
5759
"node-sass": "^4.9.3"

packages/yoastseo/spec/SEOAssessorSpec.js

+2-221
Original file line numberDiff line numberDiff line change
@@ -4,229 +4,10 @@ import factory from "./specHelpers/factory.js";
44
import getResults from "./specHelpers/getAssessorResults";
55
const i18n = factory.buildJed();
66

7-
describe( "running assessments in the assessor for regular analysis", function() {
7+
describe( "running assessments in the assessor", function() {
88
let assessor;
99

1010
beforeEach( () => {
11-
process.env.YOAST_RECALIBRATION = "disabled";
12-
assessor = new Assessor( i18n );
13-
} );
14-
15-
it( "runs assessments without any specific requirements", function() {
16-
assessor.assess( new Paper( "" ) );
17-
const AssessmentResults = assessor.getValidResults();
18-
const assessments = getResults( AssessmentResults );
19-
20-
expect( assessments ).toEqual( [
21-
"keyphraseLength",
22-
"metaDescriptionLength",
23-
"textLength",
24-
"titleWidth",
25-
] );
26-
} );
27-
28-
it( "additionally runs assessments that only require a text", function() {
29-
assessor.assess( new Paper( "text" ) );
30-
const AssessmentResults = assessor.getValidResults();
31-
const assessments = getResults( AssessmentResults );
32-
33-
expect( assessments ).toEqual( [
34-
"keyphraseLength",
35-
"metaDescriptionLength",
36-
"textImages",
37-
"textLength",
38-
"externalLinks",
39-
"internalLinks",
40-
"titleWidth",
41-
] );
42-
} );
43-
44-
it( "runs the same set of assessments if the text contains two H1s", function() {
45-
assessor.assess( new Paper( "<h1>First title</h1> text text <h1>Second title</h1>" ) );
46-
const AssessmentResults = assessor.getValidResults();
47-
const assessments = getResults( AssessmentResults );
48-
49-
expect( assessments ).toEqual( [
50-
"keyphraseLength",
51-
"metaDescriptionLength",
52-
"textImages",
53-
"textLength",
54-
"externalLinks",
55-
"internalLinks",
56-
"titleWidth",
57-
] );
58-
} );
59-
60-
it( "additionally runs assessments only require a text and a keyword", function() {
61-
assessor.assess( new Paper( "text", { keyword: "keyword" } ) );
62-
const AssessmentResults = assessor.getValidResults();
63-
const assessments = getResults( AssessmentResults );
64-
65-
expect( assessments ).toEqual( [
66-
"introductionKeyword",
67-
"keyphraseLength",
68-
"metaDescriptionLength",
69-
"textImages",
70-
"textLength",
71-
"externalLinks",
72-
"internalLinks",
73-
"titleWidth",
74-
] );
75-
} );
76-
77-
it( "additionally runs assessments that only require a keyword that contains function words only", function() {
78-
assessor.assess( new Paper( "", { keyword: "a" } ) );
79-
const AssessmentResults = assessor.getValidResults();
80-
const assessments = getResults( AssessmentResults );
81-
82-
expect( assessments ).toEqual( [
83-
"keyphraseLength",
84-
"metaDescriptionLength",
85-
"textLength",
86-
"titleWidth",
87-
"functionWordsInKeyphrase",
88-
] );
89-
} );
90-
91-
it( "additionally runs assessments that require text and a keyword", function() {
92-
assessor.assess( new Paper( "text", { keyword: "keyword" } ) );
93-
const AssessmentResults = assessor.getValidResults();
94-
const assessments = getResults( AssessmentResults );
95-
96-
expect( assessments ).toEqual( [
97-
"introductionKeyword",
98-
"keyphraseLength",
99-
"metaDescriptionLength",
100-
"textImages",
101-
"textLength",
102-
"externalLinks",
103-
"internalLinks",
104-
"titleWidth",
105-
] );
106-
} );
107-
108-
it( "additionally runs assessments that require a long enough text and a keyword and a synonym", function() {
109-
const text = "a ".repeat( 200 );
110-
assessor.assess( new Paper( text, { keyword: "keyword", synonyms: "synonym" } ) );
111-
const AssessmentResults = assessor.getValidResults();
112-
const assessments = getResults( AssessmentResults );
113-
114-
expect( assessments ).toEqual( [
115-
"introductionKeyword",
116-
"keyphraseLength",
117-
"keywordDensity",
118-
"metaDescriptionLength",
119-
"textImages",
120-
"textLength",
121-
"externalLinks",
122-
"internalLinks",
123-
"titleWidth",
124-
] );
125-
} );
126-
127-
it( "additionally runs assessments that require a text and a super-long url with stop words", function() {
128-
assessor.assess( new Paper( "text", { url: "a-sample-url-a-sample-url-a-sample-url-a-sample-url-a-sample-url-a-sample-url-a-sample-url-a-sample-url-a-sample-url" } ) );
129-
const AssessmentResults = assessor.getValidResults();
130-
const assessments = getResults( AssessmentResults );
131-
132-
expect( assessments ).toEqual( [
133-
"keyphraseLength",
134-
"metaDescriptionLength",
135-
"textImages",
136-
"textLength",
137-
"externalLinks",
138-
"internalLinks",
139-
"titleWidth",
140-
"urlLength",
141-
"urlStopWords",
142-
] );
143-
} );
144-
145-
it( "additionally runs assessments that require a text, a url and a keyword", function() {
146-
assessor.assess( new Paper( "text", { keyword: "keyword", url: "sample-url" } ) );
147-
const AssessmentResults = assessor.getValidResults();
148-
const assessments = getResults( AssessmentResults );
149-
150-
expect( assessments ).toEqual( [
151-
"introductionKeyword",
152-
"keyphraseLength",
153-
"metaDescriptionLength",
154-
"textImages",
155-
"textLength",
156-
"externalLinks",
157-
"internalLinks",
158-
"titleWidth",
159-
"urlKeyword",
160-
] );
161-
} );
162-
163-
// These specifications will additionally trigger the largest keyword distance assessment.
164-
it( "additionally runs assessments that require a long enough text and two keyword occurrences", function() {
165-
assessor.assess( new Paper( "This is a keyword and a keyword. Lorem ipsum dolor sit amet, vim illum aeque" +
166-
" constituam at. Id latine tritani alterum pro. Ei quod stet affert sed. Usu putent fabellas suavitate id." +
167-
" Quo ut stet recusabo torquatos. Eum ridens possim expetenda te. Ex per putant comprehensam. At vel utinam" +
168-
" cotidieque, at erat brute eum, velit percipit ius et. Has vidit accusata deterruisset ea, quod facete te" +
169-
" vis. Vix ei duis dolor, id eum sonet fabulas. Id vix imperdiet efficiantur. Percipit probatus pertinax te" +
170-
" sit. Putant intellegebat eu sit. Vix reque tation prompta id, ea quo labore viderer definiebas." +
171-
" Oratio vocibus offendit an mei, est esse pericula liberavisse. Lorem ipsum dolor sit amet, vim illum aeque" +
172-
" constituam at. Id latine tritani alterum pro. Ei quod stet affert sed. Usu putent fabellas suavitate id." +
173-
" Quo ut stet recusabo torquatos. Eum ridens possim expetenda te. Ex per putant comprehensam. At vel utinam" +
174-
" cotidieque, at erat brute eum, velit percipit ius et. Has vidit accusata deterruisset ea, quod facete te" +
175-
" vis. Vix ei duis dolor, id eum sonet fabulas. Id vix imperdiet efficiantur. Percipit probatus pertinax te" +
176-
" sit. Putant intellegebat eu sit. Vix reque tation prompta id, ea quo labore viderer definiebas." +
177-
" Oratio vocibus offendit an mei, est esse pericula liberavisse.", { keyword: "keyword" } ) );
178-
const AssessmentResults = assessor.getValidResults();
179-
const assessments = getResults( AssessmentResults );
180-
181-
expect( assessments ).toEqual( [
182-
"introductionKeyword",
183-
"keyphraseLength",
184-
"keywordDensity",
185-
"metaDescriptionLength",
186-
"textImages",
187-
"textLength",
188-
"externalLinks",
189-
"internalLinks",
190-
"titleWidth",
191-
] );
192-
} );
193-
194-
it( "additionally runs assessments that require a long enough text and one keyword occurrence and one synonym occurrence", function() {
195-
assessor.assess( new Paper( "This is a keyword. Lorem ipsum dolor sit amet, vim illum aeque" +
196-
" constituam at. Id latine tritani alterum pro. Ei quod stet affert sed. Usu putent fabellas suavitate id." +
197-
" Quo ut stet recusabo torquatos. Eum ridens possim expetenda te. Ex per putant comprehensam. At vel utinam" +
198-
" cotidieque, at erat brute eum, velit percipit ius et. Has vidit accusata deterruisset ea, quod facete te" +
199-
" vis. Vix ei duis dolor, id eum sonet fabulas. Id vix imperdiet efficiantur. Percipit probatus pertinax te" +
200-
" sit. Putant intellegebat eu sit. Vix reque tation prompta id, ea quo labore viderer definiebas." +
201-
" Oratio vocibus offendit an mei, est esse pericula liberavisse. Lorem ipsum dolor sit amet, vim illum aeque" +
202-
" constituam at. Id latine tritani alterum pro. Ei quod stet affert sed. Usu putent fabellas suavitate id." +
203-
" Quo ut stet recusabo torquatos. Eum ridens possim expetenda te. Ex per putant comprehensam. At vel utinam" +
204-
" cotidieque, at erat brute eum, velit percipit ius et. Has vidit accusata deterruisset ea, quod facete te" +
205-
" vis. Vix ei duis dolor, id eum sonet fabulas. Id vix imperdiet efficiantur. Percipit probatus pertinax te" +
206-
" sit. Putant intellegebat eu sit. Vix reque tation prompta id, ea quo labore viderer definiebas synonym." +
207-
" Oratio vocibus offendit an mei, est esse pericula liberavisse.", { keyword: "keyword", synonyms: "synonym" } ) );
208-
const AssessmentResults = assessor.getValidResults();
209-
const assessments = getResults( AssessmentResults );
210-
211-
expect( assessments ).toEqual( [
212-
"introductionKeyword",
213-
"keyphraseLength",
214-
"keywordDensity",
215-
"metaDescriptionLength",
216-
"textImages",
217-
"textLength",
218-
"externalLinks",
219-
"internalLinks",
220-
"titleWidth",
221-
] );
222-
} );
223-
} );
224-
225-
describe( "running assessments in the assessor for recalibration analysis", function() {
226-
let assessor;
227-
228-
beforeEach( () => {
229-
process.env.YOAST_RECALIBRATION = "enabled";
23011
assessor = new Assessor( i18n );
23112
} );
23213

@@ -276,7 +57,7 @@ describe( "running assessments in the assessor for recalibration analysis", func
27657
] );
27758
} );
27859

279-
it( "additionally runs assessments only require a text and a keyword", function() {
60+
it( "additionally runs assessments that only require a text and a keyword", function() {
28061
assessor.assess( new Paper( "text", { keyword: "keyword" } ) );
28162
const AssessmentResults = assessor.getValidResults();
28263
const assessments = getResults( AssessmentResults );

packages/yoastseo/spec/assessments/KeyphraseLengthAssessmentSpec.js

+1-95
Original file line numberDiff line numberDiff line change
@@ -3,100 +3,7 @@ import Paper from "../../src/values/Paper.js";
33
import factory from "../specHelpers/factory.js";
44
const i18n = factory.buildJed();
55

6-
describe( "the keyphrase length assessment in the regular analysis", function() {
7-
beforeEach( () => {
8-
process.env.YOAST_RECALIBRATION = "disabled";
9-
} );
10-
11-
it( "should assess a paper without a keyword as extremely bad", function() {
12-
const paper = new Paper();
13-
const researcher = factory.buildMockResearcher( 0 );
14-
15-
const result = new KeyphraseLengthAssessment().getResult( paper, researcher, i18n );
16-
17-
expect( result.getScore() ).toEqual( -999 );
18-
expect( result.getText() ).toEqual( "<a href='https://yoa.st/33i' target='_blank'>Keyphrase length</a>: " +
19-
"No focus keyphrase was set for this page. " +
20-
"<a href='https://yoa.st/33j' target='_blank'>Set a keyphrase in order to calculate your SEO score</a>." );
21-
} );
22-
23-
it( "should show a different feedback text when no keyphrase is set for a related keyphrase", function() {
24-
const paper = new Paper();
25-
const researcher = factory.buildMockResearcher( 0 );
26-
27-
const result = new KeyphraseLengthAssessment( { isRelatedKeyphrase: true } ).getResult( paper, researcher, i18n );
28-
29-
expect( result.getScore() ).toEqual( -999 );
30-
expect( result.getText() ).toEqual( "<a href='https://yoa.st/33i' target='_blank'>Keyphrase length</a>: " +
31-
"<a href='https://yoa.st/33j' target='_blank'>Set a keyphrase in order to calculate your SEO score</a>." );
32-
} );
33-
34-
it( "should assess a paper with a keyphrase that's too long as bad", function() {
35-
const paper = new Paper( "", { keyword: "keyword" } );
36-
const researcher = factory.buildMockResearcher( 11 );
37-
38-
const result = new KeyphraseLengthAssessment().getResult( paper, researcher, i18n );
39-
40-
expect( result.getScore() ).toEqual( 3 );
41-
expect( result.getText() ).toEqual( "<a href='https://yoa.st/33i' target='_blank'>Keyphrase length</a>: " +
42-
"The keyphrase is 11 words long. That's way more than the recommended maximum of 4 words. " +
43-
"<a href='https://yoa.st/33j' target='_blank'>Make it shorter</a>!" );
44-
} );
45-
46-
it( "should assess a paper with a keyphrase that's the correct length", function() {
47-
const paper = new Paper( "", { keyword: "keyword" } );
48-
const researcher = factory.buildMockResearcher( 3 );
49-
50-
const result = new KeyphraseLengthAssessment().getResult( paper, researcher, i18n );
51-
52-
expect( result.getScore() ).toEqual( 9 );
53-
expect( result.getText() ).toEqual( "<a href='https://yoa.st/33i' target='_blank'>Keyphrase length</a>: Good job!" );
54-
} );
55-
56-
it( "should assess a paper with a keyphrase that's a little longer than the correct length", function() {
57-
const paper = new Paper( "", { keyword: "keyword keyword keyword keyword keyword" } );
58-
const researcher = factory.buildMockResearcher( 5 );
59-
60-
const result = new KeyphraseLengthAssessment().getResult( paper, researcher, i18n );
61-
62-
expect( result.getScore() ).toEqual( 6 );
63-
expect( result.getText() ).toEqual( "<a href='https://yoa.st/33i' target='_blank'>Keyphrase length</a>: " +
64-
"The keyphrase is 5 words long. That's more than the recommended maximum of 4 words. " +
65-
"<a href='https://yoa.st/33j' target='_blank'>Make it shorter</a>!" );
66-
} );
67-
68-
// These tests check whether recalibration-specific changes don't affect the regular analysis.
69-
it( "should assess a paper with an 6-word keyphrase as okay for a language that doesn't support function words", function() {
70-
const paper = new Paper( "", { keyword: "1 2 3 4 5 6", locale: "xx_XX" } );
71-
const researcher = factory.buildMockResearcher( 6 );
72-
73-
const result = new KeyphraseLengthAssessment().getResult( paper, researcher, i18n );
74-
75-
expect( result.getScore() ).toEqual( 6 );
76-
expect( result.getText() ).toEqual( "<a href='https://yoa.st/33i' target='_blank'>Keyphrase length</a>: " +
77-
"The keyphrase is 6 words long. That's more than the recommended maximum of 4 words. " +
78-
"<a href='https://yoa.st/33j' target='_blank'>Make it shorter</a>!" );
79-
} );
80-
81-
it( "should assess a paper with an 9-word keyphrase as bad for a language that doesn't support function words", function() {
82-
const paper = new Paper( "", { keyword: "1 2 3 4 5 6 7 8 9", locale: "xx_XX" } );
83-
const researcher = factory.buildMockResearcher( 9 );
84-
85-
const result = new KeyphraseLengthAssessment().getResult( paper, researcher, i18n );
86-
87-
expect( result.getScore() ).toEqual( 3 );
88-
expect( result.getText() ).toEqual( "<a href='https://yoa.st/33i' target='_blank'>Keyphrase length</a>: " +
89-
"The keyphrase is 9 words long. That's way more than the recommended maximum of 4 words. " +
90-
"<a href='https://yoa.st/33j' target='_blank'>Make it shorter</a>!" );
91-
} );
92-
} );
93-
94-
describe( "the keyphrase length assessment in the recalibrated analysis", function() {
95-
beforeEach( () => {
96-
process.env.YOAST_RECALIBRATION = "enabled";
97-
} );
98-
99-
// These tests are the same as in the regular analysis.
6+
describe( "the keyphrase length assessment", function() {
1007
it( "should assess a paper without a keyword as extremely bad", function() {
1018
const paper = new Paper();
1029
const researcher = factory.buildMockResearcher( 0 );
@@ -154,7 +61,6 @@ describe( "the keyphrase length assessment in the recalibrated analysis", functi
15461
"<a href='https://yoa.st/33j' target='_blank'>Make it shorter</a>!" );
15562
} );
15663

157-
// These are the recalibration-specific tests.
15864
it( "should assess a paper with an 6-word keyphrase as good for a language that doesn't support function words", function() {
15965
const paper = new Paper( "", { keyword: "1 2 3 4 5 6", locale: "xx_XX" } );
16066
const researcher = factory.buildMockResearcher( 6 );

0 commit comments

Comments
 (0)