Skip to content

Commit 992af45

Browse files
bourdakos1lresende
authored andcommitted
Fix failing pipeline integration tests (#1621)
1 parent dc32ae9 commit 992af45

File tree

22 files changed

+683
-635
lines changed

22 files changed

+683
-635
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ jobs:
4242
python-version: ${{ matrix.python-version }}
4343
architecture: 'x64'
4444
- name: Set up Node
45-
uses: actions/setup-node@v1
45+
uses: actions/setup-node@v2
4646
with:
47-
node-version: '12.18'
47+
node-version: '*'
4848
- name: Create npm configuration for authentication
4949
run: |
5050
echo "scripts-prepend-node-path=true" >> ~/.npmrc
@@ -89,6 +89,7 @@ jobs:
8989
if: failure()
9090
with:
9191
path: |
92+
${{ github.workspace }}/build/cypress-tests/*.log
9293
${{ github.workspace }}/build/cypress-tests/screenshots//**/*
9394
${{ github.workspace }}/build/cypress-tests/videos//**/*
9495
/home/runner/.npm/_logs/*.log

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
"eslint:check": "eslint . --ignore-path .gitignore --ext .ts,.tsx,.js",
1515
"prettier": "prettier --ignore-path .gitignore --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json}\"",
1616
"prettier:check": "prettier --ignore-path .gitignore --check \"**/*{.ts,.tsx,.js,.jsx,.css,.json}\"",
17-
"start-jupyter": "mkdir -p build/cypress-tests && jupyter lab --config=./tests/test-config.py",
1817
"test": "npm run test:unit && npm run test:integration",
19-
"test:integration": "start-server-and-test start-jupyter http-get://localhost:58888?token=test cy:run",
20-
"test:integration:debug": "start-server-and-test start-jupyter http-get://localhost:58888?token=test cy:open",
18+
"start": "mkdir -p build/cypress-tests && ts-node scripts/start-test-server.ts",
19+
"test:integration": "server-test 'yarn start' ':9000/minio/health/live|http-get://localhost:58888?token=test' 'yarn cy:run'",
20+
"test:integration:debug": "server-test 'yarn start' ':9000/minio/health/live|http-get://localhost:58888?token=test' 'yarn cy:open'",
2121
"test:unit": "lerna run test --scope \"@elyra/*\" --concurrency 1 --stream"
2222
},
2323
"husky": {
@@ -41,7 +41,9 @@
4141
"@4tw/cypress-drag-drop": "^1.3.1",
4242
"@cypress/webpack-preprocessor": "^5.5.0",
4343
"@jupyterlab/testutils": "3.0.0",
44+
"@testing-library/cypress": "^7.0.4",
4445
"@types/jest": "^26.0.20",
46+
"@types/node": "^15.0.1",
4547
"@types/react": "^17.0.0",
4648
"@types/react-dom": "^17.0.0",
4749
"@types/react-intl": "^3.0.0",
@@ -50,6 +52,7 @@
5052
"cypress": "^6.2.0",
5153
"eslint": "^6.5.0",
5254
"eslint-config-prettier": "^6.9.0",
55+
"eslint-plugin-cypress": "^2.11.2",
5356
"eslint-plugin-header": "^3.0.0",
5457
"eslint-plugin-import": "^2.20.2",
5558
"eslint-plugin-prettier": "^3.1.2",
@@ -63,9 +66,10 @@
6366
"lint-staged": "^9.5.0",
6467
"prettier": "^1.19.1",
6568
"rimraf": "~3.0.2",
66-
"start-server-and-test": "1.7.9",
69+
"start-server-and-test": "^1.12.1",
6770
"ts-jest": "^26.4.4",
6871
"ts-loader": "^6.2.2",
72+
"ts-node": "^9.1.1",
6973
"typescript": "~4.1.3",
7074
"webpack": "^5.0.0"
7175
}

