Skip to content
Open
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
12 changes: 12 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ jobs:
- name: Removing authenticator prefix for simple auth
run: |
sed -i 's/mechanism = simple/!mechanism = simple/' /home/runner/install/authn.simple/run.properties
- name: Adding Amy14 user
run: |
sed -i '/user\.list/ s/$/ Amy14/' /home/runner/install/authn.simple/run.properties
- name: Adding Amy14 user password
run: |
echo "user.Amy14.password = pw" >> /home/runner/install/authn.simple/run.properties
- name: Adding Chris481 user
run: |
sed -i '/user\.list/ s/$/ Chris481/' /home/runner/install/authn.simple/run.properties
Expand Down Expand Up @@ -295,6 +301,12 @@ jobs:
- name: Removing authenticator prefix for simple auth
run: |
sed -i 's/mechanism = simple/!mechanism = simple/' /home/runner/install/authn.simple/run.properties
- name: Adding Amy14 user
run: |
sed -i '/user\.list/ s/$/ Amy14/' /home/runner/install/authn.simple/run.properties
- name: Adding Amy14 user password
run: |
echo "user.Amy14.password = pw" >> /home/runner/install/authn.simple/run.properties
- name: Adding Chris481 user
run: |
sed -i '/user\.list/ s/$/ Chris481/' /home/runner/install/authn.simple/run.properties
Expand Down
1 change: 1 addition & 0 deletions packages/datagateway-common/src/api/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const parseSearchToQuery = (queryParams: string): QueryParams => {
if (typeof parsed.view === 'string') {
parsedDOIType = { view: parsed.view };
if (typeof parsed.open === 'boolean') parsedDOIType.open = parsed.open;
if (typeof parsed.pi === 'boolean') parsedDOIType.pi = parsed.pi;
}
} catch (_e) {
console.error('doiType query param provided in an incorrect format.');
Expand Down
4 changes: 2 additions & 2 deletions packages/datagateway-common/src/app.types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ export interface SortType {

export type ViewsType = 'table' | 'card' | null;

export type DOIViewType = 'minter' | 'user' | 'session' | 'all';
export type DOIViewType = 'user' | 'session' | 'all';

export interface QueryParams {
sort: SortType;
Expand All @@ -511,7 +511,7 @@ export interface QueryParams {
endDate: Date | null;
currentTab: string;
restrict: boolean;
doiType: { view: DOIViewType; open?: boolean } | null;
doiType: { view: DOIViewType; open?: boolean; pi?: boolean } | null;
}

export enum ContributorType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ describe('DLS - All DOIs Table', () => {
cy.get('[aria-rowcount="1"]').should('exist');
cy.contains('78: Across').should('exist');

cy.contains('User-created DOIs').click();
cy.contains('User-defined DOIs').click();

cy.get('[aria-rowcount="2"]').should('exist');
cy.contains('Test DOI Title 1').should('exist');
Expand Down
64 changes: 50 additions & 14 deletions packages/datagateway-dataview/cypress/e2e/table/dls/myDois.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ describe('DLS - MyDOIs Table', () => {
before(() => {
cy.login({ username: 'root', password: 'pw', mechanism: 'simple' });
cy.seedSessionDataPublication().as('sessionDataPublication');

cy.seedSessionDataPublication({ id: 14 }).as(
'sessionDataPublication14'
);
cy.login(
{
username: 'Chris481',
Expand All @@ -36,6 +38,23 @@ describe('DLS - MyDOIs Table', () => {
cy.seedUserGeneratedDataPublication('Test DOI Title 2').as(
'dataPublication2'
);

cy.login(
{
username: 'Amy14',
password: 'pw',
mechanism: 'simple',
},
'Amy14'
);

// can seed the user defined DP in before rather than beforeEach as myDOI page is read-only
cy.seedUserGeneratedDataPublication(
'Test DOI Title 3',
[{ username: 'Chris481' }],
[14],
[]
).as('dataPublication3');
cy.dumpAliases(store);
});

Expand All @@ -60,17 +79,26 @@ describe('DLS - MyDOIs Table', () => {
cy.login({ username: 'root', password: 'pw', mechanism: 'simple' });
cy.get<UserDefinedMintResponse>('@dataPublication1').then((dp1) => {
cy.get<UserDefinedMintResponse>('@dataPublication2').then((dp2) => {
cy.get<SessionMintResponse>('@sessionDataPublication').then(
(dp3) => {
cy.clearDataPublications([
dp1.body.concept.data_publication_id,
dp1.body.version.data_publication_id,
dp2.body.concept.data_publication_id,
dp2.body.version.data_publication_id,
dp3.body.data_publication_id,
]);
}
);
cy.get<UserDefinedMintResponse>('@dataPublication3').then((dp3) => {
cy.get<SessionMintResponse>('@sessionDataPublication').then(
(dp4) => {
cy.get<SessionMintResponse>('@sessionDataPublication14').then(
(dp5) => {
cy.clearDataPublications([
dp1.body.concept.data_publication_id,
dp1.body.version.data_publication_id,
dp2.body.concept.data_publication_id,
dp2.body.version.data_publication_id,
dp3.body.concept.data_publication_id,
dp3.body.version.data_publication_id,
dp4.body.data_publication_id,
dp5.body.data_publication_id,
]);
}
);
}
);
});
});
});
});
Expand Down Expand Up @@ -99,7 +127,8 @@ describe('DLS - MyDOIs Table', () => {
});

it('should be able to sort by all sort directions on single and multiple columns', () => {
cy.contains('Minted the user-created DOI').click();
cy.contains('Principal Investigator').click();
cy.contains('User-defined DOIs').click();
//Revert the default sort
cy.contains('[role="button"]', 'Publication Date')
.as('dateSortButton')
Expand Down Expand Up @@ -180,6 +209,13 @@ describe('DLS - MyDOIs Table', () => {

cy.get('[aria-rowcount="0"]').should('exist');
});

it('should be able filter the Principal Investigator toggle button to show only sessions which they are not the PI', () => {
cy.contains('Others').click();
cy.get('[aria-rowindex="1"] [aria-colindex="1"]').contains(
'Test DOI Title 3'
);
});
});

describe('Session DOIs', () => {
Expand Down Expand Up @@ -218,7 +254,7 @@ describe('DLS - MyDOIs Table', () => {
cy.title().should('equal', 'DataGateway DataView');
cy.get('#datagateway-dataview').should('be.visible');

cy.contains('Am listed on the session DOI').click();
cy.contains('Session DOIs').click();

//Default sort
cy.get('[aria-sort="descending"]').should('exist');
Expand Down
67 changes: 35 additions & 32 deletions packages/datagateway-dataview/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,42 +123,45 @@ Cypress.Commands.add('isScrolledTo', { prevSubject: true }, (element) => {
});
});

Cypress.Commands.add('seedUserGeneratedDataPublication', (title) => {
return cy.request('datagateway-dataview-settings.json').then((response) => {
const settings = response.body;
return cy
.request({
method: 'POST',
url: `${settings.doiMinterUrl}/draft`,
headers: {
Authorization: `Bearer ${readSciGatewayToken().sessionId}`,
},
body: {
metadata: {
title: title ?? 'Test DOI title',
description: 'Test DOI description',
creators: [],
related_items: [],
subjects: [],
resource_type: 'Collection',
},
// these ids are specifically mintable by the Chris481 user
investigation_ids: [],
dataset_ids: [15],
datafile_ids: [74, 193],
},
})
.then((response) => {
return cy.request({
method: 'PUT',
url: `${settings.doiMinterUrl}/draft/${response.body.concept.data_publication_id}/publish`,
Cypress.Commands.add(
'seedUserGeneratedDataPublication',
(title, creators, dataset_ids, datafile_ids) => {
return cy.request('datagateway-dataview-settings.json').then((response) => {
const settings = response.body;
return cy
.request({
method: 'POST',
url: `${settings.doiMinterUrl}/draft`,
headers: {
Authorization: `Bearer ${readSciGatewayToken().sessionId}`,
},
body: {
metadata: {
title: title ?? 'Test DOI title',
description: 'Test DOI description',
creators: creators ?? [],
related_items: [],
subjects: [],
resource_type: 'Collection',
},
// these ids are specifically mintable by the Chris481 user
investigation_ids: [],
dataset_ids: dataset_ids ?? [15],
datafile_ids: datafile_ids ?? [74, 193],
},
})
.then((response) => {
return cy.request({
method: 'PUT',
url: `${settings.doiMinterUrl}/draft/${response.body.concept.data_publication_id}/publish`,
headers: {
Authorization: `Bearer ${readSciGatewayToken().sessionId}`,
},
});
});
});
});
});
});
}
);

Cypress.Commands.add('clearDataPublications', (ids) => {
return cy.request('datagateway-dataview-settings.json').then((response) => {
Expand Down
5 changes: 4 additions & 1 deletion packages/datagateway-dataview/cypress/support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ declare namespace Cypress {
clearDownloadCart(): Cypress.Chainable<Cypress.Response>;
seedDownloadCart(cartItems: string[]): Cypress.Chainable<Cypress.Response>;
seedUserGeneratedDataPublication(
title?: string
title?: string,
creators?: string[],
dataset_ids?: number[],
datafile_ids?: number[]
): Cypress.Chainable<Cypress.Response>;
clearDataPublications(ids: string[]): Cypress.Chainable<Cypress.Response>;
seedSessionDataPublication(params?: {
Expand Down
15 changes: 9 additions & 6 deletions packages/datagateway-dataview/public/res/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,22 @@
"all_roles": "All"
},
"my_doi_table": {
"type_button_group_aria_label": "Select DOIs where I",
"minter": "Minted the user-created DOI",
"user": "Am listed on the user-created DOI",
"session": "Am listed on the session DOI",
"type_button_group_aria_label": "Select DOI type",
"user": "User-defined DOIs",
"session": "Session DOIs",
"open_button_group_aria_label": "Select Session DOIs which are",
"open_or_closed": "Open or Closed",
"open": "Open",
"closed": "Closed",
"all": "All"
"all": "All",
"pi_button_group_aria_label": "Select DOIs which roles are",
"pi_or_any": "All",
"pi": "Principal Investigator",
"any": "Others"
},
"all_doi_table": {
"type_button_group_aria_label": "Select DOI type",
"user": "User-created DOIs",
"user": "User-defined DOIs",
"session": "Session DOIs",
"open_button_group_aria_label": "Select Session DOIs which are",
"open_or_closed": "Open or Closed",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ describe('DOI Type Selector', () => {
pressed: true,
})
).toBeInTheDocument();
expect(
screen.getByRole('button', {
name: 'my_doi_table.minter',
pressed: false,
})
).toBeInTheDocument();
expect(
screen.getByRole('button', {
name: 'my_doi_table.user',
Expand Down Expand Up @@ -94,12 +88,6 @@ describe('DOI Type Selector', () => {
pressed: false,
})
).toBeInTheDocument();
expect(
screen.getByRole('button', {
name: 'my_doi_table.minter',
pressed: false,
})
).toBeInTheDocument();
expect(
screen.getByRole('button', {
name: 'my_doi_table.user',
Expand Down Expand Up @@ -147,11 +135,6 @@ describe('DOI Type Selector', () => {
name: 'all_doi_table.type_button_group_aria_label',
})
).toBeInTheDocument();
expect(
screen.queryByRole('button', {
name: /minter/,
})
).not.toBeInTheDocument();
expect(
screen.getByRole('button', {
name: 'all_doi_table.all',
Expand Down Expand Up @@ -242,23 +225,6 @@ describe('DOI Type Selector', () => {
});
});

it('updates filters when user or minter button is clicked after open or closed is selected', async () => {
vi.mocked(parseSearchToQuery, { partial: true }).mockReturnValue({
doiType: { view: 'all', open: false },
});
renderComponent('myDOIs');

await user.click(
screen.getByRole('button', {
name: 'my_doi_table.minter',
})
);

expect(mockPushQueryParams).toHaveBeenCalledWith({
doiType: { view: 'minter' },
});
});

it('parses current doiType from query params correctly', async () => {
vi.mocked(parseSearchToQuery, { partial: true }).mockReturnValue({
doiType: { view: 'user' },
Expand All @@ -272,12 +238,6 @@ describe('DOI Type Selector', () => {
pressed: true,
})
).toBeInTheDocument();
expect(
screen.getByRole('button', {
name: 'my_doi_table.minter',
pressed: false,
})
).toBeInTheDocument();
expect(
screen.getByRole('button', {
name: 'my_doi_table.session',
Expand Down
Loading
Loading