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

feature: prompt nested folders #65

Merged
merged 8 commits into from
Nov 14, 2023
2 changes: 1 addition & 1 deletion .github/pr-title-checker-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"color": "EEEEEE"
},
"CHECKS": {
"prefixes": ["fix: ", "feat: ", "feature: ", "chore: ", "hotfix: "]
"prefixes": ["fix: ", "feat: ", "feature: ", "chore: ", "hotfix: ", "e2e: "]
},
"MESSAGES": {
"success": "All OK",
Expand Down
33 changes: 5 additions & 28 deletions e2e/src/testData/conversationHistory/conversationData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,25 @@ import {
ExpectedConstants,
ModelIds,
} from '@/e2e/src/testData';
import { FolderBuilder } from '@/e2e/src/testData/conversationHistory/folderBuilder';
import { FolderData } from '@/e2e/src/testData/folders/folderData';
import { v4 as uuidv4 } from 'uuid';

export interface FolderConversation {
conversations: Conversation[];
folders: FolderInterface;
}

export class ConversationData {
export class ConversationData extends FolderData {
private conversationBuilder: ConversationBuilder;
private folderBuilder: FolderBuilder;

constructor() {
super('chat');
this.conversationBuilder = new ConversationBuilder();
this.folderBuilder = new FolderBuilder();
}

public resetData() {
this.conversationBuilder = new ConversationBuilder();
this.folderBuilder = new FolderBuilder();
this.resetFolderData();
}

public prepareDefaultConversation(model?: OpenAIEntityModel, name?: string) {
Expand Down Expand Up @@ -203,30 +202,8 @@ export class ConversationData {
return conversation;
}

public prepareDefaultFolder() {
return this.folderBuilder.build();
}

public prepareFolder(name?: string) {
return this.folderBuilder
.withName(name ?? GeneratorUtil.randomString(7))
.build();
}

public prepareNestedFolder(nestedLevel: number) {
const rootFolder = this.prepareFolder();
this.resetData();
const foldersHierarchy = [rootFolder];
for (let i = 1; i <= nestedLevel; i++) {
const nestedFolder = this.folderBuilder
.withName(GeneratorUtil.randomString(7))
.withType('chat')
.withFolderId(foldersHierarchy[foldersHierarchy.length - 1].id)
.build();
foldersHierarchy.push(nestedFolder);
this.resetData();
}
return foldersHierarchy;
return super.prepareNestedFolder(nestedLevel, 'chat');
}

public prepareFolderWithConversations(conversationsCount: number) {
Expand Down
4 changes: 4 additions & 0 deletions e2e/src/testData/conversationHistory/folderBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export class FolderBuilder {
};
}

getFolder() {
return this.folder;
}

withId(id: string): FolderBuilder {
this.folder.id = id;
return this;
Expand Down
1 change: 1 addition & 0 deletions e2e/src/testData/expectedConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const ExpectedConstants = {
defaultIconUrl: 'url(images/icons/message-square-lines-alt.svg))',
deleteFolderMessage:
'Are you sure that you want to remove a folder with all nested elements?',
backgroundColorPattern: /(rgba\(\d+,\s*\d+,\s*\d+),\s*\d+\.*\d+\)/,
};

export enum Groups {
Expand Down
2 changes: 2 additions & 0 deletions e2e/src/testData/expectedMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,6 @@ export enum ExpectedMessages {
folderNameColorIsValid = 'Folder name color is valid',
confirmationMessageIsValid = 'Confirmation dialog message is valid',
chronologyMessageCountIsCorrect = 'Chat bar chronology messages count is correct',
newPromptButtonIsHighlighted = 'New prompt button is highlighted',
newPromptButtonCursorIsPointer = 'New prompt button cursor is a pointer',
}
43 changes: 43 additions & 0 deletions e2e/src/testData/folders/folderData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { FolderType } from '@/src/types/folder';

import { FolderBuilder } from '@/e2e/src/testData/conversationHistory/folderBuilder';
import { GeneratorUtil } from '@/e2e/src/utils';

export class FolderData {
private folderBuilder: FolderBuilder;

constructor(type: FolderType) {
this.folderBuilder = new FolderBuilder().withType(type);
}

public resetFolderData() {
const type = this.folderBuilder.getFolder().type;
this.folderBuilder = new FolderBuilder().withType(type);
}

public prepareDefaultFolder() {
return this.folderBuilder.build();
}

public prepareFolder(name?: string) {
return this.folderBuilder
.withName(name ?? GeneratorUtil.randomString(7))
.build();
}

public prepareNestedFolder(nestedLevel: number, type: FolderType) {
const rootFolder = this.prepareFolder();
this.resetFolderData();
const foldersHierarchy = [rootFolder];
for (let i = 1; i <= nestedLevel; i++) {
const nestedFolder = this.folderBuilder
.withName(GeneratorUtil.randomString(7))
.withType(type)
.withFolderId(foldersHierarchy[foldersHierarchy.length - 1].id)
.build();
foldersHierarchy.push(nestedFolder);
this.resetFolderData();
}
return foldersHierarchy;
}
}
1 change: 1 addition & 0 deletions e2e/src/testData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './conversationHistory/conversationData';
export * from './conversationHistory/folderBuilder';
export * from './prompts/promptBuilder';
export * from './prompts/promptData';
export * from './folders/folderData';
15 changes: 6 additions & 9 deletions e2e/src/testData/prompts/promptData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,33 @@ import { GeneratorUtil } from '@/e2e/src/utils/generatorUtil';
import { FolderInterface } from '@/src/types/folder';
import { Prompt } from '@/src/types/prompt';

import { FolderBuilder } from '@/e2e/src/testData/conversationHistory/folderBuilder';
import { FolderData } from '@/e2e/src/testData/folders/folderData';
import { PromptBuilder } from '@/e2e/src/testData/prompts/promptBuilder';

export interface FolderPrompt {
prompts: Prompt[];
folders: FolderInterface;
}

export class PromptData {
export class PromptData extends FolderData {
private promptBuilder: PromptBuilder;
private folderBuilder: FolderBuilder;

constructor() {
super('prompt');
this.promptBuilder = new PromptBuilder();
this.folderBuilder = new FolderBuilder().withType('prompt');
}

public resetData() {
this.promptBuilder = new PromptBuilder();
this.folderBuilder = new FolderBuilder().withType('prompt');
this.resetFolderData();
}

public prepareDefaultPrompt() {
return this.promptBuilder.withName(GeneratorUtil.randomString(10)).build();
}

public prepareFolder(name?: string) {
return this.folderBuilder
.withName(name ?? GeneratorUtil.randomString(7))
.build();
public prepareNestedFolder(nestedLevel: number) {
return super.prepareNestedFolder(nestedLevel, 'prompt');
}

public prepareDefaultPromptInFolder(name?: string): FolderPrompt {
Expand Down
Loading