Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elraphty committed May 10, 2024
1 parent 9312252 commit e31c078
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/13_depositToWorkspace.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('It desposits to a workspace ', () => {
cy.contains('Successfully Deposited');
cy.get('body').click(0, 0);

cy.contains(`${budgetAmount.toLocaleString()} SATS`);
cy.contains(`${budgetAmount.toLocaleString()} SATS`).should('exists', { timeout: 2000 });
});

// logout
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/18_withdrawWorkspaceBudget.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('It Withdraws from Workspace budget', () => {
cy.get('body').click(0, 0);
cy.wait(1000);

cy.contains(currentAmount.toLocaleString());
cy.contains(currentAmount.toLocaleString()).should('exist', { timeout: 2000 });
cy.wait(500);

// logout
Expand Down
19 changes: 8 additions & 11 deletions cypress/e2e/29_paymentHistory.cy.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { formatSat } from '../../src/helpers/helpers-extended';

describe('It Lists all payments in history', () => {
it('It adds budget, withdraw budget, pay bounties and see all the payments in history', async () => {
it('It adds budget, withdraw budget, pay bounties and see all the payments in history', () => {
const activeUser = 'alice';
cy.login(activeUser);
cy.wait(1000);

// create workspace
const workSpace = {
loggedInAs: activeUser,
name: 'Deduct Budget Pay3',
name: 'Test Workspace',
description: 'We are testing out our workspace',
website: 'https://community.sphinx.chat',
github: 'https://github.com/stakwork/sphinx-tribes-frontend'
Expand All @@ -18,7 +18,8 @@ describe('It Lists all payments in history', () => {
cy.create_workspace(workSpace);
cy.wait(1000);

cy.contains('Manage').click();
cy.contains(workSpace.name).contains('Manage').click();
cy.wait(1000);

const depositAmount = 10000;
const withdrawAmount = 2000;
Expand Down Expand Up @@ -63,10 +64,12 @@ describe('It Lists all payments in history', () => {
cy.get('body').click(0, 0);
cy.wait(1000);

cy.contains(afterWithdrawAmount.toLocaleString());
cy.contains(afterWithdrawAmount.toLocaleString()).should('exist', { timeout: 2000 });
cy.wait(500);
});

cy.wait(1000);

// create and pay bounty
const bounty: Cypress.Bounty = {
title: 'My History Bounty',
Expand Down Expand Up @@ -126,13 +129,7 @@ describe('It Lists all payments in history', () => {
cy.get('body').click(0, 0);
cy.wait(1000);

// cy.contains(finalPaymentAmount.toLocaleString()).should('exist');
cy.get('[data-testid="current-balance-amount"]')
.invoke('text')
.then((text) => {
expect(text).equal(finalPaymentAmount.toLocaleString());
});
cy.wait(1000);
cy.contains(finalPaymentAmount.toLocaleString()).should('exist', { timeout: 2000 });

cy.logout(activeUser);
});
Expand Down
4 changes: 2 additions & 2 deletions src/people/widgetViews/WorkspaceDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ const WorkspaceDetails = (props: {
const onSubmitUser = async (body: any) => {
setIsLoading(true);

body.org_uuid = uuid;
body.workspace_uuid = uuid;

const res = await main.addWorkspaceUser(body);
if (res.status === 200) {
Expand Down Expand Up @@ -265,7 +265,7 @@ const WorkspaceDetails = (props: {
.filter((r: any) => r.status)
.map((role: any) => ({
owner_pubkey: user?.owner_pubkey,
org_uuid: uuid,
workspace_uuid: uuid,
role: role.name
}));

Expand Down
2 changes: 1 addition & 1 deletion src/store/__test__/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ describe('Main store', () => {

const workspaceUser = {
owner_pubkey: user.owner_pubkey || '',
org_uuid: mockApiResponseData[2]
workspace_uuid: mockApiResponseData[2]
};

const expectedHeaders = {
Expand Down
11 changes: 7 additions & 4 deletions src/store/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2403,11 +2403,14 @@ export class MainStore {
}
}

@action async addWorkspaceUser(body: { owner_pubkey: string; org_uuid: string }): Promise<any> {
@action async addWorkspaceUser(body: {
owner_pubkey: string;
workspace_uuid: string;
}): Promise<any> {
try {
if (!uiStore.meInfo) return null;
const info = uiStore.meInfo;
const r: any = await fetch(`${TribesURL}/workspaces/users/${body.org_uuid}`, {
const r: any = await fetch(`${TribesURL}/workspaces/users/${body.workspace_uuid}`, {
method: 'POST',
mode: 'cors',
body: JSON.stringify({
Expand Down Expand Up @@ -2754,11 +2757,11 @@ export class MainStore {
}
}

async workspaceInvoiceCount(org_uuid: string): Promise<any> {
async workspaceInvoiceCount(workspace_uuid: string): Promise<any> {
try {
if (!uiStore.meInfo) return 0;
const info = uiStore.meInfo;
const r: any = await fetch(`${TribesURL}/workspaces/invoices/count/${org_uuid}`, {
const r: any = await fetch(`${TribesURL}/workspaces/invoices/count/${workspace_uuid}`, {
method: 'GET',
mode: 'cors',
headers: {
Expand Down

0 comments on commit e31c078

Please sign in to comment.