Skip to content

Commit

Permalink
doc: webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitFicus committed Jun 16, 2024
1 parent 80d88ac commit b07543b
Show file tree
Hide file tree
Showing 15 changed files with 477 additions and 268 deletions.
61 changes: 53 additions & 8 deletions izanami-frontend/src/components/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ function Editor(props: { value: string; onChange: (v: string) => void }) {
</Tooltip>
</label>
<CodeMirror
aria-label="Handlebar template"
id="handlebar-editor"
value={value}
height="450px"
Expand All @@ -128,21 +129,66 @@ events.set(
"FEATURE_UPDATED",
JSON.stringify(
{
_id: 1794867116702171100,
timestamp: "2024-05-26T23:04:02.297187Z",
_id: 1802464900523491300,
timestamp: "2024-06-16T22:14:55.120227Z",
payload: {
name: "f1",
active: true,
project: "project",
name: "summer-sales",
active: false,
project: "website",
conditions: {
"": {
enabled: true,
conditions: [
{
period: {
begin: "2024-06-16T22:00:00Z",
end: "2024-06-21T06:00:00Z",
hourPeriods: [
{
startTime: "08:00:00",
endTime: "23:00:00",
},
{
startTime: "14:00:00",
endTime: "15:00:00",
},
],
activationDays: {
days: [
"MONDAY",
"FRIDAY",
"TUESDAY",
"THURSDAY",
"WEDNESDAY",
],
},
timezone: "Europe/Paris",
},
rule: {
percentage: 25,
},
},
{
period: null,
rule: {
users: ["foo", "bar"],
},
},
],
},
},
previousConditions: {
"": {
enabled: false,
conditions: [],
},
},
},
metadata: {
user: "RESERVED_ADMIN_USER",
},
type: "FEATURE_UPDATED",
id: "08cc3224-cfd0-4159-8d8c-8fd6cffa3e37",
id: "73a2ef9e-aade-4eb7-8e12-6145b5e6ef7a",
},
null,
2
Expand Down Expand Up @@ -259,8 +305,7 @@ function EventPicker(props: {
</div>
<CodeMirror
id="event-value"
//value={value}
value={`{ "foo": "bar" }`}
value={value}
onChange={(str) => {
setValue(str);
onChange(str);
Expand Down
10 changes: 2 additions & 8 deletions izanami-frontend/src/pages/webhooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -735,12 +735,9 @@ function Headers(props: {
{arr.map(({ name, value }, index) => (
<div className="row" key={`header-${index}`}>
<div className="col-6 col-lg-3">
<label hidden htmlFor={`header-${index}-name`}>
Header {index} name
</label>
<input
aria-label={`header-${index}-name`}
className="form-control"
id={`header-${index}-name`}
value={name}
onChange={(e) => {
const v = e.target.value;
Expand All @@ -754,12 +751,9 @@ function Headers(props: {
/>
</div>
<div className="col">
<label hidden htmlFor={`header-${index}-value`}>
Header {index} value
</label>
<input
className="form-control"
id={`header-${index}-value`}
aria-label={`header-${index}-value`}
value={value}
onChange={(e) => {
const v = e.target.value;
Expand Down
2 changes: 2 additions & 0 deletions izanami-frontend/tests/screenshots/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { generate as multiConditionFeatureGenerate } from "./multi-condition-fea
import { generate as queryBuilderGenerate } from "./query-builder";
import { generate as remoteWasmoGenerate } from "./remote-wasmo";
import { generate as userInvitationGenerate } from "./user-invitation";
import { generate as webhookGenerate } from "./webhooks";

async function generateAll() {
await apiKeyGenerate();
Expand All @@ -22,6 +23,7 @@ async function generateAll() {
await userInvitationGenerate();
await base64Wasm();
await remoteWasmoGenerate();
await webhookGenerate();
}

generateAll();
60 changes: 60 additions & 0 deletions izanami-frontend/tests/screenshots/webhooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import {
testBuilder,
testFeature,
testTenant,
testproject,
} from "../testBuilder";
import { screenshotBuilder, setup } from "./utils";

export async function generate() {
const { page, browser } = await setup(true);
const screenshot = screenshotBuilder("webhooks")(page);

await testBuilder()
.withTenant(
testTenant("bookstore")
.withProject(
testproject("website")
.withFeature(testFeature("comments"))
.withFeature(testFeature("summer-sales"))
)
.withProject(
testproject("stock").withFeature(testFeature("new-store-ui"))
)
)
.build(page);

await page.goto("http://localhost:3000/tenants/bookstore/webhooks");
await screenshot("webhook-page");
await page
.getByRole("button", {
name: "Create new webhook",
})
.click();
await screenshot("webhook-form");
await page.getByLabel("Name").fill("messaging-hook");
// TODO once react forms will be fiexed to allow id on these inputs
await page.keyboard.press("Tab");
await page.keyboard.press("Space");
await page.getByLabel("URL").fill("http://my-client-app/hooks");
await page.getByRole("button", { name: "Add header" }).click();
await page.getByLabel("header-0-name").fill("Authorization");
await page.getByLabel("header-0-value").fill("my-secret-authorization-value");
await page.getByRole("combobox", { name: "Features (project)" }).click();
await page.getByText("summer-sales (website)", { exact: true }).click();

await page.getByLabel("User", { exact: true }).focus();
await page.keyboard.press("Tab");
await page.keyboard.press("Space");
await page.getByLabel("Handlebar template").scrollIntoViewIfNeeded();
await page.getByLabel("Handlebar template").click();
await screenshot("webhook-handlebar-form");
await page
.getByRole("button", { name: "Test template" })
.scrollIntoViewIfNeeded();
await page.getByRole("button", { name: "Test template" }).click();
await screenshot("webhook-completed-form");
await page.getByRole("button", { name: "Save" }).click();

await browser.close();
}
8 changes: 4 additions & 4 deletions manual/.docusaurus/client-modules.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default [
require("/home/runner/work/izanami/izanami/manual/node_modules/infima/dist/css/default/default.css"),
require("/home/runner/work/izanami/izanami/manual/node_modules/@docusaurus/theme-classic/lib/prism-include-languages"),
require("/home/runner/work/izanami/izanami/manual/node_modules/@docusaurus/theme-classic/lib/nprogress"),
require("/home/runner/work/izanami/izanami/manual/src/css/custom.css"),
require("/Users/77199M/workspace/oss/izanami-v2/manual/node_modules/infima/dist/css/default/default.css"),
require("/Users/77199M/workspace/oss/izanami-v2/manual/node_modules/@docusaurus/theme-classic/lib/prism-include-languages"),
require("/Users/77199M/workspace/oss/izanami-v2/manual/node_modules/@docusaurus/theme-classic/lib/nprogress"),
require("/Users/77199M/workspace/oss/izanami-v2/manual/src/css/custom.css"),
];
Loading

0 comments on commit b07543b

Please sign in to comment.