Skip to content

Commit

Permalink
Merge pull request #1791 from OpenQDev/vitest-migration
Browse files Browse the repository at this point in the history
Vitest migration
  • Loading branch information
Christopher-Stevers authored Apr 13, 2023
2 parents e99c4da + bdb4213 commit ae62440
Show file tree
Hide file tree
Showing 505 changed files with 5,702 additions and 1,170 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ jobs:
- run:
name: Test application
command: |
TEST=$(circleci tests glob "__tests__/**/*.test.js" | circleci tests split --split-by=timings)
TEST=$(circleci tests glob "**/*.test.js" | circleci tests split --split-by=timings)
docker exec openq-frontend yarn test:cicd $TEST
echo $TEST
- run:
command: mkdir ~/test-results && docker cp openq-frontend:/app/junit.xml ~/test-results/junit.xml
command: mkdir ~/junit docker cp openq-frontend:/app/junit.xml ~/junit/
when: always
- store_test_results:
path: ~/test-results//junit.xml
path: ~/junit
- store_artifacts:
path: ~/test-results//junit.xml
path: ~/junit

pushHelm:
machine: true
Expand Down
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
"unused-imports",
"prettier"
],
"globals": {
"vi": true
},
"rules": {
"no-async-promise-executor": "off",
"no-inner-declarations": "off",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vi-environment jsdom
*/
import React from 'react';
import GithubAuth from '../../pages/auth/github';
Expand All @@ -9,20 +9,20 @@ import nextRouter from 'next/router';

describe('GithubAuth', () => {
beforeEach(() => {
const observe = jest.fn();
const disconnect = jest.fn();
const observe = vi.fn();
const disconnect = vi.fn();

window.IntersectionObserver = jest.fn(() => ({
window.IntersectionObserver = vi.fn(() => ({
observe,
disconnect,
}));

nextRouter.useRouter = jest.fn();
nextRouter.useRouter = vi.fn();

nextRouter.useRouter.mockImplementation(() => ({
query: { type: null },
prefetch: jest.fn(() => {
return { catch: jest.fn };
prefetch: vi.fn(() => {
return { catch: vi.fn };
}),
}));
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vi-environment jsdom
*/
import React from 'react';
import { render, screen } from '../../../test-utils';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vi-environment jsdom
*/
import React from 'react';
import { render, screen } from '../../../test-utils';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vi-environment jsdom
*/
import React from 'react';
import { render, screen } from '../../../test-utils';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vi-environment jsdom
*/
import React from 'react';
import { render, screen } from '../../../test-utils';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vi-environment jsdom
*/
import React from 'react';
import { render, screen } from '../../test-utils';
Expand Down
165 changes: 0 additions & 165 deletions components/AdminPage/SetBudgetAdminPage/SetBudgetAdminPage.test.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* @vi-environment jsdom
*/
import React from 'react';
import { render, screen } from '../../../test-utils';
import SetBudgetAdminPage from '.';
import InitialState from '../../../store/Store/InitialState';
import Constants from '../../../test-utils/constant';
import userEvent from '@testing-library/user-event';
import MockOpenQClient from '../../../services/ethers/MockOpenQClient';

describe('SetBudgetAdminPage', () => {
const bounty = Constants.bounty;
beforeEach(() => {
InitialState.openQClient.reset();
const observe = vi.fn();
const disconnect = vi.fn();
window.IntersectionObserver = vi.fn(() => ({
observe,
disconnect,
}));
});

describe('Fixed price contracts', () => {
it('should allow user to update budget', async () => {
// ARRANGE
const user = userEvent.setup();
const setFundingGoal = vi.fn();
const customInitialState = {
...InitialState,
openQClient: new MockOpenQClient({ setFundingGoal }),
};
render(<SetBudgetAdminPage refreshBounty={() => {}} bounty={bounty} />, {}, customInitialState);
expect(screen.getByText('Set a New Budget for this Contract')).toBeInTheDocument();

// ACT
await user.type(screen.getByRole('textbox'), '100');
await user.click(screen.getByRole('button', { name: 'select token' }));
await user.click(screen.getByRole('button', { name: /link/i }));
await user.click(await screen.findByRole('button', { name: 'Set New Budget' }));

// ASSERT
expect(await screen.findByText(/Updating Budget.../)).toBeInTheDocument();
expect(screen.getByText(/our request is being processed.../)).toBeInTheDocument();
const updatedTexts = await screen.findAllByText(/updated/i);
expect(updatedTexts[0]).toBeInTheDocument();
expect(await screen.findByText(/budget set to/i)).toBeInTheDocument();
expect(await screen.findByText(/100.0 LINK/)).toBeInTheDocument();
expect(setFundingGoal).toBeCalledWith(bounty.bountyId, '100', '0x5FbDB2315678afecb367f032d93F642f64180aa3');
});
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// vi Snapshot v1, https://goo.gl/fbAQLP

exports[`SetBudgetAdminPage Split Price Contracts should allow user to update budget token and volume when no deposits: Snapshot: initial view 1`] = `
<DocumentFragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { waitFor } from '@testing-library/react';
describe('SetTierAdminPage', () => {
beforeEach(() => {
InitialState.openQClient.reset();
const observe = jest.fn();
const disconnect = jest.fn();
window.IntersectionObserver = jest.fn(() => ({
const observe = vi.fn();
const disconnect = vi.fn();
window.IntersectionObserver = vi.fn(() => ({
observe,
disconnect,
}));
Expand Down Expand Up @@ -42,7 +42,7 @@ describe('SetTierAdminPage', () => {
const bounty = Constants.bounty3;
// ARRANGE
const user = userEvent.setup();
const setTier = jest.fn();
const setTier = vi.fn();
const customInitialState = {
...InitialState,
openQClient: new MockOpenQClient({ setTier }),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// vi Snapshot v1, https://goo.gl/fbAQLP

exports[`SetTierAdminPage should match DOM and render "Which token?", "Volumes:" if bounty type is 3 1`] = `
<DocumentFragment>
Expand Down
Loading

0 comments on commit ae62440

Please sign in to comment.