Skip to content

Commit 106956a

Browse files
committed
Merge #492: [#228] E2E test: add a new tag
ae407d7 test: [#228] new E2E test for adding tags (Mario) Pull request description: Resolves #228 ACKs for top commit: josecelano: ACK ae407d7 Tree-SHA512: 40a39c07dc1582549c15eac6fc7a67e5637dd2b090440533c85e6e156eb2f4a45083123908894bbf609ca2764db3237a06a6f759612c7120a34938001f2ea45d
2 parents 2add58c + ae407d7 commit 106956a

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
});

pages/admin/settings/tags.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
</template>
1212
</div>
1313
<div class="flex gap-2">
14-
<input v-model="newTag" class="w-full input input-bordered" type="text">
15-
<button class="btn btn-primary" :class="{ 'loading': addingTag }" :disabled="addingTag || !newTag" @click="addTag">
14+
<input v-model="newTag" data-cy="add-tag-text-input" class="w-full input input-bordered" type="text">
15+
<button data-cy="add-tag-button" class="{ 'loading': addingTag }" :disabled="addingTag || !newTag" @click="addTag">
1616
Add tag
1717
</button>
1818
</div>

0 commit comments

Comments
 (0)