mirror of https://github.com/Ombi-app/Ombi
fix: More automation tests mainly around the Plex Settings page (#4821)
* updates * test coverage on the plex settings page * features * Update cypress.yml * Update cypress.yml * Update cypress.yml * Update cypress.config.ts * fixes * stuff * put it back * a * always kill docker * Run the wizard as part of the feature files * fix? * slow the tests down * subby * Update user-preferences-profile.spec.ts * Update user-preferences-profile.spec.tspackage-updates
parent
5f60950802
commit
21bfc5a45a
@ -1,47 +1,47 @@
|
||||
name: 'Chromatic'
|
||||
# name: 'Chromatic'
|
||||
|
||||
# Event for the workflow
|
||||
on:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
# # Event for the workflow
|
||||
# on:
|
||||
# push:
|
||||
# workflow_dispatch:
|
||||
|
||||
# List of jobs
|
||||
jobs:
|
||||
storybook-build:
|
||||
# Operating System
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
# # List of jobs
|
||||
# jobs:
|
||||
# storybook-build:
|
||||
# # Operating System
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - name: Checkout repository
|
||||
# uses: actions/checkout@v2
|
||||
# with:
|
||||
# fetch-depth: 0
|
||||
|
||||
- name: NodeModules Cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: '**/node_modules'
|
||||
key: node_modules-${{ hashFiles('**/yarn.lock') }}
|
||||
# - name: NodeModules Cache
|
||||
# uses: actions/cache@v2
|
||||
# with:
|
||||
# path: '**/node_modules'
|
||||
# key: node_modules-${{ hashFiles('**/yarn.lock') }}
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: ./src/Ombi/ClientApp
|
||||
run: yarn
|
||||
# - name: Install dependencies
|
||||
# working-directory: ./src/Ombi/ClientApp
|
||||
# run: yarn
|
||||
|
||||
- name: Publish to Chromatic
|
||||
if: github.ref != 'refs/heads/master'
|
||||
uses: chromaui/action@v1
|
||||
with:
|
||||
projectToken: 7c47e1a1a4bd
|
||||
exitZeroOnChanges: true
|
||||
workingDir: ./src/Ombi/ClientApp
|
||||
buildScriptName: storybookbuild
|
||||
exitOnceUploaded: true
|
||||
# - name: Publish to Chromatic
|
||||
# if: github.ref != 'refs/heads/master'
|
||||
# uses: chromaui/action@v1
|
||||
# with:
|
||||
# projectToken: 7c47e1a1a4bd
|
||||
# exitZeroOnChanges: true
|
||||
# workingDir: ./src/Ombi/ClientApp
|
||||
# buildScriptName: storybookbuild
|
||||
# exitOnceUploaded: true
|
||||
|
||||
- name: Publish to Chromatic and auto accept changes
|
||||
if: github.ref == 'refs/heads/develop'
|
||||
uses: chromaui/action@v1
|
||||
with:
|
||||
projectToken: 7c47e1a1a4bd
|
||||
autoAcceptChanges: true # 👈 Option to accept all changes
|
||||
workingDir: ./src/Ombi/ClientApp
|
||||
buildScriptName: storybookbuild
|
||||
exitOnceUploaded: true
|
||||
# - name: Publish to Chromatic and auto accept changes
|
||||
# if: github.ref == 'refs/heads/develop'
|
||||
# uses: chromaui/action@v1
|
||||
# with:
|
||||
# projectToken: 7c47e1a1a4bd
|
||||
# autoAcceptChanges: true # 👈 Option to accept all changes
|
||||
# workingDir: ./src/Ombi/ClientApp
|
||||
# buildScriptName: storybookbuild
|
||||
# exitOnceUploaded: true
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,45 @@
|
||||
import { defineConfig } from 'cypress';
|
||||
import createBundler from "@bahmutov/cypress-esbuild-preprocessor";
|
||||
import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor";
|
||||
import createEsbuildPlugin from "@badeball/cypress-cucumber-preprocessor/esbuild";
|
||||
|
||||
export default defineConfig({
|
||||
watchForFileChanges: true,
|
||||
chromeWebSecurity: false,
|
||||
viewportWidth: 2560,
|
||||
viewportHeight: 1440,
|
||||
retries: {
|
||||
runMode: 2,
|
||||
openMode: 0,
|
||||
},
|
||||
env: {
|
||||
username: 'a',
|
||||
password: 'a',
|
||||
dockerhost: 'http://172.17.0.1'
|
||||
},
|
||||
projectId: 'o5451s',
|
||||
e2e: {
|
||||
// We've imported your old cypress plugins here.
|
||||
// You may want to clean this up later by importing these.
|
||||
async setupNodeEvents(
|
||||
on: Cypress.PluginEvents,
|
||||
config: Cypress.PluginConfigOptions
|
||||
): Promise<Cypress.PluginConfigOptions> {
|
||||
await addCucumberPreprocessorPlugin(on, config);
|
||||
|
||||
on(
|
||||
"file:preprocessor",
|
||||
createBundler({
|
||||
plugins: [createEsbuildPlugin(config)],
|
||||
})
|
||||
);
|
||||
|
||||
// Make sure to return the config object as it might have been modified by the plugin.
|
||||
return config;
|
||||
// return require('./cypress/plugins/index.js')(on, config)
|
||||
},
|
||||
baseUrl: 'http://localhost:5000',
|
||||
specPattern: ['cypress/tests/**/*.spec.ts*', '**/*.feature'],
|
||||
excludeSpecPattern: ['**/snapshots/*'],
|
||||
},
|
||||
})
|
@ -1,23 +0,0 @@
|
||||
{
|
||||
"$schema": "https://on.cypress.io/cypress.schema.json",
|
||||
"supportFile": "cypress/support/index.ts",
|
||||
"baseUrl": "http://localhost:5000",
|
||||
"integrationFolder": "cypress/tests",
|
||||
"testFiles": "**/*.spec.ts*",
|
||||
"watchForFileChanges": true,
|
||||
"chromeWebSecurity": false,
|
||||
"viewportWidth": 2560,
|
||||
"viewportHeight": 1440,
|
||||
"retries": {
|
||||
"runMode": 2,
|
||||
"openMode": 0
|
||||
},
|
||||
"ignoreTestFiles": [
|
||||
"**/snapshots/*"
|
||||
],
|
||||
"env": {
|
||||
"username": "a",
|
||||
"password": "a"
|
||||
},
|
||||
"projectId": "o5451s"
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
|
||||
Feature: Wizard Setup
|
||||
Scenario: When visiting Ombi for the first time we should be on the Wizard page
|
||||
When I visit Ombi
|
||||
Then I should be on the "Wizard"
|
||||
|
||||
Scenario: When navigating through the Wizard feature we are required to create a local user
|
||||
When I visit Ombi
|
||||
And I click through all of the pages
|
||||
And I finish the Wizard
|
||||
Then I should get a notification "Username '' is invalid, can only contain letters or digits."
|
||||
And I should be on the User tab
|
||||
|
||||
Scenario: Completing the Wizard
|
||||
When I visit Ombi
|
||||
And I click through to the user page
|
||||
And I enter a username
|
||||
And I enter a password
|
||||
And I go to the finished tab
|
||||
And I finish the Wizard
|
||||
Then I should be on the "login"
|
@ -0,0 +1,53 @@
|
||||
import { Given, When, Then } from "@badeball/cypress-cucumber-preprocessor";
|
||||
import { wizardPage as Page } from "@/integration/page-objects";
|
||||
|
||||
Given("I set the Landing Page to {string}", (bool) => {
|
||||
cy.landingSettings(bool);
|
||||
});
|
||||
|
||||
When("I visit Ombi", () => {
|
||||
Page.visit();
|
||||
});
|
||||
|
||||
When("I click through all of the pages", () => {
|
||||
Page.welcomeTab.next.click();
|
||||
Page.mediaServerTab.next.click();
|
||||
Page.localUserTab.next.click();
|
||||
Page.ombiConfigTab.next.click();
|
||||
});
|
||||
|
||||
When("I finish the Wizard", () => {
|
||||
Page.finishButton.click();
|
||||
});
|
||||
|
||||
When("I click through to the user page", () => {
|
||||
Page.welcomeTab.next.click();
|
||||
Page.mediaServerTab.next.click();
|
||||
});
|
||||
|
||||
When("I enter a username", () => {
|
||||
Page.localUserTab.username.type(Cypress.env("username"));
|
||||
});
|
||||
|
||||
When("I enter a password", () => {
|
||||
Page.localUserTab.password.type(Cypress.env("password"));
|
||||
});
|
||||
|
||||
When("I go to the finished tab", () => {
|
||||
Page.localUserTab.next.click();
|
||||
Page.ombiConfigTab.next.click();
|
||||
});
|
||||
|
||||
Then("I should be on the {string}", (string) => {
|
||||
cy.location("pathname").should("eq", `/${string}`);
|
||||
});
|
||||
|
||||
Then("I should get a notification {string}", (string) => {
|
||||
cy.verifyNotification(string);
|
||||
});
|
||||
|
||||
Then("I should be on the User tab", () => {
|
||||
Page.matStepsHeader.then((_) => {
|
||||
cy.get('#cdk-step-label-0-2').should('have.attr', 'aria-selected', 'true');
|
||||
});
|
||||
});
|
@ -0,0 +1,13 @@
|
||||
|
||||
Feature: Login Page
|
||||
Scenario: When visiting Ombi and the Landing Page is enabled, we should end up on the landing page
|
||||
Given I set the Landing Page to "true"
|
||||
When I visit Ombi
|
||||
Then I should be on the "landingpage"
|
||||
Then I click continue
|
||||
Then I should be on the "login/true"
|
||||
|
||||
Scenario: When visiting Ombi and the Landing Page is disabled, we should end up on the login page
|
||||
Given I set the Landing Page to "false"
|
||||
When I visit Ombi
|
||||
Then I should be on the "login"
|
@ -0,0 +1,19 @@
|
||||
import { After, Before, Given, When, Then } from "@badeball/cypress-cucumber-preprocessor";
|
||||
import { loginPage as Page } from "@/integration/page-objects";
|
||||
|
||||
Given("I set the Landing Page to {string}", (bool) => {
|
||||
cy.landingSettings(bool);
|
||||
});
|
||||
|
||||
When("I visit Ombi", () => {
|
||||
Page.visit();
|
||||
});
|
||||
|
||||
Then("I should be on the {string}", (string) => {
|
||||
cy.location("pathname").should("eq", `/${string}`);
|
||||
|
||||
});
|
||||
|
||||
Then("I click continue", () => {
|
||||
cy.get("[data-cy=continue]").click();
|
||||
});
|
@ -0,0 +1,23 @@
|
||||
{
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"urlPattern": "/library/sections"
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"jsonBody": {
|
||||
"mediaContainer": {
|
||||
"directory":[
|
||||
{ "key": "1", "title": "lib1"},
|
||||
{ "key": "2", "title": "lib2"},
|
||||
{ "key": "3", "title": "lib3"},
|
||||
{ "key": "4", "title": "lib4"},
|
||||
{ "key": "5", "title": "lib5"}
|
||||
]
|
||||
}
|
||||
},
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"request": {
|
||||
"method": "GET"
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"jsonBody": {
|
||||
"mediaContainer": {
|
||||
"version": "99"
|
||||
}
|
||||
},
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
import { BasePage } from "../../base.page";
|
||||
|
||||
class PlexCredentials {
|
||||
get username(): Cypress.Chainable<any> {
|
||||
return cy.get('#username');
|
||||
}
|
||||
|
||||
get password(): Cypress.Chainable<any> {
|
||||
return cy.get('#password');
|
||||
}
|
||||
|
||||
get loadServers(): Cypress.Chainable<any> {
|
||||
return cy.get('#loadServers');
|
||||
}
|
||||
|
||||
get serverDropdown(): Cypress.Chainable<any> {
|
||||
return cy.get('#servers');
|
||||
}
|
||||
}
|
||||
|
||||
class PlexServerModal {
|
||||
get serverName(): Cypress.Chainable<any> {
|
||||
return cy.get('#serverName');
|
||||
}
|
||||
get hostName(): Cypress.Chainable<any> {
|
||||
return cy.get('#ip');
|
||||
}
|
||||
get port(): Cypress.Chainable<any> {
|
||||
return cy.get('#port');
|
||||
}
|
||||
get ssl(): Cypress.Chainable<any> {
|
||||
return cy.get('#ssl');
|
||||
}
|
||||
get authToken(): Cypress.Chainable<any> {
|
||||
return cy.get('#authToken');
|
||||
}
|
||||
get machineIdentifier(): Cypress.Chainable<any> {
|
||||
return cy.get('#machineId');
|
||||
}
|
||||
get externalHostname(): Cypress.Chainable<any> {
|
||||
return cy.get('#externalHostname');
|
||||
}
|
||||
get batchSize(): Cypress.Chainable<any> {
|
||||
return cy.get('#batchSize');
|
||||
}
|
||||
get loadLibraries(): Cypress.Chainable<any> {
|
||||
return cy.get('#loadLibs');
|
||||
}
|
||||
get testButton(): Cypress.Chainable<any> {
|
||||
return cy.get('#testPlexButton');
|
||||
}
|
||||
get deleteButton(): Cypress.Chainable<any> {
|
||||
return cy.get('#deleteServer');
|
||||
}
|
||||
get cancelButton(): Cypress.Chainable<any> {
|
||||
return cy.get('#cancel');
|
||||
}
|
||||
get saveButton(): Cypress.Chainable<any> {
|
||||
return cy.get('#saveServer');
|
||||
}
|
||||
|
||||
getLib(index: number): Cypress.Chainable<any> {
|
||||
return cy.get(`#lib-${index}`);
|
||||
}
|
||||
}
|
||||
|
||||
class PlexServersGrid {
|
||||
serverCardButton(name: string): Cypress.Chainable<any> {
|
||||
return cy.get(`#${name}-button`);
|
||||
}
|
||||
|
||||
get newServerButton(): Cypress.Chainable<any> {
|
||||
return cy.get('#newServer');
|
||||
}
|
||||
}
|
||||
|
||||
class PlexSettingsPage extends BasePage {
|
||||
|
||||
|
||||
get enableCheckbox(): Cypress.Chainable<any> {
|
||||
return cy.get('#enable');
|
||||
}
|
||||
|
||||
get enableWatchlist(): Cypress.Chainable<any> {
|
||||
return cy.get('#enableWatchlistImport');
|
||||
}
|
||||
|
||||
get submit(): Cypress.Chainable<any> {
|
||||
return cy.get('#save');
|
||||
}
|
||||
|
||||
get fullySync(): Cypress.Chainable<any> {
|
||||
return cy.get('#fullSync');
|
||||
}
|
||||
|
||||
get partialSync(): Cypress.Chainable<any> {
|
||||
return cy.get('#recentlyAddedSync');
|
||||
}
|
||||
|
||||
get clearAndResync(): Cypress.Chainable<any> {
|
||||
return cy.get('#clearData');
|
||||
}
|
||||
|
||||
get runWatchlist(): Cypress.Chainable<any> {
|
||||
return cy.get('#watchlistImport');
|
||||
}
|
||||
|
||||
plexCredentials = new PlexCredentials();
|
||||
plexServerModal = new PlexServerModal();
|
||||
plexServerGrid = new PlexServersGrid();
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
visit(options: Cypress.VisitOptions): Cypress.Chainable<Cypress.AUTWindow>;
|
||||
visit(): Cypress.Chainable<Cypress.AUTWindow>;
|
||||
visit(id: string): Cypress.Chainable<Cypress.AUTWindow>;
|
||||
visit(id: string, options: Cypress.VisitOptions): Cypress.Chainable<Cypress.AUTWindow>;
|
||||
visit(id?: any, options?: any) {
|
||||
return cy.visit(`/Settings/Plex`, options);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const plexSettingsPage = new PlexSettingsPage();
|
@ -0,0 +1,20 @@
|
||||
import { BasePage } from "../base.page";
|
||||
|
||||
|
||||
class SettingsPage extends BasePage {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
visit(options: Cypress.VisitOptions): Cypress.Chainable<Cypress.AUTWindow>;
|
||||
visit(): Cypress.Chainable<Cypress.AUTWindow>;
|
||||
visit(id: string): Cypress.Chainable<Cypress.AUTWindow>;
|
||||
visit(id: string, options: Cypress.VisitOptions): Cypress.Chainable<Cypress.AUTWindow>;
|
||||
visit(id?: any, options?: any) {
|
||||
return cy.visit(`/Settings/About`, options);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const settingsPage = new SettingsPage();
|
@ -0,0 +1,15 @@
|
||||
|
||||
Cypress.Commands.add('addMock', (mapping) => {
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: 'http://localhost:32400/__admin/mappings',
|
||||
body: mapping
|
||||
})
|
||||
})
|
||||
|
||||
Cypress.Commands.add('clearMocks', () => {
|
||||
cy.request({
|
||||
method: 'DELETE',
|
||||
url: 'http://localhost:32400/__admin/mappings'
|
||||
})
|
||||
})
|
@ -0,0 +1,12 @@
|
||||
|
||||
Cypress.Commands.add('clearPlexServers', () => {
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: '/api/v1/Settings/Plex/',
|
||||
body: `{"enable":false,"enableWatchlistImport":false,"monitorAll":false,"installId":"0c5c597d-56ea-4f34-8f59-18d34ec82482","servers":[],"id":2}`,
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + window.localStorage.getItem('id_token'),
|
||||
'Content-Type':"application/json"
|
||||
}
|
||||
})
|
||||
})
|
@ -1,47 +0,0 @@
|
||||
import { wizardPage as Page } from "@/integration/page-objects";
|
||||
|
||||
describe("Wizard Setup", () => {
|
||||
|
||||
it("Wizard should be first page", () => {
|
||||
Page.visit();
|
||||
cy.location("pathname").should("contains", "/Wizard");
|
||||
});
|
||||
|
||||
|
||||
it("Finsh with no local user", () => {
|
||||
Page.visit();
|
||||
|
||||
Page.welcomeTab.next.click();
|
||||
Page.mediaServerTab.next.click();
|
||||
Page.localUserTab.next.click();
|
||||
Page.ombiConfigTab.next.click();
|
||||
Page.finishButton.click();
|
||||
|
||||
cy.verifyNotification("Username '' is invalid, can only contain letters or digits.")
|
||||
|
||||
// Verify we end back up on the user page
|
||||
Page.matStepsHeader.then((items) => {
|
||||
|
||||
cy.get('#cdk-step-label-0-2').should('have.attr', 'aria-selected', 'true');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it("Compete Wizard", () => {
|
||||
Page.visit();
|
||||
|
||||
Page.welcomeTab.next.click();
|
||||
Page.mediaServerTab.next.click();
|
||||
|
||||
Page.localUserTab.username.type(Cypress.env("username"));
|
||||
Page.localUserTab.password.type(Cypress.env("password"));
|
||||
|
||||
Page.localUserTab.next.click();
|
||||
Page.ombiConfigTab.next.click();
|
||||
|
||||
Page.finishButton.click();
|
||||
|
||||
cy.location("pathname").should("contains", "/login");
|
||||
});
|
||||
});
|
@ -0,0 +1,182 @@
|
||||
import { plexSettingsPage as Page } from "@/integration/page-objects";
|
||||
|
||||
describe("Plex Settings Tests", () => {
|
||||
beforeEach(() => {
|
||||
cy.login();
|
||||
cy.clearPlexServers();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cy.clearMocks();
|
||||
})
|
||||
|
||||
const plexTvApiResponse = `{
|
||||
"success": true,
|
||||
"message": null,
|
||||
"servers": {
|
||||
"server": [
|
||||
{
|
||||
"accessToken": "myaccessToken",
|
||||
"name": "AutomationServer",
|
||||
"address": "1.1.1.1",
|
||||
"port": "32400",
|
||||
"version": "1.30.0.6442-5070ad484",
|
||||
"scheme": "http",
|
||||
"host": "2.2.2.2",
|
||||
"localAddresses": "${Cypress.env("dockerhost")}",
|
||||
"machineIdentifier": "9999999999999999",
|
||||
"createdAt": "5555555555",
|
||||
"updatedAt": "6666666666",
|
||||
"owned": "1",
|
||||
"synced": "0",
|
||||
"sourceTitle": null,
|
||||
"ownerId": null,
|
||||
"home": null
|
||||
}
|
||||
],
|
||||
"friendlyName": "myPlex",
|
||||
"identifier": "com.plexapp.plugins.myplex",
|
||||
"machineIdentifier": "3dd86546546546540ff065465460c2654654654654",
|
||||
"size": "1"
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
it("Load Servers from Plex.TV Api and Save", () => {
|
||||
loadServerFromPlexTvApi();
|
||||
|
||||
const modal = Page.plexServerModal;
|
||||
modal.serverName.should('have.value','AutomationServer');
|
||||
modal.hostName.should('have.value', Cypress.env("dockerhost"));
|
||||
modal.port.should('have.value','32400');
|
||||
modal.authToken.should('have.value','myaccessToken');
|
||||
modal.machineIdentifier.should('have.value','9999999999999999');
|
||||
|
||||
modal.saveButton.click();
|
||||
|
||||
Page.plexServerGrid.serverCardButton('AutomationServer').should('be.visible');
|
||||
|
||||
Page.submit.click();
|
||||
|
||||
cy.wait("@plexSave");
|
||||
|
||||
});
|
||||
|
||||
it("Load Servers from Plex.TV Api and Edit", () => {
|
||||
loadServerFromPlexTvApi();
|
||||
|
||||
const modal = Page.plexServerModal;
|
||||
modal.saveButton.click();
|
||||
|
||||
Page.plexServerGrid.serverCardButton('AutomationServer').should('be.visible');
|
||||
|
||||
Page.submit.click();
|
||||
|
||||
cy.wait("@plexSave");
|
||||
|
||||
// Edit server
|
||||
Page.plexServerGrid.serverCardButton('AutomationServer').click();
|
||||
modal.serverName.should('have.value','AutomationServer');
|
||||
modal.hostName.should('have.value', Cypress.env("dockerhost"));
|
||||
modal.port.should('have.value','32400');
|
||||
modal.authToken.should('have.value','myaccessToken');
|
||||
modal.machineIdentifier.should('have.value','9999999999999999');
|
||||
|
||||
});
|
||||
|
||||
it("Load Servers from Plex.TV Api and Test", () => {
|
||||
cy.fixture('/mocks/plex/plex-test.mock').then((json) => {
|
||||
cy.addMock(json);
|
||||
});
|
||||
loadServerFromPlexTvApi();
|
||||
cy.intercept("POST", "api/v1/tester/plex", (req) => {
|
||||
req.reply((res) => {
|
||||
res.send(plexTvApiResponse);
|
||||
});
|
||||
}).as("testResponse");
|
||||
|
||||
const modal = Page.plexServerModal;
|
||||
|
||||
modal.testButton.click();
|
||||
cy.wait("@testResponse").then(() => {
|
||||
cy.contains("Successfully connected to the Plex server AutomationServer");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it("Load Libraries from New Server", () => {
|
||||
cy.fixture('/mocks/plex/plex-libraries.mock').then((json) => {
|
||||
cy.addMock(json);
|
||||
});
|
||||
cy.intercept("POST", "api/v1/Plex/Libraries").as("libRequest");
|
||||
newServer();
|
||||
|
||||
const modal = Page.plexServerModal;
|
||||
modal.loadLibraries.click();
|
||||
|
||||
cy.wait("@libRequest");
|
||||
|
||||
modal.getLib(0).click();
|
||||
modal.getLib(0).should('contain.text',"lib1");
|
||||
});
|
||||
|
||||
it("Remove server", () => {
|
||||
loadServerFromPlexTvApi();
|
||||
const modal = Page.plexServerModal;
|
||||
modal.saveButton.click();
|
||||
|
||||
newServer(false);
|
||||
modal.saveButton.click();
|
||||
|
||||
Page.plexServerGrid.serverCardButton('AutomationServer').click();
|
||||
modal.deleteButton.click();
|
||||
Page.plexServerGrid.serverCardButton('ManualServer').click();
|
||||
modal.deleteButton.click();
|
||||
|
||||
Page.plexServerGrid.serverCardButton('AutomationServer').should('not.exist');
|
||||
Page.plexServerGrid.serverCardButton('ManualServer').should('not.exist');
|
||||
});
|
||||
|
||||
function loadServerFromPlexTvApi(visitPage = true) {
|
||||
cy.intercept("POST", "api/v1/Plex/servers", (req) => {
|
||||
req.reply((res) => {
|
||||
res.send(plexTvApiResponse);
|
||||
});
|
||||
}).as("serverResponse");
|
||||
|
||||
cy.intercept("POST", "api/v1/Settings/Plex").as('plexSave');
|
||||
|
||||
if (visitPage) {
|
||||
Page.visit();
|
||||
}
|
||||
|
||||
Page.plexCredentials.username.type('username');
|
||||
Page.plexCredentials.password.type('password');
|
||||
|
||||
Page.plexCredentials.loadServers.click();
|
||||
|
||||
cy.wait("@serverResponse");
|
||||
|
||||
Page.plexCredentials.serverDropdown.click().get('mat-option').contains('AutomationServer').click();
|
||||
}
|
||||
|
||||
function newServer(visitPage = true) {
|
||||
if (visitPage) {
|
||||
Page.visit();
|
||||
}
|
||||
|
||||
Page.plexServerGrid.newServerButton.click();
|
||||
const modal = Page.plexServerModal;
|
||||
|
||||
const server = JSON.parse(plexTvApiResponse);
|
||||
modal.serverName.clear();
|
||||
modal.serverName.type("ManualServer");
|
||||
modal.hostName.type(server.servers.server[0].localAddresses);
|
||||
modal.port.type(server.servers.server[0].port);
|
||||
modal.authToken.type(server.servers.server[0].accessToken);
|
||||
modal.machineIdentifier.type(server.servers.server[0].machineIdentifier);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue