tests: add test for filtering project through tags (#3521)

* tests: add test for filtering project through tags

Signed-off-by: Kush Trivedi <kushthedude@gmail.com>
This commit is contained in:
Kush Trivedi 2021-02-01 18:19:04 +05:30 committed by GitHub
parent 0b748bcc37
commit b8982d1d6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 72 additions and 15 deletions

View File

@ -0,0 +1,43 @@
describe(__filename, function () {
it('List an existing project tag, ensure a newly created project tag is created and displayed', function () {
const projectName = Date.now()
cy.loadProject('food.mini', projectName, 'TestTag')
cy.visitOpenRefine()
cy.navigateTo('Open Project')
cy.get('#projects-list table').contains(projectName)
cy.get('#projects-list table').contains('TestTag')
})
it('Ensure all project tags are created and displayed as filter', function () {
const project1 = 'Project A'
const project2 = 'Project B'
cy.loadProject('food.mini', project1, 'TestTagOne')
cy.loadProject('food.mini', project2, 'TestTagTwo')
cy.visitOpenRefine()
cy.navigateTo('Open Project')
cy.get('#projects-list table').contains(project1)
cy.get('#projects-list table').contains('TestTagOne')
cy.get('#projectTags ul').children().should('contain', 'TestTagOne')
cy.get('#projectTags ul').children().should('contain', 'TestTagTwo')
})
it('Ensure projects are being filtered through tags', function () {
const project1 = 'Project A'
const project2 = 'Project B'
cy.loadProject('food.mini', project1, 'TestTagOne')
cy.loadProject('food.mini', project2, 'TestTagTwo')
cy.visitOpenRefine()
cy.navigateTo('Open Project')
cy.get('#projects-list table').contains(project1)
cy.get('#projects-list table').contains('TestTagOne')
cy.get('#projectTags ul').children().contains('TestTagOne').click()
cy.get('#projects-list table')
.contains(project2)
.should('not.be.visible')
cy.get('#projects-list table').contains(project1).should('be.visible')
cy.get('#projectTags ul').children().contains('TestTagTwo').click()
cy.get('#projects-list table').contains(project2).should('be.visible')
cy.get('#projects-list table')
.contains(project1)
.should('not.be.visible')
})
})

View File

@ -45,7 +45,7 @@ Cypress.Commands.add('cleanupProjects', () => {
}) })
}) })
Cypress.Commands.add('loadProject', (fixture, projectName) => { Cypress.Commands.add('loadProject', (fixture, projectName, tagName) => {
const openRefineUrl = Cypress.env('OPENREFINE_URL') const openRefineUrl = Cypress.env('OPENREFINE_URL')
const openRefineProjectName = projectName ? projectName : 'cypress-test' const openRefineProjectName = projectName ? projectName : 'cypress-test'
@ -68,20 +68,34 @@ Cypress.Commands.add('loadProject', (fixture, projectName) => {
// the following code can be used to inject tags in created projects // the following code can be used to inject tags in created projects
// It's conflicting though, breaking up the CSV files // It's conflicting though, breaking up the CSV files
// const options = { projectTags: ['OpenRefineTesting'] }; // It is a hack to parse out CSV files in the openrefine while creating a project with tags
// '\r\n------BOUNDARY\r\nContent-Disposition: form-data; name="options"\r\n\r\n' + const options = {"encoding":"US-ASCII","separator":",","ignoreLines":-1,"headerLines":1,"skipDataLines":0,"limit":-1,"storeBlankRows":true,"guessCellValueTypes":false,"processQuotes":true,"quoteCharacter":"\"","storeBlankCellsAsNulls":true,"includeFileSources":false,"includeArchiveFileName":false,"trimStrings":false,"projectName":openRefineProjectName,"projectTags": [tagName]}
// JSON.stringify(options) + var postData
if (tagName == undefined) {
var postData = postData =
'------BOUNDARY\r\nContent-Disposition: form-data; name="project-file"; filename="' + '------BOUNDARY\r\nContent-Disposition: form-data; name="project-file"; filename="' +
fixture + fixture +
'"\r\nContent-Type: "text/csv"\r\n\r\n' + '"\r\nContent-Type: "text/csv"\r\n\r\n' +
content + content +
'\r\n------BOUNDARY\r\nContent-Disposition: form-data; name="project-name"\r\n\r\n' + '\r\n------BOUNDARY\r\nContent-Disposition: form-data; name="project-name"\r\n\r\n' +
openRefineProjectName + openRefineProjectName +
'\r\n------BOUNDARY\r\nContent-Disposition: form-data; name="format"\r\n\r\n' + '\r\n------BOUNDARY\r\nContent-Disposition: form-data; name="format"\r\n\r\n' +
openRefineFormat + openRefineFormat +
'\r\n------BOUNDARY--' '\r\n------BOUNDARY--'
} else {
postData =
'------BOUNDARY\r\nContent-Disposition: form-data; name="project-file"; filename="' +
fixture +
'"\r\nContent-Type: "text/csv"\r\n\r\n' +
content +
'\r\n------BOUNDARY\r\nContent-Disposition: form-data; name="project-name"\r\n\r\n' +
openRefineProjectName +
'\r\n------BOUNDARY\r\nContent-Disposition: form-data; name="options"\r\n\r\n' +
JSON.stringify(options) +
'\r\n------BOUNDARY\r\nContent-Disposition: form-data; name="format"\r\n\r\n' +
openRefineFormat +
'\r\n------BOUNDARY--'
}
cy.request({ cy.request({
method: 'POST', method: 'POST',