-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
import type { Locator, Page } from '@playwright/test'; | ||
import { expect } from '@playwright/test'; | ||
|
||
export default class CookieHelper { | ||
private readonly page: Page; | ||
consentBar: Locator; | ||
acceptButton: any; | ||
private readonly _page: Page; | ||
private _consentBar: Locator; | ||
private _acceptButton: Locator; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
this.consentBar = this.page.getByRole('region', { name: 'Cookie Consent' }); | ||
this.acceptButton = this.consentBar.getByRole('button', { name: 'Accept' }); | ||
public constructor(page: Page) { | ||
this._page = page; | ||
this._consentBar = this._page.getByRole('region', { | ||
name: 'Cookie Consent', | ||
}); | ||
this._acceptButton = this._consentBar.getByRole('button', { | ||
name: 'Accept', | ||
}); | ||
} | ||
|
||
async acceptCookies() { | ||
await this.acceptButton.click(); | ||
public async acceptCookies(): Promise<void> { | ||
await this._acceptButton.click(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,36 @@ | ||
const parseMD = require('parse-md').default; | ||
import fs from 'fs'; | ||
|
||
|
||
|
||
|
||
export async function extractMetadataFromMarkdown( | ||
parentPath: string, | ||
childPath?: string, | ||
grandChildPath?: string, | ||
): Promise<Metadata[]> { | ||
const metadata: Metadata[] = []; | ||
|
||
|
||
const parentFile = fs.readFileSync(parentPath, 'utf8'); | ||
const parent = parseMD(parentFile); | ||
metadata.push(parent.metadata); | ||
|
||
if (childPath) { | ||
const childFile = fs.readFileSync(childPath, 'utf8'); | ||
const child = parseMD(childFile); | ||
metadata.push(child.metadata); | ||
} | ||
|
||
if (grandChildPath) { | ||
const grandChildFile = fs.readFileSync(grandChildPath, 'utf8'); | ||
const grandChild = parseMD(grandChildFile); | ||
metadata.push(grandChild.metadata); | ||
} | ||
return metadata | ||
export async function extractMetadataFromMarkdown( | ||
parentPath: string, | ||
childPath?: string, | ||
grandChildPath?: string, | ||
): Promise<Metadata[]> { | ||
const metadata: Metadata[] = []; | ||
|
||
const parentFile = fs.readFileSync(parentPath, 'utf8'); | ||
const parent = parseMD(parentFile); | ||
metadata.push(parent.metadata); | ||
|
||
if (childPath) { | ||
const childFile = fs.readFileSync(childPath, 'utf8'); | ||
const child = parseMD(childFile); | ||
metadata.push(child.metadata); | ||
} | ||
|
||
if (grandChildPath) { | ||
const grandChildFile = fs.readFileSync(grandChildPath, 'utf8'); | ||
const grandChild = parseMD(grandChildFile); | ||
metadata.push(grandChild.metadata); | ||
} | ||
return metadata; | ||
} | ||
|
||
|
||
|
||
export type Metadata = { | ||
export interface Metadata { | ||
title: string; | ||
description: string; | ||
menu: string; | ||
label: string; | ||
order: number; | ||
layout: 'full'; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
import { test } from '@playwright/test'; | ||
Check failure on line 1 in packages/apps/docs/src/tests/page-crawler.spec.ts GitHub Actions / Build & unit test[docs] › ../page-crawler.spec.ts:15:7 › Page: kadena - All Markdown files should be present in the menu
Check failure on line 1 in packages/apps/docs/src/tests/page-crawler.spec.ts GitHub Actions / Build & unit test[docs] › ../page-crawler.spec.ts:15:7 › Page: kadena - All Markdown files should be present in the menu
Check failure on line 1 in packages/apps/docs/src/tests/page-crawler.spec.ts GitHub Actions / Build & unit test[docs] › ../page-crawler.spec.ts:15:7 › Page: build - All Markdown files should be present in the menu
Check failure on line 1 in packages/apps/docs/src/tests/page-crawler.spec.ts GitHub Actions / Build & unit test[docs] › ../page-crawler.spec.ts:15:7 › Page: build - All Markdown files should be present in the menu
Check failure on line 1 in packages/apps/docs/src/tests/page-crawler.spec.ts GitHub Actions / Build & unit test[docs] › ../page-crawler.spec.ts:15:7 › Page: pact - All Markdown files should be present in the menu
Check failure on line 1 in packages/apps/docs/src/tests/page-crawler.spec.ts GitHub Actions / Build & unit test[docs] › ../page-crawler.spec.ts:15:7 › Page: pact - All Markdown files should be present in the menu
Check failure on line 1 in packages/apps/docs/src/tests/page-crawler.spec.ts GitHub Actions / Build & unit test[docs] › ../page-crawler.spec.ts:15:7 › Page: chainweb - All Markdown files should be present in the menu
Check failure on line 1 in packages/apps/docs/src/tests/page-crawler.spec.ts GitHub Actions / Build & unit test[docs] › ../page-crawler.spec.ts:15:7 › Page: chainweb - All Markdown files should be present in the menu
Check failure on line 1 in packages/apps/docs/src/tests/page-crawler.spec.ts GitHub Actions / Build & unit test[docs] › ../page-crawler.spec.ts:15:7 › Page: marmalade - All Markdown files should be present in the menu
|
||
import TreeHelper from './helpers/tree.helper'; | ||
import CookieHelper from './helpers/cookie.helper'; | ||
import TreeHelper from './helpers/tree.helper'; | ||
|
||
|
||
const pages = ['kadena', 'build', 'pact', 'chainweb', 'marmalade', 'contribute']; | ||
const pages = [ | ||
'kadena', | ||
'build', | ||
'pact', | ||
'chainweb', | ||
'marmalade', | ||
'contribute', | ||
]; | ||
|
||
for (const pageToCheck of pages) { | ||
test(`Page: ${pageToCheck} - All Markdown files should be present in the menu`, async ({ page }) => { | ||
const treeHelper = new TreeHelper(page) | ||
const cookieHelper = new CookieHelper(page) | ||
test(`Page: ${pageToCheck} - All Markdown files should be present in the menu`, async ({ | ||
page, | ||
}) => { | ||
const treeHelper = new TreeHelper(page); | ||
const cookieHelper = new CookieHelper(page); | ||
|
||
await page.goto(pageToCheck); | ||
await cookieHelper.acceptCookies(); | ||
await treeHelper.validateTree(pageToCheck) | ||
}); | ||
await treeHelper.validateTree(pageToCheck); | ||
}); | ||
} |