Skip to content

Commit

Permalink
Merge branch 'develop' into chore/user-info
Browse files Browse the repository at this point in the history
  • Loading branch information
dougfabris committed Jul 28, 2022
2 parents a315ecb + 7794a0b commit 1bb25f0
Show file tree
Hide file tree
Showing 27 changed files with 349 additions and 38 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -681,13 +681,31 @@ jobs:
docker logs presence --tail=50
cd ./apps/meteor
IS_EE=true npm run test:e2e
E2E_COVERAGE=true IS_EE=true npm run test:e2e
- name: Extract e2e:ee:coverage
run: |
cd ./apps/meteor
yarn test:e2e:nyc
- uses: codecov/codecov-action@v3
with:
directory: ./apps/meteor
flags: e2e
verbose: true

- name: Store e2e-ee-coverage
uses: actions/upload-artifact@v2
with:
name: e2e-ee-coverage
path: ./apps/meteor/coverage*

- name: Store playwright test trace
uses: actions/upload-artifact@v2
if: failure()
with:
name: playwright-test-trace
name: e2e-ee-testtrace
path: ./apps/meteor/tests/e2e/test-failures*

deploy:
Expand Down
3 changes: 3 additions & 0 deletions apps/meteor/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"babel-plugin-istanbul"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Meteor } from 'meteor/meteor';
import { callbacks } from '../../../../../lib/callbacks';
import { LivechatRooms } from '../../../../../app/models/server';

