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 () => {
|
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.workspaceDropdownExists(app);
|
||||||
await debug.createNewRequest(app, 'csv');
|
await debug.createNewRequest(app, 'csv');
|
||||||
@ -77,9 +77,7 @@ describe('Application launch', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('sends PDF request and shows rich response', async () => {
|
it('sends PDF request and shows rich response', async () => {
|
||||||
// Cannot mock the pdf response using Prism because it is not yet supported
|
const url = 'http://127.0.0.1:4010/file/dummy.pdf';
|
||||||
// https://github.com/stoplightio/prism/issues/1248#issuecomment-646056440
|
|
||||||
const url = 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf';
|
|
||||||
|
|
||||||
await debug.workspaceDropdownExists(app);
|
await debug.workspaceDropdownExists(app);
|
||||||
await debug.createNewRequest(app, 'pdf');
|
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 basicAuthRouter = express.Router();
|
||||||
const port = 4010;
|
const port = 4010;
|
||||||
|
|
||||||
// Artificallly slow each request down
|
// Artificially slow each request down
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
setTimeout(next, 500);
|
setTimeout(next, 500);
|
||||||
});
|
});
|
||||||
@ -15,12 +15,7 @@ app.get('/pets/:id', (req, res) => {
|
|||||||
res.status(200).send({ id: req.params.id });
|
res.status(200).send({ id: req.params.id });
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/csv', (_, res) => {
|
app.use('/file', express.static('fixtures'));
|
||||||
res
|
|
||||||
.status(200)
|
|
||||||
.header('content-type', 'text/csv')
|
|
||||||
.send(`a,b,c\n1,2,3`);
|
|
||||||
});
|
|
||||||
|
|
||||||
const { utf8, latin1 } = basicAuthCreds;
|
const { utf8, latin1 } = basicAuthCreds;
|
||||||
|
|
||||||
@ -29,11 +24,7 @@ const users = {
|
|||||||
[latin1.encoded.user]: latin1.encoded.pass,
|
[latin1.encoded.user]: latin1.encoded.pass,
|
||||||
};
|
};
|
||||||
|
|
||||||
basicAuthRouter.use(
|
basicAuthRouter.use(basicAuth({ users }));
|
||||||
basicAuth({
|
|
||||||
users,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
basicAuthRouter.get('/', (_, res) => {
|
basicAuthRouter.get('/', (_, res) => {
|
||||||
res
|
res
|
||||||
|
Loading…
Reference in New Issue
Block a user