Commit 6839f2bc authored by pburdette's avatar pburdette

Update unit and feature spec

Update the specs and also apply
some styling to the table to match
previous implementation.
parent ba0dac75
...@@ -2,19 +2,25 @@ ...@@ -2,19 +2,25 @@
import { GlButton, GlTable } from '@gitlab/ui'; import { GlButton, GlTable } from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
const DEFAULT_TD_CLASSES = 'gl-w-half gl-font-sm! gl-border-gray-200!';
const DEFAULT_TH_CLASSES =
'gl-bg-transparent! gl-border-b-solid! gl-border-b-gray-200! gl-border-b-1!';
export default { export default {
fields: [ fields: [
{ {
key: 'key', key: 'key',
label: __('Key'), label: __('Key'),
tdAttr: { 'data-testid': 'trigger-build-key' }, tdAttr: { 'data-testid': 'trigger-build-key' },
tdClass: 'gl-w-half gl-font-sm!', tdClass: DEFAULT_TD_CLASSES,
thClass: DEFAULT_TH_CLASSES,
}, },
{ {
key: 'value', key: 'value',
label: __('Value'), label: __('Value'),
tdAttr: { 'data-testid': 'trigger-build-value' }, tdAttr: { 'data-testid': 'trigger-build-value' },
tdClass: 'gl-w-half gl-font-sm!', tdClass: DEFAULT_TD_CLASSES,
thClass: DEFAULT_TH_CLASSES,
}, },
], ],
components: { components: {
...@@ -68,12 +74,17 @@ export default { ...@@ -68,12 +74,17 @@ export default {
<p class="gl-display-flex gl-justify-content-space-between gl-align-items-center"> <p class="gl-display-flex gl-justify-content-space-between gl-align-items-center">
<span class="gl-font-weight-bold">{{ __('Trigger variables:') }}</span> <span class="gl-font-weight-bold">{{ __('Trigger variables:') }}</span>
<gl-button v-if="hasValues" class="gl-mt-2" size="small" @click="toggleValues">{{ <gl-button
getToggleButtonText v-if="hasValues"
}}</gl-button> class="gl-mt-2"
size="small"
data-testid="trigger-reveal-values-button"
@click="toggleValues"
>{{ getToggleButtonText }}</gl-button
>
</p> </p>
<gl-table :items="trigger.variables" :fields="$options.fields" small> <gl-table :items="trigger.variables" :fields="$options.fields" small bordered>
<template #cell(value)="data"> <template #cell(value)="data">
{{ getDisplayValue(data.value) }} {{ getDisplayValue(data.value) }}
</template> </template>
......
...@@ -533,10 +533,10 @@ RSpec.describe 'Jobs', :clean_gitlab_redis_shared_state do ...@@ -533,10 +533,10 @@ RSpec.describe 'Jobs', :clean_gitlab_redis_shared_state do
expect(page).to have_content('Trigger token') expect(page).to have_content('Trigger token')
expect(page).to have_content('Trigger variables') expect(page).to have_content('Trigger variables')
expect(page).not_to have_css('.js-reveal-variables') expect(page).not_to have_selector('[data-testid="trigger-reveal-values-button"]')
expect(page).to have_selector('.js-build-variable', text: 'TRIGGER_KEY_1') expect(page).to have_selector('[data-testid="trigger-build-key"]', text: 'TRIGGER_KEY_1')
expect(page).to have_selector('.js-build-value', text: '••••••') expect(page).to have_selector('[data-testid="trigger-build-value"]', text: '••••••')
end end
end end
...@@ -571,17 +571,17 @@ RSpec.describe 'Jobs', :clean_gitlab_redis_shared_state do ...@@ -571,17 +571,17 @@ RSpec.describe 'Jobs', :clean_gitlab_redis_shared_state do
expect(page).to have_content('Trigger token') expect(page).to have_content('Trigger token')
expect(page).to have_content('Trigger variables') expect(page).to have_content('Trigger variables')
expect(page).to have_css('.js-reveal-variables') expect(page).to have_selector('[data-testid="trigger-reveal-values-button"]')
expect(page).to have_selector('.js-build-variable', text: 'TRIGGER_KEY_1') expect(page).to have_selector('[data-testid="trigger-build-key"]', text: 'TRIGGER_KEY_1')
expect(page).to have_selector('.js-build-value', text: '••••••') expect(page).to have_selector('[data-testid="trigger-build-value"]', text: '••••••')
end end
it 'reveals values on button click', :js do it 'reveals values on button click', :js do
click_button 'Reveal values' click_button 'Reveal values'
expect(page).to have_selector('.js-build-variable', text: 'TRIGGER_KEY_1') expect(page).to have_selector('[data-testid="trigger-build-key"]', text: 'TRIGGER_KEY_1')
expect(page).to have_selector('.js-build-value', text: 'TRIGGER_VALUE_1') expect(page).to have_selector('[data-testid="trigger-build-value"]', text: 'TRIGGER_VALUE_1')
end end
end end
......
...@@ -25,7 +25,7 @@ describe('Trigger block', () => { ...@@ -25,7 +25,7 @@ describe('Trigger block', () => {
wrapper = null; wrapper = null;
}); });
describe('with short token', () => { describe('with short token and no variables', () => {
it('renders short token', () => { it('renders short token', () => {
createComponent({ createComponent({
trigger: { trigger: {
...@@ -42,6 +42,7 @@ describe('Trigger block', () => { ...@@ -42,6 +42,7 @@ describe('Trigger block', () => {
beforeEach(() => { beforeEach(() => {
createComponent({ trigger: { variables: [] } }); createComponent({ trigger: { variables: [] } });
}); });
it('does not render short token', () => { it('does not render short token', () => {
expect(findShortToken().exists()).toBe(false); expect(findShortToken().exists()).toBe(false);
}); });
...@@ -55,30 +56,30 @@ describe('Trigger block', () => { ...@@ -55,30 +56,30 @@ describe('Trigger block', () => {
describe('with variables', () => { describe('with variables', () => {
describe('hide/reveal variables', () => { describe('hide/reveal variables', () => {
it('should toggle variables on click', async () => { it('should toggle variables on click', async () => {
const hiddenValue = '••••••';
const gcsVar = { key: 'UPLOAD_TO_GCS', value: 'false', public: false };
const s3Var = { key: 'UPLOAD_TO_S3', value: 'true', public: false };
createComponent({ createComponent({
trigger: { trigger: {
short_token: 'bd7e', variables: [gcsVar, s3Var],
variables: [
{ key: 'UPLOAD_TO_GCS', value: 'false', public: false },
{ key: 'UPLOAD_TO_S3', value: 'true', public: false },
],
}, },
}); });
expect(findRevealButton().text()).toBe('Reveal values'); expect(findRevealButton().text()).toBe('Reveal values');
expect(findVariableValue(0).text()).toBe('••••••'); expect(findVariableValue(0).text()).toBe(hiddenValue);
expect(findVariableValue(1).text()).toBe('••••••'); expect(findVariableValue(1).text()).toBe(hiddenValue);
expect(findVariableKey(0).text()).toBe('UPLOAD_TO_GCS'); expect(findVariableKey(0).text()).toBe(gcsVar.key);
expect(findVariableKey(1).text()).toBe('UPLOAD_TO_S3'); expect(findVariableKey(1).text()).toBe(s3Var.key);
await findRevealButton().trigger('click'); await findRevealButton().trigger('click');
expect(findRevealButton().text()).toBe('Hide values'); expect(findRevealButton().text()).toBe('Hide values');
expect(findVariableValue(0).text()).toBe('false'); expect(findVariableValue(0).text()).toBe(gcsVar.value);
expect(findVariableValue(1).text()).toBe('true'); expect(findVariableValue(1).text()).toBe(s3Var.value);
}); });
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment