Commit 6446b6aa authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch 'pb-fix-token-access-project-fetch' into 'master'

Fix project fetch bug on token access

See merge request gitlab-org/gitlab!65353
parents 3954ded4 42e7f3c0
...@@ -101,6 +101,10 @@ export default { ...@@ -101,6 +101,10 @@ export default {
} }
} catch (error) { } catch (error) {
createFlash({ message: error }); createFlash({ message: error });
} finally {
if (this.jobTokenScopeEnabled) {
this.getProjects();
}
} }
}, },
async addProject() { async addProject() {
......
...@@ -108,7 +108,7 @@ describe('TokenAccess component', () => { ...@@ -108,7 +108,7 @@ describe('TokenAccess component', () => {
expect(findTokenSection().exists()).toBe(false); expect(findTokenSection().exists()).toBe(false);
}); });
it('switching the toggle calls the mutation', async () => { it('switching the toggle calls the mutation and fetches the projects again', async () => {
createComponent([ createComponent([
[getCIJobTokenScopeQuery, disabledJobTokenScopeHandler], [getCIJobTokenScopeQuery, disabledJobTokenScopeHandler],
[updateCIJobTokenScopeMutation, updateJobTokenScopeHandler], [updateCIJobTokenScopeMutation, updateJobTokenScopeHandler],
...@@ -117,11 +117,16 @@ describe('TokenAccess component', () => { ...@@ -117,11 +117,16 @@ describe('TokenAccess component', () => {
await waitForPromises(); await waitForPromises();
expect(getProjectsWithScope).toHaveBeenCalledTimes(1);
findToggle().vm.$emit('change', true); findToggle().vm.$emit('change', true);
await waitForPromises();
expect(updateJobTokenScopeHandler).toHaveBeenCalledWith({ expect(updateJobTokenScopeHandler).toHaveBeenCalledWith({
input: { fullPath: projectPath, jobTokenScopeEnabled: true }, input: { fullPath: projectPath, jobTokenScopeEnabled: true },
}); });
expect(getProjectsWithScope).toHaveBeenCalledTimes(2);
}); });
}); });
......
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