Skip to content

Commit

Permalink
Rename "kick" to "remove"
Browse files Browse the repository at this point in the history
Signed-off-by: Thilo Aschebrock <[email protected]>
  • Loading branch information
ThiloAschebrock committed Sep 15, 2023
1 parent 694effd commit 62cc29c
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 23 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 @@ -28,7 +28,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 out by ${userId}.` } },
{ type: 'not-logged-in', payload: { reason: `You have been removed by ${userId}.` } },
{ ...config, connectionId: userConnectionId }
),
]);
Expand Down
6 changes: 3 additions & 3 deletions e2e/kicking.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' }]);

const secondLoginPage = await assertOnLoginPage(secondPage);
await secondLoginPage.assertKickedBy('User 1');
await secondLoginPage.assertRemovedBy('User 1');
});
4 changes: 2 additions & 2 deletions e2e/pages/card-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export class CardPage {
await expect(this.votes).toHaveCount(states.length);
}

async kickUser(name: string) {
await this.votes.getByTitle(`Kick ${name} out`).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 out by ${name}.`);
async assertRemovedBy(name: string) {
await expect(this.alertText).toHaveText(`You have been removed by ${name}.`);
}

async assertSessionTakeover() {
Expand Down
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 @@ -106,7 +106,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', () => {
it('logs the user in and displays the voting page, then displays the login page if the user is removed', () => {
// given
const logoutReason = 'You were removed!';
const { socket, container, getByText } = loginUser();
Expand All @@ -131,15 +131,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', () => {
it('updates, reveals and resets votes and removes users optimistically once the first state message arrived', () => {
// given
const { socket, container, getByRole, getAllByTitle } = 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 @@ -164,7 +164,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 @@ -191,7 +191,7 @@ describe('The App component', () => {
socket.test_messages = [];

// when
fireEvent.click(getByRole('button', { name: 'Kick Non-voting User out' }));
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,11 +1,11 @@
import { VOTE_NOTE_VOTED, VOTE_OBSERVER } from '../../../../shared/cards';
import { Votes } from '../../../../shared/serverMessages';
import { COLUMN_KICK, COLUMN_NAME, COLUMN_VOTED } from '../../constants';
import { COLUMN_REMOVE, COLUMN_NAME, COLUMN_VOTED } from '../../constants';
import sharedClasses from '../../styles.module.css';
import { IconNotVoted } from '../IconNotVoted/IconNotVoted';
import { IconObserver } from '../IconObserver/IconObserver';
import { IconVoted } from '../IconVoted/IconVoted';
import { KickButton } from '../KickButton/KickButton';
import { RemoveUserButton } from '../RemoveUserButton/RemoveUserButton';
import { connectToWebSocket } from '../WebSocket/WebSocket';
import classes from './VotingStateDisplay.module.css';

Expand Down Expand Up @@ -62,7 +62,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 @@ -72,7 +72,7 @@ export const VotingStateDisplay = connectToWebSocket(({ socket }) => (
<td>{user}</td>
<td>{getIcon(voted, observer)}</td>
<td>
<KickButton user={user} />
<RemoveUserButton user={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} out`;
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 @@ -30,7 +30,7 @@ export const TOOLTIP_VOTED = 'Voted';
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 62cc29c

Please sign in to comment.