const handleAfterSaveMessage = (message, { _id: rid }) => {
const handleAfterSaveMessage = (message, { _id: rid, t: roomType, v: roomVisitor }) => {
// skips this callback if the message was edited
if (message.editedAt) {
return message;
Expand All @@ -14,14 +14,14 @@ const handleAfterSaveMessage = (message, { _id: rid }) => {
return message;
}

// Need to read the room every time, the room object is not updated
const room = LivechatRooms.findOneById(rid, { t: 1, v: 1, onHold: 1 });
if (!room) {
// message valid only if it is a livechat room
if (!(typeof roomType !== 'undefined' && roomType === 'l' && roomVisitor && roomVisitor.token)) {
return message;
}

// message valid only if it is a livechat room
if (!(typeof room.t !== 'undefined' && room.t === 'l' && room.v && room.v.token)) {
// Need to read the room every time, the room object is not updated
const room = LivechatRooms.findOneById(rid, { t: 1, v: 1, onHold: 1 });
if (!room) {
return message;
}

Expand Down
3 changes: 3 additions & 0 deletions apps/meteor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"deploy": "npm run build && pm2 startOrRestart pm2.json",
"coverage": "nyc -r html mocha --config ./.mocharc.js",
"test:e2e": "playwright test",
"test:e2e:nyc": "nyc report --reporter=text-summary --reporter=lcov",
"testapi": "mocha --config ./.mocharc.api.js",
"testunit": "npm run .testunit:definition && npm run .testunit:client && npm run .testunit:server",
".testunit:server": "mocha --config ./.mocharc.js",
Expand Down Expand Up @@ -141,6 +142,7 @@
"autoprefixer": "^9.8.8",
"babel-loader": "^8.2.5",
"babel-plugin-array-includes": "^2.0.3",
"babel-plugin-istanbul": "^6.1.1",
"chai": "^4.3.6",
"chai-datetime": "^1.8.0",
"chai-dom": "^1.11.0",
Expand All @@ -159,6 +161,7 @@
"jsdom-global": "^3.0.2",
"mocha": "^9.2.2",
"mock-require": "^3.0.3",
"nyc": "^15.1.0",
"outdent": "~0.8.0",
"pino-pretty": "^7.6.1",
"postcss": "~8.4.14",
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/server/email/IMAPInterceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class IMAPInterceptor extends EventEmitter {
});

this.imap.on('error', (err: Error) => {
this.log('Error occurred ...');
this.log('Error occurred ...', err);
throw err;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export async function onEmailReceived(email: ParsedMail, inbox: string, departme
_id: msgId,
groupable: false,
msg,
token: guest.token,
attachments: [
{
actions: [
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/tests/e2e/01-forgot-password.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { test, expect } from '@playwright/test';

import { test, expect } from './utils/test';
import { Auth } from './page-objects';

test.describe('Forgot Password', () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/02-register.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test';
import { faker } from '@faker-js/faker';

import { test, expect } from './utils/test';
import { Auth } from './page-objects';

test.describe('Register', () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/03-login.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test';
import { faker } from '@faker-js/faker';

import { test, expect } from './utils/test';
import { Auth } from './page-objects';

test.describe('Login', () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/05-channel-creation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test';
import { faker } from '@faker-js/faker';

import { test, expect } from './utils/test';
import { HomeChannel, Auth } from './page-objects';

test.describe('Channel Creation', () => {
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/tests/e2e/06-messaging.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect, test, Browser, Page } from '@playwright/test';
import { Browser, Page } from '@playwright/test';

import { test, expect } from './utils/test';
import { validUserInserted } from './utils/mocks/userAndPasswordMock';
import { Auth, HomeChannel } from './page-objects';

Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/tests/e2e/07-emoji.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { test, expect } from '@playwright/test';

import { test, expect } from './utils/test';
import { Auth, HomeChannel } from './page-objects';

test.describe('Emoji', () => {
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/tests/e2e/09-channel.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { test, expect } from '@playwright/test';

import { test, expect } from './utils/test';
import { publicChannelCreated, setPublicChannelCreated } from './utils/mocks/checks';
import { Auth, HomeChannel } from './page-objects';

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/10-user-preferences.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test';
import { faker } from '@faker-js/faker';

import { test, expect } from './utils/test';
import { Auth, HomeChannel, AccountProfile } from './page-objects';

test.describe('User preferences', () => {
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/tests/e2e/11-admin.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { test, expect } from '@playwright/test';

import { test, expect } from './utils/test';
import { Auth, Administration } from './page-objects';

test.describe('Administration', () => {
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/tests/e2e/12-settings.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { test, expect, Page } from '@playwright/test';
import { Page } from '@playwright/test';
import { v4 as uuid } from 'uuid';

import { test, expect } from './utils/test';
import { BASE_API_URL } from './utils/constants';
import { adminLogin, validUserInserted, registerUser } from './utils/mocks/userAndPasswordMock';
import { Auth, HomeChannel, AccountProfile, Administration } from './page-objects';
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/13-permissions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test';
import { v4 as uuid } from 'uuid';
import faker from '@faker-js/faker';

import { test, expect } from './utils/test';
import { Auth, Administration, HomeChannel } from './page-objects';

test.describe('Permissions', () => {
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/tests/e2e/14-setting-permissions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test, expect } from '@playwright/test';
import faker from '@faker-js/faker';

import { validUserInserted } from './utils/mocks/userAndPasswordMock';
import { test, expect } from './utils/test';
import { Auth, Administration, HomeChannel } from './page-objects';
import { validUserInserted } from './utils/mocks/userAndPasswordMock';

test.describe('Settings Permissions', () => {
let pageAuth: Auth;
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/tests/e2e/15-message-popup.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { test, expect } from '@playwright/test';

import { test, expect } from './utils/test';
import { Auth, HomeChannel } from './page-objects';

test.describe('Message Popup', () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/16-discussion.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test } from '@playwright/test';
import { faker } from '@faker-js/faker';
import { v4 as uuid } from 'uuid';

import { test } from './utils/test';
import { Auth, HomeDiscussion } from './page-objects';

test.describe('[Discussion]', () => {
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/tests/e2e/omnichannel-agents.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { test, expect } from '@playwright/test';

import { test, expect } from './utils/test';
import { Auth, OmnichannelAgents } from './page-objects';

test.describe('Agents', () => {
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/tests/e2e/omnichannel-departaments.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { test, expect } from '@playwright/test';

import { test, expect } from './utils/test';
import { Auth, OmnichannelDepartaments } from './page-objects';

test.describe('Department', () => {
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/tests/e2e/page-objects/administration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Locator, expect, Page } from '@playwright/test';
import { Locator, Page } from '@playwright/test';

import { expect } from '../utils/test';
import { AdminFlextab, AdminSidenav } from './fragments';

export class Administration {
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/tests/e2e/page-objects/home-discussion.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Locator, Page, expect } from '@playwright/test';
import { Locator, Page } from '@playwright/test';

import { expect } from '../utils/test';
import { HomeContent, HomeSidenav, HomeFlextab } from './fragments';

export class HomeDiscussion {
Expand Down
4 changes: 3 additions & 1 deletion apps/meteor/tests/e2e/page-objects/omnichannel-agents.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Locator, expect, Page } from '@playwright/test';
import { Locator, Page } from '@playwright/test';

import { expect } from '../utils/test';

export class OmnichannelAgents {
private readonly page: Page;
Expand Down
41 changes: 41 additions & 0 deletions apps/meteor/tests/e2e/utils/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as fs from 'fs';
import * as path from 'path';

import { v4 as uuid } from 'uuid';
import { test as baseTest } from '@playwright/test';

const PATH_NYC_OUTPUT = path.join(process.cwd(), '.nyc_output');
// @ts-ignore
export const test = baseTest.extend({
context: async ({ context }, use) => {
if (!process.env.E2E_COVERAGE) {
await use(context);
await context.close();

return;
}

await context.addInitScript(() =>
window.addEventListener('beforeunload', () => (window as any).collectIstanbulCoverage(JSON.stringify((window as any).__coverage__))),
);

await fs.promises.mkdir(PATH_NYC_OUTPUT, { recursive: true });

await context.exposeFunction('collectIstanbulCoverage', (coverageJSON: string) => {
if (coverageJSON) {
fs.writeFileSync(path.join(PATH_NYC_OUTPUT, `playwright_coverage_${uuid()}.json`), coverageJSON);
}
});

await use(context);

await Promise.all(
context.pages().map(async (page) => {
await page.evaluate(() => (window as any).collectIstanbulCoverage(JSON.stringify((window as any).__coverage__)));
await page.close();
}),
);
},
});

export const { expect } = test;
Loading

0 comments on commit 1bb25f0

Please sign in to comment.