From a247e95af75374d79a6775d90ef922fae9958d32 Mon Sep 17 00:00:00 2001 From: zwatson2001 Date: Tue, 24 Sep 2024 13:54:09 -0400 Subject: [PATCH 1/5] add matrix reasoning test --- task-launcher/cypress/e2e/matrix_reasoning.cy.js | 10 ++++++++++ task-launcher/cypress/support/e2e.js | 9 +++++++++ 2 files changed, 19 insertions(+) create mode 100644 task-launcher/cypress/e2e/matrix_reasoning.cy.js diff --git a/task-launcher/cypress/e2e/matrix_reasoning.cy.js b/task-launcher/cypress/e2e/matrix_reasoning.cy.js new file mode 100644 index 00000000..e064d139 --- /dev/null +++ b/task-launcher/cypress/e2e/matrix_reasoning.cy.js @@ -0,0 +1,10 @@ +import {testImageAfc} from './helpers.cy.js' + +const matrix_reasoning_url = 'http://localhost:8080/?task=matrix-reasoning' + +describe('test matrix reasoning', () => { + it('visits matrix reasoning and plays game', () => { + cy.visit(matrix_reasoning_url); + testImageAfc(true, '.image', 4); + }) +}) \ No newline at end of file diff --git a/task-launcher/cypress/support/e2e.js b/task-launcher/cypress/support/e2e.js index 40ff1ae2..12a6c861 100644 --- a/task-launcher/cypress/support/e2e.js +++ b/task-launcher/cypress/support/e2e.js @@ -20,3 +20,12 @@ import './commands' // require('./commands') import "cypress-real-events"; + +// prevent permissions check failed exception from failing test +/* +Cypress.on('uncaught:exception', (err, runnable) => { + if (err.message.includes('user not in Firestore')){ + return false + } +}) +*/ \ No newline at end of file From b4ff66d2af33e267f1068b8627f554190b905af4 Mon Sep 17 00:00:00 2001 From: zwatson2001 Date: Fri, 27 Sep 2024 11:41:22 -0400 Subject: [PATCH 2/5] add TOM test and allow retries for all tests --- task-launcher/cypress.config.js | 4 ++ task-launcher/cypress/e2e/helpers.cy.js | 47 ++++++++++--------- .../cypress/e2e/matrix_reasoning.cy.js | 2 +- .../cypress/e2e/mental_rotation_test.cy.js | 2 +- .../cypress/e2e/theory_of_mind.cy.js | 10 ++++ task-launcher/cypress/e2e/trog_test.cy.js | 2 +- task-launcher/cypress/e2e/vocab_test.cy.js | 2 +- task-launcher/cypress/support/e2e.js | 6 +-- .../src/tasks/shared/trials/afcStimulus.ts | 6 +-- 9 files changed, 48 insertions(+), 33 deletions(-) create mode 100644 task-launcher/cypress/e2e/theory_of_mind.cy.js diff --git a/task-launcher/cypress.config.js b/task-launcher/cypress.config.js index 17161e32..e9a0202d 100644 --- a/task-launcher/cypress.config.js +++ b/task-launcher/cypress.config.js @@ -6,4 +6,8 @@ export default defineConfig({ // implement node event listeners here }, }, + retries: { + runMode: 2, + openMode: 0 + } }); diff --git a/task-launcher/cypress/e2e/helpers.cy.js b/task-launcher/cypress/e2e/helpers.cy.js index 4920b85c..e3eb9f14 100644 --- a/task-launcher/cypress/e2e/helpers.cy.js +++ b/task-launcher/cypress/e2e/helpers.cy.js @@ -1,14 +1,22 @@ // clicks 'OK' button until instructions are complete function clickThroughInstructions(){ - cy.get('.jspsych-audio-multi-response-button').then((buttonWrapper) => { - if (buttonWrapper.find('.primary').length > 0){ + // if footer is present, the task has ended + cy.get('.lev-stimulus-container').then((content) => { + if (content.find('footer').length === 1){ + return; + } else { + // otherwise check for OK button, indicating instruction phase + cy.get('.jspsych-audio-multi-response-button').then((buttonWrapper) => { + if (buttonWrapper.find('.primary').length > 0){ cy.contains('OK').click({timeout: 15000}); clickThroughInstructions(); - } else { - return; + } else { + return; + } + }); } - }); - } + }); +} function handlePracticeButtons(){ cy.wait(500); @@ -26,23 +34,19 @@ function handlePracticeButtons(){ } // clicks first image option until game is over -function selectImages(correct, imgClass, numberOfButtons){ +function selectImages(correct, imgClass){ + clickThroughInstructions(); handlePracticeButtons(); - cy.get('.lev-stimulus-container', {timeout: 10000}).should('exist'); // wait for fixation cross to go away + cy.get('.lev-stimulus-container', {timeout: 10000}).should('exist'); cy.get('.jspsych-content').then((content) => { - if (content.find('.jspsych-audio-multi-response-button').length === numberOfButtons){ - if (correct){ - cy.get(imgClass).each((button) => { - const image = button.find('img')[0]; - if ((image.alt).includes('correct')){ - button.click(); - } - }) + if (content.find('.jspsych-audio-multi-response-button').length > 1){ + if (correct){ + cy.get('.correct').click({timeout: 30000}); // add timeout to handle staggered buttons } else { - cy.get(imgClass).eq(0).click(); + cy.get(imgClass).eq(0).click({timeout: 30000}); } - selectImages(correct, imgClass, numberOfButtons); + selectImages(correct, imgClass); } else { cy.contains('Thank you!').should('exist'); return; @@ -50,11 +54,10 @@ function selectImages(correct, imgClass, numberOfButtons){ }); } -export function testImageAfc(correct, imgClass, numberOfButtons){ +export function testImageAfc(correct, imgClass){ // wait for OK button to be visible - cy.contains('OK', {timeout: 120000}).should('be.visible'); + cy.contains('OK', {timeout: 300000}).should('be.visible'); cy.contains('OK').realClick(); // real click mimics user gesture so that fullscreen can start - clickThroughInstructions(); - selectImages(correct, imgClass, numberOfButtons); + selectImages(correct, imgClass); cy.contains('Exit').click(); } \ No newline at end of file diff --git a/task-launcher/cypress/e2e/matrix_reasoning.cy.js b/task-launcher/cypress/e2e/matrix_reasoning.cy.js index e064d139..92888bc7 100644 --- a/task-launcher/cypress/e2e/matrix_reasoning.cy.js +++ b/task-launcher/cypress/e2e/matrix_reasoning.cy.js @@ -5,6 +5,6 @@ const matrix_reasoning_url = 'http://localhost:8080/?task=matrix-reasoning' describe('test matrix reasoning', () => { it('visits matrix reasoning and plays game', () => { cy.visit(matrix_reasoning_url); - testImageAfc(true, '.image', 4); + testImageAfc(true, '.image'); }) }) \ No newline at end of file diff --git a/task-launcher/cypress/e2e/mental_rotation_test.cy.js b/task-launcher/cypress/e2e/mental_rotation_test.cy.js index da50e768..6df051be 100644 --- a/task-launcher/cypress/e2e/mental_rotation_test.cy.js +++ b/task-launcher/cypress/e2e/mental_rotation_test.cy.js @@ -5,6 +5,6 @@ const mental_rotation_url = 'http://localhost:8080/?task=mental-rotation' describe('test mental rotation', () => { it('visits mental rotation and plays game', () => { cy.visit(mental_rotation_url); - testImageAfc(true, '.image-large', 2); + testImageAfc(true, '.image-large'); }) }) \ No newline at end of file diff --git a/task-launcher/cypress/e2e/theory_of_mind.cy.js b/task-launcher/cypress/e2e/theory_of_mind.cy.js new file mode 100644 index 00000000..bfed3c72 --- /dev/null +++ b/task-launcher/cypress/e2e/theory_of_mind.cy.js @@ -0,0 +1,10 @@ +import {testImageAfc} from './helpers.cy.js' + +const TOM_url = 'http://localhost:8080/?task=theory-of-mind' + +describe('test theory of mind', () => { + it('visits theory of mind and plays game', () => { + cy.visit(TOM_url); + testImageAfc(true, '.image'); + }) +}) \ No newline at end of file diff --git a/task-launcher/cypress/e2e/trog_test.cy.js b/task-launcher/cypress/e2e/trog_test.cy.js index db74db72..441d0ab7 100644 --- a/task-launcher/cypress/e2e/trog_test.cy.js +++ b/task-launcher/cypress/e2e/trog_test.cy.js @@ -5,6 +5,6 @@ const trog_url = 'http://localhost:8080/?task=trog' describe('test trog', () => { it('visits trog and plays game', () => { cy.visit(trog_url); - testImageAfc(true, '.image-medium', 4); + testImageAfc(true, '.image-medium'); }) }) \ No newline at end of file diff --git a/task-launcher/cypress/e2e/vocab_test.cy.js b/task-launcher/cypress/e2e/vocab_test.cy.js index fe6dce43..a83751fd 100644 --- a/task-launcher/cypress/e2e/vocab_test.cy.js +++ b/task-launcher/cypress/e2e/vocab_test.cy.js @@ -5,6 +5,6 @@ const vocab_url = 'http://localhost:8080/?task=vocab' describe('test vocab', () => { it('visits vocab and plays game', () => { cy.visit(vocab_url); - testImageAfc(true, '.image-medium', 4); + testImageAfc(true, '.image-medium'); }) }) \ No newline at end of file diff --git a/task-launcher/cypress/support/e2e.js b/task-launcher/cypress/support/e2e.js index 12a6c861..df6c41f6 100644 --- a/task-launcher/cypress/support/e2e.js +++ b/task-launcher/cypress/support/e2e.js @@ -21,11 +21,9 @@ import './commands' import "cypress-real-events"; -// prevent permissions check failed exception from failing test -/* +// prevent firestore error from failing test Cypress.on('uncaught:exception', (err, runnable) => { if (err.message.includes('user not in Firestore')){ return false } -}) -*/ \ No newline at end of file +}); diff --git a/task-launcher/src/tasks/shared/trials/afcStimulus.ts b/task-launcher/src/tasks/shared/trials/afcStimulus.ts index 0cbe6bff..e9a9d3b1 100644 --- a/task-launcher/src/tasks/shared/trials/afcStimulus.ts +++ b/task-launcher/src/tasks/shared/trials/afcStimulus.ts @@ -214,10 +214,10 @@ function generateImageChoices(choices: string[], target: string) { return choices.map((choice) => { const imageUrl = mediaAssets.images[camelize(choice)] || practiceUrl; - // if the task is running in a cypress test, the correct answer should be indicated with alt text + // if the task is running in a cypress test, the correct answer should be indicated with 'correct' class if (window.Cypress && stimulus.assessmentStage !== 'practice_response'){ - const isCorrect = choice === target ? 'correct' : ''; - return `${isCorrect}`; + const isCorrect = choice === target; + return isCorrect ? `${choice}` : `${choice}`; } else { return `${choice}`; } From 483f9826f242641435d79e91b35176c84d1c6e8a Mon Sep 17 00:00:00 2001 From: zwatson2001 Date: Tue, 1 Oct 2024 11:24:08 -0400 Subject: [PATCH 3/5] start math (works up to slider trials) --- task-launcher/cypress/e2e/helpers.cy.js | 19 ++++++++++++------- task-launcher/cypress/e2e/math.cy.js | 10 ++++++++++ .../cypress/e2e/matrix_reasoning.cy.js | 4 ++-- .../cypress/e2e/mental_rotation_test.cy.js | 4 ++-- .../cypress/e2e/theory_of_mind.cy.js | 4 ++-- task-launcher/cypress/e2e/trog_test.cy.js | 4 ++-- task-launcher/cypress/e2e/vocab_test.cy.js | 4 ++-- .../src/tasks/shared/trials/afcStimulus.ts | 11 +++++++++++ 8 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 task-launcher/cypress/e2e/math.cy.js diff --git a/task-launcher/cypress/e2e/helpers.cy.js b/task-launcher/cypress/e2e/helpers.cy.js index e3eb9f14..5fca7f06 100644 --- a/task-launcher/cypress/e2e/helpers.cy.js +++ b/task-launcher/cypress/e2e/helpers.cy.js @@ -34,19 +34,24 @@ function handlePracticeButtons(){ } // clicks first image option until game is over -function selectImages(correct, imgClass){ +function selectAnswers(correctFlag){ clickThroughInstructions(); handlePracticeButtons(); + // wait for fixation cross to go away cy.get('.lev-stimulus-container', {timeout: 10000}).should('exist'); + cy.get('.jspsych-content').then((content) => { if (content.find('.jspsych-audio-multi-response-button').length > 1){ - if (correct){ + + if (correctFlag === 'alt') { + cy.get('[aria-label="correct"]').click({timeout: 30000}); // add timeout to handle staggered buttons + } else { // use correct class by default cy.get('.correct').click({timeout: 30000}); // add timeout to handle staggered buttons - } else { - cy.get(imgClass).eq(0).click({timeout: 30000}); } - selectImages(correct, imgClass); + + selectAnswers(correctFlag); + } else { cy.contains('Thank you!').should('exist'); return; @@ -54,10 +59,10 @@ function selectImages(correct, imgClass){ }); } -export function testImageAfc(correct, imgClass){ +export function testAfc(correctFlag){ // wait for OK button to be visible cy.contains('OK', {timeout: 300000}).should('be.visible'); cy.contains('OK').realClick(); // real click mimics user gesture so that fullscreen can start - selectImages(correct, imgClass); + selectAnswers(correctFlag); cy.contains('Exit').click(); } \ No newline at end of file diff --git a/task-launcher/cypress/e2e/math.cy.js b/task-launcher/cypress/e2e/math.cy.js new file mode 100644 index 00000000..7da1013f --- /dev/null +++ b/task-launcher/cypress/e2e/math.cy.js @@ -0,0 +1,10 @@ +import {testAfc} from './helpers.cy.js' + +const math_url = 'http://localhost:8080/?task=egma-math' + +describe('test math', () => { + it('visits math and plays game', () => { + cy.visit(math_url); + testAfc('alt'); + }) +}) \ No newline at end of file diff --git a/task-launcher/cypress/e2e/matrix_reasoning.cy.js b/task-launcher/cypress/e2e/matrix_reasoning.cy.js index 92888bc7..5e3f0e34 100644 --- a/task-launcher/cypress/e2e/matrix_reasoning.cy.js +++ b/task-launcher/cypress/e2e/matrix_reasoning.cy.js @@ -1,10 +1,10 @@ -import {testImageAfc} from './helpers.cy.js' +import {testAfc} from './helpers.cy.js' const matrix_reasoning_url = 'http://localhost:8080/?task=matrix-reasoning' describe('test matrix reasoning', () => { it('visits matrix reasoning and plays game', () => { cy.visit(matrix_reasoning_url); - testImageAfc(true, '.image'); + testAfc(); }) }) \ No newline at end of file diff --git a/task-launcher/cypress/e2e/mental_rotation_test.cy.js b/task-launcher/cypress/e2e/mental_rotation_test.cy.js index 6df051be..2fd6866d 100644 --- a/task-launcher/cypress/e2e/mental_rotation_test.cy.js +++ b/task-launcher/cypress/e2e/mental_rotation_test.cy.js @@ -1,10 +1,10 @@ -import {testImageAfc} from './helpers.cy.js' +import {testAfc} from './helpers.cy.js' const mental_rotation_url = 'http://localhost:8080/?task=mental-rotation' describe('test mental rotation', () => { it('visits mental rotation and plays game', () => { cy.visit(mental_rotation_url); - testImageAfc(true, '.image-large'); + testAfc(); }) }) \ No newline at end of file diff --git a/task-launcher/cypress/e2e/theory_of_mind.cy.js b/task-launcher/cypress/e2e/theory_of_mind.cy.js index bfed3c72..034618d8 100644 --- a/task-launcher/cypress/e2e/theory_of_mind.cy.js +++ b/task-launcher/cypress/e2e/theory_of_mind.cy.js @@ -1,10 +1,10 @@ -import {testImageAfc} from './helpers.cy.js' +import {testAfc} from './helpers.cy.js' const TOM_url = 'http://localhost:8080/?task=theory-of-mind' describe('test theory of mind', () => { it('visits theory of mind and plays game', () => { cy.visit(TOM_url); - testImageAfc(true, '.image'); + testAfc(); }) }) \ No newline at end of file diff --git a/task-launcher/cypress/e2e/trog_test.cy.js b/task-launcher/cypress/e2e/trog_test.cy.js index 441d0ab7..ba888af3 100644 --- a/task-launcher/cypress/e2e/trog_test.cy.js +++ b/task-launcher/cypress/e2e/trog_test.cy.js @@ -1,10 +1,10 @@ -import {testImageAfc} from './helpers.cy.js' +import {testAfc} from './helpers.cy.js' const trog_url = 'http://localhost:8080/?task=trog' describe('test trog', () => { it('visits trog and plays game', () => { cy.visit(trog_url); - testImageAfc(true, '.image-medium'); + testAfc(); }) }) \ No newline at end of file diff --git a/task-launcher/cypress/e2e/vocab_test.cy.js b/task-launcher/cypress/e2e/vocab_test.cy.js index a83751fd..591d21e2 100644 --- a/task-launcher/cypress/e2e/vocab_test.cy.js +++ b/task-launcher/cypress/e2e/vocab_test.cy.js @@ -1,10 +1,10 @@ -import {testImageAfc} from './helpers.cy.js' +import {testAfc} from './helpers.cy.js' const vocab_url = 'http://localhost:8080/?task=vocab' describe('test vocab', () => { it('visits vocab and plays game', () => { cy.visit(vocab_url); - testImageAfc(true, '.image-medium'); + testAfc(); }) }) \ No newline at end of file diff --git a/task-launcher/src/tasks/shared/trials/afcStimulus.ts b/task-launcher/src/tasks/shared/trials/afcStimulus.ts index e9a9d3b1..50902e3a 100644 --- a/task-launcher/src/tasks/shared/trials/afcStimulus.ts +++ b/task-launcher/src/tasks/shared/trials/afcStimulus.ts @@ -343,6 +343,17 @@ function doOnLoad(layoutConfigMap: Record) { let twoTrialsAgoIndex = currentTrialIndex - 2; if (stim.task === 'math') { twoTrialsAgoIndex = currentTrialIndex - 3; // math has a fixation or something + + // flag correct answers with alt text for math if running a Cypress test + if (window.Cypress && !isPracticeTrial && !isInstructionTrial) { + const choices: NodeListOf = document.querySelectorAll('.secondary'); + + for (var i = 0; i < choices.length; i++) { + if (choices[i].textContent == itemLayoutConfig.response.target){ + choices[i].setAttribute("aria-label", "correct"); + } + } + } } const twoTrialsAgoStimulus = jsPsych.data.get().filter({ trial_index: twoTrialsAgoIndex }).values(); From 3608abff48519b96cd8df9de4172ec45c247feff Mon Sep 17 00:00:00 2001 From: zwatson2001 Date: Mon, 7 Oct 2024 10:22:32 -0400 Subject: [PATCH 4/5] finish math test --- task-launcher/cypress/e2e/helpers.cy.js | 57 ++++++++++++++----- task-launcher/cypress/e2e/math.cy.js | 2 +- .../cypress/e2e/matrix_reasoning.cy.js | 2 +- .../cypress/e2e/mental_rotation_test.cy.js | 2 +- .../cypress/e2e/theory_of_mind.cy.js | 2 +- task-launcher/cypress/e2e/trog_test.cy.js | 2 +- task-launcher/cypress/e2e/vocab_test.cy.js | 2 +- .../src/tasks/math/trials/sliderStimulus.ts | 8 +++ 8 files changed, 57 insertions(+), 20 deletions(-) diff --git a/task-launcher/cypress/e2e/helpers.cy.js b/task-launcher/cypress/e2e/helpers.cy.js index 5fca7f06..c42065da 100644 --- a/task-launcher/cypress/e2e/helpers.cy.js +++ b/task-launcher/cypress/e2e/helpers.cy.js @@ -6,22 +6,28 @@ function clickThroughInstructions(){ return; } else { // otherwise check for OK button, indicating instruction phase - cy.get('.jspsych-audio-multi-response-button').then((buttonWrapper) => { - if (buttonWrapper.find('.primary').length > 0){ - cy.contains('OK').click({timeout: 15000}); - clickThroughInstructions(); + cy.get('.jspsych-content').then((content) => { + const okButton = content.find('.primary'); + if (okButton.length > 0) { + cy.contains('OK').click(); + clickThroughInstructions(); } else { return; } - }); - } + }) + return; + } }); } function handlePracticeButtons(){ - cy.wait(500); + cy.wait(300); + // wait for fixation cross to go away + cy.get('.lev-stimulus-container', {timeout: 60000}).should('exist'); + cy.get('.jspsych-content').then((content) => { const practiceButtons = content.find('.practice-btn'); + if (practiceButtons.length > 0){ cy.get('.practice-btn').each((button) => { button.click(); @@ -34,15 +40,16 @@ function handlePracticeButtons(){ } // clicks first image option until game is over -function selectAnswers(correctFlag){ +function selectAnswers(correctFlag, buttonClass){ + handleMathSlider(); clickThroughInstructions(); handlePracticeButtons(); // wait for fixation cross to go away - cy.get('.lev-stimulus-container', {timeout: 10000}).should('exist'); + cy.get('.lev-stimulus-container', {timeout: 60000}).should('exist'); cy.get('.jspsych-content').then((content) => { - if (content.find('.jspsych-audio-multi-response-button').length > 1){ + if (content.find(buttonClass).length > 1){ if (correctFlag === 'alt') { cy.get('[aria-label="correct"]').click({timeout: 30000}); // add timeout to handle staggered buttons @@ -50,7 +57,7 @@ function selectAnswers(correctFlag){ cy.get('.correct').click({timeout: 30000}); // add timeout to handle staggered buttons } - selectAnswers(correctFlag); + selectAnswers(correctFlag, buttonClass); } else { cy.contains('Thank you!').should('exist'); @@ -59,10 +66,32 @@ function selectAnswers(correctFlag){ }); } -export function testAfc(correctFlag){ +function handleMathSlider() { + cy.wait(300); +// wait for fixation cross to go away + cy.get('.lev-stimulus-container', {timeout: 60000}).should('exist'); + + cy.get('.jspsych-content').then((content) => { + const slider = content.find('.jspsych-slider'); + const responseButtons = content.find('.secondary'); // should be length zero if in the movable slider phase + + if (slider.length && !responseButtons.length) { + cy.get('.jspsych-slider').realClick(); + + cy.get('.primary').then((continueButton) => { + continueButton.click(); + handleMathSlider(); + }) + } + }) + + return; +} + +export function testAfc(correctFlag, buttonClass){ // wait for OK button to be visible - cy.contains('OK', {timeout: 300000}).should('be.visible'); + cy.contains('OK', {timeout: 600000}).should('be.visible'); cy.contains('OK').realClick(); // real click mimics user gesture so that fullscreen can start - selectAnswers(correctFlag); + selectAnswers(correctFlag, buttonClass); cy.contains('Exit').click(); } \ No newline at end of file diff --git a/task-launcher/cypress/e2e/math.cy.js b/task-launcher/cypress/e2e/math.cy.js index 7da1013f..7c9043fb 100644 --- a/task-launcher/cypress/e2e/math.cy.js +++ b/task-launcher/cypress/e2e/math.cy.js @@ -5,6 +5,6 @@ const math_url = 'http://localhost:8080/?task=egma-math' describe('test math', () => { it('visits math and plays game', () => { cy.visit(math_url); - testAfc('alt'); + testAfc('alt', '.secondary'); }) }) \ No newline at end of file diff --git a/task-launcher/cypress/e2e/matrix_reasoning.cy.js b/task-launcher/cypress/e2e/matrix_reasoning.cy.js index 5e3f0e34..565193b0 100644 --- a/task-launcher/cypress/e2e/matrix_reasoning.cy.js +++ b/task-launcher/cypress/e2e/matrix_reasoning.cy.js @@ -4,7 +4,7 @@ const matrix_reasoning_url = 'http://localhost:8080/?task=matrix-reasoning' describe('test matrix reasoning', () => { it('visits matrix reasoning and plays game', () => { - cy.visit(matrix_reasoning_url); + cy.visit(matrix_reasoning_url, '.image'); testAfc(); }) }) \ No newline at end of file diff --git a/task-launcher/cypress/e2e/mental_rotation_test.cy.js b/task-launcher/cypress/e2e/mental_rotation_test.cy.js index 2fd6866d..3d91fea1 100644 --- a/task-launcher/cypress/e2e/mental_rotation_test.cy.js +++ b/task-launcher/cypress/e2e/mental_rotation_test.cy.js @@ -4,7 +4,7 @@ const mental_rotation_url = 'http://localhost:8080/?task=mental-rotation' describe('test mental rotation', () => { it('visits mental rotation and plays game', () => { - cy.visit(mental_rotation_url); + cy.visit(mental_rotation_url, '.image-large'); testAfc(); }) }) \ No newline at end of file diff --git a/task-launcher/cypress/e2e/theory_of_mind.cy.js b/task-launcher/cypress/e2e/theory_of_mind.cy.js index 034618d8..ff055bb1 100644 --- a/task-launcher/cypress/e2e/theory_of_mind.cy.js +++ b/task-launcher/cypress/e2e/theory_of_mind.cy.js @@ -4,7 +4,7 @@ const TOM_url = 'http://localhost:8080/?task=theory-of-mind' describe('test theory of mind', () => { it('visits theory of mind and plays game', () => { - cy.visit(TOM_url); + cy.visit(TOM_url, '.image'); testAfc(); }) }) \ No newline at end of file diff --git a/task-launcher/cypress/e2e/trog_test.cy.js b/task-launcher/cypress/e2e/trog_test.cy.js index ba888af3..69d086bf 100644 --- a/task-launcher/cypress/e2e/trog_test.cy.js +++ b/task-launcher/cypress/e2e/trog_test.cy.js @@ -4,7 +4,7 @@ const trog_url = 'http://localhost:8080/?task=trog' describe('test trog', () => { it('visits trog and plays game', () => { - cy.visit(trog_url); + cy.visit(trog_url, '.image-medium'); testAfc(); }) }) \ No newline at end of file diff --git a/task-launcher/cypress/e2e/vocab_test.cy.js b/task-launcher/cypress/e2e/vocab_test.cy.js index 591d21e2..a42e3171 100644 --- a/task-launcher/cypress/e2e/vocab_test.cy.js +++ b/task-launcher/cypress/e2e/vocab_test.cy.js @@ -4,7 +4,7 @@ const vocab_url = 'http://localhost:8080/?task=vocab' describe('test vocab', () => { it('visits vocab and plays game', () => { - cy.visit(vocab_url); + cy.visit(vocab_url, ".image-medium"); testAfc(); }) }) \ No newline at end of file diff --git a/task-launcher/src/tasks/math/trials/sliderStimulus.ts b/task-launcher/src/tasks/math/trials/sliderStimulus.ts index bf7cced5..03c2a1a0 100644 --- a/task-launcher/src/tasks/math/trials/sliderStimulus.ts +++ b/task-launcher/src/tasks/math/trials/sliderStimulus.ts @@ -8,6 +8,7 @@ import { camelize } from '@bdelab/roar-utils'; //@ts-ignore import { arrowKeyEmojis, setSkipCurrentBlock, taskStore, replayButtonSvg, setupReplayAudio, PageAudioHandler, PageStateHandler } from '../../shared/helpers'; import { mediaAssets } from '../../..'; +import Cypress from 'cypress'; let chosenAnswer: number; let sliderStart: number; @@ -165,6 +166,13 @@ export const slider = { const btnWrapper = document.createElement('div'); const btn = document.createElement('button'); btn.textContent = responseChoices[i]; + + // flag correct answer if running in cypress + if (window.Cypress && (btn.textContent == answer)) { + btn.setAttribute("aria-label", "correct"); + + } + btn.classList.add('secondary'); btn.addEventListener('click', (e) => captureValue(btn, e)); // To not duplicate event listeners From 4043c4b0370882753c590c82e894b23fc092305b Mon Sep 17 00:00:00 2001 From: zwatson2001 Date: Mon, 7 Oct 2024 11:50:31 -0400 Subject: [PATCH 5/5] fix bugs in all other afcStimulus tasks --- task-launcher/cypress/e2e/helpers.cy.js | 7 ++++--- task-launcher/cypress/e2e/matrix_reasoning.cy.js | 4 ++-- task-launcher/cypress/e2e/mental_rotation_test.cy.js | 4 ++-- task-launcher/cypress/e2e/theory_of_mind.cy.js | 4 ++-- task-launcher/cypress/e2e/trog_test.cy.js | 4 ++-- task-launcher/cypress/e2e/vocab_test.cy.js | 4 ++-- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/task-launcher/cypress/e2e/helpers.cy.js b/task-launcher/cypress/e2e/helpers.cy.js index c42065da..96d430f9 100644 --- a/task-launcher/cypress/e2e/helpers.cy.js +++ b/task-launcher/cypress/e2e/helpers.cy.js @@ -9,7 +9,7 @@ function clickThroughInstructions(){ cy.get('.jspsych-content').then((content) => { const okButton = content.find('.primary'); if (okButton.length > 0) { - cy.contains('OK').click(); + cy.contains('OK').click({timeout: 60000}); clickThroughInstructions(); } else { return; @@ -49,8 +49,9 @@ function selectAnswers(correctFlag, buttonClass){ cy.get('.lev-stimulus-container', {timeout: 60000}).should('exist'); cy.get('.jspsych-content').then((content) => { - if (content.find(buttonClass).length > 1){ - + const responseButtons = content.find(buttonClass); + + if (responseButtons.length > 1){ if (correctFlag === 'alt') { cy.get('[aria-label="correct"]').click({timeout: 30000}); // add timeout to handle staggered buttons } else { // use correct class by default diff --git a/task-launcher/cypress/e2e/matrix_reasoning.cy.js b/task-launcher/cypress/e2e/matrix_reasoning.cy.js index 565193b0..204f9066 100644 --- a/task-launcher/cypress/e2e/matrix_reasoning.cy.js +++ b/task-launcher/cypress/e2e/matrix_reasoning.cy.js @@ -4,7 +4,7 @@ const matrix_reasoning_url = 'http://localhost:8080/?task=matrix-reasoning' describe('test matrix reasoning', () => { it('visits matrix reasoning and plays game', () => { - cy.visit(matrix_reasoning_url, '.image'); - testAfc(); + cy.visit(matrix_reasoning_url); + testAfc('class', '.image'); }) }) \ No newline at end of file diff --git a/task-launcher/cypress/e2e/mental_rotation_test.cy.js b/task-launcher/cypress/e2e/mental_rotation_test.cy.js index 3d91fea1..e9c0dca3 100644 --- a/task-launcher/cypress/e2e/mental_rotation_test.cy.js +++ b/task-launcher/cypress/e2e/mental_rotation_test.cy.js @@ -4,7 +4,7 @@ const mental_rotation_url = 'http://localhost:8080/?task=mental-rotation' describe('test mental rotation', () => { it('visits mental rotation and plays game', () => { - cy.visit(mental_rotation_url, '.image-large'); - testAfc(); + cy.visit(mental_rotation_url); + testAfc('class', '.image-large'); }) }) \ No newline at end of file diff --git a/task-launcher/cypress/e2e/theory_of_mind.cy.js b/task-launcher/cypress/e2e/theory_of_mind.cy.js index ff055bb1..1e01991e 100644 --- a/task-launcher/cypress/e2e/theory_of_mind.cy.js +++ b/task-launcher/cypress/e2e/theory_of_mind.cy.js @@ -4,7 +4,7 @@ const TOM_url = 'http://localhost:8080/?task=theory-of-mind' describe('test theory of mind', () => { it('visits theory of mind and plays game', () => { - cy.visit(TOM_url, '.image'); - testAfc(); + cy.visit(TOM_url); + testAfc('class', '.image'); }) }) \ No newline at end of file diff --git a/task-launcher/cypress/e2e/trog_test.cy.js b/task-launcher/cypress/e2e/trog_test.cy.js index 69d086bf..e75af464 100644 --- a/task-launcher/cypress/e2e/trog_test.cy.js +++ b/task-launcher/cypress/e2e/trog_test.cy.js @@ -4,7 +4,7 @@ const trog_url = 'http://localhost:8080/?task=trog' describe('test trog', () => { it('visits trog and plays game', () => { - cy.visit(trog_url, '.image-medium'); - testAfc(); + cy.visit(trog_url); + testAfc('class', '.image-medium'); }) }) \ No newline at end of file diff --git a/task-launcher/cypress/e2e/vocab_test.cy.js b/task-launcher/cypress/e2e/vocab_test.cy.js index a42e3171..cc16c942 100644 --- a/task-launcher/cypress/e2e/vocab_test.cy.js +++ b/task-launcher/cypress/e2e/vocab_test.cy.js @@ -4,7 +4,7 @@ const vocab_url = 'http://localhost:8080/?task=vocab' describe('test vocab', () => { it('visits vocab and plays game', () => { - cy.visit(vocab_url, ".image-medium"); - testAfc(); + cy.visit(vocab_url, ); + testAfc('class', '.image-medium'); }) }) \ No newline at end of file