Skip to content

Commit

Permalink
chore: make tests os agnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeiscontent committed Apr 29, 2024
1 parent be32a14 commit 5dac34b
Show file tree
Hide file tree
Showing 9 changed files with 3,582 additions and 3,059 deletions.
21 changes: 12 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v3
with:
version: 8
- name: Download deps
Expand All @@ -35,15 +35,18 @@ jobs:

e2e:
name: E2E Tests
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v3
with:
version: 8
- name: Download deps
Expand All @@ -53,9 +56,9 @@ jobs:
- name: Run tests
run: pnpm exec playwright test
- name: Upload test result
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
name: test-results-${{ runner.os }}
path: test-results/
retention-days: 30
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@conform-to/validitystate": "workspace:*",
"@conform-to/yup": "workspace:*",
"@conform-to/zod": "workspace:*",
"@playwright/test": "^1.40.1",
"@playwright/test": "^1.43.1",
"@remix-run/eslint-config": "^1.19.3",
"@remix-run/node": "^1.19.3",
"@types/node": "^20.10.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/conform-dom/formdata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export function normalize<
* Flatten a tree into a dictionary
*/
export function flatten(
data: Record<string | number | symbol, unknown> | Array<unknown> | undefined,
data: unknown,
options?: {
resolve?: (data: unknown) => unknown | null;
prefix?: string;
Expand Down Expand Up @@ -307,7 +307,7 @@ export function flatten(

if (Array.isArray(data)) {
processArray(data, prefix);
} else {
} else if (data && isPlainObject(data)) {
processObject(data, prefix);
}
}
Expand Down
11 changes: 2 additions & 9 deletions packages/conform-dom/submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,6 @@ export function setState(

Object.assign(
state,
// @ts-expect-error FIXME flatten should be more flexible
flatten(result, {
resolve(data) {
if (isPlainObject(data) || Array.isArray(data)) {
Expand Down Expand Up @@ -524,14 +523,11 @@ export function setListState(
});
}

export function serialize<Schema>(
defaultValue: DefaultValue<Schema>,
): FormValue<Schema> {
export function serialize<Schema>(defaultValue: Schema): FormValue<Schema> {
if (isPlainObject(defaultValue)) {
// @ts-expect-error FIXME
return Object.entries(defaultValue).reduce<Record<string, unknown>>(
(result, [key, value]) => {
// @ts-ignore-error FIXME
result[key] = serialize(value);
return result;
},
Expand All @@ -540,10 +536,7 @@ export function serialize<Schema>(
} else if (Array.isArray(defaultValue)) {
// @ts-expect-error FIXME
return defaultValue.map(serialize);
} else if (
// @ts-ignore-error FIXME
defaultValue instanceof Date
) {
} else if (defaultValue instanceof Date) {
// @ts-expect-error FIXME
return defaultValue.toISOString();
} else if (typeof defaultValue === 'boolean') {
Expand Down

0 comments on commit 5dac34b

Please sign in to comment.