Adding cypress tests for TMDB id

This commit is contained in:
jhouse
2020-02-07 09:31:59 +09:00
parent 5c5d0a706a
commit c110297fb4
5 changed files with 135 additions and 11 deletions
+2
View File
@@ -34,3 +34,5 @@ GapsWeb/target
/rssFeed.json
GapsOnWindows/*.jar
*.zip
cypress/screenshots
cypress/videos
@@ -73,8 +73,10 @@
<input type="text" class="form-control" id="movieDbApiKey" th:field="*{movieDbApiKey}" required>
</div>
<button type="button" onclick="testTmdbKey()" class="btn btn-info">Test</button>
<button type="button" onclick="saveTmdbKey()" class="btn btn-primary">Save</button>
<a id="testTmdbKey" href="javascript:void(0)" type="button" onclick="testTmdbKey();"
class="btn btn-info">Test</a>
<a id="saveTmdbKey" href="javascript:void(0)" type="button" onclick="saveTmdbKey();"
class="btn btn-primary">Save</a>
</form>
<div id="tmdbSpinner" class="spinner-border text-primary gaps-hide top-margin" role="status">
@@ -185,7 +187,8 @@
<h3 class="top-margin">Servers</h3>
<div id="plexServers" class="row top-margin">
<div th:id="*{plexServer.machineIdentifier}" class="col-lg-4" th:each="plexServer,status : *{plexSearch.plexServers}">
<div th:id="*{plexServer.machineIdentifier}" class="col-lg-4"
th:each="plexServer,status : *{plexSearch.plexServers}">
<div class="top-margin">
<div class="card border-secondary mb-3" style="max-width: 20rem;">
<div class="card-header" th:text="${plexServer.getFriendlyName()}"></div>
@@ -195,10 +198,12 @@
</ul>
<div class="card-body">
<a href="javascript:void(0)" th:data-machineIdentifier="*{plexServer.machineIdentifier}"
th:onclick="testExistingPlexServer(this.getAttribute('data-machineIdentifier'))" class="card-link"
th:onclick="testExistingPlexServer(this.getAttribute('data-machineIdentifier'))"
class="card-link"
data-ol-has-click-handler="">Test</a>
<a href="javascript:void(0)" th:data-machineIdentifier="*{plexServer.machineIdentifier}"
th:onclick="removePlexServer(this.getAttribute('data-machineIdentifier'))" class="card-link"
th:onclick="removePlexServer(this.getAttribute('data-machineIdentifier'))"
class="card-link"
data-ol-has-click-handler="">Remove</a>
</div>
<div class="card-footer text-muted"
@@ -0,0 +1,122 @@
let appHasStarted;
function spyOnAddEventListener(win) {
// win = window object in our application
const addListener = win.EventTarget.prototype.addEventListener
win.EventTarget.prototype.addEventListener = function (name) {
if (name === 'change') {
// web app added an event listener to the input box -
// that means the web application has started
appHasStarted = true
// restore the original event listener
win.EventTarget.prototype.addEventListener = addListener
}
return addListener.apply(this, arguments)
}
}
it('Enter invalid TMDB Key', () => {
cy.visit('/configuration', {onBeforeLoad: spyOnAddEventListener});
cy.get('#movieDbApiKey')
.clear()
.type('ABC123')
.should('have.value', 'ABC123');
cy.get('#testTmdbKey')
.click();
cy.get('#tmdbTestError')
.should('be.visible');
cy.get('#tmdbTestSuccess')
.should('not.be.visible');
cy.get('#tmdbSaveError')
.should('not.be.visible');
cy.get('#tmdbSaveSuccess')
.should('not.be.visible');
});
it('Enter valid TMDB Key', () => {
cy.visit('/configuration', {onBeforeLoad: spyOnAddEventListener});
cy.get('#movieDbApiKey')
.clear()
.type('723b4c763114904392ca441909aa0375')
.should('have.value', '723b4c763114904392ca441909aa0375');
cy.get('#testTmdbKey')
.click();
cy.get('#tmdbTestError')
.should('not.be.visible');
cy.get('#tmdbTestSuccess')
.should('be.visible');
cy.get('#tmdbSaveError')
.should('not.be.visible');
cy.get('#tmdbSaveSuccess')
.should('not.be.visible');
});
it('Save invalid TMDB Key', () => {
cy.visit('/configuration', {onBeforeLoad: spyOnAddEventListener});
cy.get('#movieDbApiKey')
.clear()
.type('ABC123')
.should('have.value', 'ABC123');
cy.get('#saveTmdbKey')
.click();
cy.get('#tmdbTestError')
.should('not.be.visible');
cy.get('#tmdbTestSuccess')
.should('not.be.visible');
cy.get('#tmdbSaveError')
.should('not.be.visible');
cy.get('#tmdbSaveSuccess')
.should('be.visible');
cy.visit('/configuration', {onBeforeLoad: spyOnAddEventListener});
cy.get('#movieDbApiKey')
.should('have.value', 'ABC123');
});
it('Save valid TMDB Key', () => {
cy.visit('/configuration', {onBeforeLoad: spyOnAddEventListener});
cy.get('#movieDbApiKey')
.clear()
.type('723b4c763114904392ca441909aa0375')
.should('have.value', '723b4c763114904392ca441909aa0375');
cy.get('#saveTmdbKey')
.click();
cy.get('#tmdbTestError')
.should('not.be.visible');
cy.get('#tmdbTestSuccess')
.should('not.be.visible');
cy.get('#tmdbSaveError')
.should('not.be.visible');
cy.get('#tmdbSaveSuccess')
.should('be.visible');
cy.visit('/configuration', {onBeforeLoad: spyOnAddEventListener});
cy.get('#movieDbApiKey')
.should('have.value', '723b4c763114904392ca441909aa0375');
});
-5
View File
@@ -1,5 +0,0 @@
describe("Index test", () => {
it("Can it make it to the index page", () => {
cy.visit("/");
});
});
+1 -1
View File
@@ -5,7 +5,7 @@
"main": "/",
"dependencies": {},
"devDependencies": {
"cypress": "^3.8.3"
"cypress": "^4.0.0"
},
"scripts": {
"e2e": "cypress open"