Skip to content

Commit

Permalink
Merge pull request #13 from BrowserSync/bslive-11-e2e-playwright
Browse files Browse the repository at this point in the history
adding a test
  • Loading branch information
shakyShane authored Aug 17, 2024
2 parents 7ecb3cd + 50a983f commit 2aae0e2
Show file tree
Hide file tree
Showing 25 changed files with 5,056 additions and 2,259 deletions.
442 changes: 221 additions & 221 deletions .github/workflows/CI.yml

Large diffs are not rendered by default.

60 changes: 60 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
jobs:
build-rust-binary:
runs-on: macos-latest
env:
# Ensure the correct target architecture is set
CARGO_TARGET_DIR: target
RUST_BACKTRACE: 1
steps:
- uses: actions/checkout@v4

# Set up Rust with the appropriate toolchain
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
target/
key: aarch64-apple-darwin-cargo-macos-latest-2

# Install dependencies
- uses: actions/setup-node@v4
with:
node-version: 22

- name: Install npm dependencies
run: npm ci

- name: Npm test unit
run: npm test

# Build the Rust binary with napi
- name: Build Rust Binary with napi
run: npm run build:debug

- name: Npm test (binary)
run: npm run test:build

- name: Install Playwright Browsers
run: npx playwright install chromium --with-deps

- name: Run Playwright tests
run: npx playwright test

- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,7 @@ Cargo.lock
!.yarn/versions

*.node
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22
7 changes: 7 additions & 0 deletions crates/bsnext_client/generated/dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ export interface ServerChangeSet {
items: ServerChangeSetItem[];
}

/**
* public version of internal events
* todo(alpha): clean this up
*/
export type InternalEventsDTO =
| { kind: "ServersChanged", payload: GetServersMessageResponse };

export type StartupEvent =
| { kind: "Started", payload?: undefined }
| { kind: "FailedStartup", payload: StartupErrorDTO };
Expand Down
302 changes: 302 additions & 0 deletions crates/bsnext_client/generated/schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,302 @@
// generated/schema.ts
import { z } from "zod";

// generated/dto.ts
var EventLevel = /* @__PURE__ */ ((EventLevel2) => {
EventLevel2["External"] = "BSLIVE_EXTERNAL";
return EventLevel2;
})(EventLevel || {});
var ChangeKind = /* @__PURE__ */ ((ChangeKind2) => {
ChangeKind2["Changed"] = "Changed";
ChangeKind2["Added"] = "Added";
ChangeKind2["Removed"] = "Removed";
return ChangeKind2;
})(ChangeKind || {});

