This commit is contained in:
Dreamgineer
2025-10-27 06:25:21 -04:00 Unverified
parent a0e2a50a38
commit b3c8157886
11 changed files with 237 additions and 29 deletions
+27
View File
@@ -0,0 +1,27 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
+8
View File
@@ -39,3 +39,11 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
# Playwright
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/playwright/.auth/
+20 -1
View File
@@ -20,6 +20,21 @@ COPY package*.json bun.lock ./
# Install into cache, then persist into real node_modules
RUN --mount=type=cache,target=/root/.bun bun install --frozen-lockfile
### Stage N: drizzle ###
FROM oven/bun:latest as drizzle
# Isolation
RUN useradd -mu 1001 container
USER container
WORKDIR /home/container
COPY --from=deps /home/container/node_modules ./node_modules
COPY --from=deps /home/container/package*.json ./
COPY --from=deps /home/container/bun.lock ./
COPY --chown=1001 ./drizzle.config.ts ./.env ./
COPY --chown=1001 ./lib/db ./lib/db
RUN bun dr push
### Stage 2: builder ###
FROM oven/bun:latest AS builder
@@ -31,7 +46,7 @@ WORKDIR /home/container
# Reuse deps
COPY --from=deps /home/container/node_modules ./node_modules
COPY --from=deps /home/container/package*.json ./
COPY --from=deps /home/container/bun.lock ./
COPY --from=deps /home/container/bun.lock ./
# App source
COPY --chown=1001 . .
@@ -50,8 +65,12 @@ WORKDIR /home/container
COPY --from=builder /home/container/node_modules ./node_modules
COPY --from=builder /home/container/bun.lock ./
COPY --from=builder /home/container/package*.json ./
COPY --from=builder /home/container/public ./public
COPY --from=builder /home/container/.env ./.env
COPY --from=builder /home/container/.next ./.next
COPY --from=builder /home/container/util ./util
COPY --from=builder /home/container/tsconfig.json ./tsconfig.json
CMD ["bun", "start"]
+26 -26
View File
@@ -8,6 +8,7 @@ import { Suspense } from "react";
import banner from "#/logos/artifact.webp";
import { Blocker } from "@/components/blocker";
import { ComboBox } from "@/components/combobox";
import { SimpleTooltip } from "@/components/tooltip";
import { Button } from "@/components/ui/button";
import {
Card,
@@ -151,28 +152,25 @@ export default async function ArtifactFormPage() {
</CardContent>
<CardFooter className="flex gap-2 justify-between">
<div className="flex gap-2">
<Tooltip>
<TooltipTrigger asChild>
<Link
href="https://tipme.in.th/536d969652666273c2fa85ad"
target="_blank"
rel="noreferrer"
<SimpleTooltip text="โดเนทลัดคิว ขั้นต่ำ 10 บาท">
<Link
href="https://tipme.in.th/536d969652666273c2fa85ad"
target="_blank"
rel="noreferrer"
>
<Button
variant="outline"
className={
config.limit >= 0 && count >= config.limit
? "bg-emerald-600! border-white! animate-pulse"
: ""
}
type="button"
>
<Button
variant="outline"
className={
config.limit >= 0 && count >= config.limit
? "bg-emerald-600! border-white! animate-pulse"
: ""
}
type="button"
>
<CircleDollarSign />
</Button>
</Link>
</TooltipTrigger>
<TooltipContent>โดเนทลัดคิว ขั้นต่ำ 10 บาท</TooltipContent>
</Tooltip>
<CircleDollarSign />
</Button>
</Link>
</SimpleTooltip>
<Tooltip>
<RulesDialog>
<TooltipTrigger asChild>
@@ -187,8 +185,11 @@ export default async function ArtifactFormPage() {
<LiveButton />
</Suspense>
</div>
<Tooltip>
<TooltipTrigger asChild>
<div className="flex gap-2 items-center">
<span className="p-1">
{count} / {config.limit < 0 ? "∞" : config.limit}
</span>
<SimpleTooltip text="ส่งเลยจัฟลูกพี่">
<Button
type="submit"
form="mainform"
@@ -200,9 +201,8 @@ export default async function ArtifactFormPage() {
>
<SendHorizonal />
</Button>
</TooltipTrigger>
<TooltipContent>ส่งเลยจัฟลูกพี่</TooltipContent>
</Tooltip>
</SimpleTooltip>
</div>
</CardFooter>
</Card>
{sid && !q && <ClearCookie />}
+2
View File
@@ -31,6 +31,8 @@ export function RulesDialog({
<br /> 3. สามารถดูให้ได้แค่
<u className="text-red-500">ตัวละครเดียว</u>เท่านั้น แต่ถ้าโดเนทลัดคิว
สามารถดูได้สูงสุด 8 ตัว
<br />
4. โดเนทขั้นต่ำ 10 บาท หากโดเนทมา แล้วลงคิวไปแล้ว แจ้งชื่อที่ลงไปในคิวมาด้วย
</p>
<DialogFooter>
<DialogClose asChild>
+2 -1
View File
@@ -4,6 +4,7 @@ import { ProgressProvider } from "@bprogress/next/app";
import { useEffect, useState } from "react";
import ReconnectingEventSource from "reconnecting-eventsource";
import { toast } from "sonner";
import CommsProvider from "@/lib/comms";
export default function Providers({ children }: { children: React.ReactNode }) {
return (
@@ -13,7 +14,7 @@ export default function Providers({ children }: { children: React.ReactNode }) {
options={{ showSpinner: false }}
shallowRouting
>
{children}
<CommsProvider>{children}</CommsProvider>
</ProgressProvider>
);
}
+9
View File
@@ -72,6 +72,7 @@
"devDependencies": {
"@better-auth/cli": "^1.3.29",
"@biomejs/biome": "2.2.7",
"@playwright/test": "^1.56.1",
"@tailwindcss/postcss": "^4",
"@types/node": "^20",
"@types/react": "19.2.2",
@@ -406,6 +407,8 @@
"@peculiar/x509": ["@peculiar/[email protected]", "", { "dependencies": { "@peculiar/asn1-cms": "^2.5.0", "@peculiar/asn1-csr": "^2.5.0", "@peculiar/asn1-ecc": "^2.5.0", "@peculiar/asn1-pkcs9": "^2.5.0", "@peculiar/asn1-rsa": "^2.5.0", "@peculiar/asn1-schema": "^2.5.0", "@peculiar/asn1-x509": "^2.5.0", "pvtsutils": "^1.3.6", "reflect-metadata": "^0.2.2", "tslib": "^2.8.1", "tsyringe": "^4.10.0" } }, "sha512-Yc4PDxN3OrxUPiXgU63c+ZRXKGE8YKF2McTciYhUHFtHVB0KMnjeFSU0qpztGhsp4P0uKix4+J2xEpIEDu8oXg=="],
"@playwright/test": ["@playwright/[email protected]", "", { "dependencies": { "playwright": "1.56.1" }, "bin": { "playwright": "cli.js" } }, "sha512-vSMYtL/zOcFpvJCW71Q/OEGQb7KYBPAdKh35WNSkaZA75JlAO8ED8UN6GUNTm3drWomcbcqRPFqQbLae8yBTdg=="],
"@polka/url": ["@polka/[email protected]", "", {}, "sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww=="],
"@prisma/client": ["@prisma/[email protected]", "", { "peerDependencies": { "prisma": "*" }, "optionalPeers": ["prisma"] }, "sha512-M0SVXfyHnQREBKxCgyo7sffrKttwE6R8PMq330MIUF0pTwjUhLbW84pFDlf06B27XyCR++VtjugEnIHdr07SVA=="],
@@ -886,6 +889,10 @@
"pkg-types": ["[email protected]", "", { "dependencies": { "confbox": "^0.2.2", "exsolve": "^1.0.7", "pathe": "^2.0.3" } }, "sha512-SIqCzDRg0s9npO5XQ3tNZioRY1uK06lA41ynBC1YmFTmnY6FjUjVt6s4LoADmwoig1qqD0oK8h1p/8mlMx8Oig=="],
"playwright": ["[email protected]", "", { "dependencies": { "playwright-core": "1.56.1" }, "optionalDependencies": { "fsevents": "2.3.2" }, "bin": { "playwright": "cli.js" } }, "sha512-aFi5B0WovBHTEvpM3DzXTUaeN6eN0qWnTkKx4NQaH4Wvcmc153PdaY2UBdSYKaGYw+UyWXSVyxDUg5DoPEttjw=="],
"playwright-core": ["[email protected]", "", { "bin": { "playwright-core": "cli.js" } }, "sha512-hutraynyn31F+Bifme+Ps9Vq59hKuUCz7H1kDOcBs+2oGguKkWTU50bBWrtz34OUWmIwpBTWDxaRPXrIXkgvmQ=="],
"postcss": ["[email protected]", "", { "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg=="],
"postgres-array": ["[email protected]", "", {}, "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA=="],
@@ -1064,6 +1071,8 @@
"nypm/tinyexec": ["[email protected]", "", {}, "sha512-5uC6DDlmeqiOwCPmK9jMSdOuZTh8bU39Ys6yidB+UTt5hfZUPGAypSgFRiEp+jbi9qH40BLDvy85jIU88wKSqw=="],
"playwright/fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA=="],
"prop-types/react-is": ["[email protected]", "", {}, "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="],
"tsyringe/tslib": ["[email protected]", "", {}, "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="],
+33
View File
@@ -0,0 +1,33 @@
"use client";
import { createContext, useState } from "react";
type WebsiteComms = Partial<{ manual: boolean }>;
type WebsiteCommsMutator = {
get<K extends keyof WebsiteComms>(key: K): WebsiteComms[K];
set<K extends keyof WebsiteComms>(key: K, value: WebsiteComms[K]): void;
};
export const CommsContext = createContext<WebsiteCommsMutator>({
get: () => undefined,
set: () => undefined,
});
export default function CommsProvider({
children,
}: {
children: React.ReactNode;
}) {
const [store, setStore] = useState<WebsiteComms>({});
return (
<CommsContext
value={{
get: (k) => store[k],
set: (k, v) => setStore((x) => ({ ...x, [k]: v })),
}}
>
{children}
</CommsContext>
);
}
+3 -1
View File
@@ -11,7 +11,8 @@
"format": "biome format --write",
"dr": "drizzle-kit",
"ba": "bunx @better-auth/cli",
"up": "docker compose up -d --build"
"up": "docker compose up -d --build",
"test": "playwright test"
},
"dependencies": {
"@bprogress/next": "^3.2.12",
@@ -82,6 +83,7 @@
"devDependencies": {
"@better-auth/cli": "^1.3.29",
"@biomejs/biome": "2.2.7",
"@playwright/test": "^1.56.1",
"@tailwindcss/postcss": "^4",
"@types/node": "^20",
"@types/react": "19.2.2",
+79
View File
@@ -0,0 +1,79 @@
import { defineConfig, devices } from "@playwright/test";
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// import path from 'path';
// dotenv.config({ path: path.resolve(__dirname, '.env') });
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: "./tests",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: process.env.CI ? "github" : [["html"], ["list"]],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('')`. */
// baseURL: 'http://localhost:3000',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
},
/* Configure projects for major browsers */
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
{
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},
{
name: "webkit",
use: { ...devices["Desktop Safari"] },
},
/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },
/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],
/* Run your local dev server before starting the tests */
webServer: {
command: "bun run build && bun start",
url: "http://localhost:3000",
reuseExistingServer: !process.env.CI,
},
});
+28
View File
@@ -0,0 +1,28 @@
import { expect, test } from "@playwright/test";
const { BASE_URL = "http://localhost:3000" } = process.env;
test("has title", async ({ page }) => {
await page.goto(BASE_URL);
// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/เกนชินไม่ใช่เกมมือถือ/);
});
test("artifact link", async ({ page }) => {
await page.goto(BASE_URL);
await page.getByText("เสือกไอดีชาวบ้าน").click();
await expect(page.getByAltText("เสือกไอดีชาวบ้าน")).toBeVisible();
});
test("tierlist link", async ({ page }) => {
await page.goto(BASE_URL);
await page.getByText("จัดเทียร์ลิสต์").click();
await page.getByText("5.7b").click();
await expect(page.getByAltText("Disclaimer")).toBeVisible();
});