@@ -16,9 +16,11 @@ import {
16
16
makeDefaultBody ,
17
17
makeRSDoc ,
18
18
makeStandardOps ,
19
+ warningFilters ,
19
20
} from "../SpecHelper.js" ;
20
21
21
22
const headerErrors = errorFilters . filter ( "w3c/headers" ) ;
23
+ const headerWarnings = warningFilters . filter ( "w3c/headers" ) ;
22
24
const defaultErrors = errorFilters . filter ( "w3c/defaults" ) ;
23
25
24
26
const findContent = string => {
@@ -62,26 +64,27 @@ describe("W3C — Headers", () => {
62
64
expect ( exportedDoc . querySelector ( ".head details[open]" ) ) . toBeTruthy ( ) ;
63
65
} ) ;
64
66
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 ( ) => {
68
69
const doc = await makeRSDoc (
69
70
makeStandardOps ( { specStatus, group : "webapps" } )
70
71
) ;
71
72
const w3cLink = doc . querySelector (
72
73
`.head a[href='https://www.w3.org/standards/types#${ specStatus } ']`
73
74
) ;
74
- expect ( w3cLink ) . withContext ( `specStatus: ${ specStatus } ` ) . toBeTruthy ( ) ;
75
- }
75
+ expect ( w3cLink ) . toBeTruthy ( ) ;
76
+ } ) ;
77
+ }
76
78
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 ( ) => {
78
81
const doc = await makeRSDoc ( makeStandardOps ( { specStatus } ) ) ;
79
82
const w3cLink = doc . querySelector (
80
83
".head a[href='https://www.w3.org/standards/types#UD']"
81
84
) ;
82
- expect ( w3cLink ) . withContext ( `specStatus: ${ specStatus } ` ) . toBeNull ( ) ;
83
- }
84
- } ) ;
85
+ expect ( w3cLink ) . toBeNull ( ) ;
86
+ } ) ;
87
+ }
85
88
86
89
describe ( "prevRecShortname & prevRecURI" , ( ) => {
87
90
it ( "takes prevRecShortname and prevRecURI into account" , async ( ) => {
@@ -1437,6 +1440,21 @@ describe("W3C — Headers", () => {
1437
1440
expect ( latestVersionLink . textContent ) . toBe ( "https://www.w3.org/TR/foo/" ) ;
1438
1441
} ) ;
1439
1442
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
+
1440
1458
it ( "allows skipping latest published version link in initial ED" , async ( ) => {
1441
1459
const ops = makeStandardOps ( {
1442
1460
specStatus : "ED" ,
@@ -1543,19 +1561,15 @@ describe("W3C — Headers", () => {
1543
1561
) ;
1544
1562
} ) ;
1545
1563
1546
- for ( const specStatus of cgbgStatus . filter ( s => s . endsWith ( "-DRAFT" ) ) ) {
1564
+ for ( const specStatus of cgStatus . filter ( s => s . endsWith ( "-DRAFT" ) ) ) {
1547
1565
it ( `doesn't set latestVersion URL for ${ specStatus } status` , async ( ) => {
1548
1566
const ops = makeStandardOps ( {
1549
1567
shortName : "some-report" ,
1550
1568
specStatus,
1551
1569
group : "wicg" ,
1552
1570
} ) ;
1553
1571
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 ) ;
1559
1573
} ) ;
1560
1574
}
1561
1575
for ( const specStatus of noTrackStatus ) {
@@ -1989,7 +2003,7 @@ describe("W3C — Headers", () => {
1989
2003
{ specStatus : "BG-FINAL" , group : "publishingbg" } ,
1990
2004
] ;
1991
2005
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 ( ) => {
1993
2007
const ops = makeStandardOps ( {
1994
2008
specStatus,
1995
2009
group,
@@ -2550,6 +2564,7 @@ describe("W3C — Headers", () => {
2550
2564
const ops = makeStandardOps ( {
2551
2565
shortName : "payment-request" ,
2552
2566
specStatus : "ED" ,
2567
+ group : "payments" ,
2553
2568
} ) ;
2554
2569
const doc = await makeRSDoc ( ops ) ;
2555
2570
const [ history ] = contains ( doc , ".head dt" , "History:" ) ;
@@ -2562,8 +2577,8 @@ describe("W3C — Headers", () => {
2562
2577
) ;
2563
2578
} ) ;
2564
2579
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 ( ) => {
2567
2582
const shortName = `push-api` ;
2568
2583
const ops = makeStandardOps ( {
2569
2584
shortName,
@@ -2575,9 +2590,9 @@ describe("W3C — Headers", () => {
2575
2590
expect ( history ) . withContext ( specStatus ) . toBeTruthy ( ) ;
2576
2591
expect ( history . nextElementSibling ) . withContext ( specStatus ) . toBeTruthy ( ) ;
2577
2592
const historyLink = history . nextElementSibling . querySelector ( "a" ) ;
2578
- expect ( historyLink ) . toBeTruthy ( ) ;
2593
+ expect ( historyLink ) . withContext ( specStatus ) . toBeTruthy ( ) ;
2579
2594
expect ( historyLink . href ) . toBe (
2580
- `https://www.w3.org/standards/history/${ shortName } / `
2595
+ `https://www.w3.org/standards/history/${ shortName } `
2581
2596
) ;
2582
2597
} ) ;
2583
2598
}
0 commit comments