Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reset license text #2726

Merged
merged 1 commit into from
Jan 30, 2025
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
2 changes: 0 additions & 2 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@
#
# SPDX-License-Identifier: Apache-2.0

. "$(dirname -- "$0")/_/husky.sh"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning in console that this line is deprecated and should be removed


yarn commitlint --edit ${1}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Please note, that there seem to be some issues with this plugin. It can help to

### Debugging the end-to-end tests

Each executed end-to-end test creates artifacts in the folder `src/e2e-tests/artifacts`. The artifacts contain the auto-generated .opossum file that the test was run against and, in case the test failed, a Playwright trace file.
Each executed end-to-end test creates artifacts in the folder `src/e2e-tests/artifacts`. The artifacts contain the auto-generated .opossum file that the test was run against and a Playwright trace file.

The trace file includes screenshots and DOM snapshots at each step of the test up to the failure. You can open this file (do not unzip it!) in your browser by going to the [Playwright Trace Viewer](https://trace.playwright.dev/).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export function PackageAutocomplete({
}, [attributeValue, inputValue]);

return (
<Autocomplete
<Autocomplete<PackageInfo, false, true, true>
title={title}
disabled={disabled}
readOnly={readOnly}
Expand Down Expand Up @@ -200,6 +200,20 @@ export function PackageAutocomplete({
secondary: (option) =>
typeof option === 'string' ? option : generatePurl(option),
}}
onChange={(_, value) =>
typeof value !== 'string' &&
value[attribute] !== packageInfo[attribute] &&
onEdit?.(() => {
dispatch(
setTemporaryDisplayPackageInfo({
...packageInfo,
[attribute]: value[attribute],
...(attribute === 'licenseName' ? { licenseText: '' } : null),
wasPreferred: undefined,
}),
);
})
}
onInputChange={(event, value) =>
event &&
packageInfo[attribute] !== value &&
Expand Down
32 changes: 17 additions & 15 deletions src/Frontend/Components/Autocomplete/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,25 +187,27 @@ export function Autocomplete<
]).length
}
size={'small'}
InputLabelProps={getInputLabelProps()}
inputRef={ref}
inputProps={{
'aria-label': props['aria-label'],
sx: {
overflowX: 'hidden',
textOverflow: 'ellipsis',
'&::placeholder': {
opacity: 1,
slotProps={{
input: {
startAdornment: startAdornment || renderStartAdornment(),
endAdornment: renderEndAdornment(),
readOnly,
sx,
...(variant === 'filled' && { disableUnderline: true }),
},
inputLabel: getInputLabelProps(),
htmlInput: {
'aria-label': props['aria-label'],
sx: {
overflowX: 'hidden',
textOverflow: 'ellipsis',
'&::placeholder': {
opacity: 1,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am assuming this just is another (preferrable) way to use the API and doesn't change anything.

},
},
}}
InputProps={{
startAdornment: startAdornment || renderStartAdornment(),
endAdornment: renderEndAdornment(),
readOnly,
sx,
...(variant === 'filled' && { disableUnderline: true }),
}}
onKeyDown={(event) => {
// https://github.com/mui/material-ui/issues/21129
event.key === 'Backspace' && event.stopPropagation();
Expand Down
17 changes: 17 additions & 0 deletions src/e2e-tests/__tests__/updating-attributions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,20 @@ test('switches correctly between previously-preferred and modified previously pr
await attributionDetails.attributionForm.comment.fill(faker.lorem.sentence());
await confirmationDialog.assert.isVisible();
});

test('resets custom license text when user selects suggested license expression', async ({
attributionDetails,
resourcesTree,
}) => {
const licenseText = faker.lorem.sentences();

await resourcesTree.goto(resourceName1);

await attributionDetails.attributionForm.licenseTextToggleButton.click();
await attributionDetails.attributionForm.licenseText.fill(licenseText);
await attributionDetails.attributionForm.assert.licenseTextIs(licenseText);

await attributionDetails.attributionForm.licenseName.click();
await attributionDetails.attributionForm.selectLicense(license1);
await attributionDetails.attributionForm.assert.licenseTextIs('');
});
5 changes: 1 addition & 4 deletions src/e2e-tests/page-objects/AttributionForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ export class AttributionForm {
this.licenseTextToggleButton = this.node.getByLabel(
'license-text-toggle-button',
);
this.licenseText = this.node.getByLabel(
text.attributionColumn.licenseText,
{ exact: true },
);
this.licenseText = this.node.getByLabel(text.attributionColumn.licenseText);
this.auditingLabels = {
criticalityLabel: this.node.getByTestId('auditing-option-criticality'),
confidenceLabel: this.node.getByTestId('auditing-option-confidence'),
Expand Down
8 changes: 3 additions & 5 deletions src/e2e-tests/utils/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,9 @@ export const test = base.extend<{
await use(Object.assign(window, { app }));

await window.context().tracing.stop({
path: info.error
? info.outputPath(
`${data?.inputData.metadata.projectId || 'app'}.trace.zip`,
)
: undefined,
path: info.outputPath(
`${data?.inputData.metadata.projectId || 'app'}.trace.zip`,
),
Comment on lines +98 to +100
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create trace even if test succeeds

});
await app.close();
},
Expand Down
Loading