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:
parent
0b748bcc37
commit
b8982d1d6e
@ -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')
|
||||
})
|
||||
})
|
@ -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 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
|
||||
// It's conflicting though, breaking up the CSV files
|
||||
// const options = { projectTags: ['OpenRefineTesting'] };
|
||||
// '\r\n------BOUNDARY\r\nContent-Disposition: form-data; name="options"\r\n\r\n' +
|
||||
// JSON.stringify(options) +
|
||||
|
||||
var 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="format"\r\n\r\n' +
|
||||
openRefineFormat +
|
||||
'\r\n------BOUNDARY--'
|
||||
// It is a hack to parse out CSV files in the openrefine while creating a project with tags
|
||||
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]}
|
||||
var postData
|
||||
if (tagName == undefined) {
|
||||
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="format"\r\n\r\n' +
|
||||
openRefineFormat +
|
||||
'\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({
|
||||
method: 'POST',
|
||||
|
Loading…
Reference in New Issue
Block a user