From e1ac0db45ff49e44e262cf9ea587939cd8ec0844 Mon Sep 17 00:00:00 2001 From: Dinika Saxena Date: Mon, 26 Jun 2023 15:36:31 +0200 Subject: [PATCH 01/77] 3911 // Make cypress ci tests easy to debug --- ci/config/delta-postgres.conf | 2 +- ci/docker-compose.yml | 15 +++++++++++---- .../e2e/{Studios.cy-ignore.ts => Studios.cy.ts} | 16 ++++++++-------- cypress/support/setupRealmsAndUsers.ts | 2 +- package.json | 3 ++- 5 files changed, 23 insertions(+), 15 deletions(-) rename cypress/e2e/{Studios.cy-ignore.ts => Studios.cy.ts} (90%) diff --git a/ci/config/delta-postgres.conf b/ci/config/delta-postgres.conf index cd926de84..193dec17c 100644 --- a/ci/config/delta-postgres.conf +++ b/ci/config/delta-postgres.conf @@ -1,6 +1,6 @@ app { http { - base-uri = "http://delta:8080/v1" + base-uri = "http://delta:8098/v1" interface = 0.0.0.0 } diff --git a/ci/docker-compose.yml b/ci/docker-compose.yml index c8da3601e..a0d77bc7b 100644 --- a/ci/docker-compose.yml +++ b/ci/docker-compose.yml @@ -2,13 +2,14 @@ version: '3.3' services: cypress: image: 'cypress/included:10.3.1-typescript' + volumes: + - ../:/e2e depends_on: - fusion - delta environment: - - CYPRESS_NEXUS_API_URL=http://delta.test:8080/v1 + - CYPRESS_NEXUS_API_URL=http://delta.test:8098/v1 - CYPRESS_BASE_URL=http://fusion.test:8000 - working_dir: /e2e container_name: cypress entrypoint: ['bash'] @@ -19,11 +20,13 @@ services: - delta environment: ANALYSIS_PLUGIN_SHOW_ON_TYPES: 'Analysis,DetailedCircuit,AnalysisReport,Report' - API_ENDPOINT: 'http://delta.test:8080/v1' + API_ENDPOINT: 'http://delta.test:8098/v1' CLIENT_ID: 'fusion' image: nexus-web:fresh expose: - 8000 + ports: + - 8000:8000 networks: default: aliases: @@ -56,9 +59,12 @@ services: './bin/delta-app', '-Xmx4G', '-Dapp.cluster.remote-interface=delta', + '-Dapp.http.port=8098', ] expose: - - 8080 + - 8098 + ports: + - 8098:8098 volumes: - ./config:/config - /tmp:/default-volume @@ -79,6 +85,7 @@ services: - --hostname-port=8080 - --hostname-strict=false - --hostname-strict-backchannel=false + - --log-level=DEBUG ports: - 8080:8080 networks: diff --git a/cypress/e2e/Studios.cy-ignore.ts b/cypress/e2e/Studios.cy.ts similarity index 90% rename from cypress/e2e/Studios.cy-ignore.ts rename to cypress/e2e/Studios.cy.ts index 0ac14fe9e..0533f11b6 100644 --- a/cypress/e2e/Studios.cy-ignore.ts +++ b/cypress/e2e/Studios.cy.ts @@ -44,14 +44,14 @@ describe('Studios', () => { studioDetailsPage = new StudioDetailsPage(); }); - // after(function() { - // cy.task('project:teardown', { - // nexusApiUrl: Cypress.env('NEXUS_API_URL'), - // authToken: this.nexusToken, - // orgLabel: Cypress.env('ORG_LABEL'), - // projectLabel: this.projectLabel, - // }); - // }); + after(function() { + cy.task('project:teardown', { + nexusApiUrl: Cypress.env('NEXUS_API_URL'), + authToken: this.nexusToken, + orgLabel: Cypress.env('ORG_LABEL'), + projectLabel: this.projectLabel, + }); + }); it('user can create a studio with a workspace and dashboard', function() { cy.visit( diff --git a/cypress/support/setupRealmsAndUsers.ts b/cypress/support/setupRealmsAndUsers.ts index 85a325fc8..8d6b5b1c4 100644 --- a/cypress/support/setupRealmsAndUsers.ts +++ b/cypress/support/setupRealmsAndUsers.ts @@ -3,7 +3,7 @@ const fetch = require('node-fetch'); const fs = require('fs'); const keycloakUrl = 'http://keycloak.test:8080'; -const deltaBaseUrl = 'http://delta.test:8080/v1'; +const deltaBaseUrl = 'http://delta.test:8098/v1'; // /* these are used for administrating keycloak */ const keycloakAdmin = { diff --git a/package.json b/package.json index e1a1e38df..745e8f307 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "style": "prettier --check \"./src/**/*.{ts,tsx,js,jsx,less}\"", "style:fix": "prettier --write \"./src/**/*.{ts,tsx,js,jsx,less}\"", "start:storybook": "start-storybook -p 6006", - "build:storybook": "build-storybook" + "build:storybook": "build-storybook", + "runtest": "echo | sudo docker exec -e -t cypress xvfb-run -s '-screen 0 1920x1080x24' cypress run --headed --config-file cypress.config.ts --browser /usr/bin/google-chrome" }, "dependencies": { "@ant-design/charts": "^1.3.4", From 155e8f91a5e8f2f67a82b966d834280f04ecd264 Mon Sep 17 00:00:00 2001 From: Dinika Saxena Date: Mon, 26 Jun 2023 16:30:18 +0200 Subject: [PATCH 02/77] 3911 // Fix cypress tests by creating sesssions correctly The responses sent from keycloak can only be accepted by the browser if SameSite cookies are None and mixed content is enabled Signed-off-by: Dinika Saxena --- cypress.config.ts | 10 +- cypress/e2e/AnalysisPlugin.cy-ignore.ts | 230 ------------------------ 2 files changed, 8 insertions(+), 232 deletions(-) delete mode 100644 cypress/e2e/AnalysisPlugin.cy-ignore.ts diff --git a/cypress.config.ts b/cypress.config.ts index 572391c83..5d9544bb5 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -17,11 +17,13 @@ export default defineConfig({ e2e: { baseUrl: 'http://localhost:8000', fileServerFolder: '/cypress', - defaultCommandTimeout: 50000, + defaultCommandTimeout: 10000, specPattern: 'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}', // @ts-ignore experimentalSessionAndOrigin: true, // testIsolation: false, + chromeWebSecurity: false, + env: { DEBUG: 'cypress:launcher:browsers', ELECTRON_DISABLE_GPU: 'true', @@ -31,6 +33,10 @@ export default defineConfig({ on('before:browser:launch', (browser, launchOptions) => { if (browser.name == 'chrome') { launchOptions.args.push('--disable-gpu'); + launchOptions.args.push('--disable-web-security'); + launchOptions.args.push( + '--unsafely-treat-insecure-origin-as-secure=http://keycloak.test:8080' + ); } return launchOptions; }), @@ -65,7 +71,7 @@ export default defineConfig({ const projectLabel = `${projectLabelBase}-${uuidv4()}`; const projectDescription = 'An project used for Cypress automated tests'; - + console.log('Auth TOKEN', authToken); try { const nexus = createNexusClient({ uri: nexusApiUrl, diff --git a/cypress/e2e/AnalysisPlugin.cy-ignore.ts b/cypress/e2e/AnalysisPlugin.cy-ignore.ts deleted file mode 100644 index 41cf0a713..000000000 --- a/cypress/e2e/AnalysisPlugin.cy-ignore.ts +++ /dev/null @@ -1,230 +0,0 @@ -import { Resource } from '@bbp/nexus-sdk'; - -describe('Report (formerly Analysis) Plugin', () => { - before(() => { - if ( - !Cypress.env('use_existing_delta_instance') || - Cypress.env('use_existing_delta_instance') === false - ) { - cy.task('auth:createRealmsAndUsers', Cypress.env('users')); - } - - cy.login( - `${Cypress.env('users').morty.username}-report-plugin`, - Cypress.env('users').morty.realm, - Cypress.env('users').morty.username, - Cypress.env('users').morty.password - ).then(session => { - cy.window().then(win => { - const authToken = win.localStorage.getItem('nexus__token'); - cy.wrap(authToken).as('nexusToken'); - - const orgLabel = Cypress.env('ORG_LABEL'); - const projectLabelBase = Cypress.env('PROJECT_LABEL_BASE'); - - cy.task('project:setup', { - nexusApiUrl: Cypress.env('NEXUS_API_URL'), - authToken, - orgLabel, - projectLabelBase, - }).then(({ projectLabel }: { projectLabel: string }) => { - cy.wrap(projectLabel).as('projectLabel'); - cy.fixture('AnalysisResource.json').then(resourcePayload => { - cy.task('resource:create', { - nexusApiUrl: Cypress.env('NEXUS_API_URL'), - authToken, - orgLabel, - projectLabel, - resourcePayload, - }).then((resource: Resource) => { - cy.wrap(resource['@id']).as('fullResourceId'); - }); - }); - }); - }); - }); - }); - - beforeEach(() => { - cy.login( - `${Cypress.env('users').morty.username}-report-plugin`, - Cypress.env('users').morty.realm, - Cypress.env('users').morty.username, - Cypress.env('users').morty.password - ); - }); - - // after(function() { - // cy.task('project:teardown', { - // nexusApiUrl: Cypress.env('NEXUS_API_URL'), - // authToken: this.nexusToken, - // orgLabel: Cypress.env('ORG_LABEL'), - // projectLabel: this.projectLabel, - // }); - // }); - - it('user can add a report with name, description and files, categories, types', function() { - cy.visit( - `${Cypress.env('ORG_LABEL')}/${ - this.projectLabel - }/resources/${encodeURIComponent(this.fullResourceId)}` - ); - cy.findByRole('button', { name: /Report/i }).click(); - cy.findByRole('button', { name: /Add Report/i }).click(); - cy.findByRole('textbox', { name: 'Report Name' }).type( - 'Cell density O1.v6-RC2' - ); - cy.findByRole('textbox', { name: 'Report Description' }).type( - 'This is where we can add a nice long description relating to why my report is better than yours.' - ); - // set category and type - cy.findByRole('button', { name: /Anatomical/ }).click(); - cy.findByRole('button', { name: /Analysis/ }).click(); - - cy.findByText(/Drag and drop files/i).click(); - cy.get('input[type=file][data-label="report-upload-file"]').attachFile( - 'sample1.png' - ); - - cy.wait(5000); - cy.screenshot('with-file-attached'); - - cy.findByRole('button', { name: 'Save' }).click(); - cy.screenshot('saving-report'); - - cy.wait(5000); - cy.screenshot('saved-report'); - }); - - it('user can edit an existing report updating its name, description, categories, types, and adding another image and pdf file', function() { - cy.visit( - `${Cypress.env('ORG_LABEL')}/${ - this.projectLabel - }/resources/${encodeURIComponent(this.fullResourceId)}` - ); - cy.url().then(url => cy.task('log', url)); - // Open report plugin - cy.findByRole('button', { name: /Report/i }).click(); - - cy.findByText(/Cell density O1.v6-RC2/i).click(); - cy.findByRole('button', { name: /Edit/ }).click(); - - cy.findByRole('textbox', { name: 'Report Name' }).type('-v2'); - cy.findByRole('textbox', { name: 'Report Description' }).type('-v2'); - cy.screenshot('updated-text'); - cy.findByRole('button', { name: 'Add Files to Report' }).click(); - cy.findByText(/Drag and drop files/i).click(); - cy.get('input[type=file][data-label="report-upload-file"]').attachFile( - 'sample2.png' - ); - cy.get('input[type=file][data-label="report-upload-file"]').attachFile( - 'sample_pdf.pdf' - ); - cy.wait(5000); - cy.screenshot('with-pdf-file-attached'); - cy.findByRole('button', { name: 'Close' }).click(); - cy.findByRole('button', { name: 'Save' }).click(); - cy.screenshot('save-updated-report'); - cy.findByText('Cell density O1.v6-RC2-v2').click(); - cy.screenshot('updated-report-saved'); - cy.findByLabelText('Report Description').should('contain', '-v2'); - cy.findAllByLabelText('Report File').should('have.length', 3); - }); - - it('user can open preview of existing image asset and edit its name and description', function() { - cy.visit( - `${Cypress.env('ORG_LABEL')}/${ - this.projectLabel - }/resources/${encodeURIComponent(this.fullResourceId)}` - ); - // Open report plugin - cy.findByRole('button', { name: /Report/i }).click(); - cy.findByText(/Cell density O1.v6-RC2/i).click(); - cy.findAllByLabelText('Report Assets'); - cy.wait(3000); - cy.findAllByRole('listitem', { name: /sample2/ }) - .first() - .findByLabelText(/Report File/) - .click(); - cy.wait(3000); - cy.screenshot('Opened Report File'); - cy.findByRole('button', { name: 'Edit name and description' }).click(); - cy.findByRole('textbox', { name: 'Asset Name' }).should( - 'contain.value', - 'sample' - ); - cy.findByRole('textbox', { name: 'Asset Description' }).should( - 'have.text', - '' - ); - cy.findByRole('textbox', { name: 'Asset Name' }) - .clear() - .type('Better name'); - cy.findByRole('textbox', { name: 'Asset Description' }).type( - 'This is the asset description' - ); - cy.findByRole('button', { name: /Save/i }).click(); - cy.screenshot('Saved asset'); - expect(cy.findByText('This is the asset description')).to.exist; - }); - - it('user can open preview of existing pdf asset', function() { - cy.visit( - `${Cypress.env('ORG_LABEL')}/${ - this.projectLabel - }/resources/${encodeURIComponent(this.fullResourceId)}` - ); - // Open anlaysis plugin - cy.findByRole('button', { name: /Report/i }).click(); - cy.findByText(/Cell density O1.v6-RC2-V2/i).click(); - cy.wait(3000); - cy.findByRole('listitem', { name: /sample_pdf/ }) - .findByLabelText(/Report File/) - .find('.ant-image-mask') - .first() - .click(); - cy.findByRole('button', { name: 'Edit name and description' }).click(); - cy.findByRole('textbox', { name: 'Asset Name' }).should( - 'contain.value', - 'sample' - ); - cy.findByRole('textbox', { name: 'Asset Description' }).should( - 'have.text', - '' - ); - cy.findByRole('textbox', { name: 'Asset Name' }) - .clear() - .type('Better name'); - cy.findByRole('textbox', { name: 'Asset Description' }).type( - 'This is the asset description' - ); - }); - - //TODO: investigate why this test is failing in CI - // it('user can navigate to report resource and update it directly on the resource', function() { - // cy.visit( - // `${Cypress.env('ORG_LABEL')}/${ - // this.projectLabel - // }/resources/${encodeURIComponent(this.fullResourceId)}` - // ); - // // Open report plugin - // cy.findByRole('button', { name: /Report/i }).click(); - // cy.get('.analysis') - // .findByText(/Cell density O1.v6-RC2-v2/i) - // .click(); - - // cy.findByRole('button', { - // name: /Open discussion on report resource/, - // }).click(); - // cy.wait(3000); - // cy.get('.analysis') - // .findByText(/Cell density O1.v6-RC2-v2/i) - // .click(); - // cy.findByRole('button', { name: /Edit/ }).click(); - // cy.wait(3000); - // cy.findByRole('textbox', { name: 'Report Name' }).type('-v3'); - // cy.findByRole('button', { name: 'Save' }).click(); - // cy.wait(3000); - // expect(cy.findByText(/-v3/)).to.exist; - // }); -}); From 5fde41f70734432e6b8d758b7a7ff2f534e9ae0e Mon Sep 17 00:00:00 2001 From: Dinika Saxena Date: Tue, 27 Jun 2023 09:22:38 +0200 Subject: [PATCH 03/77] 3911 // Modify cypress run in ci --- .github/workflows/review.yml | 17 +- .gitignore | 2 +- cypress.env.json | 1 + cypress/e2e/AnalysisPlugin.cy.ts | 230 +++++++++++++++++++++++ cypress/support/Studios/StudioDetails.ts | 5 + package.json | 2 +- 6 files changed, 246 insertions(+), 11 deletions(-) create mode 100644 cypress.env.json create mode 100644 cypress/e2e/AnalysisPlugin.cy.ts diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml index 0f0436563..40856d1d5 100644 --- a/.github/workflows/review.yml +++ b/.github/workflows/review.yml @@ -33,15 +33,14 @@ jobs: - name: build fusion docker image run: | docker build . --tag=nexus-web:fresh - # TODO: The following have been commented out because cypress tests are failing in the CI. Uncomment these when 3911 is fixed. - # - name: Start services - # run: docker-compose -f ci/docker-compose.yml up -d && sleep 60 - # - name: Copy nexus-web into Cypress container - # # avoids permission issue where cypress writes screenshots to host with root as user - # # which we can't then delete easily - # run: docker cp ./. cypress:/e2e - # - name: e2e tests - # run: echo | docker exec -e DEBUG=cypress:launcher:browsers -t cypress cypress run --config-file cypress.config.ts --browser chrome --record --key ${{ secrets.CYPRESS_RECORD_KEY }} + - name: Start services + run: docker-compose -f ci/docker-compose.yml up -d && sleep 60 + - name: Copy nexus-web into Cypress container + # avoids permission issue where cypress writes screenshots to host with root as user + # which we can't then delete easily + run: docker cp ./. cypress:/e2e + - name: e2e tests + run: echo | sudo docker exec -e -t cypress xvfb-run -s '-screen 0 1920x1080x24' cypress run --headed --config-file cypress.config.ts --browser chrome --record --key ${{ secrets.CYPRESS_RECORD_KEY }} - name: Cleanup Docker Containers if: ${{ always() }} run: docker-compose -f ci/docker-compose.yml down --rmi "local" --volumes diff --git a/.gitignore b/.gitignore index 14f873d4f..403eddee3 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ coverage/ yarn-error.log cypress/screenshots/ cypress/videos/ -cypress.env.json +# cypress.env.json *.iml .idea *.sops* diff --git a/cypress.env.json b/cypress.env.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/cypress.env.json @@ -0,0 +1 @@ +{} diff --git a/cypress/e2e/AnalysisPlugin.cy.ts b/cypress/e2e/AnalysisPlugin.cy.ts new file mode 100644 index 000000000..41cf0a713 --- /dev/null +++ b/cypress/e2e/AnalysisPlugin.cy.ts @@ -0,0 +1,230 @@ +import { Resource } from '@bbp/nexus-sdk'; + +describe('Report (formerly Analysis) Plugin', () => { + before(() => { + if ( + !Cypress.env('use_existing_delta_instance') || + Cypress.env('use_existing_delta_instance') === false + ) { + cy.task('auth:createRealmsAndUsers', Cypress.env('users')); + } + + cy.login( + `${Cypress.env('users').morty.username}-report-plugin`, + Cypress.env('users').morty.realm, + Cypress.env('users').morty.username, + Cypress.env('users').morty.password + ).then(session => { + cy.window().then(win => { + const authToken = win.localStorage.getItem('nexus__token'); + cy.wrap(authToken).as('nexusToken'); + + const orgLabel = Cypress.env('ORG_LABEL'); + const projectLabelBase = Cypress.env('PROJECT_LABEL_BASE'); + + cy.task('project:setup', { + nexusApiUrl: Cypress.env('NEXUS_API_URL'), + authToken, + orgLabel, + projectLabelBase, + }).then(({ projectLabel }: { projectLabel: string }) => { + cy.wrap(projectLabel).as('projectLabel'); + cy.fixture('AnalysisResource.json').then(resourcePayload => { + cy.task('resource:create', { + nexusApiUrl: Cypress.env('NEXUS_API_URL'), + authToken, + orgLabel, + projectLabel, + resourcePayload, + }).then((resource: Resource) => { + cy.wrap(resource['@id']).as('fullResourceId'); + }); + }); + }); + }); + }); + }); + + beforeEach(() => { + cy.login( + `${Cypress.env('users').morty.username}-report-plugin`, + Cypress.env('users').morty.realm, + Cypress.env('users').morty.username, + Cypress.env('users').morty.password + ); + }); + + // after(function() { + // cy.task('project:teardown', { + // nexusApiUrl: Cypress.env('NEXUS_API_URL'), + // authToken: this.nexusToken, + // orgLabel: Cypress.env('ORG_LABEL'), + // projectLabel: this.projectLabel, + // }); + // }); + + it('user can add a report with name, description and files, categories, types', function() { + cy.visit( + `${Cypress.env('ORG_LABEL')}/${ + this.projectLabel + }/resources/${encodeURIComponent(this.fullResourceId)}` + ); + cy.findByRole('button', { name: /Report/i }).click(); + cy.findByRole('button', { name: /Add Report/i }).click(); + cy.findByRole('textbox', { name: 'Report Name' }).type( + 'Cell density O1.v6-RC2' + ); + cy.findByRole('textbox', { name: 'Report Description' }).type( + 'This is where we can add a nice long description relating to why my report is better than yours.' + ); + // set category and type + cy.findByRole('button', { name: /Anatomical/ }).click(); + cy.findByRole('button', { name: /Analysis/ }).click(); + + cy.findByText(/Drag and drop files/i).click(); + cy.get('input[type=file][data-label="report-upload-file"]').attachFile( + 'sample1.png' + ); + + cy.wait(5000); + cy.screenshot('with-file-attached'); + + cy.findByRole('button', { name: 'Save' }).click(); + cy.screenshot('saving-report'); + + cy.wait(5000); + cy.screenshot('saved-report'); + }); + + it('user can edit an existing report updating its name, description, categories, types, and adding another image and pdf file', function() { + cy.visit( + `${Cypress.env('ORG_LABEL')}/${ + this.projectLabel + }/resources/${encodeURIComponent(this.fullResourceId)}` + ); + cy.url().then(url => cy.task('log', url)); + // Open report plugin + cy.findByRole('button', { name: /Report/i }).click(); + + cy.findByText(/Cell density O1.v6-RC2/i).click(); + cy.findByRole('button', { name: /Edit/ }).click(); + + cy.findByRole('textbox', { name: 'Report Name' }).type('-v2'); + cy.findByRole('textbox', { name: 'Report Description' }).type('-v2'); + cy.screenshot('updated-text'); + cy.findByRole('button', { name: 'Add Files to Report' }).click(); + cy.findByText(/Drag and drop files/i).click(); + cy.get('input[type=file][data-label="report-upload-file"]').attachFile( + 'sample2.png' + ); + cy.get('input[type=file][data-label="report-upload-file"]').attachFile( + 'sample_pdf.pdf' + ); + cy.wait(5000); + cy.screenshot('with-pdf-file-attached'); + cy.findByRole('button', { name: 'Close' }).click(); + cy.findByRole('button', { name: 'Save' }).click(); + cy.screenshot('save-updated-report'); + cy.findByText('Cell density O1.v6-RC2-v2').click(); + cy.screenshot('updated-report-saved'); + cy.findByLabelText('Report Description').should('contain', '-v2'); + cy.findAllByLabelText('Report File').should('have.length', 3); + }); + + it('user can open preview of existing image asset and edit its name and description', function() { + cy.visit( + `${Cypress.env('ORG_LABEL')}/${ + this.projectLabel + }/resources/${encodeURIComponent(this.fullResourceId)}` + ); + // Open report plugin + cy.findByRole('button', { name: /Report/i }).click(); + cy.findByText(/Cell density O1.v6-RC2/i).click(); + cy.findAllByLabelText('Report Assets'); + cy.wait(3000); + cy.findAllByRole('listitem', { name: /sample2/ }) + .first() + .findByLabelText(/Report File/) + .click(); + cy.wait(3000); + cy.screenshot('Opened Report File'); + cy.findByRole('button', { name: 'Edit name and description' }).click(); + cy.findByRole('textbox', { name: 'Asset Name' }).should( + 'contain.value', + 'sample' + ); + cy.findByRole('textbox', { name: 'Asset Description' }).should( + 'have.text', + '' + ); + cy.findByRole('textbox', { name: 'Asset Name' }) + .clear() + .type('Better name'); + cy.findByRole('textbox', { name: 'Asset Description' }).type( + 'This is the asset description' + ); + cy.findByRole('button', { name: /Save/i }).click(); + cy.screenshot('Saved asset'); + expect(cy.findByText('This is the asset description')).to.exist; + }); + + it('user can open preview of existing pdf asset', function() { + cy.visit( + `${Cypress.env('ORG_LABEL')}/${ + this.projectLabel + }/resources/${encodeURIComponent(this.fullResourceId)}` + ); + // Open anlaysis plugin + cy.findByRole('button', { name: /Report/i }).click(); + cy.findByText(/Cell density O1.v6-RC2-V2/i).click(); + cy.wait(3000); + cy.findByRole('listitem', { name: /sample_pdf/ }) + .findByLabelText(/Report File/) + .find('.ant-image-mask') + .first() + .click(); + cy.findByRole('button', { name: 'Edit name and description' }).click(); + cy.findByRole('textbox', { name: 'Asset Name' }).should( + 'contain.value', + 'sample' + ); + cy.findByRole('textbox', { name: 'Asset Description' }).should( + 'have.text', + '' + ); + cy.findByRole('textbox', { name: 'Asset Name' }) + .clear() + .type('Better name'); + cy.findByRole('textbox', { name: 'Asset Description' }).type( + 'This is the asset description' + ); + }); + + //TODO: investigate why this test is failing in CI + // it('user can navigate to report resource and update it directly on the resource', function() { + // cy.visit( + // `${Cypress.env('ORG_LABEL')}/${ + // this.projectLabel + // }/resources/${encodeURIComponent(this.fullResourceId)}` + // ); + // // Open report plugin + // cy.findByRole('button', { name: /Report/i }).click(); + // cy.get('.analysis') + // .findByText(/Cell density O1.v6-RC2-v2/i) + // .click(); + + // cy.findByRole('button', { + // name: /Open discussion on report resource/, + // }).click(); + // cy.wait(3000); + // cy.get('.analysis') + // .findByText(/Cell density O1.v6-RC2-v2/i) + // .click(); + // cy.findByRole('button', { name: /Edit/ }).click(); + // cy.wait(3000); + // cy.findByRole('textbox', { name: 'Report Name' }).type('-v3'); + // cy.findByRole('button', { name: 'Save' }).click(); + // cy.wait(3000); + // expect(cy.findByText(/-v3/)).to.exist; + // }); +}); diff --git a/cypress/support/Studios/StudioDetails.ts b/cypress/support/Studios/StudioDetails.ts index 1884306b3..6788859dd 100644 --- a/cypress/support/Studios/StudioDetails.ts +++ b/cypress/support/Studios/StudioDetails.ts @@ -38,6 +38,10 @@ export class StudioDetailsPage extends StudioListPage { } createDashboard(workspaceName, dashboardName) { + cy.intercept({ method: 'PUT', path: /resources/ }).as( + 'saveDashboardRequest' + ); + cy.findByRole('button', { name: /Dashboard/ }).click(); cy.findByRole('button', { name: /Add/ }).click(); cy.findByPlaceholderText(/Name/i).type(dashboardName); @@ -47,6 +51,7 @@ export class StudioDetailsPage extends StudioListPage { ).click(); cy.findByRole('checkbox', { name: /Enable Sort/i }).click(); cy.findByRole('button', { name: /Save/ }).click(); + cy.wait('@saveDashboardRequest'); cy.findByRole('menuitem', { name: new RegExp(workspaceName, 'i') }).click(); cy.get('ul') .contains(new RegExp(dashboardName, 'i')) diff --git a/package.json b/package.json index 745e8f307..8ac484e22 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "style:fix": "prettier --write \"./src/**/*.{ts,tsx,js,jsx,less}\"", "start:storybook": "start-storybook -p 6006", "build:storybook": "build-storybook", - "runtest": "echo | sudo docker exec -e -t cypress xvfb-run -s '-screen 0 1920x1080x24' cypress run --headed --config-file cypress.config.ts --browser /usr/bin/google-chrome" + "runtest": "echo | sudo docker exec -e DEBUG='cypress:*' -t cypress xvfb-run -s '-screen 0 1920x1080x24' cypress run --headed --config-file cypress.config.ts --browser chrome" }, "dependencies": { "@ant-design/charts": "^1.3.4", From 59e6f26aa112378925aeb24f5e0d7921df55a93e Mon Sep 17 00:00:00 2001 From: Dinika Saxena Date: Thu, 6 Jul 2023 09:37:32 +0200 Subject: [PATCH 04/77] Cypress tests should run without sudo permissions in ci --- .github/workflows/review.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml index 40856d1d5..c3af15279 100644 --- a/.github/workflows/review.yml +++ b/.github/workflows/review.yml @@ -40,7 +40,7 @@ jobs: # which we can't then delete easily run: docker cp ./. cypress:/e2e - name: e2e tests - run: echo | sudo docker exec -e -t cypress xvfb-run -s '-screen 0 1920x1080x24' cypress run --headed --config-file cypress.config.ts --browser chrome --record --key ${{ secrets.CYPRESS_RECORD_KEY }} + run: echo | docker exec -e -t cypress xvfb-run -s '-screen 0 1920x1080x24' cypress run --headed --config-file cypress.config.ts --browser chrome --record --key ${{ secrets.CYPRESS_RECORD_KEY }} - name: Cleanup Docker Containers if: ${{ always() }} run: docker-compose -f ci/docker-compose.yml down --rmi "local" --volumes From 982ff7ff7e9888f14a07d103562a0deb93b3475d Mon Sep 17 00:00:00 2001 From: Dinika Saxena Date: Thu, 6 Jul 2023 11:03:05 +0200 Subject: [PATCH 05/77] 3911 // Tests run locally with localuser --- cypress.env.json | 23 ++++++++++++++++++++++- cypress/support/Studios/StudioDetails.ts | 10 ++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/cypress.env.json b/cypress.env.json index 0967ef424..7ca828fd1 100644 --- a/cypress.env.json +++ b/cypress.env.json @@ -1 +1,22 @@ -{} +{ + "use_existing_delta_instance": false, + "NEXUS_API_URL": "https://dev.nise.bbp.epfl.ch/nexus/v1", + "users": { + "morty": { + "username": "localuser", + "password": "localuser", + "realm": { + "name": "Local", + "baseUrl": "https://dev.nise.bbp.epfl.ch/" + } + }, + "morpheus": { + "username": "localuser", + "password": "localuser", + "realm": { + "name": "Local", + "baseUrl": "https://dev.nise.bbp.epfl.ch/" + } + } + } +} diff --git a/cypress/support/Studios/StudioDetails.ts b/cypress/support/Studios/StudioDetails.ts index 6788859dd..b369f5f99 100644 --- a/cypress/support/Studios/StudioDetails.ts +++ b/cypress/support/Studios/StudioDetails.ts @@ -52,9 +52,11 @@ export class StudioDetailsPage extends StudioListPage { cy.findByRole('checkbox', { name: /Enable Sort/i }).click(); cy.findByRole('button', { name: /Save/ }).click(); cy.wait('@saveDashboardRequest'); - cy.findByRole('menuitem', { name: new RegExp(workspaceName, 'i') }).click(); - cy.get('ul') - .contains(new RegExp(dashboardName, 'i')) - .click(); + cy.findByRole('menuitem', { + name: new RegExp(workspaceName, 'i'), + }).click(); + cy.findByRole('menuitem', { + name: new RegExp(dashboardName, 'i'), + }).click(); } } From 6e199c35313be655f69ce9af5b8753c256be5e2e Mon Sep 17 00:00:00 2001 From: Dinika Saxena Date: Thu, 6 Jul 2023 16:46:22 +0200 Subject: [PATCH 06/77] Add cypress environment file Signed-off-by: Dinika Saxena --- .gitignore | 2 +- cypress.env.json | 22 ---------------------- src/shared/components/EditTableForm.tsx | 1 + 3 files changed, 2 insertions(+), 23 deletions(-) delete mode 100644 cypress.env.json diff --git a/.gitignore b/.gitignore index 403eddee3..14f873d4f 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ coverage/ yarn-error.log cypress/screenshots/ cypress/videos/ -# cypress.env.json +cypress.env.json *.iml .idea *.sops* diff --git a/cypress.env.json b/cypress.env.json deleted file mode 100644 index 7ca828fd1..000000000 --- a/cypress.env.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "use_existing_delta_instance": false, - "NEXUS_API_URL": "https://dev.nise.bbp.epfl.ch/nexus/v1", - "users": { - "morty": { - "username": "localuser", - "password": "localuser", - "realm": { - "name": "Local", - "baseUrl": "https://dev.nise.bbp.epfl.ch/" - } - }, - "morpheus": { - "username": "localuser", - "password": "localuser", - "realm": { - "name": "Local", - "baseUrl": "https://dev.nise.bbp.epfl.ch/" - } - } - } -} diff --git a/src/shared/components/EditTableForm.tsx b/src/shared/components/EditTableForm.tsx index 13caf971d..77061b3b5 100644 --- a/src/shared/components/EditTableForm.tsx +++ b/src/shared/components/EditTableForm.tsx @@ -560,6 +560,7 @@ const EditTableForm: React.FC<{ { onChangeViewDropDown(value); @@ -568,7 +567,11 @@ const EditTableForm: React.FC<{ > {availableViews && availableViews.map(view => ( - ))} diff --git a/src/subapps/studioLegacy/containers/WorkspaceMenuContainer.tsx b/src/subapps/studioLegacy/containers/WorkspaceMenuContainer.tsx index d98db8dc4..38eb6b8da 100644 --- a/src/subapps/studioLegacy/containers/WorkspaceMenuContainer.tsx +++ b/src/subapps/studioLegacy/containers/WorkspaceMenuContainer.tsx @@ -717,7 +717,9 @@ const WorkspaceMenu: React.FC = ({ expandIcon: , icon: , className: selectKeysHighlight(item.workspace), - onTitleClick: () => setSelectedWorkspace(item.workspace), + dataTestId: `workspace-item-${item.workspace.label}`, + onClick: () => setSelectedWorkspace(item.workspace), + // onTitleClick: () => setSelectedWorkspace(item.workspace), popupClassName: 'workspace-popup-classname', popupOffset: [0, 0], createdAt: item.workspace._createdAt, @@ -727,6 +729,7 @@ const WorkspaceMenu: React.FC = ({ label: dash.label, updatedAt: dash._updatedAt, key: `${item.workspace['@id']}*${dash['@id']}`, + dataTestId: `dashboard-item-${dash.label}`, onClick: () => { setSelectedDashboard(dash); setSelectedKeys([ From cda3bfbf8697733332af17af5d65a5dd7173652a Mon Sep 17 00:00:00 2001 From: Dinika Saxena Date: Thu, 6 Jul 2023 18:17:33 +0200 Subject: [PATCH 08/77] 3911 // GitHub user should own the file Signed-off-by: Dinika Saxena --- .github/workflows/review.yml | 5 ++++- .gitignore | 1 + .../__snapshots__/WorkSpaceMenuContainer.spec.tsx.snap | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml index c3af15279..5be368457 100644 --- a/.github/workflows/review.yml +++ b/.github/workflows/review.yml @@ -7,7 +7,10 @@ jobs: runs-on: it steps: - - uses: actions/checkout@v1 + - run: docker run --rm --volume $PWD/cypress/screenshots:/videos:rw bash chown -R $UID /videos + - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-node@v3 with: cache: 'yarn' diff --git a/.gitignore b/.gitignore index 14f873d4f..5a6fb5838 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ cypress.env.json *.sops* .sops-*.* *.key +*.asdcas diff --git a/src/subapps/studioLegacy/containers/__tests__/__snapshots__/WorkSpaceMenuContainer.spec.tsx.snap b/src/subapps/studioLegacy/containers/__tests__/__snapshots__/WorkSpaceMenuContainer.spec.tsx.snap index d86e0edae..4cb1ea0ca 100644 --- a/src/subapps/studioLegacy/containers/__tests__/__snapshots__/WorkSpaceMenuContainer.spec.tsx.snap +++ b/src/subapps/studioLegacy/containers/__tests__/__snapshots__/WorkSpaceMenuContainer.spec.tsx.snap @@ -17,6 +17,7 @@ exports[`workSpaceMenu renders with a single workspace and dashboard 1`] = ` >