Path: blob/main/tests/smoke/website/draft-utils.ts
12921 views
/*1* drafts.test.ts2*3* Copyright (C) 2020-2022 Posit Software, PBC4*5*/6import { join } from "../../../src/deno_ral/path.ts";7import { ensureFileRegexMatches, ensureHtmlElementContents, ensureHtmlElements } from "../../verify.ts";8910// Specialized verifiers for this test11export const draftPostHasContent = (siteDir: string) => {12return ensureFileRegexMatches(join(siteDir, "posts/draft-post/index.html"), [/DRAFT DOCUMENT/gm])13}1415export const draftPostIsEmpty = (siteDir: string) => {16return ensureFileRegexMatches(join(siteDir, "posts/draft-post/index.html"), [], [/DRAFT DOCUMENT/gm]);17}1819export const doesntHaveContentLinksToDrafts = (siteDir: string) => {20return ensureHtmlElements(join(siteDir, "index.html"), [], ["#draft-doc-link"])21}2223export const hasContentLinksToDrafts = (siteDir: string) => {24return ensureHtmlElements(join(siteDir, "index.html"), ["#draft-doc-link"], [])25}2627export const hasEnvelopeLinksToDrafts = (siteDir: string) => {28return ensureHtmlElementContents(join(siteDir, "index.html"), { selectors: ["#quarto-sidebar", "#quarto-header", ".quarto-listing-default"], matches: ["Draft!!"], noMatches: [] });29}3031export const doesntHaveEnvelopeLinksToDrafts = (siteDir: string) => {32return ensureHtmlElementContents(join(siteDir, "index.html"), { selectors: ["#quarto-sidebar", "#quarto-header", ".quarto-listing-default"], matches: [], noMatches: ["Draft!!"] });33}3435export const siteMapHasDraft = (siteDir: string) => {36return ensureFileRegexMatches(join(siteDir, "sitemap.xml"), [/posts\/draft-post\/index\.html/gm])37}3839export const siteMapDoesntHaveDraft = (siteDir: string) => {40return ensureFileRegexMatches(join(siteDir, "sitemap.xml"), [], [/posts\/draft-post\/index\.html/gm]);41}4243export const searchHasDraft = (siteDir: string) => {44return ensureFileRegexMatches(join(siteDir, "search.json"), [/posts\/draft-post\/index\.html/gm])45}4647export const searchDoesntHaveDraft = (siteDir: string) => {48return ensureFileRegexMatches(join(siteDir, "search.json"), [], [/posts\/draft-post\/index\.html/gm]);49}5051