Cypress/E2E: Upgrade cypress and test server config (#24594)

* upgrade cypress and test server config

* fix checks to lint and types

* fix CloudSettings and upgrade packages to latest

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Saturnino Abril
2023-10-03 22:26:37 +08:00
коммит произвёл GitHub
родитель 43cb6fa6c1
Коммит f3f9a84456
15 изменённых файлов: 2347 добавлений и 1544 удалений

Просмотреть файл

@@ -1,8 +1,6 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {UserProfile} from 'mattermost-redux/types/users';
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
@@ -13,7 +11,7 @@ import {UserProfile} from 'mattermost-redux/types/users';
// Group: @channels @channel
describe('Leave and Archive channel actions display as destructive', () => {
let testUser: UserProfile;
let testUser: Cypress.UserProfile;
let offTopicUrl: string;
before(() => {

Просмотреть файл

@@ -10,116 +10,6 @@
// Stage: @prod
// Group: @channels @cloud_only @cloud_trial
function simulateSubscription() {
cy.intercept('GET', '**/api/v4/cloud/subscription/invoices', {
statusCode: 200,
body: [
{
id: 'in_1Lz8b0I67GP2qpb43kcuMyFP',
number: '8D53267B-0006',
create_at: 1667263490000,
total: 65,
tax: 0,
status: 'open',
description: '',
period_start: 1664582400000,
period_end: 1667260800000,
subscription_id: 'sub_K0AxuWCDoDD9Qq',
line_items: [
{
price_id: 'price_1KLUYiI67GP2qpb48DXFukcJ',
total: 65,
quantity: 0.06451612903225806,
price_per_unit: 1000,
description: 'Cloud Professional',
},
],
current_product_name: 'Cloud Professional',
},
{
id: 'in_1LntnKI67GP2qpb4VObu3NgP',
number: '8D53267B-0005',
create_at: 1664584986000,
total: 733,
tax: 0,
status: 'failed',
description: '',
period_start: 1661990400000,
period_end: 1664582400000,
subscription_id: 'sub_K0AxuWCDoDD9Qq',
line_items: [
{
price_id: 'price_1KLUZ2I67GP2qpb45uTS89eb',
total: 733,
quantity: 0.7333333333333333,
price_per_unit: 999,
description: 'Cloud Professional',
},
],
current_product_name: 'Cloud Professional',
},
{
id: 'in_1LntnKI67GP2qpb4VObu3NgV',
number: '8D53267B-0005',
create_at: 1664584986000,
total: 733,
tax: 0,
status: 'paid',
description: '',
period_start: 1661990400000,
period_end: 1664582400000,
subscription_id: 'sub_K0AxuWCDoDD9Qq',
line_items: [
{
price_id: 'price_1KLUZ2I67GP2qpb45uTS89eb',
total: 733,
quantity: 0.7333333333333333,
price_per_unit: 999,
description: 'Cloud Professional',
},
],
current_product_name: 'Cloud Professional',
},
],
});
cy.intercept('GET', '**/api/v4/cloud/subscription', {
statusCode: 200,
body: {
id: 'sub_test1',
is_free_trial: 'true',
customer_id: '5zqhakmibpgyix9juiwwkpfnmr',
product_id: 'prod_K0AxuWCDoDD9Qq',
seats: 25,
status: 'active',
},
});
cy.intercept('GET', '**/api/v4/cloud/products**', {
statusCode: 200,
body:
[
{
id: 'prod_LSBESgGXq9KlLj',
sku: 'cloud-starter',
price_per_seat: 0,
name: 'Cloud Free',
},
{
id: 'prod_K0AxuWCDoDD9Qq',
sku: 'cloud-professional',
price_per_seat: 10,
name: 'Cloud Professional',
},
{
id: 'prod_Jh6tBLcgWWOOog',
sku: 'cloud-enterprise',
price_per_seat: 30,
name: 'Cloud Enterprise',
},
],
});
}
describe('System Console - Billing History', () => {
before(() => {
simulateSubscription();
@@ -166,6 +56,116 @@ describe('System Console - Billing History', () => {
cy.get('@tableRows').eq(1).find('td').eq(4).find('a').should('have.attr', 'href').and('include', 'invoices/in_1LntnKI67GP2qpb4VObu3NgP/pdf');
cy.get('@tableRows').eq(2).find('td').eq(4).find('a').should('have.attr', 'href').and('include', 'invoices/in_1LntnKI67GP2qpb4VObu3NgV/pdf');
});
function simulateSubscription() {
cy.intercept('GET', '**/api/v4/cloud/subscription/invoices', {
statusCode: 200,
body: [
{
id: 'in_1Lz8b0I67GP2qpb43kcuMyFP',
number: '8D53267B-0006',
create_at: 1667263490000,
total: 65,
tax: 0,
status: 'open',
description: '',
period_start: 1664582400000,
period_end: 1667260800000,
subscription_id: 'sub_K0AxuWCDoDD9Qq',
line_items: [
{
price_id: 'price_1KLUYiI67GP2qpb48DXFukcJ',
total: 65,
quantity: 0.06451612903225806,
price_per_unit: 1000,
description: 'Cloud Professional',
},
],
current_product_name: 'Cloud Professional',
},
{
id: 'in_1LntnKI67GP2qpb4VObu3NgP',
number: '8D53267B-0005',
create_at: 1664584986000,
total: 733,
tax: 0,
status: 'failed',
description: '',
period_start: 1661990400000,
period_end: 1664582400000,
subscription_id: 'sub_K0AxuWCDoDD9Qq',
line_items: [
{
price_id: 'price_1KLUZ2I67GP2qpb45uTS89eb',
total: 733,
quantity: 0.7333333333333333,
price_per_unit: 999,
description: 'Cloud Professional',
},
],
current_product_name: 'Cloud Professional',
},
{
id: 'in_1LntnKI67GP2qpb4VObu3NgV',
number: '8D53267B-0005',
create_at: 1664584986000,
total: 733,
tax: 0,
status: 'paid',
description: '',
period_start: 1661990400000,
period_end: 1664582400000,
subscription_id: 'sub_K0AxuWCDoDD9Qq',
line_items: [
{
price_id: 'price_1KLUZ2I67GP2qpb45uTS89eb',
total: 733,
quantity: 0.7333333333333333,
price_per_unit: 999,
description: 'Cloud Professional',
},
],
current_product_name: 'Cloud Professional',
},
],
});
cy.intercept('GET', '**/api/v4/cloud/subscription', {
statusCode: 200,
body: {
id: 'sub_test1',
is_free_trial: 'true',
customer_id: '5zqhakmibpgyix9juiwwkpfnmr',
product_id: 'prod_K0AxuWCDoDD9Qq',
seats: 25,
status: 'active',
},
});
cy.intercept('GET', '**/api/v4/cloud/products**', {
statusCode: 200,
body:
[
{
id: 'prod_LSBESgGXq9KlLj',
sku: 'cloud-starter',
price_per_seat: 0,
name: 'Cloud Free',
},
{
id: 'prod_K0AxuWCDoDD9Qq',
sku: 'cloud-professional',
price_per_seat: 10,
name: 'Cloud Professional',
},
{
id: 'prod_Jh6tBLcgWWOOog',
sku: 'cloud-enterprise',
price_per_seat: 30,
name: 'Cloud Enterprise',
},
],
});
}
});
describe('System Console - Empty Billing Screen', () => {

Просмотреть файл

@@ -10,45 +10,6 @@
// Stage: @prod
// Group: @channels @cloud_only @cloud_trial
function simulateSubscription() {
cy.intercept('GET', '**/api/v4/cloud/subscription', {
statusCode: 200,
body: {
id: 'sub_test1',
is_free_trial: 'true',
customer_id: '5zqhakmibpgyix9juiwwkpfnmr',
product_id: 'prod_Jh6tBLcgWWOOog',
seats: 25,
status: 'active',
},
});
cy.intercept('GET', '**/api/v4/cloud/products**', {
statusCode: 200,
body:
[
{
id: 'prod_LSBESgGXq9KlLj',
sku: 'cloud-starter',
price_per_seat: 0,
name: 'Cloud Free',
},
{
id: 'prod_K0AxuWCDoDD9Qq',
sku: 'cloud-professional',
price_per_seat: 10,
name: 'Cloud Professional',
},
{
id: 'prod_Jh6tBLcgWWOOog',
sku: 'cloud-enterprise',
price_per_seat: 30,
name: 'Cloud Enterprise',
},
],
});
}
describe('System Console - Payment Information section', () => {
before(() => {
// * Check if server has license for Cloud
@@ -116,5 +77,43 @@ describe('System Console - Payment Information section', () => {
cy.get('span.savedFeedback__text').should('be.visible').should('have.text', 'Thanks for sharing feedback!');
cy.get('button#feedbackSubmitedDone').should('be.enabled').click();
});
});
function simulateSubscription() {
cy.intercept('GET', '**/api/v4/cloud/subscription', {
statusCode: 200,
body: {
id: 'sub_test1',
is_free_trial: 'true',
customer_id: '5zqhakmibpgyix9juiwwkpfnmr',
product_id: 'prod_Jh6tBLcgWWOOog',
seats: 25,
status: 'active',
},
});
cy.intercept('GET', '**/api/v4/cloud/products**', {
statusCode: 200,
body:
[
{
id: 'prod_LSBESgGXq9KlLj',
sku: 'cloud-starter',
price_per_seat: 0,
name: 'Cloud Free',
},
{
id: 'prod_K0AxuWCDoDD9Qq',
sku: 'cloud-professional',
price_per_seat: 10,
name: 'Cloud Professional',
},
{
id: 'prod_Jh6tBLcgWWOOog',
sku: 'cloud-enterprise',
price_per_seat: 30,
name: 'Cloud Enterprise',
},
],
});
}
});

Просмотреть файл

@@ -10,37 +10,6 @@
// Stage: @prod
// Group: @channels @enterprise @not_cloud @system_console
// # Goes to the System Scheme page as System Admin
const goToSessionLengths = () => {
cy.apiAdminLogin();
cy.visit('/admin_console/environment/session_lengths');
};
// # Wait's until the Saving text becomes Save
const waitUntilConfigSave = () => {
cy.waitUntil(() => cy.get('#saveSetting').then((el) => {
return el[0].innerText === 'Save';
}));
};
// Clicks the save button in the system console page.
// waitUntilConfigSaved: If we need to wait for the save button to go from saving -> save.
// Usually we need to wait unless we are doing this in team override scheme
const saveConfig = (waitUntilConfigSaved = true, clickConfirmationButton = false) => {
// # Save if possible (if previous test ended abruptly all permissions may already be enabled)
cy.get('#saveSetting').then((btn) => {
if (btn.is(':enabled')) {
btn.click();
}
});
if (clickConfirmationButton) {
cy.get('#confirmModalButton').click();
}
if (waitUntilConfigSaved) {
waitUntilConfigSave();
}
};
describe('MM-T2574 Session Lengths', () => {
before(() => {
cy.shouldNotRunOnCloudEdition();
@@ -125,4 +94,35 @@ describe('MM-T2574 Session Lengths', () => {
}
});
});
// # Goes to the System Scheme page as System Admin
const goToSessionLengths = () => {
cy.apiAdminLogin();
cy.visit('/admin_console/environment/session_lengths');
};
// # Wait's until the Saving text becomes Save
const waitUntilConfigSave = () => {
cy.waitUntil(() => cy.get('#saveSetting').then((el) => {
return el[0].innerText === 'Save';
}));
};
// Clicks the save button in the system console page.
// waitUntilConfigSaved: If we need to wait for the save button to go from saving -> save.
// Usually we need to wait unless we are doing this in team override scheme
const saveConfig = (waitUntilConfigSaved = true, clickConfirmationButton = false) => {
// # Save if possible (if previous test ended abruptly all permissions may already be enabled)
cy.get('#saveSetting').then((btn) => {
if (btn.is(':enabled')) {
btn.click();
}
});
if (clickConfirmationButton) {
cy.get('#confirmModalButton').click();
}
if (waitUntilConfigSaved) {
waitUntilConfigSave();
}
};
});

Просмотреть файл

@@ -9,26 +9,6 @@
// Group: @channels @enterprise @not_cloud
function withTrialBefore(trialed: string) {
cy.intercept('GET', '**/api/v4/trial-license/prev', {
statusCode: 200,
body: {
IsLicensed: trialed,
IsTrial: trialed,
},
});
}
function withTrialLicense(trial: string) {
cy.intercept('GET', '**/api/v4/license/client?format=old', {
statusCode: 200,
body: {
IsLicensed: 'true',
IsTrial: trial,
},
});
}
describe('Self hosted Pricing modal', () => {
let urlL: string | undefined;
let createdUser: Cypress.UserProfile | undefined;
@@ -191,4 +171,24 @@ describe('Self hosted Pricing modal', () => {
cy.findByText('https://mattermost.com/pl/pricing/#self-hosted').last().should('exist');
});
function withTrialBefore(trialed: string) {
cy.intercept('GET', '**/api/v4/trial-license/prev', {
statusCode: 200,
body: {
IsLicensed: trialed,
IsTrial: trialed,
},
});
}
function withTrialLicense(trial: string) {
cy.intercept('GET', '**/api/v4/license/client?format=old', {
statusCode: 200,
body: {
IsLicensed: 'true',
IsTrial: trial,
},
});
}
});