Skip to content

Commit

Permalink
Format the project with the new prettier rules
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Henneke <dominik.henneke@nordeck.net>
  • Loading branch information
dhenneke committed Aug 1, 2023
1 parent 6938a8f commit 9235f04
Show file tree
Hide file tree
Showing 152 changed files with 1,004 additions and 1,006 deletions.
7 changes: 0 additions & 7 deletions .prettierrc

This file was deleted.

5 changes: 5 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Use single quotes instead of double quotes.
# (this will not affect JSX)
singleQuote: true

plugins: ['prettier-plugin-organize-imports']
2 changes: 1 addition & 1 deletion containers/widget-server/e2e/container.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test.describe('widget-server', () => {

test('should show environment', async ({ page }) => {
await expect(page.locator('#environment')).toHaveText(
'{"REACT_APP_EXAMPLE":"example"}'
'{"REACT_APP_EXAMPLE":"example"}',
);
});

Expand Down
2 changes: 1 addition & 1 deletion containers/widget-server/e2e/fixtures/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<title>Welcome to the widget toolkit!</title>
Expand Down
2 changes: 1 addition & 1 deletion containers/widget-server/e2e/fixtures/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
const el = document.getElementById('environment');
try {
el.innerText = JSON.stringify(
JSON.parse(window.atob(window.__ENVIRONMENT__))
JSON.parse(window.atob(window.__ENVIRONMENT__)),
);
} catch {
el.innerText = 'Could not find the environment :-(';
Expand Down
2 changes: 1 addition & 1 deletion example-widget-mui/craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function importLocalPackages() {
function overrideWebpackConfig({ webpackConfig, context }) {
const { isFound, match } = getLoader(
webpackConfig,
loaderByName('babel-loader')
loaderByName('babel-loader'),
);
if (isFound) {
const include = Array.isArray(match.loader.include)
Expand Down
2 changes: 1 addition & 1 deletion example-widget-mui/public/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
36 changes: 18 additions & 18 deletions example-widget-mui/src/AllRoomsPage/AllRoomsPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,23 @@ describe('<AllRoomsPage />', () => {
render(<AllRoomsPage />, { wrapper });

expect(
screen.getByRole('link', { name: /back to navigation/i })
screen.getByRole('link', { name: /back to navigation/i }),
).toBeInTheDocument();

await expect(
screen.findByRole('heading', { name: /all rooms/i })
screen.findByRole('heading', { name: /all rooms/i }),
).resolves.toBeInTheDocument();
expect(screen.getByText(/you have no rooms/i)).toBeInTheDocument();
expect(
screen.getByRole('button', { name: /refresh the room information/i })
screen.getByRole('button', { name: /refresh the room information/i }),
).toBeInTheDocument();
});

it('should have no accessibility violations', async () => {
const { container } = render(<AllRoomsPage />, { wrapper });

await expect(
screen.findByRole('heading', { name: /all rooms/i })
screen.findByRole('heading', { name: /all rooms/i }),
).resolves.toBeInTheDocument();
expect(await axe(container)).toHaveNoViolations();
});
Expand All @@ -92,7 +92,7 @@ describe('<AllRoomsPage />', () => {
'org.matrix.msc2762.timeline:*',
WidgetEventCapability.forStateEvent(
EventDirection.Receive,
'm.room.name'
'm.room.name',
),
'org.matrix.msc2931.navigate',
]);
Expand All @@ -104,31 +104,31 @@ describe('<AllRoomsPage />', () => {
render(<AllRoomsPage />, { wrapper });

await expect(
screen.findByText(/you have no rooms./i)
screen.findByText(/you have no rooms./i),
).resolves.toBeInTheDocument();
});

it('should render a list of rooms', async () => {
widgetApi.mockSendStateEvent(
mockRoomNameEvent({ room_id: '!room-id-1', content: { name: 'Room 1' } })
mockRoomNameEvent({ room_id: '!room-id-1', content: { name: 'Room 1' } }),
);
widgetApi.mockSendStateEvent(
mockRoomNameEvent({ room_id: '!room-id-2', content: { name: 'Room 2' } })
mockRoomNameEvent({ room_id: '!room-id-2', content: { name: 'Room 2' } }),
);
widgetApi.mockSendStateEvent(
mockRoomNameEvent({ room_id: '!room-id-3', content: { name: 'Room 3' } })
mockRoomNameEvent({ room_id: '!room-id-3', content: { name: 'Room 3' } }),
);
widgetApi.mockSendStateEvent(
mockRoomNameEvent({ room_id: '!room-id-4', content: { name: 'Room 4' } })
mockRoomNameEvent({ room_id: '!room-id-4', content: { name: 'Room 4' } }),
);
widgetApi.mockSendStateEvent(
mockRoomNameEvent({ room_id: '!room-id-5', content: { name: 'Room 5' } })
mockRoomNameEvent({ room_id: '!room-id-5', content: { name: 'Room 5' } }),
);

render(<AllRoomsPage />, { wrapper });

await expect(
screen.findByText(/all your rooms:/i)
screen.findByText(/all your rooms:/i),
).resolves.toBeInTheDocument();
expect(screen.getByRole('button', { name: /room 1/i })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /room 2/i })).toBeInTheDocument();
Expand All @@ -140,26 +140,26 @@ describe('<AllRoomsPage />', () => {
render(<AllRoomsPage />, { wrapper });

await expect(
screen.findByText(/you have no rooms/i)
screen.findByText(/you have no rooms/i),
).resolves.toBeInTheDocument();

widgetApi.mockSendStateEvent(
mockRoomNameEvent({ room_id: '!room-id-1', content: { name: 'Room 1' } })
mockRoomNameEvent({ room_id: '!room-id-1', content: { name: 'Room 1' } }),
);

await userEvent.click(
screen.getByRole('button', { name: /refresh the room information/i })
screen.getByRole('button', { name: /refresh the room information/i }),
);

await expect(
screen.findByText(/all your rooms:/i)
screen.findByText(/all your rooms:/i),
).resolves.toBeInTheDocument();
expect(screen.getByRole('button', { name: /room 1/i })).toBeInTheDocument();
});

it('should navigate to the room', async () => {
widgetApi.mockSendStateEvent(
mockRoomNameEvent({ room_id: '!room-id-1', content: { name: 'Room 1' } })
mockRoomNameEvent({ room_id: '!room-id-1', content: { name: 'Room 1' } }),
);

render(<AllRoomsPage />, { wrapper });
Expand All @@ -168,7 +168,7 @@ describe('<AllRoomsPage />', () => {
await userEvent.click(button);

expect(widgetApi.navigateTo).toBeCalledWith(
'https://matrix.to/#/!room-id-1'
'https://matrix.to/#/!room-id-1',
);
});
});
2 changes: 1 addition & 1 deletion example-widget-mui/src/AllRoomsPage/AllRoomsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const AllRoomsPage = (): ReactElement => {
...generateRoomTimelineCapabilities(Symbols.AnyRoom),
WidgetEventCapability.forStateEvent(
EventDirection.Receive,
STATE_EVENT_ROOM_NAME
STATE_EVENT_ROOM_NAME,
),
WIDGET_CAPABILITY_NAVIGATE,
]}
Expand Down
2 changes: 1 addition & 1 deletion example-widget-mui/src/App/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ it('should render error message', async () => {
render(<App widgetApiPromise={widgetApiPromise} />);

await expect(
screen.findByText(/only runs as a widget/i)
screen.findByText(/only runs as a widget/i),
).resolves.toBeInTheDocument();
});
18 changes: 9 additions & 9 deletions example-widget-mui/src/DicePage/DicePage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,25 @@ describe('<DicePage />', () => {
render(<DicePage />, { wrapper });

expect(
screen.getByRole('link', { name: /back to navigation/i })
screen.getByRole('link', { name: /back to navigation/i }),
).toBeInTheDocument();

await expect(
screen.findByRole('heading', { name: /dice/i })
screen.findByRole('heading', { name: /dice/i }),
).resolves.toBeInTheDocument();
expect(
screen.getByText(/nobody has thrown the dice in this room yet/i)
screen.getByText(/nobody has thrown the dice in this room yet/i),
).toBeInTheDocument();
expect(
screen.getByRole('button', { name: /throw dice/i })
screen.getByRole('button', { name: /throw dice/i }),
).toBeInTheDocument();
});

it('should have no accessibility violations', async () => {
const { container } = render(<DicePage />, { wrapper });

await expect(
screen.findByRole('heading', { name: /dice/i })
screen.findByRole('heading', { name: /dice/i }),
).resolves.toBeInTheDocument();
expect(await axe(container)).toHaveNoViolations();
});
Expand All @@ -73,7 +73,7 @@ describe('<DicePage />', () => {
expect(widgetApi.requestCapabilities).toBeCalledWith([
WidgetEventCapability.forRoomEvent(
EventDirection.Receive,
'net.nordeck.throw_dice'
'net.nordeck.throw_dice',
),
]);

Expand All @@ -83,7 +83,7 @@ describe('<DicePage />', () => {
expect(widgetApi.requestCapabilities).toBeCalledWith([
WidgetEventCapability.forRoomEvent(
EventDirection.Send,
'net.nordeck.throw_dice'
'net.nordeck.throw_dice',
),
]);
});
Expand All @@ -92,7 +92,7 @@ describe('<DicePage />', () => {
render(<DicePage />, { wrapper });

await expect(
screen.findByText(/nobody has thrown the dice in this room yet/i)
screen.findByText(/nobody has thrown the dice in this room yet/i),
).resolves.toBeInTheDocument();
});

Expand Down Expand Up @@ -126,7 +126,7 @@ describe('<DicePage />', () => {
await userEvent.click(button);

await expect(
screen.findByText(/your last throw: ./i)
screen.findByText(/your last throw: ./i),
).resolves.toBeInTheDocument();

expect(widgetApi.sendRoomEvent).toBeCalledWith('net.nordeck.throw_dice', {
Expand Down
8 changes: 4 additions & 4 deletions example-widget-mui/src/DicePage/DicePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const DicePage = (): ReactElement => {
capabilities={[
WidgetEventCapability.forRoomEvent(
EventDirection.Receive,
STATE_EVENT_THROW_DICE
STATE_EVENT_THROW_DICE,
),
]}
>
Expand All @@ -70,7 +70,7 @@ export const DiceView = (): ReactElement => {
.observeRoomEvents(STATE_EVENT_THROW_DICE)
.pipe(
filter(isValidThrowDiceEvent),
map((r) => r.content.pips)
map((r) => r.content.pips),
)
.subscribe((d) => {
setDices((l) => [...l, d]);
Expand All @@ -85,14 +85,14 @@ export const DiceView = (): ReactElement => {
await widgetApi.requestCapabilities([
WidgetEventCapability.forRoomEvent(
EventDirection.Send,
STATE_EVENT_THROW_DICE
STATE_EVENT_THROW_DICE,
),
]);

const pips = Math.floor(Math.random() * 6) + 1;
const result = await widgetApi.sendRoomEvent<ThrowDiceEvent>(
STATE_EVENT_THROW_DICE,
{ pips }
{ pips },
);
setLastOwnDice(result.content.pips);
}
Expand Down
30 changes: 15 additions & 15 deletions example-widget-mui/src/IdentityPage/IdentityPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ describe('<IdentityPage />', () => {
render(<IdentityPage />, { wrapper });

expect(
screen.getByRole('link', { name: /back to navigation/i })
screen.getByRole('link', { name: /back to navigation/i }),
).toBeInTheDocument();

await expect(
screen.findByRole('heading', { name: /Identity/i })
screen.findByRole('heading', { name: /Identity/i }),
).resolves.toBeInTheDocument();
expect(screen.getByText('Error')).toBeInTheDocument();
expect(screen.getByText(/error: .+/i)).toBeInTheDocument();
Expand All @@ -63,7 +63,7 @@ describe('<IdentityPage />', () => {
const { container } = render(<IdentityPage />, { wrapper });

await expect(
screen.findByRole('heading', { name: /Identity/i })
screen.findByRole('heading', { name: /Identity/i }),
).resolves.toBeInTheDocument();
expect(await axe(container)).toHaveNoViolations();
});
Expand All @@ -85,29 +85,29 @@ describe('<IdentityPage />', () => {
}

return res(ctx.json({ sub: '@alice:example.com' }));
}
)
},
),
);

render(<IdentityPage />, { wrapper });

await expect(
screen.findByText(/identity verified/i)
screen.findByText(/identity verified/i),
).resolves.toBeInTheDocument();
expect(
screen.getByText(`{ "sub": "@alice:example.com" }`)
screen.getByText(`{ "sub": "@alice:example.com" }`),
).toBeInTheDocument();
});

it('should show an error if the user rejected the token capability', async () => {
widgetApi.requestOpenIDConnectToken.mockRejectedValue(
new Error('The user rejected the request')
new Error('The user rejected the request'),
);

render(<IdentityPage />, { wrapper });

await expect(
screen.findByText(/error: the user rejected the request/i)
screen.findByText(/error: the user rejected the request/i),
).resolves.toBeInTheDocument();
});

Expand All @@ -117,7 +117,7 @@ describe('<IdentityPage />', () => {
render(<IdentityPage />, { wrapper });

await expect(
screen.findByText(/error: unknown home server/i)
screen.findByText(/error: unknown home server/i),
).resolves.toBeInTheDocument();
});

Expand All @@ -129,7 +129,7 @@ describe('<IdentityPage />', () => {
render(<IdentityPage />, { wrapper });

await expect(
screen.findByText(/error: unknown token type/i)
screen.findByText(/error: unknown token type/i),
).resolves.toBeInTheDocument();
});

Expand All @@ -146,16 +146,16 @@ describe('<IdentityPage />', () => {
'https://synapse.local/_matrix/federation/v1/openid/userinfo',
(req, res, ctx) => {
return res(ctx.status(500), ctx.json('Internal Server Error'));
}
)
},
),
);

render(<IdentityPage />, { wrapper });

await expect(
screen.findByText(
/error: error while retrieving identity: "Internal Server Error"/i
)
/error: error while retrieving identity: "Internal Server Error"/i,
),
).resolves.toBeInTheDocument();
});
});
4 changes: 2 additions & 2 deletions example-widget-mui/src/IdentityPage/IdentityPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export const IdentityView = (): ReactElement => {
`Error while retrieving identity: ${JSON.stringify(
value,
undefined,
' '
)}`
' ',
)}`,
);
}

Expand Down
Loading

0 comments on commit 9235f04

Please sign in to comment.