Skip to content

Commit

Permalink
updating wordpress gui
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardTMiles committed Mar 18, 2024
1 parent fc93a63 commit d7f463f
Show file tree
Hide file tree
Showing 251 changed files with 59,324 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/CarbonORM.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ export default class CarbonORM extends CarbonReact<{ browserRouter?: boolean },
}

return reactRouterContext(<>
<CarbonWebSocket url={'ws://localhost:8888/ws'}/>
<CarbonWebSocket
url={'ws' + (window.location.protocol === 'https:' ? 's' : '') + '://' + window.location.host + '/carbonorm/websocket'}/>
<Routes>
<Route path={UI + "*"}>
<Route path={MATERIAL_DASHBOARD + "*"} element={ppr(Dashboard, {})}>
Expand Down
73 changes: 73 additions & 0 deletions src/api/rest/C6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const RestTablePrefix = 'carbon_';

export type RestTableNames = 'carbon_carbons'
| 'carbon_comments'
| 'carbon_documentation'
| 'carbon_feature_group_references'
| 'carbon_features'
| 'carbon_group_references'
Expand Down Expand Up @@ -39,6 +40,7 @@ export type RestTableNames = 'carbon_carbons'

export type RestShortTableNames = 'carbons'
| 'comments'
| 'documentation'
| 'feature_group_references'
| 'features'
| 'group_references'
Expand Down Expand Up @@ -326,6 +328,72 @@ export const comments: iC6RestfulModel<RestTableNames> & iDefineComments = {
}
}

export interface iDocumentation {
'documentation_uri'?: string;
'documentation_data'?: string | null;
'documentation_version'?: string;
'documentation_active'?: number;
}

interface iDefineDocumentation {
'DOCUMENTATION_URI': string;
'DOCUMENTATION_DATA': string;
'DOCUMENTATION_VERSION': string;
'DOCUMENTATION_ACTIVE': string;
}

export const documentation: iC6RestfulModel<RestTableNames> & iDefineDocumentation = {
TABLE_NAME: 'carbon_documentation',
DOCUMENTATION_URI: 'carbon_documentation.documentation_uri',
DOCUMENTATION_DATA: 'carbon_documentation.documentation_data',
DOCUMENTATION_VERSION: 'carbon_documentation.documentation_version',
DOCUMENTATION_ACTIVE: 'carbon_documentation.documentation_active',
PRIMARY: [
],
PRIMARY_SHORT: [
],
COLUMNS: {
'carbon_documentation.documentation_uri': 'documentation_uri',
'carbon_documentation.documentation_data': 'documentation_data',
'carbon_documentation.documentation_version': 'documentation_version',
'carbon_documentation.documentation_active': 'documentation_active',
},
TYPE_VALIDATION: {
'carbon_documentation.documentation_uri': {
MYSQL_TYPE: 'varchar',
MAX_LENGTH: '255',
AUTO_INCREMENT: false,
SKIP_COLUMN_IN_POST: false
},
'carbon_documentation.documentation_data': {
MYSQL_TYPE: 'longblob',
MAX_LENGTH: '',
AUTO_INCREMENT: false,
SKIP_COLUMN_IN_POST: true
},
'carbon_documentation.documentation_version': {
MYSQL_TYPE: 'varchar',
MAX_LENGTH: '40',
AUTO_INCREMENT: false,
SKIP_COLUMN_IN_POST: false
},
'carbon_documentation.documentation_active': {
MYSQL_TYPE: 'tinyint',
MAX_LENGTH: '',
AUTO_INCREMENT: false,
SKIP_COLUMN_IN_POST: false
},
},
REGEX_VALIDATION: {
},
TABLE_REFERENCES: {

},
TABLE_REFERENCED_BY: {

}
}

