Skip to content

Commit

Permalink
Add doctoral spec & refactor tests dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Veikkosuhonen committed Jan 22, 2024
1 parent 4207fb5 commit 4ea8f31
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tests/basic.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test, beforeAll } from 'vitest'
import { api } from './utils'
import { seed } from './seed'
import { api } from './util/utils'
import { seed } from './util/seed'
import { mapToDegreeCode } from '../src/auth/common'

beforeAll(async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/dekaani.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { api } from "./utils";
import { api } from "./util/utils";

describe.concurrent('Dekaani', () => {
it('gets READ access to faculty and each programme of faculty', async () => {
Expand Down
54 changes: 54 additions & 0 deletions tests/doctoral.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { describe, expect, it } from "vitest";
import { api } from "./util/utils";

describe.concurrent('Doctoral schools', () => {
it('Doctoral iam gives access to all doctoral schools & gives "doctoral" special group', async () => {
[
'hy-tohtorikoulutus-johtoryhma', 'hy-tine'
].forEach(async (iam) => {
const res = await api.post('', {
userId: 'doctoralschools-user',
iamGroups: [iam],
})

expect(res.status).toBe(200)
const json = await res.json()

const numberOfDoctoralSchools = 33 // Go to data.ts and CTR+F "level: 'doctoral'"
expect(Object.keys(json).length).toBe(numberOfDoctoralSchools + 1) // +1 because 'specialGroup' field.
expect(json).toHaveProperty('specialGroup')
expect(json.specialGroup).toHaveProperty('doctoral')
expect(json.specialGroup.doctoral).toBe(true)
})
})

it('Specific doctoral school iam gives access to the corresponding doctoral programmes', async () => {
const res = await api.post('', {
userId: 'doctoralschools-user',
iamGroups: ['hy-tutkijakoulut-hymy-jory'],
})

expect(res.status).toBe(200)
const json = await res.json()

;[
'T920101',
'T920102',
'T920103',
'T920104',
'T920105',
'T920106',
'T920107',
'T920108',
'T920109',
'T920110',
'T920111',
].forEach((programme) => {
expect(json).toHaveProperty(programme)
expect(json[programme].read).toBe(true)
expect(json[programme].write).toBeFalsy()
expect(json[programme].admin).toBeFalsy()
})
})

});
2 changes: 1 addition & 1 deletion tests/jory.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { api } from "./utils";
import { api } from "./util/utils";
import { mapToDegreeCode } from "../src/auth/common";

const degreeCode = mapToDegreeCode('200-K001')
Expand Down
2 changes: 1 addition & 1 deletion tests/kosu.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { api } from "./utils";
import { api } from "./util/utils";

describe.concurrent('Kosu', () => {
it('gets READ access to each faculty and programme of location', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/lomake.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { api } from "./utils";
import { api } from "./util/utils";

describe.concurrent('Lomake', () => {
it('Katselmus iam gives the katselmus special group', async () => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 4ea8f31

Please sign in to comment.