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

ci: improved e2e tests in order to work in ubuntu-latest pipeline again (#2048869) #48

Merged
merged 12 commits into from
Feb 11, 2025
Merged
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
7 changes: 3 additions & 4 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

# Currently, no macOS runner, because during the setup of docker, this runner hangs: https://github.com/douglascamata/setup-docker-macos-action/issues/37
os: [ubuntu-latest]
node-version: [18.x, 20.x, 22.x]
node-version: [20.x, 22.x]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -48,7 +48,6 @@ jobs:
- name: Run clean install
run: npm ci


- name: Run tests on Linux
run: xvfb-run -a npm test
if: runner.os == 'Linux'
Expand All @@ -65,7 +64,7 @@ jobs:
# Therefore, we can not install and start a docker container in the WSL.

# Currently, no macOS runner, because during the setup of docker, this runner hangs: https://github.com/douglascamata/setup-docker-macos-action/issues/37
node-version: [18.x, 20.x, 22.x]
node-version: [20.x, 22.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -136,7 +135,7 @@ jobs:
run: npm run lint -- --format json --output-file eslint-results.json || true

- name: Analyze with SonarCloud
uses: SonarSource/sonarcloud-github-action@master
uses: SonarSource/sonarqube-scan-action@v4
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,4 +450,4 @@
"webpack-cli": "^5.1.4",
"webpack-shell-plugin-next": "^2.3.2"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class WebviewTestUtils {
return false;
}
},
10_000,
2_000,
"waiting for the webview to open"
);
}
Expand Down Expand Up @@ -91,6 +91,14 @@ export class WebviewTestUtils {
} finally {
// Switch webdriver back to the vscode window after each test.
await webView.switchBack();

try {
// closing the liquibase config editor
await new EditorView().closeEditor("Liquibase Configuration");
} catch (error) {
// ignore any error, just log ist
console.error("error closing the config editor", error);
}
}
}

Expand Down
44 changes: 38 additions & 6 deletions src/test/e2e/LiquibaseGUITestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ import {
} from "vscode-extension-tester";
import assert from "assert";
import { randomUUID } from "crypto";
import { WebviewTestUtils } from "./webview/WebviewTestUtils";
import { WebviewTestUtils } from "./01_webview/WebviewTestUtils";
import { DockerTestUtils } from "../suite/DockerTestUtils";
import path from "path";
import * as fs from "fs";
import { CHOOSE_CHANGELOG_OPTION, ContextOptions, RemoveCacheOptions } from "../../constants";
import chai from "chai";
import chaiString from "chai-string";
import chaiFs from "chai-fs";

chai.use(chaiFs);
chai.use(chaiString);

/**
Expand All @@ -48,6 +50,11 @@ export class LiquibaseGUITestUtils {
*/
static outputPanel: OutputView;

/**
* Indicates, if the workspace was opened once by the tests.
*/
private static workspaceOpen: boolean = false;

//#region setup tests

/**
Expand All @@ -70,6 +77,9 @@ export class LiquibaseGUITestUtils {
// open the workspace
await this.openWorkspace();

// we need to wait a bit, otherwise we can not create the config
await this.wait(1000);

// create a configuration
const configurationName = await this.createConfiguration({ addChangelog: addChangelog });

Expand Down Expand Up @@ -105,12 +115,26 @@ export class LiquibaseGUITestUtils {
}

/**
* Opens the workspace.
* Opens the workspace, if it was not opened by any other test.
*/
static async openWorkspace(): Promise<void> {
if (this.workspaceOpen) {
// If the workspace was opened before, do nothing
return;
}

await new EditorView().closeAllEditors();

await VSBrowser.instance.openResources(this.WORKSPACE_PATH);
const prompt = await new Workbench().openCommandPrompt();

const input = await InputBox.create();

await prompt.setText(">workbench.action.files.openFolder");
await prompt.confirm();

await this.selectFolder(input, this.WORKSPACE_PATH);

this.workspaceOpen = true;
}

// #endregion
Expand Down Expand Up @@ -265,7 +289,7 @@ export class LiquibaseGUITestUtils {
*/
static removeContentOfFolder(folder: string): void {
for (const file of fs.readdirSync(folder)) {
fs.rmSync(path.join(folder, file));
fs.rmSync(path.join(folder, file), { recursive: true, force: true });
}
}
//#endregion
Expand Down Expand Up @@ -357,7 +381,7 @@ export class LiquibaseGUITestUtils {
if (message.includes(text)) {
return { notification };
}
} else if (message.match(text)) {
} else if (RegExp(text).exec(message)) {
return { notification };
}
}
Expand Down Expand Up @@ -569,7 +593,15 @@ export class LiquibaseGUITestUtils {
configurationName?: string,
contextOption?: ContextOptions
): Promise<InputBox> {
await VSBrowser.instance.openResources(this.CHANGELOG_FILE);
const prompt = await new Workbench().openCommandPrompt();

const input = await InputBox.create();

await prompt.setText(">workbench.action.files.openFile");
await prompt.confirm();

await input.setText(this.CHANGELOG_FILE);
await input.confirm();

await this.openAndSelectRMBItemFromAlreadyOpenedFile(action, mochaContext);

Expand Down
2 changes: 1 addition & 1 deletion src/test/e2e/commands/convert-format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ suite("convert format", () => {
* Removes the temporary output folder after all tests.
*/
suiteTeardown("remove temporary folder", () => {
fs.rmSync(tempOutput, { recursive: true });
fs.rmSync(tempOutput, { recursive: true, force: true, maxRetries: 10 });
});

formats.forEach((pFormat) => {
Expand Down
Loading