Last active
November 4, 2020 14:40
create topic via JSON
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
import { | |
BULK_TEST_TOPICS, BULK_TEST_TOPICS_NAMES, POST_RESPONSE_TWO_NOT_ONE, CREATED_TOPICS_URL | |
} from '../fixtures/topic_testdata' | |
import { | |
getfirstTopicTitle, getfirstTopicType | |
} from '../page-objects/create_topic' | |
describe('Topic Creation Via Json:API', function () { | |
before(function () { | |
cy.createUser(Cypress.env('cyAdminUser'), Cypress.env('cyAdminPassword'), Cypress.env('cyAdminRole')); | |
}) | |
it('Create bulk topics & Verify them using json:api', function () { | |
for (let i = 0; i < BULK_TEST_TOPICS.length; i++) { | |
let BULK_TEST_JSON_OBJECT = BULK_TEST_TOPICS[i]; | |
cy.getRestToken(Cypress.env('cyAdminUser'), Cypress.env('cyAdminPassword')).then(token => { | |
cy.getNodesWithTitle(token, 'topic', BULK_TEST_JSON_OBJECT.data.attributes.title.value) | |
.then(nodes => { | |
nodes.map(function (node) { | |
cy.deleteNode(token, 'topic', node.id); | |
}); | |
}); | |
cy.createTopic(token, BULK_TEST_JSON_OBJECT) | |
}).then(res => { | |
expect(res.status).to.eq(POST_RESPONSE_TWO_NOT_ONE); | |
expect(res.body.data.attributes.body.value).to.eq(BULK_TEST_JSON_OBJECT.data.attributes.title.value); | |
}); | |
cy.logout(); | |
cy.visit(CREATED_TOPICS_URL); | |
getfirstTopicTitle().should('have.text', BULK_TEST_JSON_OBJECT.data.attributes.title.value); | |
getfirstTopicType().should('have.text', BULK_TEST_TOPICS_NAMES[i]); | |
} | |
}); | |
after(function () { | |
cy.deleteUser(Cypress.env('cyAdminUser')); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment