@@ -16,9 +16,11 @@ import {
1616 makeDefaultBody ,
1717 makeRSDoc ,
1818 makeStandardOps ,
19+ warningFilters ,
1920} from "../SpecHelper.js" ;
2021
2122const headerErrors = errorFilters . filter ( "w3c/headers" ) ;
23+ const headerWarnings = warningFilters . filter ( "w3c/headers" ) ;
2224const defaultErrors = errorFilters . filter ( "w3c/defaults" ) ;
2325
2426const findContent = string => {
@@ -62,26 +64,27 @@ describe("W3C — Headers", () => {
6264 expect ( exportedDoc . querySelector ( ".head details[open]" ) ) . toBeTruthy ( ) ;
6365 } ) ;
6466
65- it ( "links to the 'kinds of documents' only for W3C documents" , async ( ) => {
66- const statuses = [ "FPWD" , "WD" , "CR" , "CRD" , "PR" , "REC" , "NOTE" ] ;
67- for ( const specStatus of statuses ) {
67+ for ( const specStatus of recTrackStatus ) {
68+ it ( `links to the 'kinds of documents' only for W3C documents with status ${ specStatus } ` , async ( ) => {
6869 const doc = await makeRSDoc (
6970 makeStandardOps ( { specStatus, group : "webapps" } )
7071 ) ;
7172 const w3cLink = doc . querySelector (
7273 `.head a[href='https://www.w3.org/standards/types#${ specStatus } ']`
7374 ) ;
74- expect ( w3cLink ) . withContext ( `specStatus: ${ specStatus } ` ) . toBeTruthy ( ) ;
75- }
75+ expect ( w3cLink ) . toBeTruthy ( ) ;
76+ } ) ;
77+ }
7678
77- for ( const specStatus of [ "unofficial" , "base" ] ) {
79+ for ( const specStatus of noTrackStatus ) {
80+ it ( `doesn't link to the 'kinds of documents' for non-rec track ${ specStatus } ` , async ( ) => {
7881 const doc = await makeRSDoc ( makeStandardOps ( { specStatus } ) ) ;
7982 const w3cLink = doc . querySelector (
8083 ".head a[href='https://www.w3.org/standards/types#UD']"
8184 ) ;
82- expect ( w3cLink ) . withContext ( `specStatus: ${ specStatus } ` ) . toBeNull ( ) ;
83- }
84- } ) ;
85+ expect ( w3cLink ) . toBeNull ( ) ;
86+ } ) ;
87+ }
8588
8689 describe ( "prevRecShortname & prevRecURI" , ( ) => {
8790 it ( "takes prevRecShortname and prevRecURI into account" , async ( ) => {
@@ -1437,6 +1440,21 @@ describe("W3C — Headers", () => {
14371440 expect ( latestVersionLink . textContent ) . toBe ( "https://www.w3.org/TR/foo/" ) ;
14381441 } ) ;
14391442
1443+ it ( "warns if latestVersion URL doesn't exist" , async ( ) => {
1444+ const ops = makeStandardOps ( {
1445+ shortName : "foo" ,
1446+ specStatus : "WD" ,
1447+ group : "webapps" ,
1448+ github : "w3c/respec" ,
1449+ } ) ;
1450+ const doc = await makeRSDoc ( ops ) ;
1451+ const warnings = headerWarnings ( doc ) ;
1452+ expect ( warnings ) . toHaveSize ( 1 ) ;
1453+ expect ( warnings [ 0 ] . message ) . toContain (
1454+ `The "Latest published version:" header link points to a URL that does not exist`
1455+ ) ;
1456+ } ) ;
1457+
14401458 it ( "allows skipping latest published version link in initial ED" , async ( ) => {
14411459 const ops = makeStandardOps ( {
14421460 specStatus : "ED" ,
@@ -1543,19 +1561,15 @@ describe("W3C — Headers", () => {
15431561 ) ;
15441562 } ) ;
15451563
1546- for ( const specStatus of cgbgStatus . filter ( s => s . endsWith ( "-DRAFT" ) ) ) {
1564+ for ( const specStatus of cgStatus . filter ( s => s . endsWith ( "-DRAFT" ) ) ) {
15471565 it ( `doesn't set latestVersion URL for ${ specStatus } status` , async ( ) => {
15481566 const ops = makeStandardOps ( {
15491567 shortName : "some-report" ,
15501568 specStatus,
15511569 group : "wicg" ,
15521570 } ) ;
15531571 const doc = await makeRSDoc ( ops ) ;
1554- const terms = [ ...doc . querySelectorAll ( ".head dt" ) ] ;
1555- const latestVersion = terms . find (
1556- el => el . textContent . trim ( ) === "Latest published version:"
1557- ) ;
1558- expect ( latestVersion ) . toHaveSize ( 0 ) ;
1572+ expect ( contains ( doc , "dt" , "Latest published version:" ) ) . toHaveSize ( 0 ) ;
15591573 } ) ;
15601574 }
15611575 for ( const specStatus of noTrackStatus ) {
@@ -1989,7 +2003,7 @@ describe("W3C — Headers", () => {
19892003 { specStatus : "BG-FINAL" , group : "publishingbg" } ,
19902004 ] ;
19912005 for ( const { specStatus, group } of finalReportStatus ) {
1992- it ( " requires that the ${specStatus} latestVersion be a w3c URL" , async ( ) => {
2006+ it ( ` requires that the ${ specStatus } latestVersion be a w3c URL` , async ( ) => {
19932007 const ops = makeStandardOps ( {
19942008 specStatus,
19952009 group,
@@ -2550,6 +2564,7 @@ describe("W3C — Headers", () => {
25502564 const ops = makeStandardOps ( {
25512565 shortName : "payment-request" ,
25522566 specStatus : "ED" ,
2567+ group : "payments" ,
25532568 } ) ;
25542569 const doc = await makeRSDoc ( ops ) ;
25552570 const [ history ] = contains ( doc , ".head dt" , "History:" ) ;
@@ -2562,8 +2577,8 @@ describe("W3C — Headers", () => {
25622577 ) ;
25632578 } ) ;
25642579
2565- for ( const specStatus of trStatus ) {
2566- it ( `includes the history for "${ specStatus } " rec-track status ` , async ( ) => {
2580+ for ( const specStatus of recTrackStatus ) {
2581+ it ( `includes the history for rec-track "${ specStatus } " docs ` , async ( ) => {
25672582 const shortName = `push-api` ;
25682583 const ops = makeStandardOps ( {
25692584 shortName,
@@ -2575,9 +2590,9 @@ describe("W3C — Headers", () => {
25752590 expect ( history ) . withContext ( specStatus ) . toBeTruthy ( ) ;
25762591 expect ( history . nextElementSibling ) . withContext ( specStatus ) . toBeTruthy ( ) ;
25772592 const historyLink = history . nextElementSibling . querySelector ( "a" ) ;
2578- expect ( historyLink ) . toBeTruthy ( ) ;
2593+ expect ( historyLink ) . withContext ( specStatus ) . toBeTruthy ( ) ;
25792594 expect ( historyLink . href ) . toBe (
2580- `https://www.w3.org/standards/history/${ shortName } / `
2595+ `https://www.w3.org/standards/history/${ shortName } `
25812596 ) ;
25822597 } ) ;
25832598 }
0 commit comments