-
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
109 changed files
with
1,444 additions
and
3,230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const coffeescript = require('coffeescript'); | ||
const createCacheKeyFunction = require('@jest/create-cache-key-function').default; | ||
/** | ||
* @typedef {import('@jest/transform').SyncTransformer} SyncTransformer | ||
* @typedef {import('@jest/transform').TransformedSource} TransformedSource | ||
*/ | ||
|
||
/** | ||
* Transform CoffeeScript files for Jest | ||
* See: https://jestjs.io/docs/code-transformation | ||
* | ||
* @implements { SyncTransformer } | ||
*/ | ||
module.exports = { | ||
/** | ||
* Process coffee files | ||
* | ||
* @param {string} sourceText | ||
* @param {string} filename | ||
* @returns {TransformedSource} | ||
*/ | ||
process(sourceText, filename) { | ||
const {js, sourceMap, v3SourceMap } = coffeescript.compile( | ||
sourceText, | ||
// ☕ CoffeeScript 1.12.7 compiler options | ||
{ | ||
// 📜 For source maps | ||
filename, | ||
sourceMap: true, | ||
|
||
// 📦 Same default as coffee-loader | ||
bare: true, | ||
} | ||
); | ||
return { | ||
code: js, | ||
map: JSON.parse(v3SourceMap), | ||
}; | ||
}, | ||
|
||
getCacheKey: createCacheKeyFunction( | ||
[__filename, require.resolve('coffeescript')], | ||
), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import chai from 'chai'; | ||
import $ from 'jquery'; | ||
|
||
// Polyfill global fetch (for Node 20 and older) | ||
import 'whatwg-fetch'; | ||
|
||
// Add global t() mock (see /static/js/global_t.js) | ||
global.t = (str: string) => str; | ||
|
||
// @ts-expect-error: ℹ️ Add chai global for BDD-style tests | ||
global.chai = chai; | ||
|
||
// @ts-expect-error: ℹ️ Use chai's version of `expect` | ||
global.expect = chai.expect; | ||
|
||
// @ts-expect-error: ℹ️ Add jQuery globals for xlform code | ||
global.jQuery = global.$ = $; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import type {Config} from 'jest'; | ||
import {defaults} from 'jest-config'; | ||
|
||
// Config to run ☕ unit tests using the Jest runner | ||
// | ||
// To run the unit tests: 🏃 | ||
// | ||
// npx jest --config ./jsapp/jest/unit.config.ts | ||
// | ||
|
||
const config: Config = { | ||
// Naming convention (*.tests.*) | ||
testMatch: ['**/?(*.)+(tests).(js|jsx|ts|tsx|es6|coffee)'], | ||
|
||
// Where to find tests. <rootDir> = 'kpi/jsapp/jest' | ||
roots: [ | ||
'<rootDir>/../js/', // unit tests 🛠️ 'jsapp/js/**/*.tests.{ts,es6}' | ||
'<rootDir>/../../test/', // xlform/coffee ☕ 'test/**/*.tests.coffee' | ||
], | ||
|
||
// Where to resolve module imports | ||
moduleNameMapper: { | ||
// ℹ️ same aliases as in webpack.common.js (module.resolve.alias) | ||
'^jsapp/(.+)$': '<rootDir>/../$1', // 📁 'jsapp/*' | ||
'^js/(.*)$': '<rootDir>/../js/$1', // 📁 'js/*' | ||
'^test/(.*)$': '<rootDir>/../../test/$1', // 📁 'test/*' | ||
'^utils$': '<rootDir>/../js/utils', // 📄 'utils' | ||
// 🎨 mock all CSS modules imported (styles.root = 'root') | ||
'\\.(css|scss)$': 'identity-obj-proxy', | ||
}, | ||
|
||
// Extensions to try in order (for import statements with no extension) | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'es6', 'coffee'], | ||
|
||
// Transformers (SWC for JS/TS, CoffeeScript for .coffee) | ||
transform: { | ||
'^.+\\.(js|jsx|ts|tsx|es6)$': '@swc/jest', | ||
'^.+\\.coffee$': '<rootDir>/coffeeTransformer.js', | ||
}, | ||
|
||
// Exclude these files, even if they contain tests | ||
testPathIgnorePatterns: [ | ||
'test/xlform/integration.tests.coffee$', // 📄 skipped in `ee98aebe631b` | ||
...defaults.testPathIgnorePatterns, // 📦 exclude '/node_modules/' | ||
], | ||
|
||
// Set up test environment | ||
testEnvironment: 'jsdom', | ||
|
||
// Make Chai and jQuery globals available in the test environment | ||
setupFilesAfterEnv: ['<rootDir>/setupUnitTest.ts'], | ||
|
||
// Appearance options (for console output) | ||
verbose: true, | ||
displayName: {name: 'UNIT', color: 'black'}, | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// Libraries | ||
import React from 'react'; | ||
|
||
// Partial components | ||
import PaginatedQueryUniversalTable from 'js/universalTable/paginatedQueryUniversalTable.component'; | ||
import LoadingSpinner from 'js/components/common/loadingSpinner'; | ||
import Avatar from 'js/components/common/avatar'; | ||
import Badge from 'jsapp/js/components/common/badge'; | ||
|
||
// Stores, hooks and utilities | ||
import {formatTime} from 'js/utils'; | ||
import {useOrganizationQuery} from './organizationQuery'; | ||
import useOrganizationMembersQuery from './membersQuery'; | ||
|
||
// Constants and types | ||
import type {OrganizationMember} from './membersQuery'; | ||
|
||
// Styles | ||
import styles from './membersRoute.module.scss'; | ||
|
||
export default function MembersRoute() { | ||
const orgQuery = useOrganizationQuery(); | ||
|
||
if (!orgQuery.data?.id) { | ||
return ( | ||
<LoadingSpinner /> | ||
); | ||
} | ||
|
||
return ( | ||
<div className={styles.membersRouteRoot}> | ||
<header className={styles.header}> | ||
<h2 className={styles.headerText}>{t('Members')}</h2> | ||
</header> | ||
|
||
<PaginatedQueryUniversalTable<OrganizationMember> | ||
queryHook={useOrganizationMembersQuery} | ||
columns={[ | ||
{ | ||
key: 'user__extra_details__name', | ||
label: t('Name'), | ||
cellFormatter: (member: OrganizationMember) => ( | ||
<Avatar | ||
size='m' | ||
username={member.user__username} | ||
isUsernameVisible | ||
email={member.user__email} | ||
// We pass `undefined` for the case it's an empty string | ||
fullName={member.user__extra_details__name || undefined} | ||
/> | ||
), | ||
size: 360, | ||
}, | ||
{ | ||
key: 'invite', | ||
label: t('Status'), | ||
size: 120, | ||
cellFormatter: (member: OrganizationMember) => { | ||
if (member.invite?.status) { | ||
return member.invite.status; | ||
} else { | ||
return <Badge color='light-green' size='s' label={t('Active')} />; | ||
} | ||
return null; | ||
}, | ||
}, | ||
{ | ||
key: 'date_joined', | ||
label: t('Date added'), | ||
size: 140, | ||
cellFormatter: (member: OrganizationMember) => formatTime(member.date_joined), | ||
}, | ||
{ | ||
key: 'role', | ||
label: t('Role'), | ||
size: 120, | ||
}, | ||
{ | ||
key: 'user__has_mfa_enabled', | ||
label: t('2FA'), | ||
size: 90, | ||
cellFormatter: (member: OrganizationMember) => { | ||
if (member.user__has_mfa_enabled) { | ||
return <Badge size='s' color='light-blue' icon='check' />; | ||
} | ||
return <Badge size='s' color='light-storm' icon='minus' />; | ||
}, | ||
}, | ||
{ | ||
// We use `url` here, but the cell would contain interactive UI | ||
// element | ||
key: 'url', | ||
label: '', | ||
size: 64, | ||
// TODO: this will be added soon | ||
cellFormatter: () => (' '), | ||
}, | ||
]} | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react'; | ||
|
||
export default function OrganizationSettingsRoute() { | ||
return ( | ||
<div>Organization settings view to be implemented</div> | ||
); | ||
} |
Oops, something went wrong.