Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

MM-29918 Cypress/E2E: Add ability to run tests for EE and TE #6883

Merged
merged 2 commits into from
Oct 24, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************

// Group: @system_console @group_mentions
// Group: @enterprise @system_console @group_mentions

import ldapUsers from '../../../fixtures/ldap_users.json';
import * as TIMEOUTS from '../../../fixtures/timeouts';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************

// Group: @system_console @group_mentions
// Group: @enterprise @system_console @group_mentions

import ldapUsers from '../../../fixtures/ldap_users.json';
import * as TIMEOUTS from '../../../fixtures/timeouts';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************

// Group: @system_console @group_mentions
// Group: @enterprise @system_console @group_mentions

import ldapUsers from '../../../fixtures/ldap_users.json';
import * as TIMEOUTS from '../../../fixtures/timeouts';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// ***************************************************************

// Stage: @prod
// Group: @guest_account
// Group: @enterprise @guest_account

/**
* Note: This test requires Enterprise license to be uploaded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// ***************************************************************

// Stage: @prod
// Group: @guest_account
// Group: @enterprise @guest_account

/**
* Note: This test requires Enterprise license to be uploaded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// ***************************************************************

// Stage: @prod
// Group: @guest_account
// Group: @enterprise @guest_account

/**
* Note: This test requires Enterprise license to be uploaded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// ***************************************************************

// Stage: @prod
// Group: @guest_account
// Group: @enterprise @guest_account

/**
* Note: This test requires Enterprise license to be uploaded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// ***************************************************************

// Stage: @prod
// Group: @guest_account
// Group: @enterprise @guest_account

/**
* Note: This test requires Enterprise license to be uploaded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// ***************************************************************

// Stage: @prod
// Group: @guest_account
// Group: @enterprise @guest_account

/**
* Note: This test requires Enterprise license to be uploaded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// ***************************************************************

// Stage: @prod
// Group: @guest_account
// Group: @enterprise @guest_account

/**
* Note: This test requires Enterprise license to be uploaded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************

// Group: @profile_popover
// Group: @enterprise @profile_popover

import * as TIMEOUTS from '../../fixtures/timeouts';
import {createPrivateChannel} from '../enterprise/elasticsearch_autocomplete/helpers';
import {getAdminAccount} from '../../support/env';
import * as TIMEOUTS from '../../../fixtures/timeouts';
import {createPrivateChannel} from '../elasticsearch_autocomplete/helpers';
import {getAdminAccount} from '../../../support/env';

describe('Profile popover', () => {
let testTeam;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************

// Group: @enterprise

import * as TIMEOUTS from '../../../fixtures/timeouts';

describe('Channel members test', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// ***************************************************************

// Stage: @prod
// Group: @enterprise

import * as TIMEOUTS from '../../../fixtures/timeouts';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

const applitoolsConfig = require('../../../applitools.config');
const applitoolsConfig = require('../../../../applitools.config');

export function getBatchName(suffix) {
const batchName = Cypress.env('batchName') || applitoolsConfig.batchName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// Stage: @prod
// Group: @enterprise @system_console @visual_regression

import * as TIMEOUTS from '../../../fixtures/timeouts';
import * as TIMEOUTS from '../../../../fixtures/timeouts';

import {getBatchName} from '../helpers';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// Stage: @prod
// Group: @enterprise @system_console @visual_regression

import * as TIMEOUTS from '../../../fixtures/timeouts';
import * as TIMEOUTS from '../../../../fixtures/timeouts';

import {getBatchName} from '../helpers';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// Stage: @prod
// Group: @enterprise @system_console @visual_regression

import * as TIMEOUTS from '../../../fixtures/timeouts';
import * as TIMEOUTS from '../../../../fixtures/timeouts';

import {getBatchName} from '../helpers';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// Stage: @prod
// Group: @enterprise @system_console @visual_regression

import * as TIMEOUTS from '../../../fixtures/timeouts';
import * as TIMEOUTS from '../../../../fixtures/timeouts';

describe('System Console - Enterprise', () => {
const testCases = [
Expand Down
34 changes: 26 additions & 8 deletions e2e/run_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* --group=[group]
* Selects spec files with matching group. It can be of multiple values separated by comma.
* E.g. "--group='@channel,@messaging'" will select files with either @channel or @messaging.
* --exclude-group=[group]
* Exclude spec files with matching group. It can be of multiple values separated by comma.
* E.g. "--exclude-group='@enterprise'" will select files except @enterprise.
* --invert
* Selected files are those not matching any of the specified stage or group.
*
Expand All @@ -35,6 +38,12 @@
* - will run all non-production tests
* 4. "BROWSER='chrome' HEADLESS='false' node run_tests.js --stage='@prod' --group='@channel,@messaging'"
* - will run spec files matching stage and group values in Chrome (headed)
* 5. "CYPRESS_runWithEELicense=true node run_tests.js --stage='@prod'"
* - will run all production tests
* - typical test run for Enterprise Edition, given license file can be found in `cypress/fixtures` folder
* 6. "node run_tests.js --stage='@prod' --exclude-group='@enterprise'"
* - will run all production tests except @enterprise group
* - typical test run for Team Edition
*/

