generated from amosproj/amos202Xss0Y-projname
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into exploration-page-ui
- Loading branch information
Showing
24 changed files
with
768 additions
and
144 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
Binary file not shown.
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,55 @@ | ||
/* | ||
Fixed #301. | ||
This script terminates after a successful connection to the neo4j database. | ||
Connection details are taken from `__dirname/.env`, just like in the backend app. | ||
*/ | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const path = require('path'); | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const neo4j = require('neo4j-driver'); | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
require('dotenv').config({ path: path.join(__dirname, '.env') }); | ||
|
||
const config = { | ||
scheme: process.env.NEO4J_SCHEME, | ||
host: process.env.NEO4J_HOST, | ||
port: process.env.NEO4J_PORT, | ||
username: process.env.NEO4J_USERNAME, | ||
password: process.env.NEO4J_PASSWORD, | ||
}; | ||
|
||
// eslint-disable-next-line no-console | ||
console.log(config); | ||
|
||
async function tryConnect() { | ||
let driver; | ||
let session; | ||
|
||
try { | ||
driver = neo4j.driver( | ||
`${config.scheme}://${config.host}:${config.port}`, | ||
neo4j.auth.basic(config.username, config.password) | ||
); | ||
await driver.verifyConnectivity(); | ||
|
||
// start dummy query | ||
session = driver.session(); | ||
await session.run('MATCH (n) RETURN n LIMIT 1'); | ||
|
||
// eslint-disable-next-line no-console | ||
console.log('Connection successful'); | ||
} catch (e) { | ||
const timeout = 5000; | ||
// eslint-disable-next-line no-console | ||
console.log(`Connection Error: Retrying in ${timeout}ms`); | ||
setTimeout(() => { | ||
tryConnect(); | ||
}, timeout); | ||
} finally { | ||
if (session) await session.close(); | ||
if (driver) await driver.close(); | ||
} | ||
} | ||
|
||
tryConnect(); |
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 |
---|---|---|
|
@@ -2137,6 +2137,11 @@ [email protected]: | |
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a" | ||
integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw== | ||
|
||
dotenv@^10.0.0: | ||
version "10.0.0" | ||
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-10.0.0.tgz#3d4227b8fb95f81096cdd2b66653fb2c7085ba81" | ||
integrity sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q== | ||
|
||
ecc-jsbn@~0.1.1: | ||
version "0.1.2" | ||
resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" | ||
|
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,40 @@ | ||
/* | ||
Starts the database docker container with the testing dump. | ||
*/ | ||
|
||
const path = require("path"); | ||
const { execSync } = require("child_process"); | ||
|
||
const containerName="neo4j-db" | ||
const repoPath = path.join(__dirname, ".."); | ||
const mountPath = path.join(repoPath, "backend", "docker", "mount"); | ||
const pluginsPath = path.join(repoPath, "backend", "docker", "plugins"); | ||
|
||
async function main() { | ||
try { | ||
execSync(`docker container stop ${containerName}`) | ||
} catch(e) {} | ||
|
||
try { | ||
execSync(`docker container rm ${containerName}`) | ||
} catch(e) {} | ||
|
||
const command = ` | ||
docker run -d -p 7474:7474 -p 7687:7687 \\ | ||
-v ${mountPath}:/mnt/amos \\ | ||
-v ${pluginsPath}:/plugins \\ | ||
--env NEO4J_ACCEPT_LICENSE_AGREEMENT=yes \\ | ||
--env DB_PASSWORD=amos \\ | ||
--env DB_PATH=/mnt/amos/dumps/testing-dump.dump \\ | ||
--env 'NEO4JLABS_PLUGINS=["apoc", "graph-data-science"]' \\ | ||
--env 'NEO4J_dbms_security_procedures_unrestricted=apoc.*,gds.*' \\ | ||
--env 'NEO4J_dbms_security_procedures_allowlist=apoc.*,gds.*' \\ | ||
--env NEO4J_apoc_import_file_enabled=true \\ | ||
--name ${containerName} neo4j:4.2-enterprise \\ | ||
/mnt/amos/load-dump.sh | ||
` | ||
|
||
execSync(command); | ||
} | ||
|
||
main(); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,13 +1 @@ | ||
- run: | | ||
docker run -d -p 7474:7474 -p 7687:7687 \ | ||
-v ${GITHUB_WORKSPACE}/backend/docker/mount:/mnt/amos \ | ||
-v ${GITHUB_WORKSPACE}/backend/docker/plugins:/plugins \ | ||
--env NEO4J_ACCEPT_LICENSE_AGREEMENT=yes \ | ||
--env DB_PASSWORD=amos \ | ||
--env DB_PATH=/mnt/amos/dumps/testing-dump.dump \ | ||
--env 'NEO4JLABS_PLUGINS=["apoc", "graph-data-science"]' \ | ||
--env 'NEO4J_dbms_security_procedures_unrestricted=apoc.*,gds.*' \ | ||
--env 'NEO4J_dbms_security_procedures_allowlist=apoc.*,gds.*' \ | ||
--env NEO4J_apoc_import_file_enabled=true \ | ||
--name neo4j-DB neo4j:enterprise \ | ||
/mnt/amos/load-dump.sh | ||
- run: node build/start-database |
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
38 changes: 38 additions & 0 deletions
38
frontend/cypress/integration/exploration/exploration.e2e.js
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,38 @@ | ||
import layoutsData from '../../../src/exploration/previews/layoutsData'; | ||
|
||
context('Exploration', () => { | ||
// Global setup | ||
beforeEach(() => { | ||
cy.visit('http://localhost:3000/exploration'); | ||
}); | ||
|
||
context('Previews', () => { | ||
it('lists correct number of previews', () => { | ||
cy.get('.Previews'); | ||
cy.get('.LayoutPreview').should('have.length', 7); | ||
}); | ||
|
||
it('correct initial layouts', () => { | ||
cy.get('.Previews'); | ||
|
||
const layoutsDataValues = Object.values(layoutsData); | ||
cy.get('.LayoutPreview').each(($el, index) => { | ||
cy.wrap($el).should('have.text', layoutsDataValues[index].description); | ||
}); | ||
}); | ||
|
||
it('routes to graph page', () => { | ||
cy.get('.Previews'); | ||
cy.get('.LayoutPreview').eq(0).click(); | ||
cy.url().should('eq', `http://localhost:3000${layoutsData.C.path}`); | ||
}); | ||
|
||
it('routes to hierarchical page', () => { | ||
cy.get('.Previews'); | ||
cy.get('.LayoutPreview').eq(2).click(); | ||
cy.url().should('eq', `http://localhost:3000${layoutsData.H.path}`); | ||
}); | ||
|
||
// TODO: add more tests when combined with questions | ||
}); | ||
}); |
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 @@ | ||
import appendQuery from '../../src/services/http/appendQuery'; | ||
|
||
describe('appendQuery', () => { | ||
let url: URL; | ||
const baseUrl = 'https://example.com'; | ||
|
||
beforeEach(() => { | ||
url = new URL(baseUrl); | ||
}); | ||
|
||
it('should not change input href on empty input', () => { | ||
const actual = appendQuery(url, {}); | ||
expect(actual.href).to.be.eq(`${url.href}`); | ||
}); | ||
|
||
it('should be able to handle strings', () => { | ||
const actual = appendQuery(url, { example: 'successful' }); | ||
expect(actual.href).to.be.eq(`${url.href}?example=successful`); | ||
}); | ||
|
||
it('should be able to handle numbers', () => { | ||
const actual = appendQuery(url, { example: 42 }); | ||
expect(actual.href).to.be.eq(`${url.href}?example=42`); | ||
}); | ||
|
||
it('should be able to handle arrays', () => { | ||
const actual = appendQuery(url, { example: [1, 2, 3] }); | ||
expect(actual.href).to.be.eq(`${url.href}?example=1&example=2&example=3`); | ||
}); | ||
|
||
describe('appending query', () => { | ||
it('should be able to append to given queries', () => { | ||
url = new URL(`${baseUrl}?given=1`); | ||
const actual = appendQuery(url, { example: [1, 2, 3] }); | ||
expect(actual.href).to.be.eq(`${url.href}&example=1&example=2&example=3`); | ||
}); | ||
|
||
it('should be able to append to given empty query', () => { | ||
url = new URL(`${baseUrl}?`); | ||
const actual = appendQuery(url, { example: [1, 2, 3] }); | ||
expect(actual.href).to.be.eq(`${url.href}example=1&example=2&example=3`); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.