Improve end2end test.

This commit is contained in:
Paulo Gustavo Veiga 2023-01-07 22:27:01 -08:00
parent 62ea491623
commit 14d9fbe100
27 changed files with 86 additions and 31 deletions

View File

@ -1,12 +1,12 @@
/// <reference types="cypress" />
import { css } from 'cypress/types/jquery';
describe('Relationship Topics', () => { describe('Relationship Topics', () => {
beforeEach(() => { beforeEach(() => {
// Remove storage for autosave ... // Remove storage for autosave ...
cy.visit('/editor.html'); cy.visit('/editor.html');
cy.clearLocalStorage('welcome-xml'); cy.waitEditorLoaded();
cy.reload();
// Wait for load complate ...
cy.get('[aria-label="vortex-loading"]').should('not.exist');
}); });
it('Add Relationship', () => { it('Add Relationship', () => {

View File

@ -1,3 +1,4 @@
/// <reference types="cypress" />
describe('Render all sample maps', () => { describe('Render all sample maps', () => {
[ [
'complex', 'complex',
@ -22,7 +23,7 @@ describe('Render all sample maps', () => {
].forEach((mapId) => { ].forEach((mapId) => {
it(`Render map => ${mapId}`, () => { it(`Render map => ${mapId}`, () => {
cy.visit(`/viewmode.html?id=${mapId}`); cy.visit(`/viewmode.html?id=${mapId}`);
cy.reload(); cy.waitEditorLoaded();
cy.get('svg > path').should('be.visible'); cy.get('svg > path').should('be.visible');
cy.get('[aria-label="vortex-loading"]', { timeout: 120000 }).should('not.exist'); cy.get('[aria-label="vortex-loading"]', { timeout: 120000 }).should('not.exist');

View File

@ -1,19 +1,22 @@
/// <reference types="cypress" />
describe('Edit Topic', () => { describe('Edit Topic', () => {
beforeEach(() => { beforeEach(() => {
// Remove storage for autosave ... // Remove storage for autosave ...
cy.visit('/editor.html'); cy.visit('/editor.html');
cy.clearLocalStorage('welcome-xml'); cy.waitEditorLoaded();
cy.reload();
// Wait for load complate ...
cy.get('[aria-label="vortex-loading"]').should('not.exist');
cy.get('[test-id=1]').click(); cy.get('[test-id=1]').click();
}); });
it('Open Font Shape Panel', () => {
cy.get(`[aria-label="Topic Style"]`).first().trigger('mouseover');
cy.matchImageSnapshot('fontShapePanel');
});
it('Change Main Topic Text', () => { it('Change Main Topic Text', () => {
cy.get('body').type('New Title Main Topic{enter}'); cy.get('body').type('New Title Main Topic{enter}');
cy.get('[test-id=1] > text > tspan').should('have.text', 'New Title Main Topic'); cy.get('[test-id=1] > text > tspan').should('have.text', 'New Title Main Topic');
cy.contains('Mind Mapping').click({ force: true });
cy.matchImageSnapshot('changeMainTopicText'); cy.matchImageSnapshot('changeMainTopicText');
}); });
@ -51,6 +54,7 @@ describe('Edit Topic', () => {
cy.get('[test-id=1] > text').invoke('attr', 'font-style').should('eq', 'italic'); cy.get('[test-id=1] > text').invoke('attr', 'font-style').should('eq', 'italic');
cy.contains('Mind Mapping').click({ force: true });
cy.matchImageSnapshot('changeFontItalic'); cy.matchImageSnapshot('changeFontItalic');
}); });
@ -60,6 +64,7 @@ describe('Edit Topic', () => {
cy.get('[test-id=1] > text').invoke('attr', 'font-weight').should('eq', 'normal'); cy.get('[test-id=1] > text').invoke('attr', 'font-weight').should('eq', 'normal');
cy.contains('Mind Mapping').click({ force: true });
cy.matchImageSnapshot('changeFontBold'); cy.matchImageSnapshot('changeFontBold');
}); });
@ -70,6 +75,7 @@ describe('Edit Topic', () => {
cy.get('[test-id=1] > text').invoke('attr', 'fill').should('eq', '#cc0000'); cy.get('[test-id=1] > text').invoke('attr', 'fill').should('eq', '#cc0000');
cy.contains('Mind Mapping').click({ force: true });
cy.matchImageSnapshot('changeFontColor'); cy.matchImageSnapshot('changeFontColor');
}); });
}); });

View File

@ -1,9 +1,8 @@
/// <reference types="cypress" />
describe('Node manager', () => { describe('Node manager', () => {
beforeEach(() => { beforeEach(() => {
cy.visit('/editor.html'); cy.visit('/editor.html');
cy.waitEditorLoaded();
// Wait for load complate ...
cy.get('[aria-label="vortex-loading"]').should('not.exist');
// Select root node ... // Select root node ...
cy.contains('Mind Mapping').click({ force: true }); cy.contains('Mind Mapping').click({ force: true });

View File

@ -1,9 +1,9 @@
/// <reference types="cypress" />
describe('Change topic position', () => { describe('Change topic position', () => {
beforeEach(() => { beforeEach(() => {
// Remove storage for autosave ... // Remove storage for autosave ...
cy.visit('/editor.html'); cy.visit('/editor.html');
cy.clearLocalStorage('welcome-xml'); cy.waitEditorLoaded();
cy.reload();
// Wait for load complate ... // Wait for load complate ...
cy.get('[aria-label="vortex-loading"]').should('not.exist'); cy.get('[aria-label="vortex-loading"]').should('not.exist');

View File

@ -1,10 +1,20 @@
/// <reference types="cypress" />
describe('Change Topic shape', () => { describe('Change Topic shape', () => {
beforeEach(() => { beforeEach(() => {
cy.visit('/editor.html'); cy.visit('/editor.html');
cy.reload();
// Wait all has been loaded ...
cy.waitEditorLoaded();
// Select one node ...
cy.contains('Try it Now!').click(); cy.contains('Try it Now!').click();
}); });
it('open shape', () => {
cy.get(`[aria-label="Topic Style"]`).first().trigger('mouseover');
cy.matchImageSnapshot('topicShapePanel');
});
it('change to square shape', () => { it('change to square shape', () => {
cy.get(`[aria-label="Topic Style"]`).first().trigger('mouseover'); cy.get(`[aria-label="Topic Style"]`).first().trigger('mouseover');
cy.get(`[aria-label="Rectangle shape"]`).first().click(); cy.get(`[aria-label="Rectangle shape"]`).first().click();
@ -16,6 +26,7 @@ describe('Change Topic shape', () => {
.should('be.a', 'number') .should('be.a', 'number')
.should('eq', 0); .should('eq', 0);
cy.contains('Mind Mapping').click({ force: true });
cy.matchImageSnapshot('changeToSquareShape'); cy.matchImageSnapshot('changeToSquareShape');
}); });
@ -39,6 +50,7 @@ describe('Change Topic shape', () => {
.should('be.a', 'number') .should('be.a', 'number')
.should('be.lt', 5); .should('be.lt', 5);
cy.contains('Mind Mapping').click({ force: true });
cy.matchImageSnapshot('changeToRoundedRectangle'); cy.matchImageSnapshot('changeToRoundedRectangle');
}); });
@ -48,6 +60,7 @@ describe('Change Topic shape', () => {
cy.get(`[aria-label="Topic Style"]`).first().trigger('mouseover'); cy.get(`[aria-label="Topic Style"]`).first().trigger('mouseover');
cy.get(`[aria-label="Line shape"]`).first().click(); cy.get(`[aria-label="Line shape"]`).first().click();
cy.contains('Mind Mapping').click({ force: true });
cy.matchImageSnapshot('changeToLine'); cy.matchImageSnapshot('changeToLine');
}); });
@ -71,6 +84,7 @@ describe('Change Topic shape', () => {
.should('be.a', 'number') .should('be.a', 'number')
.should('be.lt', 15); .should('be.lt', 15);
cy.contains('Mind Mapping').click({ force: true });
cy.matchImageSnapshot('changeToEllipseShape'); cy.matchImageSnapshot('changeToEllipseShape');
}); });
}); });

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

View File

@ -1,13 +0,0 @@
import './commands';
Cypress.on('window:before:load', (win) => {
cy.spy(win.console, 'error');
cy.spy(win.console, 'warn');
});
// afterEach(() => {
// cy.window().then((win) => {
// expect(win.console.error).to.have.callCount(0);
// expect(win.console.warn).to.have.callCount(0);
// });
// });

View File

@ -0,0 +1,28 @@
import './commands';
Cypress.Commands.add('waitEditorLoaded', () => {
// Wait editor ...
cy.get('svg > path').should('be.visible');
cy.get('[aria-label="vortex-loading"]', { timeout: 120000 }).should('not.exist');
cy.clearLocalStorage('welcome-xml');
// Wait for font ...
cy.document().its('fonts.status').should('equal', 'loaded');
});
Cypress.Commands.add('waitForLoad', () => {
// Wait page be loaded...
cy.document().its('fonts.status').should('equal', 'loaded');
});
Cypress.on('window:before:load', (win) => {
cy.spy(win.console, 'error');
cy.spy(win.console, 'warn');
});
// afterEach(() => {
// cy.window().then((win) => {
// expect(win.console.error).to.have.callCount(0);
// expect(win.console.warn).to.have.callCount(0);
// });
// });

View File

@ -1,7 +1,7 @@
describe('Editor Page', () => { describe('Editor Page', () => {
beforeEach(() => { beforeEach(() => {
cy.visit('/c/maps/11/edit'); cy.visit('/c/maps/11/edit');
cy.get('[aria-label="vortex-loading"]', { timeout: 120000 }).should('not.exist'); cy.waitForEditorLoaded();
}); });
it('page loaded', () => { it('page loaded', () => {

View File

@ -1,6 +1,7 @@
describe('Forgot Password Page', () => { describe('Forgot Password Page', () => {
beforeEach(() => { beforeEach(() => {
cy.visit('/c/forgot-password'); cy.visit('/c/forgot-password');
cy.waitForPageLoaded();
}); });
it('page loaded', () => { it('page loaded', () => {

View File

@ -1,6 +1,7 @@
describe('Login Page', () => { describe('Login Page', () => {
beforeEach(() => { beforeEach(() => {
cy.visit('/c/login'); cy.visit('/c/login');
cy.waitForPageLoaded();
}); });
it('page loaded', () => { it('page loaded', () => {

View File

@ -1,6 +1,7 @@
describe('Maps Page', () => { describe('Maps Page', () => {
beforeEach(() => { beforeEach(() => {
cy.visit('/c/maps'); cy.visit('/c/maps');
cy.waitForPageLoaded();
cy.get('.MuiCard-root').should('have.length', 3); cy.get('.MuiCard-root').should('have.length', 3);
}); });

View File

@ -1,6 +1,7 @@
describe('Registration Page', () => { describe('Registration Page', () => {
beforeEach(() => { beforeEach(() => {
cy.visit('/c/registration'); cy.visit('/c/registration');
cy.waitForPageLoaded();
}); });
it('registation load', () => { it('registation load', () => {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 116 KiB

View File

@ -1,5 +1,20 @@
import './commands'; import './commands';
Cypress.Commands.add('waitForEditorLoaded', () => {
// Wait editor ...
cy.get('svg > path').should('be.visible');
cy.get('[aria-label="vortex-loading"]', { timeout: 120000 }).should('not.exist');
cy.clearLocalStorage('welcome-xml');
// Wait for font ...
cy.document().its('fonts.status').should('equal', 'loaded');
});
Cypress.Commands.add('waitForPageLoaded', () => {
// Wait page be loaded...
cy.document().its('fonts.status').should('equal', 'loaded');
});
Cypress.on('window:before:load', (win) => { Cypress.on('window:before:load', (win) => {
cy.spy(win.console, 'error'); cy.spy(win.console, 'error');
cy.spy(win.console, 'warn'); cy.spy(win.console, 'warn');

View File

@ -8,6 +8,7 @@
"dev": "webpack --config webpack.dev.js", "dev": "webpack --config webpack.dev.js",
"lint": "eslint src --ext js,ts,tsx", "lint": "eslint src --ext js,ts,tsx",
"cy:run": "cypress run", "cy:run": "cypress run",
"cy:open": "cypress open",
"test:integration": "start-server-and-test start http-get://localhost:3000 cy:run", "test:integration": "start-server-and-test start http-get://localhost:3000 cy:run",
"i18n:extract": "formatjs extract 'src/**/*.ts*' --ignore 'src/@types/**/*' --out-file lang/en.json", "i18n:extract": "formatjs extract 'src/**/*.ts*' --ignore 'src/@types/**/*' --out-file lang/en.json",
"i18n:compile": "for lang in {'es','en','fr','de','zh','ru'};do formatjs compile lang/${lang}.json --ast --out-file src/compiled-lang/${lang}.json;done", "i18n:compile": "for lang in {'es','en','fr','de','zh','ru'};do formatjs compile lang/${lang}.json --ast --out-file src/compiled-lang/${lang}.json;done",