Skip to content

Commit

Permalink
feat: merge branch 'arb-ltip' into deployments/arbitrum
Browse files Browse the repository at this point in the history
  • Loading branch information
acaldas committed Jul 31, 2024
2 parents 56800e6 + 11ed46f commit adbf58a
Show file tree
Hide file tree
Showing 24 changed files with 4,471 additions and 5,397 deletions.
177 changes: 173 additions & 4 deletions CHANGELOG.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ export default defineConfig({
// implement node event listeners here
},
},
env: {
TEST_PUBLIC_DRIVE:
'https://apps.powerhouse.io/develop/powerhouse/switchboard/d/test',
TEST_PUBLIC_DRIVE_NAME: 'Test',
},
});
299 changes: 291 additions & 8 deletions cypress/e2e/navigation.cy.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,39 @@
/// <reference types="cypress" />

import { clearIndexDB, newFolder } from './utils';
import {
addPublicDrive,
clearIndexDB,
clickContentViewItem,
clickContentViewItemOption,
clickSidebarItemOption,
connectDebugMenu,
getBreadcrumbItem,
newFolder,
selectSidebarItem,
} from './utils';

describe('Navigation', () => {
const maxRetries = 5;

const validateGraphQLQuery = (retryCount = 0, expectedStatusCode = 200) => {
cy.wait('@graphqlQuery').then(interception => {
if (interception.response.statusCode === expectedStatusCode) {
assert.equal(
interception.response.statusCode,
expectedStatusCode,
`GraphQL query should return a ${expectedStatusCode} status`,
);
} else if (retryCount < maxRetries) {
cy.log(
`Retry ${retryCount + 1}: GraphQL query failed with status ${interception.response.statusCode}`,
);
validateGraphQLQuery(retryCount + 1, expectedStatusCode);
} else {
assert.fail(`GraphQL query failed after ${maxRetries} retries`);
}
});
};

before(async () => {
cy.clearAllSessionStorage();
await clearIndexDB();
Expand Down Expand Up @@ -35,11 +66,263 @@ describe('Navigation', () => {
cy.contains('Close').click();
});

// it.only('should add public drive', () => {
// addPublicDrive(
// 'https://apps.powerhouse.io/powerhouse/switchboard/d/powerhouse',
// );
// cy.contains('article', 'Powerhouse').should('be.visible');
// selectSidebarItem('Powerhouse');
// });
it('should add public drive', () => {
const publicDriveUrl = Cypress.env('TEST_PUBLIC_DRIVE') as string;
const publicDriveName = Cypress.env('TEST_PUBLIC_DRIVE_NAME') as string;

addPublicDrive(publicDriveUrl);
cy.contains('article', publicDriveName).should('be.visible');
selectSidebarItem(publicDriveName);
});

it('should create and delete a folder inside test drive', () => {
const publicDriveName = Cypress.env('TEST_PUBLIC_DRIVE_NAME') as string;
selectSidebarItem(publicDriveName);
newFolder(publicDriveName, 'test-folder');
cy.contains('test-folder').should('exist');

clickSidebarItemOption('test-folder', 'delete');

cy.contains('button', 'Delete').click();
cy.contains('test-folder').should('not.exist');
});

it('should rename a folder inside test drive', () => {
const publicDriveName = Cypress.env('TEST_PUBLIC_DRIVE_NAME') as string;
selectSidebarItem(publicDriveName);
newFolder(publicDriveName, 'test-folder');
clickSidebarItemOption('test-folder', 'rename');

cy.get('input[value="test-folder"]')
.clear()
.type('renamed-folder{enter}');
cy.contains('renamed-folder').should('exist');
clickSidebarItemOption('renamed-folder', 'delete');
cy.contains('button', 'Delete').click();
});

it('should duplicate a folder inside test drive', () => {
const publicDriveName = Cypress.env('TEST_PUBLIC_DRIVE_NAME') as string;
selectSidebarItem(publicDriveName);
newFolder(publicDriveName, 'test-folder');
clickSidebarItemOption('test-folder', 'duplicate');

cy.contains('test-folder').should('exist');
cy.contains('test-folder (copy) 1').should('exist');

clickSidebarItemOption('test-folder', 'delete');
cy.contains('button', 'Delete').click();

clickSidebarItemOption('test-folder (copy) 1', 'delete');
cy.contains('button', 'Delete').click();
});

it('should create a document model inside test drive folder', () => {
const publicDriveName = Cypress.env('TEST_PUBLIC_DRIVE_NAME') as string;
selectSidebarItem(publicDriveName);

newFolder(publicDriveName, 'test-folder');
selectSidebarItem('test-folder');

cy.contains('DocumentModel').click();
cy.get('input[placeholder="Document name"]')
.clear()
.type('test-document');
cy.get('button').contains('Create').click();
cy.get('textarea[placeholder="Document Model Name"]').type('draft1');

cy.contains('Global State Schema').click();
cy.contains('Close').click();

cy.contains('draft1').should('exist');

clickSidebarItemOption('test-folder', 'delete');
cy.contains('button', 'Delete').click();
});

it('should navigate by clicking folder items in content view', () => {
const publicDriveName = Cypress.env('TEST_PUBLIC_DRIVE_NAME') as string;
selectSidebarItem(publicDriveName);

newFolder(publicDriveName, 'test-folder');
newFolder('test-folder', 'test-folder-2');
newFolder('test-folder-2', 'test-folder-3');
newFolder('test-folder-3', 'test-folder-4');

selectSidebarItem('test-folder');

clickContentViewItem('test-folder-2');
clickContentViewItem('test-folder-3');
clickContentViewItem('test-folder-4');

clickSidebarItemOption('test-folder', 'delete');
cy.contains('button', 'Delete').click();
});

it('should navigate using the breadcrumb', () => {
const publicDriveName = Cypress.env('TEST_PUBLIC_DRIVE_NAME') as string;
selectSidebarItem(publicDriveName);

newFolder(publicDriveName, 'test-folder');
newFolder('test-folder', 'test-folder-2');
newFolder('test-folder-2', 'test-folder-3');
newFolder('test-folder-3', 'test-folder-4');

selectSidebarItem('test-folder-4');

getBreadcrumbItem('test-folder-3').should('be.visible').click();
getBreadcrumbItem('test-folder-4').should('not.exist');

getBreadcrumbItem('test-folder-2').should('be.visible').click();
getBreadcrumbItem('test-folder-3').should('not.exist');

getBreadcrumbItem('test-folder').should('be.visible').click();
getBreadcrumbItem('test-folder-2').should('not.exist');

getBreadcrumbItem(publicDriveName).should('be.visible').click();
getBreadcrumbItem('test-folder').should('not.exist');

clickSidebarItemOption('test-folder', 'delete');
cy.contains('button', 'Delete').click();
});

it('should open switchboard from document link', () => {
const rwaDocumentCloseSelector =
'#document-editor-context > div > div.flex.items-center.justify-between > div.flex.justify-end.gap-x-2 > button.grid.size-8.place-items-center.rounded.border.border-gray-200.active\\:opacity-50';
const rwaSwitchboardLinkSelector =
'#document-editor-context > div > div.flex.items-center.justify-between > div.flex.justify-end.gap-x-2 > button:nth-child(1)';
const publicDriveName = Cypress.env('TEST_PUBLIC_DRIVE_NAME') as string;
selectSidebarItem(publicDriveName);

newFolder(publicDriveName, 'test-folder');
selectSidebarItem('test-folder');

cy.contains('RWA Portfolio').click();
cy.get('input[placeholder="Document name"]')
.clear()
.type('rwa-document');
cy.get('button').contains('Create').click();

cy.window().then(win => {
cy.stub(win, 'open').as('windowOpen');
});

cy.get(rwaSwitchboardLinkSelector).click();

cy.get('@windowOpen').should('have.been.called');

cy.get(rwaDocumentCloseSelector).click();
cy.contains('rwa-document').should('exist');

clickSidebarItemOption('test-folder', 'delete');
cy.contains('button', 'Delete').click();
});

it('should open switchboard from file item menu', () => {
const rwaDocumentCloseSelector =
'#document-editor-context > div > div.flex.items-center.justify-between > div.flex.justify-end.gap-x-2 > button.grid.size-8.place-items-center.rounded.border.border-gray-200.active\\:opacity-50';
const publicDriveName = Cypress.env('TEST_PUBLIC_DRIVE_NAME') as string;
selectSidebarItem(publicDriveName);

newFolder(publicDriveName, 'test-folder');
selectSidebarItem('test-folder');

cy.contains('RWA Portfolio').click();
cy.get('input[placeholder="Document name"]')
.clear()
.type('rwa-document');
cy.get('button').contains('Create').click();
cy.get(rwaDocumentCloseSelector).click();

cy.contains('rwa-document').should('exist');

cy.window().then(win => {
cy.stub(win, 'open').as('windowOpen');
});

clickContentViewItemOption('rwa-document', 'switchboard-link');

cy.get('@windowOpen').should('have.been.called');

clickSidebarItemOption('test-folder', 'delete');
cy.contains('button', 'Delete').click();
});

it('should open powerhouse webpage', () => {
cy.window().then(win => {
cy.stub(win, 'open').as('windowOpen');
});

cy.get('#ph-logo-link').should('be.visible').click();

cy.get('@windowOpen').should(
'be.calledWith',
'https://www.powerhouse.inc/',
'_blank',
);
});

it('should collapse/expand sidebar', () => {
const sidebarCollapseSelector =
'#sidebar > div.no-scrollbar.flex-1.overflow-auto.text-gray-900.transition-shadow > div.flex-shrink-0.mb-4.flex.justify-between.gap-4.px-4.pt-11.collapsed\\:justify-center > button';

cy.get(sidebarCollapseSelector).click();
cy.get('#sidebar').invoke('outerWidth').should('eq', 58);

cy.get(sidebarCollapseSelector).click();
cy.get('#sidebar').invoke('outerWidth').should('eq', 304);
});

it('should open settings', () => {
cy.contains('Settings').click();
cy.get('div[role="dialog"]').should('be.visible');
cy.contains('Cancel').click();
cy.get('div[role="dialog"]').should('not.exist');
});

it('should enable/disable connect debug mode', () => {
connectDebugMenu(true);
cy.get('#connect-debug-button').should('be.visible');

connectDebugMenu(false);
cy.get('#connect-debug-button').should('not.exist');
});

it('should register a new pull responder trigger when it becomes invalid', () => {
const publicDriveName = Cypress.env('TEST_PUBLIC_DRIVE_NAME') as string;
const publicDriveUrl = Cypress.env('TEST_PUBLIC_DRIVE') as string;

connectDebugMenu(true);
cy.get('#connect-debug-button').click();

cy.intercept('POST', publicDriveUrl, req => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (req.body.operationName === 'strands') {
req.alias = 'graphqlQuery';
}
});

cy.get('#selectedDrive').click();
cy.get('#selectedDrive').contains(publicDriveName).click();

cy.get('#autoRegisterPullResponder').click();
cy.get('#autoRegisterPullResponder').contains('Disabled').click();

cy.get('#driveTrigger').click();
cy.get('div[role="option"]').click();
cy.contains('button', 'Remove Trigger').click();

cy.get('#driveUrl').clear().type(`${publicDriveUrl}{enter}`);
cy.contains('button', 'Add Invalid Trigger').click();

validateGraphQLQuery(0, 400);

cy.get('#autoRegisterPullResponder').click();
cy.get('div[role="option"]').contains('Enabled').click();

validateGraphQLQuery(0, 200);

cy.get('#close-modal').click();
connectDebugMenu(false);
});
});
Loading

0 comments on commit adbf58a

Please sign in to comment.