|
| 1 | +import { RegistrationForm, random_user_registration_data } from "../../user/registration"; |
| 2 | +import { randomTagName } from "../random_data"; |
| 3 | + |
| 4 | +describe("The admin user", () => { |
| 5 | + const registration_form = random_user_registration_data(); |
| 6 | + |
| 7 | + before(() => { |
| 8 | + cy.delete_tags_from_database(); |
| 9 | + cy.register_as_admin_and_login(registration_form); |
| 10 | + }); |
| 11 | + |
| 12 | + after(() => { |
| 13 | + cy.delete_user_from_database(registration_form.username); |
| 14 | + }); |
| 15 | + |
| 16 | + it("should be able to add a tag", () => { |
| 17 | + const tag_name = randomTagName(); |
| 18 | + |
| 19 | + cy.go_to_settings(); |
| 20 | + |
| 21 | + // Click tags tab |
| 22 | + cy.contains("a", "tags").click(); |
| 23 | + |
| 24 | + // Add the tag |
| 25 | + cy.get("[data-cy=\"add-tag-text-input\"]").type(tag_name); |
| 26 | + |
| 27 | + cy.get("[data-cy=\"add-tag-button\"]").click(); |
| 28 | + |
| 29 | + cy.get(`[data-cy="delete-tag-${tag_name}"]`).should("exist"); |
| 30 | + }); |
| 31 | +}); |
| 32 | + |
| 33 | +describe("A non admin authenticated user", () => { |
| 34 | + const registration_form = random_user_registration_data(); |
| 35 | + |
| 36 | + before(() => { |
| 37 | + cy.delete_tags_from_database(); |
| 38 | + cy.register_and_login(registration_form); |
| 39 | + }); |
| 40 | + |
| 41 | + after(() => { |
| 42 | + cy.delete_user_from_database(registration_form.username); |
| 43 | + }); |
| 44 | + |
| 45 | + it("should not be able to delete tags", () => { |
| 46 | + cy.visit("/admin/settings/tags"); |
| 47 | + cy.contains("Please login to manage admin settings."); |
| 48 | + }); |
| 49 | +}); |
| 50 | + |
| 51 | +describe("A guest user", () => { |
| 52 | + it("should not be able to delete a tag", () => { |
| 53 | + cy.visit("/admin/settings/tags"); |
| 54 | + cy.contains("Please login to manage admin settings."); |
| 55 | + }); |
| 56 | +}); |
0 commit comments