Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into feature/workspace-markdown…
Browse files Browse the repository at this point in the history
…-editor
  • Loading branch information
MuhammadUmer44 committed Jan 5, 2025
2 parents c8aaef1 + 365712a commit 831cc1a
Show file tree
Hide file tree
Showing 11 changed files with 311 additions and 158 deletions.
10 changes: 7 additions & 3 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { defineConfig } from "cypress";
import { defineConfig } from 'cypress';

export default defineConfig({
viewportWidth: 1800,
viewportHeight: 1200,
video: true,
e2e: {
retries: {
runMode: 3,
openMode: 1
},
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
}
}
});
6 changes: 3 additions & 3 deletions cypress/e2e/23_editWorkspaceDetails.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ describe('Edit Workspace Details', () => {
website: 'https://updated.org'
};

before(() => {
it('should edit workspace details successfully', () => {
cy.login(workspace.loggedInAs);
cy.wait(1000);

cy.contains(workspace.loggedInAs).click();
cy.wait(1000);

cy.create_workspace(workspace);
cy.wait(1000);
});

it('should edit workspace details successfully', () => {
cy.contains(workspace.name).get(`[data-work-name="${workspace.name}"]`).click();
cy.wait(1000);

Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/31_editBountyBySearch.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('Edit Bounty By Searching, Change Workspace And Assignee', () => {

it('should be able to edit a bounty by searching, changing workspace, amount, coding languages, and assignee', () => {
cy.create_bounty(bounty);
cy.wait(1000);
cy.wait(2000);

// Search for the bounty
cy.get('input').type(bounty.title);
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('Edit Bounty By Searching, Change Workspace And Assignee', () => {
cy.get('[data-testid="org_uuid"]').should('exist').click({ force: true }).wait(5000);
cy.wait(1000);
cy.contains(bounty.workspace).should('exist').click({ force: true });

cy.wait(1000);
// Assign a new assignee
cy.get('.SearchInput').type(NewAssignee);
cy.wait(1000);
Expand Down Expand Up @@ -106,7 +106,7 @@ describe('Edit Bounty By Searching, Change Workspace And Assignee', () => {

cy.get('[data-testid="close-btn"]').click(0, 0);
cy.visit('http://localhost:3007/bounties');
cy.wait(1000);
cy.wait(5000);

// Verify the bounty changes
cy.get('input').type(bounty.title);
Expand Down
60 changes: 30 additions & 30 deletions cypress/e2e/32_bountyModalNavigation.cy.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
describe('Alice tries to create 8 bounties and then assert that he can go to the next and previous bounties', () => {
it('Create 8 bounties and assert next and previous bounties', () => {
let activeUser = 'alice';
let activeUser = 'bob';
cy.login(activeUser);
cy.wait(1000);
cy.wait(2000);

const assignees = ['', '', '', 'carol', 'carol', 'carol', 'carol', 'carol'];

Expand All @@ -12,105 +12,105 @@ describe('Alice tries to create 8 bounties and then assert that he can go to the
category: 'Web development',
coding_language: ['Typescript'],
description: 'Lorem Ipsum Dolor',
amount: '10000',
amount: '20000',
assign: assignees[i],
deliverables: 'We are good to go man',
tribe: '',
estimate_session_length: 'Less than 3 hour',
estimate_completion_date: '09/09/2024'
});
cy.wait(1000);
cy.wait(2000);

if (i > 5) {
if (i === 6) {
cy.contains('Filter').click();
cy.contains('Assigned').click();
cy.wait(1000);
cy.wait(2000);
}

cy.contains(`Navigation Bounty Title ${i}`).click();
cy.wait(1000);
cy.wait(2000);

cy.contains('Mark as Paid').click();
cy.wait(1000);
cy.wait(2000);

cy.contains('Next').click();
cy.wait(1000);
cy.wait(2000);

cy.contains('Skip and Mark Paid').click();
cy.wait(1000);
cy.wait(2000);

cy.get('body').click(0, 0);
cy.wait(1000);
cy.wait(2000);
}
}

cy.contains('Filter').click();
cy.contains('Assigned').click();
cy.wait(1000);
cy.wait(2000);

for (let i = 0; i < 3; i++) {
cy.contains(`Navigation Bounty Title ${i}`);
}

cy.contains('Navigation Bounty Title 0').click();
cy.wait(1000);
cy.wait(2000);

cy.contains('chevron_right').click();
cy.wait(1000);
cy.wait(2000);

cy.contains('chevron_left').click();
cy.wait(1000);
cy.wait(2000);

cy.get('[data-testid="close-btn"]').click(0, 0);
cy.wait(1000);
cy.get('[data-testid="close-btn"]').click({ force: true });
cy.wait(2000);

cy.contains('Filter').click();
cy.contains('Paid').click();
cy.wait(1000);
cy.wait(2000);

cy.contains('Navigation Bounty Title 6');
cy.contains('Navigation Bounty Title 7');

cy.contains('Navigation Bounty Title 6').click();
cy.wait(1000);
cy.wait(2000);

cy.contains('chevron_right').click();
cy.wait(1000);
cy.wait(2000);

cy.get('[data-testid="close-btn"]').click(0, 0);
cy.wait(1000);
cy.get('[data-testid="close-btn"]').click({ force: true });
cy.wait(2000);

cy.contains('Filter').click();
cy.contains('Assigned').click();
cy.wait(1000);
cy.wait(2000);

for (let i = 0; i < 8; i++) {
cy.contains(`Navigation Bounty Title ${i}`);
}

cy.contains('Navigation Bounty Title 1').click();
cy.wait(1000);
cy.wait(2000);

cy.contains('chevron_left').click();
cy.wait(1000);
cy.wait(2000);

cy.contains('Navigation Bounty Title 0');
cy.wait(1000);
cy.wait(2000);

cy.contains('chevron_right').click();
cy.wait(1000);
cy.wait(2000);

cy.contains('Navigation Bounty Title 1');
cy.wait(1000);
cy.wait(2000);

cy.contains('chevron_right').click();
cy.wait(1000);
cy.wait(2000);

cy.contains('Navigation Bounty Title 2');
cy.wait(1000);
cy.wait(2000);

cy.get('[data-testid="close-btn"]').click(0, 0);
cy.get('[data-testid="close-btn"]').click({ force: true });
cy.logout(activeUser);
});
});
4 changes: 0 additions & 4 deletions cypress/e2e/42_rolesWithdrawWorkspace.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ describe('Withdraw From Workspace Role Test', () => {
github: 'https://github.com/amazing'
};

beforeEach(() => {
cy.clearCookies();
});

it('should allow a user with a Withdraw From Workspace role to withdraw from the workspace', () => {
cy.login(workspace.loggedInAs);
cy.wait(1000);
Expand Down
4 changes: 0 additions & 4 deletions cypress/e2e/43_rolesFundWorkspace.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ describe('Fund Workspace Role Test', () => {
github: 'https://github.com/amazing'
};

beforeEach(() => {
cy.clearCookies();
});

it('Should allow a user with a Fund Workspave role to deposit into the workspace', () => {
cy.login(workspace.loggedInAs);
cy.wait(1000);
Expand Down
4 changes: 3 additions & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Cypress.Commands.add('login', (userAlias: string) => {
}

cy.visit('http://localhost:3007');
cy.wait(2000);
cy.contains('Sign in').click();

cy.get('[data-challenge]')
Expand Down Expand Up @@ -342,6 +343,7 @@ Cypress.Commands.add('lnurl_login', (seed: string): Cypress.Chainable<string> =>
}

cy.visit('http://localhost:3007');
cy.wait(2000);
cy.contains('Sign in').click();

cy.contains('Login with LNAUTH').click();
Expand Down Expand Up @@ -396,7 +398,7 @@ Cypress.Commands.add('lnurl_login', (seed: string): Cypress.Chainable<string> =>
});

Cypress.Commands.add('clickAlias', (expectedAlias) => {
cy.wait(2000);
cy.wait(3000);
cy.get('[data-testid="loggedInUser"]').within(() => {
cy.get('[data-testid="alias"]')
.should(($el) => {
Expand Down
17 changes: 17 additions & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,27 @@
import './commands';
import nodes from '../fixtures/nodes.json';
import nodesv2 from '../fixtures/v2nodes.json';
import { randomString } from '../../src/helpers/helpers-extended';

// Alternatively you can use CommonJS syntax:
// require('./commands')

const sessionId = randomString(32);

before(() => {
sessionStorage.setItem('sphinx_session_id', sessionId);
});

beforeEach(() => {
if (!sessionStorage.getItem('sphinx_session_id')) {
sessionStorage.setItem('sphinx_session_id', sessionId);
}

cy.intercept('**/*', (req: any) => {
req.headers['x-session-id'] = sessionStorage.getItem('sphinx_session_id');
});
});

async function postAllUsersToTribe() {
for (let i = 0; i < nodes.length; i++) {
const node = nodes[i];
Expand Down
37 changes: 34 additions & 3 deletions src/bounties/__tests__/bountyTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ const mockedApi = api as jest.Mocked<typeof api>;
describe('Bounty Tests', () => {
beforeAll(() => {
Object.defineProperty(window, 'localStorage', { value: localStorageMock });
const Crypto = {
getRandomValues: (arr: Uint8Array) => {
for (let i = 0; i < arr.length; i++) {
arr[i] = Math.floor(Math.random() * 256);
}
return arr;
}
};
global.crypto = Crypto as any;
});

beforeEach(() => {
Expand All @@ -37,6 +46,10 @@ describe('Bounty Tests', () => {
it('should save a new bounty and persist to localStorage', async () => {
global.fetch = jest.fn();
mockedApi.post = jest.fn().mockResolvedValue(newBounty);

mainStore.initializeSessionId();
const { sessionId } = mainStore;

await mainStore.saveBounty(newBounty);
expect(mockedApi.post).toHaveBeenCalledTimes(0);
expect(global.fetch).toHaveBeenCalledTimes(1);
Expand All @@ -45,7 +58,11 @@ describe('Bounty Tests', () => {
'http://localhost:5002/gobounties?token=undefined',
{
body: JSON.stringify(newBounty),
headers: { 'Content-Type': 'application/json', 'x-jwt': undefined },
headers: {
'Content-Type': 'application/json',
'x-jwt': undefined,
'x-session-id': sessionId
},
method: 'POST',
mode: 'cors'
}
Expand All @@ -68,11 +85,18 @@ describe('Bounty Tests', () => {
mockedApi.del = jest.fn().mockResolvedValue({});
await mainStore.deleteBounty(bountyIdToDelete, publicKeyToDelete);

mainStore.initializeSessionId();
const { sessionId } = mainStore;

const deleteRequestContent = [
'http://localhost:5002/gobounties?token=undefined',
{
body: JSON.stringify(newBounty),
headers: { 'Content-Type': 'application/json', 'x-jwt': undefined },
headers: {
'Content-Type': 'application/json',
'x-jwt': undefined,
'x-session-id': sessionId
},
method: 'POST',
mode: 'cors'
}
Expand All @@ -89,11 +113,18 @@ describe('Bounty Tests', () => {
it('should fetch and persist people bounties to localStorage', async () => {
await mainStore.getPeopleBounties();

mainStore.initializeSessionId();
const { sessionId } = mainStore;

const peopleRequestContent = [
'http://localhost:5002/gobounties?token=undefined',
{
body: JSON.stringify(newBounty),
headers: { 'Content-Type': 'application/json', 'x-jwt': undefined },
headers: {
'Content-Type': 'application/json',
'x-jwt': undefined,
'x-session-id': sessionId
},
method: 'POST',
mode: 'cors'
}
Expand Down
Loading

0 comments on commit 831cc1a

Please sign in to comment.