Created
January 7, 2025 19:49
-
-
Save Johnetordoff/d32d8b6772508d7130e88d154fcd4fd7 to your computer and use it in GitHub Desktop.
Share mocking helpers
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
/usr/local/bin/python3.9 /Users/johntordoff/osf_cookbook/unstaged_print.py | |
Checking unstaged files in repository: ../ember-osf-web | |
Unstaged files: | |
- config/environment.js | |
- mirage/config.ts | |
- mirage/scenarios/dashboard.ts | |
- mirage/views/search.ts | |
- tests/acceptance/institutions/dashboard-test.ts | |
- tests/acceptance/institutions/discover-test.ts | |
Printing file contents... | |
--- Contents of ../ember-osf-web/config/environment.js --- | |
/* eslint-env node */ | |
// Note: environment.d.ts is now in app/config | |
function isTruthy(val) { | |
return ['true', '1'].includes(val.toString().toLowerCase()); | |
} | |
let localConfig; | |
try { | |
localConfig = require('./local'); // eslint-disable-line global-require,node/no-missing-require | |
} catch (ex) { | |
localConfig = {}; | |
} | |
const { | |
A11Y_AUDIT = 'true', | |
ASSETS_PREFIX: assetsPrefix = '/ember_osf_web/', | |
BACKEND: backend = 'local', | |
CAS_URL: casUrl = 'http://192.168.168.167:8080', | |
CEDAR_CONFIG: cedarConfig = { | |
viewerConfig: { | |
showHeader: false, | |
showFooter: false, | |
expandedSampleTemplateLinks: false, | |
showSampleTemplateLinks: false, | |
defaultLanguage: 'en', | |
showTemplateData: false, | |
showInstanceData: false, | |
}, | |
editorConfig: { | |
defaultLanguage: 'en', | |
expandedSampleTemplateLinks: true, | |
showTemplateRenderingRepresentation: false, | |
showMultiInstanceInfo: false, | |
expandedInstanceDataFull: false, | |
expandedInstanceDataCore: false, | |
expandedMultiInstanceInfo: false, | |
expandedTemplateRenderingRepresentation: false, | |
expandedTemplateSourceData: false, | |
collapseStaticComponents: false, | |
showStaticText: false, | |
showInstanceDataCore: false, | |
showHeader: false, | |
showFooter: false, | |
terminologyIntegratedSearchUrl: 'https://terminology.metadatacenter.org/bioportal/integrated-search', | |
// These are required to be false | |
showInstanceDataFull: false, | |
showTemplateSourceData: false, | |
}, | |
}, | |
CLIENT_ID: clientId, | |
COLLECTIONS_ENABLED = false, | |
REGISTRIES_ENABLED = true, | |
TESTS_ENABLED = false, | |
FB_APP_ID, | |
GIT_COMMIT: release, | |
GOOGLE_ANALYTICS_ID, | |
GOOGLE_TAG_MANAGER_ID, | |
KEEN_CONFIG: keenConfig, | |
LINT_ON_BUILD: lintOnBuild = false, | |
WATER_BUTLER_ENABLED = true, | |
MIRAGE_ENABLED = true, | |
MIRAGE_SCENARIOS = [ | |
'cedar', | |
'collections', | |
'dashboard', | |
'forks', | |
'loggedIn', | |
'meetings', | |
'preprints', | |
'registrations', | |
'settings', | |
], | |
OAUTH_SCOPES: scope, | |
OSF_STATUS_COOKIE: statusCookie = 'osf_status', | |
OSF_COOKIE_DOMAIN: cookieDomain = 'localhost', | |
OSF_URL: url = 'http://localhost:5000/', | |
OSF_API_URL: apiUrl = 'http://localhost:8000', | |
OSF_API_VERSION: apiVersion = '2.20', | |
OSF_RENDER_URL: renderUrl = 'http://localhost:7778/render', | |
OSF_MFR_URL: mfrUrl = 'http://localhost:4200', | |
OSF_FILE_URL: waterbutlerUrl = 'http://localhost:7777/', | |
OSF_HELP_URL: helpUrl = 'http://localhost:4200/help', | |
OSF_AUTHENTICATOR: osfAuthenticator = 'osf-cookie', | |
PLAUDIT_WIDGET_URL: plauditWidgetUrl = 'https://osf-review.plaudit.pub/embed/endorsements.js', | |
METRICS_START_DATE: metricsStartDate = '2019-01-01', | |
POLICY_URL_PREFIX = 'https://github.com/CenterForOpenScience/centerforopenscience.org/blob/master/', | |
POPULAR_LINKS_NODE: popularNode = '57tnq', | |
// POPULAR_LINKS_REGISTRATIONS = '', | |
NEW_AND_NOTEWORTHY_LINKS_NODE: noteworthyNode = 'z3sg2', | |
/* eslint-disable-next-line max-len */ | |
// https://developers.google.com/recaptcha/docs/faq#id-like-to-run-automated-tests-with-recaptcha-v2-what-should-i-do | |
RECAPTCHA_SITE_KEY = '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', | |
REDIRECT_URI: redirectUri, | |
ROOT_URL: rootURL = '/', | |
SHARE_BASE_URL: shareBaseUrl = 'https://staging-share.osf.io/', | |
SHARE_API_URL: shareApiUrl = 'https://staging-share.osf.io/api/v2', | |
SHARE_SEARCH_URL: shareSearchUrl = 'https://staging-share.osf.io/api/v2/search/creativeworks/_search', | |
SOURCEMAPS_ENABLED: sourcemapsEnabled = true, | |
SHOW_DEV_BANNER = false, | |
} = { ...process.env, ...localConfig }; | |
module.exports = function(environment) { | |
const devMode = environment !== 'production'; | |
const ENV = { | |
modulePrefix: 'ember-osf-web', | |
cedarConfig, | |
WATER_BUTLER_ENABLED, | |
plauditWidgetUrl, | |
environment, | |
lintOnBuild, | |
testsEnabled: false, // Disable tests by default. | |
sourcemapsEnabled, | |
showDevBanner: isTruthy(SHOW_DEV_BANNER), | |
rootURL, | |
assetsPrefix, | |
locationType: 'auto', | |
sentryDSN: null, | |
googleTagManagerId: null, | |
sentryOptions: { | |
release, | |
ignoreErrors: [ | |
// https://github.com/emberjs/ember.js/issues/12505 | |
'TransitionAborted', | |
], | |
}, | |
EmberENV: { | |
FEATURES: { | |
// Here you can enable experimental features on an ember canary build | |
// e.g. 'with-controller': true | |
}, | |
EXTEND_PROTOTYPES: { | |
// Prevent Ember Data from overriding Date.parse. | |
Date: false, | |
}, | |
}, | |
APP: { | |
// Here you can pass flags/options to your application instance | |
// when it is created | |
}, | |
moment: { | |
includeTimezone: 'all', | |
outputFormat: 'YYYY-MM-DD h:mm A z', | |
}, | |
metricsAdapters: [ | |
{ | |
name: 'GoogleAnalytics', | |
environments: GOOGLE_ANALYTICS_ID ? ['all'] : [], | |
config: { | |
id: GOOGLE_ANALYTICS_ID, | |
setFields: { | |
anonymizeIp: true, | |
}, | |
}, | |
dimensions: { | |
authenticated: 'dimension1', | |
resource: 'dimension2', | |
isPublic: 'dimension3', | |
isWithdrawn: 'dimension4', | |
version: 'dimension5', | |
}, | |
}, | |
{ | |
name: 'GoogleTagManager', | |
environments: GOOGLE_TAG_MANAGER_ID ? ['all'] : [], | |
config: { | |
id: GOOGLE_TAG_MANAGER_ID, | |
}, | |
}, | |
], | |
FB_APP_ID, | |
OSF: { | |
clientId, | |
scope, | |
apiNamespace: 'v2', // URL suffix (after host) | |
backend, | |
redirectUri, | |
url, | |
apiUrl, | |
apiVersion, | |
apiHeaders: { | |
Accept: `application/vnd.api+json; version=${apiVersion}`, | |
}, | |
learnMoreUrl: 'https://cos.io/our-products/osf/', | |
donateUrl: 'https://cos.io/donate', | |
renderUrl, | |
mfrUrl, | |
waterbutlerUrl, | |
helpUrl, | |
shareBaseUrl, | |
shareApiUrl, | |
shareSearchUrl, | |
devMode, | |
metricsStartDate, | |
cookieDomain, | |
authenticator: `authenticator:${osfAuthenticator}`, | |
cookies: { | |
status: statusCookie, | |
keenUserId: 'keenUserId', | |
keenSessionId: 'keenSessionId', | |
cookieConsent: 'osf_cookieconsent', | |
newFeaturePopover: 'metadataFeaturePopover', | |
maintenance: 'maintenance', | |
csrf: 'api-csrf', | |
authSession: 'embosf-auth-session', | |
}, | |
localStorageKeys: { | |
authSession: 'embosf-auth-session', | |
joinBannerDismissed: 'slide', // TODO: update legacy UI to use a more unique key | |
}, | |
casUrl, | |
analyticsAttrs: { | |
name: 'data-analytics-name', | |
scope: 'data-analytics-scope', | |
extra: 'data-analytics-extra', | |
category: 'data-analytics-category', | |
action: 'data-analytics-action', | |
}, | |
doiUrlPrefix: 'https://doi.org/', | |
}, | |
social: { | |
twitter: { | |
viaHandle: 'OSFramework', | |
}, | |
}, | |
signUpPolicy: { | |
termsLink: `${POLICY_URL_PREFIX}TERMS_OF_USE.md`, | |
privacyPolicyLink: `${POLICY_URL_PREFIX}PRIVACY_POLICY.md`, | |
cookiesLink: `${POLICY_URL_PREFIX}PRIVACY_POLICY.md#f-cookies`, | |
}, | |
footerLinks: { | |
cos: 'https://cos.io', | |
statusPage: 'https://status.cos.io/', | |
apiDocs: 'https://developer.osf.io/', | |
topGuidelines: 'http://cos.io/top/', | |
rpp: 'https://osf.io/ezcuj/wiki/home/', | |
rpcb: 'https://osf.io/e81xl/wiki/home/', | |
twitter: 'http://twitter.com/OSFramework', | |
facebook: 'https://www.facebook.com/CenterForOpenScience/', | |
googleGroup: 'https://groups.google.com/forum/#!forum/openscienceframework', | |
github: 'https://www.github.com/centerforopenscience', | |
}, | |
support: { | |
preregUrl: 'https://cos.io/prereg/', | |
statusPageUrl: 'https://status.cos.io', | |
faqPageUrl: 'https://help.osf.io', | |
supportEmail: '[email protected]', | |
contactEmail: '[email protected]', | |
consultationUrl: 'https://cos.io/stats_consulting/', | |
twitterUrl: 'https://twitter.com/OSFSupport', | |
mailingUrl: 'https://groups.google.com/forum/#!forum/openscienceframework', | |
facebookUrl: 'https://www.facebook.com/CenterForOpenScience/', | |
githubUrl: 'https://github.com/centerforopenscience', | |
}, | |
helpLinks: { | |
linkToAProject: 'https://help.osf.io/hc/en-us/articles/360019930313-Link-to-a-Project', | |
}, | |
dashboard: { | |
popularNode, | |
noteworthyNode, | |
}, | |
featureFlagNames: { | |
routes: { | |
'collections.moderation': 'collections_moderation', | |
'registries.branded': 'branded_registries', | |
'registries.branded.discover': 'branded_registries', | |
'guid-node.index': 'ember_project_detail_page', | |
'guid-node.drafts.index': 'ember_edit_draft_registration_page', | |
'guid-node.drafts.register': 'ember_edit_draft_registration_page', | |
'guid-user.index': 'ember_user_profile_page', | |
'guid-registration.index': 'ember_old_registration_detail_page', | |
settings: 'ember_user_settings_page', | |
'settings.profile': 'ember_user_settings_page', | |
'settings.profile.education': 'ember_user_settings_page', | |
'settings.profile.employment': 'ember_user_settings_page', | |
'settings.profile.name': 'ember_user_settings_page', | |
'settings.profile.social': 'ember_user_settings_page', | |
'settings.account': 'ember_user_settings_account_page', | |
'settings.tokens': 'ember_user_settings_tokens_page', | |
'settings.tokens.index': 'ember_user_settings_tokens_page', | |
'settings.tokens.create': 'ember_user_settings_tokens_page', | |
'settings.tokens.edit': 'ember_user_settings_tokens_page', | |
'settings.developer-apps': 'ember_user_settings_apps_page', | |
'settings.developer-apps.index': 'ember_user_settings_apps_page', | |
'settings.developer-apps.create': 'ember_user_settings_apps_page', | |
'settings.developer-apps.edit': 'ember_user_settings_apps_page', | |
register: 'ember_auth_register', | |
'registries.overview': 'ember_registries_detail_page', | |
'registries.overview.index': 'ember_registries_detail_page', | |
'registries.overview.comments': 'ember_registries_detail_page', | |
'registries.overview.contributors': 'ember_registries_detail_page', | |
'registries.overview.children': 'ember_registries_detail_page', | |
'registries.overview.links': 'ember_registries_detail_page', | |
'registries.start': 'ember_registries_submission_start', | |
'registries.drafts': 'ember_registries_submission_drafts', | |
'registries.drafts.index': 'ember_registries_submission_drafts', | |
'registries.drafts.draft.metadata': 'ember_edit_draft_registration_page', | |
'registries.drafts.draft.page': 'ember_edit_draft_registration_page', | |
'registries.drafts.draft.review': 'ember_edit_draft_registration_page', | |
'registries.forms': 'ember_registries_submission_forms', | |
'registries.forms.help': 'ember_registries_submission_forms', | |
'meetings.index': 'ember_meetings_page', | |
'meetings.detail': 'ember_meeting_detail_page', | |
}, | |
navigation: { | |
institutions: 'institutions_nav_bar', | |
}, | |
storageI18n: 'storage_i18n', | |
enableInactiveSchemas: 'enable_inactive_schemas', | |
verifyEmailModals: 'ember_verify_email_modals', | |
ABTesting: { | |
homePageHeroTextVersionB: 'ab_testing_home_page_hero_text_version_b', | |
}, | |
registrationFilesPage: 'ember_registration_files_page', | |
egapAdmins: 'egap_admins', | |
shareDownload: 'share_download', | |
}, | |
gReCaptcha: { | |
siteKey: RECAPTCHA_SITE_KEY, | |
}, | |
home: { | |
youtubeId: '2TV21gOzfhw', | |
}, | |
secondaryNavbarId: '__secondaryOSFNavbar__', | |
engines: { | |
// App Engines should always be enabled in production builds | |
// as they will be enabled/disabled at runtime rather than buildtime | |
collections: { | |
enabled: !devMode || isTruthy(COLLECTIONS_ENABLED), | |
}, | |
registries: { | |
enabled: !devMode || isTruthy(REGISTRIES_ENABLED), | |
}, | |
}, | |
'ember-cli-tailwind': { | |
shouldIncludeStyleguide: false, | |
}, | |
'ember-cli-mirage': { | |
enabled: isTruthy(MIRAGE_ENABLED), | |
}, | |
'changeset-validations': { | |
rawOutput: true, | |
}, | |
mirageScenarios: MIRAGE_SCENARIOS, | |
defaultProvider: 'osf', | |
pageTitle: { | |
prepend: false, | |
}, | |
}; | |
if (environment === 'development') { | |
// ENV.APP.LOG_RESOLVER = true; | |
// ENV.APP.LOG_ACTIVE_GENERATION = true; | |
// ENV.APP.LOG_TRANSITIONS = true; | |
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true; | |
// ENV.APP.LOG_VIEW_LOOKUPS = true; | |
ENV.metricsAdapters[0].config.cookieDomain = 'none'; | |
ENV.APP.LOG_TRANSITIONS = true; | |
ENV.APP.LOG_TRANSITIONS_INTERNAL = true; | |
Object.assign(ENV, { | |
'ember-a11y-testing': { | |
componentOptions: { | |
turnAuditOff: !isTruthy(A11Y_AUDIT), | |
}, | |
}, | |
// Conditionally enable tests in development environment. | |
testsEnabled: isTruthy(TESTS_ENABLED), | |
showDevBanner: true, | |
}); | |
} | |
if (environment === 'test') { | |
Object.assign(ENV, { | |
// Testem prefers this... | |
locationType: 'none', | |
// Test environment needs to find assets in the "regular" location. | |
assetsPrefix: '/', | |
// Always enable tests in test environment. | |
testsEnabled: true, | |
// Always enable mirage for tests. | |
'ember-cli-mirage': { | |
enabled: true, | |
}, | |
APP: { | |
...ENV.APP, | |
// keep test console output quieter | |
LOG_ACTIVE_GENERATION: false, | |
LOG_VIEW_LOOKUPS: false, | |
rootElement: '#ember-testing', | |
autoboot: false, | |
}, | |
engines: { | |
...ENV.engines, | |
collections: { | |
enabled: true, | |
}, | |
registries: { | |
enabled: true, | |
}, | |
}, | |
}); | |
} | |
if (devMode) { | |
// Fallback to throwaway defaults if the environment variables are not set | |
ENV.metricsAdapters[0].config.id = ENV.metricsAdapters[0].config.id || 'UA-84580271-1'; | |
ENV.FB_APP_ID = ENV.FB_APP_ID || '1039002926217080'; | |
} | |
return ENV; | |
}; | |
--- End of File --- | |
--- Contents of ../ember-osf-web/mirage/config.ts --- | |
import { Server } from 'ember-cli-mirage'; | |
import config from 'ember-osf-web/config/environment'; | |
import { createReviewAction } from 'ember-osf-web/mirage/views/review-action'; | |
import { createResource, updateResource } from 'ember-osf-web/mirage/views/resource'; | |
import { addonsList } from './views/addons'; | |
import { getCitation } from './views/citation'; | |
import { createCollectionSubmission, getCollectionSubmissions } from './views/collection-submission'; | |
import { createSubmissionAction } from './views/collection-submission-action'; | |
import { searchCollections } from './views/collection-search'; | |
import { reportDelete } from './views/comment'; | |
import { addContributor, addPreprintContributor, createBibliographicContributor } from './views/contributor'; | |
import { createDeveloperApp, updateDeveloperApp } from './views/developer-app'; | |
import { createDraftRegistration } from './views/draft-registration'; | |
import { | |
folderFilesList, | |
nodeFileProviderList, | |
nodeFilesListForProvider, | |
uploadToFolder, | |
uploadToRoot, | |
} from './views/file'; | |
import { createFork, createRegistrationFork } from './views/fork'; | |
import { guidDetail } from './views/guid'; | |
import { identifierCreate } from './views/identifier'; | |
import { summaryMetrics } from './views/institution'; | |
import { postCountedUsage, getNodeAnalytics } from './views/metrics'; | |
import { addCollectionModerator, addRegistrationModerator } from './views/moderator'; | |
import { createNode, storageStatus } from './views/node'; | |
import { osfNestedResource, osfResource, osfToManyRelationship } from './views/osf-resource'; | |
import { getPreprintProviderSubjects, getProviderSubjects } from './views/provider-subjects'; | |
import { getSubjectsAcceptable } from './views/subjects-acceptable'; | |
import { | |
createRegistration, | |
forkRegistration, | |
getProviderRegistrations, | |
registrationDetail, | |
} from './views/registration'; | |
import { createNewSchemaResponse } from './views/schema-response'; | |
import { createSchemaResponseAction } from './views/schema-response-action'; | |
import { rootDetail } from './views/root'; | |
import { shareSearch } from './views/share-search'; | |
import { cardSearch, valueSearch } from './views/search'; | |
import { createToken } from './views/token'; | |
import { createEmails, updateEmails } from './views/update-email'; | |
import { | |
claimUnregisteredUser, | |
userNodeList, | |
userRegistrationList, | |
userPreprintList, | |
} from './views/user'; | |
import { updatePassword } from './views/user-password'; | |
import * as userSettings from './views/user-setting'; | |
import * as wb from './views/wb'; | |
import { createPreprint } from './views/preprint'; | |
const { OSF: { apiUrl, shareBaseUrl, url: osfUrl } } = config; | |
export default function(this: Server) { | |
this.passthrough(); // pass through all requests on currrent domain | |
this.passthrough('https://api.crossref.org/*'); | |
// SHARE-powered registration discover endpoint | |
this.urlPrefix = 'https://share.osf.io'; | |
this.namespace = '/api/v2/'; | |
this.post('/search/creativeworks/_search', shareSearch); | |
// SHARE-powered search endpoints | |
this.urlPrefix = shareBaseUrl; | |
this.namespace = '/trove/'; // /api/v3/ works as well, but /trove/ is the preferred URL | |
this.get('/index-card-search', cardSearch); | |
this.get('/index-value-search', valueSearch); | |
this.urlPrefix = osfUrl; | |
this.namespace = '/api/v1/'; | |
this.post('project/:id/boa/submit-job/', () => ({})); // submissions to BoA | |
this.urlPrefix = apiUrl; | |
this.namespace = '/v2'; | |
this.get('/', rootDetail); | |
osfResource(this, 'developer-app', { path: 'applications', except: ['create', 'update'] }); | |
this.post('/applications', createDeveloperApp); | |
this.patch('/applications/:id', updateDeveloperApp); | |
osfResource(this, 'file', { only: ['show', 'update'] }); | |
osfNestedResource(this, 'file', 'versions', { | |
only: ['index'], | |
path: '/files/:parentID/versions', | |
}); | |
osfNestedResource(this, 'file', 'cedarMetadataRecords', { only: ['index'] }); | |
this.get('/guids/:id', guidDetail); | |
osfResource(this, 'institution', { only: ['index', 'show'], defaultPageSize: 1000 }); | |
osfNestedResource(this, 'institution', 'users', { | |
only: ['index'], | |
path: '/institutions/:parentID/users', | |
}); | |
osfNestedResource(this, 'institution', 'userMetrics', { | |
only: ['index'], | |
path: '/institutions/:parentID/metrics/users', | |
}); | |
osfNestedResource(this, 'institution', 'departmentMetrics', { | |
only: ['index'], | |
path: '/institutions/:parentID/metrics/departments', | |
}); | |
this.get('/institutions/:id/metrics/summary', summaryMetrics); | |
osfResource(this, 'license', { only: ['index', 'show'] }); | |
osfResource(this, 'citation-style', { | |
only: ['index'], | |
path: '/citations/styles', | |
}); | |
// Passthrough for specific OSF API routes | |
this.passthrough(`${config.OSF.apiUrl}/v2/nodes/:id/requests`); | |
this.passthrough(`${config.OSF.apiUrl}/v2/users/:id/messages`); | |
osfResource(this, 'node', { except: ['create'] }); | |
this.post('/nodes/', createNode); | |
osfResource(this, 'subject', { only: ['show'] }); | |
osfNestedResource(this, 'subject', 'children', { only: ['index'] }); | |
osfNestedResource(this, 'node', 'children'); | |
this.get('/nodes/:parentID/subjectsAcceptable', getSubjectsAcceptable); | |
osfNestedResource(this, 'node', 'contributors', { | |
defaultSortKey: 'index', | |
onCreate: createBibliographicContributor, | |
}); | |
this.get('/nodes/:parentID/addons', addonsList); | |
this.get('/nodes/:parentID/files', nodeFileProviderList); // Node file providers list | |
this.get('/nodes/:parentID/files/:fileProviderId', nodeFilesListForProvider); // Node files list for file provider | |
this.get('/nodes/:parentID/files/:fileProviderId/:folderId', folderFilesList); // Node folder detail view | |
this.put('/nodes/:parentID/files/:fileProviderId/upload', uploadToRoot); // Upload to file provider | |
osfNestedResource(this, 'node', 'bibliographicContributors', { | |
only: ['index'], | |
relatedModelName: 'contributor', | |
defaultSortKey: 'index', | |
}); | |
osfNestedResource(this, 'node', 'forks', { only: ['index'] }); | |
osfNestedResource(this, 'node', 'cedarMetadataRecords', { only: ['index'] }); | |
this.post('/nodes/:id/forks', createFork); | |
osfNestedResource(this, 'node', 'linkedNodes', { only: ['index'] }); | |
osfNestedResource(this, 'node', 'linkedByNodes', { only: ['index'] }); | |
osfNestedResource(this, 'node', 'linkedRegistrations', { only: ['index'] }); | |
osfNestedResource(this, 'node', 'registrations', { only: ['index'] }); | |
this.post('/nodes/:id/registrations', createRegistration); | |
osfNestedResource(this, 'node', 'draftRegistrations', { only: ['index'] }); | |
this.post('/nodes/:guid/draft_registrations', createDraftRegistration); | |
osfNestedResource(this, 'node', 'identifiers', { only: ['index'] }); | |
osfToManyRelationship(this, 'node', 'affiliatedInstitutions', { | |
only: ['related', 'add', 'remove', 'update'], | |
path: '/nodes/:parentID/relationships/institutions', | |
}); | |
this.get('/nodes/:id/storage', storageStatus); | |
osfResource(this, 'draft-node', { only: ['show', 'index', 'create'] }); | |
osfNestedResource(this, 'draft-node', 'draftRegistrations', { only: ['index'] }); | |
this.get('/draft_nodes/:parentID/files', nodeFileProviderList); // DraftNode file providers list | |
this.get('/draft_nodes/:parentID/files/:fileProviderId', | |
nodeFilesListForProvider); // DraftNode files list for file provider | |
this.get('/draft_nodes/:parentID/files/:fileProviderId/:folderId', | |
folderFilesList); // DraftNode folder detail view | |
this.put('/draft_nodes/:parentID/files/:fileProviderId/upload', uploadToRoot); // Upload to file provider | |
osfToManyRelationship(this, 'node', 'subjects', { | |
only: ['related', 'self'], | |
}); | |
osfResource(this, 'draft-registration', { | |
only: ['index', 'show', 'update', 'delete'], | |
path: '/draft_registrations', | |
}); | |
this.post('/draft_registrations', createDraftRegistration); | |
osfToManyRelationship(this, 'draft-registration', 'subjects'); | |
osfToManyRelationship(this, 'draft-registration', 'affiliatedInstitutions', { | |
only: ['related', 'update', 'add', 'remove'], | |
path: '/draft_registrations/:parentID/relationships/institutions', | |
}); | |
osfNestedResource(this, 'draft-registration', 'contributors', { | |
defaultSortKey: 'index', | |
except: ['create'], | |
}); | |
osfNestedResource(this, 'draft-registration', 'bibliographicContributors', { | |
only: ['index'], | |
relatedModelName: 'contributor', | |
defaultSortKey: 'index', | |
}); | |
this.post('/draft_registrations/:draftId/contributors/', addContributor); | |
osfNestedResource(this, 'draft-registration', 'bibliographicContributors', { | |
only: ['index'], | |
relatedModelName: 'contributor', | |
defaultSortKey: 'index', | |
}); | |
osfResource(this, 'review-action', { | |
only: ['show'], | |
path: '/actions', | |
}); | |
osfResource(this, 'registration', { except: ['show', 'create'] }); | |
this.post('/registrations', createRegistration); | |
this.get('/registrations/:id', registrationDetail); | |
osfNestedResource(this, 'registration', 'children'); | |
osfNestedResource(this, 'registration', 'forks', { except: ['create'] }); | |
osfNestedResource(this, 'registration', 'reviewActions', { | |
only: ['index'], | |
path: '/registrations/:parentID/actions', | |
relatedModelName: 'review-action', | |
}); | |
this.post('/registrations/:parentID/actions', createReviewAction); | |
this.post('/registrations/:id/forks', forkRegistration); | |
osfNestedResource(this, 'registration', 'contributors', { defaultSortKey: 'index' }); | |
osfNestedResource(this, 'registration', 'bibliographicContributors', { | |
only: ['index'], | |
relatedModelName: 'contributor', | |
defaultSortKey: 'index', | |
}); | |
osfNestedResource(this, 'registration', 'forks', { only: ['index'] }); | |
this.post('/registrations/:id/forks', createRegistrationFork); | |
osfNestedResource(this, 'registration', 'cedarMetadataRecords', { only: ['index'] }); | |
osfNestedResource(this, 'registration', 'linkedNodes', { only: ['index'] }); | |
osfNestedResource(this, 'registration', 'linkedRegistrations', { only: ['index'] }); | |
osfToManyRelationship(this, 'registration', 'affiliatedInstitutions', { | |
only: ['related', 'update', 'add', 'remove'], | |
path: '/registrations/:parentID/relationships/institutions', | |
}); | |
osfNestedResource(this, 'registration', 'identifiers', { only: ['index'] }); | |
this.post('/registrations/:parentID/identifiers/', identifierCreate); | |
osfNestedResource(this, 'registration', 'comments', { only: ['index'] }); | |
this.get('/registrations/:guid/citation/:citationStyleID', getCitation); | |
osfToManyRelationship(this, 'registration', 'subjects', { | |
only: ['related', 'self', 'update'], | |
}); | |
this.get('/registrations/:parentID/files', nodeFileProviderList); // registration file providers list | |
this.get('/registrations/:parentID/files/:fileProviderId', | |
nodeFilesListForProvider); // registration files list for file provider | |
this.get('/registrations/:parentID/files/:fileProviderId/:folderId', | |
folderFilesList); // registration folder detail view | |
osfResource(this, 'subject', { only: ['show'] }); | |
osfNestedResource(this, 'comment', 'reports', { | |
except: ['delete'], | |
path: '/comments/:parentID/reports', | |
relatedModelName: 'comment-report', | |
}); | |
this.del('/comments/:id/reports/:reporter_id', reportDelete); | |
osfResource(this, 'registration-schema', { path: '/schemas/registrations' }); | |
osfNestedResource(this, 'registration-schema', 'schemaBlocks', { | |
path: '/schemas/registrations/:parentID/schema_blocks', | |
defaultSortKey: 'index', | |
defaultPageSize: 1000, | |
}); | |
osfResource(this, 'schema-response', { | |
path: '/schema_responses', | |
only: ['index', 'delete', 'show', 'update'], | |
}); | |
this.post('/schema_responses', createNewSchemaResponse); | |
osfNestedResource(this, 'registration', 'schemaResponses', { | |
path: '/registrations/:parentID/schema_responses', | |
only: ['show', 'create', 'index'], | |
}); | |
osfNestedResource(this, 'schema-response', 'actions', { | |
path: '/schema_responses/:parentID/actions', | |
only: ['show', 'index'], | |
relatedModelName: 'schema-response-action', | |
}); | |
this.post('/schema_responses/:revisionId/actions', createSchemaResponseAction); | |
osfResource(this, 'brand', { only: ['show'] }); | |
osfResource(this, 'collection'); | |
osfToManyRelationship(this, 'collection', 'linkedRegistrations', { | |
only: ['related', 'add', 'remove'], | |
}); | |
osfResource(this, 'scope', { only: ['index', 'show'] }); | |
osfResource(this, 'region', { only: ['index', 'show'] }); | |
this.get('/status', () => ({ meta: { version: '2.8' }, maintenance: null })); | |
osfResource(this, 'token', { except: ['create'] }); | |
this.post('/tokens', createToken); | |
osfResource(this, 'user', { except: ['create', 'delete'] }); | |
osfNestedResource(this, 'user', 'institutions', { only: ['index'] }); | |
this.get('/users/:id/settings', userSettings.getUserSetting); | |
this.patch('/users/:parentID/settings', userSettings.updateUserSetting); | |
osfNestedResource(this, 'user', 'emails', { | |
except: ['update', 'create'], | |
path: '/users/:parentID/settings/emails', | |
relatedModelName: 'user-email', | |
}); | |
this.patch('/users/:parentID/settings/emails/:emailID/', updateEmails); | |
this.post('/users/:parentID/settings/emails/', createEmails); | |
this.post('/users/:id/settings/export', userSettings.requestExport); | |
this.post('/users/:parentID/settings/password/', updatePassword); | |
this.post('/users/:parentID/claim/', claimUnregisteredUser); | |
osfResource(this, 'external-identity', { | |
path: '/users/me/settings/identities', | |
only: ['index', 'delete'], | |
}); | |
this.get('/users/:id/nodes', userNodeList); | |
this.get('/sparse/users/:id/nodes', userNodeList); | |
this.get('/users/:id/registrations', userRegistrationList); | |
this.get('/users/:id/preprints', userPreprintList); | |
osfNestedResource(this, 'user', 'draftRegistrations', { | |
only: ['index'], | |
}); | |
osfResource(this, 'preprint-provider', { | |
path: '/providers/preprints', | |
defaultPageSize: 1000, | |
}); | |
osfNestedResource(this, 'preprint-provider', 'highlightedSubjects', { | |
only: ['index'], | |
path: '/providers/preprints/:parentID/subjects/highlighted/', | |
relatedModelName: 'subject', | |
}); | |
osfNestedResource(this, 'preprint-provider', 'licensesAcceptable', { | |
only: ['index'], | |
path: '/providers/preprints/:parentID/licenses/', | |
relatedModelName: 'license', | |
}); | |
osfNestedResource(this, 'preprint-provider', 'preprints', { | |
path: '/providers/preprints/:parentID/preprints/', | |
relatedModelName: 'preprint', | |
}); | |
this.get('/providers/preprints/:parentID/subjects/', getPreprintProviderSubjects); | |
osfNestedResource(this, 'preprint-provider', 'citationStyles', { | |
only: ['index'], | |
path: '/providers/preprints/:parentID/citation_styles/', | |
relatedModelName: 'citation-style', | |
}); | |
/** | |
* Preprint Details | |
*/ | |
osfResource(this, 'preprint'); | |
this.post('/preprints', createPreprint); | |
this.get('/preprints/:id', (schema, request) => { | |
const id = request.params.id; | |
return schema.preprints.find(id); | |
}); | |
osfNestedResource(this, 'preprint', 'contributors', { | |
path: '/preprints/:parentID/contributors/', | |
defaultSortKey: 'index', | |
except: ['create'], | |
}); | |
this.post('/preprints/:preprintID/contributors/', addPreprintContributor); | |
osfNestedResource(this, 'preprint', 'bibliographicContributors', { | |
path: '/preprints/:parentID/bibliographic_contributors/', | |
defaultSortKey: 'index', | |
relatedModelName: 'contributor', | |
}); | |
osfNestedResource(this, 'preprint', 'files', { | |
path: '/preprints/:parentID/files/', | |
defaultSortKey: 'index', | |
relatedModelName: 'file', | |
}); | |
osfNestedResource(this, 'preprint', 'affiliatedInstitutions', { | |
path: '/preprints/:parentID/institutions/', | |
defaultSortKey: 'index', | |
relatedModelName: 'institution', | |
}); | |
osfToManyRelationship(this, 'preprint', 'affiliatedInstitutions', { | |
only: ['related', 'update', 'add', 'remove'], | |
path: '/preprints/:parentID/relationships/institutions', | |
}); | |
this.put('/preprints/:parentID/files/:fileProviderId/upload', uploadToRoot); // Upload to file provider | |
osfNestedResource(this, 'preprint', 'primaryFile', { | |
path: '/wb/files/:fileID/', | |
defaultSortKey: 'index', | |
relatedModelName: 'file', | |
}); | |
osfToManyRelationship(this, 'preprint', 'subjects', { | |
only: ['related', 'self', 'update'], | |
}); | |
osfNestedResource(this, 'preprint', 'identifiers', { | |
path: '/preprints/:parentID/identifiers/', | |
defaultSortKey: 'index', | |
relatedModelName: 'identifier', | |
}); | |
this.get('/preprints/:guid/citation/:citationStyleID', getCitation); | |
/** | |
* Preprint Review Actions | |
*/ | |
osfNestedResource(this, 'preprint', 'reviewActions', { | |
path: '/preprints/:parentID/review_actions/', | |
defaultSortKey: 'index', | |
relatedModelName: 'review-action', | |
}); | |
/** | |
* Preprint Requests | |
*/ | |
osfNestedResource(this, 'preprint', 'requests', { | |
path: '/preprints/:parentID/requests/', | |
defaultSortKey: 'index', | |
relatedModelName: 'preprint-request', | |
}); | |
/** | |
* Preprint Request Actions | |
*/ | |
osfResource(this, 'preprint-request', {path: '/requests'}); | |
osfNestedResource(this, 'preprint-request', 'actions', { | |
path: '/requests/:parentID/actions', | |
relatedModelName: 'preprint-request-action', | |
}); | |
/** | |
* End Preprint Details | |
*/ | |
osfResource(this, 'registration-provider', { path: '/providers/registrations' }); | |
osfNestedResource(this, 'registration-provider', 'moderators', { | |
only: ['index', 'show', 'update', 'delete'], | |
path: '/providers/registrations/:parentID/moderators/', | |
relatedModelName: 'moderator', | |
}); | |
this.post('providers/registrations/:parentID/moderators', addRegistrationModerator); | |
osfNestedResource(this, 'registration-provider', 'subscriptions', { | |
path: '/providers/registrations/:parentID/subscriptions', | |
only: ['index'], | |
}); | |
osfNestedResource(this, 'registration-provider', 'registrations', { | |
only: ['show', 'update', 'delete'], | |
path: '/providers/registrations/:parentID/registrations/', | |
relatedModelName: 'registration', | |
}); | |
this.get('/providers/registrations/:parentID/registrations/', getProviderRegistrations); | |
osfNestedResource(this, 'registration-provider', 'licensesAcceptable', { | |
only: ['index'], | |
path: '/providers/registrations/:parentID/licenses/', | |
relatedModelName: 'license', | |
}); | |
this.get('/providers/registrations/:parentID/subjects/', getProviderSubjects); | |
osfNestedResource(this, 'registration-provider', 'schemas', { | |
only: ['index'], | |
path: '/providers/registrations/:parentID/schemas/', | |
relatedModelName: 'registration-schema', | |
}); | |
this.get('/providers/registrations/:parentID/subjects/', getProviderSubjects); | |
osfResource(this, 'collection-provider', { path: '/providers/collections' }); | |
osfNestedResource(this, 'collection-provider', 'moderators', { | |
path: '/providers/collections/:parentID/moderators', | |
except: ['create'], | |
relatedModelName: 'moderator', | |
}); | |
osfNestedResource(this, 'collection-provider', 'subscriptions', { | |
path: '/providers/collections/:parentID/subscriptions', | |
only: ['index'], | |
}); | |
this.post('providers/collections/:parentID/moderators', addCollectionModerator); | |
osfNestedResource(this, 'collection-provider', 'licensesAcceptable', { | |
path: 'providers/collections/:parentID/licenses/', | |
}); | |
osfNestedResource(this, 'collection', 'collectionSubmissions', { | |
path: 'collections/:parentID/collection_submissions/', | |
}); | |
this.get('collections/:parentID/collection_submissions', getCollectionSubmissions); | |
this.post('collections/:parentID/collection_submissions/', createCollectionSubmission); | |
this.post('/search/collections/', searchCollections); | |
osfResource(this, 'collection-submission', { | |
only: ['index', 'show', 'update', 'delete'], | |
path: '/collection_submissions', | |
}); | |
osfNestedResource(this, 'collection-submission', 'collectionSubmissionActions', { | |
only: ['index'], | |
path: '/collection_submissions/:parentID/actions', | |
relatedModelName: 'collection-submission-action', | |
}); | |
this.post('/collection_submission_actions/', createSubmissionAction); | |
osfResource(this, 'collection-submission-action', { | |
only: ['show'], | |
}); | |
osfResource(this, 'custom-file-metadata-record', { only: ['show', 'update'] }); | |
osfResource(this, 'custom-item-metadata-record', { only: ['show', 'update'] }); | |
osfResource(this, 'resource', { except: ['index', 'update', 'create'] }); | |
this.patch('/resources/:id', updateResource); | |
this.post('/resources/', createResource); | |
osfNestedResource(this, 'registration', 'resources', { | |
only: ['index'], | |
path: '/registrations/:parentID/resources', | |
}); | |
osfResource(this, 'subscription', { only: ['index', 'show', 'update'] }); | |
osfResource(this, 'collection-subscription', { only: ['show', 'update'] }); | |
osfResource(this, 'registration-subscription', { only: ['show', 'update'] }); | |
// Waterbutler namespace | |
this.namespace = '/wb'; | |
this.post('/files/:id/move', wb.moveFile); | |
this.post('/files/:id/upload', wb.renameFile); | |
this.put('/files/:id/upload', uploadToFolder); | |
this.get('/files/:id/upload/', wb.fileVersions); | |
this.del('/files/:id/delete', wb.deleteFile); | |
// Private namespace | |
this.namespace = '/_'; | |
osfResource(this, 'cedar-metadata-template', {only: ['index', 'show'] }); | |
osfResource(this, 'cedar-metadata-record', {only: ['index', 'show', 'update', 'create'] }); | |
this.get('/banners/current/', () => ({ | |
data: { | |
attributes: { | |
}, | |
type: 'banners', | |
id: '', | |
}, | |
})); | |
osfResource(this, 'meeting', { only: ['index', 'show'] }); | |
osfToManyRelationship(this, 'meeting', 'submissions', { | |
only: ['related'], | |
path: '/meetings/:parentID/submissions/', | |
}); | |
// usage reporting | |
this.post('/metrics/events/counted_usage/', postCountedUsage); | |
// node analytics | |
this.get('/metrics/query/node_analytics/:nodeID/:timespan', getNodeAnalytics); | |
} | |
--- End of File --- | |
--- Contents of ../ember-osf-web/mirage/scenarios/dashboard.ts --- | |
import { ModelInstance, Server } from 'ember-cli-mirage'; | |
import config from 'ember-osf-web/config/environment'; | |
import { MirageNode } from 'ember-osf-web/mirage/factories/node'; | |
import FileProviderModel from 'ember-osf-web/models/file-provider'; | |
import NodeModel from 'ember-osf-web/models/node'; | |
import { Permission } from 'ember-osf-web/models/osf-model'; | |
import User from 'ember-osf-web/models/user'; | |
const { | |
dashboard: { | |
noteworthyNode, | |
popularNode, | |
}, | |
} = config; | |
export function dashboardScenario(server: Server, currentUser: ModelInstance<User>) { | |
server.create('user-setting', { user: currentUser }); | |
const firstNode = server.create('node', 'withAffiliatedInstitutions'); | |
server.create('contributor', { node: firstNode, users: currentUser, index: 0 }); | |
const component = server.create('node', {id: 'cmpnt', parent: firstNode}, 'withFiles', 'withStorage'); | |
server.create('contributor', { node: component, users: currentUser, index: 0, permission: Permission.Admin }); | |
const nodes = server.createList('node', 10, { | |
currentUserPermissions: Object.values(Permission), | |
}, 'withContributors'); | |
for (const node of nodes) { | |
server.create('contributor', { | |
node, | |
users: currentUser, | |
permission: Permission.Admin, | |
index: 0, | |
}); | |
} | |
server.create('node', { | |
id: noteworthyNode, | |
linkedNodes: nodes.slice(0, 5), | |
title: 'NNW', | |
currentUserPermissions: [Permission.Read], | |
}); | |
server.create('node', { | |
id: popularNode, | |
linkedNodes: nodes.slice(5, 10), | |
title: 'Popular', | |
currentUserPermissions: [Permission.Read], | |
}); | |
for (const node of nodes.slice(4, 10)) { | |
server.create('contributor', { node, users: currentUser, index: 11 }); | |
} | |
const filesNode = server.create('node', { | |
id: 'file5', | |
title: 'With some files', | |
boaEnabled: true, | |
currentUserPermissions: [Permission.Read, Permission.Write, Permission.Admin], | |
}, 'withFiles', 'withStorage', 'withContributors', 'withAffiliatedInstitutions', 'withDoi', 'withLinkedByNodes'); | |
const filesNodeOsfStorage = filesNode.files.models.filter( | |
(provider: ModelInstance<FileProviderModel>) => provider.name === 'osfstorage', | |
)[0] as ModelInstance<FileProviderModel>; | |
server.create('file', { | |
id: 'snake', | |
name: 'snake.boa', | |
checkout: currentUser.id, | |
target: filesNode, | |
parentFolder: filesNodeOsfStorage.rootFolder, | |
}); | |
server.create('contributor', { | |
node: filesNode, | |
users: currentUser, | |
permission: Permission.Admin, | |
index: 0, | |
}); | |
create0CedarMetadataFile(server, currentUser, filesNode, filesNodeOsfStorage); | |
create3CedarMetadataFile(server, currentUser); | |
create12CedarMetadataFile(server, currentUser, filesNode, filesNodeOsfStorage); | |
// NOTE: Some institutions are already created by this point | |
server.createList('institution', 20); | |
// Create a specific institution to test institutional dashboard with; should be ID 29 at this point | |
server.create('institution', { | |
id: 'has_users', | |
iris: ['http://ror.org/has_users'], | |
}, 'withMetrics'); | |
} | |
function create0CedarMetadataFile(server: Server, currentUser: ModelInstance<User>, | |
filesNode: ModelInstance<NodeModel & MirageNode>, filesNodeOsfStorage: ModelInstance<FileProviderModel>): void { | |
server.create('file', { | |
id: '0-cedar-metadata-file', | |
name: 'cedar metadata file with no records', | |
checkout: currentUser.id, | |
target: filesNode, | |
parentFolder: filesNodeOsfStorage.rootFolder, | |
}); | |
} | |
function create3CedarMetadataFile(server: Server, currentUser: ModelInstance<User>): void { | |
const filesNode = server.create('node', { | |
id: 'read-only', | |
title: 'Read-only user and non-admin and a super long name to see if there is overflow into the right nav area', | |
boaEnabled: true, | |
currentUserPermissions: [Permission.Read], | |
}, 'withFiles', 'withStorage', 'withContributors', 'withAffiliatedInstitutions', 'withDoi', 'withLinkedByNodes'); | |
const filesNodeOsfStorage = filesNode.files.models.filter( | |
(provider: ModelInstance<FileProviderModel>) => provider.name === 'osfstorage', | |
)[0] as ModelInstance<FileProviderModel>; | |
const cedarFileNode = server.create('file', { | |
id: '3-cedar-metadata-file', | |
// eslint-disable-next-line max-len | |
name: 'Cedar Metadata File on a read-only user and non-admin with a super long name to see if there is overflow in the right nav area', | |
checkout: currentUser.id, | |
target: filesNode, | |
parentFolder: filesNodeOsfStorage.rootFolder, | |
}); | |
const cedarMetadataRecords = server.createList('cedar-metadata-record', 2); | |
cedarMetadataRecords.push(server.create('cedar-metadata-record', 'isTesting')); | |
cedarFileNode.update({ | |
cedarMetadataRecords, | |
}); | |
} | |
function create12CedarMetadataFile(server: Server, currentUser: ModelInstance<User>, | |
filesNode: ModelInstance<NodeModel & MirageNode>, filesNodeOsfStorage: ModelInstance<FileProviderModel>): void { | |
const cedarFileNode = server.create('file', { | |
id: '12-cedar-metadata-file', | |
name: 'cedar metadata file', | |
checkout: currentUser.id, | |
target: filesNode, | |
parentFolder: filesNodeOsfStorage.rootFolder, | |
}); | |
const cedarMetadataRecords = server.createList('cedar-metadata-record', 8); | |
cedarMetadataRecords.push(server.create('cedar-metadata-record', 'isDraft')); | |
cedarMetadataRecords.push(server.create('cedar-metadata-record', 'isDraft')); | |
cedarMetadataRecords.push(server.create('cedar-metadata-record', 'isDraft')); | |
cedarMetadataRecords.push(server.create('cedar-metadata-record', 'isTesting')); | |
cedarFileNode.update({ | |
cedarMetadataRecords, | |
}); | |
} | |
--- End of File --- | |
--- Contents of ../ember-osf-web/mirage/views/search.ts --- | |
import { Request, Schema } from 'ember-cli-mirage'; | |
import faker from 'faker'; | |
import { PaginationLinks } from 'jsonapi-typescript'; | |
import { AttributionRoleIris, OsfmapResourceTypes } from 'ember-osf-web/models/index-card'; | |
import config from 'ember-osf-web/config/environment'; | |
import { guid } from '../factories/utils'; | |
const osfUrl = config.OSF.url; | |
const sampleStorageRegions = ['United States', 'Australia - Sydney', 'Germany - Frankfurt']; | |
const resourceMetadataByType: Partial<Record<OsfmapResourceTypes, any>> = { | |
Registration: () => { | |
const contributor = _sharePersonField(); | |
return { | |
'@id': faker.random.uuid(), | |
// accessService: [{}], | |
archivedAt: [{}], // archive.org URL | |
conformsTo: [{ // Registration Schema | |
'@id': 'https://api.osf.io/v2/schemas/registrations/564d31db8c5e4a7c9694b2be/', | |
title: [{ | |
'@value': 'Open-Ended Registration', | |
}], | |
}], | |
creator: [contributor], | |
dateAvailable: [_shareDateField()], | |
dateCopyrighted: [_shareDateField()], | |
dateCreated: [_shareDateField()], | |
dateModified: [_shareDateField()], | |
description: [{ | |
'@value': faker.lorem.sentence(), | |
}], | |
funder: [_shareOrganizationField()], | |
hasPart: [{}], // RegistrationComponent | |
hostingInstition: [_shareOrganizationField()], | |
identifier: [_shareIdentifierField(), _shareOsfIdentifier()], | |
isVersionOf: [{}], // if this is from a project | |
keyword: [{ // tags | |
'@value': faker.random.word(), | |
}], | |
publisher: [_shareOrganizationField()], // Registration Provider | |
qualifiedAttribution: [{ | |
agent: [contributor], | |
hadRole: [{ | |
'@id': faker.random.arrayElement(Object.values(AttributionRoleIris)), | |
}], | |
}], | |
resourceNature: [{ // Registration Category | |
'@id': 'https://schema.datacite.org/meta/kernel-4/#StudyRegistration', | |
displayLabel: [{ | |
'@value': 'StudyRegistration', | |
'@language': 'en', | |
}], | |
}], | |
resourceType: [{ '@id': 'Registration' }], | |
rights: [_shareLicenseField()], | |
sameAs: [{}], // some DOI | |
storageByteCount: [{ | |
'@value': faker.random.number(), | |
}], | |
storageRegion: [{ | |
prefLabel: [{ | |
'@value': faker.random.arrayElement(sampleStorageRegions), | |
}], | |
}], | |
subject: [_shareSubjectField()], | |
title: [{ | |
'@value': faker.lorem.words(3), | |
}], | |
usage: [_shareUsageReportField()], | |
}; | |
}, | |
Project: () => { | |
const contributor = _sharePersonField(); | |
const contributor2 = _sharePersonField(); | |
return { | |
'@id': fakeNodeIdentifier(), | |
// accessService: [{}], | |
creator: [contributor], | |
dateCopyrighted: [_shareDateField()], | |
dateCreated: [_shareDateField()], | |
dateModified: [_shareDateField()], | |
description: [{ | |
'@value': faker.lorem.sentence(), | |
}], | |
funder: [_shareOrganizationField()], | |
hasOsfAddon: [ | |
{ | |
prefLabel: [{ | |
'@value': 'Box', | |
}], | |
}, | |
], | |
hasPart: [{}], // ProjectComponent | |
hostingInstition: [_shareOrganizationField()], | |
identifier: [_shareIdentifierField(), _shareOsfIdentifier()], | |
keyword: [{ // tags | |
'@value': faker.random.word(), | |
}], | |
publisher: [_shareOrganizationField()], | |
qualifiedAttribution: [{ | |
agent: [contributor, contributor2], | |
hadRole: [{ | |
'@id': faker.random.arrayElement(Object.values(AttributionRoleIris)), | |
}], | |
}], | |
resourceNature: [{ | |
'@id': 'https://schema.datacite.org/meta/kernel-4/#Dataset', | |
displayLabel: [ | |
{ | |
'@value': faker.random.arrayElement(['Dataset', 'JournalArticle', 'Book']), | |
'@language': 'en', | |
}, | |
], | |
}], | |
resourceType: [{ '@id': 'Project' }], | |
rights: [_shareLicenseField()], | |
sameAs: [{}], // some DOI | |
storageByteCount: [{ | |
'@value': faker.random.number(), | |
}], | |
storageRegion: [{ | |
prefLabel: [{ | |
'@value': faker.random.arrayElement(sampleStorageRegions), | |
}], | |
}], | |
subject: [_shareSubjectField()], | |
title: [{ | |
'@value': faker.lorem.words(3), | |
}], | |
usage: [_shareUsageReportField()], | |
}; | |
}, | |
Preprint: () => { | |
const contributor = _sharePersonField(); | |
return { | |
'@id': faker.internet.url(), | |
// accessService: [{}], | |
creator: [contributor], | |
dateAccepted: [_shareDateField()], | |
dateCopyrighted: [_shareDateField()], | |
dateCreated: [_shareDateField()], | |
dateSubmitted: [_shareDateField()], | |
dateModified: [_shareDateField()], | |
description: [{ | |
'@value': faker.lorem.sentence(), | |
}], | |
hasPart: [{}], // File | |
hostingInstition: [_shareOrganizationField()], | |
identifier: [_shareIdentifierField(), _shareOsfIdentifier()], | |
// isSupplementedBy: [{}], // if this links a project | |
keyword: [{ // tags | |
'@value': faker.random.word(), | |
}], | |
omits: [{ | |
ommittedMetadataProperty: [ | |
{ '@id': 'hasPreregisteredStudyDesign' }, | |
{ '@id': 'hasPreregisteredAnalysisPlan' }, | |
], | |
}], | |
publisher: [_shareOrganizationField()], // Preprint Provider | |
qualifiedAttribution: [{ | |
agent: [contributor], | |
hadRole: [{ | |
'@id': faker.random.arrayElement(Object.values(AttributionRoleIris)), | |
}], | |
}], | |
resourceNature: [{ | |
'@id': 'https://schema.datacite.org/meta/kernel-4/#Preprint', | |
displayLabel: [{ | |
'@value': 'Preprint', | |
'@language': 'en', | |
}], | |
}], | |
resourceType: [{ '@id': 'Preprint' }], | |
rights: [_shareLicenseField()], | |
sameAs: [{}], // some DOI | |
statedConflictOfInterest: [{ | |
'@id': 'no-confict-of-interest', | |
}], | |
subject: [_shareSubjectField()], | |
title: [{ | |
'@value': faker.lorem.words(3), | |
}], | |
usage: [_shareUsageReportField()], | |
}; | |
}, | |
Agent: () => ({ | |
'@id': fakeOsfIdentifier(), | |
// accessService: [{}], | |
affiliation: [_shareOrganizationField()], | |
identifier: [ | |
_shareIdentifierField(), | |
{ | |
'@value': 'https://orcid.org/0000-0000-0000-0000', | |
}, | |
_shareOsfIdentifier(), | |
], | |
name: [{ | |
'@value': faker.name.findName(), | |
}], | |
resourceType: [{ '@id': OsfmapResourceTypes.Person }, { '@id': OsfmapResourceTypes.Agent }], | |
sameAs: [{ '@id': 'https://orcid.org/0000-0000-0000-0000' }], // some ORCID | |
}), | |
}; | |
resourceMetadataByType.ProjectComponent = function() { | |
return { | |
...resourceMetadataByType.Project(), | |
resourceType: [{ '@id': 'ProjectComponent' }], | |
isPartOf: [{ // Parent Project | |
...resourceMetadataByType.Project(), | |
}], | |
hasRoot: [{ // Root Project | |
...resourceMetadataByType.Project(), | |
}], | |
}; | |
}; | |
resourceMetadataByType.RegistrationComponent = function() { | |
return { | |
...resourceMetadataByType.Registration(), | |
resourceType: [{ '@id': 'RegistrationComponent' }], | |
isPartOf: [{ // Parent Registration | |
...resourceMetadataByType.Registration(), | |
}], | |
hasRoot: [{ // Root Registration | |
...resourceMetadataByType.Registration(), | |
}], | |
}; | |
}; | |
resourceMetadataByType.File = function() { | |
return { | |
'@id': faker.internet.url(), | |
// accessService: [{}], | |
dateCreated: [_shareDateField()], | |
dateModified: [_shareDateField()], | |
description: [{ | |
'@value': faker.lorem.sentence(), | |
}], | |
fileName: [{ | |
'@value': faker.system.fileName(), | |
}], | |
filePath: [{ | |
'@value': faker.system.filePath(), | |
}], | |
identifier: [_shareIdentifierField(), _shareOsfIdentifier()], | |
isContainedBy: [{ // Parent Project | |
...resourceMetadataByType.Project(), | |
}], | |
language: [{ | |
'@value': 'eng', | |
}], | |
// 'osf:hasFileVersion': [{}], // FileVersion | |
resourceNature: [{ | |
'@id': 'https://schema.datacite.org/meta/kernel-4/#Dataset', | |
displayLabel: [{ | |
'@value': 'Dataset', | |
'@language': 'en', | |
}], | |
}], | |
resourceType: [{ '@id': 'File' }], | |
title: [{ | |
'@value': faker.lorem.words(3), | |
}], | |
}; | |
}; | |
export function cardSearch(_: Schema, request: Request) { | |
const {queryParams} = request; | |
const pageCursor = queryParams['page[cursor]']; | |
const pageSize = queryParams['page[size]'] ? parseInt(queryParams['page[size]'], 10) : 10; | |
// cardSearchFilter[resourceType] is a comma-separated list (e.g. 'Project,ProjectComponent') or undefined | |
let requestedResourceTypes = queryParams['cardSearchFilter[resourceType]']?.split(',') as OsfmapResourceTypes[]; | |
if (!requestedResourceTypes) { | |
requestedResourceTypes = Object.keys(resourceMetadataByType) as OsfmapResourceTypes[]; | |
} | |
const indexCardSearchId = faker.random.uuid(); | |
const indexCardSearch = { | |
data: { | |
type: 'index-card-search', | |
id:indexCardSearchId, | |
attributes: { | |
cardSearchText: 'hello', | |
cardSearchFilter: [ | |
{ | |
osfmapPropertyPath: 'resourceType', | |
filterType: 'eq', | |
filterValues: [ | |
'osf:Registration', | |
], | |
}, | |
{ | |
osfmapPropertyPath: 'subject', | |
filterType: 'eq', | |
filterValues: [ | |
'https://subjects.org/subjectId', | |
], | |
}, | |
], | |
totalResultCount: 10, | |
}, | |
relationships: { | |
relatedProperties: { | |
data: [ | |
{ | |
type: 'related-property-path', | |
id: 'propertyMatch1', | |
}, | |
{ | |
type: 'related-property-path', | |
id: 'propertyMatch2', | |
}, | |
{ | |
type: 'related-property-path', | |
id: 'propertyMatch3', | |
}, | |
], | |
links: { | |
next: { | |
href: 'https://staging-share.osf.io/trove/index-card-search?page%5Bcursor%5D=lmnop', | |
}, | |
}, | |
}, | |
searchResultPage: {}, | |
}, | |
links: { | |
self: `https://share.osf.io/api/v2/index-card-search/${indexCardSearchId}`, | |
}, | |
}, | |
included: [ | |
// Related properties | |
{ | |
type: 'related-property-path', | |
id: 'propertyMatch1', | |
attributes: { | |
propertyPathKey: 'rights', | |
matchEvidence: [ | |
{ | |
'@type': ['https://share.osf.io/vocab/2023/trove/IriMatchEvidence'], | |
osfmapPropertyPath: 'resourceType', | |
matchingIri: 'rdf:Property', | |
}, | |
], | |
cardSearchResultCount: 345, | |
propertyPath: [ | |
{ | |
'@id': 'http://purl.org/dc/terms/license', | |
resourceType: [ | |
{ | |
'@id': 'Property', | |
}, | |
], | |
displayLabel: [ | |
{ | |
'@value': 'License', | |
'@language': 'en', | |
}, | |
], | |
shortFormLabel: [ | |
{ | |
'@value': 'rights', | |
'@language': 'en', | |
}, | |
], | |
}, | |
], | |
suggestedFilterOperator: 'any-of', | |
}, | |
}, | |
{ | |
type: 'related-property-path', | |
id: 'propertyMatch2', | |
attributes: { | |
propertyPathKey: 'datePublished', | |
matchEvidence: [ | |
{ | |
'@type': ['https://share.osf.io/vocab/2023/trove/IriMatchEvidence'], | |
osfmapPropertyPath: 'resourceType', | |
matchingIri: 'rdf:Property', | |
}, | |
], | |
cardSearchResultCount: 123, | |
propertyPath: [ | |
{ | |
'@id': 'http://purl.org/dc/terms/published', | |
resourceType: [ | |
{ | |
'@id': 'Property', | |
}, | |
], | |
displayLabel: [ | |
{ | |
'@value': 'Date Published', | |
'@language': 'en', | |
}, | |
], | |
shortFormLabel: [ | |
{ | |
'@value': 'datePublished', | |
'@language': 'en', | |
}, | |
], | |
}, | |
], | |
suggestedFilterOperator: 'any-of', | |
}, | |
}, | |
{ | |
type: 'related-property-path', | |
id: 'propertyMatch3', | |
attributes: { | |
propertyPathKey: 'funder', | |
matchEvidence: [ | |
{ | |
'@type': ['https://share.osf.io/vocab/2023/trove/IriMatchEvidence'], | |
osfmapPropertyPath: 'resourceType', | |
matchingIri: 'rdf:Property', | |
}, | |
], | |
cardSearchResultCount: 33, | |
propertyPath: [ | |
{ | |
'@id': 'http://purl.org/dc/terms/funder', | |
resourceType: [ | |
{ | |
'@id': 'Property', | |
}, | |
], | |
displayLabel: [ | |
{ | |
'@value': 'Funder', | |
'@language': 'en', | |
}, | |
], | |
shortFormLabel: [ | |
{ | |
'@value': 'funder', | |
'@language': 'en', | |
}, | |
], | |
}, | |
], | |
suggestedFilterOperator: 'any-of', | |
}, | |
}, | |
], | |
}; | |
const searchResultPageRelationship = { data: [] as any[], links: {} as PaginationLinks}; | |
const includedSearchResultPage: any[] = []; | |
const includedIndexCard: any[] = []; | |
Array.from({ length: pageSize }).forEach(() => { | |
const searchResultId = faker.random.uuid(); | |
const indexCardId = faker.random.uuid(); | |
const indexCardURL = `https://share.osf.io/api/v2/index-card/${indexCardId}`; | |
searchResultPageRelationship.data.push({ | |
type: 'search-result', | |
id: searchResultId, | |
}); | |
includedSearchResultPage.push({ | |
type: 'search-result', | |
id: searchResultId, | |
attributes: { | |
matchEvidence: [ | |
{ | |
'@type': ['https://share.osf.io/vocab/2023/trove/TextMatchEvidence'], | |
evidenceCardIdentifier: indexCardURL, | |
matchingHighlight: [`...<em>${faker.lorem.word()}</em>...`], | |
osfmapPropertyPath: ['description'], | |
propertyPathKey: 'description', | |
}, | |
], | |
}, | |
relationships: { | |
indexCard: { | |
data: { | |
type: 'index-card', | |
id: indexCardId, | |
}, | |
links: { | |
related: indexCardURL, | |
}, | |
}, | |
}, | |
}); | |
// pick a random resource type among the possible ones requested | |
const requestedResourceType: OsfmapResourceTypes | |
= requestedResourceTypes[Math.floor(Math.random() * requestedResourceTypes.length)]; | |
const resourceTypeMetadata = resourceMetadataByType[requestedResourceType]; | |
const osfGuid = fakeOsfIdentifier(); | |
includedIndexCard.push({ | |
type: 'index-card', | |
id: indexCardId, | |
attributes: { | |
resourceIdentifier: [ | |
indexCardURL, | |
`https://doi.org/10.0000/osf.example/${indexCardId}`, | |
osfGuid, | |
], | |
resourceMetadata: resourceTypeMetadata(), | |
}, | |
links: { | |
self: indexCardURL, | |
resource: `https://osf.example/${indexCardId}`, | |
}, | |
}); | |
}); | |
const cursorizedUrl = new URL(request.url); | |
cursorizedUrl.searchParams.set('page[cursor]', faker.random.uuid()); | |
searchResultPageRelationship.links = { | |
next: { | |
href: cursorizedUrl.toString(), | |
}, | |
}; | |
if (pageCursor) { | |
searchResultPageRelationship.links.prev = { | |
href: cursorizedUrl.toString(), | |
}; | |
searchResultPageRelationship.links.first = { | |
href: cursorizedUrl.toString(), | |
}; | |
} | |
indexCardSearch.data.relationships.searchResultPage = searchResultPageRelationship; | |
indexCardSearch.included.push(...includedSearchResultPage, ...includedIndexCard); | |
return indexCardSearch; | |
} | |
export function valueSearch(_: Schema, __: Request) { | |
const property1Id = faker.random.uuid(); | |
const property2Id = faker.random.uuid(); | |
return { | |
data: { | |
type: 'index-value-search', | |
id: 'lmnop', | |
attributes: { | |
valueSearchText: 'Institute of Health', | |
valueSearchFilter: [ | |
{ | |
osfmapPropertyPath: 'resourceType', | |
filterType: 'eq', | |
filterValues: ['datacite:Funder'], | |
}, | |
], | |
cardSearchText: 'influenza', | |
cardSearchFilter: [ | |
{ | |
osfmapPropertyPath: 'resourceType', | |
filterType: 'eq', | |
filterValues: ['datacite:Dataset'], | |
}, | |
], | |
totalResultCount: 2, | |
}, | |
relationships: { | |
searchResultPage: { | |
data: [ | |
{type: 'search-result', id: property1Id}, | |
{type: 'search-result', id: property2Id}, | |
], | |
links: { | |
next: { | |
href: 'https://staging-share.osf.io/trove/index-value-search?page%5Bcursor%5D=lmnop', | |
}, | |
}, | |
}, | |
}, | |
}, | |
included: [ | |
{ | |
type: 'search-result', | |
id: property1Id, | |
attributes: { | |
matchEvidence: [ | |
{ | |
'@type': ['https://share.osf.io/vocab/2023/trove/TextMatchEvidence'], | |
osfmapPropertyPath: 'title', | |
matchingHighlight: 'National <em>Institute of Health</em>', | |
}, | |
], | |
cardSearchResultCount: 3, | |
}, | |
relationships: { | |
indexCard: { | |
data: {type: 'index-card', id: property1Id}, | |
links: {related: 'https://share.osf.example/index-card/abc'}, | |
}, | |
}, | |
}, | |
{ | |
type: 'search-result', | |
id: property2Id, | |
attributes: { | |
matchEvidence: [ | |
{ | |
'@type': ['https://share.osf.io/vocab/2023/trove/TextMatchEvidence'], | |
osfmapPropertyPath: 'title', | |
matchingHighlight: 'Virginia <em>Institute of Health</em>', | |
}, | |
], | |
cardSearchResultCount: 2, | |
}, | |
relationships: { | |
indexCard: { | |
data: {type: 'index-card', id: property2Id}, | |
links: {related: 'https://share.osf.example/index-card/def'}, | |
}, | |
}, | |
}, | |
{ | |
type: 'index-card', | |
id: property1Id, | |
attributes: { | |
resourceType: 'osf:Funder', | |
resourceIdentifier: ['http://dx.doi.org/10.10000/505000005050'], | |
resourceMetadata: { | |
'@id': 'http://dx.doi.org/10.10000/505000005050', | |
'@type': 'datacite:Funder', | |
title: [{'@value': faker.lorem.words(3), '@language':'en'}], | |
}, | |
}, | |
}, | |
{ | |
type: 'index-card', | |
id: property2Id, | |
attributes: { | |
resourceType: 'osf:Funder', | |
resourceIdentifier: ['https://doi.org/10.10000/100000001'], | |
resourceMetadata: { | |
'@id': 'http://dx.doi.org/10.10000/100000001', | |
'@type': 'datacite:Funder', | |
title: [{'@value':faker.lorem.word(), '@language':'en'}], | |
}, | |
}, | |
}, | |
], | |
}; | |
} | |
function _sharePersonField() { | |
const fakeIdentifier = fakeUserIdentifier(); | |
return { | |
'@id': fakeIdentifier, | |
resourceType: [{ '@id': OsfmapResourceTypes.Person }, { '@id': OsfmapResourceTypes.Agent }], | |
identifier: [ | |
{ | |
'@value': 'https://orcid.org/0000-0000-0000-0000', // hard-coded as search-result looks for orcid URL | |
}, | |
_shareIdentifierField(fakeIdentifier), | |
], | |
// Pass an IRI to the _shareOrganizationField to create an organization with the same IRI | |
// as one specified in your mirage scenario | |
// e.g. in mirage scenario: server.create('institution', { iris: ['http://ror.org/has_users']}); | |
affiliation: [_shareOrganizationField('http://ror.org/has_users')], | |
name: [{ | |
'@value': faker.name.findName(), | |
}], | |
}; | |
} | |
function _shareOrganizationField(orgId?: string) { | |
const identifier = orgId || faker.internet.url(); | |
return { | |
'@id': identifier, | |
resourceType: [{ '@id': OsfmapResourceTypes.Organization }, { '@id': OsfmapResourceTypes.Agent }], | |
identifier: [_shareIdentifierField(identifier)], | |
name: [{ | |
'@value': faker.company.companyName(), | |
}], | |
// sameAs: [{}], // some ROR | |
}; | |
} | |
function _shareIdentifierField(idValue?: string) { | |
return { | |
'@value': idValue || faker.internet.url(), | |
}; | |
} | |
function fakeOsfIdentifier() { | |
const possibleGuids = ['24fxu',]; // List of possible five-character IDs | |
const randomGuid = possibleGuids[Math.floor(Math.random() * possibleGuids.length)]; | |
return `${osfUrl}${randomGuid}/`; | |
} | |
function fakeUserIdentifier() { | |
const possibleGuids = ['uhgtw']; // List of possible five-character IDs | |
const randomGuid = possibleGuids[Math.floor(Math.random() * possibleGuids.length)]; | |
return `${osfUrl}${randomGuid}/`; | |
} | |
function fakeNodeIdentifier() { | |
const possibleGuids = ['f5sq7']; // List of possible five-character IDs | |
const randomGuid = possibleGuids[Math.floor(Math.random() * possibleGuids.length)]; | |
return `${osfUrl}${randomGuid}/`; | |
} | |
function _shareOsfIdentifier(identifier?: string) { | |
return { | |
'@value': identifier || fakeOsfIdentifier(), | |
}; | |
} | |
function _shareDateField() { | |
return { | |
'@value': _randomPastYearMonthDay(), | |
}; | |
} | |
function _shareLicenseField() { | |
return { | |
'@id': 'http://creativecommons.org/licenses/by/4.0/', | |
identifier: [{ | |
'@value': 'http://creativecommons.org/licenses/by/4.0/', | |
}], | |
name: [{ | |
'@value': 'CC-BY-4.0', | |
}], | |
}; | |
} | |
function _shareSubjectField() { | |
return { | |
'@id': 'https://api.osf.io/v2/subjects/584240da54be81056cecac48', | |
resourceType: [{ '@id': OsfmapResourceTypes.Concept }], | |
inScheme: [{ | |
'@id': 'https://api.osf.io/v2/schemas/subjects/', | |
resourceType: [{ '@id': OsfmapResourceTypes.ConceptScheme }], | |
title: [{ | |
'@value': 'bepress Digital Commons Three-Tiered Taxonomy', | |
}], | |
}], | |
prefLabel: [{ | |
'@value': 'Social and Behavioral Sciences', | |
}], | |
}; | |
} | |
function _shareUsageReportField() { | |
return { | |
temporalCoverage: [{ | |
'@value': _randomPastYearMonthDay().slice(0, 7), // YYYY-MM | |
}], | |
viewCount: [{ | |
'@value': faker.random.number(), | |
}], | |
downloadCount: [{ | |
'@value': faker.random.number(), | |
}], | |
viewSessionCount: [{ | |
'@value': faker.random.number(), | |
}], | |
downloadSessionCount: [{ | |
'@value': faker.random.number(), | |
}], | |
}; | |
} | |
function _randomPastYearMonthDay(): string { | |
return faker.date.past().toISOString().split('T')[0]; | |
} | |
--- End of File --- | |
--- Contents of ../ember-osf-web/tests/acceptance/institutions/dashboard-test.ts --- | |
import { currentURL, visit } from '@ember/test-helpers'; | |
import { setupMirage } from 'ember-cli-mirage/test-support'; | |
import { percySnapshot } from 'ember-percy'; | |
import { module, test } from 'qunit'; | |
import { click, setupOSFApplicationTest } from 'ember-osf-web/tests/helpers'; | |
const moduleName = 'Acceptance | institutions | dashboard'; | |
module(moduleName, hooks => { | |
setupOSFApplicationTest(hooks); | |
setupMirage(hooks); | |
test('institutions dashboard: page layout', async function(assert) { | |
server.create('institution', { | |
id: 'has_users', | |
}, 'withMetrics'); | |
await visit('/institutions/has_users/dashboard'); | |
assert.equal( | |
currentURL(), | |
'/institutions/has_users/dashboard', | |
"Still at '/institutions/has_users/dashboard'.", | |
); | |
assert.dom('[data-test-page-tab="summary"]').exists('Summary tab exists'); | |
assert.dom('[data-test-page-tab="users"]').exists('Users tab exists'); | |
assert.dom('[data-test-page-tab="projects"]').exists('Projects tab exists'); | |
assert.dom('[data-test-page-tab="registrations"]').exists('Regitrations tab exists'); | |
assert.dom('[data-test-page-tab="preprints"]').exists('Preprints tab exists'); | |
// Summary tab | |
await percySnapshot(`${moduleName} - summary`); | |
assert.dom('[data-test-page-tab="summary"]').hasClass('active', 'Summary tab is active by default'); | |
assert.dom('[data-test-summary-report-year-month]').exists('Report year month exists'); | |
// Users tab | |
await click('[data-test-page-tab="users"]'); | |
await percySnapshot(`${moduleName} - users`); | |
assert.dom('[data-test-page-tab="users"]').hasClass('active', 'Users tab is active'); | |
assert.dom('[data-test-link-to-reports-archive]').exists('Link to download prior reports exists'); | |
assert.dom('[data-test-download-dropdown]').exists('Link to download file formats'); | |
assert.dom('[data-test-user-report-year-month]').exists('User report year month exists'); | |
// Projects tab | |
await click('[data-test-page-tab="projects"]'); | |
await percySnapshot(`${moduleName} - projects`); | |
assert.dom('[data-test-page-tab="projects"]').hasClass('active', 'Projects tab is active'); | |
assert.dom('[data-test-link-to-reports-archive]').exists('Link to download prior reports exists'); | |
assert.dom('[data-test-download-dropdown]').exists('Link to download file formats'); | |
// Registrations tab | |
await click('[data-test-page-tab="registrations"]'); | |
await percySnapshot(`${moduleName} - registrations`); | |
assert.dom('[data-test-page-tab="registrations"]').hasClass('active', 'Registrations tab is active'); | |
assert.dom('[data-test-link-to-reports-archive]').exists('Link to download prior reports exists'); | |
assert.dom('[data-test-download-dropdown]').exists('Link to download file formats'); | |
// Preprints tab | |
await click('[data-test-page-tab="preprints"]'); | |
await percySnapshot(`${moduleName} - preprints`); | |
assert.dom('[data-test-page-tab="preprints"]').hasClass('active', 'Preprints tab is active'); | |
assert.dom('[data-test-link-to-reports-archive]').exists('Link to download prior reports exists'); | |
assert.dom('[data-test-download-dropdown]').exists('Link to download file formats'); | |
}); | |
test('institutions dashboard: projects, registrations, and preprints tab', async function(assert) { | |
server.create('institution', { | |
id: 'has_users', | |
}, 'withMetrics'); | |
await visit('/institutions/has_users/dashboard'); | |
for (const tab of ['projects', 'registrations', 'preprints']) { | |
await click(`[data-test-page-tab=${tab}]`); | |
assert.dom(`[data-test-page-tab=${tab}]`).hasClass('active', `${tab} tab is active`); | |
assert.dom('[data-test-object-list-table]').exists('Object list exists'); | |
assert.dom('[data-test-object-count]').exists('Object count exists'); | |
assert.dom('[data-test-toggle-filter-button]').exists('Filter button exists'); | |
assert.dom('[data-test-customize-columns-button]').exists('Customize columns button exists'); | |
} | |
}); | |
}); | |
--- End of File --- | |
--- Contents of ../ember-osf-web/tests/acceptance/institutions/discover-test.ts --- | |
import { currentURL, visit } from '@ember/test-helpers'; | |
import { setupMirage } from 'ember-cli-mirage/test-support'; | |
import { percySnapshot } from 'ember-percy'; | |
import { setBreakpoint } from 'ember-responsive/test-support'; | |
import { module, skip } from 'qunit'; | |
import { click, setupOSFApplicationTest} from 'ember-osf-web/tests/helpers'; | |
module('Acceptance | institutions | discover', hooks => { | |
setupOSFApplicationTest(hooks); | |
setupMirage(hooks); | |
skip('Desktop: Default colors', async assert => { | |
server.create('institution', { | |
id: 'has_users', | |
}, 'withMetrics'); | |
await visit('/institutions/has_users'); | |
// verify institutions route | |
assert.equal(currentURL(), '/institutions/has_users', 'Current route is institutions discover'); | |
assert.dom('[data-test-heading-wrapper]').exists('Institutions heading wrapper shown'); | |
// verify banner and description | |
assert.dom('[data-test-institution-banner]').exists('Institution banner shown'); | |
assert.dom('[data-test-institution-description]').exists('Institution description shown'); | |
// verify topbar and sort dropdown | |
assert.dom('[data-test-topbar-wrapper]').exists('Topbar not shown on mobile'); | |
assert.dom('[data-test-topbar-sort-dropdown]').exists('Sort dropdown shown on desktop'); | |
await percySnapshot(assert); | |
}); | |
skip('Mobile: Default colors', async assert => { | |
setBreakpoint('mobile'); | |
server.create('institution', { | |
id: 'has_users', | |
}, 'withMetrics'); | |
// verify institutions route | |
await visit('/institutions/has_users'); | |
assert.equal(currentURL(), '/institutions/has_users', 'Current route is institutions discover'); | |
// verify logo and description | |
assert.dom('[data-test-institution-banner]').exists('Institution banner shown'); | |
assert.dom('[data-test-institution-description]').exists('Institution description is shown'); | |
// verify mobile menu display | |
assert.dom('[data-test-topbar-wrapper]').doesNotExist('Topbar not shown on mobile'); | |
assert.dom('[data-test-toggle-side-panel]').exists('Institution header logo shown'); | |
await click('[data-test-toggle-side-panel]'); | |
// verify resource type and sort by dropdown | |
assert.dom('[data-test-left-panel-object-type-dropdown]').exists('Mobile resource type dropdown is shown'); | |
assert.dom('[data-test-left-panel-sort-dropdown]').exists('Mobile sort by dropdown is shown'); | |
await percySnapshot(assert); | |
}); | |
}); | |
--- End of File --- | |
Process finished with exit code 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment