Skip to content

Commit

Permalink
Remove query params
Browse files Browse the repository at this point in the history
  • Loading branch information
avatus committed Jul 22, 2024
1 parent 7b03311 commit 3a7dfa6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
4 changes: 1 addition & 3 deletions web/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ import { Preview } from '@storybook/react';
import { Theme } from '../packages/design/src/theme/themes/types';
import { initialize, mswLoader } from 'msw-storybook-addon';

initialize({
onUnhandledRequest: 'bypass',
});
initialize();

history.init();

Expand Down
22 changes: 22 additions & 0 deletions web/packages/build/storybook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Teleport
* Copyright (C) 2023 Gravitational, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

// withoutQuery can be used to strip the query parameters from a url
export function withoutQuery(url: string): string {
return url.split('?')[0];
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import React from 'react';
import { MemoryRouter } from 'react-router';
import { http, HttpResponse } from 'msw';
import { withoutQuery } from 'web/packages/build/storybook';

import {
OverrideUserAgent,
Expand All @@ -44,13 +45,11 @@ const setupConnectProps = {
showHintTimeout: oneDay,
};

const nodesPathWithoutQuery = cfg.api.nodesPath.split('?')[0];

export default {
title: 'Teleport/Discover/ConnectMyComputer/SetupConnect',
};

const noNodesHandler = http.get(cfg.api.nodesPath, () =>
const noNodesHandler = http.get(withoutQuery(cfg.api.nodesPath), () =>
HttpResponse.json({ items: [] })
);

Expand Down Expand Up @@ -108,13 +107,13 @@ PollingSuccess.parameters = {
msw: {
handlers: [
http.get(
nodesPathWithoutQuery,
withoutQuery(cfg.api.nodesPath),
() => {
return HttpResponse.json({ items: [] });
},
{ once: true }
),
http.get(nodesPathWithoutQuery, () => {
http.get(withoutQuery(cfg.api.nodesPath), () => {
return HttpResponse.json({ items: [{ id: '1234', hostname: 'foo' }] });
}),
],
Expand Down

0 comments on commit 3a7dfa6

Please sign in to comment.