Files
upstream-mattermost/e2e-tests/playwright/specs/functional/channels/search/cross_team_search.spec.ts
upstream-mirror 240db4e2a7
Some checks failed
Server CI / Postgres (shard 0) (push) Has been skipped
Server CI / Postgres (shard 3) (push) Has been skipped
BuildEnv Docker Image / build-image (push) Failing after 4s
BuildEnv Docker Image / build-image-fips (push) Failing after 4s
Migration Review & Release Notes / Generate migration review & release notes (push) Failing after 3s
Server CI / Build Environment (push) Failing after 3s
Server CI / Postgres (shard 1) (push) Has been skipped
Tools CI / check-style (mattermost-govet) (push) Failing after 4s
Server CI / Postgres (shard 2) (push) Has been skipped
Tools CI / check-style (mmgotool) (push) Failing after 3s
Server CI / Elasticsearch v8 Compatibility (push) Has been skipped
Server CI / OpenSearch v2 Compatibility (push) Has been skipped
Server CI / Postgres FIPS (shard 0) (push) Has been skipped
Tools CI / Test (mattermost-govet) (push) Failing after 3s
Server CI / Postgres FIPS (shard 1) (push) Has been skipped
Server CI / Postgres FIPS (shard 2) (push) Has been skipped
Tools CI / Test (mmgotool) (push) Failing after 3s
Server CI / Postgres FIPS (shard 3) (push) Has been skipped
Server CI / Run mmctl tests (push) Has been skipped
Server CI / Run mmctl tests (FIPS) (push) Has been skipped
Server CI / Merge Postgres Test Results (push) Has been skipped
Server CI / Merge Postgres FIPS Test Results (push) Has been skipped
Server CI / Check backport migrations (push) Has been skipped
Server CI / Check generated files (push) Has been skipped
Server CI / check-style (push) Has been skipped
Server CI / Vet API (push) Has been skipped
Server CI / Build mattermost server app (push) Has been skipped
Server CI / Server CI Complete (push) Failing after 2s
Server CI / Server CI Artifacts (push) Has been skipped
Server CI / Sentry Upload (push) Has been skipped
Server CI / Server CI Report (push) Failing after 5m1s
Server CI Nightly Race / Race Detector (push) Has been skipped
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Webapp CI Cache Warm / Warm Webapp node_modules Cache (push) Has been cancelled
E2E CI Cache Warm / Warm E2E npm Registry Cache (push) Has been cancelled
API / build (push) Has been cancelled
Web App CI / check-types (push) Has been cancelled
Web App CI / check-lint (push) Has been cancelled
Web App CI / check-i18n (push) Has been cancelled
Web App CI / check-external-links (push) Has been cancelled
Web App CI / test (platform) (push) Has been cancelled
Web App CI / test (mattermost-redux) (push) Has been cancelled
Web App CI / test (channels shard 1/4) (push) Has been cancelled
Web App CI / test (channels shard 2/4) (push) Has been cancelled
Web App CI / test (channels shard 3/4) (push) Has been cancelled
Web App CI / test (channels shard 4/4) (push) Has been cancelled
Web App CI / upload-coverage (push) Has been cancelled
Web App CI / build (push) Has been cancelled
YAML Lint / yamllint (push) Has been cancelled
Push mirrored docker images / cd/Push mirrored docker images (push) Has been cancelled
docs-cd / Build and deploy docs (push) Has been cancelled
Docs CI / build (push) Has been cancelled
E2E Cache Warm: Cypress deps / Warm Cypress deps cache (push) Has been cancelled
Scorecards supply-chain security / Scorecard analysis (push) Has been cancelled
Server CI Weekly / Postgres FIPS (push) Has been skipped
Server CI Weekly / Run mmctl tests (FIPS) (push) Has been skipped
Server CI Weekly / Postgres with binary parameters (push) Has been skipped
Server CI Weekly / Build Environment (push) Failing after 1s
Server CI Nightly Race / Build Environment (push) Failing after 1s
Server CI Cache Warm / Warm Go Module and Build Cache (push) Failing after 1s
snapshot of https://github.com/mattermost/mattermost.git (master, 2026-09-16; blobs > 131072B omitted)
2026-09-16 00:29:55 +05:00

