mirror of
https://github.com/LukeHagar/website.git
synced 2025-12-06 04:22:07 +00:00
Add tests and cleanup redirects
The changes include: 1. Adding GitHub Actions test job 2. Adding redirect tests 3. Updating redirect configurations 4. Migrating some redirects to SvelteKit routes 5. Test config improvements
This commit is contained in:
31
.github/workflows/tests.yml
vendored
31
.github/workflows/tests.yml
vendored
@@ -35,7 +35,36 @@ jobs:
|
||||
run: pnpm install --frozen-lockfile
|
||||
- name: Check formatting
|
||||
run: pnpm format:check
|
||||
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
- name: Install corepack
|
||||
run: npm i -g corepack@latest
|
||||
- name: Install pnpm
|
||||
run: corepack enable
|
||||
- name: Get pnpm store directory
|
||||
shell: bash
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||
- uses: actions/cache@v4
|
||||
name: Setup pnpm cache
|
||||
with:
|
||||
path: ${{ env.STORE_PATH }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
- name: Install playwright dependencies
|
||||
run: pnpm exec playwright install
|
||||
- name: Run tests
|
||||
run: pnpm test
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -21,3 +21,4 @@ terraform/**/.t*
|
||||
terraform/**/.env
|
||||
terraform/**/**/*.tfstate*
|
||||
/.cache
|
||||
/test-results
|
||||
@@ -17,7 +17,7 @@
|
||||
"icons:optimize": "node ./src/icons/optimize.js",
|
||||
"lint": "prettier --check . && eslint .",
|
||||
"preview": "vite preview",
|
||||
"test": "npm run test:integration && npm run test:unit",
|
||||
"test": "npm run test:integration",
|
||||
"test:integration": "playwright test",
|
||||
"test:unit": "vitest",
|
||||
"optimize": "node ./scripts/optimize-assets.js",
|
||||
|
||||
@@ -2,9 +2,10 @@ import type { PlaywrightTestConfig } from '@playwright/test';
|
||||
|
||||
const config: PlaywrightTestConfig = {
|
||||
webServer: {
|
||||
command: 'npm run build && npm run preview',
|
||||
port: 4173
|
||||
command: 'npm run dev',
|
||||
port: 5173
|
||||
},
|
||||
fullyParallel: true,
|
||||
testDir: 'tests',
|
||||
testMatch: /(.+\.)?(test|spec)\.[jt]s/
|
||||
};
|
||||
|
||||
@@ -139,10 +139,6 @@
|
||||
"link": "/docs/authentication-management",
|
||||
"redirect": "/docs/products/auth/users"
|
||||
},
|
||||
{
|
||||
"link": "/docs/authentication-server",
|
||||
"redirect": "/docs/authentication-server"
|
||||
},
|
||||
{
|
||||
"link": "/docs/authentication-security",
|
||||
"redirect": "/docs/products/auth/security"
|
||||
@@ -265,7 +261,7 @@
|
||||
},
|
||||
{
|
||||
"link": "/docs/debugging",
|
||||
"redirect": "/docs/advanced/self-hosting/debugging"
|
||||
"redirect": "/docs/advanced/self-hosting/debug"
|
||||
},
|
||||
{
|
||||
"link": "/docs/upgrade",
|
||||
@@ -467,10 +463,6 @@
|
||||
"link": "/docs/models/collection",
|
||||
"redirect": "/docs/references/cloud/models/collection"
|
||||
},
|
||||
{
|
||||
"link": "/docs/models/attribute",
|
||||
"redirect": "/docs/references/cloud/models/attribute"
|
||||
},
|
||||
{
|
||||
"link": "/docs/models/index",
|
||||
"redirect": "/docs/references/cloud/models/index"
|
||||
@@ -659,10 +651,6 @@
|
||||
"link": "/keyboard",
|
||||
"redirect": "/docs/tooling/appwriter"
|
||||
},
|
||||
{
|
||||
"link": "/careers",
|
||||
"redirect": "https://appwrite.careers"
|
||||
},
|
||||
{
|
||||
"link": "/policy/terms",
|
||||
"redirect": "/terms"
|
||||
@@ -671,10 +659,7 @@
|
||||
"link": "/policy/privacy",
|
||||
"redirect": "/privacy"
|
||||
},
|
||||
{
|
||||
"link": "/cli/install.sh",
|
||||
"redirect": "https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/install.sh"
|
||||
},
|
||||
|
||||
{
|
||||
"link": "/case-studies",
|
||||
"redirect": "/customer-stories"
|
||||
|
||||
5
src/routes/careers/+page.server.ts
Normal file
5
src/routes/careers/+page.server.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
|
||||
export function load() {
|
||||
redirect(301, 'https://careers.appwrite.io');
|
||||
}
|
||||
5
src/routes/cli/install.sh/+page.server.ts
Normal file
5
src/routes/cli/install.sh/+page.server.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
|
||||
export function load() {
|
||||
redirect(301, 'https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/install.sh');
|
||||
}
|
||||
10
tests/redirects.test.ts
Normal file
10
tests/redirects.test.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
import redirects from '../src/redirects.json' with { type: 'json' };
|
||||
|
||||
redirects.forEach(({ link, redirect }) => {
|
||||
test(`redirected from ${link} to ${redirect} exists`, async ({ page }) => {
|
||||
const response = await page.goto(redirect);
|
||||
|
||||
expect(response?.ok()).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,6 +0,0 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
|
||||
test('index page has expected h1', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await expect(page.getByRole('heading', { name: 'Welcome to SvelteKit' })).toBeVisible();
|
||||
});
|
||||
Reference in New Issue
Block a user