test: GCP plugin acceptance tests (#2648)
This commit is contained in:
1 parent
dfa62dd04b
commit
cc8d4fe952
3 files changed
+75
-1
No files matched your search
@@ -11,6 +11,10 @@ import { Response } from 'miragejs';
|
||||
import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
import { setupIndexedDb } from 'api/test-support/helpers/indexed-db';
|
||||
import * as commonSelectors from 'admin/tests/helpers/selectors';
|
||||
import {
|
||||
TYPE_HOST_CATALOG_DYNAMIC,
|
||||
TYPE_HOST_CATALOG_PLUGIN_GCP,
|
||||
} from 'api/models/host-catalog';
|
||||
|
||||
module('Acceptance | host-catalogs | delete', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
@@ -30,6 +34,7 @@ module('Acceptance | host-catalogs | delete', function (hooks) {
|
||||
project: null,
|
||||
},
|
||||
hostCatalog: null,
|
||||
gcpDynamicHostCatalog: null,
|
||||
};
|
||||
const urls = {
|
||||
globalScope: null,
|
||||
@@ -37,6 +42,7 @@ module('Acceptance | host-catalogs | delete', function (hooks) {
|
||||
projectScope: null,
|
||||
hostCatalogs: null,
|
||||
hostCatalog: null,
|
||||
gcpDynamicHostCatalog: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(async function () {
|
||||
@@ -53,12 +59,20 @@ module('Acceptance | host-catalogs | delete', function (hooks) {
|
||||
instances.hostCatalog = this.server.create('host-catalog', {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
|
||||
instances.gcpDynamicHostCatalog = this.server.create('host-catalog', {
|
||||
scope: instances.scopes.project,
|
||||
type: TYPE_HOST_CATALOG_DYNAMIC,
|
||||
plugin: { name: TYPE_HOST_CATALOG_PLUGIN_GCP },
|
||||
});
|
||||
|
||||
// Generate route URLs for resources
|
||||
urls.globalScope = `/scopes/global/scopes`;
|
||||
urls.orgScope = `/scopes/${instances.scopes.org.id}/scopes`;
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.hostCatalogs = `${urls.projectScope}/host-catalogs`;
|
||||
urls.hostCatalog = `${urls.hostCatalogs}/${instances.hostCatalog.id}`;
|
||||
urls.gcpDynamicHostCatalog = `${urls.hostCatalogs}/${instances.gcpDynamicHostCatalog.id}`;
|
||||
// Generate resource counter
|
||||
getHostCatalogCount = () =>
|
||||
this.server.schema.hostCatalogs.all().models.length;
|
||||
@@ -76,6 +90,18 @@ module('Acceptance | host-catalogs | delete', function (hooks) {
|
||||
assert.strictEqual(getHostCatalogCount(), hostCatalogCount - 1);
|
||||
});
|
||||
|
||||
test('can delete GCP host catalog', async function (assert) {
|
||||
const hostCatalogCount = getHostCatalogCount();
|
||||
|
||||
await visit(urls.hostCatalogs);
|
||||
await click(`[href="${urls.gcpDynamicHostCatalog}"]`);
|
||||
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
|
||||
assert.strictEqual(getHostCatalogCount(), hostCatalogCount - 1);
|
||||
});
|
||||
|
||||
test('cannot delete host catalog without proper authorization', async function (assert) {
|
||||
await visit(urls.hostCatalogs);
|
||||
instances.hostCatalog.authorized_actions =
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
TYPE_HOST_CATALOG_STATIC,
|
||||
TYPE_HOST_CATALOG_PLUGIN_AWS,
|
||||
TYPE_HOST_CATALOG_PLUGIN_AZURE,
|
||||
TYPE_HOST_CATALOG_PLUGIN_GCP,
|
||||
} from 'api/models/host-catalog';
|
||||
import * as commonSelectors from 'admin/tests/helpers/selectors';
|
||||
|
||||
@@ -29,6 +30,7 @@ module('Acceptance | host-catalogs | list', function (hooks) {
|
||||
project: null,
|
||||
},
|
||||
staticHostCatalog: null,
|
||||
gcpHostCatalog: null,
|
||||
};
|
||||
|
||||
const urls = {
|
||||
@@ -39,6 +41,7 @@ module('Acceptance | host-catalogs | list', function (hooks) {
|
||||
awsHostCatalog: null,
|
||||
azureHostCatalog: null,
|
||||
staticHostCatalog: null,
|
||||
gcpHostCatalog: null,
|
||||
};
|
||||
|
||||
const SEARCH_INPUT_SELECTOR = '.search-filtering [type="search"]';
|
||||
@@ -68,6 +71,12 @@ module('Acceptance | host-catalogs | list', function (hooks) {
|
||||
type: TYPE_HOST_CATALOG_DYNAMIC,
|
||||
plugin: { name: TYPE_HOST_CATALOG_PLUGIN_AZURE },
|
||||
});
|
||||
instances.gcpHostCatalog = this.server.create('host-catalog', {
|
||||
scope: instances.scopes.project,
|
||||
type: TYPE_HOST_CATALOG_DYNAMIC,
|
||||
plugin: { name: TYPE_HOST_CATALOG_PLUGIN_GCP },
|
||||
});
|
||||
|
||||
urls.globalScope = `/scopes/global/scopes`;
|
||||
urls.orgScope = `/scopes/${instances.scopes.org.id}/scopes`;
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
@@ -75,6 +84,7 @@ module('Acceptance | host-catalogs | list', function (hooks) {
|
||||
urls.staticHostCatalog = `${urls.hostCatalogs}/${instances.staticHostCatalog.id}`;
|
||||
urls.awsHostCatalog = `${urls.hostCatalogs}/${instances.awsHostCatalog.id}`;
|
||||
urls.azureHostCatalog = `${urls.hostCatalogs}/${instances.azureHostCatalog.id}`;
|
||||
urls.gcpHostCatalog = `${urls.hostCatalogs}/${instances.gcpHostCatalog.id}`;
|
||||
|
||||
await authenticateSession({});
|
||||
});
|
||||
@@ -215,6 +225,21 @@ module('Acceptance | host-catalogs | list', function (hooks) {
|
||||
assert.dom(`[href="${urls.azureHostCatalog}"]`).exists();
|
||||
});
|
||||
|
||||
test('user can search for gcp host catalog', async function (assert) {
|
||||
await visit(urls.projectScope);
|
||||
|
||||
await click(`[href="${urls.hostCatalogs}"]`);
|
||||
assert.dom(`[href="${urls.staticHostCatalog}"]`).isVisible();
|
||||
assert.dom(`[href="${urls.awsHostCatalog}"]`).isVisible();
|
||||
assert.dom(`[href="${urls.azureHostCatalog}"]`).isVisible();
|
||||
assert.dom(`[href="${urls.gcpHostCatalog}"]`).isVisible();
|
||||
|
||||
await fillIn(SEARCH_INPUT_SELECTOR, TYPE_HOST_CATALOG_PLUGIN_GCP);
|
||||
await waitFor(`[href="${urls.staticHostCatalog}"]`, { count: 0 });
|
||||
|
||||
assert.dom(`[href="${urls.gcpHostCatalog}"]`).isVisible();
|
||||
});
|
||||
|
||||
test('user can search for host catalogs and get no results', async function (assert) {
|
||||
await visit(urls.projectScope);
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import * as commonSelectors from 'admin/tests/helpers/selectors';
|
||||
import {
|
||||
TYPE_HOST_CATALOG_DYNAMIC,
|
||||
TYPE_HOST_CATALOG_PLUGIN_AWS,
|
||||
TYPE_HOST_CATALOG_PLUGIN_GCP,
|
||||
} from 'api/models/host-catalog';
|
||||
|
||||
module('Acceptance | host-catalogs | update', function (hooks) {
|
||||
@@ -28,6 +29,7 @@ module('Acceptance | host-catalogs | update', function (hooks) {
|
||||
project: null,
|
||||
},
|
||||
hostCatalog: null,
|
||||
GCPHostCatalog: null,
|
||||
};
|
||||
const urls = {
|
||||
globalScope: null,
|
||||
@@ -36,10 +38,11 @@ module('Acceptance | host-catalogs | update', function (hooks) {
|
||||
hostCatalogs: null,
|
||||
hostCatalog: null,
|
||||
AWSHostCatalogWithStaticCredential: null,
|
||||
GCPHostCatalog: null,
|
||||
};
|
||||
|
||||
const NAME_INPUT_SELECTOR = '[name="name"]';
|
||||
const EDIT_BUTTON_SELECTOR = 'form [type="button"]';
|
||||
const EDIT_BUTTON_SELECTOR = '.rose-form-actions [type=button]';
|
||||
const SAVE_BUTTON_SELECTOR = '.rose-form-actions [type="submit"]';
|
||||
const CANCEL_BUTTON_SELECTOR = '.rose-form-actions [type="button"]';
|
||||
const CREDENTIAL_TYPE_SELECTOR =
|
||||
@@ -59,6 +62,12 @@ module('Acceptance | host-catalogs | update', function (hooks) {
|
||||
instances.hostCatalog = this.server.create('host-catalog', {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
instances.GCPHostCatalog = this.server.create('host-catalog', {
|
||||
scope: instances.scopes.project,
|
||||
type: TYPE_HOST_CATALOG_DYNAMIC,
|
||||
plugin: { name: TYPE_HOST_CATALOG_PLUGIN_GCP },
|
||||
});
|
||||
|
||||
instances.AWSHostCatalogWithStaticCredential = this.server.create(
|
||||
'host-catalog',
|
||||
{
|
||||
@@ -75,6 +84,7 @@ module('Acceptance | host-catalogs | update', function (hooks) {
|
||||
urls.hostCatalogs = `${urls.projectScope}/host-catalogs`;
|
||||
urls.hostCatalog = `${urls.hostCatalogs}/${instances.hostCatalog.id}`;
|
||||
urls.AWSHostCatalogWithStaticCredential = `${urls.hostCatalogs}/${instances.AWSHostCatalogWithStaticCredential.id}`;
|
||||
urls.GCPHostCatalog = `${urls.hostCatalogs}/${instances.GCPHostCatalog.id}`;
|
||||
await authenticateSession({});
|
||||
});
|
||||
|
||||
@@ -97,6 +107,19 @@ module('Acceptance | host-catalogs | update', function (hooks) {
|
||||
);
|
||||
});
|
||||
|
||||
test('can update GCP host catalog', async function (assert) {
|
||||
await visit(urls.GCPHostCatalog);
|
||||
await click(EDIT_BUTTON_SELECTOR, 'Activate edit mode');
|
||||
await fillIn('[name=project_id]', 'project-id');
|
||||
await click(SAVE_BUTTON_SELECTOR);
|
||||
|
||||
assert.strictEqual(
|
||||
this.server.schema.hostCatalogs.where({ type: 'plugin' }).models[0]
|
||||
.attributes.project_id,
|
||||
'project-id',
|
||||
);
|
||||
});
|
||||
|
||||
test('can save changes to existing host catalog', async function (assert) {
|
||||
assert.notEqual(instances.hostCatalog.name, 'random string');
|
||||
await visit(urls.hostCatalog);
|
||||
|
||||
Reference in new issue
Block a user