Added acceptance tests for testing the API for the Script section (#14441)
* Added auth to gitignore * Added a setup for logging in which allows us to save the token for the user * Added simple acceptance test for testing our api for the DataTypes * Added simple acceptance tests for testing the API for the PartialView section * Added simple acceptance tests for testing the API for the Script section * Added acceptance tests for testing the API for the Stylesheet section. (#14442)
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import {test} from '@umbraco/playwright-testhelpers';
|
||||
import {expect} from "@playwright/test";
|
||||
|
||||
test.describe('Script tests', () => {
|
||||
const scriptName = 'scriptName.js';
|
||||
|
||||
test.beforeEach(async ({page, umbracoApi}) => {
|
||||
await umbracoApi.script.ensureScriptNotNameNotExistsAtRoot(scriptName);
|
||||
});
|
||||
|
||||
test.afterEach(async ({page, umbracoApi}) => {
|
||||
await umbracoApi.script.ensureScriptNotNameNotExistsAtRoot(scriptName);
|
||||
});
|
||||
|
||||
test('can create a script', async ({page, umbracoApi, umbracoUi}) => {
|
||||
await umbracoApi.script.createScript(scriptName, 'test');
|
||||
|
||||
// Assert
|
||||
await expect(await umbracoApi.script.doesScriptWithNameExistAtRoot(scriptName)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('can update a script', async ({page, umbracoApi, umbracoUi}) => {
|
||||
const newContent = 'Howdy';
|
||||
|
||||
await umbracoApi.script.createScript(scriptName, 'test');
|
||||
|
||||
const script = await umbracoApi.script.getScriptByNameAtRoot(scriptName);
|
||||
|
||||
script.content = newContent;
|
||||
|
||||
await umbracoApi.script.updateScript(script);
|
||||
|
||||
// Assert
|
||||
// Checks if the content was updated for the script
|
||||
const updatedScript = await umbracoApi.script.getScriptByPath(script.path);
|
||||
await expect(updatedScript.content === newContent).toBeTruthy();
|
||||
});
|
||||
|
||||
test('can delete a script', async ({page, umbracoApi, umbracoUi}) => {
|
||||
await umbracoApi.script.createScript(scriptName, 'test');
|
||||
|
||||
await expect(await umbracoApi.script.doesScriptWithNameExistAtRoot(scriptName)).toBeTruthy();
|
||||
|
||||
const script = await umbracoApi.script.getScriptByNameAtRoot(scriptName);
|
||||
|
||||
await umbracoApi.script.deleteScriptByPath(script.path);
|
||||
|
||||
// Assert
|
||||
await expect(await umbracoApi.script.doesScriptWithNameExistAtRoot(scriptName)).toBeFalsy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,69 @@
|
||||
import {test} from '@umbraco/playwright-testhelpers';
|
||||
import {expect} from "@playwright/test";
|
||||
|
||||
test.describe('Script Folder tests', () => {
|
||||
const scriptFolderName = 'scriptFolder';
|
||||
|
||||
test.beforeEach(async ({page, umbracoApi}) => {
|
||||
await umbracoApi.script.ensureScriptNotNameNotExistsAtRoot(scriptFolderName);
|
||||
});
|
||||
|
||||
test.afterEach(async ({page, umbracoApi}) => {
|
||||
await umbracoApi.script.ensureScriptNotNameNotExistsAtRoot(scriptFolderName);
|
||||
});
|
||||
|
||||
test('can create script folder', async ({page, umbracoApi, umbracoUi}) => {
|
||||
await umbracoApi.script.createScriptFolder(scriptFolderName);
|
||||
|
||||
// Assert
|
||||
await expect(umbracoApi.script.doesScriptWithNameExistAtRoot(scriptFolderName)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('can delete script folder', async ({page, umbracoApi, umbracoUi}) => {
|
||||
await umbracoApi.script.createScriptFolder(scriptFolderName);
|
||||
|
||||
await expect(await umbracoApi.script.doesScriptWithNameExistAtRoot(scriptFolderName)).toBeTruthy();
|
||||
const scriptFolder = await umbracoApi.script.getScriptByNameAtRoot(scriptFolderName);
|
||||
|
||||
await umbracoApi.script.deleteScriptFolder(scriptFolder.path);
|
||||
|
||||
// Assert
|
||||
await expect(await umbracoApi.script.doesScriptWithNameExistAtRoot(scriptFolderName)).toBeFalsy();
|
||||
});
|
||||
|
||||
test('can add a script folder in another folder', async ({page, umbracoApi, umbracoUi}) => {
|
||||
const childFolderName = 'childFolder';
|
||||
await umbracoApi.script.createScriptFolder(scriptFolderName);
|
||||
|
||||
const parentFolder = await umbracoApi.script.getScriptByNameAtRoot(scriptFolderName);
|
||||
|
||||
await umbracoApi.script.createScriptFolder(childFolderName, parentFolder.path);
|
||||
|
||||
const children = await umbracoApi.script.getChildrenInScriptFolderByPath(parentFolder.path);
|
||||
|
||||
// Assert
|
||||
await expect(children.items[0].name === childFolderName).toBeTruthy();
|
||||
});
|
||||
|
||||
test('can add a script folder in a folder in another folder', async ({page, umbracoApi, umbracoUi}) => {
|
||||
const childFolderName = 'childFolder';
|
||||
const childOfChildFolderName = 'childOfChildFolder';
|
||||
|
||||
// Creates parent folder
|
||||
await umbracoApi.script.createScriptFolder(scriptFolderName);
|
||||
const parentFolder = await umbracoApi.script.getScriptByNameAtRoot(scriptFolderName);
|
||||
|
||||
// Creates child folder in parent folder
|
||||
await umbracoApi.script.createScriptFolder(childFolderName, parentFolder.path);
|
||||
const childOfParent = await umbracoApi.script.getChildrenInScriptFolderByPath(parentFolder.path);
|
||||
|
||||
// Creates childOfChild folder in child folder
|
||||
await umbracoApi.script.createScriptFolder(childOfChildFolderName, childOfParent.items[0].path);
|
||||
const childOfChild = await umbracoApi.script.getChildrenInScriptFolderByPath(childOfParent.items[0].path);
|
||||
|
||||
// Assert
|
||||
// Checks if the script folder are in the correct folders
|
||||
await expect(childOfParent.items[0].name === childFolderName).toBeTruthy();
|
||||
await expect(childOfChild.items[0].name === childOfChildFolderName).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,96 @@
|
||||
import {test} from '@umbraco/playwright-testhelpers';
|
||||
import {expect} from "@playwright/test";
|
||||
|
||||
test.describe('Stylesheet tests', () => {
|
||||
const stylesheetName = 'Stylesheet.css';
|
||||
|
||||
test.beforeEach(async ({page, umbracoApi}) => {
|
||||
await umbracoApi.stylesheet.ensureStylesheetNameNotExistsAtRoot(stylesheetName);
|
||||
});
|
||||
|
||||
test.afterEach(async ({page, umbracoApi}) => {
|
||||
await umbracoApi.stylesheet.ensureStylesheetNameNotExistsAtRoot(stylesheetName);
|
||||
});
|
||||
|
||||
test('can create a stylesheet', async ({page, umbracoApi, umbracoUi}) => {
|
||||
await umbracoApi.stylesheet.createStylesheet(stylesheetName, 'content');
|
||||
|
||||
// Assert
|
||||
await expect(await umbracoApi.stylesheet.doesStylesheetWithNameExistAtRoot(stylesheetName)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('can update a stylesheet', async ({page, umbracoApi, umbracoUi}) => {
|
||||
const newContent = 'BetterContent';
|
||||
|
||||
await umbracoApi.stylesheet.createStylesheet(stylesheetName, 'content');
|
||||
|
||||
const stylesheet = await umbracoApi.stylesheet.getStylesheetByNameAtRoot(stylesheetName);
|
||||
|
||||
stylesheet.content = newContent;
|
||||
|
||||
await umbracoApi.stylesheet.updateStylesheet(stylesheet);
|
||||
|
||||
// Assert
|
||||
// Checks if the content was updated for the stylesheet
|
||||
const updatedStylesheet = await umbracoApi.stylesheet.getStylesheetByPath(stylesheet.path);
|
||||
await expect(updatedStylesheet.content === newContent).toBeTruthy();
|
||||
});
|
||||
|
||||
test('can delete a stylesheet', async ({page, umbracoApi, umbracoUi}) => {
|
||||
await umbracoApi.stylesheet.createStylesheet(stylesheetName, 'content');
|
||||
|
||||
await expect(await umbracoApi.stylesheet.doesStylesheetWithNameExistAtRoot(stylesheetName)).toBeTruthy();
|
||||
|
||||
const stylesheet = await umbracoApi.stylesheet.getStylesheetByNameAtRoot(stylesheetName);
|
||||
|
||||
await umbracoApi.stylesheet.deleteStylesheetByPath(stylesheet.path);
|
||||
|
||||
// Assert
|
||||
await expect(await umbracoApi.stylesheet.doesStylesheetWithNameExistAtRoot(stylesheetName)).toBeFalsy();
|
||||
});
|
||||
|
||||
test('can create a stylesheet in a folder', async ({page, umbracoApi, umbracoUi}) => {
|
||||
const folderName = 'StyledFolder';
|
||||
|
||||
await umbracoApi.stylesheet.ensureStylesheetNameNotExistsAtRoot(folderName);
|
||||
|
||||
await umbracoApi.stylesheet.createStylesheetFolder(folderName);
|
||||
|
||||
const folder = await umbracoApi.stylesheet.getStylesheetByNameAtRoot(folderName);
|
||||
|
||||
await umbracoApi.stylesheet.createStylesheet(stylesheetName, 'content', folder.path);
|
||||
|
||||
// Assert
|
||||
const child = await umbracoApi.stylesheet.getChildrenInStylesheetFolderByPath(folder.path);
|
||||
await expect(child.items[0].name === stylesheetName).toBeTruthy();
|
||||
|
||||
// Clean
|
||||
await umbracoApi.stylesheet.ensureStylesheetNameNotExistsAtRoot(folderName);
|
||||
});
|
||||
|
||||
test('can delete a stylesheet from a folder', async ({page, umbracoApi, umbracoUi}) => {
|
||||
const folderName = 'StyledFolder';
|
||||
|
||||
await umbracoApi.stylesheet.ensureStylesheetNameNotExistsAtRoot(folderName);
|
||||
|
||||
await umbracoApi.stylesheet.createStylesheetFolder(folderName);
|
||||
|
||||
const folder = await umbracoApi.stylesheet.getStylesheetByNameAtRoot(folderName);
|
||||
|
||||
await umbracoApi.stylesheet.createStylesheet(stylesheetName, 'deleteMe', folder.path);
|
||||
|
||||
// Checks if the stylesheet was created
|
||||
const child = await umbracoApi.stylesheet.getChildrenInStylesheetFolderByPath(folder.path);
|
||||
|
||||
await expect(child.items[0].name === stylesheetName).toBeTruthy();
|
||||
|
||||
await umbracoApi.stylesheet.deleteStylesheetByPath(child.items[0].path);
|
||||
|
||||
// Assert
|
||||
const noChild = await umbracoApi.stylesheet.getChildrenInStylesheetFolderByPath(folder.path);
|
||||
await expect(noChild.items[0] === undefined).toBeTruthy();
|
||||
|
||||
// Clean
|
||||
await umbracoApi.stylesheet.ensureStylesheetNameNotExistsAtRoot(folderName);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,96 @@
|
||||
import {test} from '@umbraco/playwright-testhelpers';
|
||||
import {expect} from "@playwright/test";
|
||||
|
||||
test.describe('Stylesheet Folder tests', () => {
|
||||
const stylesheetFolderName = 'StylesheetFolder';
|
||||
|
||||
test.beforeEach(async ({page, umbracoApi}) => {
|
||||
await umbracoApi.stylesheet.ensureStylesheetNameNotExistsAtRoot(stylesheetFolderName);
|
||||
});
|
||||
|
||||
test.afterEach(async ({page, umbracoApi}) => {
|
||||
await umbracoApi.stylesheet.ensureStylesheetNameNotExistsAtRoot(stylesheetFolderName);
|
||||
});
|
||||
|
||||
test('can create stylesheet folder', async ({page, umbracoApi, umbracoUi}) => {
|
||||
await umbracoApi.stylesheet.createStylesheetFolder(stylesheetFolderName);
|
||||
|
||||
// Assert
|
||||
await expect(await umbracoApi.stylesheet.doesStylesheetWithNameExistAtRoot(stylesheetFolderName)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('can delete stylesheet folder', async ({page, umbracoApi, umbracoUi}) => {
|
||||
await umbracoApi.stylesheet.createStylesheetFolder(stylesheetFolderName);
|
||||
|
||||
await expect(await umbracoApi.stylesheet.doesStylesheetWithNameExistAtRoot(stylesheetFolderName)).toBeTruthy();
|
||||
|
||||
const stylesheet = await umbracoApi.stylesheet.getStylesheetByNameAtRoot(stylesheetFolderName);
|
||||
|
||||
await umbracoApi.stylesheet.deleteStylesheetFolder(stylesheet.path);
|
||||
|
||||
// Assert
|
||||
await expect(await umbracoApi.stylesheet.doesStylesheetWithNameExistAtRoot(stylesheetFolderName)).toBeFalsy();
|
||||
});
|
||||
|
||||
test('can add a stylesheet folder in another folder', async ({page, umbracoApi, umbracoUi}) => {
|
||||
const childFolderName = 'childFolder';
|
||||
await umbracoApi.stylesheet.createStylesheetFolder(stylesheetFolderName);
|
||||
|
||||
const parentFolder = await umbracoApi.stylesheet.getStylesheetByNameAtRoot(stylesheetFolderName);
|
||||
|
||||
await umbracoApi.stylesheet.createStylesheetFolder(childFolderName, parentFolder.path);
|
||||
|
||||
const children = await umbracoApi.stylesheet.getChildrenInStylesheetFolderByPath(parentFolder.path);
|
||||
|
||||
// Assert
|
||||
await expect(children.items[0].name === childFolderName).toBeTruthy();
|
||||
});
|
||||
|
||||
test('can add a stylesheet folder in a folder that is in another folder', async ({page, umbracoApi, umbracoUi}) => {
|
||||
const childFolderName = 'childFolder';
|
||||
const childOfChildFolderName = 'childOfChildFolder';
|
||||
|
||||
// Creates parent folder
|
||||
await umbracoApi.stylesheet.createStylesheetFolder(stylesheetFolderName);
|
||||
|
||||
const parentFolder = await umbracoApi.stylesheet.getStylesheetByNameAtRoot(stylesheetFolderName);
|
||||
|
||||
// Creates child folder in parent folder
|
||||
await umbracoApi.stylesheet.createStylesheetFolder(childFolderName, parentFolder.path);
|
||||
|
||||
const childOfParent = await umbracoApi.stylesheet.getChildrenInStylesheetFolderByPath(parentFolder.path);
|
||||
|
||||
// Creates childOfChild folder in child folder
|
||||
await umbracoApi.stylesheet.createStylesheetFolder(childOfChildFolderName, childOfParent.items[0].path);
|
||||
|
||||
const childOfChild = await umbracoApi.stylesheet.getChildrenInStylesheetFolderByPath(childOfParent.items[0].path);
|
||||
|
||||
// Assert
|
||||
// Checks if the stylesheet folder are in the correct folders
|
||||
await expect(childOfParent.items[0].name === childFolderName).toBeTruthy();
|
||||
await expect(childOfChild.items[0].name === childOfChildFolderName).toBeTruthy();
|
||||
});
|
||||
|
||||
test('can delete a stylesheet folder from another folder', async ({page, umbracoApi, umbracoUi}) => {
|
||||
const childFolderName = 'childFolder';
|
||||
|
||||
await umbracoApi.stylesheet.createStylesheetFolder(stylesheetFolderName);
|
||||
|
||||
const parentFolder = await umbracoApi.stylesheet.getStylesheetByNameAtRoot(stylesheetFolderName);
|
||||
|
||||
await umbracoApi.stylesheet.createStylesheetFolder(childFolderName, parentFolder.path);
|
||||
|
||||
const child = await umbracoApi.stylesheet.getChildrenInStylesheetFolderByPath(parentFolder.path);
|
||||
|
||||
await expect(child.items[0].name === childFolderName).toBeTruthy();
|
||||
|
||||
await umbracoApi.stylesheet.doesStylesheetWithPathExist(child.items[0].path);
|
||||
|
||||
await umbracoApi.stylesheet.deleteStylesheetFolder(child.items[0].path);
|
||||
|
||||
const noChild = await umbracoApi.stylesheet.getChildrenInStylesheetFolderByPath(parentFolder.path);
|
||||
|
||||
// Assert
|
||||
await expect(noChild.items[0] === undefined).toBeTruthy();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user