Skip to content

Commit 7e3d860

Browse files
committed
test: add missing test and move all NotSavedPopup tests to updating-attributions.test.ts
1 parent 3422c70 commit 7e3d860

File tree

4 files changed

+44
-23
lines changed

4 files changed

+44
-23
lines changed

src/e2e-tests/__tests__/import-dialog.test.ts

+6-17
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,26 @@ test.use({
2222
outputData: faker.opossum.outputData({}),
2323
provideImportFiles: true,
2424
},
25-
isImportFileTest: true,
25+
openFromCLI: false,
2626
});
2727

2828
test('opens, displays and closes import dialog', async ({
2929
menuBar,
3030
importDialog,
3131
}) => {
32-
await menuBar.openImportLegacyOpossumFile();
32+
await menuBar.importLegacyOpossumFile();
3333
await importDialog.assert.titleIsVisible();
3434

3535
await importDialog.cancelButton.click();
3636

3737
await importDialog.assert.titleIsHidden();
3838
});
3939

40-
test('imports legacy opossum file and checks for unsaved changes', async ({
40+
test('imports legacy opossum file', async ({
4141
menuBar,
4242
importDialog,
4343
resourcesTree,
4444
window,
45-
attributionDetails,
46-
notSavedPopup,
4745
}) => {
4846
await stubDialog(window.app, 'showOpenDialogSync', [
4947
importDialog.legacyFilePath,
@@ -54,7 +52,7 @@ test('imports legacy opossum file and checks for unsaved changes', async ({
5452
getDotOpossumFilePath(importDialog.legacyFilePath, ['json', 'json.gz']),
5553
);
5654

57-
await menuBar.openImportLegacyOpossumFile();
55+
await menuBar.importLegacyOpossumFile();
5856
await importDialog.assert.titleIsVisible();
5957

6058
await importDialog.inputFileSelection.click();
@@ -63,15 +61,6 @@ test('imports legacy opossum file and checks for unsaved changes', async ({
6361

6462
await importDialog.assert.titleIsHidden();
6563
await resourcesTree.assert.resourceIsVisible(resourceName);
66-
67-
const comment = faker.lorem.sentences();
68-
await resourcesTree.goto(resourceName);
69-
await attributionDetails.attributionForm.comment.fill(comment);
70-
71-
await menuBar.openImportLegacyOpossumFile();
72-
await notSavedPopup.assert.isVisible();
73-
await notSavedPopup.discardButton.click();
74-
await importDialog.assert.titleIsVisible();
7564
});
7665

7766
test('imports scancode file', async ({
@@ -89,7 +78,7 @@ test('imports scancode file', async ({
8978
getDotOpossumFilePath(importDialog.scancodeFilePath, ['json']),
9079
);
9180

92-
await menuBar.openImportScanCodeFile();
81+
await menuBar.importScanCodeFile();
9382
await importDialog.assert.titleIsVisible();
9483

9584
await importDialog.inputFileSelection.click();
@@ -104,7 +93,7 @@ test('shows error when no file path is set', async ({
10493
menuBar,
10594
importDialog,
10695
}) => {
107-
await menuBar.openImportLegacyOpossumFile();
96+
await menuBar.importLegacyOpossumFile();
10897
await importDialog.assert.titleIsVisible();
10998

11099
await importDialog.importButton.click();

src/e2e-tests/__tests__/updating-attributions.test.ts

+28
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,34 @@ test('warns user of unsaved changes if user attempts to navigate away before sav
109109
await topBar.assert.reportViewIsActive();
110110
});
111111

112+
test('warns user of unsaved changes if user attempts to import new file before saving', async ({
113+
attributionDetails,
114+
notSavedPopup,
115+
resourcesTree,
116+
menuBar,
117+
}) => {
118+
const comment = faker.lorem.sentences();
119+
await resourcesTree.goto(resourceName1);
120+
await attributionDetails.attributionForm.comment.fill(comment);
121+
122+
await menuBar.importLegacyOpossumFile();
123+
await notSavedPopup.assert.isVisible();
124+
});
125+
126+
test('warns user of unsaved changes if user attempts to export data before saving', async ({
127+
attributionDetails,
128+
notSavedPopup,
129+
resourcesTree,
130+
menuBar,
131+
}) => {
132+
const comment = faker.lorem.sentences();
133+
await resourcesTree.goto(resourceName1);
134+
await attributionDetails.attributionForm.comment.fill(comment);
135+
136+
await menuBar.exportFollowUp();
137+
await notSavedPopup.assert.isVisible();
138+
});
139+
112140
test('allows user to update an attribution on the selected resource only', async ({
113141
attributionDetails,
114142
resourcesTree,

src/e2e-tests/page-objects/MenuBar.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,22 @@ export class MenuBar {
2626
await clickMenuItem(this.window.app, 'label', 'Project Statistics');
2727
}
2828

29-
async openImportLegacyOpossumFile(): Promise<void> {
29+
async importLegacyOpossumFile(): Promise<void> {
3030
await clickMenuItem(
3131
this.window.app,
3232
'label',
3333
'Legacy Opossum File (.json/.json.gz)',
3434
);
3535
}
3636

37-
async openImportScanCodeFile(): Promise<void> {
37+
async importScanCodeFile(): Promise<void> {
3838
await clickMenuItem(this.window.app, 'label', 'ScanCode File (.json)');
3939
}
4040

41+
async exportFollowUp(): Promise<void> {
42+
await clickMenuItem(this.window.app, 'label', 'Follow-Up');
43+
}
44+
4145
async toggleQaMode(): Promise<void> {
4246
await clickMenuItem(this.window.app, 'label', 'QA Mode');
4347
}

src/e2e-tests/utils/fixtures.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const test = base.extend<{
6767
linkedResourcesTree: LinkedResourcesTree;
6868
menuBar: MenuBar;
6969
notSavedPopup: NotSavedPopup;
70-
isImportFileTest: boolean;
70+
openFromCLI: boolean;
7171
pathBar: PathBar;
7272
projectMetadataPopup: ProjectMetadataPopup;
7373
projectStatisticsPopup: ProjectStatisticsPopup;
@@ -77,8 +77,8 @@ export const test = base.extend<{
7777
topBar: TopBar;
7878
}>({
7979
data: undefined,
80-
isImportFileTest: false,
81-
window: async ({ data, isImportFileTest }, use, info) => {
80+
openFromCLI: true,
81+
window: async ({ data, openFromCLI }, use, info) => {
8282
const filePath = data && (await createTestFile({ data, info }));
8383

8484
const [executablePath, main] = getLaunchProps();
@@ -90,7 +90,7 @@ export const test = base.extend<{
9090
const app = await electron.launch({
9191
args: [
9292
main,
93-
...(!filePath || isImportFileTest ? args : args.concat([filePath])),
93+
...(!filePath || !openFromCLI ? args : args.concat([filePath])),
9494
],
9595
executablePath,
9696
});

0 commit comments

Comments
 (0)