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', () => {
beforeEach(() => {
// Remove storage for autosave ...
cy.visit('/editor.html');
cy.clearLocalStorage('welcome-xml');
cy.reload();
// Wait for load complate ...
cy.get('[aria-label="vortex-loading"]').should('not.exist');
cy.waitEditorLoaded();
});
it('Add Relationship', () => {

View File

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

View File

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

View File

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

View File

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

View File

@ -1,10 +1,20 @@
/// <reference types="cypress" />
describe('Change Topic shape', () => {
beforeEach(() => {
cy.visit('/editor.html');
cy.reload();
// Wait all has been loaded ...
cy.waitEditorLoaded();
// Select one node ...
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', () => {
cy.get(`[aria-label="Topic Style"]`).first().trigger('mouseover');
cy.get(`[aria-label="Rectangle shape"]`).first().click();
@ -16,6 +26,7 @@ describe('Change Topic shape', () => {
.should('be.a', 'number')
.should('eq', 0);
cy.contains('Mind Mapping').click({ force: true });
cy.matchImageSnapshot('changeToSquareShape');
});
@ -39,6 +50,7 @@ describe('Change Topic shape', () => {
.should('be.a', 'number')
.should('be.lt', 5);
cy.contains('Mind Mapping').click({ force: true });
cy.matchImageSnapshot('changeToRoundedRectangle');
});
@ -48,6 +60,7 @@ describe('Change Topic shape', () => {
cy.get(`[aria-label="Topic Style"]`).first().trigger('mouseover');
cy.get(`[aria-label="Line shape"]`).first().click();
cy.contains('Mind Mapping').click({ force: true });
cy.matchImageSnapshot('changeToLine');
});
@ -71,6 +84,7 @@ describe('Change Topic shape', () => {
.should('be.a', 'number')
.should('be.lt', 15);
cy.contains('Mind Mapping').click({ force: true });
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', () => {
beforeEach(() => {
cy.visit('/c/maps/11/edit');
cy.get('[aria-label="vortex-loading"]', { timeout: 120000 }).should('not.exist');
cy.waitForEditorLoaded();
});
it('page loaded', () => {

View File

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

View File

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

View File

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

View File

@ -1,6 +1,7 @@
describe('Registration Page', () => {
beforeEach(() => {
cy.visit('/c/registration');
cy.waitForPageLoaded();
});
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';
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) => {
cy.spy(win.console, 'error');
cy.spy(win.console, 'warn');

View File

@ -8,6 +8,7 @@
"dev": "webpack --config webpack.dev.js",
"lint": "eslint src --ext js,ts,tsx",
"cy:run": "cypress run",
"cy:open": "cypress open",
"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: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",