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

Add UI tests for TFC views #1468

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft

Add UI tests for TFC views #1468

wants to merge 15 commits into from

Conversation

dbanck
Copy link
Member

@dbanck dbanck commented Jun 5, 2023

  • Add vscode-extension-tester for UI tests
  • Ignore temporary test files
  • Mock projects response
  • WIP: Add TFC UI test

jpogran and others added 10 commits June 2, 2023 09:01
* Terraform Cloud Host Setting

Adds a setting for terraform.cloud.hostname and sets app.terraform.io as default value.

Closes #1398

* Implement Terraform Cloud Authentication Provider

This implements the `vscode.AuthenticationProvider` interface and creates a TFC specific provider. This handles listing existing sessions, creating and removing sessions.

Storing sessions/tokens will be improved by #1397. Currently it only securely stores the token. Future improvement can be done to prevent looking up user data every time the session is reloaded.

The TFC instance to target is defaulted to `app.terraform.io` with a configuration setting to override. This was added in #1398. Future work should discover whether detecting the TFC instance from the configuration available in the current working space is desirable.

One of the primary ways a user will trigger authentication will be through the VS Code Command palette commands, so #1399 is added here to finish out the login workflow.

This currently only supports one logged in user at a time. In the future, this may be extended to support multiple user tokens.

Closes #1396

* Remove type-cast for promise

* Update src/providers/authenticationProvider.ts

Co-authored-by: Daniel Banck <dbanck@users.noreply.github.com>

* Update package.json

Co-authored-by: Daniel Banck <dbanck@users.noreply.github.com>

* Update lockfile

---------

Co-authored-by: Daniel Banck <daniel@dbanck.de>
Co-authored-by: Daniel Banck <dbanck@users.noreply.github.com>
* Add allowSyntheticDefaultImports to TS options

We have to enable this to get proper types from Zodios.

This flag does not affect the JavaScript emitted by TypeScript,
it only for the type checking.

* eslint: Disable @typescript-eslint/naming-convention

* Introduce terraformCloud API client

* Add endpoint descriptions

* Add projects endpoint

* Add pagination to endpoints

* Enable filtering of workspaces

* Split endpoints into separate files

* Keep earlyApiClient as earlyApiClient to avoid confusion

* terraformCloud: add missing enums for run & workspace

* Address/update remaining TODOs

* Add a test mock server using msw

---------

Co-authored-by: Daniel Banck <daniel@dbanck.de>
* Store all session data in SecretStorage

---------

Co-authored-by: Daniel Banck <daniel@dbanck.de>
This adds a new view container for Terraform Cloud with two new views for Workspaces and Runs. A new icon is used for the view container. It uses the apiclient to pull workspace information and display it in the view.

It introduces a new command terraform.cloud.organization.picker and adds it to the login command. This command presents the user with a quickpick to choose an organization to view workspaces. After the user chooses the org, it populates a statusbar item with the organization and sets it in workspacestate. The workspace view uses that organization when querying TFC for workspaces.
* Implement basic TreeView provider for TFC runs

* Update src/providers/tfc/runProvider.ts

Co-authored-by: James Pogran <jpogran@outlook.com>

* package: Update command name

* Note TODO comment about ingress attributes

---------

Co-authored-by: James Pogran <jpogran@outlook.com>
This adds a new prompt when the login workflow is initiated that asks the user how they want to authenticate: from the terraform cli config file, generate a new token on the web, or enter it manually.

The user can choose to have the extension read the terraform cli configuration file for the token. This means the user can reuse tokens they already configured to use with TFC without having to copy paste or create new tokens.

This also adds a user prompt to open the TFC website to generate a user token. This reuses the terraform cli login page to prompt the user to generate a new token.

If the user selects to enter an existing token, a new prompt is opened where the user can enter the token.
This commit refreshes the runs view when refreshing the workspace view by adding a call to the runDataProvider.refresh when performing workspaceProvider.refresh.

If a user has selected a workspace, then refreshes the view, the selected workspace tree item is passed to the runDataProvider so that the runs for that workspace are refreshed.

If no workspace is selected, then the runDataProvider is passed undefined, which will clear it's view. The user can then select a workspace to view runs.
* Contribute new filter icon and command

* Add search query parameter to projects endpoint

* Implement project quick pick

* Improve error messages
This commit adds a command and button to the Workspace View to open the selected workspace in the system browser
@dbanck dbanck self-assigned this Jun 5, 2023
@dbanck dbanck changed the title f tfc test views Add UI tests for TFC views Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants