diff --git a/tests/cypress/e2e/for-teacher_page/customize-adventure_page/tags.cy.js b/tests/cypress/e2e/for-teacher_page/customize-adventure_page/tags.cy.js index 8ec22f3ed33..88c7f7ec016 100644 --- a/tests/cypress/e2e/for-teacher_page/customize-adventure_page/tags.cy.js +++ b/tests/cypress/e2e/for-teacher_page/customize-adventure_page/tags.cy.js @@ -66,10 +66,10 @@ describe("Tags of adventures", () => { }).as("deleteTag") cy.wait(500) - cy.get("#tag_2") + cy.get("#tag_1") .should("be.visible") .should("include.text", "statements") - cy.get("#tag_2 .fa-circle-xmark") + cy.get("#tag_1 .fa-circle-xmark") .click() cy.wait("@deleteTag").should('have.nested.property', 'response.statusCode', 200) cy.get("#tags_list li") diff --git a/website/tags.py b/website/tags.py index 2269ed9df82..fd6803752b3 100644 --- a/website/tags.py +++ b/website/tags.py @@ -30,7 +30,6 @@ def get_public_tags(self, user, adventure_id): adventure_id = request.args.get("adventure_id") adventure = self.db.get_adventure(adventure_id) if adventure: - adventure = self.db.get_adventure(adventure_id) # exclude current adventure's tags public_tags = list(filter(lambda t: t["name"] not in adventure.get("tags", []), public_tags)) @@ -58,6 +57,7 @@ def create(self, user, adventure_id, new_tag=None): adventure_tags = db_adventure.get("tags", []) if tag_name not in adventure_tags: adventure_tags.append(tag_name) + adventure_tags = sorted(adventure_tags, key=lambda tag: tag) self.db.update_adventure(adventure_id, {"tags": adventure_tags}) else: return make_response(gettext("tag_in_adventure"), 400)