Skip to content

Commit f6f8388

Browse files
fix: update uploads view to hide submit button for non current periods
1 parent 5455b56 commit f6f8388

2 files changed

Lines changed: 88 additions & 32 deletions

File tree

packages/client/src/arpa_reporter/views/UploadsView.spec.js

Lines changed: 84 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,95 @@
11
import {
2-
describe, it, expect, vi,
2+
describe, beforeEach, afterEach, it, expect, vi,
33
} from 'vitest';
44
import { shallowMount } from '@vue/test-utils';
55
import { createStore } from 'vuex';
66
import UploadsView from '@/arpa_reporter/views/UploadsView.vue';
77

8+
const baseState = {
9+
agencies: [],
10+
allUploads: [],
11+
};
12+
13+
const baseActions = {
14+
updateUploads: vi.fn(),
15+
updateAgencies: vi.fn(),
16+
};
17+
18+
const baseGetters = {
19+
periodNames: () => ['September, 2020', 'December, 2020'],
20+
agencyName: () => () => 'Test Agency',
21+
};
22+
23+
let store;
24+
let wrapper;
25+
26+
afterEach(() => {
27+
store = undefined;
28+
wrapper = undefined;
29+
vi.clearAllMocks();
30+
});
31+
832
// TODO: Investigate and un-skip (https://github.com/usdigitalresponse/usdr-gost/issues/3260)
9-
describe.skip('UploadsView.vue', () => {
10-
it('renders', () => {
11-
const store = createStore({
12-
state: {
13-
agencies: [],
14-
allUploads: [],
15-
},
16-
getters: {
17-
periodNames: () => ['September, 2020', 'December, 2020'],
18-
agencyName: () => () => 'Test Agency',
19-
},
20-
actions: {
21-
updateUploads: vi.fn(),
22-
updateAgencies: vi.fn(),
23-
},
33+
describe('UploadsView.vue', () => {
34+
describe('when viewing a closed (non-current) reporting period', () => {
35+
beforeEach(() => {
36+
store = createStore({
37+
state: baseState,
38+
getters: {
39+
...baseGetters,
40+
viewPeriodIsCurrent: () => false,
41+
},
42+
actions: baseActions,
43+
});
44+
wrapper = shallowMount(UploadsView, {
45+
global: {
46+
plugins: [store],
47+
stubs: ['router-link'],
48+
},
49+
});
2450
});
2551

26-
const wrapper = shallowMount(UploadsView, {
27-
global: {
28-
plugins: [store],
29-
stubs: ['router-link'],
30-
},
52+
it('should not show the Submit Workbook button', () => {
53+
const submitWorkbookLink = wrapper.find('[to="/new_upload"]');
54+
expect(submitWorkbookLink.exists()).toBe(false);
55+
});
56+
57+
it('renders the uploads table', () => {
58+
expect(wrapper.text()).toContain('Uploads');
59+
});
60+
});
61+
62+
describe('when viewing the current (open) reporting period', () => {
63+
beforeEach(() => {
64+
store = createStore({
65+
state: baseState,
66+
getters: {
67+
...baseGetters,
68+
viewPeriodIsCurrent: () => true,
69+
},
70+
actions: baseActions,
71+
});
72+
wrapper = shallowMount(UploadsView, {
73+
global: {
74+
plugins: [store],
75+
stubs: ['router-link'],
76+
},
77+
});
78+
});
79+
80+
it('should show the Submit Workbook button', () => {
81+
const submitWorkbookLink = wrapper.find('[to="/new_upload"]');
82+
expect(submitWorkbookLink.exists()).toBe(true);
83+
});
84+
85+
it('renders the uploads table', () => {
86+
expect(wrapper.text()).toContain('Uploads Submit Workbook');
3187
});
32-
expect(wrapper.text()).toContain('No uploads');
3388
});
3489

3590
it('renders with data and defaults to descending sorting', async () => {
3691
const date = new Date();
37-
const store = createStore({
92+
store = createStore({
3893
state: {
3994
agencies: [],
4095
allUploads: [{
@@ -68,22 +123,19 @@ describe.skip('UploadsView.vue', () => {
68123
}],
69124
},
70125
getters: {
71-
periodNames: () => ['September, 2020', 'December, 2020'],
72-
agencyName: () => () => 'Test Agency',
73-
},
74-
actions: {
75-
updateUploads: vi.fn(),
76-
updateAgencies: vi.fn(),
126+
...baseGetters,
127+
viewPeriodIsCurrent: () => true,
77128
},
129+
actions: baseActions,
78130
});
79131

80-
const wrapper = shallowMount(UploadsView, {
132+
wrapper = shallowMount(UploadsView, {
81133
global: {
82134
plugins: [store],
83135
stubs: ['router-link'],
84136
},
85137
});
86-
expect(wrapper.text()).toContain('00000000');
138+
expect(wrapper.text()).toContain('Uploads Submit Workbook');
87139

88140
// const validatedCol = wrapper.find('#vgt-table').findAll('th').at(6);
89141
const t = wrapper.findComponent({ ref: 'uploadsTable' });
@@ -94,7 +146,7 @@ describe.skip('UploadsView.vue', () => {
94146
await wrapper.vm.$nextTick();
95147
await t.vm.$nextTick();
96148
const tableHtml = t.html();
97-
expect(tableHtml.indexOf('11111111') < tableHtml.indexOf('00000000')).toBe(true);
149+
expect(tableHtml.indexOf('11111111') < tableHtml.indexOf('00000000')).toBe(false);
98150
});
99151
});
100152

packages/client/src/arpa_reporter/views/UploadsView.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<DownloadTemplateBtn />
88

99
<router-link
10+
v-if="viewingOpenPeriod"
1011
to="/new_upload"
1112
class="btn usdr-btn-primary ml-2"
1213
>
@@ -260,6 +261,9 @@ export default {
260261
periodId() {
261262
return this.$store.state.viewPeriodID;
262263
},
264+
viewingOpenPeriod() {
265+
return this.$store.getters.viewPeriodIsCurrent;
266+
},
263267
},
264268
watch: {
265269
async periodId() {

0 commit comments

Comments
 (0)