// generated/schema.ts
var routeKindDTOSchema = z.union([
z.object({
kind: z.literal("Html"),
payload: z.object({
html: z.string()
})
}),
z.object({
kind: z.literal("Json"),
payload: z.object({
json_str: z.string()
})
}),
z.object({
kind: z.literal("Raw"),
payload: z.object({
raw: z.string()
})
}),
z.object({
kind: z.literal("Sse"),
payload: z.object({
sse: z.string()
})
}),
z.object({
kind: z.literal("Proxy"),
payload: z.object({
proxy: z.string()
})
}),
z.object({
kind: z.literal("Dir"),
payload: z.object({
dir: z.string()
})
})
]);
var routeDTOSchema = z.object({
path: z.string(),
kind: routeKindDTOSchema
});
var serverDescSchema = z.object({
routes: z.array(routeDTOSchema),
id: z.string()
});
var serverIdentityDTOSchema = z.union([
z.object({
kind: z.literal("Both"),
payload: z.object({
name: z.string(),
bind_address: z.string()
})
}),
z.object({
kind: z.literal("Address"),
payload: z.object({
bind_address: z.string()
})
}),
z.object({
kind: z.literal("Named"),
payload: z.object({
name: z.string()
})
})
]);
var serverDTOSchema = z.object({
id: z.string(),
identity: serverIdentityDTOSchema,
socket_addr: z.string()
});
var getServersMessageResponseSchema = z.object({
servers: z.array(serverDTOSchema)
});
var serversChangedSchema = z.object({
servers_resp: getServersMessageResponseSchema
});
var eventLevelSchema = z.nativeEnum(EventLevel);
var stoppedWatchingSchema = z.object({
paths: z.array(z.string())
});
var fileChangedSchema = z.object({
path: z.string()
});
var filesChangedDTOSchema = z.object({
paths: z.array(z.string())
});
var inputAcceptedSchema = z.object({
path: z.string()
});
var inputErrorDTOSchema = z.union([
z.object({
kind: z.literal("MissingInputs"),
payload: z.string()
}),
z.object({
kind: z.literal("InvalidInput"),
payload: z.string()
}),
z.object({
kind: z.literal("NotFound"),
payload: z.string()
}),
z.object({
kind: z.literal("InputWriteError"),
payload: z.string()
}),
z.object({
kind: z.literal("PathError"),
payload: z.string()
}),
z.object({
kind: z.literal("PortError"),
payload: z.string()
}),
z.object({
kind: z.literal("DirError"),
payload: z.string()
}),
z.object({
kind: z.literal("YamlError"),
payload: z.string()
}),
z.object({
kind: z.literal("MarkdownError"),
payload: z.string()
}),
z.object({
kind: z.literal("Io"),
payload: z.string()
}),
z.object({
kind: z.literal("UnsupportedExtension"),
payload: z.string()
}),
z.object({
kind: z.literal("MissingExtension"),
payload: z.string()
}),
z.object({
kind: z.literal("EmptyInput"),
payload: z.string()
})
]);
var debounceDTOSchema = z.object({
kind: z.string(),
ms: z.string()
});
var watchingSchema = z.object({
paths: z.array(z.string()),
debounce: debounceDTOSchema
});
var serverChangeSchema = z.union([
z.object({
kind: z.literal("Stopped"),
payload: z.object({
bind_address: z.string()
})
}),
z.object({
kind: z.literal("Started"),
payload: z.undefined().optional()
}),
z.object({
kind: z.literal("Patched"),
payload: z.undefined().optional()
}),
z.object({
kind: z.literal("Errored"),
payload: z.object({
error: z.string()
})
})
]);
var serverChangeSetItemSchema = z.object({
identity: serverIdentityDTOSchema,
change: serverChangeSchema
});
var serverChangeSetSchema = z.object({
items: z.array(serverChangeSetItemSchema)
});
var internalEventsDTOSchema = z.object({
kind: z.literal("ServersChanged"),
payload: getServersMessageResponseSchema
});
var startupErrorDTOSchema = z.object({
kind: z.literal("InputError"),
payload: inputErrorDTOSchema
});
var changeKindSchema = z.nativeEnum(ChangeKind);
var changeDTOSchema = z.lazy(
() => z.union([
z.object({
kind: z.literal("Fs"),
payload: z.object({
path: z.string(),
change_kind: changeKindSchema
})
}),
z.object({
kind: z.literal("FsMany"),
payload: z.array(changeDTOSchema)
})
])
);
var externalEventsSchema = z.union([
z.object({
kind: z.literal("ServersChanged"),
payload: serversChangedSchema
}),
z.object({
kind: z.literal("Watching"),
payload: watchingSchema
}),
z.object({
kind: z.literal("WatchingStopped"),
payload: stoppedWatchingSchema
}),
z.object({
kind: z.literal("FileChanged"),
payload: fileChangedSchema
}),
z.object({
kind: z.literal("FilesChanged"),
payload: filesChangedDTOSchema
}),
z.object({
kind: z.literal("InputFileChanged"),
payload: fileChangedSchema
}),
z.object({
kind: z.literal("InputAccepted"),
payload: inputAcceptedSchema
}),
z.object({
kind: z.literal("InputError"),
payload: inputErrorDTOSchema
})
]);
var externalEventSchema = z.object({
level: eventLevelSchema,
fields: externalEventsSchema
});
var startupEventSchema = z.union([
z.object({
kind: z.literal("Started"),
payload: z.undefined().optional()
}),
z.object({
kind: z.literal("FailedStartup"),
payload: startupErrorDTOSchema
})
]);
var clientEventSchema = z.object({
kind: z.literal("Change"),
payload: changeDTOSchema
});
export {
changeDTOSchema,
changeKindSchema,
clientEventSchema,
debounceDTOSchema,
eventLevelSchema,
externalEventSchema,
externalEventsSchema,
fileChangedSchema,
filesChangedDTOSchema,
getServersMessageResponseSchema,
inputAcceptedSchema,
inputErrorDTOSchema,
internalEventsDTOSchema,
routeDTOSchema,
routeKindDTOSchema,
serverChangeSchema,
serverChangeSetItemSchema,
serverChangeSetSchema,
serverDTOSchema,
serverDescSchema,
serverIdentityDTOSchema,
serversChangedSchema,
startupErrorDTOSchema,
startupEventSchema,
stoppedWatchingSchema,
watchingSchema
};
Loading

0 comments on commit 2aae0e2

Please sign in to comment.