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

[ENH] Clean up the home page #621

Merged
merged 9 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 8 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
11 changes: 5 additions & 6 deletions cypress/component/index_page.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ describe("The index page", () => {
});

// Assert
cy.get("[data-cy='data-table-display']").should("be.visible.and.empty");
cy.get("[data-cy='data-table-display']").should("not.exist");
cy.get("[data-cy='data-table-selector']").should("be.visible").contains("Choose file");
cy.get("[data-cy='data-dictionary-display']").should("be.visible.and.empty");
cy.get("[data-cy='data-dictionary-display']").should("not.exist");
cy.get("[data-cy='data-dictionary-selector']").should("be.visible").contains("Choose file");
});

Expand Down Expand Up @@ -77,10 +77,9 @@ describe("The index page", () => {
plugins: ["bootstrap-vue"]
});

// Assert - Because we're looking at an input field, we need to assert
// over the value and can't just use .contains as usual
cy.get("[data-cy='data-table-display']").should('include.value', 'val1\tval2');
cy.get("[data-cy='data-dictionary-display']").should('include.value', '"col1": "something"');
cy.get("[data-cy='data-table-display']").contains("val1");
cy.get("[data-cy='data-table-display']").contains("val2");
cy.get("[data-cy='data-dictionary-display']").contains('"col1": "something"');
});

it("Dispatches an action when a dataTable is loaded", () => {
Expand Down
14 changes: 14 additions & 0 deletions cypress/e2e/page/home-pagetests.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
describe("On My homepage", () => {
it("I can upload some data", () => {
cy.visit('/');
// Before I load anything, I have a little notification that my preview will
// appear once I upload a table
// Load a table
cy.get('[data-cy="data-table-selector"]').get('input').selectFile('cypress/fixtures/examples/good/example_synthetic.tsv', { force: true });

/* ==== Generated with Cypress Studio ==== */
cy.get('[data-cy="data-dictionary-selector"] > .row > form > .file-selector-button').click();
cy.get('[data-cy="data-dictionary-selector"] > .row > form > .file-selector-button > input').selectFile('cypress/fixtures/examples/good/example_synthetic_participants.json', { force: true });
/* ==== End Cypress Studio ==== */
});
});
1 change: 0 additions & 1 deletion nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export default {

// Global CSS: https://go.nuxtjs.dev/config-css
css: [

"@/assets/css/main.css"
],

Expand Down
57 changes: 28 additions & 29 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@
<h3>{{ uiText.dataTableHeader }}</h3>
</b-row>

<!-- Shows file contents -->
<b-row>
<textarea
:cols="textArea.height"
:rows="textArea.width"
:value="stringifiedDataTable"
data-cy="data-table-display" />
</b-row>

<!-- Selects data table file (i.e. participants.tsv) -->
<b-row>
<file-selector
Expand All @@ -25,19 +16,23 @@
:enabled="true" />
</b-row>


<!-- Data dictionary file loading area -->
<!-- Shows file contents -->
<b-row>
<h3>{{ uiText.dataDictionaryHeader }}</h3>
<b-table
v-if="dataTable.length > 0"
outlined
sticky-header
:items="dataTable"
data-cy="data-table-display" />
<div v-else>
Please provide a data table to see a preview here.
surchs marked this conversation as resolved.
Show resolved Hide resolved
</div>
</b-row>

<!-- Shows file contents -->

<!-- Data dictionary file loading area -->
<b-row>
<textarea
:cols="textArea.height"
:rows="textArea.width"
:value="stringifiedDataDictionary"
data-cy="data-dictionary-display" />
<h3>{{ uiText.dataDictionaryHeader }}</h3>
</b-row>

<b-row>
Expand All @@ -49,6 +44,20 @@
:enabled="dataTableSelected" />
</b-row>

<!-- Shows file contents -->
<b-row>
<pre
v-if="Object.keys(this.dataDictionary.userProvided).length > 0"
style="height: 200px; width: 100%; overflow: auto;"
data-cy="data-dictionary-display">
{{ stringifiedDataDictionary }}
</pre>
<div v-else>
Provide a data dictionary to see the preview.
surchs marked this conversation as resolved.
Show resolved Hide resolved
If you load a data table, a skeleton data dictionary will be created for you
</div>
</b-row>

</b-container>

</template>
Expand Down Expand Up @@ -101,19 +110,9 @@
// (used to enable data dictionary selection)
return ( this.dataTable.length > 0 );
},

stringifiedDataDictionary() {

return ( 0 === Object.keys(this.dataDictionary.userProvided).length )
? "" : JSON.stringify(this.dataDictionary.userProvided, null, 4);
},

stringifiedDataTable() {

// Returns only the cell values of the table as a formatted string (no column names)
return this.dataTable.map(row => {
return Object.values(row).join("\t");
}).join("\n");
return JSON.stringify(this.dataDictionary.userProvided, null, 4);
}
},

Expand Down
Loading