Skip to content

Commit

Permalink
Merge pull request #1433 from RobAndrewHurst/workspace_rework
Browse files Browse the repository at this point in the history
Test Workspace rework
  • Loading branch information
RobAndrewHurst authored Aug 27, 2024
2 parents 8f88e85 + 64763c0 commit 01032bc
Show file tree
Hide file tree
Showing 9 changed files with 222 additions and 299 deletions.
32 changes: 32 additions & 0 deletions tests/assets/layers/scratch/infoj.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"infoj": [
{
"title": "qID",
"field": "id",
"inline": true
},
{
"type": "key"
},
{
"type": "pin",
"label": "ST_PointOnSurface",
"field": "pin",
"fieldfx": "ARRAY[ST_X(ST_PointOnSurface(geom_3857)),ST_Y(ST_PointOnSurface(geom_3857))]"
},
{
"title": "textarea",
"field": "textarea",
"edit": true
},
{
"title": "char_field",
"field": "char_field"
},
{
"title": "minutes",
"field": "integer_field",
"inline": true
}
]
}
15 changes: 15 additions & 0 deletions tests/assets/layers/scratch/layer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"group": "layer",
"format": "wkt",
"dbs": "NEON",
"tables": {
"5": null,
"6": "test.scratch"
},
"table": "test.scratch",
"srid": "3857",
"geom": "geom_3857",
"qID": "id",
"toggleLocationViewEdits": true,
"deleteLocation": true
}
23 changes: 23 additions & 0 deletions tests/assets/layers/scratch/style.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"style": {
"default": {
"strokeColor": "#333",
"fillColor": "#fff9",
"icon": {
"type": "dot"
}
},
"highlight": {
"scale": 1.3,
"strokeColor": "#090"
}
},
"draw": {
"circle_2pt": true,
"circle": {
"hidePanel": true
},
"polygon": true,
"point": true
}
}
File renamed without changes.
18 changes: 18 additions & 0 deletions tests/assets/layers/uk_geometries/infoj.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"infoj": [
{
"title": "qID",
"field": "_id",
"inline": true
},
{
"type": "key"
},
{
"type": "pin",
"label": "ST_PointOnSurface",
"field": "pin",
"fieldfx": "ARRAY[ST_X(ST_PointOnSurface(geom_3857)),ST_Y(ST_PointOnSurface(geom_3857))]"
}
]
}
27 changes: 27 additions & 0 deletions tests/assets/layers/uk_geometries/layer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"display": true,
"group": "layer",
"format": "wkt",
"dbs": "NEON",
"table": "test.uk_geometries",
"srid": "3857",
"geom": "geom_3857",
"qID": "_id",
"toggleLocationViewEdits": true,
"cluster": {
"distance": 30
},
"hover": {
"field": "_id",
"display": "true"
},
"draw": {
"circle_2pt": true,
"circle": {
"hidePanel": true
},
"polygon": true,
"point": true
},
"deleteLocation": true
}
3 changes: 1 addition & 2 deletions tests/lib/layer/decorate.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import { setView } from '../../utils/view.js';
export async function decorateTest(mapview) {
await codi.describe('Layer: decorateTest', async () => {
const decorated_layer = mapview.layers['decorate'];
const workspace = await mapp.utils.xhr(`/test/tests/workspace.json`);
const workspace_layer = workspace.locale.layers['decorate'];
const workspace_layer = await mapp.utils.xhr(`/test/api/workspace/layer?layer=decorate`);
workspace_layer.mapview = mapview;
const layer = await mapp.layer.decorate(workspace_layer);

Expand Down
139 changes: 71 additions & 68 deletions tests/mod/user/update.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,74 +8,77 @@
* This function is used as an entry point for the changeEndTest
* @function updateTest
*/
export async function updateTest(mapview) {

await codi.describe('User: update', async () => {

/**
* ### update endpoint should be able to process a body
* The user update endpoint should be able to take a body as the request.
* @function it
*/
await codi.it('update endpoint should be able to process a body', async () => {

let params = {
url: '/test/api/user/update',
body: JSON.stringify(
{
email: '[email protected]',
admin: false,
approved: false,
verified: false
}
)
};

await mapp.utils.xhr(params);

params = {
url: '/test/api/user/update',
body: JSON.stringify(
{
email: '[email protected]',
admin: true,
approved: true,
verified: false
}
)
}

await mapp.utils.xhr(params);

const acl = await mapp.utils.xhr('/test/api/user/list');
const test_user = acl.filter(user => user.email === '[email protected]')[0];

await codi.assertEqual(test_user.email, '[email protected]', 'The users email address should be [email protected]')
await codi.assertFalse(test_user.verified, 'The user should be not verified')
await codi.assertTrue(test_user.admin, 'The user should an admin')
await codi.assertTrue(test_user.approved, 'The user should be approved')
export async function updateTest() {

if (mapp.user) {
await codi.describe('User: update', async () => {

console.log(mapp);
/**
* ### update endpoint should be able to process a body
* The user update endpoint should be able to take a body as the request.
* @function it
*/
await codi.it('update endpoint should be able to process a body', async () => {

let params = {
url: '/test/api/user/update',
body: JSON.stringify(
{
email: '[email protected]',
admin: false,
approved: false,
verified: false
}
)
};

await mapp.utils.xhr(params);

params = {
url: '/test/api/user/update',
body: JSON.stringify(
{
email: '[email protected]',
admin: true,
approved: true,
verified: false
}
)
}

await mapp.utils.xhr(params);

const acl = await mapp.utils.xhr('/test/api/user/list');
const test_user = acl.filter(user => user.email === '[email protected]')[0];

await codi.assertEqual(test_user.email, '[email protected]', 'The users email address should be [email protected]')
await codi.assertFalse(test_user.verified, 'The user should be not verified')
await codi.assertTrue(test_user.admin, 'The user should an admin')
await codi.assertTrue(test_user.approved, 'The user should be approved')

});

/**
### update endpoint should be able to be just params
* The user update endpoint should be able to take a body as the request.
* @function it
*/
await codi.it('update endpoint should be able to be just params', async () => {

const url = `/test/api/user/[email protected]&field=admin&value=false`
await mapp.utils.xhr(url);

const acl = await mapp.utils.xhr('/test/api/user/list');
const test_user = acl.filter(user => user.email === '[email protected]')[0];

await codi.assertEqual(test_user.email, '[email protected]', 'The users email address should be [email protected]')
await codi.assertFalse(test_user.verified, 'The user should be not verified')
await codi.assertFalse(test_user.admin, 'The user should an admin')
await codi.assertTrue(test_user.approved, 'The user should be approved')

});

});

/**
### update endpoint should be able to be just params
* The user update endpoint should be able to take a body as the request.
* @function it
*/
await codi.it('update endpoint should be able to be just params', async () => {

const url = `/test/api/user/[email protected]&field=admin&value=false`
await mapp.utils.xhr(url);

const acl = await mapp.utils.xhr('/test/api/user/list');
const test_user = acl.filter(user => user.email === '[email protected]')[0];

await codi.assertEqual(test_user.email, '[email protected]', 'The users email address should be [email protected]')
await codi.assertFalse(test_user.verified, 'The user should be not verified')
await codi.assertFalse(test_user.admin, 'The user should an admin')
await codi.assertTrue(test_user.approved, 'The user should be approved')

});

});
}
}
Loading

0 comments on commit 01032bc

Please sign in to comment.