31 lines
2.0 KiB
JavaScript
31 lines
2.0 KiB
JavaScript
const { test } = require('node:test')
|
|
const assert = require('node:assert/strict')
|
|
const fs = require('node:fs')
|
|
const path = require('node:path')
|
|
const root = path.resolve(__dirname, '../src')
|
|
const app = fs.readFileSync(path.join(root, 'renderer/src/App.tsx'), 'utf8')
|
|
const view = fs.readFileSync(path.join(root, 'renderer/src/features/workspace/ModuleListView.tsx'), 'utf8')
|
|
|
|
test('remote creation and Git import are enabled while raw folder import remains local', () => {
|
|
assert.match(app, /allowCustomModuleCreation=\{true\}/)
|
|
assert.match(app, /allowCustomModuleImport=\{true\}/)
|
|
assert.match(app, /remoteGitImport=\{remoteWorkspace \? \{ workspaceRoot: localVisualizationWorkspaceRoot, onImport: importGitModule \} : undefined\}/)
|
|
assert.match(view, /remoteGitImport \? <RemoteModuleImportDialog/)
|
|
assert.match(app, /const importCustomModule[\s\S]*?if \(remoteWorkspace\) throw new Error/)
|
|
const importButton = view.slice(view.indexOf('aria-label={t("모듈 불러오기")}'), view.indexOf('{deleteConfirmModule &&'))
|
|
assert.match(importButton, /disabled=\{!allowCustomModuleImport\}/)
|
|
assert.doesNotMatch(importButton, /allowCustomModuleCreation/)
|
|
assert.match(view, /allowCustomModuleImport && moduleImportDialogOpen/)
|
|
})
|
|
|
|
test('new module dialog requests images from the current workspace', () => {
|
|
assert.match(app, /loadDockerImages=\{\(\) => remoteWorkspace\s*\? window\.remoteWorkspace\.modules\.listDockerImages\(getRemoteWorkspaceTarget\(\)\)/)
|
|
const dialog = view.slice(view.indexOf('function ModuleAddDialog('), view.indexOf('function ModuleImportDialog('))
|
|
assert.match(dialog, /void loadDockerImages\(\)/)
|
|
assert.doesNotMatch(dialog, /window\.localWorkspace/)
|
|
const preload = fs.readFileSync(path.join(root, 'preload/index.ts'), 'utf8')
|
|
const main = fs.readFileSync(path.join(root, 'main/index.ts'), 'utf8')
|
|
assert.match(preload, /invoke\('remote-workspace:modules:docker-images', target\)/)
|
|
assert.match(main, /handle\('remote-workspace:modules:docker-images'/)
|
|
})
|