Skip to content

Commit

Permalink
Merge pull request #502 from powerhouse-inc/479-setup-connect-tests-o…
Browse files Browse the repository at this point in the history
…n-pushes--pull-requests-to-other-branches-rc

feat: setup connect tests on pull requests to other branches
  • Loading branch information
gpuente authored Aug 29, 2024
2 parents 4f0429a + a6682b6 commit 2e19164
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 41 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/e2e-dev.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: End-to-end tests

on:
push:
branches: [develop]
pull_request:
branches:
- main
- develop
- staging
- production
- deployments/**
workflow_dispatch:
jobs:
cypress-run:
Expand Down
4 changes: 2 additions & 2 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default defineConfig({
},
env: {
TEST_PUBLIC_DRIVE:
'https://apps.powerhouse.io/develop/powerhouse/switchboard/d/test',
TEST_PUBLIC_DRIVE_NAME: 'Test',
'https://apps.powerhouse.io/develop/powerhouse/switchboard/d/cypress-test',
TEST_PUBLIC_DRIVE_NAME: 'CypressTest',
},
});
34 changes: 18 additions & 16 deletions cypress/e2e/navigation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('Navigation', () => {
});

it('should create a default local drive', () => {
cy.get('article').contains('My Local Drive').should('exist');
cy.get('p').contains('My Local Drive').should('exist');
});

it('should create a folder inside the local drive', () => {
Expand All @@ -60,6 +60,7 @@ describe('Navigation', () => {
.clear()
.type('test-document');
cy.get('button').contains('Create').click();
selectSidebarItem('test-document');
cy.get('textarea[placeholder="Document Model Name"]').type('draft1');

cy.contains('Global State Schema').click();
Expand All @@ -71,20 +72,20 @@ describe('Navigation', () => {
const publicDriveName = Cypress.env('TEST_PUBLIC_DRIVE_NAME') as string;

addPublicDrive(publicDriveUrl);
cy.contains('article', publicDriveName).should('be.visible');
cy.contains('.mr-1', 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');
newFolder(publicDriveName, 'test-folder-delete');
cy.contains('test-folder-delete').should('exist');

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

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

it('should rename a folder inside test drive', () => {
Expand All @@ -104,16 +105,16 @@ describe('Navigation', () => {
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');
newFolder(publicDriveName, 'test-folder-duplicate');
clickSidebarItemOption('test-folder-duplicate', 'duplicate');

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

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

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

Expand Down Expand Up @@ -188,9 +189,9 @@ describe('Navigation', () => {

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';
'.justify-between > :nth-child(2) > .grid';
const rwaSwitchboardLinkSelector =
'#document-editor-context > div > div.flex.items-center.justify-between > div.flex.justify-end.gap-x-2 > button:nth-child(1)';
'[dir="ltr"] > .justify-between > :nth-child(2) > :nth-child(1)';
const publicDriveName = Cypress.env('TEST_PUBLIC_DRIVE_NAME') as string;
selectSidebarItem(publicDriveName);

Expand Down Expand Up @@ -218,9 +219,10 @@ describe('Navigation', () => {
cy.contains('button', 'Delete').click();
});

it('should open switchboard from file item menu', () => {
// TODO: check why switchboard link option is not available for files
it.skip('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';
'.justify-between > :nth-child(2) > .grid';
const publicDriveName = Cypress.env('TEST_PUBLIC_DRIVE_NAME') as string;
selectSidebarItem(publicDriveName);

Expand Down
38 changes: 17 additions & 21 deletions cypress/e2e/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,41 +67,39 @@ export const clickSidebarItemOption = (
folderName: string,
option: SidebarItemOption,
) => {
cy.get('article')
cy.get('.mr-1')
.contains(folderName)
.then(el => {
hoverElement(el[0]);
});

cy.get('article')
.contains(folderName)
.closest('article')
.closest('div')
.children('button')
.click();
.invoke('removeClass', 'hidden')
.click()
.invoke('addClass', 'hidden');

const optionName = getOptionName(option);
cy.contains(optionName).click();
};

export const newFolder = (parent: string, folderName: string) => {
cy.get('article')
.contains(parent)
.then(el => {
hoverElement(el[0]);
});

cy.get('article')
cy.get('.mr-1')
.contains(parent)
.closest('article')
.closest('div')
.children('button')
.click();
.invoke('removeClass', 'hidden')
.click()
.invoke('addClass', 'hidden');

cy.contains('New Folder').click();
cy.get('input[value="New Folder"]').clear().type(`${folderName}{enter}`);

cy.get('.mr-1')
.contains(parent)
.closest('div')
.children('button')
.invoke('addClass', 'hidden');
};

export const selectSidebarItem = (item: string) => {
cy.get('article').contains(item).click();
cy.get('.mr-1').contains(item).click();
};

export const addPublicDrive = (url: string) => {
Expand Down Expand Up @@ -143,9 +141,7 @@ export const clickContentViewItemOption = (
cy.get('#content-view')
.contains(itemName)
.parent()
.parent()
.next()
.children('svg')
.invoke('attr', 'style', 'display: inline-block; width: 24px')
.click();

Expand Down

0 comments on commit 2e19164

Please sign in to comment.