From dbb3031a665888aa1473b1cee9fc4273c3619cd9 Mon Sep 17 00:00:00 2001 From: Juan Manuel Spoleti <104365141+juans-chainsafe@users.noreply.github.com> Date: Tue, 16 Aug 2022 13:59:33 -0300 Subject: [PATCH 1/9] [Storage] Add and delete a storage api key test (#2240) * add and delete a storage api key test * fix navigate to api keys page in mobile context * Update packages/storage-ui/cypress/support/page-objects/apiKeysPage.ts Co-authored-by: Andrew Snaith * Update packages/storage-ui/src/Components/Modules/ApiKeys.tsx Co-authored-by: Andrew Snaith * fix sort bucket test Co-authored-by: Michael Yankelev <12774278+FSM1@users.noreply.github.com> Co-authored-by: Andrew Snaith --- .../storage-ui/cypress/support/commands.ts | 8 +++- .../support/page-objects/apiKeysPage.ts | 21 ++++++++++ .../page-objects/modals/newKeyModal.ts | 5 +++ .../support/page-objects/navigationMenu.ts | 2 +- .../cypress/support/utils/apiTestHelper.ts | 19 +++++++++ .../cypress/tests/api-keys-management.cy.ts | 39 +++++++++++++++++++ .../cypress/tests/bucket-management.cy.ts | 31 ++++++++------- .../cypress/tests/main-navigation.cy.ts | 4 +- .../src/Components/Modules/ApiKeys.tsx | 27 ++++++++----- .../src/Components/Pages/CidsPage.tsx | 2 +- 10 files changed, 129 insertions(+), 29 deletions(-) create mode 100644 packages/storage-ui/cypress/support/page-objects/apiKeysPage.ts create mode 100644 packages/storage-ui/cypress/support/page-objects/modals/newKeyModal.ts create mode 100644 packages/storage-ui/cypress/tests/api-keys-management.cy.ts diff --git a/packages/storage-ui/cypress/support/commands.ts b/packages/storage-ui/cypress/support/commands.ts index d08a8e258a..2f9fd3782d 100644 --- a/packages/storage-ui/cypress/support/commands.ts +++ b/packages/storage-ui/cypress/support/commands.ts @@ -45,6 +45,7 @@ export interface Web3LoginOptions { deleteFpsBuckets?: boolean withNewSession?: boolean createFpsBuckets?: { name: string; type: FileSystemType }[] + deleteApiKeys?: boolean } Cypress.Commands.add("clearPins", apiTestHelper.clearPins) @@ -61,7 +62,8 @@ Cypress.Commands.add( withNewUser = true, deleteFpsBuckets = false, withNewSession = false, - createFpsBuckets + createFpsBuckets, + deleteApiKeys = false }: Web3LoginOptions = {}) => { cy.on("window:before:load", (win) => { @@ -117,6 +119,10 @@ Cypress.Commands.add( apiTestHelper.createBucket(bucket.name, bucket.type) }) } + + if(deleteApiKeys) { + apiTestHelper.deleteApiKeys() + } } ) diff --git a/packages/storage-ui/cypress/support/page-objects/apiKeysPage.ts b/packages/storage-ui/cypress/support/page-objects/apiKeysPage.ts new file mode 100644 index 0000000000..d62aa6c285 --- /dev/null +++ b/packages/storage-ui/cypress/support/page-objects/apiKeysPage.ts @@ -0,0 +1,21 @@ +// Only add things here that could be applicable to the api keys page + +import { basePage } from "./basePage" + +export const apiKeysPage = { + ...basePage, + + // main api keys elements + apiKeysHeaderLabel: () => cy.get("[data-cy=header-api-keys]", { timeout: 20000 }), + addApiKeyButton: () => cy.get("[data-cy=button-add-api-key]"), + addS3KeyButton: () => cy.get("[data-cy=button-add-s3-key]"), + + // api keys table row elements + apiKeyIdCell: () => cy.get("[data-cy=cell-api-keys-id]"), + apiKeyTypeCell: () => cy.get("[data-cy=cell-api-keys-type]"), + apiKeyStatusCell: () => cy.get("[data-cy=cell-api-keys-status]"), + apiKeyRowKebabButton: () => cy.get("[data-testid=dropdown-title-api-keys-kebab]"), + + // kebab menu elements + deleteMenuOption: () => cy.get("[data-cy=menu-delete]") +} \ No newline at end of file diff --git a/packages/storage-ui/cypress/support/page-objects/modals/newKeyModal.ts b/packages/storage-ui/cypress/support/page-objects/modals/newKeyModal.ts new file mode 100644 index 0000000000..ba09b311f8 --- /dev/null +++ b/packages/storage-ui/cypress/support/page-objects/modals/newKeyModal.ts @@ -0,0 +1,5 @@ +export const newKeyModal = { + keyIdLabel: () => cy.get("[data-cy=label-new-key-modal-key-id]"), + secretLabel: () => cy.get("[data-cy=label-new-key-modal-secret]"), + closeButton: () => cy.get("[data-cy=button-new-key-modal-close]") +} diff --git a/packages/storage-ui/cypress/support/page-objects/navigationMenu.ts b/packages/storage-ui/cypress/support/page-objects/navigationMenu.ts index 9b6c7a395b..1659f7b900 100644 --- a/packages/storage-ui/cypress/support/page-objects/navigationMenu.ts +++ b/packages/storage-ui/cypress/support/page-objects/navigationMenu.ts @@ -5,7 +5,7 @@ export const navigationMenu = { homeNavButton: () => cy.get("[data-cy=home-nav]"), cidsNavButton: () => cy.get("[data-cy=cids-nav]"), bucketsNavButton: () => cy.get("[data-cy=buckets-nav]"), - APIKeysNavButton: () => cy.get("[data-cy=api-keys-nav]"), + apiKeysNavButton: () => cy.get("[data-cy=api-keys-nav]"), // settingsNavButton: () => cy.get("[data-cy=settings-nav]"), // docsNavButton: () => cy.get("[data-cy=docs-nav]"), spaceUsedLabel: () => cy.get("[data-cy=label-space-used]"), diff --git a/packages/storage-ui/cypress/support/utils/apiTestHelper.ts b/packages/storage-ui/cypress/support/utils/apiTestHelper.ts index b4c6edf352..4e51a88fbf 100644 --- a/packages/storage-ui/cypress/support/utils/apiTestHelper.ts +++ b/packages/storage-ui/cypress/support/utils/apiTestHelper.ts @@ -71,5 +71,24 @@ export const apiTestHelper = { resolve() }) }) + }, + deleteApiKeys() { + const apiClient = getApiClient() + return new Cypress.Promise(async (resolve) => { + cy.window() + .then(async (win) => { + const tokens = await apiClient.getRefreshToken({ refresh: win.localStorage.getItem(REFRESH_TOKEN_KEY) || "" }) + + await apiClient.setToken(tokens.access_token.token) + const keys = await apiClient.listAccessKeys() + cy.log(keys.length.toString()) + keys.forEach(async (key) => { + cy.log(`Deleting api key: "${key.id}""`) + await apiClient.deleteAccessKey(key.id) + }) + cy.log("Done deleting api keys.") + resolve() + }) + }) } } diff --git a/packages/storage-ui/cypress/tests/api-keys-management.cy.ts b/packages/storage-ui/cypress/tests/api-keys-management.cy.ts new file mode 100644 index 0000000000..b33c6c5d27 --- /dev/null +++ b/packages/storage-ui/cypress/tests/api-keys-management.cy.ts @@ -0,0 +1,39 @@ +import { navigationMenu } from "../support/page-objects/navigationMenu" +import { apiKeysPage } from "../support/page-objects/apiKeysPage" +import { newKeyModal } from "../support/page-objects/modals/newKeyModal" + +describe("Main Navigation", () => { + + context("desktop", () => { + beforeEach(() => { + cy.web3Login({ deleteApiKeys: true }) + }) + + it("can add and delete a storage api key", () => { + // go to api keys section + navigationMenu.apiKeysNavButton().click() + + // add new storage api key + apiKeysPage.addApiKeyButton().click() + newKeyModal.secretLabel().should("be.visible") + newKeyModal.keyIdLabel().invoke("text").as("keyId") + newKeyModal.closeButton().click() + + // ensure new key modal is closed and api key button is not enabled + newKeyModal.secretLabel().should("not.exist") + apiKeysPage.addApiKeyButton().should("not.be.enabled") + + // ensure key id and status are correct in the table + cy.get("@keyId").then((keyId) => { + apiKeysPage.apiKeyIdCell().should("have.text", keyId) + }) + apiKeysPage.apiKeyTypeCell().should("have.text", "storage") + + // delete api key + apiKeysPage.apiKeyRowKebabButton().click() + apiKeysPage.deleteMenuOption().click() + apiKeysPage.apiKeyIdCell().should("not.exist") + }) + }) + +}) diff --git a/packages/storage-ui/cypress/tests/bucket-management.cy.ts b/packages/storage-ui/cypress/tests/bucket-management.cy.ts index ec049c7d5b..eb37f290e7 100644 --- a/packages/storage-ui/cypress/tests/bucket-management.cy.ts +++ b/packages/storage-ui/cypress/tests/bucket-management.cy.ts @@ -147,37 +147,38 @@ describe("Bucket management", () => { // }) it("can sort by name or file system in buckets table", () => { - const chainSafeBucketName = `cs bucket ${Date.now()}` - const ipfsBucketName = `ipfs bucket ${Date.now()}` + const firstChainSafeBucketName = `first cs bucket ${Date.now()}` + const secondChainsafeBucketName = `second ipfs bucket ${Date.now()}` cy.web3Login({ deleteFpsBuckets: true, createFpsBuckets: - [{ name: chainSafeBucketName, type: "chainsafe" }, { name: ipfsBucketName, type: "ipfs" }] + [{ name: firstChainSafeBucketName, type: "chainsafe" }, { name: secondChainsafeBucketName, type: "chainsafe" }] }) navigationMenu.bucketsNavButton().click() // by default should be sort by date uploading in ascending order (oldest first) - bucketsPage.bucketItemName().eq(0).should("have.text", chainSafeBucketName) - bucketsPage.bucketItemName().eq(1).should("have.text", ipfsBucketName) + bucketsPage.bucketItemName().eq(0).should("have.text", firstChainSafeBucketName) + bucketsPage.bucketItemName().eq(1).should("have.text", secondChainsafeBucketName) // ensure that sort by name in descending order (Z-A) bucketsPage.bucketsTableHeaderName().click() - bucketsPage.bucketItemName().eq(0).should("have.text", ipfsBucketName) - bucketsPage.bucketItemName().eq(1).should("have.text", chainSafeBucketName) + bucketsPage.bucketItemName().eq(0).should("have.text", secondChainsafeBucketName) + bucketsPage.bucketItemName().eq(1).should("have.text", firstChainSafeBucketName) // ensure that sort by name in ascending order (A-Z) bucketsPage.bucketsTableHeaderName().click() - bucketsPage.bucketItemName().eq(0).should("have.text", chainSafeBucketName) - bucketsPage.bucketItemName().eq(1).should("have.text", ipfsBucketName) + bucketsPage.bucketItemName().eq(0).should("have.text", firstChainSafeBucketName) + bucketsPage.bucketItemName().eq(1).should("have.text", secondChainsafeBucketName) + // commented because we can't create ipfs buckets right now // ensure that sort by file system in descending order (Z-A) - bucketsPage.bucketsTableHeaderFileSystem().click() - bucketsPage.bucketItemName().eq(0).should("have.text", ipfsBucketName) - bucketsPage.bucketItemName().eq(1).should("have.text", chainSafeBucketName) + // bucketsPage.bucketsTableHeaderFileSystem().click() + // bucketsPage.bucketItemName().eq(0).should("have.text", ipfsBucketName) + // bucketsPage.bucketItemName().eq(1).should("have.text", chainSafeBucketName) // ensure that sort by file system in ascending order (A-Z) - bucketsPage.bucketsTableHeaderFileSystem().click() - bucketsPage.bucketItemName().eq(0).should("have.text", chainSafeBucketName) - bucketsPage.bucketItemName().eq(1).should("have.text", ipfsBucketName) + // bucketsPage.bucketsTableHeaderFileSystem().click() + // bucketsPage.bucketItemName().eq(0).should("have.text", chainSafeBucketName) + // bucketsPage.bucketItemName().eq(1).should("have.text", ipfsBucketName) }) // it("can rename a folder inside the ipfs bucket", () => { diff --git a/packages/storage-ui/cypress/tests/main-navigation.cy.ts b/packages/storage-ui/cypress/tests/main-navigation.cy.ts index e4921aef5e..7fecb7c5fa 100644 --- a/packages/storage-ui/cypress/tests/main-navigation.cy.ts +++ b/packages/storage-ui/cypress/tests/main-navigation.cy.ts @@ -20,7 +20,7 @@ describe("Main Navigation", () => { }) it("can navigate to the API keys page", () => { - navigationMenu.APIKeysNavButton().click() + navigationMenu.apiKeysNavButton().click() cy.url().should("include", "/api-keys") }) @@ -54,7 +54,7 @@ describe("Main Navigation", () => { }) it("can navigate to the API keys page", () => { - navigationMenu.APIKeysNavButton().click() + navigationMenu.apiKeysNavButton().click() cy.url().should("include", "/api-keys") }) diff --git a/packages/storage-ui/src/Components/Modules/ApiKeys.tsx b/packages/storage-ui/src/Components/Modules/ApiKeys.tsx index f67f446198..0e8dbc173b 100644 --- a/packages/storage-ui/src/Components/Modules/ApiKeys.tsx +++ b/packages/storage-ui/src/Components/Modules/ApiKeys.tsx @@ -198,7 +198,9 @@ const ApiKeys = () => { return ( <>
-
+
{
diff --git a/packages/storage-ui/src/Components/Pages/CidsPage.tsx b/packages/storage-ui/src/Components/Pages/CidsPage.tsx index bd6ba5c990..240042d154 100644 --- a/packages/storage-ui/src/Components/Pages/CidsPage.tsx +++ b/packages/storage-ui/src/Components/Pages/CidsPage.tsx @@ -170,7 +170,7 @@ const CidsPage = () => {
Date: Fri, 19 Aug 2022 10:55:34 -0300 Subject: [PATCH 2/9] [Storage] Add and delete s3 key test (#2241) * add and delete a storage api key test * fix navigate to api keys page in mobile context * add and delete s3 key --- .../cypress/tests/api-keys-management.cy.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/packages/storage-ui/cypress/tests/api-keys-management.cy.ts b/packages/storage-ui/cypress/tests/api-keys-management.cy.ts index b33c6c5d27..90d1a3df28 100644 --- a/packages/storage-ui/cypress/tests/api-keys-management.cy.ts +++ b/packages/storage-ui/cypress/tests/api-keys-management.cy.ts @@ -34,6 +34,32 @@ describe("Main Navigation", () => { apiKeysPage.deleteMenuOption().click() apiKeysPage.apiKeyIdCell().should("not.exist") }) + + it("can add and delete a s3 api key", () => { + // go to api keys section + navigationMenu.apiKeysNavButton().click() + + // add new s3 api key + apiKeysPage.addS3KeyButton().click() + newKeyModal.secretLabel().should("be.visible") + newKeyModal.keyIdLabel().invoke("text").as("keyId") + newKeyModal.closeButton().click() + + // ensure new key modal is closed and api key button is enabled + newKeyModal.secretLabel().should("not.exist") + apiKeysPage.addS3KeyButton().should("be.enabled") + + // ensure key id and status are correct in the table + cy.get("@keyId").then((keyId) => { + apiKeysPage.apiKeyIdCell().should("have.text", keyId) + }) + apiKeysPage.apiKeyTypeCell().should("have.text", "s3") + + // delete s3 key + apiKeysPage.apiKeyRowKebabButton().click() + apiKeysPage.deleteMenuOption().click() + apiKeysPage.apiKeyIdCell().should("not.exist") + }) }) }) From e18948ab2fb4a6e748a22fc8ebe2356ca2cf27ed Mon Sep 17 00:00:00 2001 From: Juan Manuel Spoleti <104365141+juans-chainsafe@users.noreply.github.com> Date: Mon, 22 Aug 2022 09:58:00 -0300 Subject: [PATCH 3/9] navigate to NFTs page test (#2248) --- .../cypress/support/page-objects/navigationMenu.ts | 1 + .../storage-ui/cypress/tests/main-navigation.cy.ts | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/packages/storage-ui/cypress/support/page-objects/navigationMenu.ts b/packages/storage-ui/cypress/support/page-objects/navigationMenu.ts index 1659f7b900..573b970769 100644 --- a/packages/storage-ui/cypress/support/page-objects/navigationMenu.ts +++ b/packages/storage-ui/cypress/support/page-objects/navigationMenu.ts @@ -5,6 +5,7 @@ export const navigationMenu = { homeNavButton: () => cy.get("[data-cy=home-nav]"), cidsNavButton: () => cy.get("[data-cy=cids-nav]"), bucketsNavButton: () => cy.get("[data-cy=buckets-nav]"), + nftsNavButton: () => cy.get("[data-cy=nfts-nav]"), apiKeysNavButton: () => cy.get("[data-cy=api-keys-nav]"), // settingsNavButton: () => cy.get("[data-cy=settings-nav]"), // docsNavButton: () => cy.get("[data-cy=docs-nav]"), diff --git a/packages/storage-ui/cypress/tests/main-navigation.cy.ts b/packages/storage-ui/cypress/tests/main-navigation.cy.ts index 7fecb7c5fa..c802d3b5b0 100644 --- a/packages/storage-ui/cypress/tests/main-navigation.cy.ts +++ b/packages/storage-ui/cypress/tests/main-navigation.cy.ts @@ -19,6 +19,11 @@ describe("Main Navigation", () => { cy.url().should("include", "/buckets") }) + it.skip("can navigate to the NFTs page", () => { + navigationMenu.nftsNavButton().click() + cy.url().should("include", "/nfts") + }) + it("can navigate to the API keys page", () => { navigationMenu.apiKeysNavButton().click() cy.url().should("include", "/api-keys") @@ -53,6 +58,11 @@ describe("Main Navigation", () => { cy.url().should("include", "/buckets") }) + it.skip("can navigate to the NFTs page", () => { + navigationMenu.nftsNavButton().click() + cy.url().should("include", "/nfts") + }) + it("can navigate to the API keys page", () => { navigationMenu.apiKeysNavButton().click() cy.url().should("include", "/api-keys") From 16d38f81cace7d47f1a6ced593291dd1c678d49f Mon Sep 17 00:00:00 2001 From: Juan Manuel Spoleti <104365141+juans-chainsafe@users.noreply.github.com> Date: Mon, 22 Aug 2022 11:50:22 -0300 Subject: [PATCH 4/9] [Storage] Copy to clipboard secret api key and secret s3 test (#2246) * add and delete a storage api key test * fix navigate to api keys page in mobile context * add and delete s3 key * copy to clipboard secret s3 key and storage key * skip related ipfs tests with 'skip' instead of comment * Update packages/storage-ui/cypress/tests/api-keys-management.cy.ts Co-authored-by: Andrew Snaith Co-authored-by: Andrew Snaith --- .../cypress/tests/api-keys-management.cy.ts | 31 +- .../cypress/tests/bucket-management.cy.ts | 322 +++++++++--------- 2 files changed, 191 insertions(+), 162 deletions(-) diff --git a/packages/storage-ui/cypress/tests/api-keys-management.cy.ts b/packages/storage-ui/cypress/tests/api-keys-management.cy.ts index 90d1a3df28..87baa7fdde 100644 --- a/packages/storage-ui/cypress/tests/api-keys-management.cy.ts +++ b/packages/storage-ui/cypress/tests/api-keys-management.cy.ts @@ -60,6 +60,35 @@ describe("Main Navigation", () => { apiKeysPage.deleteMenuOption().click() apiKeysPage.apiKeyIdCell().should("not.exist") }) - }) + it("can copy secret s3 api key to the clipboard", () => { + // go to api keys section + navigationMenu.apiKeysNavButton().click() + + // add new s3 api key + apiKeysPage.addS3KeyButton().click() + + // ensure can copy to clipboard the secret key + newKeyModal.secretLabel().should("be.visible") + newKeyModal.secretLabel().click() + cy.window().its("navigator.clipboard").invoke("readText").then((text) => { + newKeyModal.secretLabel().should("have.text", text) + }) + }) + + it("can copy to clipboard secret storage api key", () => { + // go to api keys section + navigationMenu.apiKeysNavButton().click() + + // add new s3 api key + apiKeysPage.addApiKeyButton().click() + + // ensure can copy to clipboard the secret key + newKeyModal.secretLabel().should("be.visible") + newKeyModal.secretLabel().click() + cy.window().its("navigator.clipboard").invoke("readText").then((text) => { + newKeyModal.secretLabel().should("have.text", text) + }) + }) + }) }) diff --git a/packages/storage-ui/cypress/tests/bucket-management.cy.ts b/packages/storage-ui/cypress/tests/bucket-management.cy.ts index eb37f290e7..8c3e4a790c 100644 --- a/packages/storage-ui/cypress/tests/bucket-management.cy.ts +++ b/packages/storage-ui/cypress/tests/bucket-management.cy.ts @@ -82,69 +82,69 @@ describe("Bucket management", () => { bucketsPage.bucketItemName().should("not.exist") }) - // it("can create, upload file and delete an ipfs bucket", () => { - // const ipfsBucketName = `ipfs bucket ${Date.now()}` + it.skip("can create, upload file and delete an ipfs bucket", () => { + const ipfsBucketName = `ipfs bucket ${Date.now()}` - // cy.web3Login({ clearPins: true, deleteFpsBuckets: true }) - // navigationMenu.bucketsNavButton().click() + cy.web3Login({ clearPins: true, deleteFpsBuckets: true }) + navigationMenu.bucketsNavButton().click() - // // go to create bucket modal - // bucketsPage.createBucketButton().click() - // createBucketModal.body().should("be.visible") + // go to create bucket modal + bucketsPage.createBucketButton().click() + createBucketModal.body().should("be.visible") - // // ensure can't create an empty bucket - // createBucketModal.submitButton().click() - // createBucketModal.bucketNameInput().should("have.class", "error") + // ensure can't create an empty bucket + createBucketModal.submitButton().click() + createBucketModal.bucketNameInput().should("have.class", "error") - // // ensure can't create a bucket with only spaces - // createBucketModal.bucketNameInput().type(" ") - // createBucketModal.submitButton().click() - // createBucketModal.bucketNameInput().should("have.class", "error") + // ensure can't create a bucket with only spaces + createBucketModal.bucketNameInput().type(" ") + createBucketModal.submitButton().click() + createBucketModal.bucketNameInput().should("have.class", "error") - // // create a bucket and see it in the bucket table - // createBucketModal.bucketNameInput().type(ipfsBucketName) - // createBucketModal.ipfsRadioInput().click() - // createBucketModal.submitButton().click() - // bucketsPage.bucketItemRow().should("have.length", 1) - // bucketsPage.bucketItemName().should("have.text", ipfsBucketName) - // bucketsPage.bucketFileSystemType().should("have.text", "IPFS MFS") + // create a bucket and see it in the bucket table + createBucketModal.bucketNameInput().type(ipfsBucketName) + createBucketModal.ipfsRadioInput().click() + createBucketModal.submitButton().click() + bucketsPage.bucketItemRow().should("have.length", 1) + bucketsPage.bucketItemName().should("have.text", ipfsBucketName) + bucketsPage.bucketFileSystemType().should("have.text", "IPFS MFS") - // // ensure can't create a bucket with the same name - // bucketsPage.createBucketButton().click() - // createBucketModal.bucketNameInput().type(ipfsBucketName) - // createBucketModal.submitButton().click() - // createBucketModal.bucketNameInput().should("have.class", "error") - // createBucketModal.cancelButton().click() + // ensure can't create a bucket with the same name + bucketsPage.createBucketButton().click() + createBucketModal.bucketNameInput().type(ipfsBucketName) + createBucketModal.submitButton().click() + createBucketModal.bucketNameInput().should("have.class", "error") + createBucketModal.cancelButton().click() - // // open bucket and ensure header matches the expected value - // bucketsPage.bucketItemName().dblclick() - // bucketContentsPage.bucketHeaderLabel() - // .should("be.visible") - // .should("contain.text", ipfsBucketName) - - // // upload a file to the bucket - // bucketContentsPage.uploadButton().click() - // fileUploadModal.body().attachFile("../fixtures/uploadedFiles/logo.png") - // fileUploadModal.fileList().should("have.length", 1) - // fileUploadModal.uploadButton().safeClick() - // fileUploadModal.body().should("not.exist") - // bucketContentsPage.awaitBucketRefresh() - // uploadCompleteToast.body().should("be.visible") - // uploadCompleteToast.closeButton().click() - // bucketContentsPage.fileItemRow().should("have.length", 1) - - // // delete ipfs bucket - // navigationMenu.bucketsNavButton().click() - // bucketsPage.bucketRowKebabButton() - // .should("be.visible") - // .click() - // bucketsPage.deleteBucketMenuOption().click() - // deleteBucketModal.body().should("be.visible") - // deleteBucketModal.confirmButton().safeClick() - // deleteBucketModal.body().should("not.exist") - // bucketsPage.bucketItemRow().should("not.exist") - // bucketsPage.bucketItemName().should("not.exist") - // }) + // open bucket and ensure header matches the expected value + bucketsPage.bucketItemName().dblclick() + bucketContentsPage.bucketHeaderLabel() + .should("be.visible") + .should("contain.text", ipfsBucketName) + + // upload a file to the bucket + bucketContentsPage.uploadButton().click() + fileUploadModal.body().attachFile("../fixtures/uploadedFiles/logo.png") + fileUploadModal.fileList().should("have.length", 1) + fileUploadModal.uploadButton().safeClick() + fileUploadModal.body().should("not.exist") + bucketContentsPage.awaitBucketRefresh() + uploadCompleteToast.body().should("be.visible") + uploadCompleteToast.closeButton().click() + bucketContentsPage.fileItemRow().should("have.length", 1) + + // delete ipfs bucket + navigationMenu.bucketsNavButton().click() + bucketsPage.bucketRowKebabButton() + .should("be.visible") + .click() + bucketsPage.deleteBucketMenuOption().click() + deleteBucketModal.body().should("be.visible") + deleteBucketModal.confirmButton().safeClick() + deleteBucketModal.body().should("not.exist") + bucketsPage.bucketItemRow().should("not.exist") + bucketsPage.bucketItemName().should("not.exist") + }) it("can sort by name or file system in buckets table", () => { const firstChainSafeBucketName = `first cs bucket ${Date.now()}` @@ -252,40 +252,40 @@ describe("Bucket management", () => { bucketContentsPage.fileRenameInput().should("have.value", newFolderName) }) - // it("can rename a file inside the ipfs bucket", () => { - // const ipfsBucketName = `ipfs bucket ${Date.now()}` - // const newFileName = `new file name ${Date.now()}` + it.skip("can rename a file inside the ipfs bucket", () => { + const ipfsBucketName = `ipfs bucket ${Date.now()}` + const newFileName = `new file name ${Date.now()}` - // cy.web3Login({ deleteFpsBuckets: true, createFpsBuckets: [{ name: ipfsBucketName, type: "ipfs" }] }) - // navigationMenu.bucketsNavButton().click() + cy.web3Login({ deleteFpsBuckets: true, createFpsBuckets: [{ name: ipfsBucketName, type: "ipfs" }] }) + navigationMenu.bucketsNavButton().click() - // // go inside the bucket - // bucketsPage.bucketItemRow().should("have.length", 1) - // bucketsPage.bucketItemName().dblclick() + // go inside the bucket + bucketsPage.bucketItemRow().should("have.length", 1) + bucketsPage.bucketItemName().dblclick() - // // upload a file - // bucketContentsPage.uploadFileToBucket("../fixtures/uploadedFiles/logo.png") + // upload a file + bucketContentsPage.uploadFileToBucket("../fixtures/uploadedFiles/logo.png") - // // ensure an error is displayed if the edited name of the file is blank - // bucketContentsPage.renameFileOrFolder("{selectall}{del}") - // bucketContentsPage.fileRenameErrorLabel().should("be.visible") + // ensure an error is displayed if the edited name of the file is blank + bucketContentsPage.renameFileOrFolder("{selectall}{del}") + bucketContentsPage.fileRenameErrorLabel().should("be.visible") - // // ensure the original name of the file persists if the rename submission is blank - // bucketContentsPage.renameFileOrFolder("{selectall}{del}{esc}") - // bucketContentsPage.fileRenameInput().should("not.exist") - // bucketContentsPage.fileItemName().contains("logo.png") + // ensure the original name of the file persists if the rename submission is blank + bucketContentsPage.renameFileOrFolder("{selectall}{del}{esc}") + bucketContentsPage.fileRenameInput().should("not.exist") + bucketContentsPage.fileItemName().contains("logo.png") - // // rename the file - // bucketContentsPage.renameFileOrFolder(`{selectall}${newFileName}{enter}`) - // bucketContentsPage.fileItemName().contains(newFileName) + // rename the file + bucketContentsPage.renameFileOrFolder(`{selectall}${newFileName}{enter}`) + bucketContentsPage.fileItemName().contains(newFileName) - // // ensure that the name of the file is reset when renaming is canceled - // bucketContentsPage.renameFileOrFolder("{selectall}{del}abc{esc}") - // bucketContentsPage.fileRenameInput().should("not.exist") - // bucketContentsPage.fileItemKebabButton().click() - // bucketContentsPage.renameMenuOption().click() - // bucketContentsPage.fileRenameInput().should("have.value", newFileName) - // }) + // ensure that the name of the file is reset when renaming is canceled + bucketContentsPage.renameFileOrFolder("{selectall}{del}abc{esc}") + bucketContentsPage.fileRenameInput().should("not.exist") + bucketContentsPage.fileItemKebabButton().click() + bucketContentsPage.renameMenuOption().click() + bucketContentsPage.fileRenameInput().should("have.value", newFileName) + }) it("can rename a file inside the chainsafe bucket", () => { const chainsafeBucketName = `chainsafe bucket ${Date.now()}` @@ -362,61 +362,61 @@ describe("Bucket management", () => { }) }) - // it("can download a file from ipfs bucket", () => { - // const ipfsBucketName = `ipfs bucket ${Date.now()}` - // const fileName = "text-file.txt" - // const downloadsFolder = Cypress.config("downloadsFolder") - // const fileFixturePath = `uploadedFiles/${fileName}` + it.skip("can download a file from ipfs bucket", () => { + const ipfsBucketName = `ipfs bucket ${Date.now()}` + const fileName = "text-file.txt" + const downloadsFolder = Cypress.config("downloadsFolder") + const fileFixturePath = `uploadedFiles/${fileName}` - // cy.web3Login({ deleteFpsBuckets: true, createFpsBuckets: [{ name: ipfsBucketName, type: "ipfs" }] }) + cy.web3Login({ deleteFpsBuckets: true, createFpsBuckets: [{ name: ipfsBucketName, type: "ipfs" }] }) - // // upload a file and store file content - // navigationMenu.bucketsNavButton().click() - // bucketsPage.bucketItemName().dblclick() + // upload a file and store file content + navigationMenu.bucketsNavButton().click() + bucketsPage.bucketItemName().dblclick() - // // upload a file to the bucket - // bucketContentsPage.uploadFileToBucket(`../fixtures/uploadedFiles/${fileName}`) - // cy.fixture(fileFixturePath).as("fileContent") + // upload a file to the bucket + bucketContentsPage.uploadFileToBucket(`../fixtures/uploadedFiles/${fileName}`) + cy.fixture(fileFixturePath).as("fileContent") - // // download file from kebab menu - // bucketContentsPage.fileItemKebabButton().click() + // download file from kebab menu + bucketContentsPage.fileItemKebabButton().click() - // // intercept POST to ensure the request was successful - // cy.intercept("POST", "**/bucket/*/download") - // .as("downloadRequest") - // .then(() => { - // bucketContentsPage.downloadMenuOption().click() - - // cy.wait("@downloadRequest").should((download) => { - // expect(download.response).to.have.property("statusCode", 200) - // }) - // }) - - // // ensure the file was downloaded - // downloadCompleteToast.body().should("be.visible") - // downloadCompleteToast.closeButton().click() - // cy.get("@fileContent").then((fileContent) => { - // cy.readFile(`${downloadsFolder}/${fileName}`) - // .should("exist") - // .should("eq", fileContent) - // }) - // }) + // intercept POST to ensure the request was successful + cy.intercept("POST", "**/bucket/*/download") + .as("downloadRequest") + .then(() => { + bucketContentsPage.downloadMenuOption().click() - // it("can copy to clipboard the cid inside the ipfs bucket", () => { - // const ipfsBucketName = `ipfs bucket ${Date.now()}` + cy.wait("@downloadRequest").should((download) => { + expect(download.response).to.have.property("statusCode", 200) + }) + }) - // cy.web3Login({ deleteFpsBuckets: true, createFpsBuckets: [{ name: ipfsBucketName, type: "ipfs" }] }) - // // upload a file to the bucket - // navigationMenu.bucketsNavButton().click() - // bucketsPage.bucketItemName().dblclick() - // bucketContentsPage.uploadFileToBucket("../fixtures/uploadedFiles/text-file.txt") + // ensure the file was downloaded + downloadCompleteToast.body().should("be.visible") + downloadCompleteToast.closeButton().click() + cy.get("@fileContent").then((fileContent) => { + cy.readFile(`${downloadsFolder}/${fileName}`) + .should("exist") + .should("eq", fileContent) + }) + }) - // // ensure the correct cid is being copied to the clipboard - // bucketContentsPage.fileItemCid().click() - // cy.window().its("navigator.clipboard").invoke("readText").then((text) => { - // bucketContentsPage.fileItemCid().should("have.text", text) - // }) - // }) + it.skip("can copy to clipboard the cid inside the ipfs bucket", () => { + const ipfsBucketName = `ipfs bucket ${Date.now()}` + + cy.web3Login({ deleteFpsBuckets: true, createFpsBuckets: [{ name: ipfsBucketName, type: "ipfs" }] }) + // upload a file to the bucket + navigationMenu.bucketsNavButton().click() + bucketsPage.bucketItemName().dblclick() + bucketContentsPage.uploadFileToBucket("../fixtures/uploadedFiles/text-file.txt") + + // ensure the correct cid is being copied to the clipboard + bucketContentsPage.fileItemCid().click() + cy.window().its("navigator.clipboard").invoke("readText").then((text) => { + bucketContentsPage.fileItemCid().should("have.text", text) + }) + }) it("can copy to clipboard the cid inside the chainsafe bucket", () => { const chainsafeBucketName = `chainsafe bucket ${Date.now()}` @@ -475,45 +475,45 @@ describe("Bucket management", () => { bucketContentsPage.fileItemRow().should("have.length", 0) }) - // it("can delete a file inside the ipfs bucket", () => { - // const ipfsBucketName = `ipfs bucket ${Date.now()}` + it.skip("can delete a file inside the ipfs bucket", () => { + const ipfsBucketName = `ipfs bucket ${Date.now()}` - // cy.web3Login({ deleteFpsBuckets: true, createFpsBuckets: [{ name: ipfsBucketName, type: "ipfs" }] }) - // navigationMenu.bucketsNavButton().click() + cy.web3Login({ deleteFpsBuckets: true, createFpsBuckets: [{ name: ipfsBucketName, type: "ipfs" }] }) + navigationMenu.bucketsNavButton().click() - // // go inside the bucket - // bucketsPage.bucketItemRow().should("have.length", 1) - // bucketsPage.bucketItemName().dblclick() + // go inside the bucket + bucketsPage.bucketItemRow().should("have.length", 1) + bucketsPage.bucketItemName().dblclick() - // // upload a file - // bucketContentsPage.uploadFileToBucket("../fixtures/uploadedFiles/logo.png") + // upload a file + bucketContentsPage.uploadFileToBucket("../fixtures/uploadedFiles/logo.png") - // // delete the file - // bucketContentsPage.deleteFileOrFolder() - // deletionCompleteToast.body().should("be.visible") - // deletionCompleteToast.closeButton().click() - // bucketContentsPage.fileItemRow().should("have.length", 0) - // }) + // delete the file + bucketContentsPage.deleteFileOrFolder() + deletionCompleteToast.body().should("be.visible") + deletionCompleteToast.closeButton().click() + bucketContentsPage.fileItemRow().should("have.length", 0) + }) - // it("can delete a folder inside the ipfs bucket", () => { - // const ipfsBucketName = `ipfs bucket ${Date.now()}` - // const folderName = `folder ${Date.now()}` + it.skip("can delete a folder inside the ipfs bucket", () => { + const ipfsBucketName = `ipfs bucket ${Date.now()}` + const folderName = `folder ${Date.now()}` - // cy.web3Login({ deleteFpsBuckets: true, createFpsBuckets: [{ name: ipfsBucketName, type: "ipfs" }] }) - // navigationMenu.bucketsNavButton().click() + cy.web3Login({ deleteFpsBuckets: true, createFpsBuckets: [{ name: ipfsBucketName, type: "ipfs" }] }) + navigationMenu.bucketsNavButton().click() - // // go inside the bucket - // bucketsPage.bucketItemRow().should("have.length", 1) - // bucketsPage.bucketItemName().dblclick() + // go inside the bucket + bucketsPage.bucketItemRow().should("have.length", 1) + bucketsPage.bucketItemName().dblclick() - // // create a folder inside the bucket - // bucketContentsPage.createNewFolder(folderName) + // create a folder inside the bucket + bucketContentsPage.createNewFolder(folderName) - // // delete the folder - // bucketContentsPage.deleteFileOrFolder() - // deletionCompleteToast.body().should("be.visible") - // deletionCompleteToast.closeButton().click() - // bucketContentsPage.fileItemRow().should("have.length", 0) - // }) + // delete the folder + bucketContentsPage.deleteFileOrFolder() + deletionCompleteToast.body().should("be.visible") + deletionCompleteToast.closeButton().click() + bucketContentsPage.fileItemRow().should("have.length", 0) + }) }) }) From c91edfdd938ebfc9c8ab5963e69f43bd2cd6cf01 Mon Sep 17 00:00:00 2001 From: Juan Manuel Spoleti <104365141+juans-chainsafe@users.noreply.github.com> Date: Wed, 31 Aug 2022 12:26:31 -0300 Subject: [PATCH 5/9] [Storage] Add multiple s3 keys test (#2247) * add and delete a storage api key test * fix navigate to api keys page in mobile context * add and delete s3 key * copy to clipboard secret s3 key and storage key * skip related ipfs tests with 'skip' instead of comment * add multiple s3 api keys test --- .../cypress/tests/api-keys-management.cy.ts | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/packages/storage-ui/cypress/tests/api-keys-management.cy.ts b/packages/storage-ui/cypress/tests/api-keys-management.cy.ts index 87baa7fdde..926c978be1 100644 --- a/packages/storage-ui/cypress/tests/api-keys-management.cy.ts +++ b/packages/storage-ui/cypress/tests/api-keys-management.cy.ts @@ -76,11 +76,11 @@ describe("Main Navigation", () => { }) }) - it("can copy to clipboard secret storage api key", () => { + it("can copy secret storage api key to the clipboard", () => { // go to api keys section navigationMenu.apiKeysNavButton().click() - // add new s3 api key + // add new storage api key apiKeysPage.addApiKeyButton().click() // ensure can copy to clipboard the secret key @@ -90,5 +90,34 @@ describe("Main Navigation", () => { newKeyModal.secretLabel().should("have.text", text) }) }) + + it("can add multiple s3 api keys", () => { + // go to api keys section + navigationMenu.apiKeysNavButton().click() + + // add first s3 api key + apiKeysPage.addS3KeyButton().click() + newKeyModal.secretLabel().should("be.visible") + newKeyModal.keyIdLabel().invoke("text").as("firstKeyId") + newKeyModal.closeButton().click() + + // ensure key id and status of first key are correct in the table + cy.get("@firstKeyId").then((keyId) => { + apiKeysPage.apiKeyIdCell().should("have.text", keyId) + }) + apiKeysPage.apiKeyTypeCell().should("have.text", "s3") + + // add second s3 api key + apiKeysPage.addS3KeyButton().click() + newKeyModal.secretLabel().should("be.visible") + newKeyModal.keyIdLabel().invoke("text").as("secondKeyId") + newKeyModal.closeButton().click() + + // ensure key id and status of second key are correct in the table + cy.get("@secondKeyId").then((keyId) => { + apiKeysPage.apiKeyIdCell().eq(1).should("have.text", keyId) + }) + apiKeysPage.apiKeyTypeCell().eq(1).should("have.text", "s3") + }) }) }) From 71798ab64d7c264f21be9dc9ee2d012dccac2e5a Mon Sep 17 00:00:00 2001 From: Tanmoy Basak Anjan Date: Tue, 4 Oct 2022 20:55:55 +0600 Subject: [PATCH 6/9] Fix/remove need more storage (#2252) * removed modal button * list and buttons --- packages/files-ui/src/Components/Layouts/AppHeader.tsx | 10 +++++----- yarn.lock | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/files-ui/src/Components/Layouts/AppHeader.tsx b/packages/files-ui/src/Components/Layouts/AppHeader.tsx index 8917ea255d..34aa9c191d 100644 --- a/packages/files-ui/src/Components/Layouts/AppHeader.tsx +++ b/packages/files-ui/src/Components/Layouts/AppHeader.tsx @@ -153,9 +153,9 @@ const AppHeader = ({ navOpen, setNavOpen }: IAppHeader) => { window.open(ROUTE_LINKS.DiscordInvite, "_blank") }, []) - const onJoinBetaClick = useCallback(() => { - setIsBetaModalOpen(true) - }, []) + // const onJoinBetaClick = useCallback(() => { + // setIsBetaModalOpen(true) + // }, []) const onUpgradeClick = useCallback(() => { redirect(ROUTE_LINKS.SettingsPath("plan")) @@ -197,14 +197,14 @@ const AppHeader = ({ navOpen, setNavOpen }: IAppHeader) => { > Report a bug - {!isBillingEnabled && } + } */} {isBillingEnabled &&