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
|
run: pnpm install --frozen-lockfile
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
run: pnpm format:check
|
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:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -21,3 +21,4 @@ terraform/**/.t*
|
|||||||
terraform/**/.env
|
terraform/**/.env
|
||||||
terraform/**/**/*.tfstate*
|
terraform/**/**/*.tfstate*
|
||||||
/.cache
|
/.cache
|
||||||
|
/test-results
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
"icons:optimize": "node ./src/icons/optimize.js",
|
"icons:optimize": "node ./src/icons/optimize.js",
|
||||||
"lint": "prettier --check . && eslint .",
|
"lint": "prettier --check . && eslint .",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"test": "npm run test:integration && npm run test:unit",
|
"test": "npm run test:integration",
|
||||||
"test:integration": "playwright test",
|
"test:integration": "playwright test",
|
||||||
"test:unit": "vitest",
|
"test:unit": "vitest",
|
||||||
"optimize": "node ./scripts/optimize-assets.js",
|
"optimize": "node ./scripts/optimize-assets.js",
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ import type { PlaywrightTestConfig } from '@playwright/test';
|
|||||||
|
|
||||||
const config: PlaywrightTestConfig = {
|
const config: PlaywrightTestConfig = {
|
||||||
webServer: {
|
webServer: {
|
||||||
command: 'npm run build && npm run preview',
|
command: 'npm run dev',
|
||||||
port: 4173
|
port: 5173
|
||||||
},
|
},
|
||||||
|
fullyParallel: true,
|
||||||
testDir: 'tests',
|
testDir: 'tests',
|
||||||
testMatch: /(.+\.)?(test|spec)\.[jt]s/
|
testMatch: /(.+\.)?(test|spec)\.[jt]s/
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -139,10 +139,6 @@
|
|||||||
"link": "/docs/authentication-management",
|
"link": "/docs/authentication-management",
|
||||||
"redirect": "/docs/products/auth/users"
|
"redirect": "/docs/products/auth/users"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"link": "/docs/authentication-server",
|
|
||||||
"redirect": "/docs/authentication-server"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"link": "/docs/authentication-security",
|
"link": "/docs/authentication-security",
|
||||||
"redirect": "/docs/products/auth/security"
|
"redirect": "/docs/products/auth/security"
|
||||||
@@ -265,7 +261,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"link": "/docs/debugging",
|
"link": "/docs/debugging",
|
||||||
"redirect": "/docs/advanced/self-hosting/debugging"
|
"redirect": "/docs/advanced/self-hosting/debug"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"link": "/docs/upgrade",
|
"link": "/docs/upgrade",
|
||||||
@@ -467,10 +463,6 @@
|
|||||||
"link": "/docs/models/collection",
|
"link": "/docs/models/collection",
|
||||||
"redirect": "/docs/references/cloud/models/collection"
|
"redirect": "/docs/references/cloud/models/collection"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"link": "/docs/models/attribute",
|
|
||||||
"redirect": "/docs/references/cloud/models/attribute"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"link": "/docs/models/index",
|
"link": "/docs/models/index",
|
||||||
"redirect": "/docs/references/cloud/models/index"
|
"redirect": "/docs/references/cloud/models/index"
|
||||||
@@ -659,10 +651,6 @@
|
|||||||
"link": "/keyboard",
|
"link": "/keyboard",
|
||||||
"redirect": "/docs/tooling/appwriter"
|
"redirect": "/docs/tooling/appwriter"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"link": "/careers",
|
|
||||||
"redirect": "https://appwrite.careers"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"link": "/policy/terms",
|
"link": "/policy/terms",
|
||||||
"redirect": "/terms"
|
"redirect": "/terms"
|
||||||
@@ -671,10 +659,7 @@
|
|||||||
"link": "/policy/privacy",
|
"link": "/policy/privacy",
|
||||||
"redirect": "/privacy"
|
"redirect": "/privacy"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"link": "/cli/install.sh",
|
|
||||||
"redirect": "https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/install.sh"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"link": "/case-studies",
|
"link": "/case-studies",
|
||||||
"redirect": "/customer-stories"
|
"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