Skip to content

Commit 37a2f9b

Browse files
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
1 parent 395e3bf commit 37a2f9b

File tree

9 files changed

+57
-27
lines changed

9 files changed

+57
-27
lines changed

.github/workflows/tests.yml

+30-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,36 @@ jobs:
3535
run: pnpm install --frozen-lockfile
3636
- name: Check formatting
3737
run: pnpm format:check
38-
38+
tests:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v4
42+
with:
43+
ref: ${{ github.event.pull_request.head.sha }}
44+
- uses: actions/setup-node@v4
45+
with:
46+
node-version: 20
47+
- name: Install corepack
48+
run: npm i -g corepack@latest
49+
- name: Install pnpm
50+
run: corepack enable
51+
- name: Get pnpm store directory
52+
shell: bash
53+
run: |
54+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
55+
- uses: actions/cache@v4
56+
name: Setup pnpm cache
57+
with:
58+
path: ${{ env.STORE_PATH }}
59+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
60+
restore-keys: |
61+
${{ runner.os }}-pnpm-store-
62+
- name: Install dependencies
63+
run: pnpm install --frozen-lockfile
64+
- name: Install playwright dependencies
65+
run: pnpm exec playwright install
66+
- name: Run tests
67+
run: pnpm test
3968
build:
4069
runs-on: ubuntu-latest
4170
steps:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ terraform/**/.t*
2121
terraform/**/.env
2222
terraform/**/**/*.tfstate*
2323
/.cache
24+
/test-results

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"icons:optimize": "node ./src/icons/optimize.js",
1818
"lint": "prettier --check . && eslint .",
1919
"preview": "vite preview",
20-
"test": "npm run test:integration && npm run test:unit",
20+
"test": "npm run test:integration",
2121
"test:integration": "playwright test",
2222
"test:unit": "vitest",
2323
"optimize": "node ./scripts/optimize-assets.js",

playwright.config.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import type { PlaywrightTestConfig } from '@playwright/test';
22

33
const config: PlaywrightTestConfig = {
44
webServer: {
5-
command: 'npm run build && npm run preview',
6-
port: 4173
5+
command: 'npm run dev',
6+
port: 5173
77
},
8+
fullyParallel: true,
89
testDir: 'tests',
910
testMatch: /(.+\.)?(test|spec)\.[jt]s/
1011
};

src/redirects.json

+2-17
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,6 @@
139139
"link": "/docs/authentication-management",
140140
"redirect": "/docs/products/auth/users"
141141
},
142-
{
143-
"link": "/docs/authentication-server",
144-
"redirect": "/docs/authentication-server"
145-
},
146142
{
147143
"link": "/docs/authentication-security",
148144
"redirect": "/docs/products/auth/security"
@@ -265,7 +261,7 @@
265261
},
266262
{
267263
"link": "/docs/debugging",
268-
"redirect": "/docs/advanced/self-hosting/debugging"
264+
"redirect": "/docs/advanced/self-hosting/debug"
269265
},
270266
{
271267
"link": "/docs/upgrade",
@@ -467,10 +463,6 @@
467463
"link": "/docs/models/collection",
468464
"redirect": "/docs/references/cloud/models/collection"
469465
},
470-
{
471-
"link": "/docs/models/attribute",
472-
"redirect": "/docs/references/cloud/models/attribute"
473-
},
474466
{
475467
"link": "/docs/models/index",
476468
"redirect": "/docs/references/cloud/models/index"
@@ -659,10 +651,6 @@
659651
"link": "/keyboard",
660652
"redirect": "/docs/tooling/appwriter"
661653
},
662-
{
663-
"link": "/careers",
664-
"redirect": "https://appwrite.careers"
665-
},
666654
{
667655
"link": "/policy/terms",
668656
"redirect": "/terms"
@@ -671,10 +659,7 @@
671659
"link": "/policy/privacy",
672660
"redirect": "/privacy"
673661
},
674-
{
675-
"link": "/cli/install.sh",
676-
"redirect": "https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/install.sh"
677-
},
662+
678663
{
679664
"link": "/case-studies",
680665
"redirect": "/customer-stories"

src/routes/careers/+page.server.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { redirect } from '@sveltejs/kit';
2+
3+
export function load() {
4+
redirect(301, 'https://careers.appwrite.io');
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { redirect } from '@sveltejs/kit';
2+
3+
export function load() {
4+
redirect(301, 'https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/install.sh');
5+
}

tests/redirects.test.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { expect, test } from '@playwright/test';
2+
import redirects from '../src/redirects.json' with { type: 'json' };
3+
4+
redirects.forEach(({ link, redirect }) => {
5+
test(`redirected from ${link} to ${redirect} exists`, async ({ page }) => {
6+
const response = await page.goto(redirect);
7+
8+
expect(response?.ok()).toBeTruthy();
9+
});
10+
});

tests/test.ts

-6
This file was deleted.

0 commit comments

Comments
 (0)