-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
63 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,68 @@ | ||
describe('ReferenceData Component', () => { | ||
const stageIndex = 0; | ||
|
||
describe('ReferenceData Component - Input and Save References', () => { | ||
beforeEach(() => { | ||
// Clear localStorage | ||
cy.clearLocalStorage(); | ||
|
||
// Set initial localStorage data using Cypress window object | ||
const initialData = { | ||
[`stage_${stageIndex}`]: { reference1: 'Test Value 1' }, | ||
}; | ||
// initial test yaml | ||
let yamlTreatment = ` | ||
name: reference_test | ||
playerCount: 1 | ||
gameStages: | ||
- name: Stage 1 | ||
elements: | ||
- type: display | ||
reference: participantInfo.name | ||
- type: display | ||
reference: participantInfo.age | ||
`; | ||
|
||
// viewport & visit editor page | ||
cy.viewport(2000, 1000); | ||
cy.visit('http://localhost:3000/editor'); | ||
|
||
// entering YAML treatment into code editor & save | ||
cy.get('[data-cy="code-editor"]').clear().type(yamlTreatment); | ||
cy.get('[data-cy="yaml-save"]').click(); | ||
|
||
cy.window().then((win) => { | ||
win.localStorage.setItem('jsonData', JSON.stringify(initialData)); | ||
console.log('Initial LocalStorage jsonData:', win.localStorage.getItem('jsonData')); | ||
}); | ||
cy.get('[data-cy="stage-title"]', { timeout: 10000 }).should("be.visible"); | ||
|
||
cy.wait(500); | ||
cy.reload(); | ||
// verifying stage & elements are added successfully | ||
cy.get('[data-cy="stage-title"]').should("be.visible"); | ||
cy.get('[data-cy="reference-label-participantInfo.name"]').contains("Participant Info: Name").should("be.visible"); | ||
cy.get('[data-cy="reference-label-participantInfo.age"]').contains("Participant Info: Age").should("be.visible"); | ||
}); | ||
|
||
it('confirms localStorage is set correctly', () => { | ||
// Verify that localStorage contains the expected data | ||
cy.window().then((win) => { | ||
const jsonData = JSON.parse(win.localStorage.getItem('jsonData') || '{}'); | ||
expect(jsonData[`stage_${stageIndex}`].reference1).to.equal('Test Value 1'); | ||
}); | ||
}); | ||
it('allows input of reference values, saves, and displays them correctly', () => { | ||
const nameValue = 'Alice'; | ||
const ageValue = '30'; | ||
|
||
it('keeps values isolated by stage', () => { | ||
const stage2Data = { reference2: 'Stage 2 Value' }; | ||
// type values into input fields for each reference | ||
cy.get('[data-cy="reference-input-participantInfo.name"]').type(nameValue); | ||
cy.get('[data-cy="reference-input-participantInfo.age"]').type(ageValue); | ||
|
||
cy.window().then((win) => { | ||
win.localStorage.setItem('jsonData', JSON.stringify({ stage_1: stage2Data })); | ||
}); | ||
// click Save button | ||
cy.get('[data-cy="save-button"]').click(); | ||
|
||
cy.wait(500); | ||
cy.reload(); | ||
|
||
// Verify that the stage 2 value is set correctly in localStorage | ||
// verify values r stored in localStorage | ||
cy.window().then((win) => { | ||
const jsonData = JSON.parse(win.localStorage.getItem('jsonData') || '{}'); | ||
expect(jsonData['stage_1'].reference2).to.equal('Stage 2 Value'); | ||
expect(jsonData['stage_0']['participantInfo.name']).to.equal(nameValue); | ||
expect(jsonData['stage_0']['participantInfo.age']).to.equal(ageValue); | ||
}); | ||
|
||
// verify saved values r displayed in UI | ||
cy.get('[data-cy="reference-display-participantInfo.name"]').should('contain', `Saved Value: ${nameValue}`); | ||
cy.get('[data-cy="reference-display-participantInfo.age"]').should('contain', `Saved Value: ${ageValue}`); | ||
}); | ||
|
||
it('displays "No references found" message when no references exist', () => { | ||
// clear YAML treatment | ||
let emptyYamlTreatment = ` | ||
name: reference_test | ||
playerCount: 1 | ||
gameStages: [] | ||
`; | ||
cy.get('[data-cy="code-editor"]').clear().type(emptyYamlTreatment); | ||
cy.get('[data-cy="yaml-save"]').click(); | ||
|
||
// check | ||
cy.get('[data-cy="no-references-message"]').should('contain', 'No references found'); | ||
}); | ||
}); |
Binary file removed
BIN
-271 KB
...reorder.cy.ts/timeline drag and drop -- allows reodering of stages (failed).png
Binary file not shown.
Binary file added
BIN
+264 KB
...meline drag and drop -- allows reordering of elements within stage (failed).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-263 KB
...meline drag and drop -- rejects dragging elements to invalid spots (failed).png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters