Skip to content

Commit

Permalink
Move cypress to standalone e2e package
Browse files Browse the repository at this point in the history
  • Loading branch information
RexShum committed Jan 16, 2025
1 parent fd392a7 commit ce24e6b
Show file tree
Hide file tree
Showing 26 changed files with 2,221 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"scripts": {
"ft": "npm run format && npm t",
"format": "cd client/ && npm run format && cd ../server/ && npm run format && cd ../ && prettier --write \"build/*.mjs\" \"docu/**/*.mjs\" ",
"format": "cd client/ && npm run format && cd ../server/ && npm run format && cd ../poinz-e2e/ && npm run format && cd ../ && prettier --write \"build/*.mjs\" \"docu/**/*.mjs\" ",
"test": "cd client/ && npm test && cd ../server && npm test",
"prebuild": "node build/checkTranslationKeys.mjs && npm run docu",
"build": "node build/build.mjs",
Expand Down
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions poinz-e2e/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const {defineConfig} = require('cypress');

module.exports = defineConfig({
video: false,
viewportWidth: 1500,
viewportHeight: 900,
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config);
},
baseUrl: 'http://localhost:9000'
}
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import uuid from '../../app/services/uuid';
import {customNanoid} from '../support/commands';
import path from 'path';

import {Room, Landing} from '../elements/elements';
Expand All @@ -9,7 +9,7 @@ beforeEach(function () {
});

it('setup stories in new room and export them (download json)', function () {
const customRoomName = 'e2e-room-' + uuid();
const customRoomName = 'e2e-room-' + customNanoid();

cy.visit('/');
Landing.extendButton().click();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import uuid from '../../app/services/uuid';
import {customNanoid} from '../support/commands';
import {Landing, Room} from '../elements/elements';

beforeEach(function () {
Expand All @@ -17,7 +17,7 @@ it('landing page and join new random room', function () {
});

it('create new room (custom name) via landing, then join by url', function () {
const customRoomName = 'e2e-room-' + uuid();
const customRoomName = 'e2e-room-' + customNanoid();

cy.visit('/');
Landing.extendButton().click();
Expand All @@ -39,7 +39,7 @@ it('create new room (custom name) via landing, then join by url', function () {
});

it('create new room (custom name) on the fly when joining by url', function () {
const customRoomName = 'e2e-room-' + uuid();
const customRoomName = 'e2e-room-' + customNanoid();

cy.clearLocalStorage(); // this should not be needed. Cypress promises to clear all local storage in between tests.
// however, here, when joining a new room by url, I get a lot of "joinCommands" that contain the username -> Poinz does not show the username prompt, and the .type on line 47 will fail.
Expand All @@ -54,7 +54,7 @@ it('create new room (custom name) on the fly when joining by url', function () {
});

it('create new room (whitespace room name) by url', function () {
const randomId = uuid();
const randomId = customNanoid();
const customRoomName = 'this works now' + randomId;

cy.visit('/' + customRoomName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import uuid from '../../app/services/uuid';
import {tid} from '../support/commands';
import {tid, customNanoid} from '../support/commands';
import {Landing, Room} from '../elements/elements';

beforeEach(function () {
Expand All @@ -8,7 +7,7 @@ beforeEach(function () {
});

it('join random room, open settings, set password. then rejoin room', function () {
const customRoomName = 'e2e-room-' + uuid();
const customRoomName = 'e2e-room-' + customNanoid();

cy.visit('/' + customRoomName);

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import uuid from '../../app/services/uuid';
import {tid} from '../support/commands';
import {tid, customNanoid} from '../support/commands';
import {Landing, Room} from '../elements/elements';

beforeEach(function () {
Expand All @@ -9,7 +8,7 @@ beforeEach(function () {
});

it('multi user estimation with two rounds, consensus on second round', function () {
const roomId = 'multi-user-e2e_' + uuid().toLowerCase();
const roomId = 'multi-user-e2e_' + customNanoid().toLowerCase();

cy.visit('/' + roomId);

Expand All @@ -21,8 +20,8 @@ it('multi user estimation with two rounds, consensus on second round', function
// -- the following will open an additional socket to the backend, so that we can add another user to the room
// Cypress does not support multiple browsers! see https://docs.cypress.io/guides/references/trade-offs.html
// see ../support/commands.js
const userTwoSocket = uuid();
const userTwoUserId = uuid();
const userTwoSocket = customNanoid();
const userTwoUserId = customNanoid();
cy.openNewSocket(userTwoSocket);
cy.sendCommands(userTwoSocket, [
{
Expand Down Expand Up @@ -103,7 +102,7 @@ it('multi user estimation with two rounds, consensus on second round', function
});

it('estimation summary and settling on a value', function () {
const roomId = 'multi-user-e2e_' + uuid().toLowerCase();
const roomId = 'multi-user-e2e_' + customNanoid().toLowerCase();

cy.visit('/' + roomId);

Expand All @@ -112,8 +111,8 @@ it('estimation summary and settling on a value', function () {
Room.TopBar.whoami().click();
Room.TopBar.whoamiDropdown().contains(this.user.username);

const userTwoSocket = uuid();
const userTwoUserId = uuid();
const userTwoSocket = customNanoid();
const userTwoUserId = customNanoid();
cy.openNewSocket(userTwoSocket);
cy.sendCommands(userTwoSocket, [
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import uuid from '../../app/services/uuid';
import {customAlphabet} from 'nanoid';
import socketIo from 'socket.io-client';

// ***********************************************
Expand All @@ -20,6 +20,7 @@ import socketIo from 'socket.io-client';
* @return {string}
*/
export const tid = (...tid) => tid.map((t) => `[data-testid="${t}"]`).join(' ');
export const customNanoid = customAlphabet('0123456789abcdefghijklmnopqrstuvwxyz-_', 21);

Cypress.Commands.add('openNewSocket', (socketIdentifier) => {
cy.window().then((w) => {
Expand All @@ -43,7 +44,7 @@ Cypress.Commands.add('sendCommands', (socketIdentifier, commands) => {
commands.forEach((cmd) => {
w.__POINZ_E2E__[socketIdentifier].emit('command', {
...cmd,
id: uuid()
id: customNanoid()
});
});
});
Expand Down
File renamed without changes.
Loading

0 comments on commit ce24e6b

Please sign in to comment.