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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: updated containers, unified styles and refactored prompt-config wizard #216

Merged
merged 10 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ repos:
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
exclude: '.idea/modules'
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/koalaman/shellcheck-precommit
Expand All @@ -26,14 +25,14 @@ repos:
rev: 'v3.1.0'
hooks:
- id: prettier
exclude: 'go.mod|gen/ts|.idea/modules'
exclude: 'go.mod|gen/ts'
- repo: https://github.com/pre-commit/mirrors-eslint
rev: 'v8.54.0'
hooks:
- id: eslint
files: \.tsx?$
types: [file]
args: [--fix]
args: [--fix, --no-ignore]
exclude: 'gen/ts'
- repo: https://github.com/golangci/golangci-lint
rev: 'v1.55.2'
Expand Down
12 changes: 12 additions & 0 deletions frontend/public/images/logo-vector.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions frontend/public/images/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions frontend/public/images/placholder-avatar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion frontend/public/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"cohere": "Cohere",
"configName": "Config Name",
"continueButtonText": "Continue",
"createConfig": "Create Configuration",
"createPromptConfigTitle": "New Model Configuration",
"deleteMessage": "Remove Message",
"duration": "Duration",
Expand All @@ -92,7 +93,7 @@
"modelSelection": "Model",
"modelType": "Model",
"modelVendor": "Provider",
"newMessage": "New Message",
"newMessage": "+ New Message",
"noVariablesHeadline": "The template has no variables - add as necessary or click on run test",
"openai": "OpenAI",
"openaiParametersFrequencyPenaltyLabel": "Frequency Penalty",
Expand Down Expand Up @@ -320,6 +321,7 @@
"createProviderKey": "Create Provider Key",
"createdAt": "Created at",
"deleteProviderKeyWarning": "Are you sure you want to delete this provider key?",
"headline": "Bring Your Own Key",
"keyIsEncryptedMessage": "The API key is encrypted before being stored in our database.",
"keyValue": "API Key",
"modelVendor": "AI Provider",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,8 @@ describe('PromptConfigCreateWizard Page tests', () => {
).toBeInTheDocument();
});

const saveButton = screen.getByTestId(
'config-create-wizard-save-button',
);
expect(saveButton).toBeInTheDocument();
expect(saveButton).toBeDisabled();
expect(continueButton).toBeInTheDocument();
expect(continueButton).toBeDisabled();
});

it('allows the user to continue to the third stage if messages are not empty', async () => {
Expand Down Expand Up @@ -231,52 +228,6 @@ describe('PromptConfigCreateWizard Page tests', () => {
});
});

it('allows the user to save the config if messages are not empty and replaces the route', async () => {
const promptConfig = OpenAIPromptConfigFactory.buildSync();
mockFetch.mockResolvedValue({
json: () => Promise.resolve(promptConfig),
ok: true,
});

const store = getStore();
act(() => {
store.setConfigName(promptConfig.name);
store.setMessages(promptConfig.providerPromptMessages);
store.setParameters(promptConfig.modelParameters);
store.setModelType(promptConfig.modelType);
store.setModelVendor(promptConfig.modelVendor);
});
render(
<PromptConfigCreateWizard params={{ applicationId, projectId }} />,
);

const continueButton = screen.getByTestId(
'config-create-wizard-continue-button',
);
expect(continueButton).toBeInTheDocument();
fireEvent.click(continueButton);

await waitFor(() => {
expect(
screen.getByTestId('parameters-and-prompt-form-container'),
).toBeInTheDocument();
});

const saveButton = screen.getByTestId(
'config-create-wizard-save-button',
);
expect(saveButton).toBeInTheDocument();
expect(saveButton).not.toBeDisabled();

fireEvent.click(saveButton);

await waitFor(() => {
expect(mockFetch).toHaveBeenCalledTimes(1);
});

expect(routerReplaceMock).toHaveBeenCalledOnce();
});

it('allows the user to save the config when on the third stage and replaces the route', async () => {
const promptConfig = OpenAIPromptConfigFactory.buildSync();
mockFetch.mockResolvedValue({
Expand Down Expand Up @@ -343,20 +294,16 @@ describe('PromptConfigCreateWizard Page tests', () => {
store.setParameters(promptConfig.modelParameters);
store.setModelType(promptConfig.modelType);
store.setModelVendor(promptConfig.modelVendor);
store.setNextWizardStage();
store.setNextWizardStage();
});
render(
<PromptConfigCreateWizard params={{ applicationId, projectId }} />,
);

const continueButton = screen.getByTestId(
'config-create-wizard-continue-button',
);
expect(continueButton).toBeInTheDocument();
fireEvent.click(continueButton);

await waitFor(() => {
expect(
screen.getByTestId('parameters-and-prompt-form-container'),
screen.getByTestId('prompt-config-testing-form'),
).toBeInTheDocument();
});

Expand Down Expand Up @@ -473,7 +420,7 @@ describe('PromptConfigCreateWizard Page tests', () => {
expect(continueButton.length).toBeFalsy();
});

it('allows the user to cancel at all stages', async () => {
it('allows the user to cancel only on the first stage', async () => {
const promptConfig = OpenAIPromptConfigFactory.buildSync();

const store = getStore();
Expand All @@ -495,15 +442,11 @@ describe('PromptConfigCreateWizard Page tests', () => {
screen.getByTestId('prompt-config-testing-form'),
).toBeInTheDocument();
});
const cancelButton = screen.getByTestId(

let cancelButton = screen.queryByTestId(
'config-create-wizard-cancel-button',
);
expect(cancelButton).toBeInTheDocument();
expect(cancelButton).not.toBeDisabled();

fireEvent.click(cancelButton);

expect(routerPushMock).toHaveBeenCalledOnce();
expect(cancelButton).toBeNull();

act(() => {
store.setPrevWizardStage();
Expand All @@ -515,11 +458,10 @@ describe('PromptConfigCreateWizard Page tests', () => {
).toBeInTheDocument();
});

expect(cancelButton).not.toBeDisabled();

fireEvent.click(cancelButton);

expect(routerPushMock).toHaveBeenCalledTimes(2);
cancelButton = screen.queryByTestId(
'config-create-wizard-cancel-button',
);
expect(cancelButton).toBeNull();

act(() => {
store.setPrevWizardStage();
Expand All @@ -530,12 +472,12 @@ describe('PromptConfigCreateWizard Page tests', () => {
screen.getByTestId('base-form-container'),
).toBeInTheDocument();
});

cancelButton = screen.getByTestId('config-create-wizard-cancel-button');
expect(cancelButton).not.toBeDisabled();

fireEvent.click(cancelButton);

expect(routerPushMock).toHaveBeenCalledTimes(3);
expect(routerPushMock).toHaveBeenCalledTimes(1);
});

it('shows the provider key create modal when no provider key exists for the given vendor', async () => {
Expand Down
Loading
Loading