175 lines
8.2 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import type {Team} from '@mattermost/types/teams';
import {expect, test} from '@mattermost/playwright-lib';
/**
* @objective Verify cross-team search still renders the team selector and returns results correctly
* when the Onyx (dark) theme is active.
*/
test('MM-T5806 cross-team search works under the Onyx (dark) theme', {tag: '@search'}, async ({pw}) => {
// # Create a user with two teams and post a message to search for
const {adminClient, team, user} = await pw.initSetup();
const secondTeam = await adminClient.createTeam(await pw.random.team('team', 'Team', 'O', true));
await adminClient.addUsersToTeam(secondTeam.id, [user.id]);
const message = 'this is a test post containing the word pineapple';
const channel = await adminClient.getChannelByName(team.id, 'town-square');
await adminClient.createPost({channel_id: channel.id, message});
// # Log in and switch to the Onyx (dark) theme
const {channelsPage} = await pw.testBrowser.login(user);
await channelsPage.goto(team.name);
await channelsPage.toBeVisible();
const settingsModal = await channelsPage.openSettings();
const displaySettings = await settingsModal.openDisplayTab();
await displaySettings.selectPremadeTheme('Onyx');
await settingsModal.close();
// # Search for the message across teams
await channelsPage.searchFor('pineapple');
// * Verify the team selector and search results render correctly under the dark theme
await channelsPage.searchResultsPanel.teamSelector.toBeVisible();
await channelsPage.searchResultsPanel.toContainText(message);
});
/**
* @objective Verify the team filter in the search team-selector menu shows no results for a
* non-matching query, and correctly narrows to a single team for a partial matching query.
*/
test('MM-T5805 team filter shows no results for a non-matching query', {tag: '@search'}, async ({pw}) => {
// # Create a user and enough teams (5 total) for the team-filter input to render
// (see team_selector.spec.ts: the filter only shows with more than 4 teams)
const {adminClient, team, user} = await pw.initSetup();
const extraTeams: Record<string, Team> = {};
for (const fruit of ['Apple', 'Banana', 'Peach', 'Grape']) {
const newTeam = await adminClient.createTeam(await pw.random.team(fruit.toLowerCase(), fruit, 'O', true));
await adminClient.addUsersToTeam(newTeam.id, [user.id]);
extraTeams[fruit] = newTeam;
}
// # Log in, open search, and open the team selector
const {channelsPage} = await pw.testBrowser.login(user);
await channelsPage.goto(team.name);
await channelsPage.toBeVisible();
await channelsPage.globalHeader.openSearch();
const teamSelector = channelsPage.searchBox.teamSelector;
await teamSelector.open();
await expect(teamSelector.filterInput).toBeVisible();
// # Filter by a string that matches no team
await teamSelector.filterBy('Rhino');
// * Verify none of the fruit teams match, but the current team is still shown (current team is always visible)
for (const fruit of Object.keys(extraTeams)) {
await expect(teamSelector.teamOption(extraTeams[fruit].display_name)).not.toBeVisible();
}
await expect(teamSelector.teamOption(team.display_name)).toBeVisible();
// # Filter by a partial string that matches exactly one team
await teamSelector.filterBy('Banana');
// * Verify only the matching team (plus the always-visible current team) is shown
await expect(teamSelector.teamOption(extraTeams.Banana.display_name)).toBeVisible();
await expect(teamSelector.teamOption(team.display_name)).toBeVisible();
for (const fruit of ['Apple', 'Peach', 'Grape']) {
await expect(teamSelector.teamOption(extraTeams[fruit].display_name)).not.toBeVisible();
}
});
/**
* @objective Verify the search team-selector defaults to the active team (not "All Teams"), that a
* typed query persists across team-selector changes, and that the "Your teams" section header in
* the dropdown only appears while a specific team (not "All Teams") is selected.
*/
test(
'MM-T5801 team selector defaults to the active team, preserves the query, and hides "Your teams" for All Teams',
{tag: '@search'},
async ({pw}) => {
// # Create a user and 4 more teams (5 total) so the "Your teams" section renders
// (see team_selector.spec.ts: the filter/section only shows with more than 4 teams)
const {adminClient, team, user} = await pw.initSetup();
const teams = [team];
for (let i = 0; i < 4; i++) {
const newTeam = await adminClient.createTeam(await pw.random.team('team', 'Team', 'O', true));
await adminClient.addUsersToTeam(newTeam.id, [user.id]);
teams.push(newTeam);
}
const secondTeam = teams[1];
const {channelsPage} = await pw.testBrowser.login(user);
await channelsPage.goto(team.name);
await channelsPage.toBeVisible();
await channelsPage.globalHeader.openSearch();
const teamSelector = channelsPage.searchBox.teamSelector;
// * Verify the selector defaults to the currently active team, not "All Teams"
await expect(teamSelector.menuButton).toContainText(team.display_name);
// # Type a query without submitting, then switch the team selector to a different team
await channelsPage.searchBox.searchInput.fill('pineapple');
await teamSelector.selectTeam(secondTeam.display_name);
// * Verify the button label updated and the query text was preserved
await expect(teamSelector.menuButton).toContainText(secondTeam.display_name);
await expect(channelsPage.searchBox.searchInput).toHaveValue('pineapple');
// * Verify the "Your teams" section header is shown while a specific team is selected
await teamSelector.open();
await expect(teamSelector.yourTeamsHeader).toBeVisible();
// # Switch to "All Teams" (the menu is already open from the check above)
await teamSelector.teamOption('All Teams').click();
// * Verify the "Your teams" section header is hidden once "All Teams" is selected
await teamSelector.open();
await expect(teamSelector.yourTeamsHeader).not.toBeVisible();
},
);
/**
* @objective Verify the "in:" channel filter is cleared from the search query when the team
* selector is switched to "All Teams", since the filter only makes sense within a single team.
*
* @knownIssue Switching the team selector to "All Teams" does NOT clear the "in:<channel>" clause
* from the query text — it's left in place, and submitting silently re-scopes the search back to
* the channel's own team rather than actually searching "All Teams".
*/
test.fixme(
'MM-T5804 "in:" channel filter is cleared when switching search to All Teams',
{tag: '@search'},
async ({pw}) => {
// # Create a user with a second team so "All Teams" is a real, distinct selector choice
const {adminClient, team, user} = await pw.initSetup();
const secondTeam = await adminClient.createTeam(await pw.random.team('team', 'Team', 'O', true));
await adminClient.addUsersToTeam(secondTeam.id, [user.id]);
const channel = await adminClient.getChannelByName(team.id, 'town-square');
const {channelsPage} = await pw.testBrowser.login(user);
await channelsPage.goto(team.name, channel.name);
await channelsPage.toBeVisible();
await channelsPage.globalHeader.openSearch();
// # Type "in:" and pick the channel from the autocomplete suggestion
const {searchInput} = channelsPage.searchBox;
await searchInput.fill('in:');
await searchInput.pressSequentially(channel.name);
await channelsPage.searchBox.container.getByText(channel.display_name, {exact: false}).first().click();
await expect(searchInput).toHaveValue(`in:${channel.name} `);
// # Switch the team selector to "All Teams"
await channelsPage.searchBox.teamSelector.selectAllTeams();
// * Verify the "in:" clause was cleared, since it's meaningless once scoped to All Teams
await expect(searchInput).not.toHaveValue(new RegExp(`in:${channel.name}`));
},
);