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

test: DH-18428: e2e tests #213

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
cache: 'npm'
- run: npm ci
- name: Run end-to-end tests
run: xvfb-run npm run test:e2e
run: xvfb-run npm run test:e2e:ci
- name: Publish Test Summary Results
if: ${{ always() }}
run: |
Expand Down
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "e2e Tests",
"request": "launch",
"runtimeArgs": [
"run-script",
"test:e2e",
"--",
"-s",
"--spec",
"${file}"
],
"runtimeExecutable": "npm",
"skipFiles": ["<node_internals>/**"],
"type": "node"
}
]
}
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ To run using `VS Code` debugger:
1. Set a breakpoint in a test
2. Either

Use the `e2e Tests` launch config.

or

Enable auto attach with flag (`Command palette -> Debug: Toggle Auto Attach -> Only With Flag`).

> Note you may need to open a new terminal for this to take effect.
Expand All @@ -42,6 +46,12 @@ To run using `VS Code` debugger:
npm run test:e2e
```

or with flags

```sh
npm run test:e2e -- -s --spec test
```

4. You should see the tests start and `VS Code` stop at the breakpoint.

## VSCE
Expand Down
17 changes: 17 additions & 0 deletions e2e/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ARG NODE_VERSION=NOTAREALVERSION
FROM --platform=linux/amd64 node:$NODE_VERSION-alpine AS node

RUN node --version

# Package contents should change less frequently than the source code, so copy
# and install them in earlier layer
COPY package.json package-lock.json ./
RUN npm ci

# Copy code
COPY tsconfig.json tsconfig.unit.json ./
COPY e2e ./e2e
COPY src ./src
COPY scripts ./scripts

CMD ["npm", "run", "test:e2e"]
17 changes: 17 additions & 0 deletions e2e/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
services:
dhc-server:
container_name: dhc-server
image: ghcr.io/deephaven/server:${DHC_VERSION:-edge}
pull_policy: always
expose:
- 10000
environment:
- START_OPTS=-Xmx4g -DAuthHandlers=io.deephaven.auth.AnonymousAuthenticationHandler -Ddeephaven.console.type=python -Ddeephaven.application.dir=./data/app.d

e2e:
build:
context: ../
dockerfile: ./e2e/Dockerfile
depends_on:
dhc-server:
condition: service_healthy
143 changes: 143 additions & 0 deletions e2e/specs/__snapshots__/test.e2e.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
// Snapshot v1

exports[`panels > should open panels > 1: Tab groups - initial load 1`] = `
[
{
"group": 1,
"isSelected": true,
"text": "simple_ticking3.py",
},
{
"group": 2,
"isSelected": true,
"text": "test.py",
},
{
"group": 3,
"text": "t1",
},
{
"group": 3,
"text": "t2",
},
{
"group": 3,
"isSelected": true,
"text": "t3",
},
]
`;

exports[`panels > should open panels > 2: Tab groups - after clicking t1 1`] = `
[
{
"group": 1,
"isSelected": true,
"text": "simple_ticking3.py",
},
{
"group": 2,
"isSelected": true,
"text": "test.py",
},
{
"group": 3,
"isSelected": true,
"text": "t1",
},
{
"group": 3,
"text": "t2",
},
{
"group": 3,
"text": "t3",
},
]
`;

exports[`panels > should open panels > 3: Tab groups - re-run after closing t1 and t2 1`] = `
[
{
"group": 1,
"isSelected": true,
"text": "simple_ticking3.py",
},
{
"group": 2,
"isSelected": true,
"text": "test.py",
},
{
"group": 3,
"isSelected": true,
"text": "t3",
},
{
"group": 3,
"text": "t1",
},
{
"group": 3,
"text": "t2",
},
]
`;

exports[`panels > should open panels > 4: Tab groups - after dragging t1 to a new tab group 1`] = `
[
{
"group": 1,
"isSelected": true,
"text": "simple_ticking3.py",
},
{
"group": 2,
"isSelected": true,
"text": "test.py",
},
{
"group": 3,
"text": "t1",
},
{
"group": 3,
"isSelected": true,
"text": "t2",
},
{
"group": 4,
"isSelected": true,
"text": "t3",
},
]
`;

exports[`panels > should open panels > 5: Tab groups - multiple tab groups re-run after closing t1 1`] = `
[
{
"group": 1,
"isSelected": true,
"text": "simple_ticking3.py",
},
{
"group": 2,
"isSelected": true,
"text": "test.py",
},
{
"group": 3,
"isSelected": true,
"text": "t2",
},
{
"group": 4,
"isSelected": true,
"text": "t3",
},
{
"group": 4,
"text": "t1",
},
]
`;
79 changes: 74 additions & 5 deletions e2e/specs/test.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import { browser, expect } from '@wdio/globals';
import {
closeAllEditors,
closeTab,
execRunDhFileCodelens,
execPaletteCmd,
getTabs,
hasConnectionStatusBarItem,
openEditors,
parseTabState,
PYTHON_AND_GROOVY_SERVER_CONFIG,
resetConfig,
selectTab,
setConfigSectionSettings,
} from '../testUtils';

afterEach(async () => {
await resetConfig();
await closeAllEditors();
});

// There are some tests that can be used for reference in:
// https://github.com/stateful/vscode-marquee/blob/main/test/specs and
// https://github.com/webdriverio-community/wdio-vscode-service/blob/main/test/specs
Expand All @@ -30,11 +41,6 @@ describe('Connection status bar item', () => {
await openEditors(['test.txt', 'test.groovy', 'test.py']);
});

afterEach(async () => {
await resetConfig();
await closeAllEditors();
});

['test.groovy', 'test.py'].forEach(supportedTitle => {
it(`should only be visible when a supported file type is active: ${supportedTitle}`, async () => {
const workbench = await browser.getWorkbench();
Expand All @@ -51,3 +57,66 @@ describe('Connection status bar item', () => {
});
});
});

describe('panels', () => {
beforeEach(async () => {
await setConfigSectionSettings(
'coreServers',
PYTHON_AND_GROOVY_SERVER_CONFIG
);
await openEditors(['simple_ticking3.py']);
await openEditors(['test.py'], { viewColumn: 2 });
});

it.only('should open panels', async () => {
const workbench = await browser.getWorkbench();

await workbench.getEditorView().openEditor('simple_ticking3.py');
await execRunDhFileCodelens();

// We need this to wait until panels load
await workbench.getAllWebviews();

/* Test 1 */
expect(await getTabs().map(parseTabState)).toMatchSnapshot(
'1: Tab groups - initial load'
);

/* Test 2 */
await selectTab('t1', 3);

expect(await getTabs().map(parseTabState)).toMatchSnapshot(
'2: Tab groups - after clicking t1'
);

/* Test 3 */
await closeTab('t1', 3);
await closeTab('t2', 3);

await execRunDhFileCodelens();
await new Promise(resolve => setTimeout(resolve, 2000));

expect(await getTabs().map(parseTabState)).toMatchSnapshot(
'3: Tab groups - re-run after closing t1 and t2'
);

/* Test 4 */
await selectTab('t3', 3);

await execPaletteCmd('View: Move Editor into Group Below');

expect(await getTabs().map(parseTabState)).toMatchSnapshot(
'4: Tab groups - after dragging t1 to a new tab group'
);

/* Test 5 */
await closeTab('t1', 3);

await execRunDhFileCodelens();
await new Promise(resolve => setTimeout(resolve, 2000));

expect(await getTabs().map(parseTabState)).toMatchSnapshot(
'5: Tab groups - multiple tab groups re-run after closing t1'
);
});
});
7 changes: 7 additions & 0 deletions e2e/test-ws/simple_ticking3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from deephaven import time_table

t1 = time_table("PT2S")

t2 = time_table("PT2S")

t3 = time_table("PT2S")
Loading
Loading