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 Cache Warm / Warm Go Module and Build Cache (push) Failing after 2s
Server CI Nightly Race / Build Environment (push) Failing after 1s
267 lines
11 KiB
TypeScript
267 lines
11 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {expect, test} from '@mattermost/playwright-lib';
|
|
|
|
test('team selector should not be visible if user belongs to only one team', async ({pw}) => {
|
|
// # Create a user with only one team
|
|
const {adminClient, user, team} = await pw.initSetup();
|
|
|
|
// # Create a channel in the team
|
|
const channel = await adminClient.createChannel(
|
|
pw.random.channel({
|
|
teamId: team.id,
|
|
displayName: 'Test Channel',
|
|
name: 'test-channel',
|
|
}),
|
|
);
|
|
|
|
// # Post a message in the channel
|
|
const message = 'test message for search';
|
|
await adminClient.createPost({
|
|
channel_id: channel.id,
|
|
message,
|
|
});
|
|
|
|
// # Log in as the user
|
|
const {channelsPage} = await pw.testBrowser.login(user);
|
|
|
|
// # Visit a default channel page
|
|
await channelsPage.goto(team.name);
|
|
await channelsPage.toBeVisible();
|
|
|
|
// # Open the search UI
|
|
await channelsPage.globalHeader.openSearch();
|
|
|
|
// * Verify that the team selector is not visible in the search box
|
|
await channelsPage.searchBox.toBeVisible();
|
|
await channelsPage.searchBox.teamSelector.notToBeVisible();
|
|
|
|
// # Now search for the message to see search results
|
|
await channelsPage.searchBox.search(message);
|
|
await channelsPage.searchResultsPanel.toBeVisible();
|
|
|
|
// * Verify the team selector is not visible in search results panel
|
|
await channelsPage.searchResultsPanel.teamSelector.notToBeVisible();
|
|
});
|
|
|
|
test('team selector should be visible if user belongs to multiple teams', async ({pw}) => {
|
|
// # Create a user and admin client
|
|
const {adminClient, user, team} = await pw.initSetup();
|
|
|
|
// # Create a second team and add the user to it
|
|
const secondTeam = await adminClient.createTeam(await pw.random.team('team', 'Team', 'O', true));
|
|
await adminClient.addUsersToTeam(secondTeam.id, [user.id]);
|
|
|
|
// # Create a channel in the first team
|
|
const channel = await adminClient.createChannel(
|
|
pw.random.channel({
|
|
teamId: team.id,
|
|
displayName: 'Test Channel',
|
|
name: 'test-channel-multi',
|
|
}),
|
|
);
|
|
|
|
// # Post a message in the channel
|
|
const message = 'test message for multiple teams search';
|
|
await adminClient.createPost({
|
|
channel_id: channel.id,
|
|
message,
|
|
});
|
|
|
|
// # Log in as the user
|
|
const {channelsPage} = await pw.testBrowser.login(user);
|
|
|
|
// # Visit a default channel page
|
|
await channelsPage.goto(team.name);
|
|
await channelsPage.toBeVisible();
|
|
|
|
// # Open the search UI
|
|
await channelsPage.globalHeader.openSearch();
|
|
|
|
// * Verify that the team selector is visible in the search box
|
|
await channelsPage.searchBox.toBeVisible();
|
|
const composerTeamSelector = channelsPage.searchBox.teamSelector;
|
|
await composerTeamSelector.toBeVisible();
|
|
|
|
// # Click on the team selector button
|
|
await composerTeamSelector.open();
|
|
|
|
// * Verify that both teams are visible in the menu
|
|
await expect(composerTeamSelector.teamOption(team.display_name)).toBeVisible();
|
|
await expect(composerTeamSelector.teamOption(secondTeam.display_name)).toBeVisible();
|
|
await expect(composerTeamSelector.teamOption('All Teams')).toBeVisible();
|
|
|
|
// # Now search for the message to see search results
|
|
await composerTeamSelector.close();
|
|
await channelsPage.searchBox.search(message);
|
|
await channelsPage.searchResultsPanel.toBeVisible();
|
|
|
|
// * Verify the team selector is visible in search results panel
|
|
const resultsTeamSelector = channelsPage.searchResultsPanel.teamSelector;
|
|
await resultsTeamSelector.toBeVisible();
|
|
|
|
// # Click on the team selector in results panel
|
|
await resultsTeamSelector.open();
|
|
|
|
// * Verify that both teams are visible in the results panel team selector
|
|
await expect(resultsTeamSelector.teamOption(team.display_name)).toBeVisible();
|
|
await expect(resultsTeamSelector.teamOption(secondTeam.display_name)).toBeVisible();
|
|
await expect(resultsTeamSelector.teamOption('All Teams')).toBeVisible();
|
|
});
|
|
|
|
test('team selector should show filter input with more than 4 teams', async ({pw}) => {
|
|
// # Create a user and admin client
|
|
const {adminClient, user, team} = await pw.initSetup();
|
|
|
|
// # Create 4 more teams (for a total of 5) and add the user to them
|
|
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);
|
|
}
|
|
|
|
// # Log in as the user
|
|
const {channelsPage} = await pw.testBrowser.login(user);
|
|
|
|
// # Visit a default channel page
|
|
await channelsPage.goto(team.name);
|
|
await channelsPage.toBeVisible();
|
|
|
|
// # Open the search UI
|
|
await channelsPage.globalHeader.openSearch();
|
|
|
|
// # Verify team selector is visible and click on it
|
|
const teamSelector = channelsPage.searchBox.teamSelector;
|
|
await teamSelector.toBeVisible();
|
|
await teamSelector.open();
|
|
|
|
// # Verify the team filter input is visible with 5 teams
|
|
await expect(teamSelector.filterInput).toBeVisible();
|
|
|
|
// # Verify all teams are visible initially
|
|
for (const t of teams) {
|
|
await expect(teamSelector.teamOption(t.display_name)).toBeVisible();
|
|
}
|
|
|
|
// # Type filter text to match only one team
|
|
await teamSelector.filterBy(teams[2].display_name);
|
|
|
|
// # Verify only the matching team is visible (and the currently selected team)
|
|
await expect(teamSelector.teamOption(teams[0].display_name)).toBeVisible(); // Current team always visible
|
|
await expect(teamSelector.teamOption(teams[2].display_name)).toBeVisible(); // Filtered team
|
|
|
|
// # Verify other teams are hidden
|
|
for (let i = 1; i < teams.length; i++) {
|
|
if (i !== 2) {
|
|
// Skip the filtered team we're expecting to see
|
|
await expect(teamSelector.teamOption(teams[i].display_name)).not.toBeVisible();
|
|
}
|
|
}
|
|
|
|
// # Clear the filter
|
|
await teamSelector.filterBy('');
|
|
|
|
// # Verify all teams are visible again
|
|
for (const t of teams) {
|
|
await expect(teamSelector.teamOption(t.display_name)).toBeVisible();
|
|
}
|
|
});
|
|
|
|
test('MM-T5802 team filter list updates when a team is left', async ({pw}) => {
|
|
// # Create a user and 4 more teams (5 total) so the team-filter input renders
|
|
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);
|
|
}
|
|
|
|
// # Log in as the user 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();
|
|
|
|
// * Verify all 5 teams are listed initially
|
|
for (const t of teams) {
|
|
await expect(teamSelector.teamOption(t.display_name)).toBeVisible();
|
|
}
|
|
|
|
// # Close the menu, then switch to and leave one of the extra teams
|
|
await teamSelector.close();
|
|
const teamToLeave = teams[teams.length - 1];
|
|
await channelsPage.leaveTeam(teamToLeave.name);
|
|
|
|
// # Reopen search and the team selector
|
|
await channelsPage.toBeVisible();
|
|
await channelsPage.globalHeader.openSearch();
|
|
await teamSelector.open();
|
|
|
|
// * Verify the left team no longer appears in the filter list
|
|
await expect(teamSelector.teamOption(teamToLeave.display_name)).not.toBeVisible();
|
|
|
|
// * Verify the remaining teams are still listed
|
|
for (const t of teams.slice(0, -1)) {
|
|
await expect(teamSelector.teamOption(t.display_name)).toBeVisible();
|
|
}
|
|
});
|
|
|
|
test('MM-T5803 search results narrow to the selected team and update after leaving that team', async ({pw}) => {
|
|
// # Create a user with two teams, each containing a distinct message
|
|
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 messageInFirstTeam = 'pineapple message in the first team';
|
|
const messageInSecondTeam = 'pineapple message in the second team';
|
|
const firstChannel = await adminClient.getChannelByName(team.id, 'town-square');
|
|
const secondChannel = await adminClient.getChannelByName(secondTeam.id, 'town-square');
|
|
await adminClient.createPost({channel_id: firstChannel.id, message: messageInFirstTeam});
|
|
await adminClient.createPost({channel_id: secondChannel.id, message: messageInSecondTeam});
|
|
|
|
// # Log in, open search, and explicitly select "All Teams"
|
|
// (the selector defaults to the currently active team, not "All Teams", on a fresh open)
|
|
const {channelsPage} = await pw.testBrowser.login(user);
|
|
await channelsPage.goto(team.name);
|
|
await channelsPage.toBeVisible();
|
|
await channelsPage.globalHeader.openSearch();
|
|
|
|
const composerTeamSelector = channelsPage.searchBox.teamSelector;
|
|
await composerTeamSelector.selectAllTeams();
|
|
await channelsPage.searchBox.search('pineapple');
|
|
|
|
// * Verify both teams' messages show up
|
|
await channelsPage.searchResultsPanel.toContainText(messageInFirstTeam);
|
|
await channelsPage.searchResultsPanel.toContainText(messageInSecondTeam);
|
|
|
|
// # Reopen the search composer and narrow its team selector to the second team specifically
|
|
// (changing the team via the results panel's own selector updates state but does not refresh
|
|
// the displayed results — the search must be resubmitted via the composer, as below)
|
|
await channelsPage.globalHeader.openSearch();
|
|
await composerTeamSelector.selectTeam(secondTeam.display_name);
|
|
|
|
// # Re-submit the search now that the composer is scoped to the second team
|
|
await channelsPage.searchBox.searchInput.click();
|
|
await channelsPage.searchBox.searchInput.press('Enter');
|
|
|
|
// * Verify only the second team's message shows
|
|
await expect(channelsPage.searchResultsPanel.container).toContainText(messageInSecondTeam);
|
|
await expect(channelsPage.searchResultsPanel.container).not.toContainText(messageInFirstTeam);
|
|
|
|
// # Leave the second team and re-run the same search
|
|
await channelsPage.leaveTeam(secondTeam.name);
|
|
await channelsPage.toBeVisible();
|
|
await channelsPage.searchFor('pineapple');
|
|
|
|
// * Verify only the first team's message shows now that the second team was left
|
|
await expect(channelsPage.searchResultsPanel.container).toContainText(messageInFirstTeam);
|
|
await expect(channelsPage.searchResultsPanel.container).not.toContainText(messageInSecondTeam);
|
|
});
|