Merge branch 'master' of github.com:spotify/backstage into mob/techdocs-landing-page
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import * as winston from 'winston';
|
||||
|
||||
let rootLogger: winston.Logger = winston.createLogger({
|
||||
|
||||
@@ -34,6 +34,29 @@ describe('errorHandler', () => {
|
||||
expect(response.text).toBe('some message');
|
||||
});
|
||||
|
||||
it('doesnt try to send the response again if its already been sent', async () => {
|
||||
const app = express();
|
||||
const mockSend = jest.fn();
|
||||
|
||||
app.use('/works_with_async_fail', (_, res) => {
|
||||
res.status(200).send('hello');
|
||||
|
||||
// mutate the response object to test the middlware.
|
||||
// it's hard to catch errors inside middleware from the outside.
|
||||
// @ts-ignore
|
||||
res.send = mockSend;
|
||||
throw new Error('some message');
|
||||
});
|
||||
|
||||
app.use(errorHandler());
|
||||
const response = await request(app).get('/works_with_async_fail');
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.text).toBe('hello');
|
||||
|
||||
expect(mockSend).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('takes code from http-errors library errors', async () => {
|
||||
const app = express();
|
||||
app.use('/breaks', () => {
|
||||
|
||||
@@ -53,7 +53,10 @@ export function errorHandler(
|
||||
next: NextFunction,
|
||||
) => {
|
||||
if (response.headersSent) {
|
||||
// If the headers have already been sent, do not send the response again
|
||||
// as this will throw an error in the backend.
|
||||
next(error);
|
||||
return;
|
||||
}
|
||||
|
||||
const status = getStatusCode(error);
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
"classnames": "^2.2.6",
|
||||
"clsx": "^1.1.0",
|
||||
"lodash": "^4.17.15",
|
||||
"material-table": "^1.58.0",
|
||||
"material-table": "1.62.x",
|
||||
"prop-types": "^15.7.2",
|
||||
"rc-progress": "^3.0.0",
|
||||
"react": "^16.12.0",
|
||||
|
||||
+20
-2
@@ -24,12 +24,30 @@ export default {
|
||||
|
||||
const Wrapper: FC<{}> = ({ children }) => (
|
||||
<Grid container spacing={4}>
|
||||
<Grid item>{children}</Grid>
|
||||
<Grid item xs={6} sm={4} md={2}>
|
||||
{children}
|
||||
</Grid>
|
||||
</Grid>
|
||||
);
|
||||
|
||||
export const Default = () => (
|
||||
<Wrapper>
|
||||
<ItemCard description="Test" title="Item Card" label="Button" />
|
||||
<ItemCard
|
||||
title="Item Card"
|
||||
description="This is the description of an Item Card"
|
||||
label="Button"
|
||||
type="Pretitle"
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
|
||||
export const Tags = () => (
|
||||
<Wrapper>
|
||||
<ItemCard
|
||||
title="Item Card"
|
||||
description="This is a Item Card"
|
||||
tags={['one tag', 'two tag']}
|
||||
label="Button"
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
Reference in New Issue
Block a user