* 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)
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
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();
|
|
});
|
|
});
|