diff --git a/cypress/e2e/26_createOrgWithImage.cy.ts b/cypress/e2e/26_createOrgWithImage.cy.ts new file mode 100644 index 000000000..ebc316700 --- /dev/null +++ b/cypress/e2e/26_createOrgWithImage.cy.ts @@ -0,0 +1,22 @@ +describe('Create Workspace With Image', () => { + it('creates a workspace with an uploaded image', () => { + const workspace: Cypress.Workspace = { + loggedInAs: 'carol', + name: 'New Workspace With Image', + description: 'We are testing workspace image upload during creation', + website: 'https://community.sphinx.chat', + github: 'https://github.com/stakwork/sphinx-tribes-frontend', + imageFileName: 'workspace-logo.png' + }; + + cy.login(workspace.loggedInAs); + cy.wait(1000); + + cy.create_workspace(workspace); + + cy.contains('Sucessfully created workspace').should('exist'); + cy.contains(workspace.name).should('exist'); + + cy.logout(workspace.loggedInAs); + }); +}); diff --git a/cypress/global.d.ts b/cypress/global.d.ts index 74e70aec3..9c326f296 100644 --- a/cypress/global.d.ts +++ b/cypress/global.d.ts @@ -52,6 +52,7 @@ declare namespace Cypress { website?: string; github?: string; feature_call?: string; + imageFileName?: string; }; type InvoiceDetail = { diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 618f89b14..feeb9693f 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -41,6 +41,17 @@ import { bech32 } from 'bech32'; const EC = require('elliptic').ec; const v2AdminToken = 'xyzxyzxyz'; +const workspaceLogoPngBase64 = + 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+/p9sAAAAASUVORK5CYII='; + +function getWorkspaceLogoFile(fileName = 'workspace-logo.png') { + return { + contents: Cypress.Buffer.from(workspaceLogoPngBase64, 'base64'), + fileName, + mimeType: 'image/png', + lastModified: Date.now() + }; +} Cypress.Commands.add('login', (userAlias: string) => { let user; @@ -433,6 +444,12 @@ Cypress.Commands.add('create_workspace', (workspace) => { cy.get('[placeholder="Github link..."]').type(workspace.github); } + if (workspace.imageFileName) { + cy.get('#file-input').selectFile(getWorkspaceLogoFile(workspace.imageFileName), { + force: true + }); + } + cy.contains('* Required fields').next().click(); });