export interface iFeature_Group_References {
'feature_entity_id'?: string | null;
'group_entity_id'?: string | null;
Expand Down Expand Up @@ -3038,6 +3106,7 @@ export const wp_users: iC6RestfulModel<RestTableNames> & iDefineWp_Users = {
export const TABLES: tC6Tables = {
carbons: carbons,
comments: comments,
documentation: documentation,
feature_group_references: feature_group_references,
features: features,
group_references: group_references,
Expand Down Expand Up @@ -3077,6 +3146,7 @@ export const C6 : iC6Object = {
export const COLUMNS = {
'carbon_carbons.entity_pk': 'entity_pk','carbon_carbons.entity_fk': 'entity_fk','carbon_carbons.entity_tag': 'entity_tag',
'carbon_comments.parent_id': 'parent_id','carbon_comments.comment_id': 'comment_id','carbon_comments.user_id': 'user_id','carbon_comments.comment': 'comment',
'carbon_documentation.documentation_uri': 'documentation_uri','carbon_documentation.documentation_data': 'documentation_data','carbon_documentation.documentation_version': 'documentation_version','carbon_documentation.documentation_active': 'documentation_active',
'carbon_feature_group_references.feature_entity_id': 'feature_entity_id','carbon_feature_group_references.group_entity_id': 'group_entity_id',
'carbon_features.feature_entity_id': 'feature_entity_id','carbon_features.feature_code': 'feature_code','carbon_features.feature_creation_date': 'feature_creation_date',
'carbon_group_references.group_id': 'group_id','carbon_group_references.allowed_to_grant_group_id': 'allowed_to_grant_group_id',
Expand Down Expand Up @@ -3110,6 +3180,7 @@ export const COLUMNS = {

export type RestTableInterfaces = iCarbons
| iComments
| iDocumentation
| iFeature_Group_References
| iFeatures
| iGroup_References
Expand Down Expand Up @@ -3145,6 +3216,7 @@ export type tStatefulApiData<T> = T[] | undefined | null;
export interface iRestfulObjectArrayTypes {
carbons: tStatefulApiData<iCarbons>,
comments: tStatefulApiData<iComments>,
documentation: tStatefulApiData<iDocumentation>,
feature_group_references: tStatefulApiData<iFeature_Group_References>,
features: tStatefulApiData<iFeatures>,
group_references: tStatefulApiData<iGroup_References>,
Expand Down Expand Up @@ -3177,6 +3249,7 @@ export interface iRestfulObjectArrayTypes {
export const initialRestfulObjectsState: iRestfulObjectArrayTypes = {
carbons: undefined,
comments: undefined,
documentation: undefined,
feature_group_references: undefined,
features: undefined,
group_references: undefined,
Expand Down
130 changes: 130 additions & 0 deletions src/api/rest/Documentation.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import {xdescribe, expect, test} from '@jest/globals';
import {CarbonReact} from "@carbonorm/carbonreact";
import {checkAllRequestsComplete} from "@carbonorm/carbonnode";
import {act, waitFor} from '@testing-library/react';
import {C6, iRestfulObjectArrayTypes, iDocumentation, documentation } from "api/rest/C6";
import Documentation from "./Documentation";

const randomString = Math.random().toString(36).substring(7);
const randomInt = Math.floor(Math.random() * 1000000);
const fillString = 'string' + randomString + randomInt;

console.log('fillString', fillString);

/**
CREATE TABLE `carbon_documentation` (
`documentation_uri` varchar(255) NOT NULL,
`documentation_data` longblob,
`documentation_version` varchar(40) NOT NULL,
`documentation_active` tinyint NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
**/

const Test_Data: iDocumentation = {

documentation_data: fillString.substring(0, ),

}

export default Test_Data;

xdescribe('REST Documentation api', () => {

let testData = Test_Data;

test('GET POST PUT DELETE', async () => {

await act(async () => {

let selectAllResponse = await Documentation.Get({})

if ('function' === typeof selectAllResponse) {
throw Error('selectAllResponse is a promise, this typically means this specific get request has already run during test setup.');
}

// We don't care if it is filled or not, just that the request can be made.
expect(selectAllResponse?.data?.rest).not.toBeUndefined();

const postResponse = await Documentation.Post(testData);

console.log('postResponse', postResponse?.data)

expect(postResponse?.data?.created).not.toBeUndefined();

const primaryKey = documentation.PRIMARY_SHORT[0];

const postID = postResponse?.data?.created

const singleRowSelect = await Documentation.Get({
[C6.WHERE]: {
[documentation[primaryKey.toUpperCase()]]: postID,
}
})

if ('function' === typeof singleRowSelect) {
throw Error('singleRowSelect is a promise, this is unexpected.');
}

console.log('singleRowSelect', singleRowSelect?.data)

// Ensure the expected response datastructure is returned
expect(singleRowSelect?.data?.rest).not.toBeUndefined();

// Make sure the previously created post is now returned
expect(typeof singleRowSelect?.data?.rest).toEqual('object');

// todo - make this work correctly with multiple primary keys
const selectedPostId = singleRowSelect?.data?.rest[0][primaryKey]

expect(selectedPostId).toEqual(postID);

const multipleRowSelect = await Documentation.Get({
[C6.WHERE]: {
[documentation[primaryKey.toUpperCase()]]: [C6.IN, [0, postID]],
}
})

if ('function' === typeof multipleRowSelect) {
throw Error('singleRowSelect is a promise, this is unexpected.');
}

console.log('singleRowSelect', multipleRowSelect?.data)

// Ensure the expected response datastructure is returned
expect(multipleRowSelect?.data?.rest).not.toBeUndefined();

// Make sure the previously created post is now returned
expect(typeof multipleRowSelect?.data?.rest).toEqual('object');

testData[primaryKey] = postID

testData.documentation_uri = fillString.substring(0, 255);
testData.documentation_data = fillString.substring(0, );
testData.documentation_version = fillString.substring(0, 40);
testData.documentation_active = randomInt;

// wait for the global state to be updated
expect(CarbonReact.getState<iRestfulObjectArrayTypes>().documentation).not.toBeUndefined();

const updateResponse = await Documentation.Put(testData)

expect(updateResponse?.data?.updated).not.toBeUndefined();

const deleteResponse = await Documentation.Delete({
[primaryKey]: postID
})

console.log('deleteResponse', deleteResponse?.data)

expect(deleteResponse?.data?.deleted).not.toBeUndefined();

await waitFor(async () => {
expect(checkAllRequestsComplete()).toEqual(true);
}, {timeout: 10000, interval: 1000});

})

}, 100000);

})

Loading

0 comments on commit d7f463f

Please sign in to comment.