Skip to content

Commit

Permalink
checking new action to copy screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbysunil14 committed Dec 17, 2024
1 parent 5c2eb25 commit 27c0dc0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/run-regression-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,10 @@ jobs:
# Build the plugin.
- name: 'Test: RunTests'
run: bash ./src/test/resources/ci/scripts/exec.sh TEST ${{ matrix.targetVSCode }}

# Archive screenshots
- name: Archive screenshots
uses: actions/upload-artifact@v3
with:
name: liberty-run-tests-screenshots-${{ github.sha }}
path: ./screenshots/*.png
39 changes: 35 additions & 4 deletions src/test/GradleSingleModJakartaLSTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import { TextEditor, EditorView, VSBrowser } from 'vscode-extension-tester';
import * as utils from './utils/testUtils';
import * as path from 'path';
import * as assert from 'assert';
import * as fs from 'fs'

describe('LSP4Jakarta LS test for snippet test', () => {

let editor: TextEditor;

it('check if correct code is inserted when rest_class snippet is triggered', async() => {
await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), "src", "main", "java", "test", "gradle", "liberty", "web", "app", "HelloServlet.java"));
await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), "src", "main", "java", "test", "gradle", "liberty", "web", "app", "SystemResource.java"));

editor = await new EditorView().openEditor('HelloServlet.java') as TextEditor;
editor = await new EditorView().openEditor('SystemResource.java') as TextEditor;

const textPressent = await editor.getText();
if(textPressent.length > 0){
Expand All @@ -24,9 +25,10 @@ describe('LSP4Jakarta LS test for snippet test', () => {
//open the assistant
const assist = await editor.toggleContentAssist(true);
await utils.delay(6000);
await VSBrowser.instance.takeScreenshot("rest_class");
console.log("screenshot", VSBrowser.instance.getScreenshotsDir());
// toggle can return void, so we need to make sure the object is present
if (assist) {
console.log("assist reached", await assist.getItems());
// to select an item use
await assist.select('rest_class');
console.log("assist selected");
Expand All @@ -38,11 +40,40 @@ describe('LSP4Jakarta LS test for snippet test', () => {

const insertedCode = await editor.getText();
await utils.delay(6000);
console.log("inserted text: ", insertedCode);
assert(insertedCode.includes('public String methodname() {'), 'Snippet rest_class was not inserted correctly.');

// await editor.clearText();
// await editor.save();
}).timeout(475000);

after(() => {
const sourcePath = VSBrowser.instance.getScreenshotsDir();
const destinationPath = './screenshots';

copyFolderContents(sourcePath, destinationPath);
});

function copyFolderContents(sourceFolder: string, destinationFolder: string): void {
if (!fs.existsSync(sourceFolder)) {
throw new Error('Source folder does not exist');
}

if (!fs.existsSync(destinationFolder)) {
fs.mkdirSync(destinationFolder);
}

const files = fs.readdirSync(sourceFolder);

for (const file of files) {
const sourcePath = path.join(sourceFolder, file);
const destinationPath = path.join(destinationFolder, file);

if (fs.statSync(sourcePath).isDirectory()) {
copyFolderContents(sourcePath, destinationPath);
} else {
fs.copyFileSync(sourcePath, destinationPath);
}
}
}

});

0 comments on commit 27c0dc0

Please sign in to comment.