mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 02:15:43 +03:00
Test coverage for the plugins list page
This commit is contained in:
99
ui/tests/acceptance/plugins-list-test.js
Normal file
99
ui/tests/acceptance/plugins-list-test.js
Normal file
@@ -0,0 +1,99 @@
|
||||
import { currentURL } from '@ember/test-helpers';
|
||||
import { module, test } from 'qunit';
|
||||
import { setupApplicationTest } from 'ember-qunit';
|
||||
import { setupMirage } from 'ember-cli-mirage/test-support';
|
||||
import pageSizeSelect from './behaviors/page-size-select';
|
||||
import PluginsList from 'nomad-ui/tests/pages/storage/plugins/list';
|
||||
|
||||
module('Acceptance | plugins list', function(hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
hooks.beforeEach(function() {
|
||||
server.create('node');
|
||||
window.localStorage.clear();
|
||||
});
|
||||
|
||||
test('visiting /csi/plugins', async function(assert) {
|
||||
await PluginsList.visit();
|
||||
|
||||
assert.equal(currentURL(), '/csi/plugins');
|
||||
assert.equal(document.title, 'CSI Plugins - Nomad');
|
||||
});
|
||||
|
||||
test('/csi/plugins should list the first page of plugins sorted by id', async function(assert) {
|
||||
const pluginCount = PluginsList.pageSize + 1;
|
||||
server.createList('csi-plugin', pluginCount);
|
||||
|
||||
await PluginsList.visit();
|
||||
|
||||
const sortedPlugins = server.db.csiPlugins.sortBy('id');
|
||||
assert.equal(PluginsList.plugins.length, PluginsList.pageSize);
|
||||
PluginsList.plugins.forEach((plugin, index) => {
|
||||
assert.equal(plugin.id, sortedPlugins[index].id, 'Plugins are ordered');
|
||||
});
|
||||
});
|
||||
|
||||
test('each plugin row should contain information about the plugin', async function(assert) {
|
||||
const plugin = server.create('csi-plugin');
|
||||
|
||||
await PluginsList.visit();
|
||||
|
||||
const pluginRow = PluginsList.plugins.objectAt(0);
|
||||
const controllerHealthStr = plugin.controllersHealthy > 0 ? 'Healthy' : 'Unhealthy';
|
||||
const nodeHealthStr = plugin.nodesHealthy > 0 ? 'Healthy' : 'Unhealthy';
|
||||
|
||||
assert.equal(pluginRow.id, plugin.id);
|
||||
assert.equal(
|
||||
pluginRow.controllerHealth,
|
||||
`${controllerHealthStr} (${plugin.controllersHealthy}/${plugin.controllersExpected})`
|
||||
);
|
||||
assert.equal(
|
||||
pluginRow.nodeHealth,
|
||||
`${nodeHealthStr} (${plugin.nodesHealthy}/${plugin.nodesExpected})`
|
||||
);
|
||||
assert.equal(pluginRow.provider, plugin.provider);
|
||||
});
|
||||
|
||||
test('each plugin row should link to the corresponding plugin', async function(assert) {
|
||||
const plugin = server.create('csi-plugin');
|
||||
|
||||
await PluginsList.visit();
|
||||
|
||||
await PluginsList.plugins.objectAt(0).clickName();
|
||||
assert.equal(currentURL(), `/csi/plugins/${plugin.id}`);
|
||||
|
||||
await PluginsList.visit();
|
||||
assert.equal(currentURL(), '/csi/plugins');
|
||||
|
||||
await PluginsList.plugins.objectAt(0).clickRow();
|
||||
assert.equal(currentURL(), `/csi/plugins/${plugin.id}`);
|
||||
});
|
||||
|
||||
test('when there are no plugins, there is an empty message', async function(assert) {
|
||||
await PluginsList.visit();
|
||||
|
||||
assert.ok(PluginsList.isEmpty);
|
||||
assert.equal(PluginsList.emptyState.headline, 'No Plugins');
|
||||
});
|
||||
|
||||
test('when accessing plugins is forbidden, a message is shown with a link to the tokens page', async function(assert) {
|
||||
server.pretender.get('/v1/plugins', () => [403, {}, null]);
|
||||
|
||||
await PluginsList.visit();
|
||||
assert.equal(PluginsList.error.title, 'Not Authorized');
|
||||
|
||||
await PluginsList.error.seekHelp();
|
||||
assert.equal(currentURL(), '/settings/tokens');
|
||||
});
|
||||
|
||||
pageSizeSelect({
|
||||
resourceName: 'plugin',
|
||||
pageObject: PluginsList,
|
||||
pageObjectList: PluginsList.plugins,
|
||||
async setup() {
|
||||
server.createList('csi-plugin', PluginsList.pageSize);
|
||||
await PluginsList.visit();
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -13,6 +13,9 @@ export default create({
|
||||
controllerHealth: text('[data-test-plugin-controller-health]'),
|
||||
nodeHealth: text('[data-test-plugin-node-health]'),
|
||||
provider: text('[data-test-plugin-provider]'),
|
||||
|
||||
clickRow: clickable(),
|
||||
clickName: clickable('[data-test-plugin-id] a'),
|
||||
}),
|
||||
|
||||
nextPage: clickable('[data-test-pager="next"]'),
|
||||
|
||||
Reference in New Issue
Block a user