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

Added test plan for TypeSpec extension #5552

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# Create TypeSpec Project from A Template Test Scenario

New TypeSpec projects can be created using a variety of templates for specific purposes. TypeSpec supports the following non-branded templates:

* Empty Project
* Generic REST API
* TypeSpec Library (with TypeScript)
* TypeSpec Emitter (with TypeScript)

Selecting a template involves:

* Installing required libraries
* Initializing essential project files with a specified folder structure
* Configuring output settings for a designated emission purpose


## Test Environment

* OS : Windows or Linux
* Template : Empty Project, Generic REST API, TypeSpec Library (with TypeScript), TypeSpec Emitter (with TypeScript)

> Note: The extension should support all test cases in VS Code for Windows and Linux. Mac support is a stretch goal for Selenium semester.

## Prerequisites

Install TypeSpec Compiler before starting to write TypeSpec.

* [Node.js 20+](https://nodejs.org/download/)
* Npm 7+
* [Install TypeSpec Compiler CLI](https://typespec.io/docs/): `"npm install -g @typespec/compiler"`

## Test Steps

### Step 1: Install the typespec extension.

_Option 1_. Install using .vsix file:
`Extension` -> `…` -> `Install form VSIX...`

![alt text](./images/InstallTypespec_VSIX.png)

Find the .vsix file you want to install locally.

![alt text](./images/InstallTypeSpec_SelectVSIXFileTest.png)

_Option 2_. Install typespec with vscode extension marketplace:
`Extension` -> input `TypeSpec for VS Code` -> `Install`

![alt text](./images/InstallTypespec_ExtensionMarketplaceTest01.png)

### Step 2: Trigger create TypeSpec Project

_Option 1_. Clicking “Create TypeSpec Project” button/link in the “No Folder Opened” View of Explore.

![alt text](./images/TriggerCreateTypeSpecProject_NoFolderOpened.png)

_Option 2_. Typing `> TypeSpec: Create TypeSpec Project` in the _Command Palette_.

![alt text](./images/TriggerCreateTypeSpecProject_CommandPalette.png)

### Step 3. Select an empty folder as the root folder for the new TypeSpec project.

![alt text](./images/CreateTypeSpecProject_SelectFolderTest.png)

### Step 4. Check if TypeSpec Compiler CLI is install. (optional)

If the TypeSpec Compiler is not installed, the Quick Pick will initiate the installation of the TypeSpec Compiler. If TypeSpec Compiler is installed, Skip to the next step.

![alt text](./images/CreateTypeSpecProject_InstallTypeSpecCompiler.png)

### Step 5. After successfully installing TypeSpec Compiler, will go through the questions of `tsp init`.

1. If the specified folder is not empty, it will prompt `Folder C:\xxx\xxx\xxx is not empty. Are you sure you want to initialize a new project here?`. If the folder is empty, skip to the next step. _(optional)_

  **Validate:** Will it appear: `Folder C:\xxx\xxx\xxx is not empty. Are you sure you want to initialize a new project here?`

  ![alt text](./images/CreateTypeSpecProject_VerifyFolderIsEmpty.png)

2. Select a template _(Single choice)_.

  **Validate:** There should be a prompt "Select a template", and should see four options: `Empty project`, `Generic REST API`, `TypeSpec Library (With TypeScript)`, `TypeSpec Emitter (With TypeScript)`.

  ![alt text](./images/CreateTypeSpecProject_SelectTemplate.png)

3. Input project name - _(Text input)_ by default, it is the project root folder name..

![alt text](./images/CreateTypeSpecProject_InputProjectName.png)

4. Choose whether to generate a .ignore file. _(Single choice)_ `Y/N`

![alt text](./images/CreateTypeSpecProject_Generate_ignoreFile.png)

5. Select libraries to update. _(Multiple choice)_

> Note: Select libraries to update is required only when you select `Generic REST API`. This step will not appear if you select other templates.

![alt text](./images/CreateTypeSpecProject_InstallOrUpdateLibraries.png)

6. Click `OK` and the project will be created, the folder structure will be set up, dependencies will be installed, and tspconfig.yaml will be updated..

**Validate:** Verify that the project was created correctly and the dependencies are installed.

- Install Dependencies

![alt text](./images/CreateTypeSpecProject_InstallDependencies.png)

- Folder structure

- For `Empty project`, the folder structure.

![alt text](./images/CreateTypeSpecProject_CreateSucceedFolder_EmptyProject.png)

- For `Generic REST API`, the folder structure.

![alt text](./images/CreateTypeSpecProject_CreateSucceedFolder_GenericRESTAPI.png)

- For `TypeSpec Library (With TypeScript)`, the folder structure.

![alt text](./images/CreateTypeSpecProject_CreateSucceedFolder_TypeSpecLibrary.png)

- For `TypeSpec Emitter (With TypeScript)`, the folder structure.

![alt text](./images/CreateTypeSpecProject_CreateSucceedFolder_TypeSpecEmitter.png)

## Issue Report

When an error is detected, it’s necessary to document the findings by using the following form:

| No | Title | Template | Issue Description | Repro Steps | Expected Results | Actual Results | Comments |
| ---------| :--: | :--: | :--: | :--: | :--: | :--: | :--: |
| 1 | e.g. Create typespec project failed | Empty project / Generic REST API / TypeSpec Library (With TypeScript) / TypeSpec Emitter (With TypeScript) | Create project feature is not supported by the current TypeSpec Compiler (ver <= 0.63.0). Please upgrade TypeSpec Compiler and try again. | 1. Typing `>TypeSpec: Create TypeSpec Project` in the _Command Palette_. <br> 2. Select an empty folder as the root folder for the new TypeSpec project. <br> 3. Select a template. | There should be a prompt "Select a template", and should see four options: `Empty project`, `Generic REST API`, `TypeSpec Library (With TypeScript)`, `TypeSpec Emitter (With TypeScript)`. | Create project feature is not supported by the current TypeSpec Compiler (ver <= 0.63.0). Please upgrade TypeSpec Compiler and try again. | Issue link |

## Test Results Summary

The test results will be presented in the following form:

| NO | Test Cases | Platform | Template | Result | Issues | Comments |
| --------------- | :-: |:-: | :--: | :--: | :--: | :--: |
| 1 | Create TypeSpec Project from A Template | Windows/Linux | Empty project | | | |
| 2 | Create TypeSpec Project from A Template | Windows/Linux | Generic REST API | | | |
| 3 | Create TypeSpec Project from A Template | Windows/Linux | TypeSpec Library (With TypeScript) | | | |
| 4 | Create TypeSpec Project from A Template | Windows/Linux | TypeSpec Emitter (With TypeScript) | | | |
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Generate Client Code from TypeSpec Test Scenario

Generate client code from TypeSpec. In VS Code extension, we can complete code generation with step-by-step guidance.
TypeSpec Extension support will be extended to client code generation for first-class languages: `.NET`, `Python`, `Java`, and `JavaScript`.

**Important: There must be at least one TypeSpec project in the project folder.**

## Test Environment

* OS : Windows or Linux
* Language : Python, Java, JavaScript, .NET

> Note: The extension should support all test cases in VS Code for Windows and Linux. Mac support is a stretch goal for Selenium semester.

## Prerequisites

Install TypeSpec Compiler before starting to write TypeSpec.

* [Node.js 20+](https://nodejs.org/download/)
* Npm 7+
* [Install TypeSpec Compiler CLI](https://typespec.io/docs/): `"npm install -g @typespec/compiler"`

Install required SDK/runtime for executing the specified language:

* [.NET 8.0 SDK](https://dotnet.microsoft.com/en-us/download)
* [Java 11 or above](https://www.oracle.com/java/technologies/downloads/), and [Maven](https://maven.apache.org/download.cgi)
* [Python 3.8+](https://www.python.org/downloads/)
* [Node.js 20+](https://nodejs.org/download/)

## Test Steps

### Step 1: Install the typespec extension.

_Option 1_. Install using .vsix file:
`Extension` -> `…` -> `Install form VSIX...`

![alt text](./images/InstallTypespec_VSIX.png)

Find the .vsix file you want to install locally.

![alt text](./images/InstallTypeSpec_SelectVSIXFileTest.png)

_Option 2_. Install typespec with vscode extension marketplace:
`Extension` -> input `TypeSpec for VS Code` -> `Install`

![alt text](./images/InstallTypespec_ExtensionMarketplaceTest01.png)

### Step 2: Trigger generate from TypeSpec

Generation from a TypeSpec can be triggered in two ways:

_Option 1_. Clicking `Generate from TypeSpec` in the _Context Menu_ for a .tsp file in the extended TypeSpec project.

![alt text](./images/TriggerGeneratefromTypeSpec_ContextMenu.png)

_Option 2_. Typing `>TypeSpec: Generate from TypeSpec` in the _Command Palette_ with at least a TypeSpec project folder extended in the _Side Bar_.

![alt text](./images/TriggerGeneratefromTypeSpec_CommandPalette.png)

### Step 3: Click the command `TypeSpec: Generate from TypeSpec`, and choose a project.

**Validate:** There should be a prompt "Select a Typespec Project".

![alt text](./images/GeneratefromTypeSpec_SelectTypespecProject.png)

### Step 4: Select an Emitter Type.

**Validate:** There should be a prompt "Select an Emitter Type", and should see three emitter types: `Client Code`, `<PREVIEW> Server Stub`, `Protocal Schema`.

![alt text](./images/GeneratefromTypeSpec_SelectEmitter_client.png)

### Step 5: Click `Client Code`.

**Validate:** There should be a prompt "Select a Language", and should see four languages: `DotNet`, `Java`, `JavaScript`, `Python`.

![alt text](./images/GeneratefromTypeSpec_SelectClientLanguage.png)

### Step 6: Select a Language, confirm the TypeSpec emitters you want to install and their minimum requirements.

**Validate:** There should be a prompt `Here are libraries to install or update`, and TypeSpec emitters to install and their minimum requirements.

![alt text](./images/GenerateClientCode_ConfirmTypeSpecEmitters.png)

### Step 7: Initiate the generation of client code on the backend.

**Validate:** The emitter package is already installed and the client folder is generated. The result appears in the lower right corner as a notification.

- For `DotNet`:

![alt text](./images/GenerateClientCode_VerifyInstallEmitter_DotNet.png)
![alt text](./images/GenerateClientCode_VerifyGenerateSuccessful_DotNet.png)
![alt text](./images/GenerateClientCode_VerifyGenerateCodeSucceeded_DotNet.png)

- For `Java`:

![alt text](./images/GenerateClientCode_VerifyInstallEmitter_Java.png)
![alt text](./images/GenerateClientCode_VerifyGenerateSuccessful_Java.png)
![alt text](./images/GenerateClientCode_VerifyGenerateCodeSucceeded_Java.png)

- For `JavaScript`:

![alt text](./images/GenerateClientCode_VerifyInstallEmitter_JS.png)
![alt text](./images/GenerateClientCode_VerifyGenerateSuccessful_JS.png)
![alt text](./images/GenerateClientCode_VerifyGenerateCodeSucceeded_JS.png)

- For `Python`:

![alt text](./images/GenerateClientCode_VerifyInstallEmitter_Python.png)
![alt text](./images/GenerateClientCode_VerifyGenerateSuccessful_Python.png)
![alt text](./images/GenerateClientCode_VerifyGenerateCodeSucceeded_Python.png)

## Issue Report

When an error is detected, it’s necessary to document the findings by using the following form:

| No | Title | Emitter Type | Language | Issue Description | Repro Steps | Expected Results | Actual Results | Comments |
| ---------| :--: | :-: | :--: | :--: | :--: | :--: | :--: | :--: |
| 1 | e.g. Generate Client Code failed | Client Code | DotNet/ Java / JavaScript / Python | Exception occurred when generating client code for JavaScript. | 1. Typing `>TypeSpec: Generate from TypeSpec` in the _Command Palette_. <br> 2. choose a project. <br> 3. Select a template. <br> 4. Select an Emitter Type. <br> 5. Select a Language.| Generate client code for JavaScript ...Succeeded. | Exception occurred when generating client code for JavaScript. | Issue link |

## Test Results Summary

The test results will be presented in the following form:

| NO | Test Cases | Platform | Language | Result | Issues | Comments |
| --------------- | :-: |:-: | :--: | :--: | :--: | :--: |
| 1 | Generate Client Code from TypeSpec | Windows/Linux | Python | | | |
| 2 | Generate Client Code from TypeSpec | Windows/Linux | Java | | | |
| 3 | Generate Client Code from TypeSpec | Windows/Linux | .NET | | | |
| 4 | Generate Client Code from TypeSpec | Windows/Linux | JavaScript | | | |
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Generate OpenAPI 3.x from TypeSpec Test Scenario

Emit OpenAPI3 from TypeSpec to automate API-related tasks: generate API documentation, test API, etc.
The TypeSpec file itself is not sufficient to generate OpenAPI 3. The conversion process will always reference the entry point (main.tsp) of the TypeSpec build, which includes the main definitions of models, services, and operations.

**Important: There must be at least one TypeSpec project in the project folder.**

## Test Environment

* OS : Windows or Linux
* Language : OpenAPI3

> Note: The extension should support all test cases in VS Code for Windows and Linux. Mac support is a stretch goal for Selenium semester.

## Prerequisites

Install TypeSpec Compiler before starting to write TypeSpec.

* [Node.js 20+](https://nodejs.org/download/)
* Npm 7+
* [Install TypeSpec Compiler CLI](https://typespec.io/docs/): `"npm install -g @typespec/compiler"`

## Test Steps

### Step 1: Install the typespec extension.

_Option 1_. Install using .vsix file:
`Extension` -> `…` -> `Install form VSIX...`

![alt text](./images/InstallTypespec_VSIX.png)

Find the .vsix file you want to install locally.

![alt text](./images/InstallTypeSpec_SelectVSIXFileTest.png)

_Option 2_. Install typespec with vscode extension marketplace:
`Extension` -> input `TypeSpec for VS Code` -> `Install`

![alt text](./images/InstallTypespec_ExtensionMarketplaceTest01.png)

### Step 2: Trigger generate from TypeSpec

Generation from a TypeSpec can be triggered in two ways:

_Option 1_. Clicking `Generate from TypeSpec` in the _Context Menu_ for a .tsp file in the extended TypeSpec project.

![alt text](./images/TriggerGeneratefromTypeSpec_ContextMenu.png)

_Option 2_. Typing `>TypeSpec: Generate from TypeSpec` in the _Command Palette_ with at least a TypeSpec project folder extended in the _Side Bar_.

![alt text](./images/TriggerGeneratefromTypeSpec_CommandPalette.png)

### Step 3: Click the command `TypeSpec: Generate from TypeSpec`, and choose a project.

**Validate:** There should be a prompt "Select a Typespec Project".

![alt text](./images/GeneratefromTypeSpec_SelectTypespecProject.png)

### Step 4: Select an Emitter Type.

**Validate:** There should be a prompt "Select an Emitter Type", and should see three emitter types: `Client Code`, `<PREVIEW> Server Stub`, `Protocal Schema`.

![alt text](./images/GeneratefromTypeSpec_SelectEmitter_OpenAPI.png)

### Step 5: Click `Protocal Schema`.

**Validate:** There should be a prompt "Select a Language", and should see languages: `OpenAPI3`.

![alt text](./images/GeneratefromTypeSpec_SelectOpenAPILanguage.png)

### Step 6: Select a Language, confirming installation of the required TypeSpec library @typespec/openapi3.

**Validate**: There should be a prompt `Here are libraries to install or update`, and confirming installation of the required TypeSpec library @typespec/openapi3.

![alt text](./images/GenerateOpenAPI_ConfirmTypeSpecEmitters.png)

### Step 7: Initiate the generation of OpenAPI on the backend.

**Validate:** A detailed trace log should be printed in the OUTPUT window. The result appears as a Notification in the bottom right corner, and generate the schema folder.

![alt text](./images/GeneratefromTypeSpec_GenerateOpenAPIResult_prompt.png)
![alt text](./images/GeneratefromTypeSpec_GenerateOpenAPIResult_Folder.png)

If the OpenAPI 3 generation fails, the error message should indicate the root cause and suggest possible resolutions to continue.

![alt text](./images/GeneratefromTypeSpec_GenerateOpenAPIResult_Fail.png)

## Issue Report

When an error is detected, it’s necessary to document the findings by using the following form:

| No | Title | Emitter Type | Language | Issue Description | Repro Steps | Expected Results | Actual Results | Comments |
| ---------| :--: | :-: | :--: | :--: | :--: | :--: | :--: | :--: |
| 1 | e.g. Generate schema code failed | Protocal Schema | OpenAPI3 | Exception occurred when generating schema code for OpenAPI3. | 1. Typing `>TypeSpec: Generate from TypeSpec` in the _Command Palette_. <br> 2. choose a project. <br> 3. Select a template. <br> 4. Select an Emitter Type. <br> 5. Select a Language.| Generate schema code for OpenAPI3 ...Succeeded. | Exception occurred when generating schema code for OpenAPI3. | Issue link |

## Test Results Summary

The test results will be presented in the following form:

| NO | Test Cases | Platform | Language | Result | Issues | Comments |
| --------------- | :-: |:-: | :--: | :--: | :--: | :--: |
| 1 | Generate OpenAPI 3.x from TypeSpec Test Scenario | Windows/Linux | OpenAPI3 | | | |
Loading
Loading