Files
Harrison HealeyandGitHub daec1283e5 MM-69003 Mostly share ESLint config between web app and E2E tests (#36767)
* Switch Cypress to use shared ESLint config

* Run --fix in Cypress

* Manually fix remaining lint issues in Cypress

* Switch Playwright to use shared ESLint config

* Run --fix in Playwright

* Manually fix remaining lint issues in Playwright

* Install and cache web app deps during Cypress CI builds

This also caches the types and client package. That isn't needed currently
since it uses prepackaged versions of those, but I imagine we might change
that at some point.

* Run e2e-tests-check when ESLint plugin is updated

* Change E2E test GHA caching to cache all of web app node_modules

* Fix mismatch between cache save and restore

* Try bumping cache keys

* Copy step to install dependencies to server.run_cypress.sh

I don't know how this must've worked before, but if this fixes the issue,
it seems like neither Cypress nor Playwright actually use the cached
depenendencies.

* Try disabling caching entirely for Cypress tests

* Try bypassing makefile?

* Try also manually building dependencies in run_specs.sh

I don't know why this appears to duplicate run_cypress.sh and
run_playwright.sh, both of which are called run_test.sh which
might not be used any more as best I can tell.

* Try installing the web app dependencies in yet another place

* Disable the extra steps in server.prepare.sh specifically for Cypress

* Revert changes to update cache key and disable web app depenedency cache on Cypress builds
2026-06-09 20:50:58 +00:00

130 lines
4.4 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {expect} from '@mattermost/playwright-lib';
export async function setupContentFlagging(
adminClient: any,
userIds: string[],
enable = true,
hideFlaggedContent = true,
) {
// Configure content flagging
await adminClient.saveContentFlaggingConfig({
EnableContentFlagging: enable,
NotificationSettings: {
EventTargetMapping: {
assigned: ['reviewers', 'author'],
dismissed: ['reporter', 'author', 'reviewers'],
flagged: ['reviewers', 'author'],
removed: ['author', 'reporter', 'reviewers'],
},
},
ReviewerSettings: {
CommonReviewers: true,
CommonReviewerIds: userIds,
TeamReviewersSetting: {},
SystemAdminsAsReviewers: true,
TeamAdminsAsReviewers: true,
},
AdditionalSettings: {
Reasons: ['Classification mismatch', 'Need-to-know violation', 'Unauthorized disclosure', 'Other'],
ReporterCommentRequired: true,
ReviewerCommentRequired: true,
HideFlaggedContent: hideFlaggedContent,
},
});
return adminClient;
}
export async function createPost(adminClient: any, userClient: any, team: any, user: any, message: string) {
const channels = await adminClient.getMyChannels(team.id);
const townSquare = channels.find((ch: any) => ch.name === 'town-square');
if (!townSquare) {
throw new Error('Town Square channel not found');
}
const post = await userClient.createPost({
channel_id: townSquare.id,
message,
user_id: user.id,
});
return {post, message, townSquare};
}
export async function verifyAuthorNotification(
postID: string,
channelsPage: any,
contentReviewPage: any,
teamName: string,
expectedMessage: string,
postStatus: string,
) {
await channelsPage.goto(teamName, '@content-review');
await channelsPage.toBeVisible();
await contentReviewPage.setReportCardByPostID(postID);
await contentReviewPage.waitForPageLoaded();
await contentReviewPage.verifyFlaggedPostStatus(postStatus);
await contentReviewPage.verifyFlaggedPostReason('Classification mismatch');
await contentReviewPage.verifyFlaggedPostMessage(expectedMessage);
}
/**
* Verify flagged post details inside the RHS view
*/
export async function verifyRHSFlaggedPostDetails(
postID: string,
contentReviewPage: any,
postedByUsername: string,
flaggedByUsername: string,
postMessageFlagged: string,
reasonToFlag: string,
flagPostReviewStatus: string,
postFlaggedInChannel: string,
) {
await contentReviewPage.setReportCardByPostID(postID);
await contentReviewPage.openViewDetails();
await contentReviewPage.waitForRHSVisible();
await contentReviewPage.expectSelectProperty('Status', flagPostReviewStatus);
await contentReviewPage.expectSelectProperty('Reason', reasonToFlag);
await contentReviewPage.expectMessageContains(postMessageFlagged);
await contentReviewPage.expectUser('Quarantined by', flaggedByUsername);
await contentReviewPage.expectUser('Posted by', postedByUsername);
await contentReviewPage.expectChannel(postFlaggedInChannel);
}
/**
* Verify flagged post card details in the Content Review DM
*/
export async function verifyFlaggedPostCardDetails(
postID: string,
channelsPage: any,
contentReviewPage: any,
team: any,
expectedMessage: string,
) {
await channelsPage.goto(team.name, '@content-review');
await channelsPage.toBeVisible();
await contentReviewPage.setReportCardByPostID(postID);
await contentReviewPage.waitForPageLoaded();
await contentReviewPage.verifyFlaggedPostStatus('Pending');
await contentReviewPage.verifyFlaggedPostReason('Classification mismatch');
await contentReviewPage.verifyFlaggedPostMessage(expectedMessage);
}
export async function verifyReporterNotification(channelsPage: any, teamName: string, expectedMessage: string) {
await channelsPage.goto(teamName, '@content-review');
await channelsPage.toBeVisible();
const lastPostId = await channelsPage.centerView.getLastPostID();
const post = await channelsPage.centerView.getPostById(lastPostId);
await expect(post.body).toContainText(expectedMessage);
}