Use the same prefix pattern from the region switcher for the namespace switcher

This commit is contained in:
Michael Lange 2021-01-22 12:37:48 -08:00
parent 45a45ebb3f
commit 875de74503
3 changed files with 8 additions and 9 deletions

View file

@ -37,11 +37,7 @@
@tagName="div"
@class="namespace-switcher"
as |namespace|>
{{#if (eq namespace.name "default")}}
Default Namespace
{{else}}
{{namespace.name}}
{{/if}}
<span class="ember-power-select-prefix">Namespace: </span>{{namespace.name}}
</PowerSelect>
</div>
</li>

View file

@ -130,12 +130,11 @@ module('Acceptance | job detail (with namespaces)', function(hooks) {
test('when switching namespaces, the app redirects to /jobs with the new namespace', async function(assert) {
const namespace = server.db.namespaces.find(job.namespaceId);
const otherNamespace = server.db.namespaces.toArray().find(ns => ns !== namespace).name;
const label = otherNamespace === 'default' ? 'Default Namespace' : otherNamespace;
await JobDetail.visit({ id: job.id, namespace: namespace.name });
// TODO: Migrate to Page Objects
await selectChoose('[data-test-namespace-switcher]', label);
await selectChoose('[data-test-namespace-switcher]', otherNamespace);
assert.equal(currentURL().split('?')[0], '/jobs', 'Navigated to /jobs');
const jobs = server.db.jobs

View file

@ -69,7 +69,7 @@ module('Acceptance | namespaces (enabled)', function(hooks) {
);
assert.equal(
JobsList.namespaceSwitcher.options.objectAt(0).label,
'Default Namespace',
'Namespace: default',
'The first namespace is always the default one'
);
@ -79,7 +79,11 @@ module('Acceptance | namespaces (enabled)', function(hooks) {
if (index === 0) return;
const namespace = sortedNamespaces[index - 1];
assert.equal(option.label, namespace.name, `index ${index}: ${namespace.name}`);
assert.equal(
option.label,
`Namespace: ${namespace.name}`,
`index ${index}: ${namespace.name}`
);
});
});