Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/add edge test #2097

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions cypress/e2e/curationTable/addEdgeBtwNodes.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
describe('Add Edge between two nodes', () => {
it('Add Edge Between Two Nodes', () => {
cy.intercept({
method: 'GET',
url: 'http://localhost:8444/api/nodes/info?skip=0&limit=50&muted=False&sort_by=date&node_type=Topic*',
}).as('loadTopics')

cy.intercept({
method: 'POST',
url: 'http://localhost:8444/api/curation/edge*',
}).as('addEdge')

cy.intercept({
method: 'GET',
url: `http://localhost:8444/api/curation/search/*`,
}).as('searchNode')

cy.initialSetup('alice', 300)

cy.get('#cy-open-soure-table').click()

cy.get('[data-testid="sources-table"]').should('exist')

cy.contains('button', 'Topics').click()

cy.wait('@loadTopics').then((interception) => {
const responseBody = interception.response.body

const responseData = responseBody.data

let currentTopic

let topicName

let edgeTopicName

const edgeType = 'RELATED_TO'

cy.get('tbody > tr:first')
.within(() => {
cy.get('td:nth-child(2)').then(($td) => {
topicName = $td.text().trim()
cy.get('.approve-wrapper button').eq(1).click()
})
})
.then(() => {
cy.get('tbody > tr:nth-child(4)')
.within(() => {
cy.get('td:nth-child(2)').then(($td) => {
edgeTopicName = $td.text().trim()
})
})
.then(() => {
cy.get('div[data-testid="add_edge"]').click()
cy.get('#addEdge').should('exist')
cy.contains('label', 'Type').closest('div').find('input').type(edgeType)
cy.contains('label', 'Type').closest('div').parent().find('div[data-testid="RELATED_TO"]').click()

cy.contains('label', 'To').closest('div').find('input').type(edgeTopicName)

cy.contains('label', 'To').closest('div').parent().find(`div[data-testid="${edgeTopicName}"]`).click()
cy.wait('@searchNode')

for (let i = 0; i < responseData.length; i++) {
const data = responseData[i]
if (data.name === topicName) {
currentTopic = { ...data }
break
}
}
cy.contains('button', 'Confirm').click()
cy.wait('@addEdge').then((interception) => {
expect(interception.response.statusCode).to.eq(200)
})
cy.request(`http://localhost:8444/api/prediction/graph/edges/${currentTopic.ref_id}`).then((response) => {
const responseBody = response.body
let node
let edge
for (let i = 0; i < responseBody.nodes.length; i++) {
if (responseBody.nodes[i].name === edgeTopicName) {
node = { ...responseBody.nodes[i] }
break
}
}
expect(edgeTopicName).to.equal(node?.name)
for (let i = 0; i < responseBody.edges.length; i++) {
if (responseBody.edges[i].target === node.ref_id) {
edge = { ...responseBody.edges[i] }
break
}
}
expect(edge.edge_type).to.equal(edgeType)
})
cy.get('#addEdge').should('not.exist')
})
})
})
})
})
Loading
Loading