Updates pages tests
This commit is contained in:
parent
0ab29c459b
commit
39b847c79e
1 changed files with 91 additions and 1 deletions
|
@ -60,11 +60,21 @@ describe("Public pages test", () => {
|
||||||
.get("/login")
|
.get("/login")
|
||||||
.expect(200, done);
|
.expect(200, done);
|
||||||
});
|
});
|
||||||
|
it("Responds to /forget", (done) => {
|
||||||
|
request(app)
|
||||||
|
.get("/forget")
|
||||||
|
.expect(200, done)
|
||||||
|
});
|
||||||
it("Responds to /register", (done) => {
|
it("Responds to /register", (done) => {
|
||||||
request(app)
|
request(app)
|
||||||
.get("/register")
|
.get("/register")
|
||||||
.expect(200, done);
|
.expect(200, done);
|
||||||
});
|
});
|
||||||
|
it("Responds to /check", (done) => {
|
||||||
|
request(app)
|
||||||
|
.get("/check")
|
||||||
|
.expect(400, done);
|
||||||
|
});
|
||||||
it("Responds to /logout", (done) => {
|
it("Responds to /logout", (done) => {
|
||||||
request(app)
|
request(app)
|
||||||
.get("/logout")
|
.get("/logout")
|
||||||
|
@ -95,6 +105,41 @@ describe("Public pages test", () => {
|
||||||
.get("/admin/orders")
|
.get("/admin/orders")
|
||||||
.expect(302, done);
|
.expect(302, done);
|
||||||
});
|
});
|
||||||
|
it("Response to /admin/orders/date", done => {
|
||||||
|
request(app)
|
||||||
|
.get("/admin/orders/date")
|
||||||
|
.expect(302, done);
|
||||||
|
});
|
||||||
|
it("Reponse to /admin/sandwiches", done => {
|
||||||
|
request(app)
|
||||||
|
.get("/admin/sandwiches")
|
||||||
|
.expect(302, done);
|
||||||
|
});
|
||||||
|
it("Reponse to /admin/sandwiches/add", done => {
|
||||||
|
request(app)
|
||||||
|
.get("/admin/sandwiches/add")
|
||||||
|
.expect(302, done);
|
||||||
|
});
|
||||||
|
it("Reponse to /admin/sandwiches/edit", done => {
|
||||||
|
request(app)
|
||||||
|
.get("/admin/sandwiches/edit")
|
||||||
|
.expect(302, done);
|
||||||
|
});
|
||||||
|
it("Reponse to /admin/departments", done => {
|
||||||
|
request(app)
|
||||||
|
.get("/admin/departments")
|
||||||
|
.expect(302, done);
|
||||||
|
});
|
||||||
|
it("Reponse to /admin/departments/add", done => {
|
||||||
|
request(app)
|
||||||
|
.get("/admin/departments/add")
|
||||||
|
.expect(302, done);
|
||||||
|
});
|
||||||
|
it("Reponse to /admin/departments/edit", done => {
|
||||||
|
request(app)
|
||||||
|
.get("/admin/departments/edit")
|
||||||
|
.expect(302, done);
|
||||||
|
});
|
||||||
it("404 everything else", (done) => {
|
it("404 everything else", (done) => {
|
||||||
request(app)
|
request(app)
|
||||||
.get("/foo/bar")
|
.get("/foo/bar")
|
||||||
|
@ -128,6 +173,11 @@ describe("Global logged user pages", () => {
|
||||||
.expect(302);
|
.expect(302);
|
||||||
expect(res.headers.location).to.be.equal("/login?err=true");
|
expect(res.headers.location).to.be.equal("/login?err=true");
|
||||||
});
|
});
|
||||||
|
it("Forget page", async () => {
|
||||||
|
await (await getLoginAgent(app))
|
||||||
|
.get("/forget")
|
||||||
|
.expect(302);
|
||||||
|
});
|
||||||
it("Register page", async () => {
|
it("Register page", async () => {
|
||||||
await (await getLoginAgent(app))
|
await (await getLoginAgent(app))
|
||||||
.get("/register")
|
.get("/register")
|
||||||
|
@ -151,7 +201,12 @@ describe("Global logged user pages", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
for (let [p, a] of Object.entries({0: [403, 403, 403, 403], 1: [200, 403, 403, 403], 2: [200, 200, 403, 403], 3: [200, 200, 200, 200]}))
|
for (let [p, a] of Object.entries({
|
||||||
|
0: [403, 403, 403, 403, 403, 403, 403, 403, 403, 403, 403],
|
||||||
|
1: [200, 403, 403, 403, 403, 403, 403, 403, 403, 403, 403],
|
||||||
|
2: [200, 200, 403, 403, 403, 403, 403, 403, 403, 403, 403],
|
||||||
|
3: [200, 200, 200, 200, 200, 200, 200, 400, 200, 200, 400]
|
||||||
|
}))
|
||||||
describe(`Permission ${p} pages`, () => {
|
describe(`Permission ${p} pages`, () => {
|
||||||
let app;
|
let app;
|
||||||
let models;
|
let models;
|
||||||
|
@ -184,4 +239,39 @@ for (let [p, a] of Object.entries({0: [403, 403, 403, 403], 1: [200, 403, 403, 4
|
||||||
.get("/admin/orders")
|
.get("/admin/orders")
|
||||||
.expect(a[3]);
|
.expect(a[3]);
|
||||||
});
|
});
|
||||||
|
it("Orders date administration page", async () => {
|
||||||
|
await (await getLoginAgent(app))
|
||||||
|
.get("/admin/orders/date")
|
||||||
|
.expect(a[4])
|
||||||
|
});
|
||||||
|
it("Sandwiches administration page", async () => {
|
||||||
|
await (await getLoginAgent(app))
|
||||||
|
.get("/admin/sandwiches")
|
||||||
|
.expect(a[5])
|
||||||
|
});
|
||||||
|
it("Sandwiches add administration page", async () => {
|
||||||
|
await (await getLoginAgent(app))
|
||||||
|
.get("/admin/sandwiches/add")
|
||||||
|
.expect(a[6])
|
||||||
|
});
|
||||||
|
it("Sandwiches edit administration page", async () => {
|
||||||
|
await (await getLoginAgent(app))
|
||||||
|
.get("/admin/sandwiches/edit?name=test")
|
||||||
|
.expect(a[7])
|
||||||
|
});
|
||||||
|
it("Departments administration page", async () => {
|
||||||
|
await (await getLoginAgent(app))
|
||||||
|
.get("/admin/departments")
|
||||||
|
.expect(a[8])
|
||||||
|
});
|
||||||
|
it("Departments add administration page", async () => {
|
||||||
|
await (await getLoginAgent(app))
|
||||||
|
.get("/admin/departments/add")
|
||||||
|
.expect(a[9])
|
||||||
|
});
|
||||||
|
it("Departments edit administration page", async () => {
|
||||||
|
await (await getLoginAgent(app))
|
||||||
|
.get("/admin/departments/edit?name=test")
|
||||||
|
.expect(a[10])
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Reference in a new issue