Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ pipeline {
}
}

stage('Unit Test') {
steps {
sh 'npm test'
}
}

stage('Cypress Component Test') {
steps {
script {
Expand Down
26 changes: 26 additions & 0 deletions cypress/e2e/graphwise-reactodia/graphwise-reactodia.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,32 @@ describe('graphwise-reactodia', () => {
GraphwiseReactodiaSteps.getElements().should('have.length', 2);
});

it('Should restore the persisted diagram on refresh, until the host clears it', () => {
// Given a workspace seeded with two nodes, which persists the layout to local storage
GraphwiseReactodiaSteps.setSeed();
GraphwiseReactodiaSteps.provideRequiredProps();
GraphwiseReactodiaSteps.getElements().should('have.length', 2);
// And the layout has actually reached local storage (the save is debounced)
GraphwiseReactodiaSteps.getStoredDiagram().should('not.be.null');

// When the page is refreshed and mounted again *without* a seed, so nothing can re-seed the canvas
GraphwiseReactodiaSteps.visit();
GraphwiseReactodiaSteps.provideRequiredProps();

// Then the diagram is restored from local storage rather than starting empty
GraphwiseReactodiaSteps.getElements().should('have.length', 2);

// When the host clears the persisted diagram and the page is refreshed again
GraphwiseReactodiaSteps.clearDiagramStorage();
GraphwiseReactodiaSteps.getStoredDiagram().should('be.null');
GraphwiseReactodiaSteps.visit();
GraphwiseReactodiaSteps.provideRequiredProps();

// Then there is nothing left to restore and the canvas starts empty
GraphwiseReactodiaSteps.getCanvas().should('exist');
GraphwiseReactodiaSteps.getElements().should('not.exist');
});

it('Should seed the canvas with the pre-resolved graph, drawing its edges directly', () => {
// Given a pre-resolved graph seed (e.g. a CONSTRUCT result) staged before the workspace mounts
GraphwiseReactodiaSteps.setSeedGraph();
Expand Down
8 changes: 8 additions & 0 deletions cypress/steps/graphwise-reactodia-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,12 @@ export class GraphwiseReactodiaSteps {
static switchToEnglish() {
cy.getByTestId('set-language-en').click();
}

static clearDiagramStorage() {
cy.getByTestId('clear-diagram-storage').click();
}

static getStoredDiagram() {
return cy.window().its('localStorage').invoke('getItem', 'diagram.state');
}
}
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Lets IDE Jest runners (e.g. IntelliJ) use Stencil's TypeScript preprocessor.
// The canonical test runner is `npm test` (`stencil test --spec`); this config
// mirrors the transform Stencil applies so running specs directly also works.
module.exports = {
preset: '@stencil/core/testing',
};
Loading