Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃И 780 implementing new way of creating tests #791

Merged
merged 6 commits into from Jun 27, 2022

Conversation

xoscar
Copy link
Collaborator

@xoscar xoscar commented Jun 22, 2022

This PR is quite chunky! 馃ゴ We are adding a new way of creating tests by migration from the modal to a new page. We are also introducing plugins and sequences depending on the different steps a plugin might have.

Changes

  • Create test page
  • Plugin logic

Fixes

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

https://www.loom.com/share/8f192908584542f1b30cb74267609981

@xoscar xoscar requested a review from cescoferraro June 22, 2022 21:08
@xoscar xoscar self-assigned this Jun 22, 2022
@xoscar xoscar linked an issue Jun 22, 2022 that may be closed by this pull request
@@ -10,14 +10,19 @@ describe('Create test', () => {
it('should create a basic GET test from scratch', () => {
const $form = openCreateTestModal();

$form.get('[data-cy=method-select]').click();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating the creation test flows to match the new page

@@ -0,0 +1,22 @@
import * as S from './CreateTestHeader.styled';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New header component for the create test page

testSuite: string;
}

const BasicDetails = () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of the default steps forms that can be reused for multiple plugins

selectedDemo?: IDemoTestExample;
}

const BasicDetailsForm = ({form, onSubmit, onSelectDemo, onValidation, selectedDemo}: IProps) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another step form

const SelectPlugin = () => {
const {onUpdatePlugin, pluginName, onNext} = useCreateTest();
const [selectedPlugin, setSelectedPlugin] = useState(pluginName);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initial step when creating a test, it shows the list of available plugins

[SupportedPlugins.REST]: Rest,
[SupportedPlugins.Messaging]: {},
[SupportedPlugins.RPC]: {},
[SupportedPlugins.Postman]: {},
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the component mapping for our factories 馃彮

const {stepNumber, stepList, onPrev, onCreateTest, isLoading} = useCreateTest();

return (
<S.Footer>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Navigation control for the steps

}

const CreateTestSteps = ({stepList, selectedKey, pluginName, onGoTo}: IProps) => {
return (
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on the selected plugins the steps will be changing

onSelect(plugin: IPlugin): void;
}

const PluginCard = ({plugin: {title, description, isActive}, plugin, onSelect, isSelected}: IProps) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basic plugin info

],
};

const Rest: IPlugin = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where we create the plugins by specifying each of the steps, types, active status, and whatnot


export const useCreateTest = () => useContext(Context);

const CreateTestProvider = ({children}: IProps) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provides the draft test, navigation control and creation of the test

pluginName: SupportedPlugins.REST,
};

const createTestSlice = createSlice({
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stores everything related to the create test flow

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be typed

@xoscar xoscar marked this pull request as ready for review June 22, 2022 21:19
@xoscar xoscar requested a review from jorgeepc June 22, 2022 21:19
Copy link
Contributor

@jorgeepc jorgeepc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @xoscar 馃敟

}, [form, request]);

useEffect(() => {
onRefreshData();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, why do we need this effect?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The form gets stale if you go back one or multiple steps and if you change something at a prev step it wont reflect the changes.

{title}{' '}
{!isActive && (
<>
- <a href={GITHUB_ISSUES_URL}>Coming soon!</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a target blank here

Copy link
Contributor

@cescoferraro cescoferraro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good. I would just invest some time typing the new slice definition.

@xoscar xoscar merged commit eb9d206 into main Jun 27, 2022
@xoscar xoscar deleted the 780-implement-new-create-test-page branch June 27, 2022 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement new Create Test Page
3 participants