Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export default {
'\\.svg\\?raw$': '<rootDir>/test/__mocks__/fileMock.js',
'\\.(svg)$': '<rootDir>/test/__mocks__/fileMock.js',
'\\.(png|jpe?g|gif|webp|avif)$': '<rootDir>/test/__mocks__/fileMock.js',
'\\.css$': '<rootDir>/test/__mocks__/styleMock.js'
'\\.css$': '<rootDir>/test/__mocks__/styleMock.js',
'solid-logic': '<rootDir>/../solid-logic/src/index.ts',
'solid-oidc-client-browser': '<rootDir>/test/mocks/solid-oidc-client-browser.ts'
},
setupFilesAfterEnv: ['./test/helpers/setup.ts'],
testMatch: ['**/?(*.)+(spec|test).[tj]s?(x)'],
Expand Down
2 changes: 1 addition & 1 deletion src/mainPage/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const applyMenuCollapsedState = (navMenu: HTMLElement | null): void => {
updateCollapseButtonPosition(navMenu, collapseBtn)
}

const isLoggedIn = (): boolean => Boolean(authSession?.info?.isLoggedIn)
const isLoggedIn = (): boolean => Boolean(authSession?.isActive)

const ensureMenuSkeleton = () => {
menuCollapsed = loadMenuCollapsedState()
Expand Down
57 changes: 57 additions & 0 deletions test/mocks/solid-oidc-client-browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
type Listener = (...args: any[]) => void

class EventEmitterLike {
private listeners: Record<string, Listener[]> = {}

on(event: string, listener: Listener): void {

Check failure on line 6 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (22)

Missing space before function parentheses

Check failure on line 6 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (24)

Missing space before function parentheses
const list = this.listeners[event] || []
list.push(listener)
this.listeners[event] = list
}

emit(event: string, ...args: any[]): void {

Check failure on line 12 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (22)

Missing space before function parentheses

Check failure on line 12 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (24)

Missing space before function parentheses
const list = this.listeners[event] || []
list.forEach(listener => listener(...args))
}
}

export class Session {
info: { webId?: string, isLoggedIn: boolean } = { isLoggedIn: false }
webId?: string
isActive = false
events = new EventEmitterLike()

addEventListener(event: string, listener: Listener): void {

Check failure on line 24 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (22)

Missing space before function parentheses

Check failure on line 24 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (24)

Missing space before function parentheses
this.events.on(event, listener)
}

async handleIncomingRedirect(): Promise<void> {

Check failure on line 28 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (22)

Missing space before function parentheses

Check failure on line 28 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (24)

Missing space before function parentheses
return

Check failure on line 29 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (22)

Unnecessary return statement

Check failure on line 29 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (24)

Unnecessary return statement
}

async handleRedirectFromLogin(): Promise<void> {

Check failure on line 32 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (22)

Missing space before function parentheses

Check failure on line 32 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (24)

Missing space before function parentheses
return

Check failure on line 33 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (22)

Unnecessary return statement

Check failure on line 33 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (24)

Unnecessary return statement
}

async restore(): Promise<void> {

Check failure on line 36 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (22)

Missing space before function parentheses

Check failure on line 36 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (24)

Missing space before function parentheses
return

Check failure on line 37 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (22)

Unnecessary return statement

Check failure on line 37 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (24)

Unnecessary return statement
}

async login(): Promise<void> {

Check failure on line 40 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (22)

Missing space before function parentheses

Check failure on line 40 in test/mocks/solid-oidc-client-browser.ts

View workflow job for this annotation

GitHub Actions / build (24)

Missing space before function parentheses
return
}

async logout(): Promise<void> {
this.info = { isLoggedIn: false }
this.webId = undefined
this.isActive = false
}

fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
return globalThis.fetch(input, init)
}

authFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
return globalThis.fetch(input, init)
}
}
14 changes: 12 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,18 @@
] /* List of folders to include type definitions from. */,
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"preserveSymlinks": true, /* Keep symlinks unresolved to avoid duplicate rdflib type identities in local linked dev. */
/* baseUrl + paths below are for local integrated dev only.
They force a single rdflib type identity when solid-panes is linked to local solid-logic/solid-ui.
Both options are deprecated in TS6+ but remain functional until TS7.
See solid-ui README: Local Integrated Development for context. */
"ignoreDeprecations": "6.0",
"baseUrl": ".",
"paths": {
"rdflib": ["node_modules/rdflib"],
"rdflib/*": ["node_modules/rdflib/*"]
}

/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
Expand Down
Loading