Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/tests/smoke/website/draft-utils.ts
12925 views
1
/*
2
* drafts.test.ts
3
*
4
* Copyright (C) 2020-2022 Posit Software, PBC
5
*
6
*/
7
import { join } from "../../../src/deno_ral/path.ts";
8
import { ensureFileRegexMatches, ensureHtmlElementContents, ensureHtmlElements } from "../../verify.ts";
9
10
11
// Specialized verifiers for this test
12
export const draftPostHasContent = (siteDir: string) => {
13
return ensureFileRegexMatches(join(siteDir, "posts/draft-post/index.html"), [/DRAFT DOCUMENT/gm])
14
}
15
16
export const draftPostIsEmpty = (siteDir: string) => {
17
return ensureFileRegexMatches(join(siteDir, "posts/draft-post/index.html"), [], [/DRAFT DOCUMENT/gm]);
18
}
19
20
export const doesntHaveContentLinksToDrafts = (siteDir: string) => {
21
return ensureHtmlElements(join(siteDir, "index.html"), [], ["#draft-doc-link"])
22
}
23
24
export const hasContentLinksToDrafts = (siteDir: string) => {
25
return ensureHtmlElements(join(siteDir, "index.html"), ["#draft-doc-link"], [])
26
}
27
28
export const hasEnvelopeLinksToDrafts = (siteDir: string) => {
29
return ensureHtmlElementContents(join(siteDir, "index.html"), { selectors: ["#quarto-sidebar", "#quarto-header", ".quarto-listing-default"], matches: ["Draft!!"], noMatches: [] });
30
}
31
32
export const doesntHaveEnvelopeLinksToDrafts = (siteDir: string) => {
33
return ensureHtmlElementContents(join(siteDir, "index.html"), { selectors: ["#quarto-sidebar", "#quarto-header", ".quarto-listing-default"], matches: [], noMatches: ["Draft!!"] });
34
}
35
36
export const siteMapHasDraft = (siteDir: string) => {
37
return ensureFileRegexMatches(join(siteDir, "sitemap.xml"), [/posts\/draft-post\/index\.html/gm])
38
}
39
40
export const siteMapDoesntHaveDraft = (siteDir: string) => {
41
return ensureFileRegexMatches(join(siteDir, "sitemap.xml"), [], [/posts\/draft-post\/index\.html/gm]);
42
}
43
44
export const searchHasDraft = (siteDir: string) => {
45
return ensureFileRegexMatches(join(siteDir, "search.json"), [/posts\/draft-post\/index\.html/gm])
46
}
47
48
export const searchDoesntHaveDraft = (siteDir: string) => {
49
return ensureFileRegexMatches(join(siteDir, "search.json"), [], [/posts\/draft-post\/index\.html/gm]);
50
}
51