Skip to content

Commit 8d95f1d

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

File tree

4 files changed

+50
-24
lines changed

4 files changed

+50
-24
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

+30-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ test('warns user of unsaved changes if user attempts to open new file before sav
6666
notSavedPopup,
6767
resourcesTree,
6868
topBar,
69+
menuBar,
6970
}) => {
7071
const comment = faker.lorem.sentences();
7172
await resourcesTree.goto(resourceName1);
@@ -77,7 +78,7 @@ test('warns user of unsaved changes if user attempts to open new file before sav
7778
await notSavedPopup.cancelButton.click();
7879
await attributionDetails.attributionForm.assert.commentIs(comment);
7980

80-
await topBar.openFileButton.click();
81+
await menuBar.openFile();
8182
await notSavedPopup.assert.isVisible();
8283
});
8384

@@ -109,6 +110,34 @@ test('warns user of unsaved changes if user attempts to navigate away before sav
109110
await topBar.assert.reportViewIsActive();
110111
});
111112

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

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

+10-2
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,30 @@ export class MenuBar {
2222
await clickMenuItem(this.window.app, 'label', 'Project Metadata');
2323
}
2424

25+
async openFile(): Promise<void> {
26+
await clickMenuItem(this.window.app, 'label', 'Open File');
27+
}
28+
2529
async openProjectStatistics(): Promise<void> {
2630
await clickMenuItem(this.window.app, 'label', 'Project Statistics');
2731
}
2832

29-
async openImportLegacyOpossumFile(): Promise<void> {
33+
async importLegacyOpossumFile(): Promise<void> {
3034
await clickMenuItem(
3135
this.window.app,
3236
'label',
3337
'Legacy Opossum File (.json/.json.gz)',
3438
);
3539
}
3640

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

45+
async exportFollowUp(): Promise<void> {
46+
await clickMenuItem(this.window.app, 'label', 'Follow-Up');
47+
}
48+
4149
async toggleQaMode(): Promise<void> {
4250
await clickMenuItem(this.window.app, 'label', 'QA Mode');
4351
}

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)