mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-07-24 15:49:42 +02:00
* Added uri property to Page model * Added aliases collection * Added routing form aliases * Fixed redirect after page creation * Added abiltity to support few pages with same title * Added ability to change uri manually * Changed hash function * Changed uri parsing * Removed pages controller promise * Modified page's tests * Added tests for alias model * Added tests for aliases * Escaping special characters * Added missed files * Fixed bugs related to translation * Fixed parent page link * Added server validation for uri * Changed css properties order * Made uri property of page be optional * Prevented alias creation from empty uri * Moved alias types to model
58 lines
1.2 KiB
JavaScript
58 lines
1.2 KiB
JavaScript
const {app} = require('../../bin/www');
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const config = require('../../config');
|
|
const chai = require('chai');
|
|
const chaiHTTP = require('chai-http');
|
|
const {expect} = chai;
|
|
|
|
chai.use(chaiHTTP);
|
|
|
|
describe('Aliases REST: ', () => {
|
|
let agent;
|
|
|
|
before(async () => {
|
|
agent = chai.request.agent(app);
|
|
});
|
|
|
|
after(async () => {
|
|
const pathToDB = path.resolve(__dirname, '../../', config.database, './pages.db');
|
|
|
|
if (fs.existsSync(pathToDB)) {
|
|
fs.unlinkSync(pathToDB);
|
|
}
|
|
|
|
const pathToAliasDB = path.resolve(__dirname, '../../', config.database, './aliases.db');
|
|
|
|
if (fs.existsSync(pathToAliasDB)) {
|
|
fs.unlinkSync(pathToAliasDB);
|
|
}
|
|
});
|
|
|
|
it('Finding page with alias', async () => {
|
|
const body = {
|
|
blocks: [
|
|
{
|
|
type: 'header',
|
|
data: {
|
|
text: 'Test header'
|
|
}
|
|
}
|
|
]
|
|
};
|
|
|
|
const put = await agent
|
|
.put('/api/page')
|
|
.send({body});
|
|
|
|
expect(put).to.have.status(200);
|
|
expect(put).to.be.json;
|
|
|
|
const {result: {uri}} = put.body;
|
|
|
|
const get = await agent.get(`/${uri}`);
|
|
|
|
expect(get).to.have.status(200);
|
|
});
|
|
});
|