Added more tests

pull/4104/head
tidusjar 4 years ago
parent 7ddd31b89a
commit da1934b922

@ -51,7 +51,7 @@ var line = lines[Math.floor(Math.random() * lines.length)];
window.loading_screen = window.pleaseWait({
template: `<div class='pg-loading-inner'>
template: `<div id='initalLoading' class='pg-loading-inner'>
<div class='pg-loading-center-outer'>
<div class='pg-loading-center-middle'>
<h1 class='pg-loading-logo-header'>

@ -23,6 +23,7 @@
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
import 'cypress-wait-until';
Cypress.Commands.add("landingSettings", (enabled) => {
cy.fixture('login/landingPageSettings').then((settings) => {
@ -31,7 +32,7 @@ Cypress.Commands.add("landingSettings", (enabled) => {
})
})
Cypress.Commands.add('login', (username, password) => {
Cypress.Commands.add('loginWithCreds', (username, password) => {
cy.request({
method: 'POST',
url: '/api/v1/token',
@ -86,12 +87,13 @@ Cypress.Commands.add('createUser', (username, password, claims) => {
Cypress.Commands.add('generateUniqueId', () => {
const uniqueSeed = Date.now().toString();
const id = Cypress._.uniqueId(uniqueSeed);
return id;
cy.wrap(id);
});
Cypress.Commands.add("getByData", (selector, ...args) => {
return cy.get(`[data-test=${selector}]`, ...args);
});
return cy.get(`[data-test=${selector}]`, ...args);
});
Cypress.Commands.add("getByData", (selector) => {
return cy.get(`[data-test=${selector}]`);

@ -0,0 +1,42 @@
import { discoverPage as Page } from "@/integration/page-objects";
describe("Navigation Bar Tests", () => {
it("Navigation Bar should show admin options when logged in as an admin", () => {
cy.login();
Page.visit();
Page.navbar.adminDonate.should("be.visible");
Page.navbar.settings.should("be.visible");
Page.navbar.userManagement.should("be.visible");
Page.navbar.requests.should("be.visible");
Page.navbar.discover.should("be.visible");
Page.navbar.userPreferences.should("be.visible");
Page.navbar.logout.should("be.visible");
});
it("Navigation Bar should not show admin options when logged in as an non-admin", () => {
cy.generateUniqueId().then((id) => {
cy.login();
const roles = [];
roles.push({ value: "RequestMovie", enabled: true });
cy.createUser(id, "a", roles).then(() => {
cy.removeLogin();
cy.loginWithCreds(id, "a");
cy.intercept("GET", "search/Movie/Popular").as("discoverLoad");
Page.visit();
cy.wait("@discoverLoad");
Page.navbar.profileUsername.should('have.text', id);
Page.navbar.adminDonate.should("not.exist");
Page.navbar.settings.should("not.exist");
Page.navbar.userManagement.should("not.exist");
Page.navbar.requests.should("be.visible");
Page.navbar.discover.should("be.visible");
Page.navbar.userPreferences.should("be.visible");
Page.navbar.logout.should("be.visible");
});
});
});
});

2
tests/global.d.ts vendored

@ -5,7 +5,7 @@ declare namespace Cypress {
interface Chainable {
landingSettings(enabled: boolean): Chainable<any>;
login(username: string, password: string): Chainable<any>;
loginWithCreds(username: string, password: string): Chainable<any>;
login(): Chainable<any>;
removeLogin(): Chainable<any>;
verifyNotification(text: string): Chainable<any>;

@ -1,6 +1,6 @@
{
"devDependencies": {
"cypress": "^6.6.0",
"cypress": "6.7.1",
"cypress-wait-until": "^1.7.1",
"typescript": "^4.2.3"
},

@ -374,10 +374,10 @@ cypress-wait-until@^1.7.1:
resolved "https://registry.yarnpkg.com/cypress-wait-until/-/cypress-wait-until-1.7.1.tgz#3789cd18affdbb848e3cfc1f918353c7ba1de6f8"
integrity sha512-8DL5IsBTbAxBjfYgCzdbohPq/bY+IKc63fxtso1C8RWhLnQkZbVESyaclNr76jyxfId6uyzX8+Xnt0ZwaXNtkA==
cypress@^6.6.0:
version "6.6.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-6.6.0.tgz#659c64cdb06e51b6be18fdac39d8f192deb54fa0"
integrity sha512-+Xx3Zn653LJHUsCb9h1Keql2jlazbr1ROmbY6DFJMmXKLgXP4ez9cE403W93JNGRbZK0Tng3R/oP8mvd9XAPVg==
cypress@6.7.1:
version "6.7.1"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-6.7.1.tgz#6b8e1ba9badbded284ddc8575873b64211250ea6"
integrity sha512-MC9yt1GqpL4WVDQ0STI89K+PdLeC3T3NuAb2N61d6vYGR9pJy8w3Fqe0OWZwaRTJtg9eAyHXPGmFsyKeNQ3tmg==
dependencies:
"@cypress/listr-verbose-renderer" "^0.4.1"
"@cypress/request" "^2.88.5"

Loading…
Cancel
Save