Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ describe('PermissionNodesCard', () => {
await mountCard({ subjectKind: 'principal', name: 'ghost' })

expect(wrapper.find('[data-test="nodes-missing"]').text()).toContain('ghost')
expect(wrapper.find('[data-test="nodes-missing"]').attributes('role'), 'the missing notice is an alert').toBe('alert')
expect(wrapper.find('[data-test="nodes-missing"]').classes(), 'the notice is drawn on the error container').toContain('bg-error-container')
})

it('reads the nodes of the new subject when the name changes', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import { computed, onMounted, useId, watch, type PropType } from 'vue'
import { createErrorToast, createSuccessToast } from '../../helpers/toast'
import { useSession } from '../../store/session'
import MdAlert from '../md/MdAlert.vue'
import MdButton from '../md/MdButton.vue'
import MdCard from '../md/MdCard.vue'
import MdSection from '../md/MdSection.vue'
Expand Down Expand Up @@ -147,14 +148,13 @@ const overwrite = async () => settle(await nodes.overwriteConflict())
</MdButton>
</template>
</MdStatePanel>
<p
<MdAlert
v-else-if="missing"
role="alert"
class="md-body-medium text-on-surface-variant"
tone="error"
data-test="nodes-missing"
>
{{ name }} does not exist (any more).
</p>
</MdAlert>
<NodeEditor
v-else
:nodes="draft"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import NodeTemplateMenu from './NodeTemplateMenu.vue'

const TEMPLATES = [
{ id: 'reader', label: 'Reader', nodes: ['ingot.repository.{repository}.read'] },
{ id: 'admin', label: 'Instance admin', nodes: ['ingot.instance.admin'] }
{ id: 'admin', label: 'Instance admin', nodes: ['ingot.instance.admin'] },
{ id: 'broken', label: 'Broken', nodes: ['ingot.repository.{repository}.bogus.extra.parts'] }
]
const CATALOG = [
{ node: 'ingot.repository.releases', kind: 'REPOSITORY' },
Expand All @@ -49,6 +50,19 @@ describe('NodeTemplateMenu', () => {
const repository = () => wrapper!.find('input[role="combobox"]')
const listbox = () => wrapper!.find('[role="listbox"]')

it('draws the problem of a filled node through the shared error alert', async () => {
mountMenu()
await toggle().trigger('click')
await wrapper!.findAll('[data-test="template-option"]')[2].trigger('click')
await repository().setValue('releases')

const problem = wrapper!.find('[data-test="template-problem"]')

expect(problem.exists(), 'the refused node is reported').toBe(true)
expect(problem.classes(), 'the problem is drawn on the error container').toContain('bg-error-container')
expect(problem.attributes('role'), 'the problem is announced at once').toBe('alert')
})

it('announces the open panel on the toggle button', async () => {
mountMenu()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

<script setup lang="ts">
import { computed, ref, useId, type PropType } from 'vue'
import MdAlert from '../../md/MdAlert.vue'
import MdButton from '../../md/MdButton.vue'
import MdListbox from '../../md/MdListbox.vue'
import MdTextField from '../../md/MdTextField.vue'
Expand Down Expand Up @@ -291,14 +292,13 @@ const submit = () => {
>
Adds {{ preview }}
</p>
<p
<MdAlert
v-if="nodeError"
role="alert"
class="md-body-small text-error"
tone="error"
data-test="template-problem"
>
{{ nodeError }}
</p>
</MdAlert>
<div class="flex justify-end gap-2">
<MdButton
variant="text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,9 @@ describe('RepositoryAccessCard', () => {
holder.session!.client.value.identity.repositoryAccess = vi.fn(() => new Promise(() => {}))
wrapper = await mountCard()

expect(wrapper.get('[data-test="loading"]').text()).toContain('Loading')
expect(wrapper.get('[data-test="loading"]').attributes('aria-busy'), 'the loading state is drawn as a busy state panel').toBe('true')
expect(wrapper.get('[data-test="loading"]').text(), 'the loading panel names what loads').toContain('Loading who has access')
expect(wrapper.get('[data-test="loading"]').attributes('data-ingot-state'), 'the stable anchor keeps its loading state while the panel draws the skeleton').toBe('loading')
})

it('shows the error with a retry that asks again', async () => {
Expand All @@ -375,6 +377,7 @@ describe('RepositoryAccessCard', () => {
wrapper = await mountCard()

expect(wrapper.get('[role="alert"]').text()).toContain('Server error')
expect(wrapper.get('[role="alert"]').text(), 'the error panel names what failed').toContain('Could not load who has access')

await wrapper.get('[data-test="retry"]').trigger('click')
await flushPromises()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { useSession } from '../../store/session'
import MdButton from '../md/MdButton.vue'
import MdCard from '../md/MdCard.vue'
import MdDataTable from '../md/MdDataTable.vue'
import MdStatePanel from '../md/MdStatePanel.vue'
import MdTextField from '../md/MdTextField.vue'
import TokenTag from '../tokens/TokenTag.vue'
import { ROLES, pathPrefixLabel } from '../access/accessTeams'
Expand Down Expand Up @@ -236,30 +237,30 @@ const rows = computed(() => {
</TokenTag>
</div>

<p
<MdStatePanel
v-if="status === 'loading'"
state="loading"
data-ingot-state="loading"
title="Loading who has access"
data-test="loading"
role="status"
class="md-body-medium text-on-surface-variant"
>
Loading...
</p>
<div
/>
<MdStatePanel
v-else-if="status === 'error'"
role="alert"
class="flex flex-wrap items-center gap-3"
state="error"
title="Could not load who has access"
:description="failure"
>
<span class="md-body-medium text-error">Could not load who has access: {{ failure }}</span>
<MdButton
data-test="retry"
variant="tonal"
type="button"
@click="load"
>
Retry
</MdButton>
</div>
<template #actions>
<MdButton
data-test="retry"
variant="tonal"
type="button"
@click="load"
>
Retry
</MdButton>
</template>
</MdStatePanel>
<p
v-else-if="entries.length === 0"
data-test="empty"
Expand Down
Loading