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

testing for vs code extension #1428

Closed
3 of 10 tasks
felixhaeberle opened this issue Oct 4, 2023 · 13 comments
Closed
3 of 10 tasks

testing for vs code extension #1428

felixhaeberle opened this issue Oct 4, 2023 · 13 comments
Assignees
Labels
scope: inlang/sherlock-vscode Related to source-code/ide-extension. type: improvement Something that can be improved.

Comments

@felixhaeberle
Copy link
Collaborator

felixhaeberle commented Oct 4, 2023

Problem

Currently, we lack a proper testing strategy for the vs code extension.

Context: We oftentimes get bugs or have misleading behavior because of changes we do which we can't properly test or it's simply too time-consuming to do so.

Expected behavior

We should implement a basic set of e2e tests that start the extension and test basic functionalities.

The scope of this e2e test should at least cover all the commands & decorations we have so far.

must-have tests for functionality:

  • load project
  • auto-gen project.inlang.json
  • message preview
  • edit message
  • extract message
  • open message in editor
  • display lint
  • display error

nice-to-have tests for functionality:

  • detect properties missing in plugin ("app.inlang.ideExtension")
  • display context tooltip

Tasks

  • Make E2E run on Windows (Lots of uncertainty, but probably it's not much work left: ~4h): Used 0.75h
  • E2E test: load an example project and verify loading status (2h)
  • E2E test: edit a message (2h)
  • Unit test: auto-gen project.inlang.json (1h)
  • Unit test: message preview (hard to estimate, because I don't know how difficult it is to mock into the tooltip rendering and snapshot the HTML there: ~4h)
  • Unit test: edit message (0.5h)
  • Unit test: extract message (0.5h)
  • Unit test: open message in editor (0.5h)
  • Unit test: display lint (1h)
  • Unit test: display error (1h)

Other information

cc @openscript What do you think? What is your estimate & how would you test the vs code extension?

@felixhaeberle felixhaeberle added type: improvement Something that can be improved. scope: inlang/sherlock-vscode Related to source-code/ide-extension. priority: medium labels Oct 4, 2023
@openscript
Copy link
Contributor

openscript commented Oct 4, 2023

Everything which can be tested with unit tests should be unit tests. E2E tests are expensive: more work to create, harder to maintain, take longer to execute, ...

I would go for an incomplete set of E2E tests (smoke testing alike):

  1. Load a project
  2. Edit a message

The rest I would do as unit tests (with quite some vscode mocking). If we find out, that some features we should have tested E2E, we can add it later on.

What do you think @felixhaeberle ?

@felixhaeberle
Copy link
Collaborator Author

@openscript You're right! Let's go for the minimal amount of e2e & test the rest with unit tests 👍

@openscript
Copy link
Contributor

openscript commented Oct 5, 2023

  • Make E2E run on Windows (Lots of uncertainty, but probably it's not much work left: ~4h): Used 0.75h
  • E2E test: load an example project and verify loading status (2h)
  • E2E test: edit a message (2h)
  • Unit test: auto-gen project.inlang.json (1h)
  • Unit test: message preview (hard to estimate, because I don't know how difficult it is to mock into the tooltip rendering and snapshot the HTML there: ~4h)
  • Unit test: edit message (0.5h)
  • Unit test: extract message (0.5h)
  • Unit test: open message in editor (0.5h)
  • Unit test: display lint (1h)
  • Unit test: display error (1h)

Worst case estimate is about 16.5 hours.

@felixhaeberle
Copy link
Collaborator Author

felixhaeberle commented Oct 5, 2023

@openscript Go for it 👍

@felixhaeberle felixhaeberle changed the title testing strategy for vs code extension testing for vs code extension Oct 5, 2023
@openscript
Copy link
Contributor

ETA: 16th of October

@openscript openscript linked a pull request Oct 13, 2023 that will close this issue
@openscript
Copy link
Contributor

New ETA: 24th of October

@openscript
Copy link
Contributor

openscript commented Oct 25, 2023

There is no public API to access/read decorations, hence it's difficult to test this in an e2e scenario:
https://stackoverflow.com/questions/60989904/how-to-get-current-list-of-decorations-or-handle-decoration-position-change-in-v
microsoft/vscode#54147

@openscript
Copy link
Contributor

Without additional tools it's not possible to write proper E2E tests for Visual Studio Code. We need to access the UI renderer and internal API (like notifications). The guide from the VSCode project itself doesn't cover this: https://code.visualstudio.com/api/working-with-extensions/testing-extension

I've found these tools to achieve this:

We need this, for the very basic tests like "E2E test: load an example project and verify loading status". The setup of this tools will take 2-3 hours.

@openscript
Copy link
Contributor

Interesting talk about this topic:

https://www.youtube.com/watch?v=PhGNTioBUiU

@openscript
Copy link
Contributor

Status update:

The last two weeks I tried to get E2E testing up and running, but so far I didn't complete this part. Microsoft provides @vscode/test-electron, which helps you to download VSCode and run an instance of it for you tests. Unfortunately @vscode/test-electron doesn't include something, to put VSCode on a workbench and assert its reactions, like when the extension trigger a notification, to assert if the notification really happened.

There are two projects that try to fill this gap:

I went with wdio-vscode-service. It didn't work behind proxy, so I created a custom version. I got a simple "hello world" test running, but I have strange typing errors, which persist until today:

image
image

To proceed with wdio-vscode-service we need to:

  • Resolve the typing problems
  • Change the build.js script
  • Find out how to make it load an example project
  • Write tests

@openscript
Copy link
Contributor

Hi @felixhaeberle

This week I've invested 15h into the E2E tests, but I couldn't produce resilient tests, which work with Github Actions. All my tinkering is here #1795.

Along the way there were already several issues:

How should we proceed? I still think E2E tests are very valuable, as with unit testing we cannot catch things like #1803, but I'm not sure if it's worth to put somebodies main focus on this right now.

@felixhaeberle
Copy link
Collaborator Author

we will introduce high(er) coverage of unit testing with #1876, so closing when merged. going forward, unit testing will be a continuous effort.

@samuelstroschein
Copy link
Member

closing as stale / likely has a duplicate in linear

@samuelstroschein samuelstroschein closed this as not planned Won't fix, can't repro, duplicate, stale Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: inlang/sherlock-vscode Related to source-code/ide-extension. type: improvement Something that can be improved.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants