-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add stricter tests to catch shiny errors
- Loading branch information
Showing
9 changed files
with
4,041 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -57,3 +57,4 @@ rsconnect/ | |
|
||
# Markdown generated files | ||
*/README.html | ||
_internal/tests/node_modules |
This file contains 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,11 @@ | ||
{ | ||
"RNA-seq": 10, | ||
"basic-teal": 1, | ||
"efficacy": 15, | ||
"exploratory": 16, | ||
"longitudinal": 8, | ||
"early-dev": 10, | ||
"patient-profile": 10, | ||
"python": 0, | ||
"safety": 12 | ||
} |
This file contains 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,9 @@ | ||
const { defineConfig } = require('cypress') | ||
|
||
module.exports = defineConfig({ | ||
e2e: { | ||
setupNodeEvents(on, config) {}, | ||
baseUrl: 'http://localhost:3333', | ||
supportFile: false, | ||
}, | ||
}) |
This file contains 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,2 @@ | ||
/screenshots/ | ||
/videos/ |
This file contains 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,45 @@ | ||
describe("app", () => { | ||
beforeEach(() => { | ||
cy.visit("/"); | ||
}); | ||
|
||
it("Starts", () => {}); | ||
|
||
it.only("Has expected teal tabs", () => { | ||
cy.get(".nav.nav-pills a[data-bs-toggle=tab]", { timeout: 30000 }).should( | ||
"have.length", | ||
Cypress.env("NUM_TABS") | ||
); | ||
}); | ||
|
||
it("Navigates to all tabs without error", () => { | ||
cy.get(".nav.nav-pills a[data-bs-toggle=tab]", { timeout: 30000 }).each( | ||
($el) => { | ||
cy.wrap($el).as("tealTab"); | ||
|
||
cy.get("@tealTab").then(($el2) => { | ||
cy.log(`Navigating to: ${$el2[0].innerText}`); | ||
}); | ||
|
||
cy.get("@tealTab").click(); | ||
|
||
cy.get("@tealTab").invoke("attr", "href").as("hrefTab"); | ||
|
||
cy.waitForStabilityAndCatchError("body"); | ||
|
||
cy.get("@hrefTab").then((hrefTab) => { | ||
cy.get(`${hrefTab}.tab-pane.active`) | ||
.should("be.visible") | ||
.within(() => { | ||
cy.get("*") | ||
.filter(":visible") | ||
.should("have.length.gte", 1) | ||
.then(($el3) => { | ||
cy.wrap($el3).contains(/.+/); | ||
}); | ||
}); | ||
}); | ||
} | ||
); | ||
}); | ||
}); |
This file contains 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,33 @@ | ||
Cypress.Commands.add( | ||
"waitForStabilityAndCatchError", | ||
(selector, stabilityPeriod = 300) => { | ||
let lastInnerHTML = ""; | ||
let timesRun = 0; | ||
const checkInterval = 100; | ||
const maxTimesRun = stabilityPeriod / checkInterval; | ||
|
||
function checkForChanges() { | ||
cy.get(selector).then(($el) => { | ||
// Check for shiny-output-error class anywhere in the body | ||
if (Cypress.$("body").find(".shiny-output-error").length > 0) { | ||
throw new Error( | ||
"shiny-output-error class detected during stability check" | ||
); | ||
} | ||
|
||
const currentInnerHTML = $el.prop("innerHTML"); | ||
if (currentInnerHTML !== lastInnerHTML) { | ||
lastInnerHTML = currentInnerHTML; | ||
timesRun = 0; | ||
} else if (timesRun < maxTimesRun) { | ||
timesRun += 1; | ||
} else { | ||
return; | ||
} | ||
cy.wait(checkInterval).then(checkForChanges); | ||
}); | ||
} | ||
|
||
checkForChanges(); | ||
} | ||
); |
Oops, something went wrong.