const os = require('os');
Expand Down Expand Up @@ -72,17 +81,11 @@ async function runTests() {
return;
}

const {invert, group, stage} = argv;

let hasFailed = false;
for (let i = 0; i < finalTestFiles.length; i++) {
const testFile = finalTestFiles[i];
const testStage = stage ? `Stage: "${stage}" ` : '';
const testGroup = group ? `Group: "${group}" ` : '';
printMessage(finalTestFiles, i);

// Log which files were being tested
console.log(chalk.magenta.bold(`${invert ? 'All Except --> ' : ''}${testStage}${stage && group ? '| ' : ''}${testGroup}`));
console.log(chalk.magenta(`(Testing ${i + 1} of ${finalTestFiles.length}) - `, testFile));
const testFile = finalTestFiles[i];

const result = await cypress.run({
browser,
Expand Down Expand Up @@ -146,4 +149,19 @@ async function runTests() {
chai.expect(hasFailed, FAILURE_MESSAGE).to.be.false;
}

function printMessage(testFiles, index) {
const {invert, excludeGroup, group, stage} = argv;

const testFile = testFiles[index];
const testStage = stage ? `Stage: "${stage}" ` : '';
const withGroup = group || excludeGroup;
const groupMessage = group ? `"${group}"` : 'All';
const excludeGroupMessage = excludeGroup ? `except "${excludeGroup}"` : '';
const testGroup = withGroup ? `Group: ${groupMessage} ${excludeGroupMessage}` : '';

// Log which files were being tested
console.log(chalk.magenta.bold(`${invert ? 'All Except --> ' : ''}${testStage}${stage && withGroup ? '| ' : ''}${testGroup}`));
console.log(chalk.magenta(`(Testing ${index + 1} of ${testFiles.length}) - `, testFile));
}

runTests();
44 changes: 27 additions & 17 deletions e2e/utils/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,58 +26,68 @@ const grepFiles = (command) => {
};

function getTestFiles() {
const {invert, group, stage} = argv;
const {invert, excludeGroup, group, stage} = argv;

const allFiles = grepFiles(grepCommand());

const stageFiles = [];
let stageFiles = allFiles;
if (stage) {
const sc = grepCommand(stage.split(',').join('\\|'));
stageFiles.push(...grepFiles(sc));
stageFiles = grepFiles(sc);
}
const groupFiles = [];

let groupFiles = [...stageFiles];
if (group) {
const gc = grepCommand(group.split(',').join('\\|'));
groupFiles.push(...grepFiles(gc));
groupFiles = grepFiles(gc);
}

const excludeGroupFiles = [];
if (excludeGroup) {
const egc = grepCommand(excludeGroup.split(',').join('\\|'));
excludeGroupFiles.push(...grepFiles(egc));
}

const finalGroupFiles = without(groupFiles, ...excludeGroupFiles);
const withGroup = group || excludeGroup;

if (invert) {
// Return no test file if no stage and group, but inverted
if (!stage && !group) {
// Return no test file if no stage and withGroup, but inverted
if (!stage && !withGroup) {
return [];
}

// Return all excluding stage files
if (stage && !group) {
if (stage && !withGroup) {
return without(allFiles, ...stageFiles);
}

// Return all excluding group files
if (!stage && group) {
return without(allFiles, ...groupFiles);
if (!stage && withGroup) {
return without(allFiles, ...finalGroupFiles);
}

// Return all excluding group and stage files
return without(allFiles, ...intersection(stageFiles, groupFiles));
return without(allFiles, ...intersection(stageFiles, finalGroupFiles));
}

// Return all files if no stage and group flags
if (!stage && !group) {
if (!stage && !withGroup) {
return allFiles;
}

// Return stage files if no group flag
if (stage && !group) {
if (stage && !withGroup) {
return stageFiles;
}

// Return group files if no stage flag
if (!stage && group) {
return groupFiles;
if (!stage && withGroup) {
return finalGroupFiles;
}

// Return files if both in stage and group
return intersection(stageFiles, groupFiles);
// Return files if both in stage and withGroup
return intersection(stageFiles, finalGroupFiles);
}

function getSkippedFiles(initialTestFiles, platform, browser, headless) {
Expand Down