Skip to content

Add page object for WebviewView#855

Merged
djelinek merged 1 commit intoredhat-developer:mainfrom
datho7561:804-webview-view
Oct 11, 2023
Merged

Add page object for WebviewView#855
djelinek merged 1 commit intoredhat-developer:mainfrom
datho7561:804-webview-view

Conversation

@datho7561
Copy link
Copy Markdown
Contributor

@datho7561 datho7561 commented Jun 15, 2023

Fixes #804

Signed-off-by: David Thompson davthomp@redhat.com

Before submitting your PR, please review the following checklist:

  • CONSIDER adding a new test if your PR resolves an issue.
  • DO keep pull requests small so they can be easily reviewed.
  • DO make sure tests pass.
  • DO make sure any public APIs changes are documented.
  • DO make sure not to introduce any compiler warnings.

Before merging the PR:

  • CHECK continous integration of main branch is green.
  • CHECK pull request check job is green.
  • CHECK all pull request questions/requests are resolved.
  • WAIT till PR is approved by at least 1 committer.

@datho7561
Copy link
Copy Markdown
Contributor Author

@djelinek If you have time, could you please review this PR?

Also, where should I document the API change? It seems it's documented in the GitHub wiki, so should I make changes t the wiki directly, and if so, should I do this before/after the PR is merged?

@mlorinc
Copy link
Copy Markdown
Contributor

mlorinc commented Jun 16, 2023

Thank you for your contribution.

I just want to point out that, with this PR the tester will have 2 WebView page objects which raises the question whether it is really needed to have 2 page objects of the same kind. I do not mind doing semver major changes if it will improve WebView API.

What do you think @datho7561 @djelinek?

@datho7561
Copy link
Copy Markdown
Contributor Author

You're right, this page object can also be used with the editor webviews. However, the editor webview page object has a mechanism to ensure that the webview you are accessing is the intended one when there are mulitple webviews being displayed. I expect if you have an editor webview and a panel webview open, then my WebviewView implementation would sometimes access the editor webview.

I'll see if I can add a similar mechanism to prevent the WebviewView from accessing editor webviews.

@datho7561
Copy link
Copy Markdown
Contributor Author

I can't seem to find a similar aria-flowto attribute defined on VS Code's div representing the panel, I'll do a bit more investigation though.

datho7561 added a commit to datho7561/vscode-openshift-tools that referenced this pull request Jun 21, 2023
It's a webview, since we need to use either a treeview or webview for all
panels.
It wraps xtermjs, the same library VS Code uses for its terminal.
It exposes an API for interacting with the terminal multiplexer, as well
as with the individual running processes.
For example, we can run `odo dev` and update the UI
(like we were doing before this PR).

