Skip to content

Commit 8a70514

Browse files
authored
Disable plannotate and fix ESlint (#539)
* fix eslint * add option to enable or disable plannotate * fix tests
1 parent 533fa15 commit 8a70514

File tree

15 files changed

+318
-68
lines changed

15 files changed

+318
-68
lines changed

.eslintrc.json

Lines changed: 0 additions & 45 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"eslint.nodePath": "../node_modules",
1515
"eslint.options": {
16-
"overrideConfigFile": "../.eslintrc.json"
16+
"overrideConfigFile": "eslint.config.js"
1717
},
1818
"eslint.format.enable": true,
1919
"[javascript]": {

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ ENV DATABASE=""
3232
ENV SHOW_APP_BAR="true"
3333
ENV NO_EXTERNAL_REQUESTS="false"
3434
ENV ENABLE_ASSEMBLER="false"
35+
ENV ENABLE_PLANNOTATE="false"
3536
CMD ["sh", "docker_entrypoint.sh"]

cypress/e2e/group-2/migrate_and_bug_fix.cy.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,56 +7,56 @@ describe('Test that when files are loaded, old versions are migrated and bug fix
77
it('Can migrate old files', () => {
88
// When drag and drop
99
cy.get('div.cloning-history').selectFile('cypress/test_files/old_and_bug_fix/crispr_hdr.json', { action: 'drag-drop' });
10-
cy.get('div.MuiAlert-message', { timeout: 20000 }).contains('migrated to the latest version');
10+
cy.get('#global-error-message-wrapper div.MuiAlert-message', { timeout: 20000 }).contains('migrated to the latest version');
1111

1212
cy.get('div.MuiAlert-action svg[data-testid="CloseIcon"]').click();
13-
cy.get('div.MuiAlert-message').should('not.exist');
13+
cy.get('#global-error-message-wrapper div.MuiAlert-message').should('not.exist');
1414
addLane();
1515
// When loading from file in source
1616
addSource('UploadedFileSource', true);
1717
cy.get('form.submit-sequence-file input').last().selectFile('cypress/test_files/old_and_bug_fix/crispr_hdr.json', { force: true });
18-
cy.get('div.MuiAlert-message', { timeout: 20000 }).contains('migrated to the latest version');
18+
cy.get('#global-error-message-wrapper div.MuiAlert-message', { timeout: 20000 }).contains('migrated to the latest version');
1919
cy.get('div.MuiAlert-action svg[data-testid="CloseIcon"]').click();
20-
cy.get('div.MuiAlert-message').should('not.exist');
20+
cy.get('#global-error-message-wrapper div.MuiAlert-message').should('not.exist');
2121
// When loading from menu
2222
cy.get('.MuiToolbar-root .MuiButtonBase-root').contains('File').siblings('input').selectFile('cypress/test_files/old_and_bug_fix/crispr_hdr.json', { force: true });
2323
cy.get('.history-loaded-dialog').contains('Replace existing').click();
2424
cy.get('.history-loaded-dialog button').contains('Select').click();
25-
cy.get('div.MuiAlert-message', { timeout: 20000 }).contains('migrated to the latest version');
25+
cy.get('#global-error-message-wrapper div.MuiAlert-message', { timeout: 20000 }).contains('migrated to the latest version');
2626
cy.get('div.MuiAlert-action svg[data-testid="CloseIcon"]').click();
27-
cy.get('div.MuiAlert-message').should('not.exist');
27+
cy.get('#global-error-message-wrapper div.MuiAlert-message').should('not.exist');
2828
});
2929
it('Can fix bugs in old files', () => {
3030
// When drag and drop
3131
cy.get('div.cloning-history').selectFile('cypress/test_files/old_and_bug_fix/gateway.json', { action: 'drag-drop' });
32-
cy.get('div.MuiAlert-message', { timeout: 20000 }).contains('migrated to the latest version');
33-
cy.get('div.MuiAlert-message').contains('contained an error');
32+
cy.get('#global-error-message-wrapper div.MuiAlert-message', { timeout: 20000 }).contains('migrated to the latest version');
33+
cy.get('#global-error-message-wrapper div.MuiAlert-message').contains('contained an error');
3434
cy.get('div.MuiAlert-action svg[data-testid="CloseIcon"]').first().click();
3535
cy.get('div.MuiAlert-action svg[data-testid="CloseIcon"]').first().click();
36-
cy.get('div.MuiAlert-message').should('not.exist');
36+
cy.get('#global-error-message-wrapper div.MuiAlert-message').should('not.exist');
3737
addLane();
3838
// When loading from file in source
3939
addSource('UploadedFileSource', true);
4040
cy.get('form.submit-sequence-file input').last().selectFile('cypress/test_files/old_and_bug_fix/gateway.json', { force: true });
41-
cy.get('div.MuiAlert-message', { timeout: 20000 }).contains('migrated to the latest version');
42-
cy.get('div.MuiAlert-message').contains('contained an error');
41+
cy.get('#global-error-message-wrapper div.MuiAlert-message', { timeout: 20000 }).contains('migrated to the latest version');
42+
cy.get('#global-error-message-wrapper div.MuiAlert-message').contains('contained an error');
4343
cy.get('div.MuiAlert-action svg[data-testid="CloseIcon"]').first().click();
4444
cy.get('div.MuiAlert-action svg[data-testid="CloseIcon"]').first().click();
45-
cy.get('div.MuiAlert-message').should('not.exist');
45+
cy.get('#global-error-message-wrapper div.MuiAlert-message').should('not.exist');
4646
// When loading from menu
4747
cy.get('.MuiToolbar-root .MuiButtonBase-root').contains('File').siblings('input').selectFile('cypress/test_files/old_and_bug_fix/gateway.json', { force: true });
4848
cy.get('.history-loaded-dialog').contains('Replace existing').click();
4949
cy.get('.history-loaded-dialog button').contains('Select').click();
50-
cy.get('div.MuiAlert-message', { timeout: 20000 }).contains('migrated to the latest version');
50+
cy.get('#global-error-message-wrapper div.MuiAlert-message', { timeout: 20000 }).contains('migrated to the latest version');
5151
cy.get('div.MuiAlert-action svg[data-testid="CloseIcon"]').first().click();
5252
cy.get('div.MuiAlert-action svg[data-testid="CloseIcon"]').first().click();
53-
cy.get('div.MuiAlert-message').should('not.exist');
53+
cy.get('#global-error-message-wrapper div.MuiAlert-message').should('not.exist');
5454
});
5555
it('Works with zip files', () => {
5656
cy.get('div.cloning-history').selectFile('cypress/test_files/old_and_bug_fix/cloning_strategy_with_sequencing.zip', { action: 'drag-drop' });
57-
cy.get('div.MuiAlert-message', { timeout: 20000 }).contains('migrated to the latest version');
57+
cy.get('#global-error-message-wrapper div.MuiAlert-message', { timeout: 20000 }).contains('migrated to the latest version');
5858
cy.get('div.MuiAlert-action svg[data-testid="CloseIcon"]').click();
59-
cy.get('div.MuiAlert-message').should('not.exist');
59+
cy.get('#global-error-message-wrapper div.MuiAlert-message').should('not.exist');
6060
cy.get('#sequence-1 svg[data-testid="RuleIcon"]').click();
6161
cy.get('table').contains('BZO902_13409020_13409020.ab1');
6262
cy.get('table').contains('BZO903_13409037_13409037.ab1');
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { manuallyTypeSequence } from "../common_functions";
2+
import defaultConfig from '../../../public/config.dev.json';
3+
4+
5+
describe('test that configuration works', () => {
6+
7+
it('Annotation source is not available if enablePlannotate is false', () => {
8+
// Intercept config.json request and modify enablePlannotate to false
9+
cy.intercept('GET', '**/config.json', (req) => {
10+
req.reply({ statusCode: 200, body: {...defaultConfig, enablePlannotate: false}});
11+
}).as('configRequest');
12+
13+
cy.visit('/');
14+
cy.wait('@configRequest');
15+
16+
manuallyTypeSequence('atata');
17+
cy.get('svg[data-testid="AddCircleIcon"]', { timeout: 20000 }).first().click();
18+
cy.get('li#source-2 .MuiInputBase-root').click();
19+
cy.get('li[data-value="AnnotationSource"]').should('not.exist');
20+
cy.get('li[data-value="RestrictionEnzymeDigestionSource"]').should('exist');
21+
});
22+
it('Annotation source is available if enablePlannotate is true', () => {
23+
// Intercept config.json request and modify enablePlannotate to true
24+
cy.intercept('GET', '**/config.json', (req) => {
25+
req.reply({ statusCode: 200, body: {...defaultConfig, enablePlannotate: true}});
26+
}).as('configRequest');
27+
28+
cy.visit('/');
29+
cy.wait('@configRequest');
30+
31+
manuallyTypeSequence('atata');
32+
cy.get('svg[data-testid="AddCircleIcon"]', { timeout: 20000 }).first().click();
33+
cy.get('li#source-2 .MuiInputBase-root').click();
34+
cy.get('li[data-value="AnnotationSource"]').should('exist');
35+
});
36+
it('Assembler is not available if enableAssembler is false', () => {
37+
// Intercept config.json request and modify enableAssembler to false
38+
cy.intercept('GET', '**/config.json', (req) => {
39+
req.reply({ statusCode: 200, body: {...defaultConfig, enableAssembler: false}});
40+
}).as('configRequest');
41+
42+
cy.visit('/');
43+
cy.wait('@configRequest');
44+
45+
// Wait for the app to finish loading
46+
cy.get('.loading-state-message', { timeout: 10000 }).should('not.exist');
47+
48+
// Check that the assembler tab is not present
49+
cy.get('.MuiTabs-root').contains('Assembler').should('not.exist');
50+
});
51+
52+
it('Assembler is available if enableAssembler is true', () => {
53+
// Intercept config.json request and modify enableAssembler to true
54+
cy.intercept('GET', '**/config.json', (req) => {
55+
req.reply({ statusCode: 200, body: {...defaultConfig, enableAssembler: true}});
56+
}).as('configRequest');
57+
cy.visit('/');
58+
cy.wait('@configRequest');
59+
60+
// Check that the assembler tab is present
61+
cy.get('.MuiTabs-root').contains('Assembler').should('exist');
62+
});
63+
64+
});
65+

cypress/e2e/group-4/drag_and_drop_file.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('Test drag and drop functionality', () => {
3333
it('Can load a history file', () => {
3434
cy.get('div.cloning-history').selectFile('public/examples/homologous_recombination.json', { action: 'drag-drop' });
3535
// No error message should be displayed
36-
cy.get('div.MuiAlert-message').should('not.exist');
36+
cy.get('div#global-error-message-wrapper div.MuiAlert-message').should('not.exist');
3737
cy.get('div.tf-tree.tf-ancestor-tree').contains('Homologous recombination with').should('exist');
3838
});
3939
it('Shows the right errors when dropping wrong files', () => {

eslint.config.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import js from '@eslint/js';
2+
import react from 'eslint-plugin-react';
3+
import reactHooks from 'eslint-plugin-react-hooks';
4+
import cypress from 'eslint-plugin-cypress';
5+
6+
export default [
7+
js.configs.recommended,
8+
{
9+
files: ['**/*.{js,jsx}'],
10+
languageOptions: {
11+
ecmaVersion: 2021,
12+
sourceType: 'module',
13+
globals: {
14+
browser: true,
15+
__APP_VERSION__: 'readonly',
16+
window: 'readonly',
17+
document: 'readonly',
18+
console: 'readonly',
19+
process: 'readonly',
20+
Buffer: 'readonly',
21+
global: 'readonly',
22+
module: 'readonly',
23+
require: 'readonly',
24+
exports: 'readonly',
25+
__dirname: 'readonly',
26+
__filename: 'readonly'
27+
},
28+
parserOptions: {
29+
ecmaFeatures: {
30+
jsx: true
31+
}
32+
}
33+
},
34+
plugins: {
35+
react,
36+
'react-hooks': reactHooks
37+
},
38+
rules: {
39+
...react.configs.recommended.rules,
40+
...reactHooks.configs.recommended.rules,
41+
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
42+
'max-len': ['error', { code: 300 }],
43+
'react/prop-types': 0,
44+
'object-curly-newline': 0,
45+
'import/prefer-default-export': 0,
46+
'indent': ['error', 2],
47+
'no-unused-vars': 'warn',
48+
'no-console': 'warn'
49+
},
50+
settings: {
51+
react: {
52+
version: 'detect'
53+
}
54+
}
55+
},
56+
{
57+
files: ['cypress/**/*.{js,jsx}'],
58+
plugins: {
59+
cypress
60+
},
61+
rules: {
62+
...cypress.configs.recommended.rules
63+
}
64+
}
65+
];

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"eslint-plugin-import": "^2.31.0",
6969
"eslint-plugin-jsx-a11y": "^6.10.2",
7070
"eslint-plugin-react": "^7.37.5",
71+
"eslint-plugin-react-hooks": "^7.0.0",
7172
"husky": "^9.1.7",
7273
"jsdom": "^22.1.0",
7374
"pinst": "^3.0.0",

public/config.dev.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"backendUrl": "http://127.0.0.1:8000",
33
"showAppBar": true,
4-
"noExternalRequests": false
4+
"noExternalRequests": false,
5+
"enableAssembler": true,
6+
"enablePlannotate": true
57
}

public/config.elabftw.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
"backendUrl": "http://127.0.0.1:8000",
33
"database": "elabftw",
44
"showAppBar": true,
5-
"noExternalRequests": false
5+
"noExternalRequests": false,
6+
"enableAssembler": true,
7+
"enablePlannotate": true
68
}

0 commit comments

Comments
 (0)