Skip to content

Commit 48c7457

Browse files
committed
Update contributing documentation
Signed-off-by: David Thompson <davthomp@redhat.com>
1 parent ee83fee commit 48c7457

File tree

4 files changed

+84
-3
lines changed

4 files changed

+84
-3
lines changed

CONTRIBUTING.md

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,92 @@ There are only a few guidelines that we need contributors to follow.
4141

4242
* Any other changes should be recompiled automatically by the VS Code prelaunch task.
4343
* The launch will be prevented if there are compilation errors.
44-
4. Once the extension is installed and reloaded, there will be an OpenShift Icon on the View Container, on the lines of snap mentioned below.
44+
4. Once the extension is launched in debug mode, there will be an OpenShift icon in the Sidebar:
4545

4646
![View Container OpenShift](images/view-container-icon.png)
4747

48-
## Running the Integration Test Suite
48+
When you click on it, you should see the following view:
49+
50+
![The OpenShift sidebar. It contains five tree views: an application explorer for viewing information about the cluster, a components section, a section that lists devfile registries, a serverless functions section, and a debug section](images/openshift-sidebar-august2023.png)
51+
52+
## Debugging webviews
53+
54+
The first thing to note about webviews is that breakpoints set in VS Code in the webview code won't work.
55+
This is because the extension code and the webview JavaScript are run in separate processes.
56+
Any code in a `.tsx` file or under `./src/webview/common` is webview code.
57+
Note that not all the code under `./src/webview` is webview code;
58+
some of it is code used on the extension side in order to load and interact with the webview.
59+
60+
In order watch or inspect values in webview code,
61+
it's easiest to use `console.log()` statements.
62+
The output from these statements can be inspected by opening Chrome debug tools
63+
(by running the command "Developer: Toggle Developer Tools"),
64+
then selecting the "Console" tab.
65+
66+
![The Chrome debug tools, opened to the "Console" tab](images/chrome-devtools-console.png)
67+
68+
The Chrome debug tools can also be used to help with writing the layout of webviews.
69+
In order to inspect the layout, switch to the "Elements" view.
70+
Then, you will need to walk through the tree in order to locate the webview HTML.
71+
It should be nested in two `<iframe>` elements (in order to sandbox it from the rest of VS Code).
72+
It will look something like this:
73+
74+
![VS Code with the "Create Component" webview open. On the right, the Chrome debug tools are open, showing a tree that represents the HTML for the webview. In VS Code, the "Create Component" webview is highlighted in blue to indicate it's being hovered over in the Chrome debug tools HTML tree view](images/chrome-devtools-webview.png)
75+
76+
Then, you can modify the CSS and attributes of elements in order to experiment with the layout of the webview.
77+
78+
## Running the tests
79+
80+
### Running the unit test suite
81+
82+
You don't need to be connected to a cluster in order for the tests to work properly.
83+
In order to run the unit test suite, run:
84+
```
85+
npm test
86+
```
87+
88+
In order to run the UI test suite and collect test coverage information, run:
89+
90+
```
91+
npm run test:coverage
92+
```
93+
94+
### Running the UI tests
95+
96+
There are two sets of UI tests: ones that don't require a connection to a cluster,
97+
and ones that do require a connection to a cluster.
98+
99+
In order to run the UI tests that don't require a cluster,
100+
make sure that you aren't logged into any cluster by running `oc logout`,
101+
then run:
102+
103+
```
104+
npm run public-ui-test
105+
```
106+
107+
In order to run the cluster-dependant UI tests,
108+
you need an OpenShift cluster where you can create and delete projects.
109+
This means that OpenShift Developer Sandbox won't work.
110+
`minikube`, `kind`, and MicroShift clusters also won't work,
111+
since the UI tests some OpenShift-specific features,
112+
such as logging in to the cluster.
113+
The tests will create and delete resources on the cluster,
114+
so please make sure nothing important is running on the cluster.
115+
116+
Then, you need to configure the following environment variables to point to your cluster:
117+
- `CLUSTER_URL`: the URL pointing to the API of the cluster, defaults to `https://api.crc.testing:6443` (the default `crc` address)
118+
- `CLUSTER_USER`: the username to use to login to the cluster, defaults to `developer`
119+
- `CLUSTER_PASSWORD`: the password to use to login to the cluster, default to `developer`
120+
121+
Note that if you are running `crc`, the defaults should work.
122+
123+
Once, you've configured your cluster, run:
124+
125+
```
126+
npm run cluster-ui-test
127+
```
128+
129+
### Running the Integration Test Suite
49130
50131
In order to run the integration test suite, you need access to an OpenShift cluster
51132
where you can create and delete projects.
@@ -56,7 +137,7 @@ The tests will create and delete resources on the cluster,
56137
so please make sure nothing important is running on the cluster.
57138
58139
First, set the following environment variables to point the tests to your cluster:
59-
- `CLUSTER_URL`: the URL pointing to the API of the cluster, defaults to `https://192.168.130.11:6443` (the default `crc` IP address)
140+
- `CLUSTER_URL`: the URL pointing to the API of the cluster, defaults to `https://api.crc.testing:6443` (the default `crc` IP address)
60141
- `CLUSTER_USER`: the username to use to login to the cluster, defaults to `developer`
61142
- `CLUSTER_PASSWORD`: the password to use to login to the cluster, default to `developer`
62143

images/chrome-devtools-console.png

144 KB
Loading

images/chrome-devtools-webview.png

302 KB
Loading
62.4 KB
Loading

0 commit comments

Comments
 (0)