-
Notifications
You must be signed in to change notification settings - Fork 33
feat: replace instruments table with the new dynamic material table #1793
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
Merged
martin-trajanovski
merged 21 commits into
master
from
SWAP-4586-replace-instruments-table-after-refactor
May 19, 2025
Merged
Changes from 14 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
a8fe135
refactor proposal-dashboard table before replacing the instruments table
martin-trajanovski 2a7f288
Merge branch 'master' into SWAP-4585-replace-instruments-table
martin-trajanovski 16d74d7
fix typo
martin-trajanovski a523fdd
Merge branch 'SWAP-4585-replace-instruments-table' of https://github.…
martin-trajanovski c85d4e9
feat: replace instruments table with the new dynamic material table
martin-trajanovski 5e91d7e
Merge branch 'master' into SWAP-4586-replace-instruments-table-after-…
martin-trajanovski d4f7478
Merge branch 'master' into SWAP-4586-replace-instruments-table-after-…
martin-trajanovski a7d4572
add e2e tests for instruments table
martin-trajanovski e727cb2
Merge branch 'master' into SWAP-4586-replace-instruments-table-after-…
martin-trajanovski 8f7b783
Merge branch 'master' into SWAP-4586-replace-instruments-table-after-…
martin-trajanovski be7db7e
Merge branch 'master' into SWAP-4586-replace-instruments-table-after-…
martin-trajanovski c334874
bump sdk-ts-angular to latest
martin-trajanovski 5c360cf
fix typos
martin-trajanovski 7c84730
Merge branch 'master' into SWAP-4586-replace-instruments-table-after-…
martin-trajanovski 49614dd
refactor the table congig into service
martin-trajanovski aacbf46
Merge branch 'master' into SWAP-4586-replace-instruments-table-after-…
martin-trajanovski e14ad41
solving conflicts, first pass
nitrosx 5bf3710
resolved UI failing tests
nitrosx e8dbdd7
Fixed unit tests
nitrosx 05a1eda
Merge branch 'master' into SWAP-4586-replace-instruments-table-after-…
martin-trajanovski 10c80fb
fix linting and some wrong merge resolution changes
martin-trajanovski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
const path = require("path"); | ||
|
||
import { testData } from "../../fixtures/testData"; | ||
import { testConfig } from "../../fixtures/testData"; | ||
import { getFormattedFileNamingDate, mergeConfig } from "../../support/utils"; | ||
|
||
describe("Instruments general", () => { | ||
beforeEach(() => { | ||
cy.login(Cypress.env("username"), Cypress.env("password")); | ||
}); | ||
|
||
after(() => { | ||
cy.removeInstruments(); | ||
}); | ||
|
||
describe("Instruments table and details", () => { | ||
it("should be able to see instrument in a table and visit the instrument details page", () => { | ||
const instrument = { | ||
...testData.instrument, | ||
name: "Cypress test instrument", | ||
uniqueName: `Instrument-${Math.floor(1000 + Math.random() * 9000).toString()}`, | ||
}; | ||
cy.createInstrument(instrument); | ||
|
||
cy.visit("/instruments"); | ||
|
||
cy.get("mat-table mat-header-row").should("exist"); | ||
|
||
cy.finishedLoading(); | ||
|
||
cy.get("mat-table mat-row").should("contain", instrument.uniqueName); | ||
|
||
cy.get("mat-cell") | ||
.contains(instrument.uniqueName) | ||
.closest("mat-row") | ||
.contains(instrument.name) | ||
.click(); | ||
|
||
cy.url().should("include", `/instruments`); | ||
|
||
cy.contains(instrument.uniqueName); | ||
}); | ||
|
||
it("instrument should have metadata and if not it should be able to add", () => { | ||
const metadataName = "Instrument Metadata Name"; | ||
const metadataValue = "instrument metadata value"; | ||
const instrument = { | ||
...testData.instrument, | ||
name: "Cypress test instrument", | ||
uniqueName: `Instrument-${Math.floor(1000 + Math.random() * 9000).toString()}`, | ||
}; | ||
cy.createInstrument(instrument); | ||
|
||
cy.visit("/instruments"); | ||
|
||
cy.finishedLoading(); | ||
|
||
cy.get("mat-cell") | ||
.contains(instrument.uniqueName) | ||
.closest("mat-row") | ||
.contains(instrument.name) | ||
.click(); | ||
|
||
cy.finishedLoading(); | ||
|
||
cy.get('[data-cy="instrument-metadata-card"]').should("exist"); | ||
|
||
cy.get('[data-cy="instrument-metadata-card"] [role="tab"]') | ||
.contains("Edit") | ||
.click(); | ||
|
||
cy.get('[data-cy="add-new-row"]').click(); | ||
|
||
// simulate click event on the drop down | ||
cy.get("mat-select[data-cy=field-type-input]").last().click(); // opens the drop down | ||
|
||
// simulate click event on the drop down item (mat-option) | ||
cy.get("mat-option") | ||
.contains("string") | ||
.then((option) => { | ||
option[0].click(); | ||
}); | ||
|
||
cy.get("[data-cy=metadata-name-input]") | ||
.last() | ||
.focus() | ||
.type(`${metadataName}{enter}`); | ||
cy.get("[data-cy=metadata-value-input]") | ||
.last() | ||
.focus() | ||
.type(`${metadataValue}{enter}`); | ||
|
||
cy.get("button[data-cy=save-changes-button]").click(); | ||
|
||
cy.finishedLoading(); | ||
|
||
cy.reload(); | ||
|
||
cy.finishedLoading(); | ||
|
||
cy.contains(instrument.name); | ||
|
||
cy.get('[data-cy="instrument-metadata-card"]').contains(metadataName, { | ||
matchCase: true, | ||
}); | ||
cy.get('[data-cy="instrument-metadata-card"]').contains(metadataValue, { | ||
matchCase: true, | ||
}); | ||
}); | ||
}); | ||
|
||
describe("Instruments dynamic material table", () => { | ||
it("should be able to sort for instrument in the column sort", () => { | ||
const newInstrument = { | ||
...testData.instrument, | ||
name: "000 Cypress test instrument", | ||
uniqueName: `Instrument-${Math.floor(1000 + Math.random() * 9000).toString()}`, | ||
}; | ||
|
||
const newInstrument2 = { | ||
...testData.instrument, | ||
name: "001 Cypress test instrument", | ||
uniqueName: `Instrument-${Math.floor(1000 + Math.random() * 9000).toString()}`, | ||
}; | ||
|
||
cy.createInstrument(newInstrument2); | ||
cy.createInstrument(newInstrument); | ||
|
||
cy.visit("/instruments"); | ||
|
||
cy.get("mat-table mat-row") | ||
.first() | ||
.should("not.contain", newInstrument.name); | ||
|
||
cy.get(".mat-sort-header-container").contains("Name").click(); | ||
|
||
cy.get("mat-table mat-row").first().should("contain", newInstrument.name); | ||
|
||
cy.reload(); | ||
|
||
cy.get("mat-table mat-row").first().should("contain", newInstrument.name); | ||
}); | ||
|
||
it("should be able to download table data as a json", () => { | ||
const instrument = { | ||
...testData.instrument, | ||
uniqueName: `Instrument-${Math.floor(1000 + Math.random() * 9000).toString()}`, | ||
}; | ||
|
||
cy.createInstrument(instrument); | ||
|
||
cy.visit("/instruments"); | ||
|
||
cy.get("dynamic-mat-table table-menu button").click(); | ||
|
||
cy.get('[role="menu"] button').contains("Save data").click(); | ||
|
||
cy.get('[role="menu"] button').contains("Json file").click(); | ||
|
||
const downloadsFolder = Cypress.config("downloadsFolder"); | ||
const tableName = "instrumentsTable"; | ||
|
||
cy.readFile( | ||
path.join( | ||
downloadsFolder, | ||
`${tableName}${getFormattedFileNamingDate()}.json`, | ||
), | ||
).then((actualExport) => { | ||
const foundInstrument = actualExport.find( | ||
(instrument) => instrument.uniqueName === instrument.uniqueName, | ||
); | ||
|
||
expect(foundInstrument).to.exist; | ||
}); | ||
}); | ||
|
||
it("should be able to download table data as a csv", () => { | ||
const instrument = { | ||
...testData.instrument, | ||
uniqueName: `Instrument-${Math.floor(1000 + Math.random() * 9000).toString()}`, | ||
}; | ||
|
||
cy.createInstrument(instrument); | ||
|
||
cy.visit("/instruments"); | ||
|
||
cy.get("dynamic-mat-table table-menu button").click(); | ||
|
||
cy.get('[role="menu"] button').contains("Save data").click(); | ||
|
||
cy.get('[role="menu"] button').contains("CSV file").click(); | ||
|
||
const downloadsFolder = Cypress.config("downloadsFolder"); | ||
const tableName = "instrumentsTable"; | ||
|
||
cy.readFile( | ||
path.join( | ||
downloadsFolder, | ||
`${tableName}${getFormattedFileNamingDate()}.csv`, | ||
), | ||
).then((actualExport) => { | ||
expect(actualExport).to.contain(instrument.uniqueName); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 18 additions & 17 deletions
35
src/app/instruments/instruments-dashboard/instruments-dashboard.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
<ng-container *ngIf="vm$ | async as vm"> | ||
<div fxLayout="row" fxLayout.lt-lg="column"> | ||
<div fxFlex="100"> | ||
<app-table | ||
[data]="vm.instruments" | ||
[columns]="tableColumns" | ||
[paginate]="tablePaginate" | ||
[currentPage]="vm.currentPage" | ||
[dataCount]="vm.instrumentsCount" | ||
[dataPerPage]="vm.instrumentsPerPage" | ||
(pageChange)="onPageChange($event)" | ||
(sortChange)="onSortChange($event)" | ||
(rowClick)="onRowClick($event)" | ||
></app-table> | ||
</div> | ||
</div> | ||
</ng-container> | ||
<dynamic-mat-table | ||
[tableName]="tableName" | ||
[columns]="columns" | ||
[pending]="pending" | ||
[setting]="setting" | ||
[pagingMode]="paginationMode" | ||
[dataSource]="dataSource" | ||
[pagination]="pagination" | ||
[rowSelectionMode]="rowSelectionMode" | ||
[showGlobalTextSearch]="showGlobalTextSearch" | ||
(paginationChange)="onPaginationChange($event)" | ||
(onRowEvent)="onRowClick($event)" | ||
(settingChange)="onSettingChange($event)" | ||
(onTableEvent)="onTableEvent($event)" | ||
style="height: 70vh" | ||
class="mat-elevation-z2" | ||
> | ||
</dynamic-mat-table> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.