Skip to content

Commit

Permalink
Merge branch 'main' into issues#680_ReOpen_2
Browse files Browse the repository at this point in the history
  • Loading branch information
v-hongli1 authored Nov 4, 2024
2 parents d6ecf42 + 3317017 commit e6e162a
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/quick-coins-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@azure-tools/cadl-ranch-dashboard": minor
---

Added number of scenarios under each row
5 changes: 5 additions & 0 deletions .changeset/witty-frogs-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@azure-tools/cadl-ranch-specs": patch
---

Fix Issue In Versioning\Removed.
2 changes: 1 addition & 1 deletion packages/cadl-ranch-dashboard/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@azure-tools/cadl-ranch-dashboard",
"private": true,
"version": "0.9.0",
"version": "0.10.0",
"description": "Cadl Ranch Dashboard website",
"main": "dist/index.js",
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FunctionComponent } from "react";
import { TreeTableRow } from "./types.js";
import { FunctionComponent, useMemo } from "react";
import { ManifestTreeNode, TreeTableRow } from "./types.js";
import { Button, Popover, PopoverSurface, PopoverTrigger, Title3, Tooltip } from "@fluentui/react-components";
import ReactMarkdown from "react-markdown";
import { ScenarioData } from "@azure-tools/cadl-ranch-coverage-sdk";
Expand All @@ -17,6 +17,7 @@ const INDENT_SIZE = 14;
export const RowLabelCell: FunctionComponent<RowLabelCellProps> = ({ row }) => {
const caret = row.hasChildren ? row.expanded ? <ChevronDown20Filled /> : <ChevronRight20Filled /> : null;
const marginLeft = row.depth * INDENT_SIZE;
const rowLabel = getLabelForRow(row);
return (
<td
css={[
Expand All @@ -42,7 +43,7 @@ export const RowLabelCell: FunctionComponent<RowLabelCellProps> = ({ row }) => {
flex: 1,
}}
>
{row.item.name}
{rowLabel}
</div>
<div css={{}}>
{row.item.scenario && <ScenarioInfoButton scenario={row.item.scenario} />}
Expand Down Expand Up @@ -98,3 +99,24 @@ const GotoSourceButton: FunctionComponent<ShowSourceButtonProps> = ({ scenario }
function getGithubLineNumber(value: number): `L${number}` {
return `L${value + 1}`;
}

function getLabelForRow(row: TreeTableRow): string {
return useMemo(() => {
const countLeafChildren = (node: ManifestTreeNode): number => {
if (Object.keys(node.children).length === 0) {
return 1;
}

return Object.values(node.children).reduce((acc, child) => acc + countLeafChildren(child), 0);
};

const { name } = row.item;

if (!row.hasChildren) {
return name;
}

const totalLeafChildren = countLeafChildren(row.item);
return `${name} (${totalLeafChildren} scenarios)`;
}, [row.item, row.hasChildren]);
}
43 changes: 43 additions & 0 deletions packages/cadl-ranch-specs/cadl-ranch-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -9160,6 +9160,49 @@ Expected request body:
{ "prop": "foo" }
```

### Versioning_Removed_modelV3

- Endpoint: `post /versioning/removed/api-version:{version}/v3`

path: "/versioning/removed/api-version[:]v1/v3"
Expected request body:

```json
{ "id": "123", "enumProp": "enumMemberV1" }
```

Expected response body:

```json
{ "id": "123", "enumProp": "enumMemberV1" }
```

path: "/versioning/removed/api-version[:]v2preview/v3"
Expected request body:

```json
{ "id": "123" }
```

Expected response body:

```json
{ "id": "123" }
```

path: "/versioning/removed/api-version[:]v2/v3"
Expected request body:

```json
{ "id": "123", "enumProp": "enumMemberV1" }
```

Expected response body:

```json
{ "id": "123", "enumProp": "enumMemberV1" }
```

### Versioning_Removed_v2

- Endpoint: `post /versioning/removed/api-version:{version}/v2`
Expand Down
70 changes: 67 additions & 3 deletions packages/cadl-ranch-specs/http/versioning/removed/main.tsp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import "@typespec/http";
import "@azure-tools/cadl-ranch-expect";
import "@typespec/versioning";
import "@azure-tools/typespec-azure-core";

using TypeSpec.Http;
using TypeSpec.Versioning;
using TypeSpec.Rest;

/**
* Test for the `@removed` decorator.
Expand All @@ -20,7 +22,7 @@ using TypeSpec.Versioning;
endpoint: url,

/**
* Need to be set as 'v1' or 'v2' in client.
* Need to be set as 'v1', 'v2preview' or 'v2' in client.
*/
version: Versions,
}
Expand All @@ -32,12 +34,17 @@ namespace Versioning.Removed;
*/
enum Versions {
/**
* The version v1.
* The original version v1.
*/
v1: "v1",

/**
* The version v2.
* The V2 Preview version.
*/
v2preview: "v2preview",

/**
* The latest version v2.
*/
v2: "v2",
}
Expand Down Expand Up @@ -66,13 +73,29 @@ model ModelV2 {
unionProp: UnionV2;
}

model ModelV3 {
id: string;

@removed(Versions.v2preview)
@added(Versions.v2)
enumProp: EnumV3;
}

enum EnumV2 {
@removed(Versions.v2)
enumMemberV1,

enumMemberV2,
}

enum EnumV3 {
@removed(Versions.v2preview)
@added(Versions.v2)
enumMemberV1,

enumMemberV2Preview,
}

@removed(Versions.v2)
union UnionV1 {
string,
Expand Down Expand Up @@ -123,3 +146,44 @@ interface InterfaceV1 {
@route("/v1")
v1InInterface(@body body: ModelV1): ModelV1;
}

/** This operation will pass different paths and different request bodies based on different versions. */
@scenario
@scenarioDoc("""
path: "/versioning/removed/api-version[:]v1/v3"
Expected request body:
```json
{ "id": "123", "enumProp": "enumMemberV1" }
```
Expected response body:
```json
{ "id": "123", "enumProp": "enumMemberV1" }
```
path: "/versioning/removed/api-version[:]v2preview/v3"
Expected request body:
```json
{ "id": "123"}
```
Expected response body:
```json
{ "id": "123"}
```
path: "/versioning/removed/api-version[:]v2/v3"
Expected request body:
```json
{ "id": "123", "enumProp": "enumMemberV1" }
```
Expected response body:
```json
{ "id": "123", "enumProp": "enumMemberV1" }
```
""")
@post
@route("/v3")
op modelV3(@body body: ModelV3): ModelV3;
47 changes: 47 additions & 0 deletions packages/cadl-ranch-specs/http/versioning/removed/mockapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,50 @@ Scenarios.Versioning_Removed_v2 = passOnSuccess({
},
kind: "MockApiDefinition",
});

Scenarios.Versioning_Removed_modelV3 = passOnSuccess({
uri: `/versioning/removed/api-version[:]v1/v3`,
method: "post",
request: {
body: {
id: "123",
enumProp: "enumMemberV1",
},
},
response: {
status: 200,
body: json({ id: "123", enumProp: "enumMemberV1" }),
},
kind: "MockApiDefinition",
});

Scenarios.Versioning_Removed_modelV3_V2 = passOnSuccess({
uri: `/versioning/removed/api-version[:]v2/v3`,
method: "post",
request: {
body: {
id: "123",
enumProp: "enumMemberV1",
},
},
response: {
status: 200,
body: json({ id: "123", enumProp: "enumMemberV1" }),
},
kind: "MockApiDefinition",
});

Scenarios.Versioning_Removed_modelV3_V2preview = passOnSuccess({
uri: `/versioning/removed/api-version[:]v2preview/v3`,
method: "post",
request: {
body: {
id: "123",
},
},
response: {
status: 200,
body: json({ id: "123" }),
},
kind: "MockApiDefinition",
});

0 comments on commit e6e162a

Please sign in to comment.