From e63fabee6b675bbc4fecc75c4fc12ecdcfb262d4 Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Fri, 21 Jun 2024 16:40:23 -0700 Subject: [PATCH 01/10] added test "connects to (mock) sensor" --- cypress/integration/branch/sensor.data.spec.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cypress/integration/branch/sensor.data.spec.js b/cypress/integration/branch/sensor.data.spec.js index 29adecb..1088a0a 100644 --- a/cypress/integration/branch/sensor.data.spec.js +++ b/cypress/integration/branch/sensor.data.spec.js @@ -1,7 +1,7 @@ import ExperimentSetup from "../../supports/elements/ExperimentSetup" import SensorData from "../../supports/elements/SensorData"; -context.skip("Testing Experiment Selection View", () => { +context("Testing Experiment Selection View", () => { //const branch = "master" @@ -71,10 +71,13 @@ context.skip("Testing Experiment Selection View", () => { describe("Sensor Connection", () => { - it("connects to (mock) sensor", () => { - sensorData.getExperimentOptionsMenu().should('be.visible').click() - sensorData.selectMenuOption('Connect') - cy.wait(2000) + it.only("connects to (mock) sensor", () => { + + sensorData.getTab('Collect').should('be.visible').click() + sensorData.getSensorConnectionStatus().contains('No Sensor Connected').click() + // Assert the connection status + sensorData.getSensorConnectionStatus() + .should('contain.text', 'Connected: Mocked Sensor') }) it("returning to experiments list should disconnect from sensor", () => { sensorData.getBackButton().click() From 8c8e11d1276111735465c2c87bacedce66cf1a1a Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Mon, 24 Jun 2024 11:48:21 -0700 Subject: [PATCH 02/10] fixed the test "returning to experiments list should disconnect from sensor" --- cypress/integration/branch/sensor.data.spec.js | 17 +++++++++-------- cypress/supports/elements/SensorData.js | 3 +++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cypress/integration/branch/sensor.data.spec.js b/cypress/integration/branch/sensor.data.spec.js index 1088a0a..4c10df2 100644 --- a/cypress/integration/branch/sensor.data.spec.js +++ b/cypress/integration/branch/sensor.data.spec.js @@ -70,9 +70,7 @@ context("Testing Experiment Selection View", () => { }) describe("Sensor Connection", () => { - - it.only("connects to (mock) sensor", () => { - + it("connects to (mock) sensor", () => { sensorData.getTab('Collect').should('be.visible').click() sensorData.getSensorConnectionStatus().contains('No Sensor Connected').click() // Assert the connection status @@ -83,12 +81,15 @@ context("Testing Experiment Selection View", () => { sensorData.getBackButton().click() experimentSetup.getExperiment('Schoolyard Investigation', 1).click() sensorData.getTab('Collect').click() + // Assert the disconnect status sensorData.getSensorConnectionStatus().should('contain', 'No Sensor Connected') - sensorData.getExperimentOptionsMenu().click() + sensorData.getExperimentOptionsMenu() // gets the click in the helper function sensorData.selectMenuOption('Connect') - cy.wait(2000) + // Assert the connection status + sensorData.getSensorConnectionStatus() + .should('contain.text', 'Connected: Mocked Sensor') }) - it("verifies enabled sensor connection UI", () => { + it.skip("verifies enabled sensor connection UI", () => { sensorData.assertRecordButtonStatus('enabled') sensorData.getSensorConnectionStatus().contains(sensorLabels.mockSensorLabel) sensorData.getConnectedSensorValue('Temperature').should('not.contain', '--') @@ -97,7 +98,7 @@ context("Testing Experiment Selection View", () => { // sensorData.ConnectedSensorValue('Relative Humidity').should('not.contain','--') // sensorData.getConnectedSensorValue('Light').should('not.contain','--') }) - it("disconnects from mock sensor and verify UI", () => { + it.skip("disconnects from mock sensor and verify UI", () => { sensorData.getExperimentOptionsMenu().click() sensorData.selectMenuOption('Disconnect') @@ -105,7 +106,7 @@ context("Testing Experiment Selection View", () => { sensorData.getDisconnectSensorStateIcon().should('exist') sensorData.getDisconnectedSensorValue('Temperature').should('contain', '--') }) - it("collects data from (mock) sensor", () => { + it.skip("collects data from (mock) sensor", () => { sensorData.getExperimentOptionsMenu().click() sensorData.selectMenuOption('Connect') diff --git a/cypress/supports/elements/SensorData.js b/cypress/supports/elements/SensorData.js index 95ecf30..0304ce8 100644 --- a/cypress/supports/elements/SensorData.js +++ b/cypress/supports/elements/SensorData.js @@ -63,6 +63,9 @@ class SensorData { getExperimentOptionsMenu() { return cy.get('.data-table-field-module-dataTable-vortex').within(() => { cy.get('.menu-module-menuIcon-vortex') + .should('exist') + .and('be.visible') + .click({ force: true }) // click is here to get the helper function to work }) } From dbf2f9b1ab89a2647781b9281e4a47554444a3b2 Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Mon, 24 Jun 2024 14:29:19 -0700 Subject: [PATCH 03/10] fixed remaining broken cypress tests in sensor.data.spec --- .../integration/branch/sensor.data.spec.js | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/cypress/integration/branch/sensor.data.spec.js b/cypress/integration/branch/sensor.data.spec.js index 4c10df2..ba42471 100644 --- a/cypress/integration/branch/sensor.data.spec.js +++ b/cypress/integration/branch/sensor.data.spec.js @@ -89,8 +89,12 @@ context("Testing Experiment Selection View", () => { sensorData.getSensorConnectionStatus() .should('contain.text', 'Connected: Mocked Sensor') }) - it.skip("verifies enabled sensor connection UI", () => { - sensorData.assertRecordButtonStatus('enabled') + it("verifies enabled sensor connection UI", () => { + sensorData.getBackButton().click() + experimentSetup.getExperiment('Schoolyard Investigation', 1).click() + sensorData.getTab('Collect').click() + sensorData.getExperimentOptionsMenu() // gets the click in the helper function + sensorData.selectMenuOption('Connect') sensorData.getSensorConnectionStatus().contains(sensorLabels.mockSensorLabel) sensorData.getConnectedSensorValue('Temperature').should('not.contain', '--') // Not able to get a second sensor value, Temp is enough for now @@ -98,16 +102,24 @@ context("Testing Experiment Selection View", () => { // sensorData.ConnectedSensorValue('Relative Humidity').should('not.contain','--') // sensorData.getConnectedSensorValue('Light').should('not.contain','--') }) - it.skip("disconnects from mock sensor and verify UI", () => { - sensorData.getExperimentOptionsMenu().click() + it("disconnects from mock sensor and verify UI", () => { + sensorData.getBackButton().click() + experimentSetup.getExperiment('Schoolyard Investigation', 1).click() + sensorData.getTab('Collect').click() + sensorData.getExperimentOptionsMenu() // gets the click in the helper function + sensorData.selectMenuOption('Connect') + sensorData.getExperimentOptionsMenu() sensorData.selectMenuOption('Disconnect') sensorData.getSensorConnectionStatus().contains('No Sensor Connected') sensorData.getDisconnectSensorStateIcon().should('exist') sensorData.getDisconnectedSensorValue('Temperature').should('contain', '--') }) - it.skip("collects data from (mock) sensor", () => { - sensorData.getExperimentOptionsMenu().click() + it("collects data from (mock) sensor", () => { + sensorData.getBackButton().click() + experimentSetup.getExperiment('Schoolyard Investigation', 1).click() + sensorData.getTab('Collect').click() + sensorData.getExperimentOptionsMenu() // gets the click in the helper function sensorData.selectMenuOption('Connect') for (let i = 0; i <= 5; i++) { From f4f67f837cccfec62ae26bf34a4e311276ff9786 Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Wed, 26 Jun 2024 16:14:34 -0700 Subject: [PATCH 04/10] update to SensorData test --- cypress/supports/elements/SensorData.js | 1 - 1 file changed, 1 deletion(-) diff --git a/cypress/supports/elements/SensorData.js b/cypress/supports/elements/SensorData.js index 0304ce8..e4f70df 100644 --- a/cypress/supports/elements/SensorData.js +++ b/cypress/supports/elements/SensorData.js @@ -77,7 +77,6 @@ class SensorData { getRecordButton() { return cy.get('[data-test="record-sensor"]') } - assertRecordButtonStatus(status) { if (status == 'enabled') { return this.getRecordButton().should('have.class', 'data-table-field-module-active-vortex') From b8eb268f63cafdfef037aba1b4f5996fd569b3aa Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Thu, 27 Jun 2024 16:50:04 -0700 Subject: [PATCH 05/10] setup for test "create and setup a data trial" including new helper function --- .../branch/experiment.setup.spec.js | 35 +++++++++++++++++++ cypress/supports/elements/SensorData.js | 16 +++++++++ 2 files changed, 51 insertions(+) diff --git a/cypress/integration/branch/experiment.setup.spec.js b/cypress/integration/branch/experiment.setup.spec.js index 2bfaf5e..1434387 100644 --- a/cypress/integration/branch/experiment.setup.spec.js +++ b/cypress/integration/branch/experiment.setup.spec.js @@ -1,4 +1,5 @@ import ExperimentSetup from "../../supports/elements/ExperimentSetup" +import SensorData from "../../supports/elements/SensorData" context("Testing Experiment Selection View", () => { @@ -15,6 +16,8 @@ context("Testing Experiment Selection View", () => { let studySite2 = "Study Site #2" let defaultSchoolyardInvestigation = "Schoolyard Investigation #1" + let sensorData = new SensorData(); + before(() => { cy.visit(url); }); @@ -100,4 +103,36 @@ context("Testing Experiment Selection View", () => { experimentSetup.deleteExperiment() }) }) + + describe("Tests Data Trial", () => { + + it.only("create and setup a data trial", () => { + experimentSetup.openNewExperiment('Data Trial') + //cy.wait(500) + + sensorData.getExperimentOptionsMenu() // gets the click in the helper function + sensorData.selectMenuOption('Connect') + + // Select and verify the "Mocked Sensor: Temperature" option + sensorData.selectSensor('Temperature') + cy.get('div.sensor-module-connectionLabel-vortex select') + .should('have.value', '1'); + + }) + // this is pasted code from above + // it("edit experiment and verify changes", () => { + // experimentSetup.getExperiment('Stream Study', 1).click() + // experimentSetup.getExperimentNameSpan().click() + // experimentSetup.getNameInput().type(testLabel2) + // experimentSetup.getGroupMembersTextBox().type(testGroupMembers) + // experimentSetup.getSubheader(testLabel2) + // experimentSetup.getBackButton().click() + // experimentSetup.expandAllExperimentLabels() + // experimentSetup.getExperimentLabel(testLabel2).should('be.visible') + // }) + + // it("deletes Stream Study experiment", () => { + // experimentSetup.deleteExperiment() + // }) + }) }) \ No newline at end of file diff --git a/cypress/supports/elements/SensorData.js b/cypress/supports/elements/SensorData.js index e4f70df..22cfbf1 100644 --- a/cypress/supports/elements/SensorData.js +++ b/cypress/supports/elements/SensorData.js @@ -46,6 +46,22 @@ class SensorData { cy.get('.sensor-value-module-connectedValue-vortex') }) } + selectSensor(input){ + // Click to focus on the select dropdown (adjust the selector as needed) + cy.get('div.sensor-module-connectionLabel-vortex select').focus(); + + if (input === 'Force') { + // Select the "Mocked Sensor: Force" option + cy.get('div.sensor-module-connectionLabel-vortex select').select('Mocked Sensor: Force'); + return 'Mocked Sensor: Force'; + } else if (input === 'Temperature') { + // Select the "Mocked Sensor: Temperature" option + cy.get('div.sensor-module-connectionLabel-vortex select').select('Mocked Sensor: Temperature'); + return 'Mocked Sensor: Temperature'; + } else { + throw new Error('Invalid input: please specify either "Force" or "Temperature"'); + } + } getDataRow(index) { return cy.get('.data-table-field-module-refreshSensorReading-vortex').eq(index - 1).parent().parent() From 2f285150df8f110134ff649e70c41b890f2158dd Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Fri, 12 Jul 2024 15:48:56 -0700 Subject: [PATCH 06/10] add helper function selectSensor --- cypress/supports/elements/SensorData.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/supports/elements/SensorData.js b/cypress/supports/elements/SensorData.js index 22cfbf1..7c89a76 100644 --- a/cypress/supports/elements/SensorData.js +++ b/cypress/supports/elements/SensorData.js @@ -46,7 +46,7 @@ class SensorData { cy.get('.sensor-value-module-connectedValue-vortex') }) } - selectSensor(input){ + selectSensor(sensorType){ // Click to focus on the select dropdown (adjust the selector as needed) cy.get('div.sensor-module-connectionLabel-vortex select').focus(); From 7cdd90a88546767eee8796cb341ce724c810e193 Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Fri, 12 Jul 2024 17:21:44 -0700 Subject: [PATCH 07/10] add time series display checks --- .../branch/experiment.setup.spec.js | 22 ++++++++++--- cypress/supports/elements/SensorData.js | 31 +++++++++++++++++-- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/cypress/integration/branch/experiment.setup.spec.js b/cypress/integration/branch/experiment.setup.spec.js index 1434387..98a2421 100644 --- a/cypress/integration/branch/experiment.setup.spec.js +++ b/cypress/integration/branch/experiment.setup.spec.js @@ -106,9 +106,8 @@ context("Testing Experiment Selection View", () => { describe("Tests Data Trial", () => { - it.only("create and setup a data trial", () => { + it.only("collect time series data from (mock) sensor", () => { experimentSetup.openNewExperiment('Data Trial') - //cy.wait(500) sensorData.getExperimentOptionsMenu() // gets the click in the helper function sensorData.selectMenuOption('Connect') @@ -116,8 +115,23 @@ context("Testing Experiment Selection View", () => { // Select and verify the "Mocked Sensor: Temperature" option sensorData.selectSensor('Temperature') cy.get('div.sensor-module-connectionLabel-vortex select') - .should('have.value', '1'); - + .should('have.value', '1') + // Assert the connection status + sensorData.getSensorConnectionStatus() + .should('contain.text', 'Connected: Mocked Sensor') + + // select the sample rate + sensorData.selectSample('100/sec') + // TODO: add checks that time series data displays + // and UI is disabled during time series checks + // Blocker: PT #187949831 + // also fix expected to find element 5 error (probably just need x-1) + for (let i = 0; i <= 5; i++) { + sensorData.getDataTrialRow(i).within(() => { + sensorData.getRecordButton().click() + cy.wait(20000) // wait for new sensor values + }) + } }) // this is pasted code from above // it("edit experiment and verify changes", () => { diff --git a/cypress/supports/elements/SensorData.js b/cypress/supports/elements/SensorData.js index 7c89a76..3390336 100644 --- a/cypress/supports/elements/SensorData.js +++ b/cypress/supports/elements/SensorData.js @@ -46,7 +46,7 @@ class SensorData { cy.get('.sensor-value-module-connectedValue-vortex') }) } - selectSensor(sensorType){ + selectSensor(input){ // Click to focus on the select dropdown (adjust the selector as needed) cy.get('div.sensor-module-connectionLabel-vortex select').focus(); @@ -62,10 +62,37 @@ class SensorData { throw new Error('Invalid input: please specify either "Force" or "Temperature"'); } } - + selectSample(input) { + // Click to focus on the select dropdown (adjust the selector as needed) + cy.get('div.sensor-module-tsvInfoRow-vortex select').focus(); + + // Define the valid options + const options = [ + '0.1/sec', + '0.5/sec', + '1/sec', + '2/sec', + '5/sec', + '20/sec', + '50/sec', + '100/sec' + ]; + + // Check if the input is one of the valid options + if (options.includes(input)) { + // Select the specified option + cy.get('div.sensor-module-tsvInfoRow-vortex select').select(input); + return input; + } else { + throw new Error(`Invalid input: please specify one of the following options: ${options.join(', ')}`); + } + } getDataRow(index) { return cy.get('.data-table-field-module-refreshSensorReading-vortex').eq(index - 1).parent().parent() } + getDataTrialRow(index) { + return cy.get('.data-table-field-module-refreshSensorReading-vortex').eq(index).parent().parent() + } getCompletedDataRow(index) { // this is only the complete data row with data recorded from sensor/mock sensor From a2d3a7499325e02ddd89fe817cdc8cabb853b0ba Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Mon, 15 Jul 2024 11:58:54 -0700 Subject: [PATCH 08/10] added checks for time series display in top row --- .../branch/experiment.setup.spec.js | 49 ++++++++++++++++--- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/cypress/integration/branch/experiment.setup.spec.js b/cypress/integration/branch/experiment.setup.spec.js index 98a2421..f83812c 100644 --- a/cypress/integration/branch/experiment.setup.spec.js +++ b/cypress/integration/branch/experiment.setup.spec.js @@ -119,19 +119,54 @@ context("Testing Experiment Selection View", () => { // Assert the connection status sensorData.getSensorConnectionStatus() .should('contain.text', 'Connected: Mocked Sensor') - + + // Check that the input fields are disabled + const labelSelectors = [ + 'input[placeholder="Label #1"]', + 'input[placeholder="Label #2"]', + 'input[placeholder="Label #3"]', + 'input[placeholder="Label #4"]', + 'input[placeholder="Label #5"]' + ] + // select the sample rate sensorData.selectSample('100/sec') + sensorData.getRecordButton().first().click() + // Check the data collection every 1 second for a total of 5 seconds + // Note: after 5 sec Cypress starts failing the test because of missed + // time. This should be enough for now to ensure that the test is at + // least starting. + const checkTimes = [1, 2, 3, 4, 5] + checkTimes.forEach((time) => { + cy.wait(time * 100) + cy.get('.data-table-field-module-sparkgraphContainer-vortex') + .contains(`${time} sec`) + .should('be.visible') + }) + labelSelectors.forEach((selector) => { + cy.get(selector).should('be.disabled') + // Check that the connected icon button is disabled + cy.get('div.sensor-module-connectionLabel-vortex select').should('be.disabled') + + // Check that the sample rate dropdown is disabled + cy.get('.sensor-module-tsvInfoRow-vortex select').should('be.disabled') + }) + // Checks to make sure that the run automatically stops and final display + // is 10 sec + cy.wait(2000) + cy.get('.data-table-field-module-sparkgraphContainer-vortex') + .contains(`10 sec`) + // TODO: add checks that time series data displays // and UI is disabled during time series checks // Blocker: PT #187949831 // also fix expected to find element 5 error (probably just need x-1) - for (let i = 0; i <= 5; i++) { - sensorData.getDataTrialRow(i).within(() => { - sensorData.getRecordButton().click() - cy.wait(20000) // wait for new sensor values - }) - } + // for (let i = 0; i <= 5; i++) { + // sensorData.getDataTrialRow(i).within(() => { + // sensorData.getRecordButton().click() + // cy.wait(20000) // wait for new sensor values + // }) + // } }) // this is pasted code from above // it("edit experiment and verify changes", () => { From b8a48f78f9ec5270c96932bada10f7b2de689526 Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Mon, 15 Jul 2024 16:06:11 -0700 Subject: [PATCH 09/10] checks that input fields work as expected --- .../branch/experiment.setup.spec.js | 179 +++++++++++++----- 1 file changed, 136 insertions(+), 43 deletions(-) diff --git a/cypress/integration/branch/experiment.setup.spec.js b/cypress/integration/branch/experiment.setup.spec.js index f83812c..88e1c8b 100644 --- a/cypress/integration/branch/experiment.setup.spec.js +++ b/cypress/integration/branch/experiment.setup.spec.js @@ -106,36 +106,40 @@ context("Testing Experiment Selection View", () => { describe("Tests Data Trial", () => { - it.only("collect time series data from (mock) sensor", () => { + it("collect time series data from (mock) sensor", () => { + + // Constants will check that the input fields are disabled + const labelSelectors = [ + 'input[placeholder="Label #1"]', + 'input[placeholder="Label #2"]', + 'input[placeholder="Label #3"]', + 'input[placeholder="Label #4"]', + 'input[placeholder="Label #5"]' + ] + // Open a new Data Trial experimentSetup.openNewExperiment('Data Trial') sensorData.getExperimentOptionsMenu() // gets the click in the helper function - sensorData.selectMenuOption('Connect') // Select and verify the "Mocked Sensor: Temperature" option + cy.log('Select and verify mocked sensor') + sensorData.selectMenuOption('Connect') sensorData.selectSensor('Temperature') cy.get('div.sensor-module-connectionLabel-vortex select') - .should('have.value', '1') + .should('have.value', '1') // Assert the connection status sensorData.getSensorConnectionStatus() - .should('contain.text', 'Connected: Mocked Sensor') - - // Check that the input fields are disabled - const labelSelectors = [ - 'input[placeholder="Label #1"]', - 'input[placeholder="Label #2"]', - 'input[placeholder="Label #3"]', - 'input[placeholder="Label #4"]', - 'input[placeholder="Label #5"]' - ] + .should('contain.text', 'Connected: Mocked Sensor') - // select the sample rate + // Select the sample rate sensorData.selectSample('100/sec') + + // Start recording data trial sensorData.getRecordButton().first().click() // Check the data collection every 1 second for a total of 5 seconds - // Note: after 5 sec Cypress starts failing the test because of missed - // time. This should be enough for now to ensure that the test is at - // least starting. + // Note: after 5 sec Cypress starts failing the test because the timing + // isn't perfectly synchronized. A duration of 5 seconds will ensure that + // the trial is at least starting. const checkTimes = [1, 2, 3, 4, 5] checkTimes.forEach((time) => { cy.wait(time * 100) @@ -143,45 +147,134 @@ context("Testing Experiment Selection View", () => { .contains(`${time} sec`) .should('be.visible') }) + + // Check that the selectors are disabled during collection run. labelSelectors.forEach((selector) => { cy.get(selector).should('be.disabled') // Check that the connected icon button is disabled cy.get('div.sensor-module-connectionLabel-vortex select').should('be.disabled') - // Check that the sample rate dropdown is disabled cy.get('.sensor-module-tsvInfoRow-vortex select').should('be.disabled') }) - // Checks to make sure that the run automatically stops and final display - // is 10 sec - cy.wait(2000) + // Checks to make sure that the run automatically stops after the max time + // and final display is 10 sec + cy.wait(10000) cy.get('.data-table-field-module-sparkgraphContainer-vortex') .contains(`10 sec`) + // Checks that it's possible to stop recording in the middle of a time trial + cy.log('checks that it is possible to stop recording in the middle of a time trial') + sensorData.getRecordButton().last().click() + labelSelectors.forEach((selector) => { + cy.get(selector).should('be.disabled') + // Check that the connected icon button is disabled + cy.get('div.sensor-module-connectionLabel-vortex select').should('be.disabled') + + // Check that the sample rate dropdown is disabled + cy.get('.sensor-module-tsvInfoRow-vortex select').should('be.disabled') + }) + cy.wait(5000) + sensorData.getRecordButton().last().click() + // TODO: add checks that time series data displays - // and UI is disabled during time series checks + // for all elements in the table elements // Blocker: PT #187949831 // also fix expected to find element 5 error (probably just need x-1) - // for (let i = 0; i <= 5; i++) { - // sensorData.getDataTrialRow(i).within(() => { - // sensorData.getRecordButton().click() - // cy.wait(20000) // wait for new sensor values - // }) - // } + // for (let i = 0; i <= 5; i++) { + // sensorData.getDataTrialRow(i).within(() => { + // sensorData.getRecordButton().click() + // cy.wait(20000) // wait for new sensor values + // }) + // } + + // cy.log('Delete the trial run') + // The delete tests are not working now because Cypress won't + // recognize the delete button. Putting this code here for now + // in case it's fixable + // sensorData.getRecordButton().first().click({force:true}) + // cy.wait(1000) + // // Wait for the confirmation dialog to appear and verify the text + // // Check if the confirmation dialog is present and interact with it + // // Intercept the window confirm dialog and automatically click "OK" + // cy.on('window:confirm', (txt) => { + // // Assertion to check the text of the confirmation dialog + // expect(txt).to.contains('delete trial? this will delete the trial') + // return true; // This will simulate clicking the "OK" button + // }) + + // // Checks to make sure that the top line was deleted and defaulted. + // cy.get('.data-table-field-module-sparkgraphContainer-vortex').first() + // .contains(`^0 sec`) + // .should('be.visible') + // cy.get(labelSelectors[0]).should('have.attr', 'placeholder', 'Label #1') + + }) + it("checks that labels can be renamed and retain new names after a data trial run", () => { + cy.visit(url); + // Define the label selectors and new labels + const labelSelectors = [ + 'input[placeholder="Label #1"]', + 'input[placeholder="Label #2"]', + 'input[placeholder="Label #3"]', + 'input[placeholder="Label #4"]', + 'input[placeholder="Label #5"]' + ] + const newLabels = [ + 'New Label #1', + 'New Label #2', + 'New Label #3', + 'New Label #4', + 'New Label #5' + ] + + // Open a new Data Trial + experimentSetup.openNewExperiment('Data Trial') + + sensorData.getExperimentOptionsMenu() // gets the click in the helper function + + // Select and verify the "Mocked Sensor: Force" option + // Used force sensor to vary it up for QA + cy.log('Select and verify mocked sensor') + sensorData.selectMenuOption('Connect') + sensorData.selectSensor('Force') + cy.get('div.sensor-module-connectionLabel-vortex select') + .should('have.value', '0') + // Assert the connection status + sensorData.getSensorConnectionStatus() + .should('contain.text', 'Connected: Mocked Sensor') + + // Select the sample rate + sensorData.selectSample('20/sec') + + // Ensure the input fields are not disabled before the collection run and rename labels + labelSelectors.forEach((selector, index) => { + cy.get(selector) + .should('not.be.disabled') + .clear() + .type(newLabels[index]) + .should('have.value', newLabels[index]) + }) + + // Start the data collection + sensorData.getRecordButton().first().click() + + // Check that the selectors are disabled during collection run + // (this checks that the run is going) + labelSelectors.forEach((selector) => { + cy.get(selector).should('be.disabled') + }) + + // Wait for the data collection to go a bit (adjust time as necessary) + cy.wait(5000) + // stop the data collection + sensorData.getRecordButton().first().click() + + // After the data collection, check that the labels retain their new names + labelSelectors.forEach((selector, index) => { + cy.get(selector) + .should('not.be.disabled') + .should('have.value', newLabels[index]) + }) }) - // this is pasted code from above - // it("edit experiment and verify changes", () => { - // experimentSetup.getExperiment('Stream Study', 1).click() - // experimentSetup.getExperimentNameSpan().click() - // experimentSetup.getNameInput().type(testLabel2) - // experimentSetup.getGroupMembersTextBox().type(testGroupMembers) - // experimentSetup.getSubheader(testLabel2) - // experimentSetup.getBackButton().click() - // experimentSetup.expandAllExperimentLabels() - // experimentSetup.getExperimentLabel(testLabel2).should('be.visible') - // }) - - // it("deletes Stream Study experiment", () => { - // experimentSetup.deleteExperiment() - // }) }) }) \ No newline at end of file From 4fb8c38dfe8a687f9caee59844ce240d73e8f4dd Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Wed, 17 Jul 2024 11:44:20 -0700 Subject: [PATCH 10/10] add delete data trial test and also make tweaks to collect data trial test --- cypress.json | 2 +- .../branch/experiment.setup.spec.js | 43 +++++++------------ cypress/supports/elements/ExperimentSetup.js | 6 ++- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/cypress.json b/cypress.json index 18b7185..2c2d25e 100644 --- a/cypress.json +++ b/cypress.json @@ -3,5 +3,5 @@ "video": false, "fixturesFolder": false, "supportFile": false, - "defaultCommandTimeout": 8000 + "defaultCommandTimeout": 12000 } \ No newline at end of file diff --git a/cypress/integration/branch/experiment.setup.spec.js b/cypress/integration/branch/experiment.setup.spec.js index 88e1c8b..dfca9b4 100644 --- a/cypress/integration/branch/experiment.setup.spec.js +++ b/cypress/integration/branch/experiment.setup.spec.js @@ -105,7 +105,7 @@ context("Testing Experiment Selection View", () => { }) describe("Tests Data Trial", () => { - + it("collect time series data from (mock) sensor", () => { // Constants will check that the input fields are disabled @@ -136,11 +136,8 @@ context("Testing Experiment Selection View", () => { // Start recording data trial sensorData.getRecordButton().first().click() - // Check the data collection every 1 second for a total of 5 seconds - // Note: after 5 sec Cypress starts failing the test because the timing - // isn't perfectly synchronized. A duration of 5 seconds will ensure that - // the trial is at least starting. - const checkTimes = [1, 2, 3, 4, 5] + // Check the data collection every 1 second for the duration of the run (10 sec) + const checkTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] checkTimes.forEach((time) => { cy.wait(time * 100) cy.get('.data-table-field-module-sparkgraphContainer-vortex') @@ -163,6 +160,7 @@ context("Testing Experiment Selection View", () => { .contains(`10 sec`) // Checks that it's possible to stop recording in the middle of a time trial + // also checks that UI disables during a run cy.log('checks that it is possible to stop recording in the middle of a time trial') sensorData.getRecordButton().last().click() labelSelectors.forEach((selector) => { @@ -187,27 +185,18 @@ context("Testing Experiment Selection View", () => { // }) // } - // cy.log('Delete the trial run') - // The delete tests are not working now because Cypress won't - // recognize the delete button. Putting this code here for now - // in case it's fixable - // sensorData.getRecordButton().first().click({force:true}) - // cy.wait(1000) - // // Wait for the confirmation dialog to appear and verify the text - // // Check if the confirmation dialog is present and interact with it - // // Intercept the window confirm dialog and automatically click "OK" - // cy.on('window:confirm', (txt) => { - // // Assertion to check the text of the confirmation dialog - // expect(txt).to.contains('delete trial? this will delete the trial') - // return true; // This will simulate clicking the "OK" button - // }) - - // // Checks to make sure that the top line was deleted and defaulted. - // cy.get('.data-table-field-module-sparkgraphContainer-vortex').first() - // .contains(`^0 sec`) - // .should('be.visible') - // cy.get(labelSelectors[0]).should('have.attr', 'placeholder', 'Label #1') - + cy.log('Delete the trial run') + sensorData.getRecordButton().first().click({force:true}) + cy.wait(1000) + // Wait for the confirmation dialog to appear and verify the text + // Check if the confirmation dialog is present and interact with it + // Intercept the window confirm dialog and automatically click "OK" + experimentSetup.deleteDataTrialExperiment() + // Checks to make sure that the top line was deleted and defaulted. + cy.get('.data-table-field-module-sparkgraphContainer-vortex').first() + .contains(/^0 sec$/) + .should('be.visible') + cy.get(labelSelectors[0]).should('have.attr', 'placeholder', 'Label #1') }) it("checks that labels can be renamed and retain new names after a data trial run", () => { cy.visit(url); diff --git a/cypress/supports/elements/ExperimentSetup.js b/cypress/supports/elements/ExperimentSetup.js index 3ad61a9..97cecd6 100644 --- a/cypress/supports/elements/ExperimentSetup.js +++ b/cypress/supports/elements/ExperimentSetup.js @@ -38,7 +38,11 @@ class ExperimentSetup { cy.get('.menu-module-menu-vortex').contains('Delete').click() }) } - + deleteDataTrialExperiment() { + return cy.get('[data-test="record-sensor"]').first().click()//.then(() => { + //cy.get('.menu-module-menu-vortex').contains('Delete').click() + // }) + } // Label Tab UI selectors needed getBackButton() {