-
Notifications
You must be signed in to change notification settings - Fork 1
Sort project list in data store creator #416
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,15 +112,71 @@ describe("DataStoreProjectInitializer.vue", () => { | |
| }); | ||
| } | ||
|
|
||
| async function openProjectDropdown() { | ||
| await wrapper.find(".p-autocomplete-dropdown").trigger("click"); | ||
| await flushPromises(); | ||
| } | ||
|
|
||
| async function selectProject(project: AvailableProject) { | ||
| await openProjectDropdown(); | ||
| const listItem = wrapper.find( | ||
| `.p-autocomplete-option[aria-label="${project.name}"]`, | ||
| ); | ||
| expect(listItem.exists()).toBe(true); | ||
| await listItem.trigger("click"); | ||
| await innerVm().$nextTick(); | ||
| expect(innerVm().selectedProject.id).toBe(project.id); | ||
| } | ||
|
|
||
| it("Create Data Store - Header", () => { | ||
| expect(wrapper).toBeTruthy(); | ||
| expect(wrapper.text()).toContain("Create a Data Store for a Project"); | ||
| expect(wrapper.text()).toContain("Helpful tooltips"); | ||
| }); | ||
|
|
||
| it("Check data store project dropdown options", () => { | ||
| it("Check data store project dropdown options", async () => { | ||
| expect( | ||
| wrapper.find(".p-autocomplete-input").attributes("placeholder"), | ||
| ).toBe("Select or search for a project"); | ||
| expect(wrapper.find(".p-autocomplete-option").exists()).toBe(false); | ||
|
|
||
| await openProjectDropdown(); | ||
|
|
||
| const options = wrapper.findAll(".p-autocomplete-option"); | ||
| expect(options).toHaveLength(fakeParsedProjects.length); | ||
| const dropDownOptions = fakeParsedProjects.map((item) => item.name); | ||
| checkDropdown(".project-picker", dropDownOptions, "Select a Project"); | ||
| options.forEach((option) => { | ||
| expect(option.text()).toBeOneOf(dropDownOptions); | ||
| }); | ||
| }); | ||
|
|
||
| it("Filters the project suggestions by the typed query", async () => { | ||
| const target = fakeParsedProjects[1]!; | ||
| const autoComplete = wrapper.findComponent(".project-picker"); | ||
|
|
||
| await autoComplete.vm.$emit("complete", { query: "-2" }); | ||
| await innerVm().$nextTick(); | ||
| expect( | ||
| innerVm().projectSuggestions.map((p: AvailableProject) => p.name), | ||
| ).toEqual([target.name]); | ||
|
|
||
| // An empty query (i.e. the dropdown button) falls back to every project | ||
| await autoComplete.vm.$emit("complete", { query: "" }); | ||
| await innerVm().$nextTick(); | ||
| expect(innerVm().projectSuggestions).toHaveLength( | ||
| fakeParsedProjects.length, | ||
| ); | ||
| }); | ||
|
|
||
| it("Sorts the project suggestions alphabetically", async () => { | ||
| const autoComplete = wrapper.findComponent(".project-picker"); | ||
| await autoComplete.vm.$emit("complete", { query: "" }); | ||
| await innerVm().$nextTick(); | ||
|
|
||
| const names = innerVm().projectSuggestions.map( | ||
| (p: AvailableProject) => p.name, | ||
| ); | ||
| expect(names).toEqual([...names].sort()); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Use an unordered project fixture for the sorting test.
🤖 Prompt for AI Agents |
||
| }); | ||
|
|
||
| it("Check data store type dropdown options", () => { | ||
|
|
@@ -160,23 +216,7 @@ describe("DataStoreProjectInitializer.vue", () => { | |
| protocol: string = "http", | ||
| // methods?: string[], | ||
| ) { | ||
| await wrapper.find(".project-picker").trigger("click"); // open dropdown menu | ||
| expect(wrapper.findAll(".p-select-option").length).toBe( | ||
| fakeParsedProjects.length, | ||
| ); | ||
| const listItem = wrapper.find(`li[aria-label="${projectDropdown.name}"]`); | ||
| expect(listItem.exists()).toBe(true); | ||
| await listItem.trigger("click"); | ||
| // Can't get manually clicking option to work so manually setting it | ||
| // Use the actual availableProjects entry to ensure object identity matches Select options | ||
| const matchingProject = innerVm().availableProjects.find( | ||
| (p: AvailableProject) => p.id === projectDropdown.id, | ||
| ); | ||
| innerVm().selectedProject = matchingProject; | ||
| await innerVm().$nextTick(); | ||
| expect(wrapper.find(".project-picker span").text()).toBe( | ||
| projectDropdown.name, | ||
| ); | ||
| await selectProject(projectDropdown); | ||
|
|
||
| // Set server name | ||
| const serverWrapper = wrapper.find(".data-store-server-input"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Search both the project name and project ID.
Line 92 uses
proj.idonly whenproj.nameis nullish. A project with a display name cannot be found by its ID. Match the query against both fields.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents