You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ombi/tests/cypress/support/commands.ts

91 lines
2.5 KiB

// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
Cypress.Commands.add("landingSettings", (enabled) => {
cy.fixture('login/landingPageSettings').then((settings) => {
settings.enabled = enabled;
cy.intercept("GET", "**/Settings/LandingPage", settings).as("landingPageSettingsDisabled");
})
})
Cypress.Commands.add('login', (username, password) => {
cy.clearLocalStorage();
cy.request({
method: 'POST',
url: '/api/v1/token',
body: {
username: username,
password: password,
}
})
.then((resp) => {
window.localStorage.setItem('id_token', resp.body.access_token);
});
});
Cypress.Commands.add('login', () => {
cy.clearLocalStorage();
cy.request({
method: 'POST',
url: '/api/v1/token',
body: {
username: Cypress.env('username'),
password: Cypress.env('password'),
}
})
.then((resp) => {
window.localStorage.setItem('id_token', resp.body.access_token);
});
});
Cypress.Commands.add('removeLogin', () => {
window.localStorage.removeItem('id_token');
});
Cypress.Commands.add('verifyNotification', (text) => {
cy.contains(text);
});
Cypress.Commands.add('createUser', (username, password, claims) => {
cy.request({
method: 'POST',
url: '/api/v1/identity',
body: {
UserName: username,
Password: password,
Claims: claims,
},
headers: {
'Authorization': 'Bearer ' + window.localStorage.getItem('id_token'),
}
})
})
Cypress.Commands.add('generateUniqueId', () => {
const uniqueSeed = Date.now().toString();
const id = Cypress._.uniqueId(uniqueSeed);
return id;
});