Skip to content

Commit 0829883

Browse files
committed
Merge branch 'chat-proof' of https://github.com/SolidOS/solid-ui into chat-proof
2 parents d527997 + 3576458 commit 0829883

File tree

8 files changed

+26
-66478
lines changed

8 files changed

+26
-66478
lines changed

dist/solid-ui.js

Lines changed: 0 additions & 66456 deletions
This file was deleted.

dist/solid-ui.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/solid-ui.min.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

dist/solid-ui.min.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/chat/keys.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export async function getPrivateKey (webId: NamedNode) {
8282
return privateKey as string
8383
}
8484

85-
const deleteKey = async (keyDoc: string) => {
85+
const deleteKeyAcl = async (keyDoc: string) => {
8686
await store.fetcher.load(keyDoc)
8787

8888
const keyAclDoc = store.any(store.sym(keyDoc), store.sym('http://www.iana.org/assignments/link-relations/acl'))
@@ -120,7 +120,7 @@ async function saveKey (keyDoc: string, del, add, me: string = '') {
120120
}
121121
}
122122
*/
123-
await deleteKey(keyDoc)
123+
await deleteKeyAcl(keyDoc)
124124
// save key
125125
await store.updater.updateMany(del, add) // or a promise store.updater.update ?
126126

src/utils/keyHelpers/accessData.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ export const getPodRoot = async (webId: NamedNode) => {
2525
podRoot = storages.find((storage) => webIdURL.origin === new URL(storage.value).origin) as NamedNode
2626
if (!podRoot) podRoot = storages[0] as NamedNode
2727
}
28-
return podRoot?.value
28+
return podRoot as NamedNode
2929
}
3030

3131
export const pubKeyUrl = async (webId: NamedNode) => {
3232
try {
33-
return await getPodRoot(webId) + 'profile/keys/publicKey.ttl'
33+
return (await getPodRoot(webId)).value + 'profile/keys/publicKey.ttl'
3434
} catch (err) { throw new Error(err) }
3535
}
3636

@@ -40,8 +40,12 @@ export async function getExistingPublicKey (webId: NamedNode, publicKeyUrl: stri
4040
}
4141

4242
export const privKeyUrl = async (webId: NamedNode) => {
43+
let settings = store.any(webId, ns.space('preferencesFile'), null, webId.doc())?.value
44+
settings = settings?.split('/').slice(0, -1).join('/')
4345
try {
44-
return await getPodRoot(webId) + 'profile/keys/privateKey.ttl'
46+
const podRoot = await getPodRoot(webId)
47+
if (!settings?.startsWith(podRoot.value)) throw new Error(`/settings/ is expected to be in ${podRoot.value}`)
48+
return `${settings}/keys/privateKey.ttl`
4549
} catch (err) { throw new Error(err) }
4650
}
4751

test/unit/README.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Solid-UI Unit Testing
22
The purpose of this README is to provide guidance on how to write tests for solid-ui for beginners.
33

4-
Although we would love to have 100% test coverage, we realize that this is not a commericial product. solid-ui is an open source, volunteer built library that houses UI components that can be used to build Solid applications. We are working to increase test coverage on existing code, any help is much appreciated. If you add a new component to solid-ui, you should write tests to test the main functionality of your component in order for your PR to be merged.
4+
Although we would love to have 100% test coverage, we realize that this is not a commericial product. `solid-ui` is an open source, volunteer built library that houses UI components that can be used to build Solid applications. We are working to increase test coverage on existing code, and any help is much appreciated. If you add a new component to `solid-ui`, you should write tests to test the main functionality of your component before your PR will be merged.
55

66
## Running Tests
77

@@ -10,30 +10,35 @@ The following command will run all the tests.
1010
`npm run test`
1111

1212
### One file at a time
13-
There are a lot of tests in `solid-ui` so you will most likely want to run only the test you are working on at the moment. In order to do that you can use the following command.
13+
There are a lot of tests in `solid-ui`, so you will most likely want to run only the test you are working on at the moment. You can use commands like the following to do that:
1414
`npm test <filetobetested>`
1515
`npm test test/unit/utils/keyHelpers/accessData.test.ts`
1616

1717
### Coverage
1818
Run the following command:
1919
`npm run coverage`
2020

21-
Then you can see the results in `coverage/lcov-report/index.html`. If you are using VSCode you can right click and select to `Open in Browser Preview`. Otherwise, you can type the path in your browswer, for instance `file:///Users/<yourhomedirectory>/2023Development/solid-ui/coverage/lcov-report/index.html` is an example.
21+
The results will be found in `coverage/lcov-report/index.html`. If you are using VSCode, you can right click and select `Open in Browser Preview`. Alternatively, you can type the path in your browser; for instance, the following:
22+
```
23+
file:///Users/<yourhomedirectory>/2023Development/solid-ui/coverage/lcov-report/index.html
24+
```
2225

2326
## Tips and Tricks
24-
The following are some tips and tricks in hopes to make testing easier.
27+
The following are some tips and tricks to make your testing easier.
2528

2629
### VSCode Debugging
27-
There is an extension that can be used to aide in debugging jest tests. To find out more about it you can look at [Jest Runner](https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner)
30+
There is an extension that can be used to aide in debugging `jest` tests. To find out more about it, you can look at [Jest Runner](https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner).
2831

2932
### Mocking
30-
In solid-ui we do not currently follow a MVC pattern therefore there can be some difficulty in testing. The following are patterns to help with this.
33+
In `solid-ui`, we do not currently follow a MVC pattern, so testing is not always easy. The following are patterns to help with this.
3134
#### Store methods
3235
##### Load
33-
In SolidOS we use [rdflib.js](https://github.com/linkeddata/rdflib.js/) to work with LinkedData. The way this works is that you first load the document you need to work with into the store. Once the document is loaded you can then access the data by using additional methods on the store such as `any, each,...`. Since the data that gets returned will need to be mocked, `load` doesn't need to do anything. See below for what you need to put in the top of your file in order to mock the `load` method.
34-
`import { store } from 'solid-logic'` at the top of your file.
35-
36-
`store.fetcher.load = jest.fn().mockImplementation(() => {})`
36+
In SolidOS, we use [`rdflib.js`](https://github.com/linkeddata/rdflib.js/) to work with LinkedData. First, you load the document you need to work with into the store. Once the document is loaded, you can access the data by using additional methods on the store such as `any`, `each`, etc. Since the data that gets returned will need to be mocked, `load` doesn't need to do anything. You need to put the following into your file to mock the `load` method:
37+
```
38+
import { store } from 'solid-logic' /* at the top of your file */
39+
...
40+
store.fetcher.load = jest.fn().mockImplementation(() => {})
41+
```
3742

3843
##### Any
3944

test/unit/utils/keyHelpers/accessData.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('cryptoKeyHelpers', () => {
3838
describe.skip('privKeyUrl', () => {
3939
it('returns...', () => {
4040
const result = privKeyUrl(new NamedNode('https://alice.solid.example/profile/card#me'))
41-
expect(result).toEqual('https://alice.solid.example/profile/keys/privateKey.ttl')
41+
expect(result).toEqual('https://alice.solid.example/settings/keys/privateKey.ttl')
4242
})
4343
})
4444

@@ -50,7 +50,7 @@ describe('cryptoKeyHelpers', () => {
5050
it('returns...', async () => {
5151
const webId = new NamedNode('https://alice.solid.example/profile/card#me')
5252
const result = await getPodRoot(webId)
53-
expect(result).toBe('https://alice.solid.example')
53+
expect(result.value).toBe('https://alice.solid.example')
5454
})
5555
})
5656
describe('getKeyIfExists', () => {

0 commit comments

Comments
 (0)