Skip to content

Commit

Permalink
Merge pull request #127 from TNG/bugfix/kick-typo
Browse files Browse the repository at this point in the history
Change wording: Remove instead of kick
  • Loading branch information
ThiloAschebrock committed Sep 16, 2023
2 parents efbf249 + 978b7ee commit a57f034
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion backend/sendmessage/src/remove-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const removeUser = async (user: string, config: ConfigWithHandler): Promi
broadcastState(updatedGroupItem, config),
userConnectionId &&
sendMessageToConnection(
{ type: 'not-logged-in', payload: { reason: `You have been kicked by ${userId}.` } },
{ type: 'not-logged-in', payload: { reason: `You have been removed by ${userId}.` } },
{ ...config, connectionId: userConnectionId },
),
]);
Expand Down
4 changes: 2 additions & 2 deletions e2e/pages/card-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export class CardPage {
await expect(this.votes).toHaveCount(states.length);
}

async kickUser(name: string) {
await this.votes.getByTitle(`Kick ${name}`).click();
async removeUser(name: string) {
await this.votes.getByTitle(`Remove ${name}`).click();
}

async selectCard(value: CardValue) {
Expand Down
4 changes: 2 additions & 2 deletions e2e/pages/login-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export class LoginPage {
await this.loginButton.click();
}

async assertKickedBy(name: string) {
await expect(this.alertText).toHaveText(`You have been kicked by ${name}.`);
async assertRemovedBy(name: string) {
await expect(this.alertText).toHaveText(`You have been removed by ${name}.`);
}

async assertSessionTakeover() {
Expand Down
6 changes: 3 additions & 3 deletions e2e/kicking.spec.ts → e2e/remove-users.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { test } from '@playwright/test';
import { assertOnCardPage } from './pages/card-page';
import { assertOnLoginPage, login, loginWithSameSession } from './pages/login-page';

test('allows to kick users', async ({ page, context }) => {
test('allows to remove users', async ({ page, context }) => {
await login(page, 'User 1');
const secondPage = await context.newPage();
await loginWithSameSession(secondPage, 'User 2', page);

const cardPage = await assertOnCardPage(page);
await cardPage.kickUser('User 2');
await cardPage.removeUser('User 2');
await cardPage.assertVotingStateIs([{ name: 'User 1', state: 'Not voted', pending: false }]);

const secondLoginPage = await assertOnLoginPage(secondPage);
await secondLoginPage.assertKickedBy('User 1');
await secondLoginPage.assertRemovedBy('User 1');
});
10 changes: 5 additions & 5 deletions frontend/src/Components/App/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('The App component', () => {
expect(container.querySelector('input[type=submit]')).not.toBeDisabled();
});

it('logs the user in and displays the voting page, then displays the login page if the user is kicked out', async () => {
it('logs the user in and displays the voting page, then displays the login page if the user is removed', async () => {
// given
const logoutReason = 'You were removed!';
const { socket, container, getByText } = await loginUser();
Expand All @@ -132,15 +132,15 @@ describe('The App component', () => {
expect(container.querySelector('input[type=submit]')).toBeVisible();
});

it('updates, reveals and resets votes and kicks optimistically once the first state message arrived', async () => {
it('updates, reveals and resets votes and removes users optimistically once the first state message arrived', async () => {
// given
const { socket, container, getByRole, getAllByTitle } = await loginUser();

// then
const revealButton = getByRole('button', { name: 'reveal votes' });
expect(revealButton).toBeDisabled();
container.querySelectorAll('button.largeCard').forEach((card) => expect(card).toBeDisabled());
getAllByTitle(/^Kick/).forEach((button) => expect(button).toBeDisabled());
getAllByTitle(/^Remove/).forEach((button) => expect(button).toBeDisabled());
const changeScaleButton = getByRole('button', { name: 'Change Scale' });
expect(changeScaleButton).toBeDisabled();

Expand All @@ -166,7 +166,7 @@ describe('The App component', () => {
// then
expect(revealButton).toBeEnabled();
container.querySelectorAll('button.largeCard').forEach((card) => expect(card).toBeEnabled());
getAllByTitle(/^Kick/).forEach((button) => expect(button).toBeEnabled());
getAllByTitle(/^Remove/).forEach((button) => expect(button).toBeEnabled());
expect(changeScaleButton).toBeEnabled();

// when
Expand All @@ -193,7 +193,7 @@ describe('The App component', () => {
socket.test_messages = [];

// when
fireEvent.click(getByRole('button', { name: 'Kick Non-voting User' }));
fireEvent.click(getByRole('button', { name: 'Remove Non-voting User' }));

// then
expect(container.querySelector('tbody')).toHaveTextContent('Happy UserVoting User');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { BUTTON_KICK } from '../../constants';
import { BUTTON_REMOVE_USER } from '../../constants';
import { connectToWebSocket } from '../WebSocket/WebSocket';
import classes from './KickButton.module.css';
import classes from './RemoveUserButton.module.css';

interface Props {
user: string;
}

export const KickButton = connectToWebSocket<Props>(
export const RemoveUserButton = connectToWebSocket<Props>(
({ socket: { connected, removeUser }, user }) => (
<button
class={classes.root}
title={BUTTON_KICK(user)}
title={BUTTON_REMOVE_USER(user)}
disabled={!connected}
onClick={() => removeUser(user)}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {
COLUMN_KICK,
COLUMN_NAME,
COLUMN_REMOVE,
COLUMN_VOTED,
TOOLTIP_PENDING_CONNECTION,
} from '../../constants';
import { UserState, getVotingState } from '../../helpers/getVotingState';
import sharedClasses from '../../styles.module.css';
import { WebSocketApi } from '../../types/WebSocket';
import { IconNotVoted } from '../IconNotVoted/IconNotVoted';
import { IconObserver } from '../IconObserver/IconObserver';
import { IconVoted } from '../IconVoted/IconVoted';
import { KickButton } from '../KickButton/KickButton';
import { UserState, getVotingState } from '../../helpers/getVotingState';
import { RemoveUserButton } from '../RemoveUserButton/RemoveUserButton';
import { connectToWebSocket } from '../WebSocket/WebSocket';
import classes from './VotingStateDisplay.module.css';

Expand Down Expand Up @@ -65,7 +65,7 @@ export const VotingStateDisplay = connectToWebSocket(({ socket }) => (
<tr class={sharedClasses.headerRow}>
<th>{COLUMN_NAME}</th>
<th>{COLUMN_VOTED}</th>
<th>{COLUMN_KICK}</th>
<th>{COLUMN_REMOVE}</th>
</tr>
</thead>
<tbody>
Expand All @@ -80,7 +80,7 @@ export const VotingStateDisplay = connectToWebSocket(({ socket }) => (
</td>
<td>{getIcon(userState)}</td>
<td>
<KickButton user={userState.user} />
<RemoveUserButton user={userState.user} />
</td>
</tr>
);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const LABEL_SESSION = 'Session:';

export const BUTTON_CONNECTING = 'Connecting…';
export const BUTTON_COPY_TO_CLIPBOARD = 'Copy Link to Clipboard';
export const BUTTON_KICK = (user: string) => `Kick ${user}`;
export const BUTTON_REMOVE_USER = (user: string) => `Remove ${user}`;
export const BUTTON_LOGIN = 'Login';
export const BUTTON_OBSERVER = 'Observer';
export const BUTTON_REFRESH_SESSION = 'Refresh Session';
Expand All @@ -31,7 +31,7 @@ export const TOOLTIP_PENDING_CONNECTION = 'Pending connection';
export const COLUMN_NAME = 'Name';
export const COLUMN_VOTE = 'Vote';
export const COLUMN_VOTED = 'Voted';
export const COLUMN_KICK = 'Kick';
export const COLUMN_REMOVE = 'Remove';

export const SWITCH_TO_DARK = 'Switch to dark color mode';
export const SWITCH_TO_LIGHT = 'Switch to light color mode';
Expand Down

0 comments on commit a57f034

Please sign in to comment.