From 9565974b6ab9c4d1db452e37ecd18ebb56ea4026 Mon Sep 17 00:00:00 2001
From: Nemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com>
Date: Tue, 11 Jan 2022 21:55:12 +0100
Subject: [PATCH] Repro #19603: Archived sub-collections are still showing in
 Permissions (#19615)

---
 ...lection-shows-up-in-permissions.cy.spec.js | 22 +++++++++++++
 ...o-not-show-archived-collections.cy.spec.js | 32 -------------------
 2 files changed, 22 insertions(+), 32 deletions(-)
 create mode 100644 frontend/test/metabase/scenarios/permissions/reproductions/19603-archived-sub-collection-shows-up-in-permissions.cy.spec.js
 delete mode 100644 frontend/test/metabase/scenarios/permissions/reproductions/19603-do-not-show-archived-collections.cy.spec.js

diff --git a/frontend/test/metabase/scenarios/permissions/reproductions/19603-archived-sub-collection-shows-up-in-permissions.cy.spec.js b/frontend/test/metabase/scenarios/permissions/reproductions/19603-archived-sub-collection-shows-up-in-permissions.cy.spec.js
new file mode 100644
index 00000000000..b51821640ae
--- /dev/null
+++ b/frontend/test/metabase/scenarios/permissions/reproductions/19603-archived-sub-collection-shows-up-in-permissions.cy.spec.js
@@ -0,0 +1,22 @@
+import { restore } from "__support__/e2e/cypress";
+
+describe("issue 19603", () => {
+  beforeEach(() => {
+    restore();
+    cy.signInAsAdmin();
+
+    // Archive second collection (nested under the first one)
+    cy.request("GET", "/api/collection/").then(({ body }) => {
+      const { id } = body.find(c => c.slug === "second_collection");
+
+      cy.archiveCollection(id);
+    });
+  });
+
+  it("archived subcollection should not show up in permissions (metabase#19603)", () => {
+    cy.visit("/admin/permissions/collections");
+
+    cy.findByText("First collection").click();
+    cy.findByText("Second collection").should("not.exist");
+  });
+});
diff --git a/frontend/test/metabase/scenarios/permissions/reproductions/19603-do-not-show-archived-collections.cy.spec.js b/frontend/test/metabase/scenarios/permissions/reproductions/19603-do-not-show-archived-collections.cy.spec.js
deleted file mode 100644
index 145012f762b..00000000000
--- a/frontend/test/metabase/scenarios/permissions/reproductions/19603-do-not-show-archived-collections.cy.spec.js
+++ /dev/null
@@ -1,32 +0,0 @@
-import { restore } from "__support__/e2e/cypress";
-
-const UNARCHIVED_PARENT_NAME = "Unarchived parent";
-const ARCHIVED_NAME = "Archived child";
-
-describe("issue 19603", () => {
-  beforeEach(() => {
-    restore();
-    cy.signInAsAdmin();
-
-    cy.createCollection({
-      name: UNARCHIVED_PARENT_NAME,
-    }).then(response => {
-      const { id: collectionId } = response.body;
-      cy.createCollection({
-        name: ARCHIVED_NAME,
-        parent_id: collectionId,
-        archived: true,
-      }).then(response => {
-        const { id: archivedCollectionId } = response.body;
-        cy.archiveCollection(archivedCollectionId);
-      });
-    });
-  });
-
-  it("should not show archived collections on the collections permissions page (metabase#19603)", () => {
-    cy.visit("admin/permissions/collections");
-
-    cy.findByText(UNARCHIVED_PARENT_NAME).click();
-    cy.findByText(ARCHIVED_NAME).should("not.exist");
-  });
-});
-- 
GitLab