Skip to content

Commit

Permalink
fix(folders): Alphabetical folder order should be case insensitive.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewxyz3 committed Nov 19, 2023
1 parent 3b01d5b commit 5d328b8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 10 deletions.
31 changes: 31 additions & 0 deletions e2e/cypress/integration/folders.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
/// <reference types="cypress" />

describe('Folder management', () => {
it('should create folders and check that their order is alphabetical and case insensitive', () => {
cy.visit('/');
cy.closeWelcomeDialog();

// Create folders for test
cy.get('#createFolderButton').click();
cy.get('mat-dialog-container input').type('folderA');
cy.get('mat-dialog-container #doneButton').click();

cy.get('#createFolderButton').click();
cy.get('mat-dialog-container input').type('FolderB');
cy.get('mat-dialog-container #doneButton').click();

cy.get('#createFolderButton').click();
cy.get('mat-dialog-container input').type('folderC');
cy.get('mat-dialog-container #doneButton').click();

cy.get('#createFolderButton').click();
cy.get('mat-dialog-container input').type('FolderD');
cy.get('mat-dialog-container #doneButton').click();


// Get all folder elements and extract their text content
cy.get('mat-tree-node').then((nodes) => {
const folderNames = Array.from(nodes, (node) => Cypress.$(node).text().trim().toLowerCase());

// Check if the folders are sorted alphabetically and case-insensitively
expect(folderNames).to.deep.equal(folderNames.slice().sort());
});
});

it('should create folder at root level', () => {
cy.visit('/');
cy.closeWelcomeDialog();
Expand Down
23 changes: 13 additions & 10 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,16 +373,19 @@ export class AppComponent implements OnInit, AfterViewInit, CanvasTableSelectLis
});

// Only update if actual changes found (else folderlist redraw takes 3sec or more)
this.displayedFolders =
this.messagelistservice.folderListSubject
.pipe(distinctUntilChanged((prev: FolderListEntry[], curr: FolderListEntry[]) => {
return prev.length === curr.length
&& prev.every((f, index) =>
objectEqualWithKeys(f, curr[index], [
'folderId', 'totalMessages', 'newMessages', 'folderName'
]))
}))
.pipe(map((folders: FolderListEntry[]) => folders.filter(f => f.folderPath.indexOf('Drafts') !== 0))
this.displayedFolders = this.messagelistservice.folderListSubject
.pipe(
distinctUntilChanged((prev: FolderListEntry[], curr: FolderListEntry[]) => {
return prev.length === curr.length &&
prev.every((f, index) =>
objectEqualWithKeys(f, curr[index], ['folderId', 'totalMessages', 'newMessages', 'folderName'])
);
}),
map((folders: FolderListEntry[]) => {
const filteredFolders = folders.filter(folder => folder.folderPath.indexOf('Drafts') !== 0);
const sortedFolders = filteredFolders.sort((folderA, folderB) => folderA.folderName.localeCompare(folderB.folderName, undefined, { sensitivity: 'base' }));
return sortedFolders;
})
);

this.canvastable.scrollLimitHit.subscribe((limit) =>
Expand Down

0 comments on commit 5d328b8

Please sign in to comment.