Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Make package releasable #496

Merged
merged 5 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,9 @@ jobs:
- name: Install Dependencies for Vite Plugin Relay
run: pnpm i
- name: Install Playwright
run: npx playwright install --with-deps
- name: Build Vite Plugin Relay
run: pnpm build
- name: Install Dependencies for Vite 3 Example Site
run: pnpm --filter example-vite-3 i
- name: Test Vite 3 Example Site
run: pnpm --filter example-vite-3 test
- name: Install Dependencies for Vite 2 Example Site
run: pnpm --filter example-vite-2 i
- name: Test Vite 2 Example Site
run: pnpm --filter example-vite-2 test
run: pnpm --filter example exec playwright install --with-deps
- name: Test Example Site
run: pnpm --filter example test

lint:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions examples/latest/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ dist-ssr
*.njsproj
*.sln
*.sw?
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
2 changes: 1 addition & 1 deletion examples/latest/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
3 changes: 2 additions & 1 deletion examples/latest/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "example-vite-3",
"name": "example",
"private": true,
"version": "0.0.0",
"type": "module",
Expand All @@ -18,6 +18,7 @@
},
"devDependencies": {
"@playwright/test": "1.40.1",
"@types/node": "^20.10.4",
"@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17",
"@types/react-relay": "^16.0.5",
Expand Down
29 changes: 29 additions & 0 deletions examples/latest/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { defineConfig, devices } from "@playwright/test";

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: "./src",
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
use: {
trace: "on-first-retry",
},
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
{
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},
{
name: "webkit",
use: { ...devices["Desktop Safari"] },
},
],
});
49 changes: 21 additions & 28 deletions examples/latest/src/App.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { test, expect, Page } from "@playwright/test";
import { GraphQLResponseWithData as RelayGraphQLResponseWithData } from "relay-runtime";
import path from "path";
import { AppQuery$data } from "./__generated__/AppQuery.graphql";

const apiUrl = "https://spacex-production.up.railway.app/graphql";

// Mutable removes the readonly property from a type. This is done because the Relay compiler outputs types with readonly fields.
type Mutable<T> = {
-readonly [P in keyof T]: T[P];
Expand Down Expand Up @@ -34,37 +35,33 @@ test.beforeEach(async ({ page }) => {
if (route.request().resourceType() === "document") {
return route.fulfill({
status: 200,
path: path.join(__dirname, "../dist/index.html"),
path: new URL("../dist/index.html", import.meta.url).pathname,
});
} else {
const url = new URL(route.request().url());
return route.fulfill({
status: 200,
path: path.join(__dirname, "../dist", url.pathname),
path: new URL("../dist" + url.pathname, import.meta.url).pathname,
});
}
});
});

test("renders list with many ships", async ({ page }) => {
await modifyGraphQLResponse(
page,
"https://api.spacex.land/graphql",
(body: GraphQLResponseWithData<Mutable<AppQuery$data>>) => {
body.data.ships = [
{
id: "one",
name: "Ship One",
},
{
id: "two",
name: "Ship Two",
},
];
await modifyGraphQLResponse(page, apiUrl, (body: GraphQLResponseWithData<Mutable<AppQuery$data>>) => {
body.data.ships = [
{
id: "one",
name: "Ship One",
},
{
id: "two",
name: "Ship Two",
},
];

return body;
},
);
return body;
});

await page.goto(`http://localhost`, { waitUntil: "networkidle" });

Expand All @@ -83,14 +80,10 @@ test("renders list with many ships", async ({ page }) => {
});

test("renders list with no ships", async ({ page }) => {
await modifyGraphQLResponse(
page,
"https://api.spacex.land/graphql",
(body: GraphQLResponseWithData<Mutable<AppQuery$data>>) => {
body.data.ships = [];
return body;
},
);
await modifyGraphQLResponse(page, apiUrl, (body: GraphQLResponseWithData<Mutable<AppQuery$data>>) => {
body.data.ships = [];
return body;
});

await page.goto(`http://localhost`, { waitUntil: "networkidle" });

Expand Down
6 changes: 1 addition & 5 deletions examples/latest/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ export default function App(): ReactElement {
Data Viewer
</h1>
<h2 id="ships-heading">Ships</h2>
<ul aria-labelledby="ships-heading">
{data.ships?.map((ship) => (
<li key={ship?.id}>{ship?.name}</li>
))}
</ul>
<ul aria-labelledby="ships-heading">{data.ships?.map((ship) => <li key={ship?.id}>{ship?.name}</li>)}</ul>
</>
);
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"build": "tsup src/plugin.ts --dts --clean --format cjs,esm --no-splitting --env.NODE_ENV production",
"dev": "tsup src/plugin.ts --dts --clean --format cjs,esm --no-splitting --watch",
"test": "pnpm -r --parallel --filter=!vite-plugin-relay exec pnpm test",
"lint": "prettier --check . && eslint src/** examples/vite-2/src/** examples/vite-3/src/**",
"format": "prettier --write . && eslint src/** examples/vite-2/src/** examples/vite-3/src/** --fix",
"lint": "prettier --check . && eslint src/** examples/latest/src/**",
"format": "prettier --write . && eslint src/** examples/latest/src/** --fix",
"prepare": "husky install && yarn build"
},
"peerDependencies": {
Expand Down
Loading
Loading