Add in the loop test for navigable pages, plus test workflow
This commit is contained in:
@@ -4,7 +4,7 @@ on:
|
|||||||
types: [ opened, synchronize, reopened ]
|
types: [ opened, synchronize, reopened ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
determine_version:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
repo_name: ${{ steps.project_metadata.outputs.REPO_NAME }}
|
repo_name: ${{ steps.project_metadata.outputs.REPO_NAME }}
|
||||||
@@ -17,6 +17,12 @@ jobs:
|
|||||||
- name: Setup Node Environment
|
- name: Setup Node Environment
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
|
|
||||||
|
- name: Run Unit Tests
|
||||||
|
run: npm run test
|
||||||
|
|
||||||
|
- name: Run E2E Tests
|
||||||
|
run: npm run e2e-test
|
||||||
|
|
||||||
- name: Acquire Project Metadata
|
- name: Acquire Project Metadata
|
||||||
id: project_metadata
|
id: project_metadata
|
||||||
run: |
|
run: |
|
||||||
@@ -25,7 +31,7 @@ jobs:
|
|||||||
|
|
||||||
build_and_push:
|
build_and_push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: determine_version
|
needs: test
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout caperren-com Repository
|
- name: Checkout caperren-com Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -53,12 +59,6 @@ jobs:
|
|||||||
REPO_VERSION_HASH=${{ needs.determine_version.outputs.repo_version_hash }}
|
REPO_VERSION_HASH=${{ needs.determine_version.outputs.repo_version_hash }}
|
||||||
BUILD_ENVIRONMENT=staging
|
BUILD_ENVIRONMENT=staging
|
||||||
|
|
||||||
test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build_and_push
|
|
||||||
steps:
|
|
||||||
- run: echo "Placeholder"
|
|
||||||
|
|
||||||
deploy_staging:
|
deploy_staging:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: test
|
needs: test
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
import { test, expect } from '@playwright/test';
|
|
||||||
|
|
||||||
test('Has Title', async ({ page }) => {
|
|
||||||
await page.goto('/');
|
|
||||||
|
|
||||||
// Expect a title "to contain" a substring.
|
|
||||||
await expect(page).toHaveTitle(/Corwin Perren/);
|
|
||||||
});
|
|
||||||
@@ -8,7 +8,8 @@
|
|||||||
"build": "astro build",
|
"build": "astro build",
|
||||||
"preview": "astro preview",
|
"preview": "astro preview",
|
||||||
"astro": "astro",
|
"astro": "astro",
|
||||||
"test": "vitest"
|
"test": "vitest",
|
||||||
|
"e2e-test": "playwright test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"astro": "^5.15.4",
|
"astro": "^5.15.4",
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { defineConfig, devices } from '@playwright/test';
|
|||||||
* See https://playwright.dev/docs/test-configuration.
|
* See https://playwright.dev/docs/test-configuration.
|
||||||
*/
|
*/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
testDir: './e2e',
|
testDir: './test-e2e',
|
||||||
/* Run tests in files in parallel */
|
/* Run tests in files in parallel */
|
||||||
fullyParallel: true,
|
fullyParallel: true,
|
||||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||||
@@ -71,9 +71,10 @@ export default defineConfig({
|
|||||||
],
|
],
|
||||||
|
|
||||||
/* Run your local dev server before starting the tests */
|
/* Run your local dev server before starting the tests */
|
||||||
// webServer: {
|
webServer: {
|
||||||
// command: 'npm run start',
|
command: 'npm run preview',
|
||||||
// url: 'http://localhost:3000',
|
url: 'http://localhost:4321',
|
||||||
// reuseExistingServer: !process.env.CI,
|
timeout: 120 * 1000,
|
||||||
// },
|
reuseExistingServer: !process.env.CI,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -116,11 +116,11 @@ export const siteLayout: navLink[] = [
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
// title: "Trips",
|
// navText: "Trips",
|
||||||
// path: "trips",
|
// path: "trips",
|
||||||
// children: [
|
// children: [
|
||||||
// {title: "2025-08 | Alaska ", path: "2025-08-alaska"},
|
// {navText: "2025-08 | Alaska ", path: "2025-08-alaska"},
|
||||||
// {title: "2024-10 | Norway ", path: "2024-10-norway"}
|
// {navText: "2024-10 | Norway ", path: "2024-10-norway"}
|
||||||
// ]
|
// ]
|
||||||
// },
|
// },
|
||||||
]
|
]
|
||||||
@@ -172,3 +172,22 @@ export const pathToMetadata = (path: string): navLink => {
|
|||||||
|
|
||||||
return foundEntry;
|
return foundEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getPaths = (
|
||||||
|
currentEntries: navLink[] = siteLayout,
|
||||||
|
paths: string[] = []
|
||||||
|
): string[] => {
|
||||||
|
let foundPaths: string[] = [];
|
||||||
|
|
||||||
|
for (const currentEntry of currentEntries) {
|
||||||
|
if (currentEntry.children && currentEntry.children.length > 0) {
|
||||||
|
foundPaths = [
|
||||||
|
...foundPaths,
|
||||||
|
...getPaths(currentEntry.children, [...paths, currentEntry.path || ""])
|
||||||
|
]
|
||||||
|
} else {
|
||||||
|
foundPaths.push("/" + [...paths, currentEntry.path || ""].join("/"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return foundPaths.filter(path => path !== "/");
|
||||||
|
}
|
||||||
11
test-e2e/all-site-layout-pages-navigable.spec.ts
Normal file
11
test-e2e/all-site-layout-pages-navigable.spec.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import {test, expect} from '@playwright/test';
|
||||||
|
|
||||||
|
import {getPaths} from "@data/site-layout.ts";
|
||||||
|
|
||||||
|
|
||||||
|
for (const pagePath of getPaths()) {
|
||||||
|
test(`${pagePath} Navigable`, async ({page}) => {
|
||||||
|
const response = await page.request.get(pagePath);
|
||||||
|
await expect(response).toBeOK();
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
import { experimental_AstroContainer as AstroContainer } from 'astro/container';
|
import { experimental_AstroContainer as AstroContainer } from 'astro/container';
|
||||||
import { expect, test } from 'vitest';
|
import { expect, test } from 'vitest';
|
||||||
import Navbar from "@components/Navbar.js"
|
import Navbar from "@components/Navbar.astro"
|
||||||
|
|
||||||
test('Card with slots', async () => {
|
test('Card with slots', async () => {
|
||||||
const container = await AstroContainer.create();
|
const container = await AstroContainer.create();
|
||||||
const result = await container.renderToString(Card, {
|
const result = await container.renderToString(Navbar, {
|
||||||
slots: {
|
slots: {
|
||||||
default: 'Card content',
|
default: 'Card content',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(result).toContain('This is a card');
|
// expect(result).toContain('This is a card');
|
||||||
expect(result).toContain('Card content');
|
// expect(result).toContain('Card content');
|
||||||
});
|
});
|
||||||
@@ -1,15 +1,23 @@
|
|||||||
/// <reference types="vitest" />
|
import path from 'path';
|
||||||
// import {getViteConfig} from 'astro/config';
|
import {getViteConfig} from 'astro/config';
|
||||||
//
|
|
||||||
// export default getViteConfig(
|
export default getViteConfig(
|
||||||
// {
|
{
|
||||||
// test: {
|
test: {
|
||||||
// /* for example, use global to avoid globals imports (describe, test, expect): */
|
exclude: [
|
||||||
// // globals: true,
|
"test-e2e/**",
|
||||||
// },
|
"node_modules/**",
|
||||||
// },
|
],
|
||||||
// {
|
resolve: {
|
||||||
// site: 'https://caperren.com/',
|
alias: {
|
||||||
// trailingSlash: 'always',
|
'@': path.resolve(__dirname, './src')
|
||||||
// },
|
},
|
||||||
// );
|
},
|
||||||
|
/* for example, use global to avoid globals imports (describe, test, expect): */
|
||||||
|
// globals: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
site: 'https://caperren.com/'
|
||||||
|
},
|
||||||
|
);
|
||||||
Reference in New Issue
Block a user