Open EightRice opened 1 year ago
This is a priority immediately after my onboarding.
Duplicate issue: https://github.com/dOrgTech/homebase-app/issues/702
Integrate the tests done by the upwork team, so that as we're doing new features and fixes we run them through a testing pipeline.
Tests being referred to seem to be in this repository: https://github.com/W3DevTeam/TezosHomebaseTests Below is a good example of a GitHub action that could be run (might have to be adapted for Netlify).
name: Playwright Tests
on:
deployment_status:
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
if: github.event.deployment_status.state == 'success'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Install Playwright
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
env:
PLAYWRIGHT_TEST_BASE_URL: ${{ github.event.deployment_status.target_url }}
Playwright has good documentation to execute on this: https://playwright.dev/docs/ci-intro
Sadly, Netlfiy does not currently send a deployment_status
event: https://answers.netlify.com/t/can-netlify-deliver-deploy-event-to-github-api-after-successful-deployment/10905
Current approach seems to be working but CSS class paths seem to be the cause of the current test failures (timeouts likely due to being unable to find the elements)
It seems like the first test is now getting stuck when it's prompted to connect a wallet when it clicks the deploy button
WIP pull request: https://github.com/dOrgTech/homebase-app/pull/740 New tests repository (fork) to make changes to: https://github.com/dOrgTech/homebase-app-tests
@Man-Jain @EightRice @thenerdcat Were the tests intended to work without a wallet connection? I'm asking because it seems like a wallet was never setup for the tests and yet, when I'm debugging the first test case, it seems to be getting stuck at the wallet connection prompt:
If wallet connection needs to be added, I'm happy to do so, I just wanted to check first since adding that may be somewhat time consuming.
Andrei has custom deployment preview for hardcoded wallet which can be extended
@benefacto This is the deploy preview with the hardcoded wallet: https://deploy-preview-629--tezos-homebase.netlify.app/
This pull request reconfigured the codebase to be testable: https://github.com/dOrgTech/homebase-app/pull/629
Will actually need to use a URL parameter to handle the test mode, maybe something like this: To maintain the test mode URL parameter across navigations in your React app, you can use one of the following approaches:
You can create a HOC that wraps your components and automatically appends the test mode parameter to any navigation links.
Create the HOC:
import React from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
const withTestMode = (WrappedComponent) => {
return (props) => {
const location = useLocation();
const navigate = useNavigate();
const testMode = new URLSearchParams(location.search).get('testMode');
const handleNavigation = (path) => {
navigate(`${path}${testMode ? `?testMode=${testMode}` : ''}`);
};
return <WrappedComponent {...props} navigate={handleNavigation} />;
};
};
export default withTestMode;
Use the HOC:
import withTestMode from './withTestMode';
const MyComponent = ({ navigate }) => {
// Use the `navigate` function passed by the HOC
return (
<button onClick={() => navigate('/next-page')}>Go to Next Page</button>
);
};
export default withTestMode(MyComponent);
Alternatively, you can create a custom hook to handle the navigation logic with the test mode parameter.
Create the Custom Hook:
import { useLocation, useNavigate } from 'react-router-dom';
const useTestModeNavigation = () => {
const location = useLocation();
const navigate = useNavigate();
const testMode = new URLSearchParams(location.search).get('testMode');
const navigateWithTestMode = (path) => {
navigate(`${path}${testMode ? `?testMode=${testMode}` : ''}`);
};
return navigateWithTestMode;
};
export default useTestModeNavigation;
Use the Custom Hook:
import useTestModeNavigation from './useTestModeNavigation';
const MyComponent = () => {
const navigateWithTestMode = useTestModeNavigation();
return (
<button onClick={() => navigateWithTestMode('/next-page')}>Go to Next Page</button>
);
};
export default MyComponent;
In both approaches, the test mode parameter is preserved in the URL during navigation. This helps maintain a consistent application state based on the URL parameter, ensuring that the test mode remains active across different views and user interactions. Choose the approach that best fits your application architecture and coding style.
Need access to LaunchDarkly as that's the feature flag system that's already setup: https://github.com/dOrgTech/homebase-app/blob/0938a65e51ed0d0f557b2acda9189473a2a8ebc6/src/services/config/hooks/featureFlags.ts#L1
Magenta now has access and can grant me it
What's remaining on this one is to setup a feature flag (LaunchDarkly) such that when it is passed, the app is considered to be in test mode (using the test wallet rather than the connected one), then this URL should be used by the GitHub action for testing purposes (possible that you might need a wait for Netlify action: https://github.com/JakePartusch/wait-for-netlify-action); possible that tests may need tweaks to use the latest UI
Have the tests perform on every merge / PR creation