mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +00:00
Serve csv and pdf files locally (#2946)
Co-authored-by: David Marby <david@dmarby.se>
This commit is contained in:
parent
357b8f05f8
commit
adb79a720d
@ -64,7 +64,7 @@ describe('Application launch', function() {
|
||||
);
|
||||
|
||||
it('sends CSV request and shows rich response', async () => {
|
||||
const url = 'http://127.0.0.1:4010/csv';
|
||||
const url = 'http://127.0.0.1:4010/file/dummy.csv';
|
||||
|
||||
await debug.workspaceDropdownExists(app);
|
||||
await debug.createNewRequest(app, 'csv');
|
||||
@ -77,9 +77,7 @@ describe('Application launch', function() {
|
||||
});
|
||||
|
||||
it('sends PDF request and shows rich response', async () => {
|
||||
// Cannot mock the pdf response using Prism because it is not yet supported
|
||||
// https://github.com/stoplightio/prism/issues/1248#issuecomment-646056440
|
||||
const url = 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf';
|
||||
const url = 'http://127.0.0.1:4010/file/dummy.pdf';
|
||||
|
||||
await debug.workspaceDropdownExists(app);
|
||||
await debug.createNewRequest(app, 'pdf');
|
||||
|
2
packages/insomnia-smoke-test/fixtures/dummy.csv
Normal file
2
packages/insomnia-smoke-test/fixtures/dummy.csv
Normal file
@ -0,0 +1,2 @@
|
||||
a,b,c
|
||||
1,2,3
|
|
BIN
packages/insomnia-smoke-test/fixtures/dummy.pdf
Normal file
BIN
packages/insomnia-smoke-test/fixtures/dummy.pdf
Normal file
Binary file not shown.
@ -6,7 +6,7 @@ const app = express();
|
||||
const basicAuthRouter = express.Router();
|
||||
const port = 4010;
|
||||
|
||||
// Artificallly slow each request down
|
||||
// Artificially slow each request down
|
||||
app.use((req, res, next) => {
|
||||
setTimeout(next, 500);
|
||||
});
|
||||
@ -15,12 +15,7 @@ app.get('/pets/:id', (req, res) => {
|
||||
res.status(200).send({ id: req.params.id });
|
||||
});
|
||||
|
||||
app.get('/csv', (_, res) => {
|
||||
res
|
||||
.status(200)
|
||||
.header('content-type', 'text/csv')
|
||||
.send(`a,b,c\n1,2,3`);
|
||||
});
|
||||
app.use('/file', express.static('fixtures'));
|
||||
|
||||
const { utf8, latin1 } = basicAuthCreds;
|
||||
|
||||
@ -29,11 +24,7 @@ const users = {
|
||||
[latin1.encoded.user]: latin1.encoded.pass,
|
||||
};
|
||||
|
||||
basicAuthRouter.use(
|
||||
basicAuth({
|
||||
users,
|
||||
}),
|
||||
);
|
||||
basicAuthRouter.use(basicAuth({ users }));
|
||||
|
||||
basicAuthRouter.get('/', (_, res) => {
|
||||
res
|
||||
|
Loading…
Reference in New Issue
Block a user