Skip to content

Commit ac7e919

Browse files
committed
test message
1 parent fe61b56 commit ac7e919

5 files changed

Lines changed: 351 additions & 1 deletion

File tree

playwright-report/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tests/check_cli_page.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
const { chromium } = require('@playwright/test');
2+
3+
async function checkCliPage() {
4+
const browser = await chromium.launch();
5+
const page = await browser.newPage();
6+
7+
try {
8+
await page.goto('https://console-table.netlify.app/docs/doc-cli-install-quick-start');
9+
10+
// Wait for the page to load
11+
await page.waitForLoadState('networkidle');
12+
13+
// Get the page title
14+
const title = await page.title();
15+
console.log('Page title:', title);
16+
17+
// Check for h1 elements
18+
const h1Elements = await page.locator('h1').all();
19+
console.log('Number of h1 elements:', h1Elements.length);
20+
21+
for (const h1 of h1Elements) {
22+
const text = await h1.textContent();
23+
console.log('H1 text:', text);
24+
}
25+
26+
// Check for the specific heading we're looking for
27+
const pageHeading = await page.locator('h1').first();
28+
if (pageHeading) {
29+
const headingText = await pageHeading.textContent();
30+
console.log('First h1 text:', headingText);
31+
}
32+
33+
// Get all visible headings
34+
const headings = await page.locator('h1, h2, h3').all();
35+
console.log('\nAll headings:');
36+
for (const heading of headings) {
37+
const text = await heading.textContent();
38+
const tag = await heading.evaluate(node => node.tagName.toLowerCase());
39+
console.log(`${tag}: ${text}`);
40+
}
41+
} catch (error) {
42+
console.error('Error:', error);
43+
} finally {
44+
await browser.close();
45+
}
46+
}
47+
48+
checkCliPage();
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
const { test, expect } = require('@playwright/test');
2+
3+
test.describe('Direct URL Access Tests', () => {
4+
const pages = [
5+
{
6+
url: "/docs/",
7+
title: "Install and Quick start",
8+
headlines: ["Installation", "Basic Example"]
9+
},
10+
{
11+
url: "/docs/doc-table-instance-creation",
12+
title: "Create Table Instance",
13+
headlines: ["Table instance creation", "Functions of table instance"]
14+
},
15+
{
16+
url: "/docs/doc-adding-rows",
17+
title: "Adding Rows",
18+
headlines: ["One row at a time", "Batch Row Adding"]
19+
},
20+
{
21+
url: "/docs/doc-row-divider",
22+
title: "Row Dividers",
23+
headlines: ["Basic Row Divider", "Multiple Sections"]
24+
},
25+
{
26+
url: "/docs/doc-color",
27+
title: "Coloring",
28+
headlines: ["Custom Color"]
29+
},
30+
{
31+
url: "/docs/doc-sort-filter",
32+
title: "Sort and Filter",
33+
headlines: ["Filter", "Advanced Sorting"]
34+
},
35+
{
36+
url: "/docs/doc-alignment",
37+
title: "Alignment",
38+
headlines: []
39+
},
40+
{
41+
url: "/docs/doc-enable-disable-col",
42+
title: "Enable and Disable Columns",
43+
headlines: ["Enable", "Disable"]
44+
},
45+
{
46+
url: "/docs/doc-computed-function",
47+
title: "Calculated Columns",
48+
headlines: ["Using All Parameters", "Advanced Examples"]
49+
},
50+
{
51+
url: "/docs/doc-emojis-special-chars",
52+
title: "Special Chars and emojis",
53+
headlines: ["Special chars", "Newlines in cells"]
54+
},
55+
{
56+
url: "/docs/doc-typescript",
57+
title: "Typescript",
58+
headlines: []
59+
},
60+
{
61+
url: "/docs/doc-cli-install-quick-start",
62+
title: "CLI Quick Start",
63+
headlines: ["Installation", "Basic Example"]
64+
}
65+
];
66+
67+
for (const pageInfo of pages) {
68+
test(`Direct access to ${pageInfo.title} page works correctly`, async ({ page }) => {
69+
// Navigate directly to the URL
70+
await page.goto(pageInfo.url);
71+
72+
// Check that the page title is in the h1 heading or somewhere on the page
73+
if (pageInfo.title === "CLI Quick Start") {
74+
// Special case for CLI Quick Start page - it has "Quick Start" as the h1
75+
await expect(page.locator('h1:has-text("Quick Start")')).toBeVisible();
76+
} else {
77+
await expect(page.locator(`h1:has-text("${pageInfo.title}")`)).toBeVisible();
78+
}
79+
80+
// Check each headline by looking for heading elements containing the text
81+
for (const headline of pageInfo.headlines) {
82+
// Use a more specific selector for each headline
83+
await page.waitForSelector(`h2:has-text("${headline}"), h3:has-text("${headline}"), h4:has-text("${headline}")`, { state: 'visible' });
84+
}
85+
86+
// Special check for Special Chars and emojis page
87+
if (pageInfo.title === "Special Chars and emojis") {
88+
// Verify code examples
89+
const codeBlocks = await page.locator('pre code').count();
90+
expect(codeBlocks).toBeGreaterThan(1);
91+
92+
// Verify screenshots
93+
const screenshots = await page.locator('img[alt="Screenshot"]').count();
94+
expect(screenshots).toBeGreaterThan(0);
95+
}
96+
});
97+
}
98+
99+
test('404 page is displayed for non-existent pages', async ({ page }) => {
100+
// Navigate to a non-existent page
101+
await page.goto('/docs/non-existent-page');
102+
103+
// Check that the 404 page is displayed
104+
await expect(page.locator('h1:has-text("Page Not Found")')).toBeVisible();
105+
});
106+
});
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
const { test, expect } = require('@playwright/test');
2+
3+
test.describe('Documentation Page Content Tests', () => {
4+
const pages = [
5+
{
6+
title: "Install and Quick start",
7+
headlines: ["Installation", "Basic Example"]
8+
},
9+
{
10+
title: "Create Table Instance",
11+
headlines: ["Table instance creation", "Functions of table instance"]
12+
},
13+
{
14+
title: "Adding Rows",
15+
headlines: ["One row at a time", "Batch Row Adding"]
16+
},
17+
{
18+
title: "Row Dividers",
19+
headlines: ["Basic Row Divider", "Multiple Sections"]
20+
},
21+
{
22+
title: "Coloring",
23+
headlines: ["Custom Color"]
24+
},
25+
{
26+
title: "Sort and Filter",
27+
headlines: ["Filter", "Advanced Sorting"]
28+
},
29+
{
30+
title: "Alignment",
31+
headlines: []
32+
},
33+
{
34+
title: "Enable and Disable Columns",
35+
headlines: ["Enable", "Disable"]
36+
},
37+
{
38+
title: "Calculated Columns",
39+
headlines: ["Using All Parameters", "Advanced Examples"]
40+
},
41+
{
42+
title: "Special Chars and emojis",
43+
headlines: ["Special chars", "Newlines in cells"]
44+
}
45+
];
46+
47+
test.beforeEach(async ({ page }) => {
48+
// Go to docs page before each test
49+
await page.goto('/');
50+
await page.locator('a:has-text("GET STARTED")').click();
51+
});
52+
53+
for (const pageInfo of pages) {
54+
test(`${pageInfo.title} page contains correct headlines`, async ({ page }) => {
55+
// Find and click the link with the page title in the sidebar
56+
await page.locator(`nav.menu a:has-text("${pageInfo.title}")`).first().click();
57+
58+
// Check that the page title is in the h1 heading
59+
await expect(page.locator(`h1:has-text("${pageInfo.title}")`)).toBeVisible();
60+
61+
// Check each headline by looking for heading elements containing the text
62+
for (const headline of pageInfo.headlines) {
63+
// Use a more specific selector for each headline
64+
await page.waitForSelector(`h2:has-text("${headline}"), h3:has-text("${headline}"), h4:has-text("${headline}")`, { state: 'visible' });
65+
}
66+
67+
// Special check for Special Chars and emojis page
68+
if (pageInfo.title === "Special Chars and emojis") {
69+
// Verify screenshot presence
70+
const screenshots = await page.locator('img[alt="Screenshot"]').count();
71+
expect(screenshots).toBeGreaterThan(0);
72+
}
73+
});
74+
}
75+
});
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
const { test, expect } = require('@playwright/test');
2+
3+
test.describe('Navigation Links Tests', () => {
4+
test.beforeEach(async ({ page }) => {
5+
await page.goto('/');
6+
});
7+
8+
test('header navigation links work correctly', async ({ page }) => {
9+
// Test GitHub link in header
10+
const githubLink = page.locator('nav[aria-label="Main"] a:has-text("GitHub")');
11+
await expect(githubLink).toBeVisible();
12+
await expect(githubLink).toHaveAttribute('href', 'https://github.com/console-table-printer/console-table-printer');
13+
await expect(githubLink).toHaveAttribute('target', '_blank');
14+
await expect(githubLink).toHaveAttribute('rel', 'noopener noreferrer');
15+
16+
// Test NPM link in header
17+
const npmLink = page.locator('nav[aria-label="Main"] a:has-text("npmjs")');
18+
await expect(npmLink).toBeVisible();
19+
await expect(npmLink).toHaveAttribute('href', 'https://www.npmjs.com/package/console-table-printer');
20+
await expect(npmLink).toHaveAttribute('target', '_blank');
21+
await expect(npmLink).toHaveAttribute('rel', 'noopener noreferrer');
22+
});
23+
24+
test('footer links work correctly', async ({ page }) => {
25+
// Test Learn section links
26+
const quickStartLink = page.locator('footer a:has-text("Quick Start")').first();
27+
await expect(quickStartLink).toBeVisible();
28+
await expect(quickStartLink).toHaveAttribute('href', '/docs');
29+
30+
const cliLink = page.locator('footer a:has-text("Getting Started With CLI")').first();
31+
await expect(cliLink).toBeVisible();
32+
await expect(cliLink).toHaveAttribute('href', '/docs/doc-cli-install-quick-start');
33+
34+
// Test Decorate section links
35+
const colorLink = page.locator('footer a:has-text("Color")').first();
36+
await expect(colorLink).toBeVisible();
37+
await expect(colorLink).toHaveAttribute('href', '/docs/doc-color');
38+
39+
const borderLink = page.locator('footer a:has-text("Border")').first();
40+
await expect(borderLink).toBeVisible();
41+
await expect(borderLink).toHaveAttribute('href', '/docs/doc-border-design');
42+
43+
const alignmentLink = page.locator('footer a:has-text("Alignment")').first();
44+
await expect(alignmentLink).toBeVisible();
45+
await expect(alignmentLink).toHaveAttribute('href', '/docs/doc-alignment');
46+
});
47+
48+
test('external links in footer work correctly', async ({ page }) => {
49+
// Test GitHub link in footer
50+
const githubLink = page.locator('footer a:has-text("GitHub")').first();
51+
await expect(githubLink).toBeVisible();
52+
await expect(githubLink).toHaveAttribute('href', 'https://github.com/console-table-printer/console-table-printer');
53+
await expect(githubLink).toHaveAttribute('target', '_blank');
54+
await expect(githubLink).toHaveAttribute('rel', 'noopener noreferrer');
55+
56+
// Test NPM link in footer
57+
const npmLink = page.locator('footer a:has-text("Npmjs")').first();
58+
await expect(npmLink).toBeVisible();
59+
await expect(npmLink).toHaveAttribute('href', 'https://www.npmjs.com/package/console-table-printer');
60+
await expect(npmLink).toHaveAttribute('target', '_blank');
61+
await expect(npmLink).toHaveAttribute('rel', 'noopener noreferrer');
62+
});
63+
64+
test('announcement bar link works correctly', async ({ page }) => {
65+
// Test GitHub star link in announcement bar
66+
const announcementLink = page.locator('div[role="banner"] a[href="https://github.com/console-table-printer/console-table-printer"]');
67+
await expect(announcementLink).toBeVisible();
68+
await expect(announcementLink).toHaveAttribute('target', '_blank');
69+
await expect(announcementLink).toHaveAttribute('rel', 'noopener noreferrer');
70+
});
71+
});
72+
73+
test.describe('Documentation Page Navigation', () => {
74+
test('sidebar navigation links work correctly', async ({ page }) => {
75+
// Go to docs page
76+
await page.goto('/');
77+
await page.locator('a:has-text("GET STARTED")').click();
78+
79+
// Define the sidebar links to test
80+
const sidebarLinks = [
81+
{ text: "Install and Quick start", url: "/docs/" },
82+
{ text: "Create Table Instance", url: "/docs/doc-table-instance-creation" },
83+
{ text: "Adding Rows", url: "/docs/doc-adding-rows" },
84+
{ text: "Row Dividers", url: "/docs/doc-row-divider" },
85+
{ text: "Coloring", url: "/docs/doc-color" },
86+
{ text: "Sort and Filter", url: "/docs/doc-sort-filter" },
87+
{ text: "Alignment", url: "/docs/doc-alignment" },
88+
{ text: "Enable and Disable Columns", url: "/docs/doc-enable-disable-col" },
89+
{ text: "Calculated Columns", url: "/docs/doc-computed-function" },
90+
{ text: "Special Chars and emojis", url: "/docs/doc-emojis-special-chars" },
91+
{ text: "Typescript", url: "/docs/doc-typescript" }
92+
];
93+
94+
// Test each sidebar link
95+
for (const link of sidebarLinks) {
96+
// Find and click the link
97+
await page.locator(`nav.menu a:has-text("${link.text}")`).first().click();
98+
99+
// Check that the URL includes the expected path
100+
await expect(page).toHaveURL(new RegExp(link.url));
101+
102+
// Verify page content is loaded
103+
await expect(page.locator('main')).toBeVisible();
104+
105+
// Additional checks for Special Chars and emojis page
106+
if (link.text === "Special Chars and emojis") {
107+
// Verify both sections are present using heading elements
108+
await expect(page.locator('h2:has-text("Special chars")')).toBeVisible();
109+
await expect(page.locator('h2:has-text("Newlines in cells")')).toBeVisible();
110+
111+
// Verify code examples - use count greater than 1
112+
const codeBlocks = await page.locator('pre code').count();
113+
expect(codeBlocks).toBeGreaterThan(1);
114+
115+
// Verify screenshots - use count greater than 0
116+
const screenshots = await page.locator('img[alt="Screenshot"]').count();
117+
expect(screenshots).toBeGreaterThan(0);
118+
}
119+
}
120+
});
121+
});

0 commit comments

Comments
 (0)