What's missing:
- [ ] copy/paste
- [ ] Tests (pending on redhat-developer/vscode-extension-tester#855)
- [ ] reordering the tabs (I think we should gauge interest and save this for a future PR)
- [ ] tab bar scrolling (supposedly the Material UI component comes with
      this built it, but it wasn't working when I tested it)

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/vscode-openshift-tools that referenced this pull request Jun 22, 2023
It's a webview, since we need to use either a treeview or webview for all
panels.
It wraps xtermjs, the same library VS Code uses for its terminal.
It exposes an API for interacting with the terminal multiplexer, as well
as with the individual running processes.
For example, we can run `odo dev` and update the UI
(like we were doing before this PR).

What's missing:
- [ ] copy/paste
- [ ] Tests (pending on redhat-developer/vscode-extension-tester#855)
- [ ] reordering the tabs (I think we should gauge interest and save this for a future PR)
- [ ] tab bar scrolling (supposedly the Material UI component comes with
      this built it, but it wasn't working when I tested it)

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/vscode-openshift-tools that referenced this pull request Jun 22, 2023
It's a webview, since we need to use either a treeview or webview for all
panels.
It wraps xtermjs, the same library VS Code uses for its terminal.
It exposes an API for interacting with the terminal multiplexer, as well
as with the individual running processes.
For example, we can run `odo dev` and update the UI
(like we were doing before this PR).

What's missing:
- [ ] copy/paste
- [ ] Tests (pending on redhat-developer/vscode-extension-tester#855)
- [ ] reordering the tabs (I think we should gauge interest and save this for a future PR)
- [ ] tab bar scrolling (supposedly the Material UI component comes with
      this built it, but it wasn't working when I tested it)

Signed-off-by: David Thompson <davthomp@redhat.com>
@djelinek djelinek self-requested a review June 23, 2023 18:45
datho7561 added a commit to datho7561/vscode-openshift-tools that referenced this pull request Jun 28, 2023
It's a webview, since we need to use either a treeview or webview for all
panels.
It wraps xtermjs, the same library VS Code uses for its terminal.
It exposes an API for interacting with the terminal multiplexer, as well
as with the individual running processes.
For example, we can run `odo dev` and update the UI
(like we were doing before this PR).

What's missing:
- [ ] copy/paste
- [ ] Tests (pending on redhat-developer/vscode-extension-tester#855)
- [ ] reordering the tabs (I think we should gauge interest and save this for a future PR)
- [ ] tab bar scrolling (supposedly the Material UI component comes with
      this built it, but it wasn't working when I tested it)

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/vscode-openshift-tools that referenced this pull request Jun 28, 2023
It's a webview, since we need to use either a treeview or webview for all
panels.
It wraps xtermjs, the same library VS Code uses for its terminal.
It exposes an API for interacting with the terminal multiplexer, as well
as with the individual running processes.
For example, we can run `odo dev` and update the UI
(like we were doing before this PR).

What's missing:
- [ ] copy/paste
- [ ] Tests (pending on redhat-developer/vscode-extension-tester#855)
- [ ] reordering the tabs (I think we should gauge interest and save this for a future PR)
- [ ] tab bar scrolling (supposedly the Material UI component comes with
      this built it, but it wasn't working when I tested it)

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/vscode-openshift-tools that referenced this pull request Jun 29, 2023
It's a webview, since we need to use either a treeview or webview for all
panels.
It wraps xtermjs, the same library VS Code uses for its terminal.
It exposes an API for interacting with the terminal multiplexer, as well
as with the individual running processes.
For example, we can run `odo dev` and update the UI
(like we were doing before this PR).

What's missing:
- [ ] copy/paste
- [ ] Tests (pending on redhat-developer/vscode-extension-tester#855)
- [ ] reordering the tabs (I think we should gauge interest and save this for a future PR)
- [ ] tab bar scrolling (supposedly the Material UI component comes with
      this built it, but it wasn't working when I tested it)

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/vscode-openshift-tools that referenced this pull request Jun 29, 2023
It's a webview, since we need to use either a treeview or webview for all
panels.
It wraps xtermjs, the same library VS Code uses for its terminal.
It exposes an API for interacting with the terminal multiplexer, as well
as with the individual running processes.
For example, we can run `odo dev` and update the UI
(like we were doing before this PR).

What's missing:
- [ ] copy/paste
- [ ] Tests (pending on redhat-developer/vscode-extension-tester#855)
- [ ] reordering the tabs (I think we should gauge interest and save this for a future PR)
- [ ] tab bar scrolling (supposedly the Material UI component comes with
      this built it, but it wasn't working when I tested it)

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/vscode-openshift-tools that referenced this pull request Jun 29, 2023
It's a webview, since we need to use either a treeview or webview for all
panels.
It wraps xtermjs, the same library VS Code uses for its terminal.
It exposes an API for interacting with the terminal multiplexer, as well
as with the individual running processes.
For example, we can run `odo dev` and update the UI
(like we were doing before this PR).

What's missing:
- [ ] copy/paste
- [ ] Tests (pending on redhat-developer/vscode-extension-tester#855)
- [ ] reordering the tabs (I think we should gauge interest and save this for a future PR)
- [ ] tab bar scrolling (supposedly the Material UI component comes with
      this built it, but it wasn't working when I tested it)

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/vscode-openshift-tools that referenced this pull request Jul 12, 2023
It's a webview, since we need to use either a treeview or webview for all
panels.
It wraps xtermjs, the same library VS Code uses for its terminal.
It exposes an API for interacting with the terminal multiplexer, as well
as with the individual running processes.
For example, we can run `odo dev` and update the UI
(like we were doing before this PR).

What's missing:
- [ ] copy/paste
- [ ] Tests (pending on redhat-developer/vscode-extension-tester#855)
- [ ] reordering the tabs (I think we should gauge interest and save this for a future PR)
- [ ] tab bar scrolling (supposedly the Material UI component comes with
      this built it, but it wasn't working when I tested it)

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/vscode-openshift-tools that referenced this pull request Jul 13, 2023
It's a webview, since we need to use either a treeview or webview for all
panels.
It wraps xtermjs, the same library VS Code uses for its terminal.
It exposes an API for interacting with the terminal multiplexer, as well
as with the individual running processes.
For example, we can run `odo dev` and update the UI
(like we were doing before this PR).

What's missing:
- [ ] copy/paste
- [ ] Tests (pending on redhat-developer/vscode-extension-tester#855)
- [ ] reordering the tabs (I think we should gauge interest and save this for a future PR)
- [ ] tab bar scrolling (supposedly the Material UI component comes with
      this built it, but it wasn't working when I tested it)

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/vscode-openshift-tools that referenced this pull request Jul 13, 2023
It's a webview, since we need to use either a treeview or webview for all
panels.
It wraps xtermjs, the same library VS Code uses for its terminal.
It exposes an API for interacting with the terminal multiplexer, as well
as with the individual running processes.
For example, we can run `odo dev` and update the UI
(like we were doing before this PR).

What's missing:
- [ ] copy/paste
- [ ] Tests (pending on redhat-developer/vscode-extension-tester#855)
- [ ] reordering the tabs (I think we should gauge interest and save this for a future PR)
- [ ] tab bar scrolling (supposedly the Material UI component comes with
      this built it, but it wasn't working when I tested it)

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to redhat-developer/vscode-openshift-tools that referenced this pull request Jul 13, 2023
It's a webview, since we need to use either a treeview or webview for all
panels.
It wraps xtermjs, the same library VS Code uses for its terminal.
It exposes an API for interacting with the terminal multiplexer, as well
as with the individual running processes.
For example, we can run `odo dev` and update the UI
(like we were doing before this PR).

What's missing:
- [ ] copy/paste
- [ ] Tests (pending on redhat-developer/vscode-extension-tester#855)
- [ ] reordering the tabs (I think we should gauge interest and save this for a future PR)
- [ ] tab bar scrolling (supposedly the Material UI component comes with
      this built it, but it wasn't working when I tested it)

Signed-off-by: David Thompson <davthomp@redhat.com>
@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@djelinek djelinek added ready-for-review Pull Request is Ready for Review and removed no-pr-activity labels Aug 23, 2023
@datho7561 datho7561 marked this pull request as ready for review October 4, 2023 20:27
@datho7561
Copy link
Copy Markdown
Contributor Author

@djelinek I refactored the code to reduce code duplication. If you have time, could you please let me know what you think?

Comment thread page-objects/src/components/WebviewMixin.ts Outdated
Comment thread page-objects/src/components/bottomBar/WebviewView.ts Outdated
@djelinek
Copy link
Copy Markdown
Collaborator

djelinek commented Oct 6, 2023

another point, the test for the WebviewView component is not working standalone, just in whole pipeline.. which is interesting.. need take a look more closer

Comment thread test/test-project/src/test/bottomBar/webviewView-test.ts Outdated
Comment thread page-objects/src/components/bottomBar/WebviewView.ts Outdated
@datho7561
Copy link
Copy Markdown
Contributor Author

I can't seem to run the tests locally, I get:

 1) "before all" hook in "{root}":
     Error: Server terminated early with status 126

@djelinek
Copy link
Copy Markdown
Collaborator

djelinek commented Oct 9, 2023

I can't seem to run the tests locally, I get:

 1) "before all" hook in "{root}":
     Error: Server terminated early with status 126

do you have more from console log please?

@datho7561
Copy link
Copy Markdown
Contributor Author

datho7561 commented Oct 10, 2023

full output of npm test
❯ npm test

> vscode-extension-tester@5.9.1 test
> npm run build && npm run prepare-test && cd test/test-project && npm run ui-test


> vscode-extension-tester@5.9.1 prebuild
> npm run prepare-deps


> vscode-extension-tester@5.9.1 prepare-deps
> npm run build-page-objects && npm run build-locators


> vscode-extension-tester@5.9.1 build-page-objects
> cd page-objects && npm i && npm run build


up to date, audited 306 packages in 709ms

75 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

> monaco-page-objects@3.9.1 build
> rimraf out/ && tsc


> vscode-extension-tester@5.9.1 build-locators
> cd locators && npm i && npm run build


up to date, audited 306 packages in 642ms

75 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

> vscode-extension-tester-locators@3.7.1 build
> rimraf out/ && tsc


> vscode-extension-tester@5.9.1 build
> npm link ./page-objects ./locators && rimraf out/ && tsc && chmod a+x ./out/cli.js


up to date, audited 306 packages in 781ms

75 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

> vscode-extension-tester@5.9.1 prepare-test
> cd test/test-project && npm install && rimraf package-lock.json


up to date, audited 571 packages in 4s

113 packages are looking for funding
  run `npm fund` for details

4 vulnerabilities (2 moderate, 2 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

> test-project@0.0.1 ui-test
> npm run cb-init && extest setup-and-run './out/src/test/cli/order-3-test.js' './out/src/test/cli/order-2-test.js' './out/src/test/cli/order-1-test.js' './out/src/test/**/*-test.js' './out/src/test/system/clipboard.test.js' -u -i -r . -e ./test-extensions


> test-project@0.0.1 cb-init
> echo hello_ExTester | clipboard

Downloading VSCode: 1.83.0 / stable
VS Code exists in local cache, skipping download
Downloading ChromeDriver 114.0.5735.90 from: https://chromedriver.storage.googleapis.com/114.0.5735.90/chromedriver_linux64.zip
progress: 0/7407250 (0%)
progress: 7407250/7407250 (100%)
Unpacking ChromeDriver 114.0.5735.90 into /home/davthomp/Documents/Projects/vscode-extension-tester/test/test-project/test-resources
Success!
Executing prepublish script 'npm run vscode:prepublish'...

> test-project@0.0.1 vscode:prepublish
> npm run compile


> test-project@0.0.1 compile
> rimraf out && tsc -p ./ && npm run lint


> test-project@0.0.1 lint
> eslint src --ext .ts

 DONE  Packaged: /home/davthomp/Documents/Projects/vscode-extension-tester/test/test-project/test-project-0.0.1.vsix (103 files, 276.49KB)
Installing extensions...
(node:77742) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `code --trace-deprecation ...` to show where the warning was created)
Extension 'test-project-0.0.1.vsix' was successfully installed.
Loading mocha configuration from /home/davthomp/Documents/Projects/vscode-extension-tester/test/test-project/.mocharc.js


Writing code settings to /home/davthomp/Documents/Projects/vscode-extension-tester/test/test-project/test-resources/settings/User/settings.json
Launching browser...
  1) "before all" hook in "{root}"
  2) "after all" hook in "{root}"

  0 passing (18ms)
  2 failing

  1) "before all" hook in "{root}":
     Error: Server terminated early with status 126
      at /home/davthomp/Documents/Projects/vscode-extension-tester/node_modules/selenium-webdriver/remote/index.js:259:24
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

  2) "after all" hook in "{root}":
     TypeError: Cannot read properties of undefined (reading 'manage')
      at VSBrowser.<anonymous> (/home/davthomp/Documents/Projects/vscode-extension-tester/out/browser.js:153:48)
      at Generator.next (<anonymous>)
      at /home/davthomp/Documents/Projects/vscode-extension-tester/out/browser.js:31:71
      at new Promise (<anonymous>)
      at __awaiter (/home/davthomp/Documents/Projects/vscode-extension-tester/out/browser.js:27:12)
      at VSBrowser.quit (/home/davthomp/Documents/Projects/vscode-extension-tester/out/browser.js:152:16)
      at Context.<anonymous> (/home/davthomp/Documents/Projects/vscode-extension-tester/out/suite/runner.js:108:35)
      at Generator.next (<anonymous>)
      at /home/davthomp/Documents/Projects/vscode-extension-tester/out/suite/runner.js:31:71
      at new Promise (<anonymous>)
      at __awaiter (/home/davthomp/Documents/Projects/vscode-extension-tester/out/suite/runner.js:27:12)
      at Context.<anonymous> (/home/davthomp/Documents/Projects/vscode-extension-tester/out/suite/runner.js:106:24)

@djelinek
Copy link
Copy Markdown
Collaborator

full output of npm test

❯ npm test



> vscode-extension-tester@5.9.1 test

> npm run build && npm run prepare-test && cd test/test-project && npm run ui-test



@datho7561 which version of NodeJS are you using?

@datho7561
Copy link
Copy Markdown
Contributor Author

❯ node --version
v18.17.1
❯ npm --version
9.6.7

Okay. It seems like the version I'm using is too new. I'll try the version listed in the README.

@datho7561
Copy link
Copy Markdown
Contributor Author

I can reproduce the failure. I'm working on fixing it.

@datho7561 datho7561 force-pushed the 804-webview-view branch 3 times, most recently from 978527b to 81d1d32 Compare October 10, 2023 21:31
@datho7561
Copy link
Copy Markdown
Contributor Author

Okay, I wrote a better selector for the webviewview iframe, and added a new entry to the locators package for it.

Copy link
Copy Markdown
Collaborator

@djelinek djelinek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, working as expected

good job, thank you @datho7561 !

Comment thread wiki/WebviewView.md Outdated
Fixes redhat-developer#804

Signed-off-by: David Thompson <davthomp@redhat.com>
@sonarqubecloud
Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@djelinek djelinek self-requested a review October 11, 2023 14:18
@djelinek djelinek added the ready-for-review Pull Request is Ready for Review label Oct 11, 2023
@djelinek djelinek merged commit b423d76 into redhat-developer:main Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Pull Request is Ready for Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🚀 Request] Access WebView in BottomBar

3 participants