Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
fix(w3c): allow TAG to show W3C logo (speced#4000)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres authored Feb 1, 2022
1 parent cad135d commit 36c93d7
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/w3c/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
cgbgStatus,
recTrackStatus,
registryTrackStatus,
tagStatus,
} from "./headers.js";
import { codedJoinOr, docLink, showError, showWarning } from "../core/utils.js";
import { coreDefaults } from "../core/defaults.js";
Expand Down Expand Up @@ -67,8 +68,8 @@ export function run(conf) {
conf.license = "w3c-software-doc";
}

processLogos(conf);
validateStatusForGroup(conf);
processLogos(conf);
}

function processLogos(conf) {
Expand All @@ -78,7 +79,12 @@ function processLogos(conf) {
// Excludes "ED" status
if (
conf.wg?.length &&
[...recTrackStatus, ...registryTrackStatus, ...W3CNotes].includes(status)
[
...recTrackStatus,
...registryTrackStatus,
...W3CNotes,
...tagStatus,
].includes(status)
) {
conf.logos?.unshift(w3cLogo);
}
Expand All @@ -91,7 +97,7 @@ function processLogos(conf) {
}

function validateStatusForGroup(conf) {
const { specStatus, groupType } = conf;
const { specStatus, groupType, group } = conf;
switch (groupType) {
case "cg": {
if (![...cgbgStatus, "unofficial"].includes(specStatus)) {
Expand All @@ -114,13 +120,22 @@ function validateStatusForGroup(conf) {
break;
}
case "wg": {
if (cgbgStatus.includes(specStatus)) {
if ([...tagStatus, ...cgbgStatus].includes(specStatus)) {
const msg = docLink`W3C Working Group documents can't use \`"${specStatus}"\` for the ${"[specStatus]"} configuration option.`;
const hint = docLink`Please see ${"[specStatus]"} for appropriate status for W3C Working Group documents.`;
showError(msg, name, { hint });
}
break;
}
case "other":
if (group === "tag" && !tagStatus.includes(specStatus)) {
const msg = docLink`The W3C Technical Architecture Group's documents can't use \`"${specStatus}"\` for the ${"[specStatus]"} configuration option.`;
const supportedStatus = codedJoinOr(tagStatus, { quotes: true });
const hint = `Please use one of: ${supportedStatus}. Automatically falling back to \`"unofficial"\`.`;
showError(msg, name, { hint });
conf.specStatus = "unofficial";
}
break;
default:
if (
!conf.wgId &&
Expand Down
1 change: 1 addition & 0 deletions src/w3c/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export const recTrackStatus = [
"RSCND",
];
export const registryTrackStatus = ["DRY", "CRY", "CRYD", "RY"];
export const tagStatus = ["draft-finding", "finding", "editor-draft-finding"];
export const cgStatus = ["CG-DRAFT", "CG-FINAL"];
export const bgStatus = ["BG-DRAFT", "BG-FINAL"];
export const cgbgStatus = [...cgStatus, ...bgStatus];
Expand Down
24 changes: 24 additions & 0 deletions tests/spec/w3c/defaults-spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use strict";

import { cgbgStatus, tagStatus } from "../../../src/w3c/headers.js";

import {
flushIframes,
makeDefaultBody,
Expand Down Expand Up @@ -105,6 +107,28 @@ describe("W3C — Defaults", () => {
expect(doc.querySelector("img[alt='W3C']")).not.toBeNull();
});

it("allows W3C TAG to show logos", async () => {
for (const specStatus of tagStatus) {
const ops = makeStandardOps({
specStatus,
group: "tag",
});
const doc = await makeRSDoc(ops);
expect(doc.querySelector("img[alt='W3C']")).not.toBeNull();
}
});

it("doesn't allow the W3C TAG to show logo when status is from another group type", async () => {
for (const specStatus of cgbgStatus) {
const ops = makeStandardOps({
specStatus,
group: "tag",
});
const doc = await makeRSDoc(ops);
expect(doc.querySelector("img[alt='W3C']")).toBeNull();
}
});

it("warns when using a W3C specStatus, but no group is configured and defaults to 'base'", async () => {
const warningFilter = warningFilters.filter("w3c/defaults");
const ops = makeStandardOps({ specStatus: "WD" });
Expand Down

0 comments on commit 36c93d7

Please sign in to comment.