packages/ui-components/src/TextInput.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export const TextInput: React.FC<ITextFieldProps> = ({
7878
>
7979
<CustomTooltip title={description ?? ''}>
8080
<TextField
81+
id={fieldName}
8182
label={label}
8283
required={required}
8384
variant="outlined"

scripts/start-test-server.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2018-2021 Elyra Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { exec, spawn } from 'child_process';
18+
import fs from 'fs';
19+
import path from 'path';
20+
21+
const config = path.join(__dirname, '..', 'tests', 'test-config.py');
22+
const jupyter = exec(`jupyter lab --config ${config}`);
23+
24+
const CONTAINER_NAME = 'minio_test';
25+
26+
const docker = spawn('docker', [
27+
'run',
28+
'--rm',
29+
'--name',
30+
CONTAINER_NAME,
31+
'-p',
32+
'9000:9000',
33+
'minio/minio',
34+
'server',
35+
'/data'
36+
]);
37+
38+
const logDir = path.join(__dirname, '..', 'build', 'cypress-tests');
39+
40+
const jupyterLog = fs.createWriteStream(path.join(logDir, 'jupyter.log'));
41+
jupyter.stderr?.pipe(jupyterLog);
42+
43+
const dockerLog = fs.createWriteStream(path.join(logDir, 'docker.log'));
44+
docker.stderr.pipe(dockerLog);
45+
46+
const handleTeardown = (): void => {
47+
spawn('docker', ['kill', CONTAINER_NAME]);
48+
process.exit();
49+
};
50+
51+
process.on('SIGINT', handleTeardown);
52+
process.on('SIGTERM', handleTeardown);

tests/.eslintrc.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2018-2021 Elyra Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
module.exports = {
18+
plugins: ['cypress'],
19+
env: {
20+
'cypress/globals': true,
21+
node: true
22+
}
23+
};

tests/integration/codesnippet.ts

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('Code Snippet tests', () => {
1818
const snippetName = 'test-code-snippet';
1919

2020
beforeEach(() => {
21-
cy.openJupyterLab();
21+
cy.resetJupyterLab();
2222
openCodeSnippetExtension();
2323
});
2424

@@ -36,8 +36,6 @@ describe('Code Snippet tests', () => {
3636
cy.get(
3737
'.elyra-metadata .elyra-metadataHeader-button[title="Create new Code Snippet"]'
3838
).should('be.visible');
39-
// Close metadata editor tab
40-
cy.closeCurrentTab();
4139
});
4240

4341
it('should provide warnings when required fields are not entered properly', () => {
@@ -53,9 +51,6 @@ describe('Code Snippet tests', () => {
5351
'required-warnings'
5452
);
5553
cy.get('@required-warnings').should('have.length', 2);
56-
57-
// Close metadata editor tab
58-
cy.closeCurrentTab();
5954
});
6055

6156
it('should create valid code-snippet', () => {
@@ -339,21 +334,6 @@ const saveAndCloseMetadataEditor = (): void => {
339334
cy.get('.elyra-metadataEditor-saveButton > button:visible').click();
340335
};
341336

342-
// const fillMetadaEditorForm = (snippetName: string): void => {
343-
// // Name code snippet
344-
// cy.get('.elyra-metadataEditor-form-display_name').type(snippetName);
345-
346-
// // Select python language from dropdown list
347-
// editSnippetLanguage(snippetName, 'Python');
348-
349-
// // Add snippet code
350-
// cy.get('.elyra-metadataEditor-code > .bp3-form-content').type(
351-
// 'print("Code Snippet Test")'
352-
// );
353-
354-
// saveAndCloseMetadataEditor();
355-
// };
356-
357337
const deleteSnippet = (snippetName: string): void => {
358338
// Find element by name
359339
const item = getSnippetByName(snippetName);
@@ -374,19 +354,6 @@ const getActionButtonsElement = (snippetName: string): any => {
374354
return actionButtonsElement;
375355
};
376356

377-
// const deleteFileByType = (type: string): void => {
378-
// cy.getFileByType(type).rightclick();
379-
// cy.get('.p-Menu-content > [data-command="filebrowser:delete"]').click();
380-
// cy.get('.jp-mod-accept > .jp-Dialog-buttonLabel:visible').click();
381-
// cy.wait(100);
382-
// };
383-
384-
// const checkCodeMirror = (): void => {
385-
// cy.get('span.cm-string')
386-
// .first()
387-
// .contains('Code Snippet Test');
388-
// };
389-
390357
const insert = (snippetName: string): void => {
391358
getActionButtonsElement(snippetName).within(() => {
392359
cy.get('button[title="Insert"]').click();
@@ -403,8 +370,3 @@ const editSnippetLanguage = (snippetName: string, lang: string): void => {
403370
.contains(`${lang}`)
404371
.click();
405372
};
406-
407-
// const closeTabWithoutSaving = (): void => {
408-
// cy.closeCurrentTab();
409-
// cy.get('button.jp-mod-accept.jp-mod-warn').click();
410-
// };

tests/integration/git.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616

1717
describe('Git', () => {
18-
it('opens jupyterlab', () => {
19-
cy.visit('?token=test&reset');
18+
beforeEach(() => {
19+
cy.resetJupyterLab();
2020
});
2121

2222
it('opens git extension', () => {

tests/integration/launcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
describe('Elyra launcher is in use', () => {
1818
beforeEach(() => {
19-
cy.openJupyterLab();
19+
cy.resetJupyterLab();
2020
});
2121

2222
it('should have Elyra extensions', () => {

tests/integration/lsp.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,25 @@
1515
*/
1616

1717
describe('LSP', () => {
18-
before(() => {
18+
beforeEach(() => {
1919
// read python file used for testing
20-
cy.readFile('tests/assets/helloworld.py').then((file: any) => {
21-
cy.writeFile('build/cypress-tests/helloworld.py', file);
22-
});
20+
cy.bootstrapFile('helloworld.py');
2321

24-
cy.openJupyterLab();
22+
cy.resetJupyterLab();
2523
});
2624

27-
after(() => {
25+
afterEach(() => {
2826
// delete Python file used for testing
29-
cy.exec('find build/cypress-tests/ -name helloworld.py -delete', {
30-
failOnNonZeroExit: false
31-
});
27+
cy.deleteFile('helloworld.py');
3228
});
3329

3430
it('LSP extension is initialized', () => {
3531
// open Python file
36-
cy.getFileByType('python').dblclick();
37-
38-
cy.wait(1000);
32+
cy.openFile('helloworld.py');
3933

4034
//check for lsp item on status bar
4135
cy.get('.lsp-statusbar-item ').find(
4236
'[title="Fully connected & initialized (1 virtual document)"]'
4337
);
44-
45-
// close tab
46-
cy.closeCurrentTab();
4738
});
4839
});

0 commit comments

Comments
 (0)